@medplum/react 1.0.6 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/OperationOutcomeAlert/OperationOutcomeAlert.d.ts +6 -0
- package/dist/cjs/ReferenceRangeEditor/ReferenceRangeEditor.d.ts +1 -2
- package/dist/cjs/ResourceTimeline/ResourceTimeline.d.ts +2 -2
- package/dist/cjs/auth/AuthenticationForm.d.ts +15 -1
- package/dist/cjs/auth/SignInForm.d.ts +1 -0
- package/dist/cjs/index.cjs +150 -167
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/esm/DefaultResourceTimeline/DefaultResourceTimeline.mjs +6 -18
- package/dist/esm/DefaultResourceTimeline/DefaultResourceTimeline.mjs.map +1 -1
- package/dist/esm/EncounterTimeline/EncounterTimeline.mjs +7 -24
- package/dist/esm/EncounterTimeline/EncounterTimeline.mjs.map +1 -1
- package/dist/esm/OperationOutcomeAlert/OperationOutcomeAlert.d.ts +6 -0
- package/dist/esm/OperationOutcomeAlert/OperationOutcomeAlert.mjs +13 -0
- package/dist/esm/OperationOutcomeAlert/OperationOutcomeAlert.mjs.map +1 -0
- package/dist/esm/PatientTimeline/PatientTimeline.mjs +13 -20
- package/dist/esm/PatientTimeline/PatientTimeline.mjs.map +1 -1
- package/dist/esm/ReferenceRangeEditor/ReferenceRangeEditor.d.ts +1 -2
- package/dist/esm/ReferenceRangeEditor/ReferenceRangeEditor.mjs.map +1 -1
- package/dist/esm/ResourcePropertyDisplay/ResourcePropertyDisplay.mjs +2 -2
- package/dist/esm/ResourcePropertyDisplay/ResourcePropertyDisplay.mjs.map +1 -1
- package/dist/esm/ResourcePropertyInput/ResourcePropertyInput.mjs +2 -2
- package/dist/esm/ResourcePropertyInput/ResourcePropertyInput.mjs.map +1 -1
- package/dist/esm/ResourceTimeline/ResourceTimeline.d.ts +2 -2
- package/dist/esm/ResourceTimeline/ResourceTimeline.mjs +19 -24
- package/dist/esm/ResourceTimeline/ResourceTimeline.mjs.map +1 -1
- package/dist/esm/ServiceRequestTimeline/ServiceRequestTimeline.mjs +8 -30
- package/dist/esm/ServiceRequestTimeline/ServiceRequestTimeline.mjs.map +1 -1
- package/dist/esm/auth/AuthenticationForm.d.ts +15 -1
- package/dist/esm/auth/AuthenticationForm.mjs +66 -34
- package/dist/esm/auth/AuthenticationForm.mjs.map +1 -1
- package/dist/esm/auth/NewUserForm.mjs +3 -4
- package/dist/esm/auth/NewUserForm.mjs.map +1 -1
- package/dist/esm/auth/SignInForm.d.ts +1 -0
- package/dist/esm/auth/SignInForm.mjs +27 -19
- package/dist/esm/auth/SignInForm.mjs.map +1 -1
- package/dist/esm/index.min.mjs +1 -1
- package/package.json +17 -17
- package/rollup.config.mjs +0 -110
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useCallback, useEffect } from 'react';
|
|
2
2
|
import { Document } from '../Document/Document.mjs';
|
|
3
3
|
import { useMedplum } from '../MedplumProvider/MedplumProvider.mjs';
|
|
4
4
|
import { AuthenticationForm } from './AuthenticationForm.mjs';
|
|
@@ -23,7 +23,22 @@ function SignInForm(props) {
|
|
|
23
23
|
const [login, setLogin] = useState(undefined);
|
|
24
24
|
const [mfaRequired, setAuthenticatorRequired] = useState(false);
|
|
25
25
|
const [memberships, setMemberships] = useState(undefined);
|
|
26
|
-
|
|
26
|
+
const handleCode = useCallback((code) => {
|
|
27
|
+
if (onCode) {
|
|
28
|
+
onCode(code);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
medplum
|
|
32
|
+
.processCode(code)
|
|
33
|
+
.then(() => {
|
|
34
|
+
if (onSuccess) {
|
|
35
|
+
onSuccess();
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
.catch(console.log);
|
|
39
|
+
}
|
|
40
|
+
}, [medplum, onCode, onSuccess]);
|
|
41
|
+
const handleAuthResponse = useCallback((response) => {
|
|
27
42
|
setAuthenticatorRequired(!!response.mfaRequired);
|
|
28
43
|
if (response.login) {
|
|
29
44
|
setLogin(response.login);
|
|
@@ -39,28 +54,21 @@ function SignInForm(props) {
|
|
|
39
54
|
handleCode(response.code);
|
|
40
55
|
}
|
|
41
56
|
}
|
|
42
|
-
}
|
|
43
|
-
|
|
57
|
+
}, [chooseScopes, handleCode]);
|
|
58
|
+
const handleScopeResponse = useCallback((response) => {
|
|
44
59
|
handleCode(response.code);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
onCode(code);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
60
|
+
}, [handleCode]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (props.login) {
|
|
51
63
|
medplum
|
|
52
|
-
.
|
|
53
|
-
.then(
|
|
54
|
-
|
|
55
|
-
onSuccess();
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
.catch(console.log);
|
|
64
|
+
.get('auth/login/' + props.login)
|
|
65
|
+
.then(handleAuthResponse)
|
|
66
|
+
.catch(console.error);
|
|
59
67
|
}
|
|
60
|
-
}
|
|
68
|
+
}, [medplum, props, handleAuthResponse]);
|
|
61
69
|
return (React.createElement(Document, { width: 450 }, (() => {
|
|
62
70
|
if (!login) {
|
|
63
|
-
return (React.createElement(AuthenticationForm, {
|
|
71
|
+
return (React.createElement(AuthenticationForm, { onForgotPassword: onForgotPassword, onRegister: onRegister, handleAuthResponse: handleAuthResponse, ...baseLoginRequest }, props.children));
|
|
64
72
|
}
|
|
65
73
|
else if (mfaRequired) {
|
|
66
74
|
return React.createElement(MfaForm, { login: login, handleAuthResponse: handleAuthResponse });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignInForm.mjs","sources":["../../../src/auth/SignInForm.tsx"],"sourcesContent":["import { BaseLoginRequest, LoginAuthenticationResponse } from '@medplum/core';\nimport { ProjectMembership } from '@medplum/fhirtypes';\nimport React, { useState } from 'react';\nimport { Document } from '../Document/Document';\nimport { useMedplum } from '../MedplumProvider/MedplumProvider';\nimport { AuthenticationForm } from './AuthenticationForm';\nimport { ChooseProfileForm } from './ChooseProfileForm';\nimport { ChooseScopeForm } from './ChooseScopeForm';\nimport { MfaForm } from './MfaForm';\nimport { NewProjectForm } from './NewProjectForm';\n\nexport interface SignInFormProps extends BaseLoginRequest {\n readonly chooseScopes?: boolean;\n readonly onSuccess?: () => void;\n readonly onForgotPassword?: () => void;\n readonly onRegister?: () => void;\n readonly onCode?: (code: string) => void;\n readonly children?: React.ReactNode;\n}\n\n/**\n * The SignInForm component allows users to sign in to Medplum.\n *\n * \"Signing in\" is a multi-step process:\n * 1) Authentication - identify the user\n * 2) MFA - If MFA is enabled, prompt for MFA code\n * 3) Choose profile - If the user has multiple profiles, prompt to choose one\n * 4) Choose scope - If the user has multiple scopes, prompt to choose one\n * 5) Success - Return to the caller with either a code or a redirect\n */\nexport function SignInForm(props: SignInFormProps): JSX.Element {\n const { chooseScopes, onSuccess, onForgotPassword, onRegister, onCode, ...baseLoginRequest } = props;\n const medplum = useMedplum();\n const [login, setLogin] = useState<string | undefined>(undefined);\n const [mfaRequired, setAuthenticatorRequired] = useState<boolean>(false);\n const [memberships, setMemberships] = useState<ProjectMembership[] | undefined>(undefined);\n\n
|
|
1
|
+
{"version":3,"file":"SignInForm.mjs","sources":["../../../src/auth/SignInForm.tsx"],"sourcesContent":["import { BaseLoginRequest, LoginAuthenticationResponse } from '@medplum/core';\nimport { ProjectMembership } from '@medplum/fhirtypes';\nimport React, { useCallback, useEffect, useState } from 'react';\nimport { Document } from '../Document/Document';\nimport { useMedplum } from '../MedplumProvider/MedplumProvider';\nimport { AuthenticationForm } from './AuthenticationForm';\nimport { ChooseProfileForm } from './ChooseProfileForm';\nimport { ChooseScopeForm } from './ChooseScopeForm';\nimport { MfaForm } from './MfaForm';\nimport { NewProjectForm } from './NewProjectForm';\n\nexport interface SignInFormProps extends BaseLoginRequest {\n readonly login?: string;\n readonly chooseScopes?: boolean;\n readonly onSuccess?: () => void;\n readonly onForgotPassword?: () => void;\n readonly onRegister?: () => void;\n readonly onCode?: (code: string) => void;\n readonly children?: React.ReactNode;\n}\n\n/**\n * The SignInForm component allows users to sign in to Medplum.\n *\n * \"Signing in\" is a multi-step process:\n * 1) Authentication - identify the user\n * 2) MFA - If MFA is enabled, prompt for MFA code\n * 3) Choose profile - If the user has multiple profiles, prompt to choose one\n * 4) Choose scope - If the user has multiple scopes, prompt to choose one\n * 5) Success - Return to the caller with either a code or a redirect\n */\nexport function SignInForm(props: SignInFormProps): JSX.Element {\n const { chooseScopes, onSuccess, onForgotPassword, onRegister, onCode, ...baseLoginRequest } = props;\n const medplum = useMedplum();\n const [login, setLogin] = useState<string | undefined>(undefined);\n const [mfaRequired, setAuthenticatorRequired] = useState<boolean>(false);\n const [memberships, setMemberships] = useState<ProjectMembership[] | undefined>(undefined);\n\n const handleCode = useCallback(\n (code: string): void => {\n if (onCode) {\n onCode(code);\n } else {\n medplum\n .processCode(code)\n .then(() => {\n if (onSuccess) {\n onSuccess();\n }\n })\n .catch(console.log);\n }\n },\n [medplum, onCode, onSuccess]\n );\n\n const handleAuthResponse = useCallback(\n (response: LoginAuthenticationResponse): void => {\n setAuthenticatorRequired(!!response.mfaRequired);\n\n if (response.login) {\n setLogin(response.login);\n }\n\n if (response.memberships) {\n setMemberships(response.memberships);\n }\n\n if (response.code) {\n if (chooseScopes) {\n setMemberships(undefined);\n } else {\n handleCode(response.code as string);\n }\n }\n },\n [chooseScopes, handleCode]\n );\n\n const handleScopeResponse = useCallback(\n (response: LoginAuthenticationResponse): void => {\n handleCode(response.code as string);\n },\n [handleCode]\n );\n\n useEffect(() => {\n if (props.login) {\n medplum\n .get('auth/login/' + props.login)\n .then(handleAuthResponse)\n .catch(console.error);\n }\n }, [medplum, props, handleAuthResponse]);\n\n return (\n <Document width={450}>\n {(() => {\n if (!login) {\n return (\n <AuthenticationForm\n onForgotPassword={onForgotPassword}\n onRegister={onRegister}\n handleAuthResponse={handleAuthResponse}\n {...baseLoginRequest}\n >\n {props.children}\n </AuthenticationForm>\n );\n } else if (mfaRequired) {\n return <MfaForm login={login} handleAuthResponse={handleAuthResponse} />;\n } else if (memberships) {\n return <ChooseProfileForm login={login} memberships={memberships} handleAuthResponse={handleAuthResponse} />;\n } else if (props.projectId === 'new') {\n return <NewProjectForm login={login} handleAuthResponse={handleAuthResponse} />;\n } else if (props.chooseScopes) {\n return <ChooseScopeForm login={login} scope={props.scope} handleAuthResponse={handleScopeResponse} />;\n } else {\n return <div>Success</div>;\n }\n })()}\n </Document>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;AAqBA;;;;;;;;;AASG;AACG,SAAU,UAAU,CAAC,KAAsB,EAAA;AAC/C,IAAA,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,GAAG,KAAK,CAAC;AACrG,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAqB,SAAS,CAAC,CAAC;IAClE,MAAM,CAAC,WAAW,EAAE,wBAAwB,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IACzE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAkC,SAAS,CAAC,CAAC;AAE3F,IAAA,MAAM,UAAU,GAAG,WAAW,CAC5B,CAAC,IAAY,KAAU;AACrB,QAAA,IAAI,MAAM,EAAE;YACV,MAAM,CAAC,IAAI,CAAC,CAAC;AACd,SAAA;AAAM,aAAA;YACL,OAAO;iBACJ,WAAW,CAAC,IAAI,CAAC;iBACjB,IAAI,CAAC,MAAK;AACT,gBAAA,IAAI,SAAS,EAAE;AACb,oBAAA,SAAS,EAAE,CAAC;AACb,iBAAA;AACH,aAAC,CAAC;AACD,iBAAA,KAAK,CAAC,OAAO,CAAC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