@veridid/workflow-ui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (430) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +202 -2
  3. package/build/module/WorkflowFontScaleContext.js +67 -0
  4. package/build/module/WorkflowFontScaleContext.js.map +1 -0
  5. package/build/module/adapter/WalletAdapter.js +152 -0
  6. package/build/module/adapter/WalletAdapter.js.map +1 -0
  7. package/build/module/components/FallbackVideoPlayer.js +8 -0
  8. package/build/module/components/FallbackVideoPlayer.js.map +1 -0
  9. package/build/module/components/FallbackVideoPlayer.native.js +10 -0
  10. package/build/module/components/FallbackVideoPlayer.native.js.map +1 -0
  11. package/build/module/components/FallbackVideoPlayer.web.js +35 -0
  12. package/build/module/components/FallbackVideoPlayer.web.js.map +1 -0
  13. package/build/module/components/WorkflowButtonLabel.js +32 -0
  14. package/build/module/components/WorkflowButtonLabel.js.map +1 -0
  15. package/build/module/components/WorkflowCalendarIcon.js +73 -0
  16. package/build/module/components/WorkflowCalendarIcon.js.map +1 -0
  17. package/build/module/components/WorkflowText.js +92 -0
  18. package/build/module/components/WorkflowText.js.map +1 -0
  19. package/build/module/content/BadgeContent.js +73 -0
  20. package/build/module/content/BadgeContent.js.map +1 -0
  21. package/build/module/content/BarChartContent.js +97 -0
  22. package/build/module/content/BarChartContent.js.map +1 -0
  23. package/build/module/content/BarcodeContent.js +78 -0
  24. package/build/module/content/BarcodeContent.js.map +1 -0
  25. package/build/module/content/BasicTableContent.js +145 -0
  26. package/build/module/content/BasicTableContent.js.map +1 -0
  27. package/build/module/content/ButtonContent.js +130 -0
  28. package/build/module/content/ButtonContent.js.map +1 -0
  29. package/build/module/content/CalendarContent.js +173 -0
  30. package/build/module/content/CalendarContent.js.map +1 -0
  31. package/build/module/content/CardContent.js +114 -0
  32. package/build/module/content/CardContent.js.map +1 -0
  33. package/build/module/content/CarouselContent.js +173 -0
  34. package/build/module/content/CarouselContent.js.map +1 -0
  35. package/build/module/content/ChipContent.js +214 -0
  36. package/build/module/content/ChipContent.js.map +1 -0
  37. package/build/module/content/ChipRowContent.js +127 -0
  38. package/build/module/content/ChipRowContent.js.map +1 -0
  39. package/build/module/content/CredentialOfferContent.js +312 -0
  40. package/build/module/content/CredentialOfferContent.js.map +1 -0
  41. package/build/module/content/DialContent.js +101 -0
  42. package/build/module/content/DialContent.js.map +1 -0
  43. package/build/module/content/DividerContent.js +26 -0
  44. package/build/module/content/DividerContent.js.map +1 -0
  45. package/build/module/content/DonutChartContent.js +118 -0
  46. package/build/module/content/DonutChartContent.js.map +1 -0
  47. package/build/module/content/FormContent.js +141 -0
  48. package/build/module/content/FormContent.js.map +1 -0
  49. package/build/module/content/FormFieldBridge.js +157 -0
  50. package/build/module/content/FormFieldBridge.js.map +1 -0
  51. package/build/module/content/GaugeContent.js +77 -0
  52. package/build/module/content/GaugeContent.js.map +1 -0
  53. package/build/module/content/GridLayoutContent.js +227 -0
  54. package/build/module/content/GridLayoutContent.js.map +1 -0
  55. package/build/module/content/ImageContent.js +190 -0
  56. package/build/module/content/ImageContent.js.map +1 -0
  57. package/build/module/content/ListContent.js +107 -0
  58. package/build/module/content/ListContent.js.map +1 -0
  59. package/build/module/content/LocationContent.js +148 -0
  60. package/build/module/content/LocationContent.js.map +1 -0
  61. package/build/module/content/MapContent.js +213 -0
  62. package/build/module/content/MapContent.js.map +1 -0
  63. package/build/module/content/MultipleChoiceContent.js +91 -0
  64. package/build/module/content/MultipleChoiceContent.js.map +1 -0
  65. package/build/module/content/OpenBadgePreviewContent.js +141 -0
  66. package/build/module/content/OpenBadgePreviewContent.js.map +1 -0
  67. package/build/module/content/PhotoContent.js +154 -0
  68. package/build/module/content/PhotoContent.js.map +1 -0
  69. package/build/module/content/PieChartContent.js +129 -0
  70. package/build/module/content/PieChartContent.js.map +1 -0
  71. package/build/module/content/ProofPresentationContent.js +154 -0
  72. package/build/module/content/ProofPresentationContent.js.map +1 -0
  73. package/build/module/content/RadioButtonContent.js +136 -0
  74. package/build/module/content/RadioButtonContent.js.map +1 -0
  75. package/build/module/content/RowContent.js +539 -0
  76. package/build/module/content/RowContent.js.map +1 -0
  77. package/build/module/content/SectionContent.js +123 -0
  78. package/build/module/content/SectionContent.js.map +1 -0
  79. package/build/module/content/ShareEntryContent.js +111 -0
  80. package/build/module/content/ShareEntryContent.js.map +1 -0
  81. package/build/module/content/SimulatedHint.js +33 -0
  82. package/build/module/content/SimulatedHint.js.map +1 -0
  83. package/build/module/content/SliderContent.js +46 -0
  84. package/build/module/content/SliderContent.js.map +1 -0
  85. package/build/module/content/SpacerContent.js +21 -0
  86. package/build/module/content/SpacerContent.js.map +1 -0
  87. package/build/module/content/SpinnerContent.js +33 -0
  88. package/build/module/content/SpinnerContent.js.map +1 -0
  89. package/build/module/content/SubmitButtonContent.js +281 -0
  90. package/build/module/content/SubmitButtonContent.js.map +1 -0
  91. package/build/module/content/TextContent.js +127 -0
  92. package/build/module/content/TextContent.js.map +1 -0
  93. package/build/module/content/TileContent.js +237 -0
  94. package/build/module/content/TileContent.js.map +1 -0
  95. package/build/module/content/TimelineContent.js +120 -0
  96. package/build/module/content/TimelineContent.js.map +1 -0
  97. package/build/module/content/TitleContent.js +55 -0
  98. package/build/module/content/TitleContent.js.map +1 -0
  99. package/build/module/content/VideoContent.js +142 -0
  100. package/build/module/content/VideoContent.js.map +1 -0
  101. package/build/module/content/WebLinkContent.js +95 -0
  102. package/build/module/content/WebLinkContent.js.map +1 -0
  103. package/build/module/content/index.js +48 -0
  104. package/build/module/content/index.js.map +1 -0
  105. package/build/module/form-fields/CheckboxField.js +47 -0
  106. package/build/module/form-fields/CheckboxField.js.map +1 -0
  107. package/build/module/form-fields/DateField.js +8 -0
  108. package/build/module/form-fields/DateField.js.map +1 -0
  109. package/build/module/form-fields/DateField.native.js +141 -0
  110. package/build/module/form-fields/DateField.native.js.map +1 -0
  111. package/build/module/form-fields/DateField.web.js +45 -0
  112. package/build/module/form-fields/DateField.web.js.map +1 -0
  113. package/build/module/form-fields/DropdownField.js +172 -0
  114. package/build/module/form-fields/DropdownField.js.map +1 -0
  115. package/build/module/form-fields/MCQField.js +100 -0
  116. package/build/module/form-fields/MCQField.js.map +1 -0
  117. package/build/module/form-fields/RadioField.js +56 -0
  118. package/build/module/form-fields/RadioField.js.map +1 -0
  119. package/build/module/form-fields/SliderField.js +8 -0
  120. package/build/module/form-fields/SliderField.js.map +1 -0
  121. package/build/module/form-fields/SliderField.native.js +77 -0
  122. package/build/module/form-fields/SliderField.native.js.map +1 -0
  123. package/build/module/form-fields/SliderField.web.js +82 -0
  124. package/build/module/form-fields/SliderField.web.js.map +1 -0
  125. package/build/module/form-fields/SubmitButtonField.js +42 -0
  126. package/build/module/form-fields/SubmitButtonField.js.map +1 -0
  127. package/build/module/form-fields/TextField.js +56 -0
  128. package/build/module/form-fields/TextField.js.map +1 -0
  129. package/build/module/form-fields/index.js +15 -0
  130. package/build/module/form-fields/index.js.map +1 -0
  131. package/build/module/i18n/WorkflowI18n.js +94 -0
  132. package/build/module/i18n/WorkflowI18n.js.map +1 -0
  133. package/build/module/icons/WorkflowIcon.js +50 -0
  134. package/build/module/icons/WorkflowIcon.js.map +1 -0
  135. package/build/module/imageUriCache.js +25 -0
  136. package/build/module/imageUriCache.js.map +1 -0
  137. package/build/module/index.js +49 -0
  138. package/build/module/index.js.map +1 -0
  139. package/build/module/modal/WorkflowModal.js +115 -0
  140. package/build/module/modal/WorkflowModal.js.map +1 -0
  141. package/build/module/package.json +1 -0
  142. package/build/module/platform/platformName.js +10 -0
  143. package/build/module/platform/platformName.js.map +1 -0
  144. package/build/module/platform/platformName.web.js +5 -0
  145. package/build/module/platform/platformName.web.js.map +1 -0
  146. package/build/module/protocol/controlSnapshotStore.js +19 -0
  147. package/build/module/protocol/controlSnapshotStore.js.map +1 -0
  148. package/build/module/protocol/useProtocolExchange.js +168 -0
  149. package/build/module/protocol/useProtocolExchange.js.map +1 -0
  150. package/build/module/registries/ContentRegistry.js +53 -0
  151. package/build/module/registries/ContentRegistry.js.map +1 -0
  152. package/build/module/registries/FormFieldRegistry.js +56 -0
  153. package/build/module/registries/FormFieldRegistry.js.map +1 -0
  154. package/build/module/render/NodeBoundary.js +73 -0
  155. package/build/module/render/NodeBoundary.js.map +1 -0
  156. package/build/module/render/RenderTree.js +52 -0
  157. package/build/module/render/RenderTree.js.map +1 -0
  158. package/build/module/render/WorkflowRenderContext.js +34 -0
  159. package/build/module/render/WorkflowRenderContext.js.map +1 -0
  160. package/build/module/render/nodes.js +103 -0
  161. package/build/module/render/nodes.js.map +1 -0
  162. package/build/module/responsive/ResponsiveProvider.js +63 -0
  163. package/build/module/responsive/ResponsiveProvider.js.map +1 -0
  164. package/build/module/responsive/index.js +4 -0
  165. package/build/module/responsive/index.js.map +1 -0
  166. package/build/module/responsive/responsive.js +56 -0
  167. package/build/module/responsive/responsive.js.map +1 -0
  168. package/build/module/style/resolveDisplayHintStyle.js +145 -0
  169. package/build/module/style/resolveDisplayHintStyle.js.map +1 -0
  170. package/build/module/theme/WorkflowTheme.js +200 -0
  171. package/build/module/theme/WorkflowTheme.js.map +1 -0
  172. package/build/module/utils/testable.js +12 -0
  173. package/build/module/utils/testable.js.map +1 -0
  174. package/build/typescript/WorkflowFontScaleContext.d.ts +7 -0
  175. package/build/typescript/WorkflowFontScaleContext.d.ts.map +1 -0
  176. package/build/typescript/adapter/WalletAdapter.d.ts +145 -0
  177. package/build/typescript/adapter/WalletAdapter.d.ts.map +1 -0
  178. package/build/typescript/components/FallbackVideoPlayer.d.ts +6 -0
  179. package/build/typescript/components/FallbackVideoPlayer.d.ts.map +1 -0
  180. package/build/typescript/components/FallbackVideoPlayer.native.d.ts +7 -0
  181. package/build/typescript/components/FallbackVideoPlayer.native.d.ts.map +1 -0
  182. package/build/typescript/components/FallbackVideoPlayer.web.d.ts +9 -0
  183. package/build/typescript/components/FallbackVideoPlayer.web.d.ts.map +1 -0
  184. package/build/typescript/components/WorkflowButtonLabel.d.ts +11 -0
  185. package/build/typescript/components/WorkflowButtonLabel.d.ts.map +1 -0
  186. package/build/typescript/components/WorkflowCalendarIcon.d.ts +11 -0
  187. package/build/typescript/components/WorkflowCalendarIcon.d.ts.map +1 -0
  188. package/build/typescript/components/WorkflowText.d.ts +13 -0
  189. package/build/typescript/components/WorkflowText.d.ts.map +1 -0
  190. package/build/typescript/content/BadgeContent.d.ts +5 -0
  191. package/build/typescript/content/BadgeContent.d.ts.map +1 -0
  192. package/build/typescript/content/BarChartContent.d.ts +5 -0
  193. package/build/typescript/content/BarChartContent.d.ts.map +1 -0
  194. package/build/typescript/content/BarcodeContent.d.ts +11 -0
  195. package/build/typescript/content/BarcodeContent.d.ts.map +1 -0
  196. package/build/typescript/content/BasicTableContent.d.ts +5 -0
  197. package/build/typescript/content/BasicTableContent.d.ts.map +1 -0
  198. package/build/typescript/content/ButtonContent.d.ts +5 -0
  199. package/build/typescript/content/ButtonContent.d.ts.map +1 -0
  200. package/build/typescript/content/CalendarContent.d.ts +19 -0
  201. package/build/typescript/content/CalendarContent.d.ts.map +1 -0
  202. package/build/typescript/content/CardContent.d.ts +5 -0
  203. package/build/typescript/content/CardContent.d.ts.map +1 -0
  204. package/build/typescript/content/CarouselContent.d.ts +5 -0
  205. package/build/typescript/content/CarouselContent.d.ts.map +1 -0
  206. package/build/typescript/content/ChipContent.d.ts +5 -0
  207. package/build/typescript/content/ChipContent.d.ts.map +1 -0
  208. package/build/typescript/content/ChipRowContent.d.ts +8 -0
  209. package/build/typescript/content/ChipRowContent.d.ts.map +1 -0
  210. package/build/typescript/content/CredentialOfferContent.d.ts +98 -0
  211. package/build/typescript/content/CredentialOfferContent.d.ts.map +1 -0
  212. package/build/typescript/content/DialContent.d.ts +5 -0
  213. package/build/typescript/content/DialContent.d.ts.map +1 -0
  214. package/build/typescript/content/DividerContent.d.ts +5 -0
  215. package/build/typescript/content/DividerContent.d.ts.map +1 -0
  216. package/build/typescript/content/DonutChartContent.d.ts +5 -0
  217. package/build/typescript/content/DonutChartContent.d.ts.map +1 -0
  218. package/build/typescript/content/FormContent.d.ts +19 -0
  219. package/build/typescript/content/FormContent.d.ts.map +1 -0
  220. package/build/typescript/content/FormFieldBridge.d.ts +2 -0
  221. package/build/typescript/content/FormFieldBridge.d.ts.map +1 -0
  222. package/build/typescript/content/GaugeContent.d.ts +5 -0
  223. package/build/typescript/content/GaugeContent.d.ts.map +1 -0
  224. package/build/typescript/content/GridLayoutContent.d.ts +5 -0
  225. package/build/typescript/content/GridLayoutContent.d.ts.map +1 -0
  226. package/build/typescript/content/ImageContent.d.ts +5 -0
  227. package/build/typescript/content/ImageContent.d.ts.map +1 -0
  228. package/build/typescript/content/ListContent.d.ts +5 -0
  229. package/build/typescript/content/ListContent.d.ts.map +1 -0
  230. package/build/typescript/content/LocationContent.d.ts +32 -0
  231. package/build/typescript/content/LocationContent.d.ts.map +1 -0
  232. package/build/typescript/content/MapContent.d.ts +11 -0
  233. package/build/typescript/content/MapContent.d.ts.map +1 -0
  234. package/build/typescript/content/MultipleChoiceContent.d.ts +5 -0
  235. package/build/typescript/content/MultipleChoiceContent.d.ts.map +1 -0
  236. package/build/typescript/content/OpenBadgePreviewContent.d.ts +14 -0
  237. package/build/typescript/content/OpenBadgePreviewContent.d.ts.map +1 -0
  238. package/build/typescript/content/PhotoContent.d.ts +57 -0
  239. package/build/typescript/content/PhotoContent.d.ts.map +1 -0
  240. package/build/typescript/content/PieChartContent.d.ts +5 -0
  241. package/build/typescript/content/PieChartContent.d.ts.map +1 -0
  242. package/build/typescript/content/ProofPresentationContent.d.ts +14 -0
  243. package/build/typescript/content/ProofPresentationContent.d.ts.map +1 -0
  244. package/build/typescript/content/RadioButtonContent.d.ts +5 -0
  245. package/build/typescript/content/RadioButtonContent.d.ts.map +1 -0
  246. package/build/typescript/content/RowContent.d.ts +5 -0
  247. package/build/typescript/content/RowContent.d.ts.map +1 -0
  248. package/build/typescript/content/SectionContent.d.ts +5 -0
  249. package/build/typescript/content/SectionContent.d.ts.map +1 -0
  250. package/build/typescript/content/ShareEntryContent.d.ts +15 -0
  251. package/build/typescript/content/ShareEntryContent.d.ts.map +1 -0
  252. package/build/typescript/content/SimulatedHint.d.ts +9 -0
  253. package/build/typescript/content/SimulatedHint.d.ts.map +1 -0
  254. package/build/typescript/content/SliderContent.d.ts +10 -0
  255. package/build/typescript/content/SliderContent.d.ts.map +1 -0
  256. package/build/typescript/content/SpacerContent.d.ts +5 -0
  257. package/build/typescript/content/SpacerContent.d.ts.map +1 -0
  258. package/build/typescript/content/SpinnerContent.d.ts +5 -0
  259. package/build/typescript/content/SpinnerContent.d.ts.map +1 -0
  260. package/build/typescript/content/SubmitButtonContent.d.ts +9 -0
  261. package/build/typescript/content/SubmitButtonContent.d.ts.map +1 -0
  262. package/build/typescript/content/TextContent.d.ts +5 -0
  263. package/build/typescript/content/TextContent.d.ts.map +1 -0
  264. package/build/typescript/content/TileContent.d.ts +5 -0
  265. package/build/typescript/content/TileContent.d.ts.map +1 -0
  266. package/build/typescript/content/TimelineContent.d.ts +5 -0
  267. package/build/typescript/content/TimelineContent.d.ts.map +1 -0
  268. package/build/typescript/content/TitleContent.d.ts +5 -0
  269. package/build/typescript/content/TitleContent.d.ts.map +1 -0
  270. package/build/typescript/content/VideoContent.d.ts +10 -0
  271. package/build/typescript/content/VideoContent.d.ts.map +1 -0
  272. package/build/typescript/content/WebLinkContent.d.ts +5 -0
  273. package/build/typescript/content/WebLinkContent.d.ts.map +1 -0
  274. package/build/typescript/content/index.d.ts +46 -0
  275. package/build/typescript/content/index.d.ts.map +1 -0
  276. package/build/typescript/form-fields/CheckboxField.d.ts +5 -0
  277. package/build/typescript/form-fields/CheckboxField.d.ts.map +1 -0
  278. package/build/typescript/form-fields/DateField.d.ts +6 -0
  279. package/build/typescript/form-fields/DateField.d.ts.map +1 -0
  280. package/build/typescript/form-fields/DateField.native.d.ts +5 -0
  281. package/build/typescript/form-fields/DateField.native.d.ts.map +1 -0
  282. package/build/typescript/form-fields/DateField.web.d.ts +9 -0
  283. package/build/typescript/form-fields/DateField.web.d.ts.map +1 -0
  284. package/build/typescript/form-fields/DropdownField.d.ts +5 -0
  285. package/build/typescript/form-fields/DropdownField.d.ts.map +1 -0
  286. package/build/typescript/form-fields/MCQField.d.ts +5 -0
  287. package/build/typescript/form-fields/MCQField.d.ts.map +1 -0
  288. package/build/typescript/form-fields/RadioField.d.ts +5 -0
  289. package/build/typescript/form-fields/RadioField.d.ts.map +1 -0
  290. package/build/typescript/form-fields/SliderField.d.ts +6 -0
  291. package/build/typescript/form-fields/SliderField.d.ts.map +1 -0
  292. package/build/typescript/form-fields/SliderField.native.d.ts +5 -0
  293. package/build/typescript/form-fields/SliderField.native.d.ts.map +1 -0
  294. package/build/typescript/form-fields/SliderField.web.d.ts +11 -0
  295. package/build/typescript/form-fields/SliderField.web.d.ts.map +1 -0
  296. package/build/typescript/form-fields/SubmitButtonField.d.ts +5 -0
  297. package/build/typescript/form-fields/SubmitButtonField.d.ts.map +1 -0
  298. package/build/typescript/form-fields/TextField.d.ts +5 -0
  299. package/build/typescript/form-fields/TextField.d.ts.map +1 -0
  300. package/build/typescript/form-fields/index.d.ts +13 -0
  301. package/build/typescript/form-fields/index.d.ts.map +1 -0
  302. package/build/typescript/i18n/WorkflowI18n.d.ts +75 -0
  303. package/build/typescript/i18n/WorkflowI18n.d.ts.map +1 -0
  304. package/build/typescript/icons/WorkflowIcon.d.ts +27 -0
  305. package/build/typescript/icons/WorkflowIcon.d.ts.map +1 -0
  306. package/build/typescript/imageUriCache.d.ts +7 -0
  307. package/build/typescript/imageUriCache.d.ts.map +1 -0
  308. package/build/typescript/index.d.ts +47 -0
  309. package/build/typescript/index.d.ts.map +1 -0
  310. package/build/typescript/modal/WorkflowModal.d.ts +33 -0
  311. package/build/typescript/modal/WorkflowModal.d.ts.map +1 -0
  312. package/build/typescript/package.json +1 -0
  313. package/build/typescript/platform/platformName.d.ts +8 -0
  314. package/build/typescript/platform/platformName.d.ts.map +1 -0
  315. package/build/typescript/platform/platformName.web.d.ts +3 -0
  316. package/build/typescript/platform/platformName.web.d.ts.map +1 -0
  317. package/build/typescript/protocol/controlSnapshotStore.d.ts +12 -0
  318. package/build/typescript/protocol/controlSnapshotStore.d.ts.map +1 -0
  319. package/build/typescript/protocol/useProtocolExchange.d.ts +40 -0
  320. package/build/typescript/protocol/useProtocolExchange.d.ts.map +1 -0
  321. package/build/typescript/registries/ContentRegistry.d.ts +57 -0
  322. package/build/typescript/registries/ContentRegistry.d.ts.map +1 -0
  323. package/build/typescript/registries/FormFieldRegistry.d.ts +37 -0
  324. package/build/typescript/registries/FormFieldRegistry.d.ts.map +1 -0
  325. package/build/typescript/render/NodeBoundary.d.ts +25 -0
  326. package/build/typescript/render/NodeBoundary.d.ts.map +1 -0
  327. package/build/typescript/render/RenderTree.d.ts +23 -0
  328. package/build/typescript/render/RenderTree.d.ts.map +1 -0
  329. package/build/typescript/render/WorkflowRenderContext.d.ts +57 -0
  330. package/build/typescript/render/WorkflowRenderContext.d.ts.map +1 -0
  331. package/build/typescript/render/nodes.d.ts +49 -0
  332. package/build/typescript/render/nodes.d.ts.map +1 -0
  333. package/build/typescript/responsive/ResponsiveProvider.d.ts +39 -0
  334. package/build/typescript/responsive/ResponsiveProvider.d.ts.map +1 -0
  335. package/build/typescript/responsive/index.d.ts +3 -0
  336. package/build/typescript/responsive/index.d.ts.map +1 -0
  337. package/build/typescript/responsive/responsive.d.ts +24 -0
  338. package/build/typescript/responsive/responsive.d.ts.map +1 -0
  339. package/build/typescript/style/resolveDisplayHintStyle.d.ts +23 -0
  340. package/build/typescript/style/resolveDisplayHintStyle.d.ts.map +1 -0
  341. package/build/typescript/theme/WorkflowTheme.d.ts +177 -0
  342. package/build/typescript/theme/WorkflowTheme.d.ts.map +1 -0
  343. package/build/typescript/utils/testable.d.ts +8 -0
  344. package/build/typescript/utils/testable.d.ts.map +1 -0
  345. package/package.json +101 -3
  346. package/src/WorkflowFontScaleContext.tsx +74 -0
  347. package/src/adapter/WalletAdapter.tsx +225 -0
  348. package/src/components/FallbackVideoPlayer.native.tsx +9 -0
  349. package/src/components/FallbackVideoPlayer.tsx +5 -0
  350. package/src/components/FallbackVideoPlayer.web.tsx +24 -0
  351. package/src/components/WorkflowButtonLabel.tsx +41 -0
  352. package/src/components/WorkflowCalendarIcon.tsx +52 -0
  353. package/src/components/WorkflowText.tsx +121 -0
  354. package/src/content/BadgeContent.tsx +57 -0
  355. package/src/content/BarChartContent.tsx +76 -0
  356. package/src/content/BarcodeContent.tsx +59 -0
  357. package/src/content/BasicTableContent.tsx +139 -0
  358. package/src/content/ButtonContent.tsx +124 -0
  359. package/src/content/CalendarContent.tsx +178 -0
  360. package/src/content/CardContent.tsx +137 -0
  361. package/src/content/CarouselContent.tsx +197 -0
  362. package/src/content/ChipContent.tsx +209 -0
  363. package/src/content/ChipRowContent.tsx +133 -0
  364. package/src/content/CredentialOfferContent.tsx +229 -0
  365. package/src/content/DialContent.tsx +96 -0
  366. package/src/content/DividerContent.tsx +33 -0
  367. package/src/content/DonutChartContent.tsx +110 -0
  368. package/src/content/FormContent.tsx +158 -0
  369. package/src/content/FormFieldBridge.tsx +144 -0
  370. package/src/content/GaugeContent.tsx +66 -0
  371. package/src/content/GridLayoutContent.tsx +285 -0
  372. package/src/content/ImageContent.tsx +222 -0
  373. package/src/content/ListContent.tsx +98 -0
  374. package/src/content/LocationContent.tsx +135 -0
  375. package/src/content/MapContent.tsx +232 -0
  376. package/src/content/MultipleChoiceContent.tsx +74 -0
  377. package/src/content/OpenBadgePreviewContent.tsx +93 -0
  378. package/src/content/PhotoContent.tsx +110 -0
  379. package/src/content/PieChartContent.tsx +121 -0
  380. package/src/content/ProofPresentationContent.tsx +127 -0
  381. package/src/content/RadioButtonContent.tsx +129 -0
  382. package/src/content/RowContent.tsx +627 -0
  383. package/src/content/SectionContent.tsx +133 -0
  384. package/src/content/ShareEntryContent.tsx +109 -0
  385. package/src/content/SimulatedHint.tsx +20 -0
  386. package/src/content/SliderContent.tsx +56 -0
  387. package/src/content/SpacerContent.tsx +15 -0
  388. package/src/content/SpinnerContent.tsx +24 -0
  389. package/src/content/SubmitButtonContent.tsx +256 -0
  390. package/src/content/TextContent.tsx +140 -0
  391. package/src/content/TileContent.tsx +216 -0
  392. package/src/content/TimelineContent.tsx +91 -0
  393. package/src/content/TitleContent.tsx +49 -0
  394. package/src/content/VideoContent.tsx +131 -0
  395. package/src/content/WebLinkContent.tsx +87 -0
  396. package/src/content/index.ts +45 -0
  397. package/src/form-fields/CheckboxField.tsx +29 -0
  398. package/src/form-fields/DateField.native.tsx +123 -0
  399. package/src/form-fields/DateField.tsx +5 -0
  400. package/src/form-fields/DateField.web.tsx +32 -0
  401. package/src/form-fields/DropdownField.tsx +137 -0
  402. package/src/form-fields/MCQField.tsx +68 -0
  403. package/src/form-fields/RadioField.tsx +53 -0
  404. package/src/form-fields/SliderField.native.tsx +53 -0
  405. package/src/form-fields/SliderField.tsx +5 -0
  406. package/src/form-fields/SliderField.web.tsx +58 -0
  407. package/src/form-fields/SubmitButtonField.tsx +33 -0
  408. package/src/form-fields/TextField.tsx +49 -0
  409. package/src/form-fields/index.ts +12 -0
  410. package/src/i18n/WorkflowI18n.tsx +100 -0
  411. package/src/icons/WorkflowIcon.tsx +43 -0
  412. package/src/imageUriCache.ts +27 -0
  413. package/src/index.ts +96 -0
  414. package/src/modal/WorkflowModal.tsx +119 -0
  415. package/src/platform/platformName.ts +7 -0
  416. package/src/platform/platformName.web.ts +2 -0
  417. package/src/protocol/controlSnapshotStore.ts +25 -0
  418. package/src/protocol/useProtocolExchange.ts +185 -0
  419. package/src/registries/ContentRegistry.tsx +130 -0
  420. package/src/registries/FormFieldRegistry.tsx +83 -0
  421. package/src/render/NodeBoundary.tsx +69 -0
  422. package/src/render/RenderTree.tsx +63 -0
  423. package/src/render/WorkflowRenderContext.tsx +71 -0
  424. package/src/render/nodes.ts +104 -0
  425. package/src/responsive/ResponsiveProvider.tsx +103 -0
  426. package/src/responsive/index.ts +7 -0
  427. package/src/responsive/responsive.ts +67 -0
  428. package/src/style/resolveDisplayHintStyle.ts +153 -0
  429. package/src/theme/WorkflowTheme.tsx +162 -0
  430. package/src/utils/testable.ts +10 -0
