@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.
- package/LICENSE +202 -0
- package/README.md +202 -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 +107 -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/WorkflowIcon.js +50 -0
- package/build/module/icons/WorkflowIcon.js.map +1 -0
- package/build/module/imageUriCache.js +25 -0
- package/build/module/imageUriCache.js.map +1 -0
- package/build/module/index.js +49 -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/WorkflowIcon.d.ts +27 -0
- package/build/typescript/icons/WorkflowIcon.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 +47 -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 +101 -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/WorkflowIcon.tsx +43 -0
- package/src/imageUriCache.ts +27 -0
- package/src/index.ts +96 -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,229 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { ActivityIndicator, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
|
|
3
|
+
import { type ExchangeAttribute, useWalletAdapter } from '../adapter/WalletAdapter'
|
|
4
|
+
import WorkflowButtonLabel from '../components/WorkflowButtonLabel'
|
|
5
|
+
import { useWorkflowT } from '../i18n/WorkflowI18n'
|
|
6
|
+
import { useProtocolExchange } from '../protocol/useProtocolExchange'
|
|
7
|
+
import { type ContentProps, ContentRegistry } from '../registries/ContentRegistry'
|
|
8
|
+
import { useResponsive } from '../responsive'
|
|
9
|
+
import { resolveButtonFillStyle, resolveSurfaceBackground } from '../style/resolveDisplayHintStyle'
|
|
10
|
+
import { useWorkflowTheme } from '../theme/WorkflowTheme'
|
|
11
|
+
import { testIdWithKey } from '../utils/testable'
|
|
12
|
+
import { SimulatedHint } from './SimulatedHint'
|
|
13
|
+
|
|
14
|
+
// Collapse a possibly-JSON attribute value into a short, readable string so the
|
|
15
|
+
// text preview never dumps a raw transcript/studentInfo blob.
|
|
16
|
+
export const formatPreviewValue = (raw?: string): string => {
|
|
17
|
+
if (raw == null) return ''
|
|
18
|
+
const trimmed = String(raw).trim()
|
|
19
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(trimmed)
|
|
22
|
+
if (Array.isArray(parsed)) return `${parsed.length} item${parsed.length === 1 ? '' : 's'}`
|
|
23
|
+
if (parsed && typeof parsed === 'object') {
|
|
24
|
+
const keys = Object.keys(parsed)
|
|
25
|
+
return keys.length ? keys.slice(0, 6).join(', ') + (keys.length > 6 ? '…' : '') : '—'
|
|
26
|
+
}
|
|
27
|
+
} catch {
|
|
28
|
+
// not JSON: plain truncation below
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return trimmed.length > 120 ? `${trimmed.slice(0, 117)}…` : trimmed
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const shortId = (id: string) => (id.length > 24 ? `${id.slice(0, 12)}…${id.slice(-8)}` : id)
|
|
35
|
+
|
|
36
|
+
const noCard = () => ({ element: null, resolving: false })
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Credential offer card (CrMS contract): accept fires `item.event` (default
|
|
40
|
+
* `accept`), decline fires `decline-event` (default `decline`), `label` is the
|
|
41
|
+
* accept button text. Outcomes `accepted-event` / `error-event`.
|
|
42
|
+
*
|
|
43
|
+
* Moved from the wallet with credo, bifold hooks and navigation replaced by
|
|
44
|
+
* the WalletAdapter: records come from `useExchanges('credential')`, the
|
|
45
|
+
* designed card from `useCredentialCard`, the details screen from
|
|
46
|
+
* `openCredential`.
|
|
47
|
+
*/
|
|
48
|
+
const CredentialOfferContent: React.FC<ContentProps> = (props) => {
|
|
49
|
+
const { item, styles, groupFontScale = 1 } = props
|
|
50
|
+
const t = useWorkflowT()
|
|
51
|
+
const { ms, width } = useResponsive()
|
|
52
|
+
const { card } = useWorkflowTheme()
|
|
53
|
+
const adapter = useWalletAdapter()
|
|
54
|
+
const { phase, recordId, record, consent, decline } = useProtocolExchange({
|
|
55
|
+
...props,
|
|
56
|
+
kind: 'credential',
|
|
57
|
+
adapter,
|
|
58
|
+
defaultEvent: 'accept',
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
const acceptLabel = (typeof item.label === 'string' && item.label.trim()) || t('Workflow.AcceptCredential')
|
|
62
|
+
const credDefId = typeof item['cred-def-id'] === 'string' ? item['cred-def-id'] : ''
|
|
63
|
+
const itemAttributes = Array.isArray(item.attributes) ? (item.attributes as ExchangeAttribute[]) : []
|
|
64
|
+
const recordAttributes = record?.attributes ?? []
|
|
65
|
+
|
|
66
|
+
// At offer time the record's attributes are often still empty; the offered
|
|
67
|
+
// values live in the offer's format data until the credential is issued.
|
|
68
|
+
const [offerAttributes, setOfferAttributes] = useState<ExchangeAttribute[]>([])
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
const id = record?.id
|
|
71
|
+
if (!id || recordAttributes.length > 0 || !adapter.getOfferedAttributes) return
|
|
72
|
+
let cancelled = false
|
|
73
|
+
adapter
|
|
74
|
+
.getOfferedAttributes(id)
|
|
75
|
+
.then((offered) => {
|
|
76
|
+
if (!cancelled && offered.length > 0) setOfferAttributes(offered)
|
|
77
|
+
})
|
|
78
|
+
.catch(() => undefined)
|
|
79
|
+
return () => {
|
|
80
|
+
cancelled = true
|
|
81
|
+
}
|
|
82
|
+
}, [adapter, record?.id, recordAttributes.length])
|
|
83
|
+
|
|
84
|
+
// The item's `attributes` are only a designer placeholder; real values win.
|
|
85
|
+
const realAttributes = recordAttributes.length > 0 ? recordAttributes : offerAttributes
|
|
86
|
+
const cardAttributes = realAttributes.length > 0 ? realAttributes : itemAttributes
|
|
87
|
+
const previewAttributes = offerAttributes.length > 0 ? offerAttributes : itemAttributes
|
|
88
|
+
|
|
89
|
+
const openDetails = () => {
|
|
90
|
+
if (phase === 'done' && recordId) adapter.openCredential?.(recordId)
|
|
91
|
+
}
|
|
92
|
+
const cardWidth = Math.min(300, width - 72)
|
|
93
|
+
const useCard = adapter.useCredentialCard ?? noCard
|
|
94
|
+
const designed = useCard({
|
|
95
|
+
credDefId: credDefId || undefined,
|
|
96
|
+
attributes: cardAttributes,
|
|
97
|
+
record,
|
|
98
|
+
width: cardWidth,
|
|
99
|
+
onPress: phase === 'done' ? openDetails : undefined,
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
const fill = resolveSurfaceBackground(item.bgColor as string | undefined)
|
|
103
|
+
const statusText: Record<string, string> = {
|
|
104
|
+
awaiting: t('Workflow.WaitingForOffer'),
|
|
105
|
+
working: t('Workflow.ReceivingCredential'),
|
|
106
|
+
done: t('Workflow.CredentialReceived'),
|
|
107
|
+
declined: t('Workflow.OfferDeclined'),
|
|
108
|
+
error: t('Workflow.OfferFailed'),
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<TouchableOpacity
|
|
113
|
+
activeOpacity={phase === 'done' ? 0.7 : 1}
|
|
114
|
+
onPress={openDetails}
|
|
115
|
+
testID={testIdWithKey('WorkflowCredentialOffer')}
|
|
116
|
+
accessibilityLabel={t('Workflow.CredentialOffer')}
|
|
117
|
+
>
|
|
118
|
+
<View
|
|
119
|
+
style={[
|
|
120
|
+
styles.fieldContainer,
|
|
121
|
+
s.card,
|
|
122
|
+
{ backgroundColor: card.surface, borderColor: card.border },
|
|
123
|
+
fill !== 'transparent' ? { backgroundColor: fill } : null,
|
|
124
|
+
]}
|
|
125
|
+
>
|
|
126
|
+
<View style={s.headerRow}>
|
|
127
|
+
<Text style={[s.kicker, { color: card.offerKicker }]}>{t('Workflow.CredentialOffer').toUpperCase()}</Text>
|
|
128
|
+
{credDefId ? <Text style={[s.id, { color: card.mutedId }]}>{shortId(credDefId)}</Text> : null}
|
|
129
|
+
</View>
|
|
130
|
+
{item.text ? (
|
|
131
|
+
<Text style={[styles.description, { color: card.text, marginBottom: 4 }]}>{String(item.text)}</Text>
|
|
132
|
+
) : null}
|
|
133
|
+
{designed.element ? (
|
|
134
|
+
<View style={s.cardSlot}>{designed.element}</View>
|
|
135
|
+
) : designed.resolving ? (
|
|
136
|
+
<View style={[s.cardSlot, s.skeleton, { width: cardWidth, height: (cardWidth * 264) / 420 }]}>
|
|
137
|
+
<ActivityIndicator color="#016C72" />
|
|
138
|
+
</View>
|
|
139
|
+
) : previewAttributes.length > 0 || realAttributes.length > 0 ? (
|
|
140
|
+
<View style={s.attrList}>
|
|
141
|
+
{(realAttributes.length > 0 ? realAttributes : previewAttributes).map((attr, i) => (
|
|
142
|
+
<Text key={`${attr.name}-${i}`} style={[s.attrLine, { color: card.text }]}>
|
|
143
|
+
<Text style={s.attrName}>{attr.name}</Text>
|
|
144
|
+
{attr.value != null ? `: ${formatPreviewValue(attr.value)}` : ''}
|
|
145
|
+
</Text>
|
|
146
|
+
))}
|
|
147
|
+
</View>
|
|
148
|
+
) : null}
|
|
149
|
+
|
|
150
|
+
{phase === 'ready' ? (
|
|
151
|
+
<View style={s.btnRow}>
|
|
152
|
+
<TouchableOpacity
|
|
153
|
+
style={[s.primaryBtn, { backgroundColor: card.accent }, resolveButtonFillStyle(item)]}
|
|
154
|
+
onPress={consent}
|
|
155
|
+
disabled={props.disabled}
|
|
156
|
+
activeOpacity={0.85}
|
|
157
|
+
testID={testIdWithKey('WorkflowCredentialOfferAccept')}
|
|
158
|
+
>
|
|
159
|
+
<WorkflowButtonLabel
|
|
160
|
+
style={[s.btnText, { fontSize: ms(13), color: card.buttonText }]}
|
|
161
|
+
groupFontScale={groupFontScale}
|
|
162
|
+
>
|
|
163
|
+
{acceptLabel}
|
|
164
|
+
</WorkflowButtonLabel>
|
|
165
|
+
</TouchableOpacity>
|
|
166
|
+
<TouchableOpacity
|
|
167
|
+
style={[s.secondaryBtn, { borderColor: card.border }]}
|
|
168
|
+
onPress={decline}
|
|
169
|
+
disabled={props.disabled}
|
|
170
|
+
activeOpacity={0.7}
|
|
171
|
+
testID={testIdWithKey('WorkflowCredentialOfferDecline')}
|
|
172
|
+
>
|
|
173
|
+
<WorkflowButtonLabel
|
|
174
|
+
style={[s.btnText, { fontSize: ms(13), color: card.text }]}
|
|
175
|
+
groupFontScale={groupFontScale}
|
|
176
|
+
>
|
|
177
|
+
{t('Global.Decline')}
|
|
178
|
+
</WorkflowButtonLabel>
|
|
179
|
+
</TouchableOpacity>
|
|
180
|
+
</View>
|
|
181
|
+
) : (
|
|
182
|
+
<View style={s.statusRow}>
|
|
183
|
+
{phase === 'awaiting' || phase === 'working' ? (
|
|
184
|
+
<ActivityIndicator size="small" color={card.accent} />
|
|
185
|
+
) : null}
|
|
186
|
+
<Text style={[s.statusText, { color: card.text }]}>{statusText[phase]}</Text>
|
|
187
|
+
</View>
|
|
188
|
+
)}
|
|
189
|
+
{adapter.simulated ? <SimulatedHint color={card.mutedId} /> : null}
|
|
190
|
+
</View>
|
|
191
|
+
</TouchableOpacity>
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Card styles shared with the proof-presentation control. */
|
|
196
|
+
export const s = StyleSheet.create({
|
|
197
|
+
card: { borderWidth: 1, borderRadius: 10, padding: 12, gap: 8 },
|
|
198
|
+
headerRow: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', gap: 8, minWidth: 0 },
|
|
199
|
+
kicker: { fontSize: 11, fontWeight: '700', letterSpacing: 0.5, flexShrink: 1 },
|
|
200
|
+
id: { fontSize: 11, fontFamily: 'Courier', flexShrink: 1 },
|
|
201
|
+
attrList: { gap: 4 },
|
|
202
|
+
cardSlot: { marginTop: 4 },
|
|
203
|
+
skeleton: { borderRadius: 12, justifyContent: 'center', alignItems: 'center', backgroundColor: 'rgba(0,0,0,0.04)' },
|
|
204
|
+
attrLine: { fontSize: 12 },
|
|
205
|
+
attrName: { fontWeight: '700' },
|
|
206
|
+
btnRow: { flexDirection: 'row', gap: 8, justifyContent: 'flex-end', marginTop: 4 },
|
|
207
|
+
primaryBtn: {
|
|
208
|
+
paddingHorizontal: 12,
|
|
209
|
+
paddingVertical: 8,
|
|
210
|
+
borderRadius: 8,
|
|
211
|
+
alignItems: 'center',
|
|
212
|
+
justifyContent: 'center',
|
|
213
|
+
},
|
|
214
|
+
secondaryBtn: {
|
|
215
|
+
paddingHorizontal: 12,
|
|
216
|
+
paddingVertical: 8,
|
|
217
|
+
borderRadius: 8,
|
|
218
|
+
borderWidth: 1,
|
|
219
|
+
alignItems: 'center',
|
|
220
|
+
justifyContent: 'center',
|
|
221
|
+
},
|
|
222
|
+
btnText: { fontWeight: '600' },
|
|
223
|
+
statusRow: { flexDirection: 'row', alignItems: 'center', gap: 8, marginTop: 4, minHeight: 32 },
|
|
224
|
+
statusText: { fontSize: 13, fontWeight: '600', flexShrink: 1 },
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
ContentRegistry.register('credential-offer', CredentialOfferContent)
|
|
228
|
+
|
|
229
|
+
export default CredentialOfferContent
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet, TouchableOpacity, View } from 'react-native'
|
|
3
|
+
import { useWalletAdapter } from '../adapter/WalletAdapter'
|
|
4
|
+
import WorkflowButtonLabel from '../components/WorkflowButtonLabel'
|
|
5
|
+
import { WorkflowIcon } from '../icons/WorkflowIcon'
|
|
6
|
+
import { type ContentProps, ContentRegistry } from '../registries/ContentRegistry'
|
|
7
|
+
import { useResponsive } from '../responsive'
|
|
8
|
+
import {
|
|
9
|
+
resolveButtonFillStyle,
|
|
10
|
+
resolveItemSurfaceStyle,
|
|
11
|
+
resolveSurfaceBackground,
|
|
12
|
+
} from '../style/resolveDisplayHintStyle'
|
|
13
|
+
|
|
14
|
+
const WHITE = '#FFFFFF'
|
|
15
|
+
|
|
16
|
+
const DialContent: React.FC<ContentProps> = ({ item, fillContainer, groupFontScale = 1 }) => {
|
|
17
|
+
const { s, ms, isSmall } = useResponsive()
|
|
18
|
+
const adapter = useWalletAdapter()
|
|
19
|
+
const explicitNumber =
|
|
20
|
+
(typeof item.number === 'string' && item.number.trim()) ||
|
|
21
|
+
(typeof item.value === 'string' && item.value.trim()) ||
|
|
22
|
+
''
|
|
23
|
+
const text = typeof item.text === 'string' ? item.text.trim() : ''
|
|
24
|
+
const labelProp = typeof item.label === 'string' ? item.label.trim() : ''
|
|
25
|
+
const number = explicitNumber || (!text ? labelProp : '') || ''
|
|
26
|
+
const label = text || (explicitNumber && labelProp ? labelProp : '') || (number ? `Call ${number}` : 'Call')
|
|
27
|
+
|
|
28
|
+
const handleDial = () => {
|
|
29
|
+
if (number) {
|
|
30
|
+
void adapter.openUrl(`tel:${number}`).catch(() => undefined)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!number) {
|
|
35
|
+
return null
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const fill = resolveSurfaceBackground(item.bgColor as string | undefined)
|
|
39
|
+
const isTransparent = fill === 'transparent'
|
|
40
|
+
const minHeight = s(isSmall ? 44 : 52)
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<View style={[local.wrap, resolveItemSurfaceStyle(item), fillContainer ? { flex: 1, marginBottom: 0 } : null]}>
|
|
44
|
+
<TouchableOpacity
|
|
45
|
+
style={[
|
|
46
|
+
local.pill,
|
|
47
|
+
{
|
|
48
|
+
minHeight,
|
|
49
|
+
borderRadius: minHeight / 2,
|
|
50
|
+
paddingVertical: s(isSmall ? 10 : 14),
|
|
51
|
+
paddingHorizontal: s(isSmall ? 12 : 16),
|
|
52
|
+
marginTop: fillContainer ? 0 : s(8),
|
|
53
|
+
},
|
|
54
|
+
fillContainer ? { flex: 1, alignSelf: 'stretch', height: '100%', maxWidth: '100%' } : null,
|
|
55
|
+
resolveButtonFillStyle(item, { includePadding: false }),
|
|
56
|
+
isTransparent
|
|
57
|
+
? {
|
|
58
|
+
backgroundColor: 'transparent',
|
|
59
|
+
borderWidth: 1.5,
|
|
60
|
+
borderColor: WHITE,
|
|
61
|
+
}
|
|
62
|
+
: null,
|
|
63
|
+
]}
|
|
64
|
+
onPress={handleDial}
|
|
65
|
+
activeOpacity={0.85}
|
|
66
|
+
>
|
|
67
|
+
<WorkflowIcon name="phone" size={s(18)} color={WHITE} style={{ marginRight: s(6) }} />
|
|
68
|
+
<WorkflowButtonLabel
|
|
69
|
+
style={{ color: WHITE, fontWeight: '700', fontSize: ms(isSmall ? 13 : 15) }}
|
|
70
|
+
groupFontScale={groupFontScale}
|
|
71
|
+
>
|
|
72
|
+
{label}
|
|
73
|
+
</WorkflowButtonLabel>
|
|
74
|
+
</TouchableOpacity>
|
|
75
|
+
</View>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const local = StyleSheet.create({
|
|
80
|
+
wrap: {
|
|
81
|
+
width: '100%',
|
|
82
|
+
minWidth: 0,
|
|
83
|
+
},
|
|
84
|
+
pill: {
|
|
85
|
+
flexDirection: 'row',
|
|
86
|
+
width: '100%',
|
|
87
|
+
alignItems: 'center',
|
|
88
|
+
justifyContent: 'center',
|
|
89
|
+
flexShrink: 1,
|
|
90
|
+
minWidth: 0,
|
|
91
|
+
},
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
ContentRegistry.register('dial', DialContent)
|
|
95
|
+
|
|
96
|
+
export default DialContent
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View } from 'react-native'
|
|
3
|
+
|
|
4
|
+
import { type ContentProps, ContentRegistry } from '../registries/ContentRegistry'
|
|
5
|
+
import {
|
|
6
|
+
resolveItemSurfaceStyle,
|
|
7
|
+
resolveSurfaceBackground,
|
|
8
|
+
resolveSurfacePadding,
|
|
9
|
+
} from '../style/resolveDisplayHintStyle'
|
|
10
|
+
|
|
11
|
+
const DividerContent: React.FC<ContentProps> = ({ item, colors }) => {
|
|
12
|
+
const padding = resolveSurfacePadding(item.padding)
|
|
13
|
+
const backgroundColor = resolveSurfaceBackground(item.bgColor as string | undefined)
|
|
14
|
+
const lineColor = backgroundColor === 'transparent' ? colors.border : backgroundColor
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<View
|
|
18
|
+
style={[
|
|
19
|
+
{
|
|
20
|
+
height: 1,
|
|
21
|
+
backgroundColor: lineColor,
|
|
22
|
+
opacity: backgroundColor === 'transparent' ? 0.3 : 1,
|
|
23
|
+
marginVertical: padding !== undefined ? Math.max(4, Math.floor(padding / 2)) : 4,
|
|
24
|
+
},
|
|
25
|
+
resolveItemSurfaceStyle(item),
|
|
26
|
+
]}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
ContentRegistry.register('divider', DividerContent)
|
|
32
|
+
|
|
33
|
+
export default DividerContent
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Text, View } from 'react-native'
|
|
3
|
+
import Svg, { Circle, G } from 'react-native-svg'
|
|
4
|
+
import { type ContentProps, ContentRegistry } from '../registries/ContentRegistry'
|
|
5
|
+
import { resolveItemSurfaceStyle } from '../style/resolveDisplayHintStyle'
|
|
6
|
+
|
|
7
|
+
interface SliceItem {
|
|
8
|
+
label: string
|
|
9
|
+
count: number | string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const parseCount = (count: number | string): number => {
|
|
13
|
+
if (typeof count === 'number') return count
|
|
14
|
+
return parseFloat(count) || 0
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const DEFAULT_SLICES: SliceItem[] = [
|
|
18
|
+
{ label: 'Complete', count: 65 },
|
|
19
|
+
{ label: 'Remaining', count: 35 },
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
const DonutChartContent: React.FC<ContentProps> = ({ item, styles, colors }) => {
|
|
23
|
+
const rawSlices: SliceItem[] = item.slices || []
|
|
24
|
+
const slices = rawSlices.length > 0 ? rawSlices : DEFAULT_SLICES
|
|
25
|
+
|
|
26
|
+
const size = 200
|
|
27
|
+
const radius = size / 2
|
|
28
|
+
const donutWidth = 40 // Width of the donut ring
|
|
29
|
+
const innerRadius = radius - donutWidth
|
|
30
|
+
|
|
31
|
+
// Calculate total for percentages
|
|
32
|
+
const total = slices.reduce((sum, slice) => sum + parseCount(slice.count), 0)
|
|
33
|
+
|
|
34
|
+
// Predefined colors for slices
|
|
35
|
+
const sliceColors = ['#FF6384', '#36A2EB', '#FFCE56', '#4BC0C0', '#9966FF', '#FF9F40']
|
|
36
|
+
|
|
37
|
+
let currentAngle = -90 // Start at top
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<View style={[styles.fieldContainer, resolveItemSurfaceStyle(item)]}>
|
|
41
|
+
{item.title && (
|
|
42
|
+
<Text style={[styles.formLabel, { color: colors.text, marginBottom: 12, textAlign: 'center' }]}>
|
|
43
|
+
{item.title}
|
|
44
|
+
</Text>
|
|
45
|
+
)}
|
|
46
|
+
|
|
47
|
+
<View style={{ alignItems: 'center' }}>
|
|
48
|
+
<Svg width={size} height={size}>
|
|
49
|
+
<G rotation={0} origin={`${radius}, ${radius}`}>
|
|
50
|
+
{slices.map((slice, index) => {
|
|
51
|
+
const count = parseCount(slice.count)
|
|
52
|
+
const percentage = (count / total) * 100
|
|
53
|
+
const angle = (percentage / 100) * 360
|
|
54
|
+
|
|
55
|
+
// Calculate stroke-dasharray for each slice
|
|
56
|
+
const circumference = 2 * Math.PI * innerRadius
|
|
57
|
+
const strokeDasharray = `${(angle / 360) * circumference} ${circumference}`
|
|
58
|
+
const rotation = currentAngle
|
|
59
|
+
|
|
60
|
+
currentAngle += angle
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<Circle
|
|
64
|
+
key={index}
|
|
65
|
+
cx={radius}
|
|
66
|
+
cy={radius}
|
|
67
|
+
r={innerRadius}
|
|
68
|
+
fill="none"
|
|
69
|
+
stroke={sliceColors[index % sliceColors.length]}
|
|
70
|
+
strokeWidth={donutWidth}
|
|
71
|
+
strokeDasharray={strokeDasharray}
|
|
72
|
+
rotation={rotation}
|
|
73
|
+
origin={`${radius}, ${radius}`}
|
|
74
|
+
/>
|
|
75
|
+
)
|
|
76
|
+
})}
|
|
77
|
+
</G>
|
|
78
|
+
</Svg>
|
|
79
|
+
|
|
80
|
+
{/* Legend */}
|
|
81
|
+
<View style={{ marginTop: 16, width: '100%' }}>
|
|
82
|
+
{slices.map((slice, index) => {
|
|
83
|
+
const count = parseCount(slice.count)
|
|
84
|
+
const percentage = ((count / total) * 100).toFixed(1)
|
|
85
|
+
return (
|
|
86
|
+
<View key={index} style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 8 }}>
|
|
87
|
+
<View
|
|
88
|
+
style={{
|
|
89
|
+
width: 16,
|
|
90
|
+
height: 16,
|
|
91
|
+
backgroundColor: sliceColors[index % sliceColors.length],
|
|
92
|
+
borderRadius: 2,
|
|
93
|
+
marginRight: 8,
|
|
94
|
+
}}
|
|
95
|
+
/>
|
|
96
|
+
<Text style={[styles.description, { color: colors.text, fontSize: 13 }]}>
|
|
97
|
+
{slice.label}: {count} ({percentage}%)
|
|
98
|
+
</Text>
|
|
99
|
+
</View>
|
|
100
|
+
)
|
|
101
|
+
})}
|
|
102
|
+
</View>
|
|
103
|
+
</View>
|
|
104
|
+
</View>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
ContentRegistry.register('donut-chart', DonutChartContent)
|
|
109
|
+
|
|
110
|
+
export default DonutChartContent
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react'
|
|
2
|
+
import { View } from 'react-native'
|
|
3
|
+
import { type ContentProps, ContentRegistry } from '../registries/ContentRegistry'
|
|
4
|
+
import { FormFieldRegistry as GlobalFormFieldRegistry } from '../registries/FormFieldRegistry'
|
|
5
|
+
import { deriveNode } from '../render/nodes'
|
|
6
|
+
import { LiveInputContext } from '../render/WorkflowRenderContext'
|
|
7
|
+
import { useWorkflowTheme } from '../theme/WorkflowTheme'
|
|
8
|
+
|
|
9
|
+
// Field styles come from the theme and win over the host's own `styles`
|
|
10
|
+
// (inputs inside a form look the same on every screen).
|
|
11
|
+
const FIELD_STYLE_KEYS = [
|
|
12
|
+
'input',
|
|
13
|
+
'dateButton',
|
|
14
|
+
'dropdown',
|
|
15
|
+
'checkboxRow',
|
|
16
|
+
'checkbox',
|
|
17
|
+
'checkboxLabel',
|
|
18
|
+
'radioRow',
|
|
19
|
+
'radioOuter',
|
|
20
|
+
'radioInner',
|
|
21
|
+
'radioLabel',
|
|
22
|
+
] as const
|
|
23
|
+
|
|
24
|
+
interface FormContentProps extends ContentProps {
|
|
25
|
+
formData?: Record<string, any>
|
|
26
|
+
onFieldChange?: (name: string, value: any) => void
|
|
27
|
+
FormFieldRegistry?: any
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Whether a form child is an input (rendered by the form-field registry) or a
|
|
32
|
+
* display item such as a paragraph, title or divider (rendered by the content
|
|
33
|
+
* registry). `text` is both: with a `name` / `form-id` it is the legacy text
|
|
34
|
+
* input (action-menu `fields`), without one it is a paragraph.
|
|
35
|
+
*/
|
|
36
|
+
export function isFormFieldChild(field: any, registry: { has(type: string): boolean }): boolean {
|
|
37
|
+
if (!field || typeof field.type !== 'string' || !registry.has(field.type)) return false
|
|
38
|
+
if (field.type === 'text') return Boolean(field.name || field['form-id'])
|
|
39
|
+
return true
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const FormContent: React.FC<FormContentProps> = ({
|
|
43
|
+
item,
|
|
44
|
+
styles,
|
|
45
|
+
colors,
|
|
46
|
+
formData = {},
|
|
47
|
+
onFieldChange,
|
|
48
|
+
onAction,
|
|
49
|
+
FormFieldRegistry,
|
|
50
|
+
}) => {
|
|
51
|
+
const registry = FormFieldRegistry || GlobalFormFieldRegistry
|
|
52
|
+
const theme = useWorkflowTheme()
|
|
53
|
+
const children: any[] = Array.isArray(item.fields)
|
|
54
|
+
? item.fields
|
|
55
|
+
: Array.isArray((item as any).children)
|
|
56
|
+
? (item as any).children
|
|
57
|
+
: []
|
|
58
|
+
// Only inputs carry form values; display children are rendered but never submitted.
|
|
59
|
+
const fields: any[] = children.filter((field) => isFormFieldChild(field, registry))
|
|
60
|
+
|
|
61
|
+
const initialValues: Record<string, any> = {}
|
|
62
|
+
fields.forEach((field: any, index: number) => {
|
|
63
|
+
const name = field.name || field['form-id'] || `field_${index}`
|
|
64
|
+
initialValues[name] = formData[name] ?? field.defaultValue ?? ''
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const [localValues, setLocalValues] = useState<Record<string, any>>(initialValues)
|
|
68
|
+
const onFieldChangeRef = useRef(onFieldChange)
|
|
69
|
+
onFieldChangeRef.current = onFieldChange
|
|
70
|
+
const fieldsKey = fields
|
|
71
|
+
.map((field: any, index: number) => field.name || field['form-id'] || `field_${index}`)
|
|
72
|
+
.join('|')
|
|
73
|
+
|
|
74
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: re-run only when the set of fields changes (fieldsKey), not on every formData update
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
fields.forEach((field: any, index: number) => {
|
|
77
|
+
const name = field.name || field['form-id'] || `field_${index}`
|
|
78
|
+
const def = field.defaultValue
|
|
79
|
+
if (formData[name] == null && def != null && def !== '') {
|
|
80
|
+
onFieldChangeRef.current?.(name, def)
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}, [fieldsKey])
|
|
84
|
+
|
|
85
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: fields is derived from props each render; fieldsKey is its stable identity
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
setLocalValues((prev) => {
|
|
88
|
+
const next = { ...prev }
|
|
89
|
+
let changed = false
|
|
90
|
+
fields.forEach((field: any, index: number) => {
|
|
91
|
+
const name = field.name || field['form-id'] || `field_${index}`
|
|
92
|
+
if (formData[name] !== undefined && next[name] !== formData[name]) {
|
|
93
|
+
next[name] = formData[name]
|
|
94
|
+
changed = true
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
return changed ? next : prev
|
|
98
|
+
})
|
|
99
|
+
}, [formData, fieldsKey])
|
|
100
|
+
|
|
101
|
+
if (children.length === 0) {
|
|
102
|
+
return null
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const mergedStyles = { ...styles }
|
|
106
|
+
for (const key of FIELD_STYLE_KEYS) mergedStyles[key] = theme.styles[key]
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
// Fields read the form's own values for `showWhen` / `{{ input.x }}` (see render/NodeBoundary).
|
|
110
|
+
<LiveInputContext.Provider value={localValues}>
|
|
111
|
+
<View style={{ borderWidth: 1, borderColor: colors.border, borderRadius: 8, padding: 12, gap: 4 }}>
|
|
112
|
+
{children.map((child: any, childIndex: number) => {
|
|
113
|
+
if (!isFormFieldChild(child, registry)) {
|
|
114
|
+
return (
|
|
115
|
+
<View key={`display-${childIndex}`}>
|
|
116
|
+
{ContentRegistry.render(child?.type, {
|
|
117
|
+
item: child,
|
|
118
|
+
onAction,
|
|
119
|
+
styles,
|
|
120
|
+
colors,
|
|
121
|
+
formData: localValues,
|
|
122
|
+
onFieldChange,
|
|
123
|
+
})}
|
|
124
|
+
</View>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
const field = child
|
|
128
|
+
const index = fields.indexOf(child)
|
|
129
|
+
const name = field.name || field['form-id'] || `field_${index}`
|
|
130
|
+
const fieldValue = localValues[name]
|
|
131
|
+
|
|
132
|
+
const handleChange = (value: any) => {
|
|
133
|
+
setLocalValues((prev) => ({ ...prev, [name]: value }))
|
|
134
|
+
if (onFieldChange) onFieldChange(name, value)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const normalizedField = deriveNode(field, { name })
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<View key={`${name}-${index}`}>
|
|
141
|
+
{registry.render(field.type, {
|
|
142
|
+
field: normalizedField,
|
|
143
|
+
value: fieldValue,
|
|
144
|
+
onChange: handleChange,
|
|
145
|
+
styles: mergedStyles,
|
|
146
|
+
colors,
|
|
147
|
+
})}
|
|
148
|
+
</View>
|
|
149
|
+
)
|
|
150
|
+
})}
|
|
151
|
+
</View>
|
|
152
|
+
</LiveInputContext.Provider>
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
ContentRegistry.register('form', FormContent)
|
|
157
|
+
|
|
158
|
+
export default FormContent
|