@medplum/react 0.10.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/dist/cjs/AttachmentButton.d.ts +2 -0
  2. package/dist/cjs/CalendarInput.d.ts +0 -1
  3. package/dist/cjs/CheckboxFormSection.d.ts +0 -1
  4. package/dist/cjs/DescriptionList.d.ts +0 -1
  5. package/dist/cjs/DiagnosticReportDisplay.d.ts +0 -1
  6. package/dist/cjs/Document.d.ts +0 -1
  7. package/dist/cjs/FhirPathTable.d.ts +0 -1
  8. package/dist/cjs/FormSection.d.ts +0 -1
  9. package/dist/cjs/MedplumLink.d.ts +2 -4
  10. package/dist/cjs/QuestionnaireBuilder.d.ts +0 -1
  11. package/dist/cjs/QuestionnaireForm.d.ts +0 -1
  12. package/dist/cjs/RequestGroupDisplay.d.ts +0 -1
  13. package/dist/cjs/ResourceBadge.d.ts +0 -1
  14. package/dist/cjs/ResourceBlame.d.ts +0 -1
  15. package/dist/cjs/ResourceDiff.d.ts +0 -1
  16. package/dist/cjs/ResourceDiffTable.d.ts +0 -2
  17. package/dist/cjs/ResourceName.d.ts +2 -1
  18. package/dist/cjs/ResourceTimeline.d.ts +0 -1
  19. package/dist/cjs/Scheduler.d.ts +0 -1
  20. package/dist/cjs/SearchControl.d.ts +0 -1
  21. package/dist/cjs/SearchFilterEditor.d.ts +0 -1
  22. package/dist/cjs/Timeline.d.ts +0 -1
  23. package/dist/cjs/auth/AuthenticationForm.d.ts +1 -0
  24. package/dist/cjs/auth/RegisterForm.d.ts +0 -1
  25. package/dist/cjs/auth/SignInForm.d.ts +1 -1
  26. package/dist/cjs/index.js +1252 -907
  27. package/dist/cjs/index.js.map +1 -1
  28. package/dist/cjs/index.min.js +1 -1
  29. package/dist/cjs/index.min.js.map +1 -1
  30. package/dist/cjs/stories/DescriptionList.stories.d.ts +5 -0
  31. package/dist/cjs/stories/PlanDefinitionBuilder.stories.d.ts +2 -0
  32. package/dist/cjs/stories/RequestGroupDisplay.stories.d.ts +1 -0
  33. package/dist/cjs/stories/ResourceTable.stories.d.ts +4 -0
  34. package/dist/cjs/stories/covid19.d.ts +15 -0
  35. package/dist/esm/AttachmentArrayInput.js +2 -2
  36. package/dist/esm/AttachmentArrayInput.js.map +1 -1
  37. package/dist/esm/AttachmentButton.d.ts +2 -0
  38. package/dist/esm/AttachmentButton.js +4 -1
  39. package/dist/esm/AttachmentButton.js.map +1 -1
  40. package/dist/esm/BackboneElementInput.js +2 -1
  41. package/dist/esm/BackboneElementInput.js.map +1 -1
  42. package/dist/esm/CalendarInput.d.ts +0 -1
  43. package/dist/esm/CalendarInput.js +39 -2
  44. package/dist/esm/CalendarInput.js.map +1 -1
  45. package/dist/esm/CheckboxFormSection.d.ts +0 -1
  46. package/dist/esm/CheckboxFormSection.js +5 -5
  47. package/dist/esm/CheckboxFormSection.js.map +1 -1
  48. package/dist/esm/DescriptionList.d.ts +0 -1
  49. package/dist/esm/DescriptionList.js +23 -1
  50. package/dist/esm/DescriptionList.js.map +1 -1
  51. package/dist/esm/DiagnosticReportDisplay.d.ts +0 -1
  52. package/dist/esm/DiagnosticReportDisplay.js +40 -22
  53. package/dist/esm/DiagnosticReportDisplay.js.map +1 -1
  54. package/dist/esm/Document.d.ts +0 -1
  55. package/dist/esm/Document.js +7 -2
  56. package/dist/esm/Document.js.map +1 -1
  57. package/dist/esm/ErrorBoundary.js +2 -1
  58. package/dist/esm/ErrorBoundary.js.map +1 -1
  59. package/dist/esm/FhirPathTable.d.ts +0 -1
  60. package/dist/esm/FhirPathTable.js +5 -5
  61. package/dist/esm/FhirPathTable.js.map +1 -1
  62. package/dist/esm/FormSection.d.ts +0 -1
  63. package/dist/esm/FormSection.js +3 -11
  64. package/dist/esm/FormSection.js.map +1 -1
  65. package/dist/esm/MedplumLink.d.ts +2 -4
  66. package/dist/esm/MedplumLink.js +11 -8
  67. package/dist/esm/MedplumLink.js.map +1 -1
  68. package/dist/esm/PlanDefinitionBuilder.js +41 -10
  69. package/dist/esm/PlanDefinitionBuilder.js.map +1 -1
  70. package/dist/esm/QuestionnaireBuilder.d.ts +0 -1
  71. package/dist/esm/QuestionnaireBuilder.js +78 -31
  72. package/dist/esm/QuestionnaireBuilder.js.map +1 -1
  73. package/dist/esm/QuestionnaireForm.d.ts +0 -1
  74. package/dist/esm/QuestionnaireForm.js +26 -16
  75. package/dist/esm/QuestionnaireForm.js.map +1 -1
  76. package/dist/esm/RequestGroupDisplay.d.ts +0 -1
  77. package/dist/esm/RequestGroupDisplay.js +8 -7
  78. package/dist/esm/RequestGroupDisplay.js.map +1 -1
  79. package/dist/esm/ResourceBadge.d.ts +0 -1
  80. package/dist/esm/ResourceBadge.js +2 -1
  81. package/dist/esm/ResourceBadge.js.map +1 -1
  82. package/dist/esm/ResourceBlame.d.ts +0 -1
  83. package/dist/esm/ResourceBlame.js +59 -10
  84. package/dist/esm/ResourceBlame.js.map +1 -1
  85. package/dist/esm/ResourceDiff.d.ts +0 -1
  86. package/dist/esm/ResourceDiff.js +13 -2
  87. package/dist/esm/ResourceDiff.js.map +1 -1
  88. package/dist/esm/ResourceDiffTable.d.ts +0 -2
  89. package/dist/esm/ResourceDiffTable.js +25 -3
  90. package/dist/esm/ResourceDiffTable.js.map +1 -1
  91. package/dist/esm/ResourceForm.js +6 -5
  92. package/dist/esm/ResourceForm.js.map +1 -1
  93. package/dist/esm/ResourceInput.js +28 -2
  94. package/dist/esm/ResourceInput.js.map +1 -1
  95. package/dist/esm/ResourceName.d.ts +2 -1
  96. package/dist/esm/ResourceName.js +5 -2
  97. package/dist/esm/ResourceName.js.map +1 -1
  98. package/dist/esm/ResourcePropertyDisplay.js +6 -6
  99. package/dist/esm/ResourcePropertyDisplay.js.map +1 -1
  100. package/dist/esm/ResourceTimeline.d.ts +0 -1
  101. package/dist/esm/ResourceTimeline.js +78 -25
  102. package/dist/esm/ResourceTimeline.js.map +1 -1
  103. package/dist/esm/Scheduler.d.ts +0 -1
  104. package/dist/esm/Scheduler.js +20 -4
  105. package/dist/esm/Scheduler.js.map +1 -1
  106. package/dist/esm/SearchControl.d.ts +0 -1
  107. package/dist/esm/SearchControl.js +33 -18
  108. package/dist/esm/SearchControl.js.map +1 -1
  109. package/dist/esm/SearchFilterEditor.d.ts +0 -1
  110. package/dist/esm/SearchFilterEditor.js +2 -2
  111. package/dist/esm/SearchFilterEditor.js.map +1 -1
  112. package/dist/esm/Timeline.d.ts +0 -1
  113. package/dist/esm/Timeline.js +13 -16
  114. package/dist/esm/Timeline.js.map +1 -1
  115. package/dist/esm/auth/AuthenticationForm.d.ts +1 -0
  116. package/dist/esm/auth/AuthenticationForm.js +6 -3
  117. package/dist/esm/auth/AuthenticationForm.js.map +1 -1
  118. package/dist/esm/auth/ChooseProfileForm.js +3 -3
  119. package/dist/esm/auth/ChooseProfileForm.js.map +1 -1
  120. package/dist/esm/auth/NewProjectForm.js +3 -3
  121. package/dist/esm/auth/NewProjectForm.js.map +1 -1
  122. package/dist/esm/auth/NewUserForm.js +4 -3
  123. package/dist/esm/auth/NewUserForm.js.map +1 -1
  124. package/dist/esm/auth/RegisterForm.d.ts +0 -1
  125. package/dist/esm/auth/RegisterForm.js.map +1 -1
  126. package/dist/esm/auth/SignInForm.d.ts +1 -1
  127. package/dist/esm/auth/SignInForm.js +1 -1
  128. package/dist/esm/auth/SignInForm.js.map +1 -1
  129. package/dist/esm/index.min.js +1 -1
  130. package/dist/esm/index.min.js.map +1 -1
  131. package/dist/esm/stories/DescriptionList.stories.d.ts +5 -0
  132. package/dist/esm/stories/PlanDefinitionBuilder.stories.d.ts +2 -0
  133. package/dist/esm/stories/RequestGroupDisplay.stories.d.ts +1 -0
  134. package/dist/esm/stories/ResourceTable.stories.d.ts +4 -0
  135. package/dist/esm/stories/covid19.d.ts +15 -0
  136. package/package.json +35 -23
  137. package/rollup.config.mjs +111 -0
  138. package/dist/cjs/defaulttheme.css +0 -192
  139. package/dist/cjs/styles.css +0 -528
  140. package/dist/esm/defaulttheme.css +0 -192
  141. package/dist/esm/styles.css +0 -528