@@ -0,0 +1,222 @@
1
+ import React, { useEffect, useState } from 'react'
2
+ import type { DimensionValue } from 'react-native'
3
+ import { Image, type LayoutChangeEvent, StyleSheet, View } from 'react-native'
4
+ import WorkflowText from '../components/WorkflowText'
5
+ import { WorkflowIcon } from '../icons/WorkflowIcon'
6
+ import { prefetchImageUri } from '../imageUriCache'
7
+ import { type ContentProps, ContentRegistry } from '../registries/ContentRegistry'
8
+ import { useResponsive } from '../responsive'
9
+ import { resolveAspectRatio, resolveItemSurfaceStyle } from '../style/resolveDisplayHintStyle'
10
+
11
+ const resolveImageUrl = (item: ContentProps['item']): string | undefined => {
12
+ const raw =
13
+ (typeof item.url === 'string' && item.url) ||
14
+ (typeof item.src === 'string' && item.src) ||
15
+ (typeof item.image === 'string' && item.image) ||
16
+ undefined
17
+ const trimmed = raw?.trim()
18
+ return trimmed ? trimmed : undefined
19
+ }
20
+
21
+ const ImageErrorFrame: React.FC<{
22
+ width?: number | string
23
+ height: number
24
+ maxWidth?: number
25
+ radius: number
26
+ colors: ContentProps['colors']
27
+ iconSize: number
28
+ }> = ({ width, height, maxWidth, radius, colors, iconSize }) => (
29
+ <View
30
+ style={[
31
+ local.errorFrame,
32
+ {
33
+ width: (width ?? '100%') as DimensionValue,
34
+ height,
35
+ maxWidth,
36
+ borderRadius: radius,
37
+ backgroundColor: colors.background,
38
+ borderColor: colors.border,
39
+ },
40
+ ]}
41
+ >
42
+ <WorkflowIcon set="material-community" name="image-off-outline" size={iconSize} color={colors.border} />
43
+ <WorkflowText variant="caption" numberOfLines={1} style={{ color: colors.text, opacity: 0.7, marginTop: 6 }}>
44
+ Image unavailable
45
+ </WorkflowText>
46
+ </View>
47
+ )
48
+
49
+ const ImageContent: React.FC<ContentProps> = ({ item, styles, colors, mediaFrame }) => {
50
+ const { s, isSmall } = useResponsive()
51
+ const imageUrl = resolveImageUrl(item)
52
+ const [failed, setFailed] = useState(false)
53
+ const [containerWidth, setContainerWidth] = useState(0)
54
+ const [aspectRatio, setAspectRatio] = useState(16 / 9)
55
+ const maxImageHeight = s(isSmall ? 180 : 220)
56
+ const radius = s(8)
57
+ const iconSize = s(isSmall ? 28 : 36)
58
+
59
+ useEffect(() => {
60
+ setFailed(false)
61
+ prefetchImageUri(imageUrl)
62
+ }, [imageUrl])
63
+
64
+ const alignSelf =
65
+ item.align === 'center'
66
+ ? ('center' as const)
67
+ : item.align === 'right' || item.align === 'end'
68
+ ? ('flex-end' as const)
69
+ : ('stretch' as const)
70
+
71
+ if (mediaFrame) {
72
+ if (!imageUrl || failed) {
73
+ return (
74
+ <ImageErrorFrame
75
+ height={mediaFrame.height}
76
+ maxWidth={mediaFrame.width}
77
+ radius={radius}
78
+ colors={colors}
79
+ iconSize={iconSize}
80
+ />
81
+ )
82
+ }
83
+
84
+ return (
85
+ <View
86
+ style={[
87
+ local.frameWrap,
88
+ {
89
+ width: '100%',
90
+ height: mediaFrame.height,
91
+ maxWidth: mediaFrame.width,
92
+ borderRadius: radius,
93
+ },
94
+ ]}
95
+ >
96
+ <Image
97
+ source={{ uri: imageUrl }}
98
+ style={local.frameImage}
99
+ resizeMode={mediaFrame.mode || 'cover'}
100
+ onError={() => setFailed(true)}
101
+ />
102
+ </View>
103
+ )
104
+ }
105
+
106
+ if (!imageUrl || failed) {
107
+ return (
108
+ <View style={[styles.fieldContainer, resolveItemSurfaceStyle(item as any), local.wrap, { marginBottom: 0 }]}>
109
+ <ImageErrorFrame
110
+ height={typeof item.height === 'number' ? item.height : maxImageHeight}
111
+ radius={radius}
112
+ colors={colors}
113
+ iconSize={iconSize}
114
+ />
115
+ </View>
116
+ )
117
+ }
118
+
119
+ const onContainerLayout = (event: LayoutChangeEvent) => {
120
+ const nextWidth = event.nativeEvent.layout.width
121
+ if (nextWidth > 0 && Math.abs(nextWidth - containerWidth) > 1) {
122
+ setContainerWidth(nextWidth)
123
+ }
124
+ }
125
+
126
+ const hintedWidth = typeof item.width === 'number' && Number.isFinite(item.width) ? item.width : undefined
127
+ const hintedHeight =
128
+ typeof item.height === 'number' && Number.isFinite(item.height)
129
+ ? item.height
130
+ : typeof item.minHeight === 'number' && Number.isFinite(item.minHeight)
131
+ ? item.minHeight
132
+ : undefined
133
+ const hintedRatio = resolveAspectRatio(item.aspectRatio ?? item.ratio)
134
+ const useFixedThumb = hintedWidth != null && hintedHeight != null
135
+ const usePixelThumb = useFixedThumb && item.fixedPx === true
136
+ const sizeOf = (n: number) => (usePixelThumb ? n : s(n))
137
+ const useHintedFrame = !useFixedThumb && (hintedHeight != null || hintedRatio != null)
138
+ const fittedHeight = useFixedThumb
139
+ ? hintedHeight
140
+ : useHintedFrame
141
+ ? (hintedHeight ??
142
+ (containerWidth > 0 && hintedRatio != null
143
+ ? Math.min(containerWidth / hintedRatio, maxImageHeight)
144
+ : maxImageHeight))
145
+ : containerWidth > 0
146
+ ? Math.min(containerWidth / aspectRatio, maxImageHeight)
147
+ : maxImageHeight
148
+ const fittedWidth = useFixedThumb ? sizeOf(hintedWidth) : containerWidth > 0 ? containerWidth : '100%'
149
+
150
+ return (
151
+ <View
152
+ style={[
153
+ useFixedThumb ? null : styles.fieldContainer,
154
+ resolveItemSurfaceStyle(item as any),
155
+ local.wrap,
156
+ {
157
+ marginBottom: 0,
158
+ width: useFixedThumb ? sizeOf(hintedWidth) : '100%',
159
+ maxWidth: useFixedThumb ? sizeOf(hintedWidth) : '100%',
160
+ alignSelf: useFixedThumb ? 'center' : alignSelf,
161
+ },
162
+ ]}
163
+ onLayout={useFixedThumb ? undefined : onContainerLayout}
164
+ >
165
+ <Image
166
+ source={{ uri: imageUrl }}
167
+ style={[
168
+ local.image,
169
+ {
170
+ width: fittedWidth as DimensionValue,
171
+ maxWidth: '100%',
172
+ height: useFixedThumb ? sizeOf(hintedHeight) : fittedHeight,
173
+ alignSelf: useFixedThumb ? 'center' : alignSelf,
174
+ borderRadius: typeof item.borderRadius === 'number' ? s(item.borderRadius) : radius,
175
+ },
176
+ ]}
177
+ resizeMode="cover"
178
+ onLoad={(event) => {
179
+ if (useHintedFrame || useFixedThumb) return
180
+ const { width, height } = event.nativeEvent.source
181
+ if (width > 0 && height > 0) {
182
+ setAspectRatio(width / height)
183
+ }
184
+ }}
185
+ onError={() => setFailed(true)}
186
+ />
187
+ </View>
188
+ )
189
+ }
190
+
191
+ const local = StyleSheet.create({
192
+ wrap: {
193
+ width: '100%',
194
+ maxWidth: '100%',
195
+ overflow: 'hidden',
196
+ },
197
+ image: {
198
+ backgroundColor: 'transparent',
199
+ },
200
+ frameWrap: {
201
+ overflow: 'hidden',
202
+ width: '100%',
203
+ maxWidth: '100%',
204
+ },
205
+ frameImage: {
206
+ width: '100%',
207
+ height: '100%',
208
+ },
209
+ errorFrame: {
210
+ width: '100%',
211
+ maxWidth: '100%',
212
+ alignSelf: 'stretch',
213
+ alignItems: 'center',
214
+ justifyContent: 'center',
215
+ borderWidth: 1,
216
+ borderStyle: 'dashed',
217
+ },
218
+ })
219
+
220
+ ContentRegistry.register('image', ImageContent)
221
+
222
+ export default ImageContent
@@ -0,0 +1,98 @@
1
+ import React, { type ReactNode } from 'react'
2
+ import { View } from 'react-native'
3
+ import WorkflowText from '../components/WorkflowText'
4
+ import { type ContentProps, ContentRegistry } from '../registries/ContentRegistry'
5
+ import { useResponsive } from '../responsive'
6
+ import { resolveItemSurfaceStyle } from '../style/resolveDisplayHintStyle'
7
+
8
+ const resolveChildLabel = (child: ContentProps['item']): string | undefined => {
9
+ const candidates = [child.text, child.title, child.label, child.subtitle]
10
+ for (const value of candidates) {
11
+ if (typeof value === 'string' && value.trim().length > 0) {
12
+ return value.trim()
13
+ }
14
+ }
15
+ return undefined
16
+ }
17
+
18
+ const ListContent: React.FC<ContentProps> = ({
19
+ item,
20
+ styles,
21
+ colors,
22
+ onAction,
23
+ formData,
24
+ onFieldChange,
25
+ FormFieldRegistry,
26
+ buttonVariant,
27
+ }) => {
28
+ const { s, ms } = useResponsive()
29
+ const listItems: string[] = Array.isArray(item.items) ? item.items : []
30
+ const children: ContentProps['item'][] = Array.isArray(item.children) ? item.children : []
31
+
32
+ if (listItems.length === 0 && children.length === 0) return null
33
+
34
+ const bulletRow = (key: string, body: ReactNode) => (
35
+ <View
36
+ key={key}
37
+ style={{ flexDirection: 'row', alignItems: 'flex-start', marginBottom: s(6), minWidth: 0, width: '100%' }}
38
+ >
39
+ <WorkflowText variant="body" size={14} style={{ color: colors.text, marginRight: s(8), marginTop: s(2) }}>
40
+ {'•'}
41
+ </WorkflowText>
42
+ <View style={{ flex: 1, minWidth: 0 }}>{body}</View>
43
+ </View>
44
+ )
45
+
46
+ return (
47
+ <View
48
+ style={[
49
+ styles.fieldContainer,
50
+ resolveItemSurfaceStyle(item),
51
+ { marginBottom: 0, width: '100%', maxWidth: '100%' },
52
+ ]}
53
+ >
54
+ {listItems.map((text, i) =>
55
+ bulletRow(
56
+ `li-${i}`,
57
+ <WorkflowText variant="body" size={14} style={{ color: colors.text, flex: 1, lineHeight: ms(20) }}>
58
+ {text}
59
+ </WorkflowText>
60
+ )
61
+ )}
62
+ {children.map((child, i) => {
63
+ const key = String(child._id ?? `child-${i}`)
64
+ const label = resolveChildLabel(child)
65
+ const isPlainText = ['text', 'title'].includes(String(child.type)) && !!label
66
+
67
+ if (isPlainText) {
68
+ return bulletRow(
69
+ key,
70
+ <WorkflowText variant="body" size={14} style={{ color: colors.text, lineHeight: ms(20) }}>
71
+ {label}
72
+ </WorkflowText>
73
+ )
74
+ }
75
+
76
+ if (!ContentRegistry.has(child.type)) return null
77
+
78
+ return bulletRow(
79
+ key,
80
+ ContentRegistry.render(child.type, {
81
+ item: child,
82
+ onAction,
83
+ styles,
84
+ colors,
85
+ formData,
86
+ onFieldChange,
87
+ FormFieldRegistry,
88
+ buttonVariant,
89
+ })
90
+ )
91
+ })}
92
+ </View>
93
+ )
94
+ }
95
+
96
+ ContentRegistry.register('list', ListContent)
97
+
98
+ export default ListContent
@@ -0,0 +1,135 @@
1
+ import React, { useState } from 'react'
2
+ import { ActivityIndicator, StyleSheet, TouchableOpacity, View } from 'react-native'
3
+ import { useWalletAdapter } from '../adapter/WalletAdapter'
4
+ import WorkflowButtonLabel from '../components/WorkflowButtonLabel'
5
+ import { useWorkflowT } from '../i18n/WorkflowI18n'
6
+ import { WorkflowIcon } from '../icons/WorkflowIcon'
7
+ import { type ContentProps, ContentRegistry } from '../registries/ContentRegistry'
8
+ import { useResponsive } from '../responsive'
9
+ import {
10
+ resolveButtonFillStyle,
11
+ resolveItemSurfaceStyle,
12
+ resolveSurfaceBackground,
13
+ } from '../style/resolveDisplayHintStyle'
14
+ import { testIdWithKey } from '../utils/testable'
15
+ import { SimulatedHint } from './SimulatedHint'
16
+
17
+ const WHITE = '#FFFFFF'
18
+
19
+ export const mapsUrl = (latitude: number, longitude: number) =>
20
+ `https://www.google.com/maps/search/?api=1&query=${latitude},${longitude}`
21
+
22
+ /**
23
+ * "Share location" pill: reads the position (`adapter.getLocation()`), sends
24
+ * `{ latitude, longitude }` to `form-id` and to `actionID` / `event`, then
25
+ * opens the share sheet with the coordinates and a maps link.
26
+ */
27
+ const LocationContent: React.FC<ContentProps> = ({
28
+ item,
29
+ onAction,
30
+ onFieldChange,
31
+ fillContainer,
32
+ groupFontScale = 1,
33
+ disabled,
34
+ }) => {
35
+ const t = useWorkflowT()
36
+ const adapter = useWalletAdapter()
37
+ const { s, ms, isSmall } = useResponsive()
38
+ const label = (typeof item.label === 'string' && item.label) || t('WorkflowUi.ShareLocation')
39
+ const formId = item['form-id'] as string | undefined
40
+ const actionId = (item.actionID as string | undefined) || (item.event as string | undefined)
41
+ const [loading, setLoading] = useState(false)
42
+
43
+ const handlePress = async () => {
44
+ if (loading || disabled) return
45
+ setLoading(true)
46
+ try {
47
+ const coords = await adapter.getLocation()
48
+ if (!coords) {
49
+ adapter.alert(t('WorkflowUi.LocationUnavailable'), t('WorkflowUi.LocationUnavailableMessage'))
50
+ return
51
+ }
52
+ const { latitude, longitude } = coords
53
+ const payload = { latitude, longitude }
54
+ if (formId) onFieldChange?.(formId, payload)
55
+ if (actionId) onAction(actionId, payload)
56
+ const coordText = `${latitude.toFixed(6)}, ${longitude.toFixed(6)}`
57
+ await adapter
58
+ .share({
59
+ title: t('WorkflowUi.ShareLocation'),
60
+ subject: t('WorkflowUi.ShareLocation'),
61
+ message: `${t('WorkflowUi.MyLocation')}\n${coordText}\n\n${mapsUrl(latitude, longitude)}`,
62
+ })
63
+ .catch(() => adapter.alert(t('WorkflowUi.Error'), t('WorkflowUi.ShareFailed')))
64
+ } catch {
65
+ adapter.alert(t('WorkflowUi.LocationUnavailable'), t('WorkflowUi.LocationUnavailableMessage'))
66
+ } finally {
67
+ setLoading(false)
68
+ }
69
+ }
70
+
71
+ const isTransparent = resolveSurfaceBackground(item.bgColor as string | undefined) === 'transparent'
72
+ const minHeight = s(isSmall ? 44 : 52)
73
+
74
+ return (
75
+ <View
76
+ style={[pill.wrap, resolveItemSurfaceStyle(item as any), fillContainer ? { flex: 1, marginBottom: 0 } : null]}
77
+ >
78
+ <TouchableOpacity
79
+ testID={testIdWithKey('WorkflowShareLocation')}
80
+ accessibilityLabel={label}
81
+ accessibilityRole="button"
82
+ style={[
83
+ pill.pill,
84
+ {
85
+ minHeight,
86
+ borderRadius: minHeight / 2,
87
+ paddingVertical: s(isSmall ? 10 : 14),
88
+ paddingHorizontal: s(isSmall ? 10 : 16),
89
+ },
90
+ fillContainer ? { flex: 1, height: '100%' } : null,
91
+ resolveButtonFillStyle(item as any, { includePadding: false }),
92
+ isTransparent ? { backgroundColor: 'transparent', borderWidth: 1.5, borderColor: WHITE } : null,
93
+ disabled ? pill.disabled : null,
94
+ ]}
95
+ onPress={handlePress}
96
+ activeOpacity={0.85}
97
+ disabled={loading || disabled}
98
+ >
99
+ {loading ? (
100
+ <ActivityIndicator color={WHITE} />
101
+ ) : (
102
+ <>
103
+ <WorkflowIcon name="share" size={s(18)} color={WHITE} style={{ marginRight: s(8) }} />
104
+ <WorkflowButtonLabel
105
+ style={[pill.text, { color: WHITE, fontSize: ms(isSmall ? 13 : 15) }]}
106
+ groupFontScale={groupFontScale}
107
+ >
108
+ {label}
109
+ </WorkflowButtonLabel>
110
+ </>
111
+ )}
112
+ </TouchableOpacity>
113
+ {adapter.simulated ? <SimulatedHint /> : null}
114
+ </View>
115
+ )
116
+ }
117
+
118
+ /** Shared by the location and share pills. */
119
+ export const pill = StyleSheet.create({
120
+ wrap: { marginBottom: 8 },
121
+ pill: {
122
+ flexDirection: 'row',
123
+ alignItems: 'center',
124
+ justifyContent: 'center',
125
+ width: '100%',
126
+ flexShrink: 1,
127
+ minWidth: 0,
128
+ },
129
+ text: { fontWeight: '700', flexShrink: 1 },
130
+ disabled: { opacity: 0.5 },
131
+ })
132
+
133
+ ContentRegistry.register('location', LocationContent)
134
+
135
+ export default LocationContent
@@ -0,0 +1,232 @@
1
+ import React, { useMemo } from 'react'
2
+ import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
3
+ import { useWalletAdapter } from '../adapter/WalletAdapter'
4
+ import { useWorkflowT } from '../i18n/WorkflowI18n'
5
+ import { type ContentProps, ContentRegistry } from '../registries/ContentRegistry'
6
+ import { mapsUrl } from './LocationContent'
7
+
8
+ const WHITE = '#FFFFFF'
9
+ const TILE_ZOOM = 15
10
+ const TILE_SIZE = 128
11
+
12
+ type Coordinates = { latitude: number; longitude: number }
13
+
14
+ const FALLBACK_COORDS: Coordinates = {
15
+ latitude: 34.240546,
16
+ longitude: -77.948781,
17
+ }
18
+
19
+ const isValidCoords = (latitude: number, longitude: number): boolean =>
20
+ !Number.isNaN(latitude) &&
21
+ !Number.isNaN(longitude) &&
22
+ latitude >= -90 &&
23
+ latitude <= 90 &&
24
+ longitude >= -180 &&
25
+ longitude <= 180 &&
26
+ !(latitude === 0 && longitude === 0)
27
+
28
+ const toNumber = (value: unknown): number => {
29
+ if (typeof value === 'number') return value
30
+ if (typeof value === 'string') return Number.parseFloat(value.trim())
31
+ return NaN
32
+ }
33
+
34
+ const coordsFromPair = (latitude: unknown, longitude: unknown): Coordinates | null => {
35
+ const lat = toNumber(latitude)
36
+ const lng = toNumber(longitude)
37
+ if (!isValidCoords(lat, lng)) return null
38
+ return { latitude: lat, longitude: lng }
39
+ }
40
+
41
+ const coordsFromString = (value: unknown): Coordinates | null => {
42
+ if (typeof value !== 'string') return null
43
+ const parts = value
44
+ .split(/[,;\s]+/)
45
+ .map((part) => part.trim())
46
+ .filter(Boolean)
47
+ if (parts.length < 2) return null
48
+ return coordsFromPair(parts[0], parts[1])
49
+ }
50
+
51
+ const coordsFromRecord = (record: Record<string, unknown>): Coordinates | null => {
52
+ const direct = coordsFromPair(
53
+ record.latitude ?? record.lat,
54
+ record.longitude ?? record.lng ?? record.lon ?? record.long
55
+ )
56
+ if (direct) return direct
57
+
58
+ for (const key of ['gps', 'coordinates', 'coordinate', 'coords', 'position', 'location', 'geo']) {
59
+ const value = record[key]
60
+ if (value == null) continue
61
+
62
+ const fromString = coordsFromString(value)
63
+ if (fromString) return fromString
64
+
65
+ if (Array.isArray(value) && value.length >= 2) {
66
+ const asLatLng = coordsFromPair(value[0], value[1])
67
+ if (asLatLng) return asLatLng
68
+ const asLngLat = coordsFromPair(value[1], value[0])
69
+ if (asLngLat) return asLngLat
70
+ }
71
+
72
+ if (typeof value === 'object') {
73
+ const nested = coordsFromRecord(value as Record<string, unknown>)
74
+ if (nested) return nested
75
+ }
76
+ }
77
+
78
+ return null
79
+ }
80
+
81
+ const latLngToWorld = (latitude: number, longitude: number, zoom: number) => {
82
+ const n = 2 ** zoom
83
+ const x = ((longitude + 180) / 360) * n
84
+ const latRad = (latitude * Math.PI) / 180
85
+ const y = ((1 - Math.log(Math.tan(latRad) + 1 / Math.cos(latRad)) / Math.PI) / 2) * n
86
+ return { x, y }
87
+ }
88
+
89
+ const tileUrl = (x: number, y: number, z: number): string =>
90
+ `https://a.basemaps.cartocdn.com/rastertiles/voyager/${z}/${x}/${y}.png`
91
+
92
+ /**
93
+ * Static map preview (Carto tiles around the item's coordinates, pin in the
94
+ * middle) that opens the maps app on tap. Coordinates come from
95
+ * `latitude`/`longitude`, `lat`/`lng`, or a `gps` / `coordinates` / `location`
96
+ * value (string, array or object).
97
+ */
98
+ const MapContent: React.FC<ContentProps> = ({ item, styles, colors }) => {
99
+ const t = useWorkflowT()
100
+ const adapter = useWalletAdapter()
101
+ const textColor = (typeof colors?.text === 'string' && colors.text) || WHITE
102
+
103
+ const coords = useMemo(() => {
104
+ const fromJson = coordsFromRecord(item as Record<string, unknown>)
105
+ return fromJson ?? FALLBACK_COORDS
106
+ }, [item])
107
+
108
+ const mapPreview = useMemo(() => {
109
+ const world = latLngToWorld(coords.latitude, coords.longitude, TILE_ZOOM)
110
+ const centerX = Math.floor(world.x)
111
+ const centerY = Math.floor(world.y)
112
+ const pinOffsetX = (world.x - centerX - 0.5) * TILE_SIZE
113
+ const pinOffsetY = (world.y - centerY - 0.5) * TILE_SIZE
114
+
115
+ const tiles: Array<{ key: string; url: string; row: number; col: number }> = []
116
+ for (let row = -1; row <= 1; row += 1) {
117
+ for (let col = -1; col <= 1; col += 1) {
118
+ const x = centerX + col
119
+ const y = centerY + row
120
+ tiles.push({
121
+ key: `${TILE_ZOOM}-${x}-${y}`,
122
+ url: tileUrl(x, y, TILE_ZOOM),
123
+ row: row + 1,
124
+ col: col + 1,
125
+ })
126
+ }
127
+ }
128
+
129
+ return { tiles, pinOffsetX, pinOffsetY }
130
+ }, [coords.latitude, coords.longitude])
131
+
132
+ const handleOpenMaps = () => {
133
+ void adapter.openUrl(mapsUrl(coords.latitude, coords.longitude)).catch(() => undefined)
134
+ }
135
+
136
+ const fromJson =
137
+ (typeof item.label === 'string' && item.label.trim()) ||
138
+ (typeof item.title === 'string' && item.title.trim()) ||
139
+ (typeof item.text === 'string' && item.text.trim()) ||
140
+ (typeof item.name === 'string' && item.name.trim()) ||
141
+ ''
142
+
143
+ const locationTitle =
144
+ fromJson || `${t('WorkflowUi.Location')}: ${coords.latitude.toFixed(6)}, ${coords.longitude.toFixed(6)}`
145
+
146
+ return (
147
+ <View style={styles.fieldContainer}>
148
+ <Text style={[styles.label, { color: textColor, marginBottom: 10, fontWeight: '700' }]}>{locationTitle}</Text>
149
+
150
+ <TouchableOpacity onPress={handleOpenMaps} activeOpacity={0.9}>
151
+ <View style={local.mapFrame}>
152
+ <View style={local.tileGrid}>
153
+ {mapPreview.tiles.map((tile) => (
154
+ <Image
155
+ key={tile.key}
156
+ source={{ uri: tile.url }}
157
+ style={[
158
+ local.tile,
159
+ {
160
+ left: tile.col * TILE_SIZE,
161
+ top: tile.row * TILE_SIZE,
162
+ },
163
+ ]}
164
+ />
165
+ ))}
166
+ </View>
167
+ <View
168
+ style={[
169
+ local.pin,
170
+ {
171
+ transform: [{ translateX: mapPreview.pinOffsetX }, { translateY: mapPreview.pinOffsetY }],
172
+ },
173
+ ]}
174
+ pointerEvents="none"
175
+ >
176
+ <View style={local.pinDot} />
177
+ <View style={local.pinStem} />
178
+ </View>
179
+ </View>
180
+
181
+ <Text style={[styles.description, { color: textColor, textAlign: 'center', marginTop: 8 }]}>
182
+ {t('WorkflowUi.OpenInMaps')}
183
+ </Text>
184
+ </TouchableOpacity>
185
+ </View>
186
+ )
187
+ }
188
+
189
+ const local = StyleSheet.create({
190
+ mapFrame: {
191
+ width: '100%',
192
+ height: 200,
193
+ borderRadius: 8,
194
+ overflow: 'hidden',
195
+ backgroundColor: 'rgba(255,255,255,0.08)',
196
+ borderWidth: 1,
197
+ borderColor: 'rgba(255,255,255,0.25)',
198
+ alignItems: 'center',
199
+ justifyContent: 'center',
200
+ },
201
+ tileGrid: {
202
+ width: TILE_SIZE * 3,
203
+ height: TILE_SIZE * 3,
204
+ position: 'relative',
205
+ },
206
+ tile: {
207
+ position: 'absolute',
208
+ width: TILE_SIZE,
209
+ height: TILE_SIZE,
210
+ },
211
+ pin: {
212
+ position: 'absolute',
213
+ alignItems: 'center',
214
+ },
215
+ pinDot: {
216
+ width: 16,
217
+ height: 16,
218
+ borderRadius: 8,
219
+ backgroundColor: '#E53935',
220
+ borderWidth: 2,
221
+ borderColor: WHITE,
222
+ },
223
+ pinStem: {
224
+ width: 2,
225
+ height: 10,
226
+ backgroundColor: '#E53935',
227
+ marginTop: -1,
228
+ },
229
+ })
230
+
231
+ ContentRegistry.register('map', MapContent)
232
+ export default MapContent