@medplum/react 0.9.29 → 0.9.32

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.
Files changed (59) hide show
  1. package/dist/cjs/auth/AuthenticationForm.d.ts +14 -0
  2. package/dist/cjs/auth/ChooseProfileForm.d.ts +8 -0
  3. package/dist/cjs/auth/NewProjectForm.d.ts +7 -0
  4. package/dist/cjs/auth/NewUserForm.d.ts +10 -0
  5. package/dist/cjs/auth/RegisterForm.d.ts +12 -0
  6. package/dist/cjs/{SignInForm.d.ts → auth/SignInForm.d.ts} +1 -1
  7. package/dist/cjs/index.d.ts +3 -2
  8. package/dist/cjs/index.js +609 -548
  9. package/dist/cjs/index.js.map +1 -1
  10. package/dist/cjs/index.min.js +1 -1
  11. package/dist/cjs/index.min.js.map +1 -1
  12. package/dist/cjs/styles.css +197 -197
  13. package/dist/esm/Autocomplete.js +1 -0
  14. package/dist/esm/Autocomplete.js.map +1 -1
  15. package/dist/esm/CodeInput.js +1 -1
  16. package/dist/esm/CodeInput.js.map +1 -1
  17. package/dist/esm/CodeableConceptInput.js +1 -1
  18. package/dist/esm/CodeableConceptInput.js.map +1 -1
  19. package/dist/esm/CodingInput.js +1 -1
  20. package/dist/esm/CodingInput.js.map +1 -1
  21. package/dist/esm/GoogleButton.js +2 -2
  22. package/dist/esm/GoogleButton.js.map +1 -1
  23. package/dist/esm/MedplumLink.js +29 -14
  24. package/dist/esm/MedplumLink.js.map +1 -1
  25. package/dist/esm/ResourceHistoryTable.js +15 -11
  26. package/dist/esm/ResourceHistoryTable.js.map +1 -1
  27. package/dist/esm/ResourceTimeline.js +3 -1
  28. package/dist/esm/ResourceTimeline.js.map +1 -1
  29. package/dist/esm/auth/AuthenticationForm.d.ts +14 -0
  30. package/dist/esm/{SignInForm.js → auth/AuthenticationForm.js} +12 -76
  31. package/dist/esm/auth/AuthenticationForm.js.map +1 -0
  32. package/dist/esm/auth/ChooseProfileForm.d.ts +8 -0
  33. package/dist/esm/auth/ChooseProfileForm.js +32 -0
  34. package/dist/esm/auth/ChooseProfileForm.js.map +1 -0
  35. package/dist/esm/auth/NewProjectForm.d.ts +7 -0
  36. package/dist/esm/auth/NewProjectForm.js +42 -0
  37. package/dist/esm/auth/NewProjectForm.js.map +1 -0
  38. package/dist/esm/auth/NewUserForm.d.ts +10 -0
  39. package/dist/esm/auth/NewUserForm.js +87 -0
  40. package/dist/esm/auth/NewUserForm.js.map +1 -0
  41. package/dist/esm/auth/RegisterForm.d.ts +12 -0
  42. package/dist/esm/auth/RegisterForm.js +39 -0
  43. package/dist/esm/auth/RegisterForm.js.map +1 -0
  44. package/dist/esm/{SignInForm.d.ts → auth/SignInForm.d.ts} +1 -1
  45. package/dist/esm/auth/SignInForm.js +52 -0
  46. package/dist/esm/auth/SignInForm.js.map +1 -0
  47. package/dist/esm/index.d.ts +3 -2
  48. package/dist/esm/index.js +3 -2
  49. package/dist/esm/index.js.map +1 -1
  50. package/dist/esm/index.min.js +1 -1
  51. package/dist/esm/index.min.js.map +1 -1
  52. package/dist/esm/styles.css +197 -197
  53. package/package.json +16 -18
  54. package/dist/cjs/RegisterForm.d.ts +0 -18
  55. package/dist/esm/RegisterForm.d.ts +0 -18
  56. package/dist/esm/RegisterForm.js +0 -121
  57. package/dist/esm/RegisterForm.js.map +0 -1
  58. package/dist/esm/SignInForm.js.map +0 -1
  59. package/stats.html +0 -4034