@@ -1 +1 @@
1
- {"version":3,"file":"NewUserForm.js","sources":["../../../src/auth/NewUserForm.tsx"],"sourcesContent":["import { Button, Checkbox, Divider, Group, PasswordInput, Stack, Text, TextInput } from '@mantine/core';\nimport { GoogleCredentialResponse, LoginAuthenticationResponse } from '@medplum/core';\nimport { OperationOutcome } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport { Form } from '../Form';\nimport { getGoogleClientId, GoogleButton } from '../GoogleButton';\nimport { useMedplum } from '../MedplumProvider';\nimport { getErrorsForInput, 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 <Group position=\"center\" p=\"xl\" style={{ height: 70 }}>\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 </Group>\n <Divider label=\"or\" labelPosition=\"center\" my=\"lg\" />\n </>\n )}\n <Stack spacing=\"xl\">\n <TextInput\n name=\"firstName\"\n type=\"text\"\n label=\"First name\"\n placeholder=\"First name\"\n required={true}\n autoFocus={true}\n error={getErrorsForInput(outcome, 'firstName')}\n />\n <TextInput\n name=\"lastName\"\n type=\"text\"\n label=\"Last name\"\n placeholder=\"Last name\"\n required={true}\n error={getErrorsForInput(outcome, 'lastName')}\n />\n <TextInput\n name=\"email\"\n type=\"email\"\n label=\"Email\"\n placeholder=\"name@domain.com\"\n required={true}\n error={getErrorsForInput(outcome, 'email')}\n />\n <PasswordInput\n name=\"password\"\n label=\"Password\"\n autoComplete=\"off\"\n required={true}\n error={getErrorsForInput(outcome, 'password')}\n />\n <Text color=\"dimmed\" size=\"xs\">\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 </Text>\n <Text color=\"dimmed\" size=\"xs\">\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 </Text>\n </Stack>\n <Group position=\"apart\" mt=\"xl\" noWrap>\n <Checkbox name=\"remember\" label=\"Remember me\" size=\"xs\" />\n <Button type=\"submit\">Create account</Button>\n </Group>\n </Form>\n );\n}\n"],"names":[],"mapp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,KAAK,EAAC,QAAQ,EAAC,IAAI,EAAC,IAAI,EAAA;;gBACgB,KAAG,CAAA,aAAA,CAAA,GAAA,EAAA,EAAA,IAAI,EAAC,iCAAiC,EAAwB,EAAA,qBAAA,CAAA;gBAC5G,OAAO;gBACR,KAAG,CAAA,aAAA,CAAA,GAAA,EAAA,EAAA,IAAI,EAAC,+BAA+B,EAA+B,EAAA,4BAAA,CAAA;AACjE,gBAAA,GAAA,CAAA;YACP,KAAC,CAAA,aAAA,CAAA,IAAI,IAAC,KAAK,EAAC,QAAQ,EAAC,IAAI,EAAC,IAAI,EAAA;;gBACuB,GAAG;gBACtD,KAAG,CAAA,aAAA,CAAA,GAAA,EAAA,EAAA,IAAI,EAAC,qCAAqC,EAAwB,EAAA,qBAAA,CAAA;gBACpE,OAAO;gBACR,KAAG,CAAA,aAAA,CAAA,GAAA,EAAA,EAAA,IAAI,EAAC,mCAAmC,EAA+B,EAAA,4BAAA,CAAA;0BACrE,CACD;QACR,KAAC,CAAA,aAAA,CAAA,KAAK,EAAC,EAAA,QAAQ,EAAC,OAAO,EAAC,EAAE,EAAC,IAAI,EAAC,MAAM,EAAA,IAAA,EAAA;AACpC,YAAA,KAAA,CAAA,aAAA,CAAC,QAAQ,EAAA,EAAC,IAAI,EAAC,UAAU,EAAC,KAAK,EAAC,aAAa,EAAC,IAAI,EAAC,IAAI,EAAG,CAAA;YAC1D,KAAC,CAAA,aAAA,CAAA,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAwB,EAAA,gBAAA,CAAA,CACvC,CACH,EACP;AACJ;;;;"}
1
+ {"version":3,"file":"NewUserForm.js","sources":["../../../src/auth/NewUserForm.tsx"],"sourcesContent":["import { Alert, Button, Center, Checkbox, Divider, Group, PasswordInput, Stack, Text, TextInput } from '@mantine/core';\nimport { GoogleCredentialResponse, LoginAuthenticationResponse } from '@medplum/core';\nimport { OperationOutcome } from '@medplum/fhirtypes';\nimport { IconAlertCircle } from '@tabler/icons';\nimport React, { useEffect, useState } from 'react';\nimport { Form } from '../Form';\nimport { getGoogleClientId, GoogleButton } from '../GoogleButton';\nimport { useMedplum } from '../MedplumProvider';\nimport { getErrorsForInput, 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 <Center sx={{ flexDirection: 'column' }}>{props.children}</Center>\n {issues && (\n <Alert icon={<IconAlertCircle size={16} />} color=\"red\">\n {issues.map((issue) => (\n <div data-testid=\"text-field-error\" key={issue.details?.text}>\n {issue.details?.text}\n </div>\n ))}\n </Alert>\n )}\n {googleClientId && (\n <>\n <Group position=\"center\" p=\"xl\" style={{ height: 70 }}>\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 </Group>\n <Divider label=\"or\" labelPosition=\"center\" my=\"lg\" />\n </>\n )}\n <Stack spacing=\"xl\">\n <TextInput\n name=\"firstName\"\n type=\"text\"\n label=\"First name\"\n placeholder=\"First name\"\n required={true}\n autoFocus={true}\n error={getErrorsForInput(outcome, 'firstName')}\n />\n <TextInput\n name=\"lastName\"\n type=\"text\"\n label=\"Last name\"\n placeholder=\"Last name\"\n required={true}\n error={getErrorsForInput(outcome, 'lastName')}\n />\n <TextInput\n name=\"email\"\n type=\"email\"\n label=\"Email\"\n placeholder=\"name@domain.com\"\n required={true}\n error={getErrorsForInput(outcome, 'email')}\n />\n <PasswordInput\n name=\"password\"\n label=\"Password\"\n autoComplete=\"off\"\n required={true}\n error={getErrorsForInput(outcome, 'password')}\n />\n <Text color=\"dimmed\" size=\"xs\">\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 </Text>\n <Text color=\"dimmed\" size=\"xs\">\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 </Text>\n </Stack>\n <Group position=\"apart\" mt=\"xl\" noWrap>\n <Checkbox name=\"remember\" label=\"Remember me\" size=\"xs\" />\n <Button type=\"submit\">Create account</Button>\n </Group>\n </Form>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AAmBM,SAAU,WAAW,CAAC,KAAuB,EAAA;IACjD,MAAM,cAAc,GAAG,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAC/D,IAAA,MAAM,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;AAChD,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,CAAC,O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AA;gBAC5G,OAAO;gBACR,KAAG,CAAA,aAAA,CAAA,GAAA,EAAA,EAAA,IAAI,EAAC,+BAA+B,EAA+B,EAAA,4BAAA,CAAA;AACjE,gBAAA,GAAA,CAAA;YACP,KAAC,CAAA,aAAA,CAAA,IAAI,IAAC,KAAK,EAAC,QAAQ,EAAC,IAAI,EAAC,IAAI,EAAA;;gBACuB,GAAG;gBACtD,KAAG,CAAA,aAAA,CAAA,GAAA,EAAA,EAAA,IAAI,EAAC,qCAAqC,EAAwB,EAAA,qBAAA,CAAA;gBACpE,OAAO;gBACR,KAAG,CAAA,aAAA,CAAA,GAAA,EAAA,EAAA,IAAI,EAAC,mCAAmC,EAA+B,EAAA,4BAAA,CAAA;0BACrE,CACD;QACR,KAAC,CAAA,aAAA,CAAA,KAAK,EAAC,EAAA,QAAQ,EAAC,OAAO,EAAC,EAAE,EAAC,IAAI,EAAC,MAAM,EAAA,IAAA,EAAA;AACpC,YAAA,KAAA,CAAA,aAAA,CAAC,QAAQ,EAAA,EAAC,IAAI,EAAC,UAAU,EAAC,KAAK,EAAC,aAAa,EAAC,IAAI,EAAC,IAAI,EAAG,CAAA;YAC1D,KAAC,CAAA,aAAA,CAAA,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAwB,EAAA,gBAAA,CAAA,CACvC,CACH,EACP;AACJ;;;;"}
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import '../util.css';
3
2
  export interface RegisterFormProps {
4
3
  readonly type: 'patient' | 'project';
5
4
  readonly projectId?: string;
@@ -1 +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';\n\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 </NewUserForm>\n )}\n {login && type === 'project' && <NewProjectForm login={login} handleAuthResponse={handleAuthResponse} />}\n </Document>\n );\n}\n"],"names":[],"mappings":";;;;;;AAmBM,SAAU,YAAY,CAAC,KAAwB,EAAA;AACnD,IAAA,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;AAC/E,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAqB,SAAS,CAAC,CAAC;IAClE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAAoB,CAAC;IAE3D,SAAS,CAA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kB,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
+ {"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';\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 </NewUserForm>\n )}\n {login && type === 'project' && <NewProjectForm login={login} handleAuthResponse={handleAuthResponse} />}\n </Document>\n );\n}\n"],"names":[],"mappings":";;;;;;AAiBM,SAAU,YAAY,CAAC,KAAwB,EAAA;AACnD,IAAA,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;AAC/E,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAqB,SAAS,CAAC,CAAC;IAClE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAAoB,CAAC;IAE3D,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,IAAI,KAAK,SAAS,IAAI,KAAK,EAAE;YAC/B,OAAO;iBACJ,eAAe,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,SAAmB,EAAE,CAAC;AAC1D,iBAAA,IAAI,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAc,CAAC,CAAC;AAChE,iBAAA,IAAI,CAAC,MAAM,SAAS,EAAE,CAAC;iBACvB,KAAK,CAAC,CAAC,GAAG,KAAK,UAAU,CAAC,GAAuB,CAAC,CAAC,CAAC;AACxD,SAAA;AACH,KAAC,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;IAEjD,SAAS,kBAAkB,CAAC,QAAqC,EAAA;QAC/D,IAAI,QAAQ,CAAC,IAAI,EAAE;YACjB,OAAO;AACJ,iBAAA,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC;AAC1B,iBAAA,IAAI,CAAC,MAAM,SAAS,EAAE,CAAC;AACvB,iBAAA,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AACvB,SAAA;aAAM,IAAI,QAAQ,CAAC,KAAK,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,5 +1,4 @@
1
1
  import React from 'react';
2
- import '../util.css';
3
2
  export interface SignInFormProps {
4
3
  readonly remember?: boolean;
5
4
  readonly projectId?: string;
@@ -9,6 +8,7 @@ export interface SignInFormProps {
9
8
  readonly nonce?: string;
10
9
  readonly codeChallenge?: string;
11
10
  readonly codeChallengeMethod?: string;
11
+ readonly resourceType?: string;
12
12
  readonly onSuccess?: () => void;
13
13
  readonly onForgotPassword?: () => void;
14
14
  readonly onRegister?: () => void;
@@ -34,7 +34,7 @@ function SignInForm(props) {
34
34
  }
35
35
  return (React.createElement(Document, { width: 450 }, (() => {
36
36
  if (!login) {
37
- return (React.createElement(AuthenticationForm, { projectId: props.projectId, clientId: props.clientId, scope: props.scope, nonce: props.nonce, googleClientId: props.googleClientId, generatePkce: !props.onCode, codeChallenge: props.codeChallenge, codeChallengeMethod: props.codeChallengeMethod, onForgotPassword: props.onForgotPassword, onRegister: props.onRegister, handleAuthResponse: handleAuthResponse }, props.children));
37
+ return (React.createElement(AuthenticationForm, { projectId: props.projectId, clientId: props.clientId, resourceType: props.resourceType, scope: props.scope, nonce: props.nonce, googleClientId: props.googleClientId, generatePkce: !props.onCode, codeChallenge: props.codeChallenge, codeChallengeMethod: props.codeChallengeMethod, onForgotPassword: props.onForgotPassword, onRegister: props.onRegister, handleAuthResponse: handleAuthResponse }, props.children));
38
38
  }
39
39
  else if (memberships) {
40
40
  return React.createElement(ChooseProfileForm, { login: login, memberships: memberships, handleAuthResponse: handleAuthResponse });
@@ -1 +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';\n\nimport '../util.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 codeChallenge?: string;\n readonly codeChallengeMethod?: 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 generatePkce={!props.onCode}\n codeChallenge={props.codeChallenge}\n codeChallengeMethod={props.codeChallengeMethod}\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":";;;;;;;AA2BM,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,WAAW,CAAC,CAAC;AACtC,SAAA;QAED,IAAI,QAAQ,CAAC,IAAI,EAAE;YACjB,IAAI,KAAK,CAAC,MAAM,EAAE;AAChB,gBAAA,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC7B,aAAA;AAA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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;;;;"}
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';\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 codeChallenge?: string;\n readonly codeChallengeMethod?: string;\n readonly resourceType?: 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 resourceType={props.resourceType}\n scope={props.scope}\n nonce={props.nonce}\n googleClientId={props.googleClientId}\n generatePkce={!props.onCode}\n codeChallenge={props.codeChallenge}\n codeChallengeMethod={props.codeChallengeMethod}\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":";;;;;;;AA0BM,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,WAAW,CAAC,CAAC;AACtC,SAAA;QAED,IAAI,QAAQ,CAAC,IAAI,EAAE;YACjB,IAAI,KAAK,CAAC,MAAM,EAAE;AAChB,gBAAA,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC7B,aAAA;AAAM,iBAAA;gBACL,OAAO;AACJ,qBAAA,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC;qBAC1B,IAAI,CAAC,MAAK;oBACT,IAAI,KAAK,CAAC,SAAS,EAAE;wBACnB,KAAK,CAAC,SAAS,EAAE,CAAC;AACnB,qBAAA;AACH,iBAAC,CAAC;AACD,qBAAA,KAAK,CA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