@veridid/workflow-ui 0.0.0-stage → 0.1.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.
- package/LICENSE +202 -0
- package/README.md +217 -2
- package/build/module/WorkflowFontScaleContext.js +67 -0
- package/build/module/WorkflowFontScaleContext.js.map +1 -0
- package/build/module/adapter/WalletAdapter.js +152 -0
- package/build/module/adapter/WalletAdapter.js.map +1 -0
- package/build/module/components/FallbackVideoPlayer.js +8 -0
- package/build/module/components/FallbackVideoPlayer.js.map +1 -0
- package/build/module/components/FallbackVideoPlayer.native.js +10 -0
- package/build/module/components/FallbackVideoPlayer.native.js.map +1 -0
- package/build/module/components/FallbackVideoPlayer.web.js +35 -0
- package/build/module/components/FallbackVideoPlayer.web.js.map +1 -0
- package/build/module/components/WorkflowButtonLabel.js +32 -0
- package/build/module/components/WorkflowButtonLabel.js.map +1 -0
- package/build/module/components/WorkflowCalendarIcon.js +73 -0
- package/build/module/components/WorkflowCalendarIcon.js.map +1 -0
- package/build/module/components/WorkflowText.js +92 -0
- package/build/module/components/WorkflowText.js.map +1 -0
- package/build/module/content/BadgeContent.js +73 -0
- package/build/module/content/BadgeContent.js.map +1 -0
- package/build/module/content/BarChartContent.js +97 -0
- package/build/module/content/BarChartContent.js.map +1 -0
- package/build/module/content/BarcodeContent.js +78 -0
- package/build/module/content/BarcodeContent.js.map +1 -0
- package/build/module/content/BasicTableContent.js +145 -0
- package/build/module/content/BasicTableContent.js.map +1 -0
- package/build/module/content/ButtonContent.js +130 -0
- package/build/module/content/ButtonContent.js.map +1 -0
- package/build/module/content/CalendarContent.js +173 -0
- package/build/module/content/CalendarContent.js.map +1 -0
- package/build/module/content/CardContent.js +114 -0
- package/build/module/content/CardContent.js.map +1 -0
- package/build/module/content/CarouselContent.js +173 -0
- package/build/module/content/CarouselContent.js.map +1 -0
- package/build/module/content/ChipContent.js +214 -0
- package/build/module/content/ChipContent.js.map +1 -0
- package/build/module/content/ChipRowContent.js +127 -0
- package/build/module/content/ChipRowContent.js.map +1 -0
- package/build/module/content/CredentialOfferContent.js +312 -0
- package/build/module/content/CredentialOfferContent.js.map +1 -0
- package/build/module/content/DialContent.js +101 -0
- package/build/module/content/DialContent.js.map +1 -0
- package/build/module/content/DividerContent.js +26 -0
- package/build/module/content/DividerContent.js.map +1 -0
- package/build/module/content/DonutChartContent.js +118 -0
- package/build/module/content/DonutChartContent.js.map +1 -0
- package/build/module/content/FormContent.js +141 -0
- package/build/module/content/FormContent.js.map +1 -0
- package/build/module/content/FormFieldBridge.js +157 -0
- package/build/module/content/FormFieldBridge.js.map +1 -0
- package/build/module/content/GaugeContent.js +77 -0
- package/build/module/content/GaugeContent.js.map +1 -0
- package/build/module/content/GridLayoutContent.js +227 -0
- package/build/module/content/GridLayoutContent.js.map +1 -0
- package/build/module/content/ImageContent.js +190 -0
- package/build/module/content/ImageContent.js.map +1 -0
- package/build/module/content/ListContent.js +121 -0
- package/build/module/content/ListContent.js.map +1 -0
- package/build/module/content/LocationContent.js +148 -0
- package/build/module/content/LocationContent.js.map +1 -0
- package/build/module/content/MapContent.js +213 -0
- package/build/module/content/MapContent.js.map +1 -0
- package/build/module/content/MultipleChoiceContent.js +91 -0
- package/build/module/content/MultipleChoiceContent.js.map +1 -0
- package/build/module/content/OpenBadgePreviewContent.js +141 -0
- package/build/module/content/OpenBadgePreviewContent.js.map +1 -0
- package/build/module/content/PhotoContent.js +154 -0
- package/build/module/content/PhotoContent.js.map +1 -0
- package/build/module/content/PieChartContent.js +129 -0
- package/build/module/content/PieChartContent.js.map +1 -0
- package/build/module/content/ProofPresentationContent.js +154 -0
- package/build/module/content/ProofPresentationContent.js.map +1 -0
- package/build/module/content/RadioButtonContent.js +136 -0
- package/build/module/content/RadioButtonContent.js.map +1 -0
- package/build/module/content/RowContent.js +539 -0
- package/build/module/content/RowContent.js.map +1 -0
- package/build/module/content/SectionContent.js +123 -0
- package/build/module/content/SectionContent.js.map +1 -0
- package/build/module/content/ShareEntryContent.js +111 -0
- package/build/module/content/ShareEntryContent.js.map +1 -0
- package/build/module/content/SimulatedHint.js +33 -0
- package/build/module/content/SimulatedHint.js.map +1 -0
- package/build/module/content/SliderContent.js +46 -0
- package/build/module/content/SliderContent.js.map +1 -0
- package/build/module/content/SpacerContent.js +21 -0
- package/build/module/content/SpacerContent.js.map +1 -0
- package/build/module/content/SpinnerContent.js +33 -0
- package/build/module/content/SpinnerContent.js.map +1 -0
- package/build/module/content/SubmitButtonContent.js +281 -0
- package/build/module/content/SubmitButtonContent.js.map +1 -0
- package/build/module/content/TextContent.js +127 -0
- package/build/module/content/TextContent.js.map +1 -0
- package/build/module/content/TileContent.js +237 -0
- package/build/module/content/TileContent.js.map +1 -0
- package/build/module/content/TimelineContent.js +120 -0
- package/build/module/content/TimelineContent.js.map +1 -0
- package/build/module/content/TitleContent.js +55 -0
- package/build/module/content/TitleContent.js.map +1 -0
- package/build/module/content/VideoContent.js +142 -0
- package/build/module/content/VideoContent.js.map +1 -0
- package/build/module/content/WebLinkContent.js +95 -0
- package/build/module/content/WebLinkContent.js.map +1 -0
- package/build/module/content/index.js +48 -0
- package/build/module/content/index.js.map +1 -0
- package/build/module/form-fields/CheckboxField.js +47 -0
- package/build/module/form-fields/CheckboxField.js.map +1 -0
- package/build/module/form-fields/DateField.js +8 -0
- package/build/module/form-fields/DateField.js.map +1 -0
- package/build/module/form-fields/DateField.native.js +141 -0
- package/build/module/form-fields/DateField.native.js.map +1 -0
- package/build/module/form-fields/DateField.web.js +45 -0
- package/build/module/form-fields/DateField.web.js.map +1 -0
- package/build/module/form-fields/DropdownField.js +172 -0
- package/build/module/form-fields/DropdownField.js.map +1 -0
- package/build/module/form-fields/MCQField.js +100 -0
- package/build/module/form-fields/MCQField.js.map +1 -0
- package/build/module/form-fields/RadioField.js +56 -0
- package/build/module/form-fields/RadioField.js.map +1 -0
- package/build/module/form-fields/SliderField.js +8 -0
- package/build/module/form-fields/SliderField.js.map +1 -0
- package/build/module/form-fields/SliderField.native.js +77 -0
- package/build/module/form-fields/SliderField.native.js.map +1 -0
- package/build/module/form-fields/SliderField.web.js +82 -0
- package/build/module/form-fields/SliderField.web.js.map +1 -0
- package/build/module/form-fields/SubmitButtonField.js +42 -0
- package/build/module/form-fields/SubmitButtonField.js.map +1 -0
- package/build/module/form-fields/TextField.js +56 -0
- package/build/module/form-fields/TextField.js.map +1 -0
- package/build/module/form-fields/index.js +15 -0
- package/build/module/form-fields/index.js.map +1 -0
- package/build/module/i18n/WorkflowI18n.js +94 -0
- package/build/module/i18n/WorkflowI18n.js.map +1 -0
- package/build/module/icons/VectorIcon.js +23 -0
- package/build/module/icons/VectorIcon.js.map +1 -0
- package/build/module/icons/VectorIcon.web.js +62 -0
- package/build/module/icons/VectorIcon.web.js.map +1 -0
- package/build/module/icons/WorkflowIcon.js +36 -0
- package/build/module/icons/WorkflowIcon.js.map +1 -0
- package/build/module/icons/types.js +4 -0
- package/build/module/icons/types.js.map +1 -0
- package/build/module/imageUriCache.js +25 -0
- package/build/module/imageUriCache.js.map +1 -0
- package/build/module/index.js +50 -0
- package/build/module/index.js.map +1 -0
- package/build/module/modal/WorkflowModal.js +115 -0
- package/build/module/modal/WorkflowModal.js.map +1 -0
- package/build/module/package.json +1 -0
- package/build/module/platform/platformName.js +10 -0
- package/build/module/platform/platformName.js.map +1 -0
- package/build/module/platform/platformName.web.js +5 -0
- package/build/module/platform/platformName.web.js.map +1 -0
- package/build/module/protocol/controlSnapshotStore.js +19 -0
- package/build/module/protocol/controlSnapshotStore.js.map +1 -0
- package/build/module/protocol/useProtocolExchange.js +168 -0
- package/build/module/protocol/useProtocolExchange.js.map +1 -0
- package/build/module/registries/ContentRegistry.js +53 -0
- package/build/module/registries/ContentRegistry.js.map +1 -0
- package/build/module/registries/FormFieldRegistry.js +56 -0
- package/build/module/registries/FormFieldRegistry.js.map +1 -0
- package/build/module/render/NodeBoundary.js +73 -0
- package/build/module/render/NodeBoundary.js.map +1 -0
- package/build/module/render/RenderTree.js +52 -0
- package/build/module/render/RenderTree.js.map +1 -0
- package/build/module/render/WorkflowRenderContext.js +34 -0
- package/build/module/render/WorkflowRenderContext.js.map +1 -0
- package/build/module/render/nodes.js +103 -0
- package/build/module/render/nodes.js.map +1 -0
- package/build/module/responsive/ResponsiveProvider.js +63 -0
- package/build/module/responsive/ResponsiveProvider.js.map +1 -0
- package/build/module/responsive/index.js +4 -0
- package/build/module/responsive/index.js.map +1 -0
- package/build/module/responsive/responsive.js +56 -0
- package/build/module/responsive/responsive.js.map +1 -0
- package/build/module/style/resolveDisplayHintStyle.js +145 -0
- package/build/module/style/resolveDisplayHintStyle.js.map +1 -0
- package/build/module/theme/WorkflowTheme.js +200 -0
- package/build/module/theme/WorkflowTheme.js.map +1 -0
- package/build/module/utils/testable.js +12 -0
- package/build/module/utils/testable.js.map +1 -0
- package/build/typescript/WorkflowFontScaleContext.d.ts +7 -0
- package/build/typescript/WorkflowFontScaleContext.d.ts.map +1 -0
- package/build/typescript/adapter/WalletAdapter.d.ts +145 -0
- package/build/typescript/adapter/WalletAdapter.d.ts.map +1 -0
- package/build/typescript/components/FallbackVideoPlayer.d.ts +6 -0
- package/build/typescript/components/FallbackVideoPlayer.d.ts.map +1 -0
- package/build/typescript/components/FallbackVideoPlayer.native.d.ts +7 -0
- package/build/typescript/components/FallbackVideoPlayer.native.d.ts.map +1 -0
- package/build/typescript/components/FallbackVideoPlayer.web.d.ts +9 -0
- package/build/typescript/components/FallbackVideoPlayer.web.d.ts.map +1 -0
- package/build/typescript/components/WorkflowButtonLabel.d.ts +11 -0
- package/build/typescript/components/WorkflowButtonLabel.d.ts.map +1 -0
- package/build/typescript/components/WorkflowCalendarIcon.d.ts +11 -0
- package/build/typescript/components/WorkflowCalendarIcon.d.ts.map +1 -0
- package/build/typescript/components/WorkflowText.d.ts +13 -0
- package/build/typescript/components/WorkflowText.d.ts.map +1 -0
- package/build/typescript/content/BadgeContent.d.ts +5 -0
- package/build/typescript/content/BadgeContent.d.ts.map +1 -0
- package/build/typescript/content/BarChartContent.d.ts +5 -0
- package/build/typescript/content/BarChartContent.d.ts.map +1 -0
- package/build/typescript/content/BarcodeContent.d.ts +11 -0
- package/build/typescript/content/BarcodeContent.d.ts.map +1 -0
- package/build/typescript/content/BasicTableContent.d.ts +5 -0
- package/build/typescript/content/BasicTableContent.d.ts.map +1 -0
- package/build/typescript/content/ButtonContent.d.ts +5 -0
- package/build/typescript/content/ButtonContent.d.ts.map +1 -0
- package/build/typescript/content/CalendarContent.d.ts +19 -0
- package/build/typescript/content/CalendarContent.d.ts.map +1 -0
- package/build/typescript/content/CardContent.d.ts +5 -0
- package/build/typescript/content/CardContent.d.ts.map +1 -0
- package/build/typescript/content/CarouselContent.d.ts +5 -0
- package/build/typescript/content/CarouselContent.d.ts.map +1 -0
- package/build/typescript/content/ChipContent.d.ts +5 -0
- package/build/typescript/content/ChipContent.d.ts.map +1 -0
- package/build/typescript/content/ChipRowContent.d.ts +8 -0
- package/build/typescript/content/ChipRowContent.d.ts.map +1 -0
- package/build/typescript/content/CredentialOfferContent.d.ts +98 -0
- package/build/typescript/content/CredentialOfferContent.d.ts.map +1 -0
- package/build/typescript/content/DialContent.d.ts +5 -0
- package/build/typescript/content/DialContent.d.ts.map +1 -0
- package/build/typescript/content/DividerContent.d.ts +5 -0
- package/build/typescript/content/DividerContent.d.ts.map +1 -0
- package/build/typescript/content/DonutChartContent.d.ts +5 -0
- package/build/typescript/content/DonutChartContent.d.ts.map +1 -0
- package/build/typescript/content/FormContent.d.ts +19 -0
- package/build/typescript/content/FormContent.d.ts.map +1 -0
- package/build/typescript/content/FormFieldBridge.d.ts +2 -0
- package/build/typescript/content/FormFieldBridge.d.ts.map +1 -0
- package/build/typescript/content/GaugeContent.d.ts +5 -0
- package/build/typescript/content/GaugeContent.d.ts.map +1 -0
- package/build/typescript/content/GridLayoutContent.d.ts +5 -0
- package/build/typescript/content/GridLayoutContent.d.ts.map +1 -0
- package/build/typescript/content/ImageContent.d.ts +5 -0
- package/build/typescript/content/ImageContent.d.ts.map +1 -0
- package/build/typescript/content/ListContent.d.ts +5 -0
- package/build/typescript/content/ListContent.d.ts.map +1 -0
- package/build/typescript/content/LocationContent.d.ts +32 -0
- package/build/typescript/content/LocationContent.d.ts.map +1 -0
- package/build/typescript/content/MapContent.d.ts +11 -0
- package/build/typescript/content/MapContent.d.ts.map +1 -0
- package/build/typescript/content/MultipleChoiceContent.d.ts +5 -0
- package/build/typescript/content/MultipleChoiceContent.d.ts.map +1 -0
- package/build/typescript/content/OpenBadgePreviewContent.d.ts +14 -0
- package/build/typescript/content/OpenBadgePreviewContent.d.ts.map +1 -0
- package/build/typescript/content/PhotoContent.d.ts +57 -0
- package/build/typescript/content/PhotoContent.d.ts.map +1 -0
- package/build/typescript/content/PieChartContent.d.ts +5 -0
- package/build/typescript/content/PieChartContent.d.ts.map +1 -0
- package/build/typescript/content/ProofPresentationContent.d.ts +14 -0
- package/build/typescript/content/ProofPresentationContent.d.ts.map +1 -0
- package/build/typescript/content/RadioButtonContent.d.ts +5 -0
- package/build/typescript/content/RadioButtonContent.d.ts.map +1 -0
- package/build/typescript/content/RowContent.d.ts +5 -0
- package/build/typescript/content/RowContent.d.ts.map +1 -0
- package/build/typescript/content/SectionContent.d.ts +5 -0
- package/build/typescript/content/SectionContent.d.ts.map +1 -0
- package/build/typescript/content/ShareEntryContent.d.ts +15 -0
- package/build/typescript/content/ShareEntryContent.d.ts.map +1 -0
- package/build/typescript/content/SimulatedHint.d.ts +9 -0
- package/build/typescript/content/SimulatedHint.d.ts.map +1 -0
- package/build/typescript/content/SliderContent.d.ts +10 -0
- package/build/typescript/content/SliderContent.d.ts.map +1 -0
- package/build/typescript/content/SpacerContent.d.ts +5 -0
- package/build/typescript/content/SpacerContent.d.ts.map +1 -0
- package/build/typescript/content/SpinnerContent.d.ts +5 -0
- package/build/typescript/content/SpinnerContent.d.ts.map +1 -0
- package/build/typescript/content/SubmitButtonContent.d.ts +9 -0
- package/build/typescript/content/SubmitButtonContent.d.ts.map +1 -0
- package/build/typescript/content/TextContent.d.ts +5 -0
- package/build/typescript/content/TextContent.d.ts.map +1 -0
- package/build/typescript/content/TileContent.d.ts +5 -0
- package/build/typescript/content/TileContent.d.ts.map +1 -0
- package/build/typescript/content/TimelineContent.d.ts +5 -0
- package/build/typescript/content/TimelineContent.d.ts.map +1 -0
- package/build/typescript/content/TitleContent.d.ts +5 -0
- package/build/typescript/content/TitleContent.d.ts.map +1 -0
- package/build/typescript/content/VideoContent.d.ts +10 -0
- package/build/typescript/content/VideoContent.d.ts.map +1 -0
- package/build/typescript/content/WebLinkContent.d.ts +5 -0
- package/build/typescript/content/WebLinkContent.d.ts.map +1 -0
- package/build/typescript/content/index.d.ts +46 -0
- package/build/typescript/content/index.d.ts.map +1 -0
- package/build/typescript/form-fields/CheckboxField.d.ts +5 -0
- package/build/typescript/form-fields/CheckboxField.d.ts.map +1 -0
- package/build/typescript/form-fields/DateField.d.ts +6 -0
- package/build/typescript/form-fields/DateField.d.ts.map +1 -0
- package/build/typescript/form-fields/DateField.native.d.ts +5 -0
- package/build/typescript/form-fields/DateField.native.d.ts.map +1 -0
- package/build/typescript/form-fields/DateField.web.d.ts +9 -0
- package/build/typescript/form-fields/DateField.web.d.ts.map +1 -0
- package/build/typescript/form-fields/DropdownField.d.ts +5 -0
- package/build/typescript/form-fields/DropdownField.d.ts.map +1 -0
- package/build/typescript/form-fields/MCQField.d.ts +5 -0
- package/build/typescript/form-fields/MCQField.d.ts.map +1 -0
- package/build/typescript/form-fields/RadioField.d.ts +5 -0
- package/build/typescript/form-fields/RadioField.d.ts.map +1 -0
- package/build/typescript/form-fields/SliderField.d.ts +6 -0
- package/build/typescript/form-fields/SliderField.d.ts.map +1 -0
- package/build/typescript/form-fields/SliderField.native.d.ts +5 -0
- package/build/typescript/form-fields/SliderField.native.d.ts.map +1 -0
- package/build/typescript/form-fields/SliderField.web.d.ts +11 -0
- package/build/typescript/form-fields/SliderField.web.d.ts.map +1 -0
- package/build/typescript/form-fields/SubmitButtonField.d.ts +5 -0
- package/build/typescript/form-fields/SubmitButtonField.d.ts.map +1 -0
- package/build/typescript/form-fields/TextField.d.ts +5 -0
- package/build/typescript/form-fields/TextField.d.ts.map +1 -0
- package/build/typescript/form-fields/index.d.ts +13 -0
- package/build/typescript/form-fields/index.d.ts.map +1 -0
- package/build/typescript/i18n/WorkflowI18n.d.ts +75 -0
- package/build/typescript/i18n/WorkflowI18n.d.ts.map +1 -0
- package/build/typescript/icons/VectorIcon.d.ts +4 -0
- package/build/typescript/icons/VectorIcon.d.ts.map +1 -0
- package/build/typescript/icons/VectorIcon.web.d.ts +16 -0
- package/build/typescript/icons/VectorIcon.web.d.ts.map +1 -0
- package/build/typescript/icons/WorkflowIcon.d.ts +19 -0
- package/build/typescript/icons/WorkflowIcon.d.ts.map +1 -0
- package/build/typescript/icons/types.d.ts +12 -0
- package/build/typescript/icons/types.d.ts.map +1 -0
- package/build/typescript/imageUriCache.d.ts +7 -0
- package/build/typescript/imageUriCache.d.ts.map +1 -0
- package/build/typescript/index.d.ts +48 -0
- package/build/typescript/index.d.ts.map +1 -0
- package/build/typescript/modal/WorkflowModal.d.ts +33 -0
- package/build/typescript/modal/WorkflowModal.d.ts.map +1 -0
- package/build/typescript/package.json +1 -0
- package/build/typescript/platform/platformName.d.ts +8 -0
- package/build/typescript/platform/platformName.d.ts.map +1 -0
- package/build/typescript/platform/platformName.web.d.ts +3 -0
- package/build/typescript/platform/platformName.web.d.ts.map +1 -0
- package/build/typescript/protocol/controlSnapshotStore.d.ts +12 -0
- package/build/typescript/protocol/controlSnapshotStore.d.ts.map +1 -0
- package/build/typescript/protocol/useProtocolExchange.d.ts +40 -0
- package/build/typescript/protocol/useProtocolExchange.d.ts.map +1 -0
- package/build/typescript/registries/ContentRegistry.d.ts +57 -0
- package/build/typescript/registries/ContentRegistry.d.ts.map +1 -0
- package/build/typescript/registries/FormFieldRegistry.d.ts +37 -0
- package/build/typescript/registries/FormFieldRegistry.d.ts.map +1 -0
- package/build/typescript/render/NodeBoundary.d.ts +25 -0
- package/build/typescript/render/NodeBoundary.d.ts.map +1 -0
- package/build/typescript/render/RenderTree.d.ts +23 -0
- package/build/typescript/render/RenderTree.d.ts.map +1 -0
- package/build/typescript/render/WorkflowRenderContext.d.ts +57 -0
- package/build/typescript/render/WorkflowRenderContext.d.ts.map +1 -0
- package/build/typescript/render/nodes.d.ts +49 -0
- package/build/typescript/render/nodes.d.ts.map +1 -0
- package/build/typescript/responsive/ResponsiveProvider.d.ts +39 -0
- package/build/typescript/responsive/ResponsiveProvider.d.ts.map +1 -0
- package/build/typescript/responsive/index.d.ts +3 -0
- package/build/typescript/responsive/index.d.ts.map +1 -0
- package/build/typescript/responsive/responsive.d.ts +24 -0
- package/build/typescript/responsive/responsive.d.ts.map +1 -0
- package/build/typescript/style/resolveDisplayHintStyle.d.ts +23 -0
- package/build/typescript/style/resolveDisplayHintStyle.d.ts.map +1 -0
- package/build/typescript/theme/WorkflowTheme.d.ts +177 -0
- package/build/typescript/theme/WorkflowTheme.d.ts.map +1 -0
- package/build/typescript/utils/testable.d.ts +8 -0
- package/build/typescript/utils/testable.d.ts.map +1 -0
- package/package.json +104 -3
- package/src/WorkflowFontScaleContext.tsx +74 -0
- package/src/adapter/WalletAdapter.tsx +225 -0
- package/src/components/FallbackVideoPlayer.native.tsx +9 -0
- package/src/components/FallbackVideoPlayer.tsx +5 -0
- package/src/components/FallbackVideoPlayer.web.tsx +24 -0
- package/src/components/WorkflowButtonLabel.tsx +41 -0
- package/src/components/WorkflowCalendarIcon.tsx +52 -0
- package/src/components/WorkflowText.tsx +121 -0
- package/src/content/BadgeContent.tsx +57 -0
- package/src/content/BarChartContent.tsx +76 -0
- package/src/content/BarcodeContent.tsx +59 -0
- package/src/content/BasicTableContent.tsx +139 -0
- package/src/content/ButtonContent.tsx +124 -0
- package/src/content/CalendarContent.tsx +178 -0
- package/src/content/CardContent.tsx +137 -0
- package/src/content/CarouselContent.tsx +197 -0
- package/src/content/ChipContent.tsx +209 -0
- package/src/content/ChipRowContent.tsx +133 -0
- package/src/content/CredentialOfferContent.tsx +229 -0
- package/src/content/DialContent.tsx +96 -0
- package/src/content/DividerContent.tsx +33 -0
- package/src/content/DonutChartContent.tsx +110 -0
- package/src/content/FormContent.tsx +158 -0
- package/src/content/FormFieldBridge.tsx +144 -0
- package/src/content/GaugeContent.tsx +66 -0
- package/src/content/GridLayoutContent.tsx +285 -0
- package/src/content/ImageContent.tsx +222 -0
- package/src/content/ListContent.tsx +98 -0
- package/src/content/LocationContent.tsx +135 -0
- package/src/content/MapContent.tsx +232 -0
- package/src/content/MultipleChoiceContent.tsx +74 -0
- package/src/content/OpenBadgePreviewContent.tsx +93 -0
- package/src/content/PhotoContent.tsx +110 -0
- package/src/content/PieChartContent.tsx +121 -0
- package/src/content/ProofPresentationContent.tsx +127 -0
- package/src/content/RadioButtonContent.tsx +129 -0
- package/src/content/RowContent.tsx +627 -0
- package/src/content/SectionContent.tsx +133 -0
- package/src/content/ShareEntryContent.tsx +109 -0
- package/src/content/SimulatedHint.tsx +20 -0
- package/src/content/SliderContent.tsx +56 -0
- package/src/content/SpacerContent.tsx +15 -0
- package/src/content/SpinnerContent.tsx +24 -0
- package/src/content/SubmitButtonContent.tsx +256 -0
- package/src/content/TextContent.tsx +140 -0
- package/src/content/TileContent.tsx +216 -0
- package/src/content/TimelineContent.tsx +91 -0
- package/src/content/TitleContent.tsx +49 -0
- package/src/content/VideoContent.tsx +131 -0
- package/src/content/WebLinkContent.tsx +87 -0
- package/src/content/index.ts +45 -0
- package/src/form-fields/CheckboxField.tsx +29 -0
- package/src/form-fields/DateField.native.tsx +123 -0
- package/src/form-fields/DateField.tsx +5 -0
- package/src/form-fields/DateField.web.tsx +32 -0
- package/src/form-fields/DropdownField.tsx +137 -0
- package/src/form-fields/MCQField.tsx +68 -0
- package/src/form-fields/RadioField.tsx +53 -0
- package/src/form-fields/SliderField.native.tsx +53 -0
- package/src/form-fields/SliderField.tsx +5 -0
- package/src/form-fields/SliderField.web.tsx +58 -0
- package/src/form-fields/SubmitButtonField.tsx +33 -0
- package/src/form-fields/TextField.tsx +49 -0
- package/src/form-fields/index.ts +12 -0
- package/src/i18n/WorkflowI18n.tsx +100 -0
- package/src/icons/VectorIcon.tsx +10 -0
- package/src/icons/VectorIcon.web.tsx +55 -0
- package/src/icons/WorkflowIcon.tsx +30 -0
- package/src/icons/types.ts +13 -0
- package/src/imageUriCache.ts +27 -0
- package/src/index.ts +97 -0
- package/src/modal/WorkflowModal.tsx +119 -0
- package/src/platform/platformName.ts +7 -0
- package/src/platform/platformName.web.ts +2 -0
- package/src/protocol/controlSnapshotStore.ts +25 -0
- package/src/protocol/useProtocolExchange.ts +185 -0
- package/src/registries/ContentRegistry.tsx +130 -0
- package/src/registries/FormFieldRegistry.tsx +83 -0
- package/src/render/NodeBoundary.tsx +69 -0
- package/src/render/RenderTree.tsx +63 -0
- package/src/render/WorkflowRenderContext.tsx +71 -0
- package/src/render/nodes.ts +104 -0
- package/src/responsive/ResponsiveProvider.tsx +103 -0
- package/src/responsive/index.ts +7 -0
- package/src/responsive/responsive.ts +67 -0
- package/src/style/resolveDisplayHintStyle.ts +153 -0
- package/src/theme/WorkflowTheme.tsx +162 -0
- 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
|
+
import { coerceToChipRowItem } from './ChipRowContent'
|
|
8
|
+
|
|
9
|
+
const resolveChildLabel = (child: ContentProps['item']): string | undefined => {
|
|
10
|
+
const candidates = [child.text, child.title, child.label, child.subtitle]
|
|
11
|
+
for (const value of candidates) {
|
|
12
|
+
if (typeof value === 'string' && value.trim().length > 0) {
|
|
13
|
+
return value.trim()
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return undefined
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const ListContent: React.FC<ContentProps> = (props) => {
|
|
20
|
+
const { item, styles, colors, onAction, formData, onFieldChange, FormFieldRegistry, buttonVariant } = props
|
|
21
|
+
const { s, ms } = useResponsive()
|
|
22
|
+
const listItems: string[] = Array.isArray(item.items) ? item.items : []
|
|
23
|
+
const children: ContentProps['item'][] = Array.isArray(item.children) ? item.children : []
|
|
24
|
+
|
|
25
|
+
if (listItems.length === 0 && children.length === 0) return null
|
|
26
|
+
|
|
27
|
+
// A list of only chips (3+) is a chip row, like row / section / grid. The
|
|
28
|
+
// wallet used to apply this to every top-level item before rendering.
|
|
29
|
+
const chipRowItem = coerceToChipRowItem(item)
|
|
30
|
+
if (chipRowItem && ContentRegistry.has('chip-row')) {
|
|
31
|
+
return <>{ContentRegistry.render('chip-row', { ...props, item: chipRowItem })}</>
|
|
32
|
+
}
|
|
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
|