@dxos/shell 0.3.11-main.1caa3af
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 +8 -0
- package/README.md +21 -0
- package/dist/lib/browser/chunk-ZSTKOCBT.mjs +10 -0
- package/dist/lib/browser/chunk-ZSTKOCBT.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/react.mjs +3617 -0
- package/dist/lib/browser/react.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +179 -0
- package/dist/lib/browser/testing/index.mjs.map +7 -0
- package/dist/types/src/components/AuthCode.d.ts +8 -0
- package/dist/types/src/components/AuthCode.d.ts.map +1 -0
- package/dist/types/src/components/AuthCode.js +26 -0
- package/dist/types/src/components/AuthCode.js.map +1 -0
- package/dist/types/src/components/Clipboard/ClipboardProvider.d.ts +9 -0
- package/dist/types/src/components/Clipboard/ClipboardProvider.d.ts.map +1 -0
- package/dist/types/src/components/Clipboard/ClipboardProvider.js +46 -0
- package/dist/types/src/components/Clipboard/ClipboardProvider.js.map +1 -0
- package/dist/types/src/components/Clipboard/CopyButton.d.ts +9 -0
- package/dist/types/src/components/Clipboard/CopyButton.d.ts.map +1 -0
- package/dist/types/src/components/Clipboard/CopyButton.js +65 -0
- package/dist/types/src/components/Clipboard/CopyButton.js.map +1 -0
- package/dist/types/src/components/Clipboard/index.d.ts +3 -0
- package/dist/types/src/components/Clipboard/index.d.ts.map +1 -0
- package/dist/types/src/components/Clipboard/index.js +22 -0
- package/dist/types/src/components/Clipboard/index.js.map +1 -0
- package/dist/types/src/components/CompoundButton/CompoundButton.d.ts +17 -0
- package/dist/types/src/components/CompoundButton/CompoundButton.d.ts.map +1 -0
- package/dist/types/src/components/CompoundButton/CompoundButton.js +29 -0
- package/dist/types/src/components/CompoundButton/CompoundButton.js.map +1 -0
- package/dist/types/src/components/CompoundButton/CompoundButton.stories.d.ts +35 -0
- package/dist/types/src/components/CompoundButton/CompoundButton.stories.d.ts.map +1 -0
- package/dist/types/src/components/CompoundButton/CompoundButton.stories.js +45 -0
- package/dist/types/src/components/CompoundButton/CompoundButton.stories.js.map +1 -0
- package/dist/types/src/components/CompoundButton/index.d.ts +2 -0
- package/dist/types/src/components/CompoundButton/index.d.ts.map +1 -0
- package/dist/types/src/components/CompoundButton/index.js +21 -0
- package/dist/types/src/components/CompoundButton/index.js.map +1 -0
- package/dist/types/src/components/IdentityList/DeviceList.d.ts +7 -0
- package/dist/types/src/components/IdentityList/DeviceList.d.ts.map +1 -0
- package/dist/types/src/components/IdentityList/DeviceList.js +29 -0
- package/dist/types/src/components/IdentityList/DeviceList.js.map +1 -0
- package/dist/types/src/components/IdentityList/IdentityListItem.d.ts +11 -0
- package/dist/types/src/components/IdentityList/IdentityListItem.d.ts.map +1 -0
- package/dist/types/src/components/IdentityList/IdentityListItem.js +47 -0
- package/dist/types/src/components/IdentityList/IdentityListItem.js.map +1 -0
- package/dist/types/src/components/IdentityList/SpaceMemberList.d.ts +13 -0
- package/dist/types/src/components/IdentityList/SpaceMemberList.d.ts.map +1 -0
- package/dist/types/src/components/IdentityList/SpaceMemberList.js +54 -0
- package/dist/types/src/components/IdentityList/SpaceMemberList.js.map +1 -0
- package/dist/types/src/components/IdentityList/SpaceMemberList.stories.d.ts +17 -0
- package/dist/types/src/components/IdentityList/SpaceMemberList.stories.d.ts.map +1 -0
- package/dist/types/src/components/IdentityList/SpaceMemberList.stories.js +26 -0
- package/dist/types/src/components/IdentityList/SpaceMemberList.stories.js.map +1 -0
- package/dist/types/src/components/IdentityList/index.d.ts +4 -0
- package/dist/types/src/components/IdentityList/index.d.ts.map +1 -0
- package/dist/types/src/components/IdentityList/index.js +23 -0
- package/dist/types/src/components/IdentityList/index.js.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationList.d.ts +11 -0
- package/dist/types/src/components/InvitationList/InvitationList.d.ts.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationList.js +22 -0
- package/dist/types/src/components/InvitationList/InvitationList.js.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationList.stories.d.ts +17 -0
- package/dist/types/src/components/InvitationList/InvitationList.stories.d.ts.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationList.stories.js +39 -0
- package/dist/types/src/components/InvitationList/InvitationList.stories.js.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationListContainer.d.ts +7 -0
- package/dist/types/src/components/InvitationList/InvitationListContainer.d.ts.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationListContainer.js +42 -0
- package/dist/types/src/components/InvitationList/InvitationListContainer.js.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationListItem.d.ts +12 -0
- package/dist/types/src/components/InvitationList/InvitationListItem.d.ts.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationListItem.js +103 -0
- package/dist/types/src/components/InvitationList/InvitationListItem.js.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationListProps.d.ts +9 -0
- package/dist/types/src/components/InvitationList/InvitationListProps.d.ts.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationListProps.js +3 -0
- package/dist/types/src/components/InvitationList/InvitationListProps.js.map +1 -0
- package/dist/types/src/components/InvitationList/index.d.ts +4 -0
- package/dist/types/src/components/InvitationList/index.d.ts.map +1 -0
- package/dist/types/src/components/InvitationList/index.js +23 -0
- package/dist/types/src/components/InvitationList/index.js.map +1 -0
- package/dist/types/src/components/Panel/Action.d.ts +20 -0
- package/dist/types/src/components/Panel/Action.d.ts.map +1 -0
- package/dist/types/src/components/Panel/Action.js +93 -0
- package/dist/types/src/components/Panel/Action.js.map +1 -0
- package/dist/types/src/components/Panel/Actions.d.ts +11 -0
- package/dist/types/src/components/Panel/Actions.d.ts.map +1 -0
- package/dist/types/src/components/Panel/Actions.js +36 -0
- package/dist/types/src/components/Panel/Actions.js.map +1 -0
- package/dist/types/src/components/Panel/CloseButton.d.ts +5 -0
- package/dist/types/src/components/Panel/CloseButton.d.ts.map +1 -0
- package/dist/types/src/components/Panel/CloseButton.js +21 -0
- package/dist/types/src/components/Panel/CloseButton.js.map +1 -0
- package/dist/types/src/components/Panel/Emoji.d.ts +7 -0
- package/dist/types/src/components/Panel/Emoji.d.ts.map +1 -0
- package/dist/types/src/components/Panel/Emoji.js +24 -0
- package/dist/types/src/components/Panel/Emoji.js.map +1 -0
- package/dist/types/src/components/Panel/Heading.d.ts +16 -0
- package/dist/types/src/components/Panel/Heading.d.ts.map +1 -0
- package/dist/types/src/components/Panel/Heading.js +39 -0
- package/dist/types/src/components/Panel/Heading.js.map +1 -0
- package/dist/types/src/components/Panel/Input.d.ts +11 -0
- package/dist/types/src/components/Panel/Input.d.ts.map +1 -0
- package/dist/types/src/components/Panel/Input.js +19 -0
- package/dist/types/src/components/Panel/Input.js.map +1 -0
- package/dist/types/src/components/Panel/Label.d.ts +4 -0
- package/dist/types/src/components/Panel/Label.d.ts.map +1 -0
- package/dist/types/src/components/Panel/Label.js +17 -0
- package/dist/types/src/components/Panel/Label.js.map +1 -0
- package/dist/types/src/components/Panel/Panel.stories.d.ts +13 -0
- package/dist/types/src/components/Panel/Panel.stories.d.ts.map +1 -0
- package/dist/types/src/components/Panel/Panel.stories.js +44 -0
- package/dist/types/src/components/Panel/Panel.stories.js.map +1 -0
- package/dist/types/src/components/Panel/StepHeading.d.ts +5 -0
- package/dist/types/src/components/Panel/StepHeading.d.ts.map +1 -0
- package/dist/types/src/components/Panel/StepHeading.js +35 -0
- package/dist/types/src/components/Panel/StepHeading.js.map +1 -0
- package/dist/types/src/components/Panel/index.d.ts +9 -0
- package/dist/types/src/components/Panel/index.d.ts.map +1 -0
- package/dist/types/src/components/Panel/index.js +28 -0
- package/dist/types/src/components/Panel/index.js.map +1 -0
- package/dist/types/src/components/SpaceListItem.d.ts +7 -0
- package/dist/types/src/components/SpaceListItem.d.ts.map +1 -0
- package/dist/types/src/components/SpaceListItem.js +46 -0
- package/dist/types/src/components/SpaceListItem.js.map +1 -0
- package/dist/types/src/components/StorybookDialog.d.ts +6 -0
- package/dist/types/src/components/StorybookDialog.d.ts.map +1 -0
- package/dist/types/src/components/StorybookDialog.js +23 -0
- package/dist/types/src/components/StorybookDialog.js.map +1 -0
- package/dist/types/src/components/Viewport/Viewport.d.ts +39 -0
- package/dist/types/src/components/Viewport/Viewport.d.ts.map +1 -0
- package/dist/types/src/components/Viewport/Viewport.js +73 -0
- package/dist/types/src/components/Viewport/Viewport.js.map +1 -0
- package/dist/types/src/components/Viewport/Viewport.stories.d.ts +17 -0
- package/dist/types/src/components/Viewport/Viewport.stories.d.ts.map +1 -0
- package/dist/types/src/components/Viewport/Viewport.stories.js +51 -0
- package/dist/types/src/components/Viewport/Viewport.stories.js.map +1 -0
- package/dist/types/src/components/Viewport/index.d.ts +2 -0
- package/dist/types/src/components/Viewport/index.d.ts.map +1 -0
- package/dist/types/src/components/Viewport/index.js +21 -0
- package/dist/types/src/components/Viewport/index.js.map +1 -0
- package/dist/types/src/components/index.d.ts +9 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/components/index.js +28 -0
- package/dist/types/src/components/index.js.map +1 -0
- package/dist/types/src/composites/IdentityDialog/IdentityDialog.d.ts +7 -0
- package/dist/types/src/composites/IdentityDialog/IdentityDialog.d.ts.map +1 -0
- package/dist/types/src/composites/IdentityDialog/IdentityDialog.js +26 -0
- package/dist/types/src/composites/IdentityDialog/IdentityDialog.js.map +1 -0
- package/dist/types/src/composites/IdentityDialog/index.d.ts +2 -0
- package/dist/types/src/composites/IdentityDialog/index.d.ts.map +1 -0
- package/dist/types/src/composites/IdentityDialog/index.js +21 -0
- package/dist/types/src/composites/IdentityDialog/index.js.map +1 -0
- package/dist/types/src/composites/JoinDialog/JoinDialog.d.ts +6 -0
- package/dist/types/src/composites/JoinDialog/JoinDialog.d.ts.map +1 -0
- package/dist/types/src/composites/JoinDialog/JoinDialog.js +27 -0
- package/dist/types/src/composites/JoinDialog/JoinDialog.js.map +1 -0
- package/dist/types/src/composites/JoinDialog/index.d.ts +2 -0
- package/dist/types/src/composites/JoinDialog/index.d.ts.map +1 -0
- package/dist/types/src/composites/JoinDialog/index.js +21 -0
- package/dist/types/src/composites/JoinDialog/index.js.map +1 -0
- package/dist/types/src/composites/Shell/Shell.d.ts +6 -0
- package/dist/types/src/composites/Shell/Shell.d.ts.map +1 -0
- package/dist/types/src/composites/Shell/Shell.js +90 -0
- package/dist/types/src/composites/Shell/Shell.js.map +1 -0
- package/dist/types/src/composites/Shell/ShellContext.d.ts +30 -0
- package/dist/types/src/composites/Shell/ShellContext.d.ts.map +1 -0
- package/dist/types/src/composites/Shell/ShellContext.js +129 -0
- package/dist/types/src/composites/Shell/ShellContext.js.map +1 -0
- package/dist/types/src/composites/Shell/index.d.ts +4 -0
- package/dist/types/src/composites/Shell/index.d.ts.map +1 -0
- package/dist/types/src/composites/Shell/index.js +23 -0
- package/dist/types/src/composites/Shell/index.js.map +1 -0
- package/dist/types/src/composites/Shell/memory-shell-runtime.d.ts +16 -0
- package/dist/types/src/composites/Shell/memory-shell-runtime.d.ts.map +1 -0
- package/dist/types/src/composites/Shell/memory-shell-runtime.js +38 -0
- package/dist/types/src/composites/Shell/memory-shell-runtime.js.map +1 -0
- package/dist/types/src/composites/Shell/run-shell.d.ts +3 -0
- package/dist/types/src/composites/Shell/run-shell.d.ts.map +1 -0
- package/dist/types/src/composites/Shell/run-shell.js +54 -0
- package/dist/types/src/composites/Shell/run-shell.js.map +1 -0
- package/dist/types/src/composites/SpaceDialog/SpaceDialog.d.ts +6 -0
- package/dist/types/src/composites/SpaceDialog/SpaceDialog.d.ts.map +1 -0
- package/dist/types/src/composites/SpaceDialog/SpaceDialog.js +26 -0
- package/dist/types/src/composites/SpaceDialog/SpaceDialog.js.map +1 -0
- package/dist/types/src/composites/SpaceDialog/index.d.ts +2 -0
- package/dist/types/src/composites/SpaceDialog/index.d.ts.map +1 -0
- package/dist/types/src/composites/SpaceDialog/index.js +21 -0
- package/dist/types/src/composites/SpaceDialog/index.js.map +1 -0
- package/dist/types/src/composites/index.d.ts +5 -0
- package/dist/types/src/composites/index.d.ts.map +1 -0
- package/dist/types/src/composites/index.js +24 -0
- package/dist/types/src/composites/index.js.map +1 -0
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/index.js +10 -0
- package/dist/types/src/index.js.map +1 -0
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.d.ts +4 -0
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.d.ts.map +1 -0
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.js +124 -0
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.js.map +1 -0
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.d.ts +22 -0
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.d.ts.map +1 -0
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.js +86 -0
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.js.map +1 -0
- package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts +27 -0
- package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts.map +1 -0
- package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.js +6 -0
- package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.js.map +1 -0
- package/dist/types/src/panels/IdentityPanel/identityMachine.d.ts +46 -0
- package/dist/types/src/panels/IdentityPanel/identityMachine.d.ts.map +1 -0
- package/dist/types/src/panels/IdentityPanel/identityMachine.js +79 -0
- package/dist/types/src/panels/IdentityPanel/identityMachine.js.map +1 -0
- package/dist/types/src/panels/IdentityPanel/index.d.ts +3 -0
- package/dist/types/src/panels/IdentityPanel/index.d.ts.map +1 -0
- package/dist/types/src/panels/IdentityPanel/index.js +22 -0
- package/dist/types/src/panels/IdentityPanel/index.js.map +1 -0
- package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.d.ts +9 -0
- package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.d.ts.map +1 -0
- package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js +85 -0
- package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js.map +1 -0
- package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.d.ts +15 -0
- package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.d.ts.map +1 -0
- package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.js +62 -0
- package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.js.map +1 -0
- package/dist/types/src/panels/IdentityPanel/steps/index.d.ts +3 -0
- package/dist/types/src/panels/IdentityPanel/steps/index.d.ts.map +1 -0
- package/dist/types/src/panels/IdentityPanel/steps/index.js +22 -0
- package/dist/types/src/panels/IdentityPanel/steps/index.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/JoinHeading.d.ts +10 -0
- package/dist/types/src/panels/JoinPanel/JoinHeading.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/JoinHeading.js +45 -0
- package/dist/types/src/panels/JoinPanel/JoinHeading.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/JoinPanel.d.ts +4 -0
- package/dist/types/src/panels/JoinPanel/JoinPanel.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/JoinPanel.js +293 -0
- package/dist/types/src/panels/JoinPanel/JoinPanel.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/JoinPanel.stories.d.ts +92 -0
- package/dist/types/src/panels/JoinPanel/JoinPanel.stories.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/JoinPanel.stories.js +74 -0
- package/dist/types/src/panels/JoinPanel/JoinPanel.stories.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/JoinPanelProps.d.ts +91 -0
- package/dist/types/src/panels/JoinPanel/JoinPanelProps.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/JoinPanelProps.js +6 -0
- package/dist/types/src/panels/JoinPanel/JoinPanelProps.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/index.d.ts +3 -0
- package/dist/types/src/panels/JoinPanel/index.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/index.js +22 -0
- package/dist/types/src/panels/JoinPanel/index.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/joinMachine.d.ts +87 -0
- package/dist/types/src/panels/JoinPanel/joinMachine.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/joinMachine.js +402 -0
- package/dist/types/src/panels/JoinPanel/joinMachine.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/AdditionMethodChooser.d.ts +4 -0
- package/dist/types/src/panels/JoinPanel/steps/AdditionMethodChooser.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/AdditionMethodChooser.js +34 -0
- package/dist/types/src/panels/JoinPanel/steps/AdditionMethodChooser.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/IdentityAdded.d.ts +8 -0
- package/dist/types/src/panels/JoinPanel/steps/IdentityAdded.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/IdentityAdded.js +56 -0
- package/dist/types/src/panels/JoinPanel/steps/IdentityAdded.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/IdentityInput.d.ts +12 -0
- package/dist/types/src/panels/JoinPanel/steps/IdentityInput.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/IdentityInput.js +67 -0
- package/dist/types/src/panels/JoinPanel/steps/IdentityInput.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationAccepted.d.ts +9 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationAccepted.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationAccepted.js +44 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationAccepted.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationAuthenticator.d.ts +11 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationAuthenticator.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationAuthenticator.js +72 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationAuthenticator.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationInput.d.ts +8 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationInput.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationInput.js +68 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationInput.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationRescuer.d.ts +11 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationRescuer.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationRescuer.js +49 -0
- package/dist/types/src/panels/JoinPanel/steps/InvitationRescuer.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/ResetIdentity.d.ts +12 -0
- package/dist/types/src/panels/JoinPanel/steps/ResetIdentity.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/ResetIdentity.js +63 -0
- package/dist/types/src/panels/JoinPanel/steps/ResetIdentity.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/index.d.ts +9 -0
- package/dist/types/src/panels/JoinPanel/steps/index.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/steps/index.js +28 -0
- package/dist/types/src/panels/JoinPanel/steps/index.js.map +1 -0
- package/dist/types/src/panels/Panels.stories.d.ts +22 -0
- package/dist/types/src/panels/Panels.stories.d.ts.map +1 -0
- package/dist/types/src/panels/Panels.stories.js +71 -0
- package/dist/types/src/panels/Panels.stories.js.map +1 -0
- package/dist/types/src/panels/SpacePanel/SpacePanel.d.ts +4 -0
- package/dist/types/src/panels/SpacePanel/SpacePanel.d.ts.map +1 -0
- package/dist/types/src/panels/SpacePanel/SpacePanel.js +93 -0
- package/dist/types/src/panels/SpacePanel/SpacePanel.js.map +1 -0
- package/dist/types/src/panels/SpacePanel/SpacePanel.stories.d.ts +30 -0
- package/dist/types/src/panels/SpacePanel/SpacePanel.stories.d.ts.map +1 -0
- package/dist/types/src/panels/SpacePanel/SpacePanel.stories.js +183 -0
- package/dist/types/src/panels/SpacePanel/SpacePanel.stories.js.map +1 -0
- package/dist/types/src/panels/SpacePanel/SpacePanelProps.d.ts +30 -0
- package/dist/types/src/panels/SpacePanel/SpacePanelProps.d.ts.map +1 -0
- package/dist/types/src/panels/SpacePanel/SpacePanelProps.js +6 -0
- package/dist/types/src/panels/SpacePanel/SpacePanelProps.js.map +1 -0
- package/dist/types/src/panels/SpacePanel/index.d.ts +3 -0
- package/dist/types/src/panels/SpacePanel/index.d.ts.map +1 -0
- package/dist/types/src/panels/SpacePanel/index.js +22 -0
- package/dist/types/src/panels/SpacePanel/index.js.map +1 -0
- package/dist/types/src/panels/SpacePanel/spaceMachine.d.ts +35 -0
- package/dist/types/src/panels/SpacePanel/spaceMachine.d.ts.map +1 -0
- package/dist/types/src/panels/SpacePanel/spaceMachine.js +46 -0
- package/dist/types/src/panels/SpacePanel/spaceMachine.js.map +1 -0
- package/dist/types/src/panels/SpacePanel/steps/SpaceManager.d.ts +15 -0
- package/dist/types/src/panels/SpacePanel/steps/SpaceManager.d.ts.map +1 -0
- package/dist/types/src/panels/SpacePanel/steps/SpaceManager.js +120 -0
- package/dist/types/src/panels/SpacePanel/steps/SpaceManager.js.map +1 -0
- package/dist/types/src/panels/SpacePanel/steps/index.d.ts +2 -0
- package/dist/types/src/panels/SpacePanel/steps/index.d.ts.map +1 -0
- package/dist/types/src/panels/SpacePanel/steps/index.js +21 -0
- package/dist/types/src/panels/SpacePanel/steps/index.js.map +1 -0
- package/dist/types/src/panels/index.d.ts +4 -0
- package/dist/types/src/panels/index.d.ts.map +1 -0
- package/dist/types/src/panels/index.js +23 -0
- package/dist/types/src/panels/index.js.map +1 -0
- package/dist/types/src/playwright/invitations-manager.d.ts +26 -0
- package/dist/types/src/playwright/invitations-manager.d.ts.map +1 -0
- package/dist/types/src/playwright/invitations-manager.js +142 -0
- package/dist/types/src/playwright/invitations-manager.js.map +1 -0
- package/dist/types/src/playwright/invitations.spec.d.ts +2 -0
- package/dist/types/src/playwright/invitations.spec.d.ts.map +1 -0
- package/dist/types/src/playwright/invitations.spec.js +298 -0
- package/dist/types/src/playwright/invitations.spec.js.map +1 -0
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/playwright/playwright.config.js +8 -0
- package/dist/types/src/playwright/playwright.config.js.map +1 -0
- package/dist/types/src/react.d.ts +6 -0
- package/dist/types/src/react.d.ts.map +1 -0
- package/dist/types/src/react.js +25 -0
- package/dist/types/src/react.js.map +1 -0
- package/dist/types/src/steps/InvitationManager.d.ts +7 -0
- package/dist/types/src/steps/InvitationManager.d.ts.map +1 -0
- package/dist/types/src/steps/InvitationManager.js +80 -0
- package/dist/types/src/steps/InvitationManager.js.map +1 -0
- package/dist/types/src/steps/StepProps.d.ts +14 -0
- package/dist/types/src/steps/StepProps.d.ts.map +1 -0
- package/dist/types/src/steps/StepProps.js +6 -0
- package/dist/types/src/steps/StepProps.js.map +1 -0
- package/dist/types/src/steps/index.d.ts +3 -0
- package/dist/types/src/steps/index.d.ts.map +1 -0
- package/dist/types/src/steps/index.js +22 -0
- package/dist/types/src/steps/index.js.map +1 -0
- package/dist/types/src/stories/Invitations.e2e-stories.d.ts +22 -0
- package/dist/types/src/stories/Invitations.e2e-stories.d.ts.map +1 -0
- package/dist/types/src/stories/Invitations.e2e-stories.js +146 -0
- package/dist/types/src/stories/Invitations.e2e-stories.js.map +1 -0
- package/dist/types/src/styles/index.d.ts +3 -0
- package/dist/types/src/styles/index.d.ts.map +1 -0
- package/dist/types/src/styles/index.js +22 -0
- package/dist/types/src/styles/index.js.map +1 -0
- package/dist/types/src/styles/invitationStatusStyles.d.ts +20 -0
- package/dist/types/src/styles/invitationStatusStyles.d.ts.map +1 -0
- package/dist/types/src/styles/invitationStatusStyles.js +41 -0
- package/dist/types/src/styles/invitationStatusStyles.js.map +1 -0
- package/dist/types/src/styles/panelStyles.d.ts +2 -0
- package/dist/types/src/styles/panelStyles.d.ts.map +1 -0
- package/dist/types/src/styles/panelStyles.js +8 -0
- package/dist/types/src/styles/panelStyles.js.map +1 -0
- package/dist/types/src/testing/fixtures/identities.d.ts +3 -0
- package/dist/types/src/testing/fixtures/identities.d.ts.map +1 -0
- package/dist/types/src/testing/fixtures/identities.js +18 -0
- package/dist/types/src/testing/fixtures/identities.js.map +1 -0
- package/dist/types/src/testing/fixtures/index.d.ts +3 -0
- package/dist/types/src/testing/fixtures/index.d.ts.map +1 -0
- package/dist/types/src/testing/fixtures/index.js +22 -0
- package/dist/types/src/testing/fixtures/index.js.map +1 -0
- package/dist/types/src/testing/fixtures/invitations.d.ts +3 -0
- package/dist/types/src/testing/fixtures/invitations.d.ts.map +1 -0
- package/dist/types/src/testing/fixtures/invitations.js +25 -0
- package/dist/types/src/testing/fixtures/invitations.js.map +1 -0
- package/dist/types/src/testing/index.d.ts +4 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/index.js +23 -0
- package/dist/types/src/testing/index.js.map +1 -0
- package/dist/types/src/testing/scoped-shell-manager.d.ts +17 -0
- package/dist/types/src/testing/scoped-shell-manager.d.ts.map +1 -0
- package/dist/types/src/testing/scoped-shell-manager.js +71 -0
- package/dist/types/src/testing/scoped-shell-manager.js.map +1 -0
- package/dist/types/src/testing/shell-manager.d.ts +24 -0
- package/dist/types/src/testing/shell-manager.d.ts.map +1 -0
- package/dist/types/src/testing/shell-manager.js +85 -0
- package/dist/types/src/testing/shell-manager.js.map +1 -0
- package/dist/types/src/translations/index.d.ts +5 -0
- package/dist/types/src/translations/index.d.ts.map +1 -0
- package/dist/types/src/translations/index.js +32 -0
- package/dist/types/src/translations/index.js.map +1 -0
- package/dist/types/src/translations/locales/en-US.d.ts +97 -0
- package/dist/types/src/translations/locales/en-US.d.ts.map +1 -0
- package/dist/types/src/translations/locales/en-US.js +103 -0
- package/dist/types/src/translations/locales/en-US.js.map +1 -0
- package/dist/types/src/types/FailReason.d.ts +2 -0
- package/dist/types/src/types/FailReason.d.ts.map +1 -0
- package/dist/types/src/types/FailReason.js +6 -0
- package/dist/types/src/types/FailReason.js.map +1 -0
- package/dist/types/src/types/IInvitation.d.ts +7 -0
- package/dist/types/src/types/IInvitation.d.ts.map +1 -0
- package/dist/types/src/types/IInvitation.js +6 -0
- package/dist/types/src/types/IInvitation.js.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/index.js +22 -0
- package/dist/types/src/types/index.js.map +1 -0
- package/dist/types/src/util/index.d.ts +3 -0
- package/dist/types/src/util/index.d.ts.map +1 -0
- package/dist/types/src/util/index.js +22 -0
- package/dist/types/src/util/index.js.map +1 -0
- package/dist/types/src/util/invitationStatusValue.d.ts +8 -0
- package/dist/types/src/util/invitationStatusValue.d.ts.map +1 -0
- package/dist/types/src/util/invitationStatusValue.js +24 -0
- package/dist/types/src/util/invitationStatusValue.js.map +1 -0
- package/dist/types/src/util/toEmoji.d.ts +2 -0
- package/dist/types/src/util/toEmoji.d.ts.map +1 -0
- package/dist/types/src/util/toEmoji.js +26 -0
- package/dist/types/src/util/toEmoji.js.map +1 -0
- package/package.json +79 -0
- package/src/components/AuthCode.tsx +36 -0
- package/src/components/Clipboard/ClipboardProvider.tsx +26 -0
- package/src/components/Clipboard/CopyButton.tsx +70 -0
- package/src/components/Clipboard/index.ts +6 -0
- package/src/components/CompoundButton/CompoundButton.stories.tsx +49 -0
- package/src/components/CompoundButton/CompoundButton.tsx +89 -0
- package/src/components/CompoundButton/index.ts +5 -0
- package/src/components/IdentityList/DeviceList.tsx +45 -0
- package/src/components/IdentityList/IdentityListItem.tsx +42 -0
- package/src/components/IdentityList/SpaceMemberList.stories.tsx +24 -0
- package/src/components/IdentityList/SpaceMemberList.tsx +65 -0
- package/src/components/IdentityList/index.ts +7 -0
- package/src/components/InvitationList/InvitationList.stories.tsx +44 -0
- package/src/components/InvitationList/InvitationList.tsx +31 -0
- package/src/components/InvitationList/InvitationListContainer.tsx +27 -0
- package/src/components/InvitationList/InvitationListItem.tsx +183 -0
- package/src/components/InvitationList/InvitationListProps.ts +9 -0
- package/src/components/InvitationList/index.ts +7 -0
- package/src/components/Panel/Action.tsx +142 -0
- package/src/components/Panel/Actions.tsx +31 -0
- package/src/components/Panel/CloseButton.tsx +24 -0
- package/src/components/Panel/Emoji.tsx +36 -0
- package/src/components/Panel/Heading.tsx +32 -0
- package/src/components/Panel/Input.tsx +27 -0
- package/src/components/Panel/Label.tsx +14 -0
- package/src/components/Panel/Panel.stories.tsx +52 -0
- package/src/components/Panel/StepHeading.tsx +17 -0
- package/src/components/Panel/index.ts +12 -0
- package/src/components/SpaceListItem.tsx +35 -0
- package/src/components/StorybookDialog.tsx +33 -0
- package/src/components/Viewport/Viewport.stories.tsx +66 -0
- package/src/components/Viewport/Viewport.tsx +120 -0
- package/src/components/Viewport/index.tsx +5 -0
- package/src/components/index.ts +12 -0
- package/src/composites/IdentityDialog/IdentityDialog.tsx +39 -0
- package/src/composites/IdentityDialog/index.ts +5 -0
- package/src/composites/JoinDialog/JoinDialog.tsx +40 -0
- package/src/composites/JoinDialog/index.ts +5 -0
- package/src/composites/Shell/Shell.tsx +98 -0
- package/src/composites/Shell/ShellContext.tsx +163 -0
- package/src/composites/Shell/index.ts +7 -0
- package/src/composites/Shell/memory-shell-runtime.ts +50 -0
- package/src/composites/Shell/run-shell.tsx +38 -0
- package/src/composites/SpaceDialog/SpaceDialog.tsx +37 -0
- package/src/composites/SpaceDialog/index.ts +5 -0
- package/src/composites/index.ts +8 -0
- package/src/index.ts +7 -0
- package/src/panels/IdentityPanel/IdentityPanel.stories.tsx +113 -0
- package/src/panels/IdentityPanel/IdentityPanel.tsx +158 -0
- package/src/panels/IdentityPanel/IdentityPanelProps.ts +36 -0
- package/src/panels/IdentityPanel/identityMachine.ts +131 -0
- package/src/panels/IdentityPanel/index.ts +6 -0
- package/src/panels/IdentityPanel/steps/IdentityActionChooser.tsx +96 -0
- package/src/panels/IdentityPanel/steps/ProfileForm.tsx +79 -0
- package/src/panels/IdentityPanel/steps/index.ts +6 -0
- package/src/panels/JoinPanel/JoinHeading.tsx +49 -0
- package/src/panels/JoinPanel/JoinPanel.stories.tsx +91 -0
- package/src/panels/JoinPanel/JoinPanel.tsx +415 -0
- package/src/panels/JoinPanel/JoinPanelProps.ts +132 -0
- package/src/panels/JoinPanel/index.ts +6 -0
- package/src/panels/JoinPanel/joinMachine.ts +536 -0
- package/src/panels/JoinPanel/steps/AdditionMethodChooser.tsx +65 -0
- package/src/panels/JoinPanel/steps/IdentityAdded.tsx +75 -0
- package/src/panels/JoinPanel/steps/IdentityInput.tsx +86 -0
- package/src/panels/JoinPanel/steps/InvitationAccepted.tsx +43 -0
- package/src/panels/JoinPanel/steps/InvitationAuthenticator.tsx +99 -0
- package/src/panels/JoinPanel/steps/InvitationInput.tsx +102 -0
- package/src/panels/JoinPanel/steps/InvitationRescuer.tsx +102 -0
- package/src/panels/JoinPanel/steps/ResetIdentity.tsx +71 -0
- package/src/panels/JoinPanel/steps/index.ts +12 -0
- package/src/panels/Panels.stories.tsx +61 -0
- package/src/panels/SpacePanel/SpacePanel.stories.tsx +328 -0
- package/src/panels/SpacePanel/SpacePanel.tsx +122 -0
- package/src/panels/SpacePanel/SpacePanelProps.ts +40 -0
- package/src/panels/SpacePanel/index.ts +6 -0
- package/src/panels/SpacePanel/spaceMachine.ts +72 -0
- package/src/panels/SpacePanel/steps/SpaceManager.tsx +157 -0
- package/src/panels/SpacePanel/steps/index.ts +5 -0
- package/src/panels/index.ts +7 -0
- package/src/playwright/invitations-manager.ts +168 -0
- package/src/playwright/invitations.spec.ts +364 -0
- package/src/playwright/playwright.config.ts +7 -0
- package/src/react.ts +9 -0
- package/src/steps/InvitationManager.tsx +116 -0
- package/src/steps/StepProps.ts +17 -0
- package/src/steps/index.ts +6 -0
- package/src/stories/Invitations.e2e-stories.tsx +231 -0
- package/src/styles/index.ts +6 -0
- package/src/styles/invitationStatusStyles.ts +42 -0
- package/src/styles/panelStyles.ts +5 -0
- package/src/testing/fixtures/identities.ts +16 -0
- package/src/testing/fixtures/index.ts +6 -0
- package/src/testing/fixtures/invitations.ts +23 -0
- package/src/testing/index.ts +7 -0
- package/src/testing/scoped-shell-manager.ts +79 -0
- package/src/testing/shell-manager.ts +102 -0
- package/src/translations/index.ts +7 -0
- package/src/translations/locales/en-US.ts +101 -0
- package/src/types/FailReason.ts +5 -0
- package/src/types/IInvitation.ts +14 -0
- package/src/types/index.ts +6 -0
- package/src/util/index.ts +6 -0
- package/src/util/invitationStatusValue.ts +22 -0
- package/src/util/toEmoji.ts +22 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Dialog, type DialogContentProps, useId } from '@dxos/react-ui';
|
|
8
|
+
|
|
9
|
+
import { ClipboardProvider } from '../../components';
|
|
10
|
+
import { SpacePanel, type SpacePanelProps } from '../../panels';
|
|
11
|
+
|
|
12
|
+
export interface SpaceDialogProps
|
|
13
|
+
extends Omit<DialogContentProps, 'children'>,
|
|
14
|
+
Omit<SpacePanelProps, 'doneActionParent'> {}
|
|
15
|
+
|
|
16
|
+
export const SpaceDialog = (spacePanelProps: SpaceDialogProps) => {
|
|
17
|
+
const titleId = useId('spaceDialog__title');
|
|
18
|
+
return (
|
|
19
|
+
<Dialog.Root defaultOpen onOpenChange={(open) => open || spacePanelProps.onDone?.()}>
|
|
20
|
+
<Dialog.Portal>
|
|
21
|
+
<Dialog.Overlay>
|
|
22
|
+
<Dialog.Content aria-labelledby={titleId}>
|
|
23
|
+
<ClipboardProvider>
|
|
24
|
+
<SpacePanel
|
|
25
|
+
{...{
|
|
26
|
+
...spacePanelProps,
|
|
27
|
+
titleId,
|
|
28
|
+
doneActionParent: <Dialog.Close asChild />,
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
</ClipboardProvider>
|
|
32
|
+
</Dialog.Content>
|
|
33
|
+
</Dialog.Overlay>
|
|
34
|
+
</Dialog.Portal>
|
|
35
|
+
</Dialog.Root>
|
|
36
|
+
);
|
|
37
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxosTheme';
|
|
6
|
+
|
|
7
|
+
import { faker } from '@faker-js/faker';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { PublicKey } from '@dxos/react-client';
|
|
11
|
+
import { Invitation } from '@dxos/react-client/invitations';
|
|
12
|
+
import { withTheme } from '@dxos/storybook-utils';
|
|
13
|
+
|
|
14
|
+
import { IdentityPanelImpl } from './IdentityPanel';
|
|
15
|
+
import type { IdentityPanelImplProps } from './IdentityPanelProps';
|
|
16
|
+
import { IdentityActionChooserImpl } from './steps';
|
|
17
|
+
import { StorybookDialog } from '../../components/StorybookDialog';
|
|
18
|
+
import { InvitationManager, type InvitationManagerProps } from '../../steps';
|
|
19
|
+
|
|
20
|
+
faker.seed(1234);
|
|
21
|
+
|
|
22
|
+
const noOpProps: IdentityPanelImplProps = {
|
|
23
|
+
titleId: 'storybookIdentityPanel',
|
|
24
|
+
send: () => {},
|
|
25
|
+
activeView: 'identity action chooser',
|
|
26
|
+
createInvitationUrl: (code) => code,
|
|
27
|
+
identity: {
|
|
28
|
+
identityKey: PublicKey.random(),
|
|
29
|
+
profile: {
|
|
30
|
+
displayName: faker.person.firstName(),
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default {
|
|
36
|
+
title: 'Panels/Identity',
|
|
37
|
+
decorators: [withTheme],
|
|
38
|
+
parameters: { chromatic: { disableSnapshot: false } },
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const IdentityActionChooser = () => {
|
|
42
|
+
return (
|
|
43
|
+
<StorybookDialog inOverlayLayout>
|
|
44
|
+
<IdentityPanelImpl
|
|
45
|
+
{...noOpProps}
|
|
46
|
+
activeView='identity action chooser'
|
|
47
|
+
IdentityActionChooser={IdentityActionChooserImpl}
|
|
48
|
+
/>
|
|
49
|
+
</StorybookDialog>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const DeviceInvitationManagerWithState = (extraProps: InvitationManagerProps) => (
|
|
54
|
+
<StorybookDialog inOverlayLayout>
|
|
55
|
+
<IdentityPanelImpl
|
|
56
|
+
{...noOpProps}
|
|
57
|
+
activeView='device invitation manager'
|
|
58
|
+
IdentityActionChooser={IdentityActionChooserImpl}
|
|
59
|
+
InvitationManager={(props) => <InvitationManager {...props} {...extraProps} />}
|
|
60
|
+
/>
|
|
61
|
+
</StorybookDialog>
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
export const DeviceInvitationManager = () =>
|
|
65
|
+
DeviceInvitationManagerWithState({ status: Invitation.State.INIT, id: '0' });
|
|
66
|
+
|
|
67
|
+
export const DeviceInvitationManagerConnecting = () =>
|
|
68
|
+
DeviceInvitationManagerWithState({
|
|
69
|
+
status: Invitation.State.CONNECTING,
|
|
70
|
+
id: '1',
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export const DeviceInvitationManagerConnected = () =>
|
|
74
|
+
DeviceInvitationManagerWithState({
|
|
75
|
+
status: Invitation.State.CONNECTED,
|
|
76
|
+
id: '2',
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export const DeviceInvitationManagerReady = () =>
|
|
80
|
+
DeviceInvitationManagerWithState({
|
|
81
|
+
status: Invitation.State.READY_FOR_AUTHENTICATION,
|
|
82
|
+
authCode: '123123',
|
|
83
|
+
id: '3',
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
export const DeviceInvitationManagerAuthenticating = () =>
|
|
87
|
+
DeviceInvitationManagerWithState({
|
|
88
|
+
status: Invitation.State.AUTHENTICATING,
|
|
89
|
+
id: '4',
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export const DeviceInvitationManagerSuccess = () =>
|
|
93
|
+
DeviceInvitationManagerWithState({ status: Invitation.State.SUCCESS });
|
|
94
|
+
|
|
95
|
+
export const DeviceInvitationManagerError = () => DeviceInvitationManagerWithState({ status: Invitation.State.ERROR });
|
|
96
|
+
|
|
97
|
+
export const DeviceInvitationManagerTimeout = () =>
|
|
98
|
+
DeviceInvitationManagerWithState({ status: Invitation.State.TIMEOUT });
|
|
99
|
+
|
|
100
|
+
export const DeviceInvitationManagerCancelled = () =>
|
|
101
|
+
DeviceInvitationManagerWithState({
|
|
102
|
+
status: Invitation.State.CANCELLED,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// export const IdentityActionChooser = {
|
|
106
|
+
// decorators: [ClientDecorator()],
|
|
107
|
+
// args: { activeView: 'identity action chooser' },
|
|
108
|
+
// };
|
|
109
|
+
|
|
110
|
+
// export const DeviceManager = {
|
|
111
|
+
// decorators: [ClientDecorator()],
|
|
112
|
+
// args: { activeView: 'device manager' },
|
|
113
|
+
// };
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
import React, { useEffect, useMemo } from 'react';
|
|
5
|
+
|
|
6
|
+
import { generateName } from '@dxos/display-name';
|
|
7
|
+
import { log } from '@dxos/log';
|
|
8
|
+
import { useClient } from '@dxos/react-client';
|
|
9
|
+
import { type Identity, useIdentity } from '@dxos/react-client/halo';
|
|
10
|
+
import { useInvitationStatus } from '@dxos/react-client/invitations';
|
|
11
|
+
import type { CancellableInvitationObservable } from '@dxos/react-client/invitations';
|
|
12
|
+
import { Avatar, DensityProvider, useId, useJdenticonHref, useTranslation } from '@dxos/react-ui';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
type IdentityPanelHeadingProps,
|
|
16
|
+
type IdentityPanelImplProps,
|
|
17
|
+
type IdentityPanelProps,
|
|
18
|
+
} from './IdentityPanelProps';
|
|
19
|
+
import { useIdentityMachine } from './identityMachine';
|
|
20
|
+
import { IdentityActionChooser, ProfileForm } from './steps';
|
|
21
|
+
import { Viewport, Heading, CloseButton } from '../../components';
|
|
22
|
+
import { InvitationManager } from '../../steps';
|
|
23
|
+
|
|
24
|
+
const viewStyles = 'pbs-1 pbe-3 pli-3';
|
|
25
|
+
|
|
26
|
+
const IdentityHeading = ({ titleId, title, identity, onDone }: IdentityPanelHeadingProps) => {
|
|
27
|
+
const fallbackHref = useJdenticonHref(identity.identityKey.toHex(), 12);
|
|
28
|
+
return (
|
|
29
|
+
<Heading titleId={titleId} title={title} corner={<CloseButton onDone={onDone} />}>
|
|
30
|
+
<Avatar.Root size={12} variant='circle' status='active'>
|
|
31
|
+
<Avatar.Frame classNames='block mbs-4 mbe-2 mli-auto chromatic-ignore'>
|
|
32
|
+
<Avatar.Fallback href={fallbackHref} />
|
|
33
|
+
</Avatar.Frame>
|
|
34
|
+
<Avatar.Label classNames='block text-center font-light text-xl'>
|
|
35
|
+
{identity.profile?.displayName ?? generateName(identity.identityKey.toHex())}
|
|
36
|
+
</Avatar.Label>
|
|
37
|
+
</Avatar.Root>
|
|
38
|
+
</Heading>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const IdentityPanelImpl = (props: IdentityPanelImplProps) => {
|
|
43
|
+
const {
|
|
44
|
+
identity,
|
|
45
|
+
titleId,
|
|
46
|
+
activeView,
|
|
47
|
+
onUpdateProfile,
|
|
48
|
+
IdentityActionChooser: IdentityActionChooserComponent = IdentityActionChooser,
|
|
49
|
+
InvitationManager: InvitationManagerComponent = InvitationManager,
|
|
50
|
+
onDone,
|
|
51
|
+
...rest
|
|
52
|
+
} = props;
|
|
53
|
+
const { t } = useTranslation('os');
|
|
54
|
+
const title = useMemo(() => {
|
|
55
|
+
switch (activeView) {
|
|
56
|
+
case 'device manager':
|
|
57
|
+
case 'device invitation manager':
|
|
58
|
+
return t('choose devices label');
|
|
59
|
+
default:
|
|
60
|
+
return t('identity heading');
|
|
61
|
+
}
|
|
62
|
+
}, [activeView, t]);
|
|
63
|
+
return (
|
|
64
|
+
<DensityProvider density='fine'>
|
|
65
|
+
<IdentityHeading {...{ identity, titleId, title, onDone }} />
|
|
66
|
+
<Viewport.Root activeView={activeView}>
|
|
67
|
+
<Viewport.Views>
|
|
68
|
+
<Viewport.View id='identity action chooser' classNames={viewStyles}>
|
|
69
|
+
<IdentityActionChooserComponent active={activeView === 'identity action chooser'} {...rest} />
|
|
70
|
+
</Viewport.View>
|
|
71
|
+
<Viewport.View id='device invitation manager' classNames={viewStyles}>
|
|
72
|
+
<InvitationManagerComponent
|
|
73
|
+
active={activeView === 'device invitation manager'}
|
|
74
|
+
{...rest}
|
|
75
|
+
invitationUrl={rest.createInvitationUrl(rest.invitationCode!)}
|
|
76
|
+
/>
|
|
77
|
+
</Viewport.View>
|
|
78
|
+
<Viewport.View classNames={viewStyles} id='update profile form'>
|
|
79
|
+
<ProfileForm
|
|
80
|
+
send={rest.send}
|
|
81
|
+
active={activeView === 'update profile form'}
|
|
82
|
+
profile={identity.profile}
|
|
83
|
+
onUpdateProfile={onUpdateProfile}
|
|
84
|
+
/>
|
|
85
|
+
</Viewport.View>
|
|
86
|
+
{/* <Viewport.View id='signing out'></Viewport.View> */}
|
|
87
|
+
</Viewport.Views>
|
|
88
|
+
</Viewport.Root>
|
|
89
|
+
</DensityProvider>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const IdentityPanelWithInvitationImpl = ({
|
|
94
|
+
invitation,
|
|
95
|
+
...props
|
|
96
|
+
}: IdentityPanelImplProps & { invitation: CancellableInvitationObservable }) => {
|
|
97
|
+
const invitationStatus = useInvitationStatus(invitation);
|
|
98
|
+
return <IdentityPanelImpl {...props} {...invitationStatus} />;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const IdentityPanel = ({
|
|
102
|
+
titleId: propsTitleId,
|
|
103
|
+
createInvitationUrl = (code) => code,
|
|
104
|
+
...props
|
|
105
|
+
}: IdentityPanelProps) => {
|
|
106
|
+
const titleId = useId('identityPanel__heading', propsTitleId);
|
|
107
|
+
const client = useClient();
|
|
108
|
+
const identity = useIdentity();
|
|
109
|
+
if (!identity) {
|
|
110
|
+
console.error('IdentityPanel rendered with no active identity.');
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
const [identityState, identitySend, identityService] = useIdentityMachine(client);
|
|
114
|
+
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
const subscription = identityService.subscribe((state) => {
|
|
117
|
+
log('[state]', state);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
return subscription.unsubscribe;
|
|
121
|
+
}, [identityService]);
|
|
122
|
+
|
|
123
|
+
const activeView = useMemo(() => {
|
|
124
|
+
switch (true) {
|
|
125
|
+
case identityState.matches('choosingAction'):
|
|
126
|
+
return 'identity action chooser';
|
|
127
|
+
case identityState.matches('managingDeviceInvitation'):
|
|
128
|
+
return 'device invitation manager';
|
|
129
|
+
case [{ managingProfile: 'idle' }, { managingProfile: 'pending' }].some(identityState.matches):
|
|
130
|
+
return 'update profile form';
|
|
131
|
+
// case identityState.matches('signingOut'):
|
|
132
|
+
// return 'identity exit';
|
|
133
|
+
default:
|
|
134
|
+
return 'identity action chooser';
|
|
135
|
+
}
|
|
136
|
+
}, [identityState]);
|
|
137
|
+
|
|
138
|
+
const onUpdateProfile = async (profile: NonNullable<Identity['profile']>) => {
|
|
139
|
+
identitySend({ type: 'updateProfile' });
|
|
140
|
+
await client.halo.updateProfile(profile);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const implProps = {
|
|
144
|
+
...props,
|
|
145
|
+
identity,
|
|
146
|
+
activeView,
|
|
147
|
+
send: identitySend,
|
|
148
|
+
titleId,
|
|
149
|
+
createInvitationUrl,
|
|
150
|
+
onUpdateProfile,
|
|
151
|
+
} satisfies IdentityPanelImplProps;
|
|
152
|
+
|
|
153
|
+
return identityState.context.invitation ? (
|
|
154
|
+
<IdentityPanelWithInvitationImpl {...implProps} invitation={identityState.context.invitation} />
|
|
155
|
+
) : (
|
|
156
|
+
<IdentityPanelImpl {...implProps} />
|
|
157
|
+
);
|
|
158
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type cloneElement } from 'react';
|
|
6
|
+
import { type Event, type SingleOrArray } from 'xstate';
|
|
7
|
+
|
|
8
|
+
import type { Identity } from '@dxos/react-client/halo';
|
|
9
|
+
import { type InvitationStatus } from '@dxos/react-client/invitations';
|
|
10
|
+
|
|
11
|
+
import { type IdentityEvent } from './identityMachine';
|
|
12
|
+
import { type InvitationManagerProps } from '../../steps';
|
|
13
|
+
|
|
14
|
+
export type IdentityPanelImplProps = {
|
|
15
|
+
titleId: string;
|
|
16
|
+
activeView: 'device manager' | 'update profile form' | 'device invitation manager' | 'identity action chooser';
|
|
17
|
+
identity: Identity;
|
|
18
|
+
onUpdateProfile?: (profile: NonNullable<Identity['profile']>) => Promise<void>;
|
|
19
|
+
createInvitationUrl: (invitationCode: string) => string;
|
|
20
|
+
send?: (event: SingleOrArray<Event<IdentityEvent>>) => void;
|
|
21
|
+
onDone?: () => void;
|
|
22
|
+
doneActionParent?: Parameters<typeof cloneElement>[0];
|
|
23
|
+
invitationUrl?: string;
|
|
24
|
+
IdentityActionChooser?: React.FC<IdentityPanelStepProps>;
|
|
25
|
+
InvitationManager?: React.FC<InvitationManagerProps>;
|
|
26
|
+
} & Partial<InvitationStatus>;
|
|
27
|
+
|
|
28
|
+
export type IdentityPanelProps = Partial<Omit<IdentityPanelImplProps, 'send' | 'activeView' | 'identity'>>;
|
|
29
|
+
|
|
30
|
+
export type IdentityPanelHeadingProps = Pick<IdentityPanelImplProps, 'titleId' | 'identity' | 'onDone'> & {
|
|
31
|
+
title: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type IdentityPanelStepProps = Pick<IdentityPanelImplProps, 'send' | 'onDone' | 'doneActionParent'> & {
|
|
35
|
+
active?: boolean;
|
|
36
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useMachine } from '@xstate/react';
|
|
6
|
+
import { assign, createMachine, type InterpreterFrom, type StateFrom, type Subscribable } from 'xstate';
|
|
7
|
+
|
|
8
|
+
import { log } from '@dxos/log';
|
|
9
|
+
import { type Client } from '@dxos/react-client';
|
|
10
|
+
import { type Identity } from '@dxos/react-client/halo';
|
|
11
|
+
import { type CancellableInvitationObservable } from '@dxos/react-client/invitations';
|
|
12
|
+
|
|
13
|
+
import { type StepEvent } from '../../steps';
|
|
14
|
+
|
|
15
|
+
type IdentityMachineContext = {
|
|
16
|
+
invitation?: CancellableInvitationObservable;
|
|
17
|
+
identity: Identity | null;
|
|
18
|
+
identitySubscribable: Subscribable<SetIdentityEvent> | null;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type IdentityChooseActionEvent = {
|
|
22
|
+
type: 'chooseDevices' | 'chooseProfile' | /* 'chooseSignOut' | */ 'unchooseAction';
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type IdentitySelectDeviceInvitationEvent = {
|
|
26
|
+
type: 'selectInvitation';
|
|
27
|
+
invitation: CancellableInvitationObservable;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type SetIdentityEvent = {
|
|
31
|
+
type: 'setIdentity';
|
|
32
|
+
identity: Identity | null;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type UpdateProfileEvent = {
|
|
36
|
+
type: 'updateProfile';
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type IdentityEvent =
|
|
40
|
+
| SetIdentityEvent
|
|
41
|
+
| UpdateProfileEvent
|
|
42
|
+
| IdentitySelectDeviceInvitationEvent
|
|
43
|
+
| IdentityChooseActionEvent
|
|
44
|
+
| StepEvent;
|
|
45
|
+
|
|
46
|
+
const identityMachine = createMachine<IdentityMachineContext, IdentityEvent>(
|
|
47
|
+
{
|
|
48
|
+
id: 'identity',
|
|
49
|
+
predictableActionArguments: true,
|
|
50
|
+
context: {
|
|
51
|
+
identity: null,
|
|
52
|
+
identitySubscribable: null,
|
|
53
|
+
},
|
|
54
|
+
initial: 'choosingAction',
|
|
55
|
+
invoke: {
|
|
56
|
+
src: (context) => context.identitySubscribable!,
|
|
57
|
+
},
|
|
58
|
+
states: {
|
|
59
|
+
choosingAction: {},
|
|
60
|
+
managingDeviceInvitation: {},
|
|
61
|
+
managingProfile: {
|
|
62
|
+
initial: 'idle',
|
|
63
|
+
states: {
|
|
64
|
+
idle: {},
|
|
65
|
+
pending: {},
|
|
66
|
+
},
|
|
67
|
+
on: {
|
|
68
|
+
setIdentity: { target: 'choosingAction', actions: ['setIdentity', 'log'] },
|
|
69
|
+
updateProfile: { target: '.pending', actions: 'log' },
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
// signingOut: {},
|
|
73
|
+
},
|
|
74
|
+
on: {
|
|
75
|
+
unchooseAction: { target: '.choosingAction', actions: ['unsetInvitation', 'log'] },
|
|
76
|
+
chooseDevices: { target: '.managingDeviceInvitation', actions: ['unsetInvitation', 'log'] },
|
|
77
|
+
deselectInvitation: { target: '.choosingAction', actions: ['unsetInvitation', 'log'] },
|
|
78
|
+
selectInvitation: { target: '.managingDeviceInvitation', actions: ['setInvitation', 'log'] },
|
|
79
|
+
chooseProfile: { target: '.managingProfile', actions: 'log' },
|
|
80
|
+
// chooseSignOut: { target: '.signingOut', actions: 'log' },
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
actions: {
|
|
85
|
+
setIdentity: assign<IdentityMachineContext, IdentityEvent>({
|
|
86
|
+
identity: (context, event) => (event as SetIdentityEvent)?.identity ?? null,
|
|
87
|
+
}),
|
|
88
|
+
setInvitation: assign<IdentityMachineContext, IdentityEvent>({
|
|
89
|
+
invitation: (context, event) => (event as IdentitySelectDeviceInvitationEvent)?.invitation ?? null,
|
|
90
|
+
}),
|
|
91
|
+
unsetInvitation: assign<IdentityMachineContext, IdentityEvent>({
|
|
92
|
+
invitation: () => undefined,
|
|
93
|
+
}),
|
|
94
|
+
log: (context, event) => {
|
|
95
|
+
log('[transition]', {
|
|
96
|
+
event,
|
|
97
|
+
context,
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
type IdentityMachine = typeof identityMachine;
|
|
105
|
+
|
|
106
|
+
type IdentityState = StateFrom<IdentityMachine>;
|
|
107
|
+
type IdentitySend = InterpreterFrom<IdentityMachine>['send'];
|
|
108
|
+
|
|
109
|
+
const useIdentityMachine = (client: Client, options?: Parameters<typeof useMachine<IdentityMachine>>[1]) => {
|
|
110
|
+
return useMachine(identityMachine, {
|
|
111
|
+
...options,
|
|
112
|
+
context: {
|
|
113
|
+
...options?.context,
|
|
114
|
+
identity: client.halo.identity.get(),
|
|
115
|
+
identitySubscribable: client.halo.identity.map((identity) => ({
|
|
116
|
+
type: 'setIdentity',
|
|
117
|
+
identity,
|
|
118
|
+
})) satisfies Subscribable<SetIdentityEvent>,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export type {
|
|
124
|
+
IdentityMachine,
|
|
125
|
+
IdentityEvent,
|
|
126
|
+
IdentityMachineContext,
|
|
127
|
+
IdentityChooseActionEvent,
|
|
128
|
+
IdentityState,
|
|
129
|
+
IdentitySend,
|
|
130
|
+
};
|
|
131
|
+
export { identityMachine, useIdentityMachine };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { CaretRight, Plus, Power, UserGear } from '@phosphor-icons/react';
|
|
6
|
+
import React, { useCallback } from 'react';
|
|
7
|
+
|
|
8
|
+
import { useClient } from '@dxos/react-client';
|
|
9
|
+
import { useHaloInvitations } from '@dxos/react-client/halo';
|
|
10
|
+
import { Invitation, InvitationEncoder } from '@dxos/react-client/invitations';
|
|
11
|
+
import { DensityProvider, useTranslation } from '@dxos/react-ui';
|
|
12
|
+
import { getSize } from '@dxos/react-ui-theme';
|
|
13
|
+
|
|
14
|
+
import { Action } from '../../../components';
|
|
15
|
+
import { type IdentityPanelStepProps } from '../IdentityPanelProps';
|
|
16
|
+
|
|
17
|
+
export type IdentityActionChooserProps = IdentityPanelStepProps;
|
|
18
|
+
|
|
19
|
+
export const IdentityActionChooser = (props: IdentityPanelStepProps) => {
|
|
20
|
+
const { send } = props;
|
|
21
|
+
const client = useClient();
|
|
22
|
+
const invitations = useHaloInvitations();
|
|
23
|
+
const onInvitationEvent = useCallback((invitation: Invitation) => {
|
|
24
|
+
const invitationCode = InvitationEncoder.encode(invitation);
|
|
25
|
+
if (invitation.state === Invitation.State.CONNECTING) {
|
|
26
|
+
console.log(JSON.stringify({ invitationCode, authCode: invitation.authCode }));
|
|
27
|
+
}
|
|
28
|
+
}, []);
|
|
29
|
+
const createInvitation = (e: React.MouseEvent) => {
|
|
30
|
+
const testing = e.altKey && e.shiftKey;
|
|
31
|
+
invitations.forEach((invitation) => invitation.cancel());
|
|
32
|
+
const invitation = client.halo.share(
|
|
33
|
+
testing ? { type: Invitation.Type.MULTIUSE, authMethod: Invitation.AuthMethod.NONE } : undefined,
|
|
34
|
+
);
|
|
35
|
+
// TODO(wittjosiah): Don't depend on NODE_ENV.
|
|
36
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
37
|
+
invitation.subscribe(onInvitationEvent);
|
|
38
|
+
}
|
|
39
|
+
send?.({ type: 'selectInvitation', invitation });
|
|
40
|
+
};
|
|
41
|
+
return <IdentityActionChooserImpl {...props} onCreateInvitationClick={(e) => createInvitation(e)} />;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type IdentityActionChooserImplProps = IdentityActionChooserProps & {
|
|
45
|
+
onCreateInvitationClick?: (e: React.MouseEvent) => void;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const IdentityActionChooserImpl = ({
|
|
49
|
+
onCreateInvitationClick,
|
|
50
|
+
active,
|
|
51
|
+
send,
|
|
52
|
+
onDone,
|
|
53
|
+
doneActionParent,
|
|
54
|
+
}: IdentityActionChooserImplProps) => {
|
|
55
|
+
const { t } = useTranslation('os');
|
|
56
|
+
|
|
57
|
+
// const doneAction = (
|
|
58
|
+
// <PanelAction aria-label={t('done label')} onClick={onDone} disabled={!active} data-testid='identity-panel-done'>
|
|
59
|
+
// <Check weight='light' className={getSize(6)} />
|
|
60
|
+
// </PanelAction>
|
|
61
|
+
// );
|
|
62
|
+
return (
|
|
63
|
+
<div role='none' className='grow flex flex-col gap-1'>
|
|
64
|
+
<DensityProvider density='coarse'>
|
|
65
|
+
<div className='grow justify-center flex flex-col gap-1'>
|
|
66
|
+
<Action
|
|
67
|
+
disabled={!active}
|
|
68
|
+
data-testid='devices-panel.create-invitation'
|
|
69
|
+
onClick={onCreateInvitationClick}
|
|
70
|
+
classNames='plb-4'
|
|
71
|
+
>
|
|
72
|
+
<Plus className={getSize(6)} />
|
|
73
|
+
<span className='grow mli-3'>{t('choose devices label')}</span>
|
|
74
|
+
<CaretRight weight='bold' className={getSize(4)} />
|
|
75
|
+
</Action>
|
|
76
|
+
<Action data-testid='manage-profile' onClick={() => send?.({ type: 'chooseProfile' })} classNames='plb-4'>
|
|
77
|
+
<UserGear className={getSize(6)} />
|
|
78
|
+
<span className='grow mli-3'>{t('choose profile label')}</span>
|
|
79
|
+
<CaretRight weight='bold' className={getSize(4)} />
|
|
80
|
+
</Action>
|
|
81
|
+
<Action
|
|
82
|
+
disabled
|
|
83
|
+
data-testid='sign-out'
|
|
84
|
+
onClick={() => {} /* send({ type: 'chooseSignOut' }) */}
|
|
85
|
+
classNames='plb-4'
|
|
86
|
+
>
|
|
87
|
+
<Power className={getSize(6)} />
|
|
88
|
+
<span className='grow mli-3'>{t('choose sign out label')}</span>
|
|
89
|
+
<CaretRight weight='bold' className={getSize(4)} />
|
|
90
|
+
</Action>
|
|
91
|
+
</div>
|
|
92
|
+
</DensityProvider>
|
|
93
|
+
{/* <PanelActions>{doneActionParent ? cloneElement(doneActionParent, {}, doneAction) : doneAction}</PanelActions> */}
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useState } from 'react';
|
|
6
|
+
import { type Event, type SingleOrArray } from 'xstate';
|
|
7
|
+
|
|
8
|
+
import { log } from '@dxos/log';
|
|
9
|
+
import { type Identity } from '@dxos/react-client/halo';
|
|
10
|
+
import { useTranslation } from '@dxos/react-ui';
|
|
11
|
+
|
|
12
|
+
import { Action, Actions, StepHeading, Input } from '../../../components';
|
|
13
|
+
import { type IdentityPanelStepProps } from '../IdentityPanelProps';
|
|
14
|
+
import { type IdentityEvent } from '../identityMachine';
|
|
15
|
+
|
|
16
|
+
export interface ProfileFormProps extends Omit<IdentityPanelStepProps, 'send'> {
|
|
17
|
+
send?: (event: SingleOrArray<Event<IdentityEvent>>) => void;
|
|
18
|
+
onUpdateProfile?: (profile: NonNullable<Identity['profile']>) => Promise<void>;
|
|
19
|
+
profile?: Identity['profile'];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type ProfileFormImplProps = ProfileFormProps & {
|
|
23
|
+
validationMessage?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const ProfileForm = (props: ProfileFormProps) => {
|
|
27
|
+
const { onUpdateProfile } = props;
|
|
28
|
+
const { t } = useTranslation('os');
|
|
29
|
+
const [validationMessage, setValidationMessage] = useState('');
|
|
30
|
+
const handleUpdateProfile = async (profile: NonNullable<Identity['profile']>) => {
|
|
31
|
+
await onUpdateProfile?.(profile).catch((error) => {
|
|
32
|
+
log.catch(error);
|
|
33
|
+
setValidationMessage(t('failed to update profile message'));
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
return <ProfileFormImpl {...props} onUpdateProfile={handleUpdateProfile} validationMessage={validationMessage} />;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// TODO(zhenyasav): impl shouldn't need send()
|
|
40
|
+
export const ProfileFormImpl = (props: ProfileFormImplProps) => {
|
|
41
|
+
const { active, profile, send, onUpdateProfile, validationMessage } = props;
|
|
42
|
+
const disabled = !active;
|
|
43
|
+
const { t } = useTranslation('os');
|
|
44
|
+
const [inputValue, setInputValue] = useState(profile?.displayName ?? '');
|
|
45
|
+
return (
|
|
46
|
+
<>
|
|
47
|
+
<div role='none' className='grow flex flex-col justify-center'>
|
|
48
|
+
<Input
|
|
49
|
+
{...{ validationMessage }}
|
|
50
|
+
label={<StepHeading>{t('display name input label')}</StepHeading>}
|
|
51
|
+
disabled={disabled}
|
|
52
|
+
data-testid='display-name-input'
|
|
53
|
+
placeholder={t('display name input placeholder')}
|
|
54
|
+
value={inputValue}
|
|
55
|
+
onChange={({ target: { value } }) => setInputValue(value)}
|
|
56
|
+
onKeyDown={({ key }) => key === 'Enter' && onUpdateProfile?.({ displayName: inputValue })}
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
<Actions>
|
|
60
|
+
<Action
|
|
61
|
+
variant='ghost'
|
|
62
|
+
disabled={disabled}
|
|
63
|
+
onClick={() => send?.({ type: 'unchooseAction' })}
|
|
64
|
+
data-testid={'update-profile-form-back'}
|
|
65
|
+
>
|
|
66
|
+
{t('back label')}
|
|
67
|
+
</Action>
|
|
68
|
+
<Action
|
|
69
|
+
variant='primary'
|
|
70
|
+
disabled={disabled}
|
|
71
|
+
onClick={() => onUpdateProfile?.({ displayName: inputValue })}
|
|
72
|
+
data-testid={'update-profile-form-continue'}
|
|
73
|
+
>
|
|
74
|
+
{t('done label')}
|
|
75
|
+
</Action>
|
|
76
|
+
</Actions>
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
};
|