@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,185 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
2
|
+
import type { ExchangeKind, ExchangeRecord, WalletAdapter } from '../adapter/WalletAdapter'
|
|
3
|
+
import type { ContentProps } from '../registries/ContentRegistry'
|
|
4
|
+
import { getControlSnapshot, saveControlSnapshot } from './controlSnapshotStore'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* - `ready`: the action buttons show (credential offer / proof request card).
|
|
8
|
+
* - `awaiting`: the user consented; waiting for the offer or request to arrive.
|
|
9
|
+
* - `working`: accepting the offer / presenting the proof.
|
|
10
|
+
* - `done`, `declined`, `error`: final.
|
|
11
|
+
*/
|
|
12
|
+
export type ExchangePhase = 'ready' | 'awaiting' | 'working' | 'done' | 'declined' | 'error'
|
|
13
|
+
|
|
14
|
+
// Grace window when matching an arriving record to this control: records
|
|
15
|
+
// created more than this long before the control mounted belong to some other
|
|
16
|
+
// flow and must not be silently consumed here.
|
|
17
|
+
const ARM_SKEW_MS = 60 * 1000
|
|
18
|
+
|
|
19
|
+
type Options = Pick<
|
|
20
|
+
ContentProps,
|
|
21
|
+
'item' | 'onAction' | 'onOutcome' | 'connectionId' | 'persistKey' | 'autoFireCheck'
|
|
22
|
+
> & {
|
|
23
|
+
kind: ExchangeKind
|
|
24
|
+
adapter: WalletAdapter
|
|
25
|
+
/** Default for `item.event` (`accept` for offers, `present` for proofs). */
|
|
26
|
+
defaultEvent: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const pick = (value: unknown, fallback: string) => (typeof value === 'string' && value.trim()) || fallback
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The shared lifecycle of the credential-offer and proof-presentation
|
|
33
|
+
* controls, moved from the wallet with credo replaced by the adapter.
|
|
34
|
+
*
|
|
35
|
+
* The watcher is armed from mount because the CrMS coordinator usually sends
|
|
36
|
+
* the offer / request as soon as the state is entered (before any tap).
|
|
37
|
+
* Pressing the primary button consents: an arrived record is accepted
|
|
38
|
+
* directly; otherwise the control waits for it and, for event-driven
|
|
39
|
+
* templates only, fires the workflow event to request it. Firing the event
|
|
40
|
+
* when the coordinator also auto-fires would duplicate the exchange, which
|
|
41
|
+
* this control must never do. Outcomes (`accepted`, `error`, decline) go back
|
|
42
|
+
* through `onOutcome` when the host provides it.
|
|
43
|
+
*
|
|
44
|
+
* The phase is kept in the snapshot store under `persistKey`, so leaving and
|
|
45
|
+
* re-entering the screen cannot bring the buttons back.
|
|
46
|
+
*/
|
|
47
|
+
export function useProtocolExchange({
|
|
48
|
+
kind,
|
|
49
|
+
adapter,
|
|
50
|
+
item,
|
|
51
|
+
onAction,
|
|
52
|
+
onOutcome,
|
|
53
|
+
connectionId,
|
|
54
|
+
persistKey,
|
|
55
|
+
autoFireCheck,
|
|
56
|
+
defaultEvent,
|
|
57
|
+
}: Options) {
|
|
58
|
+
const primaryEvent = pick(item.event, defaultEvent)
|
|
59
|
+
const declineEvent = pick(item['decline-event'], 'decline')
|
|
60
|
+
const acceptedEvent = pick(item['accepted-event'], 'accepted')
|
|
61
|
+
const errorEvent = pick(item['error-event'], 'error')
|
|
62
|
+
const idKey = kind === 'credential' ? 'credentialId' : 'proofId'
|
|
63
|
+
|
|
64
|
+
const snapshot = getControlSnapshot(persistKey)
|
|
65
|
+
const [phase, setPhase] = useState<ExchangePhase>(snapshot ? toPhase(snapshot.phase) : 'ready')
|
|
66
|
+
const [recordId, setRecordId] = useState<string | null>(snapshot?.recordId ?? null)
|
|
67
|
+
const armedAtRef = useRef<number | null>(snapshot?.armedAt ?? Date.now())
|
|
68
|
+
const handledIdsRef = useRef<Set<string>>(new Set(snapshot?.handledIds ?? []))
|
|
69
|
+
const outcomeSentRef = useRef(snapshot?.outcomeSent ?? false)
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
saveControlSnapshot(persistKey, {
|
|
73
|
+
phase,
|
|
74
|
+
recordId,
|
|
75
|
+
armedAt: armedAtRef.current,
|
|
76
|
+
handledIds: [...handledIdsRef.current],
|
|
77
|
+
outcomeSent: outcomeSentRef.current,
|
|
78
|
+
})
|
|
79
|
+
}, [persistKey, phase, recordId])
|
|
80
|
+
|
|
81
|
+
const records = adapter.useExchanges(kind)
|
|
82
|
+
// The wallet always knows the connection; the simulated adapter may not.
|
|
83
|
+
const canWatch = Boolean(connectionId) || adapter.simulated
|
|
84
|
+
|
|
85
|
+
const fireOutcome = useCallback(
|
|
86
|
+
(event: string, data?: Record<string, unknown>) => {
|
|
87
|
+
if (outcomeSentRef.current) return
|
|
88
|
+
outcomeSentRef.current = true
|
|
89
|
+
;(onOutcome ?? onAction)(event, data)
|
|
90
|
+
},
|
|
91
|
+
[onAction, onOutcome]
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
const acceptRecord = useCallback(
|
|
95
|
+
(id: string) => {
|
|
96
|
+
handledIdsRef.current.add(id)
|
|
97
|
+
setRecordId(id)
|
|
98
|
+
setPhase('working')
|
|
99
|
+
adapter.acceptExchange(kind, id).catch((error: unknown) => {
|
|
100
|
+
setPhase('error')
|
|
101
|
+
fireOutcome(errorEvent, { message: error instanceof Error ? error.message : String(error) })
|
|
102
|
+
})
|
|
103
|
+
},
|
|
104
|
+
[adapter, kind, errorEvent, fireOutcome]
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
// Watch for the record on this workflow's connection. Before consent it is
|
|
108
|
+
// only remembered; after consent it is accepted immediately.
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if ((phase !== 'ready' && phase !== 'awaiting') || !canWatch) return
|
|
111
|
+
const armedAt = armedAtRef.current ?? 0
|
|
112
|
+
const pending = records.find(
|
|
113
|
+
(r) =>
|
|
114
|
+
r.status === 'pending' &&
|
|
115
|
+
r.connectionId === connectionId &&
|
|
116
|
+
!handledIdsRef.current.has(r.id) &&
|
|
117
|
+
r.createdAt >= armedAt - ARM_SKEW_MS
|
|
118
|
+
)
|
|
119
|
+
if (!pending) return
|
|
120
|
+
if (phase === 'awaiting') acceptRecord(pending.id)
|
|
121
|
+
else if (recordId !== pending.id) setRecordId(pending.id)
|
|
122
|
+
}, [phase, canWatch, connectionId, records, recordId, acceptRecord])
|
|
123
|
+
|
|
124
|
+
// Final states of the accepted record → workflow outcome events.
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (!recordId || phase !== 'working') return
|
|
127
|
+
const record = records.find((r) => r.id === recordId)
|
|
128
|
+
if (record?.status === 'success') {
|
|
129
|
+
setPhase('done')
|
|
130
|
+
fireOutcome(acceptedEvent, { [idKey]: recordId })
|
|
131
|
+
} else if (record?.status === 'declined') {
|
|
132
|
+
setPhase('declined')
|
|
133
|
+
fireOutcome(declineEvent, { [idKey]: recordId })
|
|
134
|
+
} else if (record?.status === 'failed') {
|
|
135
|
+
setPhase('error')
|
|
136
|
+
fireOutcome(errorEvent, { [idKey]: recordId })
|
|
137
|
+
}
|
|
138
|
+
}, [recordId, phase, records, acceptedEvent, declineEvent, errorEvent, idKey, fireOutcome])
|
|
139
|
+
|
|
140
|
+
const consent = () => {
|
|
141
|
+
if (recordId && !handledIdsRef.current.has(recordId)) {
|
|
142
|
+
// Already arrived (the coordinator sent it): accept directly.
|
|
143
|
+
acceptRecord(recordId)
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
setPhase('awaiting')
|
|
147
|
+
adapter.expectExchange?.(kind, connectionId)
|
|
148
|
+
if (!autoFireCheck?.(primaryEvent)) onAction(primaryEvent)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const decline = () => {
|
|
152
|
+
setPhase('declined')
|
|
153
|
+
if (recordId && !handledIdsRef.current.has(recordId)) {
|
|
154
|
+
handledIdsRef.current.add(recordId)
|
|
155
|
+
adapter.declineExchange(kind, recordId).catch(() => undefined)
|
|
156
|
+
}
|
|
157
|
+
// Many templates have no decline transition: the outcome channel keeps
|
|
158
|
+
// that from surfacing as an error.
|
|
159
|
+
;(onOutcome ?? onAction)(declineEvent)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const record: ExchangeRecord | undefined = recordId ? records.find((r) => r.id === recordId) : undefined
|
|
163
|
+
return { phase, recordId, record, consent, decline }
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Snapshots written by the wallet's own controls used their phase names.
|
|
167
|
+
const toPhase = (saved: string): ExchangePhase => {
|
|
168
|
+
switch (saved) {
|
|
169
|
+
case 'offer':
|
|
170
|
+
case 'request':
|
|
171
|
+
return 'ready'
|
|
172
|
+
case 'accepting':
|
|
173
|
+
case 'presenting':
|
|
174
|
+
return 'working'
|
|
175
|
+
case 'awaiting':
|
|
176
|
+
case 'done':
|
|
177
|
+
case 'declined':
|
|
178
|
+
case 'error':
|
|
179
|
+
case 'ready':
|
|
180
|
+
case 'working':
|
|
181
|
+
return saved
|
|
182
|
+
default:
|
|
183
|
+
return 'ready'
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { NodeBoundary } from '../render/NodeBoundary'
|
|
4
|
+
|
|
5
|
+
// Base props all content types receive
|
|
6
|
+
export interface ContentProps {
|
|
7
|
+
item: {
|
|
8
|
+
type: string
|
|
9
|
+
text?: string
|
|
10
|
+
url?: string
|
|
11
|
+
label?: string
|
|
12
|
+
actionID?: string
|
|
13
|
+
fields?: any[]
|
|
14
|
+
[key: string]: any // Allow custom properties
|
|
15
|
+
}
|
|
16
|
+
// May return the underlying advance() promise (WorkflowDetails.tsx does) so
|
|
17
|
+
// a control can react to its OWN tap failing — e.g. flash a brief error
|
|
18
|
+
// state — on top of whatever generic failure handling the host screen
|
|
19
|
+
// already does. Fire-and-forget callers are still fine; nothing requires
|
|
20
|
+
// awaiting the return value.
|
|
21
|
+
onAction: (actionId: string, data?: any) => void | Promise<unknown>
|
|
22
|
+
// Optional channel for AUTOMATIC outcome events (accepted/declined/error)
|
|
23
|
+
// emitted by protocol-aware controls. Unlike onAction (user taps — loud
|
|
24
|
+
// errors), outcomes are best-effort: the host screen only forwards them
|
|
25
|
+
// when the template has a matching transition and never surfaces failures.
|
|
26
|
+
onOutcome?: (event: string, data?: any) => void
|
|
27
|
+
// Stable identity for this control across screen remounts (instance:state:index).
|
|
28
|
+
// Protocol-aware controls persist their phase under this key (see
|
|
29
|
+
// controlSnapshotStore) so leaving and re-entering the screen cannot
|
|
30
|
+
// resurrect already-used action buttons.
|
|
31
|
+
persistKey?: string
|
|
32
|
+
// Answers "will the coordinator auto-fire this event on the current state?"
|
|
33
|
+
// (see coordinatorAutoFire.ts). When true, the protocol exchange is already
|
|
34
|
+
// in flight and a control's primary tap must only consent — never advance.
|
|
35
|
+
autoFireCheck?: (event: string) => boolean
|
|
36
|
+
styles: Record<string, any>
|
|
37
|
+
colors: {
|
|
38
|
+
primary: string
|
|
39
|
+
text: string
|
|
40
|
+
background: string
|
|
41
|
+
border: string
|
|
42
|
+
buttonText?: string
|
|
43
|
+
workflowButton?: string
|
|
44
|
+
workflowButtonText?: string
|
|
45
|
+
}
|
|
46
|
+
formData?: Record<string, any>
|
|
47
|
+
onFieldChange?: (name: string, value: any) => void
|
|
48
|
+
FormFieldRegistry?: any
|
|
49
|
+
content?: any[]
|
|
50
|
+
buttonVariant?: 'workflow' | 'primary'
|
|
51
|
+
mediaFrame?: {
|
|
52
|
+
width: number
|
|
53
|
+
height: number
|
|
54
|
+
mode?: 'cover' | 'contain'
|
|
55
|
+
}
|
|
56
|
+
fillContainer?: boolean
|
|
57
|
+
// Shared font scale (0-1) computed across sibling buttons or titles in the
|
|
58
|
+
// same group (workflow action row, carousel of cards/tiles, etc.), so one
|
|
59
|
+
// long label/title doesn't shrink on its own while shorter siblings stay at
|
|
60
|
+
// full size. See estimateGroupButtonScale.
|
|
61
|
+
groupFontScale?: number
|
|
62
|
+
// The DIDComm connection the surrounding workflow instance runs over.
|
|
63
|
+
// Protocol-aware controls (credential-offer, proof-presentation) need it to
|
|
64
|
+
// match incoming credential/proof exchange records to this workflow.
|
|
65
|
+
connectionId?: string
|
|
66
|
+
// Workflow instance context/artifacts and the template's `catalog` block —
|
|
67
|
+
// for controls that resolve bindings against them (vs `formData`, which only
|
|
68
|
+
// holds this screen's collected form input).
|
|
69
|
+
context?: Record<string, unknown>
|
|
70
|
+
artifacts?: Record<string, unknown>
|
|
71
|
+
catalog?: Record<string, any>
|
|
72
|
+
/** Merged into chip selection while a filter tap is in flight (browse_programs). */
|
|
73
|
+
optimisticContext?: Record<string, unknown>
|
|
74
|
+
// Screen-wide "an action is in flight" flag — true for every interactive
|
|
75
|
+
// control the instant ANY submit-button/tile/chip on this screen fires
|
|
76
|
+
// onAction, cleared once advance() settles (see WorkflowDetails.tsx's
|
|
77
|
+
// actionLoading). Disables SIBLINGS while one control is busy.
|
|
78
|
+
disabled?: boolean
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type ContentRenderer = React.FC<ContentProps>
|
|
82
|
+
|
|
83
|
+
class ContentRegistryClass {
|
|
84
|
+
private renderers = new Map<string, ContentRenderer>()
|
|
85
|
+
|
|
86
|
+
register(type: string, renderer: ContentRenderer) {
|
|
87
|
+
this.renderers.set(type, renderer)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
get(type: string): ContentRenderer | undefined {
|
|
91
|
+
return this.renderers.get(type)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
has(type: string): boolean {
|
|
95
|
+
return this.renderers.has(type)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
render(type: string, props: ContentProps): React.ReactNode {
|
|
99
|
+
const Renderer = this.renderers.get(type)
|
|
100
|
+
if (!Renderer || !props.item) {
|
|
101
|
+
return null
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Every node passes through NodeBoundary: `disabled` from the item,
|
|
105
|
+
// client-side expressions and the designer wrapper (see render/).
|
|
106
|
+
return (
|
|
107
|
+
<NodeBoundary
|
|
108
|
+
node={props.item}
|
|
109
|
+
kind="content"
|
|
110
|
+
formData={props.formData}
|
|
111
|
+
disabled={props.disabled}
|
|
112
|
+
render={(item, disabled, theme) => (
|
|
113
|
+
<Renderer
|
|
114
|
+
{...props}
|
|
115
|
+
item={item as ContentProps['item']}
|
|
116
|
+
disabled={disabled}
|
|
117
|
+
colors={props.colors ? { ...theme.colors, ...props.colors } : theme.colors}
|
|
118
|
+
styles={props.styles ? { ...theme.styles, ...props.styles } : theme.styles}
|
|
119
|
+
/>
|
|
120
|
+
)}
|
|
121
|
+
/>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
getTypes(): string[] {
|
|
126
|
+
return Array.from(this.renderers.keys())
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const ContentRegistry = new ContentRegistryClass()
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { NodeBoundary } from '../render/NodeBoundary'
|
|
4
|
+
|
|
5
|
+
// Base props all form fields receive
|
|
6
|
+
export interface FormFieldProps {
|
|
7
|
+
field: {
|
|
8
|
+
type: string
|
|
9
|
+
name: string
|
|
10
|
+
label: string
|
|
11
|
+
options?: string[]
|
|
12
|
+
min?: number
|
|
13
|
+
max?: number
|
|
14
|
+
placeholder?: string
|
|
15
|
+
required?: boolean
|
|
16
|
+
[key: string]: any // Allow custom properties
|
|
17
|
+
}
|
|
18
|
+
value: any
|
|
19
|
+
onChange: (value: any) => void
|
|
20
|
+
styles: Record<string, any>
|
|
21
|
+
colors: {
|
|
22
|
+
primary: string
|
|
23
|
+
text: string
|
|
24
|
+
background: string
|
|
25
|
+
border: string
|
|
26
|
+
buttonText?: string
|
|
27
|
+
}
|
|
28
|
+
// Shared font scale (0-1) computed across all sibling buttons in the same
|
|
29
|
+
// workflow group; forwarded to submit-button style fields.
|
|
30
|
+
groupFontScale?: number
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Renderer function type
|
|
34
|
+
export type FormFieldRenderer = React.FC<FormFieldProps>
|
|
35
|
+
|
|
36
|
+
// The registry
|
|
37
|
+
class FormFieldRegistryClass {
|
|
38
|
+
private renderers = new Map<string, FormFieldRenderer>()
|
|
39
|
+
|
|
40
|
+
register(type: string, renderer: FormFieldRenderer) {
|
|
41
|
+
this.renderers.set(type, renderer)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get(type: string): FormFieldRenderer | undefined {
|
|
45
|
+
return this.renderers.get(type)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
has(type: string): boolean {
|
|
49
|
+
return this.renderers.has(type)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
render(type: string, props: FormFieldProps): React.ReactNode {
|
|
53
|
+
const Renderer = this.renderers.get(type)
|
|
54
|
+
if (!Renderer) {
|
|
55
|
+
// biome-ignore lint/suspicious/noConsole: developer warning for a template using an unregistered form field type
|
|
56
|
+
console.warn(`Unknown form field type: ${type}`)
|
|
57
|
+
return null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Same boundary as content: `showWhen` / `{{ }}` against the form's live values, designer wrapper.
|
|
61
|
+
return (
|
|
62
|
+
<NodeBoundary
|
|
63
|
+
node={props.field}
|
|
64
|
+
kind="field"
|
|
65
|
+
render={(field, _disabled, theme) => (
|
|
66
|
+
<Renderer
|
|
67
|
+
{...props}
|
|
68
|
+
field={field as FormFieldProps['field']}
|
|
69
|
+
colors={props.colors ? { ...theme.colors, ...props.colors } : theme.colors}
|
|
70
|
+
styles={props.styles ? { ...theme.styles, ...props.styles } : theme.styles}
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
/>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Get all registered types (useful for validation)
|
|
78
|
+
getTypes(): string[] {
|
|
79
|
+
return Array.from(this.renderers.keys())
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const FormFieldRegistry = new FormFieldRegistryClass()
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { UiEnv } from '@veridid/workflow-core'
|
|
2
|
+
import { type ReactNode, useContext, useMemo } from 'react'
|
|
3
|
+
import { useWorkflowTheme, type WorkflowTheme } from '../theme/WorkflowTheme'
|
|
4
|
+
import { lookupPath, type ResolvedNode, resolveNode, sourceNode, type WorkflowNode } from './nodes'
|
|
5
|
+
import { LiveInputContext, PathMapContext, RenderOptionsContext } from './WorkflowRenderContext'
|
|
6
|
+
|
|
7
|
+
export type NodeBoundaryProps = {
|
|
8
|
+
node: WorkflowNode
|
|
9
|
+
kind: 'content' | 'field'
|
|
10
|
+
/** The control's form values (`ContentProps.formData`); fields read them from context. */
|
|
11
|
+
formData?: Record<string, unknown>
|
|
12
|
+
/** The screen-busy flag passed to the control. */
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
render: (item: WorkflowNode, disabled: boolean | undefined, theme: WorkflowTheme) => ReactNode
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Sits around every control the registries render, so each node gets the same
|
|
19
|
+
* treatment wherever it appears (top level, inside a card, a row, a form…):
|
|
20
|
+
*
|
|
21
|
+
* - `disabled: true` on the item disables the control. The engine sets it from
|
|
22
|
+
* `enabledWhen`; before, only chips read it.
|
|
23
|
+
* - Under a `WorkflowRenderProvider` with an `env`: `showWhen`, `enabledWhen`
|
|
24
|
+
* and `{{ }}` are evaluated with workflow-core, with form values as `input`.
|
|
25
|
+
* - Under a `RenderTree` with `renderNodeWrapper`: the designer's wrapper.
|
|
26
|
+
* - `colors` and `styles` default to the `WorkflowThemeProvider` theme.
|
|
27
|
+
*/
|
|
28
|
+
export function NodeBoundary({ node, kind, formData, disabled, render }: NodeBoundaryProps) {
|
|
29
|
+
const options = useContext(RenderOptionsContext)
|
|
30
|
+
const paths = useContext(PathMapContext)
|
|
31
|
+
const contextInput = useContext(LiveInputContext)
|
|
32
|
+
const theme = useWorkflowTheme()
|
|
33
|
+
const input = formData ?? contextInput
|
|
34
|
+
const baseEnv = options?.env
|
|
35
|
+
|
|
36
|
+
const env = useMemo<UiEnv | undefined>(
|
|
37
|
+
() => (baseEnv && input ? { ...baseEnv, input: { ...baseEnv.input, ...input } } : baseEnv),
|
|
38
|
+
[baseEnv, input]
|
|
39
|
+
)
|
|
40
|
+
const resolved = useMemo<ResolvedNode>(
|
|
41
|
+
() => (env ? resolveNode(node, env) : { item: node, hidden: false }),
|
|
42
|
+
[node, env]
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
if (resolved.hidden && !options?.keepHidden) return null
|
|
46
|
+
|
|
47
|
+
const { item } = resolved
|
|
48
|
+
const isDisabled = disabled || item.disabled === true ? true : disabled
|
|
49
|
+
let element = render(item, isDisabled, theme)
|
|
50
|
+
|
|
51
|
+
// Fields inside a form read the form's values from here.
|
|
52
|
+
if (kind === 'content' && formData && formData !== contextInput) {
|
|
53
|
+
element = <LiveInputContext.Provider value={formData}>{element}</LiveInputContext.Provider>
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const path = options?.renderNodeWrapper ? lookupPath(paths, node) : undefined
|
|
57
|
+
if (options?.renderNodeWrapper && path) {
|
|
58
|
+
element = options.renderNodeWrapper(element, {
|
|
59
|
+
type: node.type,
|
|
60
|
+
kind,
|
|
61
|
+
path,
|
|
62
|
+
item,
|
|
63
|
+
source: sourceNode(node),
|
|
64
|
+
hidden: resolved.hidden,
|
|
65
|
+
disabled: isDisabled === true,
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
return <>{element}</>
|
|
69
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Fragment, useContext, useMemo } from 'react'
|
|
2
|
+
import { type ContentProps, ContentRegistry } from '../registries/ContentRegistry'
|
|
3
|
+
import { NodeBoundary } from './NodeBoundary'
|
|
4
|
+
import { buildPathMap, isNode, type WorkflowNodePath } from './nodes'
|
|
5
|
+
import { PathMapContext, RenderOptionsContext } from './WorkflowRenderContext'
|
|
6
|
+
|
|
7
|
+
export type RenderTreeProps = Omit<ContentProps, 'item' | 'colors' | 'styles'> & {
|
|
8
|
+
/** Default: the `WorkflowThemeProvider` theme. */
|
|
9
|
+
colors?: ContentProps['colors']
|
|
10
|
+
/** Host styles; merged over the theme's. */
|
|
11
|
+
styles?: ContentProps['styles']
|
|
12
|
+
/** Display-hint items for one screen (e.g. the result of `resolveView`). */
|
|
13
|
+
items: readonly unknown[] | undefined
|
|
14
|
+
/** Prefix for every node path, when this tree is part of a larger document. */
|
|
15
|
+
basePath?: WorkflowNodePath
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Renders a list of display-hint items through the content registry, giving
|
|
20
|
+
* every node (including nested children) a path for `renderNodeWrapper`.
|
|
21
|
+
* Adds no layout of its own: each item renders as a sibling in the host's
|
|
22
|
+
* container.
|
|
23
|
+
*
|
|
24
|
+
* Items whose type has no component render nothing, or `renderUnknown` from
|
|
25
|
+
* the `WorkflowRenderProvider` (the designer shows a placeholder).
|
|
26
|
+
*/
|
|
27
|
+
export function RenderTree({ items, basePath, ...shared }: RenderTreeProps) {
|
|
28
|
+
const options = useContext(RenderOptionsContext)
|
|
29
|
+
const baseKey = basePath?.join('.') ?? ''
|
|
30
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: basePath is compared by value (baseKey)
|
|
31
|
+
const paths = useMemo(() => buildPathMap(items, basePath), [items, baseKey])
|
|
32
|
+
|
|
33
|
+
if (!items?.length) return null
|
|
34
|
+
return (
|
|
35
|
+
<PathMapContext.Provider value={paths}>
|
|
36
|
+
{items.map((item, index) => {
|
|
37
|
+
if (!isNode(item)) return null
|
|
38
|
+
if (ContentRegistry.has(item.type)) {
|
|
39
|
+
return (
|
|
40
|
+
<Fragment key={`${index}-${item.type}`}>
|
|
41
|
+
{ContentRegistry.render(item.type, {
|
|
42
|
+
...(shared as Omit<ContentProps, 'item'>),
|
|
43
|
+
item: item as ContentProps['item'],
|
|
44
|
+
})}
|
|
45
|
+
</Fragment>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
const renderUnknown = options?.renderUnknown
|
|
49
|
+
if (!renderUnknown) return null
|
|
50
|
+
return (
|
|
51
|
+
<NodeBoundary
|
|
52
|
+
key={`${index}-${item.type}`}
|
|
53
|
+
node={item}
|
|
54
|
+
kind="content"
|
|
55
|
+
formData={shared.formData}
|
|
56
|
+
disabled={shared.disabled}
|
|
57
|
+
render={(resolved) => renderUnknown(resolved)}
|
|
58
|
+
/>
|
|
59
|
+
)
|
|
60
|
+
})}
|
|
61
|
+
</PathMapContext.Provider>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { UiEnv } from '@veridid/workflow-core'
|
|
2
|
+
import { createContext, type ReactNode, useMemo } from 'react'
|
|
3
|
+
import type { NodePathMap, WorkflowNode, WorkflowNodePath } from './nodes'
|
|
4
|
+
|
|
5
|
+
/** What a `renderNodeWrapper` gets to know about the node it wraps. */
|
|
6
|
+
export type WorkflowNodeInfo = {
|
|
7
|
+
type: string
|
|
8
|
+
/** `content` for registry components, `field` for inputs inside a form. */
|
|
9
|
+
kind: 'content' | 'field'
|
|
10
|
+
/** Position in the items given to `RenderTree`. */
|
|
11
|
+
path: WorkflowNodePath
|
|
12
|
+
/** The node as rendered (`{{ }}` resolved, `disabled` from `enabledWhen`). */
|
|
13
|
+
item: WorkflowNode
|
|
14
|
+
/** The node as written in the items, before resolution. */
|
|
15
|
+
source: WorkflowNode
|
|
16
|
+
/** `showWhen` failed; only seen with `keepHidden`. */
|
|
17
|
+
hidden: boolean
|
|
18
|
+
/** The control renders disabled (`enabledWhen`, `disabled: true`, or the screen is busy). */
|
|
19
|
+
disabled: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type WorkflowRenderOptions = {
|
|
23
|
+
/**
|
|
24
|
+
* Data for `showWhen`, `enabledWhen` and `{{ }}`, the same env the engine
|
|
25
|
+
* uses (`context`, `artifacts`, `participants`, `viewer`). When set, every
|
|
26
|
+
* node is checked as it renders, and form values are added under `input`
|
|
27
|
+
* so conditions update as the user types. Leave it out when items come
|
|
28
|
+
* already resolved (the engine's status messages) and need no re-check.
|
|
29
|
+
*/
|
|
30
|
+
env?: UiEnv
|
|
31
|
+
/**
|
|
32
|
+
* Wraps every node that has a path (anything inside `RenderTree`, not the
|
|
33
|
+
* pieces a component makes for itself). The designer uses it for selection
|
|
34
|
+
* outlines and drag handles, so editing tools never live in the shared
|
|
35
|
+
* components.
|
|
36
|
+
*/
|
|
37
|
+
renderNodeWrapper?: (element: ReactNode, info: WorkflowNodeInfo) => ReactNode
|
|
38
|
+
/** Renders a top-level item whose type has no component (default: nothing). */
|
|
39
|
+
renderUnknown?: (item: WorkflowNode) => ReactNode
|
|
40
|
+
/**
|
|
41
|
+
* Render nodes whose `showWhen` fails instead of dropping them; the wrapper
|
|
42
|
+
* sees `hidden: true` and can dim them. For the designer.
|
|
43
|
+
*/
|
|
44
|
+
keepHidden?: boolean
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const RenderOptionsContext = createContext<WorkflowRenderOptions | null>(null)
|
|
48
|
+
export const PathMapContext = createContext<NodePathMap | null>(null)
|
|
49
|
+
/** Form values of the nearest enclosing control, for fields inside a form. */
|
|
50
|
+
export const LiveInputContext = createContext<Record<string, unknown> | undefined>(undefined)
|
|
51
|
+
|
|
52
|
+
export type WorkflowRenderProviderProps = WorkflowRenderOptions & { children?: ReactNode }
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Optional. Turns on client-side expression checks and the designer hooks for
|
|
56
|
+
* every workflow component below it. Without it, components render exactly the
|
|
57
|
+
* items they are given.
|
|
58
|
+
*/
|
|
59
|
+
export function WorkflowRenderProvider({
|
|
60
|
+
env,
|
|
61
|
+
renderNodeWrapper,
|
|
62
|
+
renderUnknown,
|
|
63
|
+
keepHidden,
|
|
64
|
+
children,
|
|
65
|
+
}: WorkflowRenderProviderProps) {
|
|
66
|
+
const value = useMemo(
|
|
67
|
+
() => ({ env, renderNodeWrapper, renderUnknown, keepHidden }),
|
|
68
|
+
[env, renderNodeWrapper, renderUnknown, keepHidden]
|
|
69
|
+
)
|
|
70
|
+
return <RenderOptionsContext.Provider value={value}>{children}</RenderOptionsContext.Provider>
|
|
71
|
+
}
|