@@ -0,0 +1,87 @@
1
+ import { __awaiter } from '../node_modules/tslib/tslib.es6.js';
2
+ import React, { useState, useEffect } from 'react';
3
+ import { Button } from '../Button.js';
4
+ import { Form } from '../Form.js';
5
+ import { FormSection } from '../FormSection.js';
6
+ import { getGoogleClientId, GoogleButton } from '../GoogleButton.js';
7
+ import { Input } from '../Input.js';
8
+ import { useMedplum } from '../MedplumProvider.js';
9
+ import { getIssuesForExpression } from '../utils/outcomes.js';
10
+ import { initRecaptcha, getRecaptcha } from '../utils/recaptcha.js';
11
+
12
+ function NewUserForm(props) {
13
+ const googleClientId = getGoogleClientId(props.googleClientId);
14
+ const recaptchaSiteKey = props.recaptchaSiteKey;
15
+ const medplum = useMedplum();
16
+ const [outcome, setOutcome] = useState();
17
+ const issues = getIssuesForExpression(outcome, undefined);
18
+ useEffect(() => initRecaptcha(recaptchaSiteKey), [recaptchaSiteKey]);
19
+ return (React.createElement(Form, { style: { maxWidth: 400 }, onSubmit: (formData) => __awaiter(this, void 0, void 0, function* () {
20
+ try {
21
+ const recaptchaToken = yield getRecaptcha(recaptchaSiteKey);
22
+ props.handleAuthResponse(yield medplum.startNewUser({
23
+ projectId: props.projectId,
24
+ firstName: formData.firstName,
25
+ lastName: formData.lastName,
26
+ email: formData.email,
27
+ password: formData.password,
28
+ remember: formData.remember === 'true',
29
+ recaptchaSiteKey,
30
+ recaptchaToken,
31
+ }));
32
+ }
33
+ catch (err) {
34
+ setOutcome(err);
35
+ }
36
+ }) },
37
+ React.createElement("div", { className: "medplum-center" }, props.children),
38
+ issues && (React.createElement("div", { className: "medplum-input-error" }, issues.map((issue) => {
39
+ var _a, _b;
40
+ return (React.createElement("div", { "data-testid": "text-field-error", key: (_a = issue.details) === null || _a === void 0 ? void 0 : _a.text }, (_b = issue.details) === null || _b === void 0 ? void 0 : _b.text));
41
+ }))),
42
+ googleClientId && (React.createElement(React.Fragment, null,
43
+ React.createElement("div", { className: "medplum-signin-google-container" },
44
+ React.createElement(GoogleButton, { googleClientId: googleClientId, handleGoogleCredential: (response) => __awaiter(this, void 0, void 0, function* () {
45
+ try {
46
+ props.handleAuthResponse(yield medplum.startGoogleLogin({
47
+ googleClientId: response.clientId,
48
+ googleCredential: response.credential,
49
+ createUser: true,
50
+ }));
51
+ }
52
+ catch (err) {
53
+ setOutcome(err);
54
+ }
55
+ }) })),
56
+ React.createElement("div", { className: "medplum-signin-separator" }, "or"))),
57
+ React.createElement(FormSection, { title: "First Name", htmlFor: "firstName", outcome: outcome },
58
+ React.createElement(Input, { name: "firstName", type: "text", testid: "firstName", placeholder: "First name", required: true, autoFocus: true, outcome: outcome })),
59
+ React.createElement(FormSection, { title: "Last Name", htmlFor: "lastName", outcome: outcome },
60
+ React.createElement(Input, { name: "lastName", type: "text", testid: "lastName", placeholder: "Last name", required: true, outcome: outcome })),
61
+ React.createElement(FormSection, { title: "Email", htmlFor: "email", outcome: outcome },
62
+ React.createElement(Input, { name: "email", type: "email", testid: "email", placeholder: "name@domain.com", required: true, outcome: outcome })),
63
+ React.createElement(FormSection, { title: "Password", htmlFor: "password", outcome: outcome },
64
+ React.createElement(Input, { name: "password", type: "password", testid: "password", autoComplete: "off", required: true, outcome: outcome })),
65
+ React.createElement("p", { style: { fontSize: '12px', color: '#888' } },
66
+ "By clicking submit you agree to the Medplum ",
67
+ React.createElement("a", { href: "https://www.medplum.com/privacy" }, "Privacy\u00A0Policy"),
68
+ ' and ',
69
+ React.createElement("a", { href: "https://www.medplum.com/terms" }, "Terms\u00A0of\u00A0Service"),
70
+ "."),
71
+ React.createElement("p", { style: { fontSize: '12px', color: '#888' } },
72
+ "This site is protected by reCAPTCHA and the Google",
73
+ ' ',
74
+ React.createElement("a", { href: "https://policies.google.com/privacy" }, "Privacy\u00A0Policy"),
75
+ ' and ',
76
+ React.createElement("a", { href: "https://policies.google.com/terms" }, "Terms\u00A0of\u00A0Service"),
77
+ " apply."),
78
+ React.createElement("div", { className: "medplum-signin-buttons" },
79
+ React.createElement("div", null,
80
+ React.createElement("input", { type: "checkbox", id: "remember", name: "remember", value: "true" }),
81
+ React.createElement("label", { htmlFor: "remember" }, "Remember me")),
82
+ React.createElement("div", null,
83
+ React.createElement(Button, { type: "submit", testid: "submit" }, "Create account")))));
84
+ }
85
+
86
+ export { NewUserForm };
87
+ //# sourceMappingURL=NewUserForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NewUserForm.js","sources":["../../../src/auth/NewUserForm.tsx"],"sourcesContent":["import { GoogleCredentialResponse, LoginAuthenticationResponse } from '@medplum/core';\nimport { OperationOutcome } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport { Button } from '../Button';\nimport { Form } from '../Form';\nimport { FormSection } from '../FormSection';\nimport { getGoogleClientId, GoogleButton } from '../GoogleButton';\nimport { Input } from '../Input';\nimport { useMedplum } from '../MedplumProvider';\nimport { getIssuesForExpression } from '../utils/outcomes';\nimport { getRecaptcha, initRecaptcha } from '../utils/recaptcha';\n\nexport interface NewUserFormProps {\n readonly projectId: string;\n readonly googleClientId?: string;\n readonly recaptchaSiteKey: string;\n readonly children?: React.ReactNode;\n readonly handleAuthResponse: (response: LoginAuthenticationResponse) => void;\n}\n\nexport function NewUserForm(props: NewUserFormProps): JSX.Element {\n const googleClientId = getGoogleClientId(props.googleClientId);\n const recaptchaSiteKey = props.recaptchaSiteKey;\n const medplum = useMedplum();\n const [outcome, setOutcome] = useState<OperationOutcome>();\n const issues = getIssuesForExpression(outcome, undefined);\n\n useEffect(() => initRecaptcha(recaptchaSiteKey), [recaptchaSiteKey]);\n\n return (\n <Form\n style={{ maxWidth: 400 }}\n onSubmit={async (formData: Record<string, string>) => {\n try {\n const recaptchaToken = await getRecaptcha(recaptchaSiteKey);\n props.handleAuthResponse(\n await medplum.startNewUser({\n projectId: props.projectId,\n firstName: formData.firstName,\n lastName: formData.lastName,\n email: formData.email,\n password: formData.password,\n remember: formData.remember === 'true',\n recaptchaSiteKey,\n recaptchaToken,\n })\n );\n } catch (err) {\n setOutcome(err as OperationOutcome);\n }\n }}\n >\n <div className=\"medplum-center\">{props.children}</div>\n {issues && (\n <div className=\"medplum-input-error\">\n {issues.map((issue) => (\n <div data-testid=\"text-field-error\" key={issue.details?.text}>\n {issue.details?.text}\n </div>\n ))}\n </div>\n )}\n {googleClientId && (\n <>\n <div className=\"medplum-signin-google-container\">\n <GoogleButton\n googleClientId={googleClientId}\n handleGoogleCredential={async (response: GoogleCredentialResponse) => {\n try {\n props.handleAuthResponse(\n await medplum.startGoogleLogin({\n googleClientId: response.clientId,\n googleCredential: response.credential,\n createUser: true,\n })\n );\n } catch (err) {\n setOutcome(err as OperationOutcome);\n }\n }}\n />\n </div>\n <div className=\"medplum-signin-separator\">or</div>\n </>\n )}\n <FormSection title=\"First Name\" htmlFor=\"firstName\" outcome={outcome}>\n <Input\n name=\"firstName\"\n type=\"text\"\n testid=\"firstName\"\n placeholder=\"First name\"\n required={true}\n autoFocus={true}\n outcome={outcome}\n />\n </FormSection>\n <FormSection title=\"Last Name\" htmlFor=\"lastName\" outcome={outcome}>\n <Input\n name=\"lastName\"\n type=\"text\"\n testid=\"lastName\"\n placeholder=\"Last name\"\n required={true}\n outcome={outcome}\n />\n </FormSection>\n <FormSection title=\"Email\" htmlFor=\"email\" outcome={outcome}>\n <Input\n name=\"email\"\n type=\"email\"\n testid=\"email\"\n placeholder=\"name@domain.com\"\n required={true}\n outcome={outcome}\n />\n </FormSection>\n <FormSection title=\"Password\" htmlFor=\"password\" outcome={outcome}>\n <Input name=\"password\" type=\"password\" testid=\"password\" autoComplete=\"off\" required={true} outcome={outcome} />\n </FormSection>\n <p style={{ fontSize: '12px', color: '#888' }}>\n By clicking submit you agree to the Medplum <a href=\"https://www.medplum.com/privacy\">Privacy&nbsp;Policy</a>\n {' and '}\n <a href=\"https://www.medplum.com/terms\">Terms&nbsp;of&nbsp;Service</a>.\n </p>\n <p style={{ fontSize: '12px', color: '#888' }}>\n This site is protected by reCAPTCHA and the Google{' '}\n <a href=\"https://policies.google.com/privacy\">Privacy&nbsp;Policy</a>\n {' and '}\n <a href=\"https://policies.google.com/terms\">Terms&nbsp;of&nbsp;Service</a> apply.\n </p>\n <div className=\"medplum-signin-buttons\">\n <div>\n <input type=\"checkbox\" id=\"remember\" name=\"remember\" value=\"true\" />\n <label htmlFor=\"remember\">Remember me</label>\n </div>\n <div>\n <Button type=\"submit\" testid=\"submit\">\n Create account\n </Button>\n </div>\n </div>\n </Form>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAoBM,SAAU,WAAW,CAAC,KAAuB,EAAA;IACjD,MAAM,cA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,CAAA,KAAA,EAAA,IAAA;AACE,gBAAA,KAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAC,IAAI,EAAC,QAAQ,EAAC,MAAM,EAAC,QAAQ,EAE5B,EAAA,gBAAA,CAAA,CACL,CACF,CACD,EACP;AACJ;;;;"}
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import './SignInForm.css';
3
+ import '../util.css';
4
+ export interface RegisterFormProps {
5
+ readonly type: 'patient' | 'project';
6
+ readonly projectId?: string;
7
+ readonly googleClientId?: string;
8
+ readonly recaptchaSiteKey: string;
9
+ readonly children?: React.ReactNode;
10
+ readonly onSuccess: () => void;
11
+ }
12
+ export declare function RegisterForm(props: RegisterFormProps): JSX.Element;
@@ -0,0 +1,39 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { Document } from '../Document.js';
3
+ import { useMedplum } from '../MedplumProvider.js';
4
+ import { NewProjectForm } from './NewProjectForm.js';
5
+ import { NewUserForm } from './NewUserForm.js';
6
+
7
+ function RegisterForm(props) {
8
+ const { type, projectId, googleClientId, recaptchaSiteKey, onSuccess } = props;
9
+ const medplum = useMedplum();
10
+ const [login, setLogin] = useState(undefined);
11
+ const [outcome, setOutcome] = useState();
12
+ useEffect(() => {
13
+ if (type === 'patient' && login) {
14
+ medplum
15
+ .startNewPatient({ login, projectId: projectId })
16
+ .then((response) => medplum.processCode(response.code))
17
+ .then(() => onSuccess())
18
+ .catch((err) => setOutcome(err));
19
+ }
20
+ }, [medplum, type, projectId, login, onSuccess]);
21
+ function handleAuthResponse(response) {
22
+ if (response.code) {
23
+ medplum
24
+ .processCode(response.code)
25
+ .then(() => onSuccess())
26
+ .catch(console.log);
27
+ }
28
+ else if (response.login) {
29
+ setLogin(response.login);
30
+ }
31
+ }
32
+ return (React.createElement(Document, { width: 450 },
33
+ outcome && React.createElement("pre", null, JSON.stringify(outcome, null, 2)),
34
+ !login && (React.createElement(NewUserForm, { projectId: projectId, googleClientId: googleClientId, recaptchaSiteKey: recaptchaSiteKey, handleAuthResponse: handleAuthResponse }, props.children)),
35
+ login && type === 'project' && React.createElement(NewProjectForm, { login: login, handleAuthResponse: handleAuthResponse })));
36
+ }
37
+
38
+ export { RegisterForm };
39
+ //# sourceMappingURL=RegisterForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RegisterForm.js","sources":["../../../src/auth/RegisterForm.tsx"],"sourcesContent":["import { LoginAuthenticationResponse } from '@medplum/core';\nimport { OperationOutcome } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport { Document } from '../Document';\nimport { useMedplum } from '../MedplumProvider';\nimport { NewProjectForm } from './NewProjectForm';\nimport { NewUserForm } from './NewUserForm';\nimport './SignInForm.css';\nimport '../util.css';\n\nexport interface RegisterFormProps {\n readonly type: 'patient' | 'project';\n readonly projectId?: string;\n readonly googleClientId?: string;\n readonly recaptchaSiteKey: string;\n readonly children?: React.ReactNode;\n readonly onSuccess: () => void;\n}\n\nexport function RegisterForm(props: RegisterFormProps): JSX.Element {\n const { type, projectId, googleClientId, recaptchaSiteKey, onSuccess } = props;\n const medplum = useMedplum();\n const [login, setLogin] = useState<string | undefined>(undefined);\n const [outcome, setOutcome] = useState<OperationOutcome>();\n\n useEffect(() => {\n if (type === 'patient' && login) {\n medplum\n .startNewPatient({ login, projectId: projectId as string })\n .then((response) => medplum.processCode(response.code as string))\n .then(() => onSuccess())\n .catch((err) => setOutcome(err as OperationOutcome));\n }\n }, [medplum, type, projectId, login, onSuccess]);\n\n function handleAuthResponse(response: LoginAuthenticationResponse): void {\n if (response.code) {\n medplum\n .processCode(response.code)\n .then(() => onSuccess())\n .catch(console.log);\n } else if (response.login) {\n setLogin(response.login);\n }\n }\n\n return (\n <Document width={450}>\n {outcome && <pre>{JSON.stringify(outcome, null, 2)}</pre>}\n {!login && (\n <NewUserForm\n projectId={projectId as string}\n googleClientId={googleClientId}\n recaptchaSiteKey={recaptchaSiteKey}\n handleAuthResponse={handleAuthResponse}\n >\n {props.children}\n </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EAAE;AACzB,YAAA,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC1B,SAAA;KACF;AAED,IAAA,QACE,KAAC,CAAA,aAAA,CAAA,QAAQ,EAAC,EAAA,KAAK,EAAE,GAAG,EAAA;AACjB,QAAA,OAAO,IAAI,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,IAAA,EAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAO;QACxD,CAAC,KAAK,KACL,KAAC,CAAA,aAAA,CAAA,WAAW,EACV,EAAA,SAAS,EAAE,SAAmB,EAC9B,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,kBAAkB,EAAE,kBAAkB,EAAA,EAErC,KAAK,CAAC,QAAQ,CACH,CACf;AACA,QAAA,KAAK,IAAI,IAAI,KAAK,SAAS,IAAI,KAAA,CAAA,aAAA,CAAC,cAAc,EAAC,EAAA,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAI,CAAA,CAC/F,EACX;AACJ;;;;"}
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
+ import '../util.css';
2
3
  import './SignInForm.css';
3
- import './util.css';
4
4
  export interface SignInFormProps {
5
5
  readonly remember?: boolean;
6
6
  readonly projectId?: string;
@@ -0,0 +1,52 @@
1
+ import React, { useState } from 'react';
2
+ import { Document } from '../Document.js';
3
+ import { useMedplum } from '../MedplumProvider.js';
4
+ import { AuthenticationForm } from './AuthenticationForm.js';
5
+ import { ChooseProfileForm } from './ChooseProfileForm.js';
6
+ import { NewProjectForm } from './NewProjectForm.js';
7
+
8
+ function SignInForm(props) {
9
+ const medplum = useMedplum();
10
+ const [login, setLogin] = useState(undefined);
11
+ const [memberships, setMemberships] = useState(undefined);
12
+ function handleAuthResponse(response) {
13
+ if (response.login) {
14
+ setLogin(response.login);
15
+ }
16
+ if (response.memberships) {
17
+ setMemberships(response.memberships);
18
+ }
19
+ if (response.code) {
20
+ if (props.onCode) {
21
+ props.onCode(response.code);
22
+ }
23
+ else {
24
+ medplum
25
+ .processCode(response.code)
26
+ .then(() => {
27
+ if (props.onSuccess) {
28
+ props.onSuccess();
29
+ }
30
+ })
31
+ .catch(console.log);
32
+ }
33
+ }
34
+ }
35
+ return (React.createElement(Document, { width: 450 }, (() => {
36
+ if (!login) {
37
+ return (React.createElement(AuthenticationForm, { projectId: props.projectId, clientId: props.clientId, scope: props.scope, nonce: props.nonce, googleClientId: props.googleClientId, onForgotPassword: props.onForgotPassword, onRegister: props.onRegister, handleAuthResponse: handleAuthResponse }, props.children));
38
+ }
39
+ else if (memberships) {
40
+ return React.createElement(ChooseProfileForm, { login: login, memberships: memberships, handleAuthResponse: handleAuthResponse });
41
+ }
42
+ else if (props.projectId === 'new') {
43
+ return React.createElement(NewProjectForm, { login: login, handleAuthResponse: handleAuthResponse });
44
+ }
45
+ else {
46
+ return React.createElement("div", null, "Success");
47
+ }
48
+ })()));
49
+ }
50
+
51
+ export { SignInForm };
52
+ //# sourceMappingURL=SignInForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SignInForm.js","sources":["../../../src/auth/SignInForm.tsx"],"sourcesContent":["import { LoginAuthenticationResponse } from '@medplum/core';\nimport { ProjectMembership } from '@medplum/fhirtypes';\nimport React, { useState } from 'react';\nimport { Document } from '../Document';\nimport { useMedplum } from '../MedplumProvider';\nimport { AuthenticationForm } from './AuthenticationForm';\nimport { ChooseProfileForm } from './ChooseProfileForm';\nimport { NewProjectForm } from './NewProjectForm';\nimport '../util.css';\nimport './SignInForm.css';\n\nexport interface SignInFormProps {\n readonly remember?: boolean;\n readonly projectId?: string;\n readonly googleClientId?: string;\n readonly clientId?: string;\n readonly scope?: string;\n readonly nonce?: string;\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\nexport function SignInForm(props: SignInFormProps): JSX.Element {\n const medplum = useMedplum();\n const [login, setLogin] = useState<string | undefined>(undefined);\n const [memberships, setMemberships] = useState<ProjectMembership[] | undefined>(undefined);\n\n function handleAuthResponse(response: LoginAuthenticationResponse): void {\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 (props.onCode) {\n props.onCode(response.code);\n } else {\n medplum\n .processCode(response.code)\n .then(() => {\n if (props.onSuccess) {\n props.onSuccess();\n }\n })\n .catch(console.log);\n }\n }\n }\n\n return (\n <Document width={450}>\n {(() => {\n if (!login) {\n return (\n <AuthenticationForm\n projectId={props.projectId}\n clientId={props.clientId}\n scope={props.scope}\n nonce={props.nonce}\n googleClientId={props.googleClientId}\n onForgotPassword={props.onForgotPassword}\n onRegister={props.onRegister}\n handleAuthResponse={handleAuthResponse}\n >\n {props.children}\n </AuthenticationForm>\n );\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 {\n return <div>Success</div>;\n }\n })()}\n </Document>\n );\n}\n"],"names":[],"mappings":";;;;;;;AAyBM,SAAU,UAAU,CAAC,KAAsB,EAAA;AAC/C,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,cAAc,CAAC,GAAG,QAAQ,CAAkC,SAAS,CAAC,CAAC;IAE3F,SAAS,kBAAkB,CAAC,QAAqC,EAAA;QAC/D,IAAI,QAAQ,CAAC,KAAK,EAAE;AAClB,YAAA,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC1B,SAAA;QAED,IAAI,QAAQ,CAAC,WAAW,EAAE;AACxB,YAAA,cAAc,CAAC,QAAQ,CAAC,W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ACpC,OAAO,KAAA,CAAA,aAAA,CAAC,cAAc,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAA,CAAI,CAAC;AACjF,SAAA;AAAM,aAAA;AACL,YAAA,OAAO,2CAAkB,CAAC;AAC3B,SAAA;AACH,KAAC,GAAG,CACK,EACX;AACJ;;;;"}
@@ -3,6 +3,8 @@ export * from './AddressInput';
3
3
  export * from './AttachmentArrayDisplay';
4
4
  export * from './AttachmentArrayInput';
5
5
  export * from './AttachmentInput';
6
+ export * from './auth/RegisterForm';
7
+ export * from './auth/SignInForm';
6
8
  export * from './Autocomplete';
7
9
  export * from './Avatar';
8
10
  export * from './BackboneElementInput';
@@ -18,6 +20,7 @@ export * from './ContactPointDisplay';
18
20
  export * from './ContactPointInput';
19
21
  export * from './DateTimeInput';
20
22
  export * from './DefaultResourceTimeline';
23
+ export * from './DescriptionList';
21
24
  export * from './DiagnosticReportDisplay';
22
25
  export * from './Document';
23
26
  export * from './EncounterTimeline';
@@ -47,7 +50,6 @@ export * from './QuestionnaireUtils';
47
50
  export * from './RangeDisplay';
48
51
  export * from './RangeInput';
49
52
  export * from './ReferenceInput';
50
- export * from './RegisterForm';
51
53
  export * from './RequestGroupDisplay';
52
54
  export * from './ResourceArrayDisplay';
53
55
  export * from './ResourceArrayInput';
@@ -70,7 +72,6 @@ export * from './SearchFilterEditor';
70
72
  export * from './SearchUtils';
71
73
  export * from './Select';
72
74
  export * from './ServiceRequestTimeline';
73
- export * from './SignInForm';
74
75
  export * from './StatusBadge';
75
76
  export * from './Tab';
76
77
  export * from './TabList';
package/dist/esm/index.js CHANGED
@@ -3,6 +3,8 @@ export { AddressInput } from './AddressInput.js';
3
3
  export { AttachmentArrayDisplay } from './AttachmentArrayDisplay.js';
4
4
  export { AttachmentArrayInput } from './AttachmentArrayInput.js';
5
5
  export { AttachmentInput } from './AttachmentInput.js';
6
+ export { RegisterForm } from './auth/RegisterForm.js';
7
+ export { SignInForm } from './auth/SignInForm.js';
6
8
  export { Autocomplete } from './Autocomplete.js';
7
9
  export { Avatar } from './Avatar.js';
8
10
  export { BackboneElementInput } from './BackboneElementInput.js';
@@ -18,6 +20,7 @@ export { ContactPointDisplay } from './ContactPointDisplay.js';
18
20
  export { ContactPointInput } from './ContactPointInput.js';
19
21
  export { DateTimeInput, convertIsoToLocal, convertLocalToIso } from './DateTimeInput.js';
20
22
  export { DefaultResourceTimeline } from './DefaultResourceTimeline.js';
23
+ export { DescriptionList, DescriptionListEntry } from './DescriptionList.js';
21
24
  export { DiagnosticReportDisplay, ObservationTable } from './DiagnosticReportDisplay.js';
22
25
  export { Document } from './Document.js';
23
26
  export { EncounterTimeline } from './EncounterTimeline.js';
@@ -47,7 +50,6 @@ export { QuestionnaireItemType, addQuestionnaireInitialValues, isChoiceQuestion
47
50
  export { RangeDisplay, formatRangeString } from './RangeDisplay.js';
48
51
  export { RangeInput } from './RangeInput.js';
49
52
  export { ReferenceInput } from './ReferenceInput.js';
50
- export { RegisterForm } from './RegisterForm.js';
51
53
  export { RequestGroupDisplay } from './RequestGroupDisplay.js';
52
54
  export { ResourceArrayDisplay } from './ResourceArrayDisplay.js';
53
55
  export { ResourceArrayInput } from './ResourceArrayInput.js';
@@ -70,7 +72,6 @@ export { SearchFilterEditor } from './SearchFilterEditor.js';
70
72
  export { addDateEqualsFilter, addDateFilter, addDateFilterBetween, addField, addFilter, addLastMonthFilter, addMissingFilter, addNextMonthFilter, addThisMonthFilter, addTodayFilter, addTomorrowFilter, addYearToDateFilter, addYesterdayFilter, buildFieldNameString, clearFilters, clearFiltersOnField, deleteFilter, getOpString, getSearchOperators, getSortField, hasFilterOnField, isSortDescending, movePage, renderValue, setFilters, setOffset, setSort, toggleSort } from './SearchUtils.js';
71
73
  export { Select } from './Select.js';
72
74
  export { ServiceRequestTimeline } from './ServiceRequestTimeline.js';
73
- export { SignInForm } from './SignInForm.js';
74
75
  export { StatusBadge } from './StatusBadge.js';
75
76
  export { Tab } from './Tab.js';
76
77
  export { TabList } from './TabList.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}