@medplum/react 0.9.22 → 0.9.25
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/index.js +205 -75
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/cjs/styles.css +70 -55
- package/dist/esm/index.js +203 -77
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/styles.css +70 -55
- package/dist/types/RegisterForm.d.ts +18 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/stories/RegisterForm.stories.d.ts +7 -0
- package/dist/types/utils/recaptcha.d.ts +12 -0
- package/package.json +9 -9
package/dist/cjs/styles.css
CHANGED
|
@@ -1370,6 +1370,76 @@ div.medplum-nav-menu-container {
|
|
|
1370
1370
|
color: var(--medplum-blue-500);
|
|
1371
1371
|
}
|
|
1372
1372
|
|
|
1373
|
+
.medplum-signin-buttons {
|
|
1374
|
+
display: flex;
|
|
1375
|
+
justify-content: space-between;
|
|
1376
|
+
line-height: 32px;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
.medplum-signin-buttons > div {
|
|
1380
|
+
display: flex;
|
|
1381
|
+
align-items: center;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
.medplum-signin-buttons a {
|
|
1385
|
+
font-size: 12px;
|
|
1386
|
+
margin-right: 16px;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
.medplum-signin-buttons label {
|
|
1390
|
+
font-size: 12px;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
.medplum-signin-google-container {
|
|
1394
|
+
padding: 20px 0 10px 0;
|
|
1395
|
+
margin: 20px 0 10px 0;
|
|
1396
|
+
text-align: center;
|
|
1397
|
+
display: flex;
|
|
1398
|
+
align-items: center;
|
|
1399
|
+
justify-content: center;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
.medplum-signin-separator {
|
|
1403
|
+
padding: 12px 0;
|
|
1404
|
+
margin: 12px 0;
|
|
1405
|
+
overflow: hidden;
|
|
1406
|
+
text-align: center;
|
|
1407
|
+
font-size: var(--medplum-font-small);
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
.medplum-signin-separator::before,
|
|
1411
|
+
.medplum-signin-separator::after {
|
|
1412
|
+
background-color: var(--medplum-gray-400);
|
|
1413
|
+
content: '';
|
|
1414
|
+
display: inline-block;
|
|
1415
|
+
height: 0.1px;
|
|
1416
|
+
position: relative;
|
|
1417
|
+
vertical-align: middle;
|
|
1418
|
+
width: 50%;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
.medplum-signin-separator::before {
|
|
1422
|
+
right: 0.5em;
|
|
1423
|
+
margin-left: -50%;
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
.medplum-signin-separator::after {
|
|
1427
|
+
left: 0.5em;
|
|
1428
|
+
margin-right: -50%;
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
.medplum-left {
|
|
1432
|
+
text-align: left;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
.medplum-center {
|
|
1436
|
+
text-align: center;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
.medplum-right {
|
|
1440
|
+
text-align: right;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1373
1443
|
.medplum-status {
|
|
1374
1444
|
padding: 1px 6px;
|
|
1375
1445
|
font-size: 80%;
|
|
@@ -1569,61 +1639,6 @@ div.medplum-nav-menu-container {
|
|
|
1569
1639
|
|
|
1570
1640
|
.grecaptcha-badge { visibility: hidden; }
|
|
1571
1641
|
|
|
1572
|
-
.medplum-signin {
|
|
1573
|
-
max-width: 400px;
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
.medplum-signin-buttons {
|
|
1577
|
-
display: flex;
|
|
1578
|
-
justify-content: space-between;
|
|
1579
|
-
line-height: 32px;
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
|
-
.medplum-signin-buttons > div {
|
|
1583
|
-
display: flex;
|
|
1584
|
-
align-items: center;
|
|
1585
|
-
}
|
|
1586
|
-
|
|
1587
|
-
.medplum-signin-buttons a {
|
|
1588
|
-
font-size: 12px;
|
|
1589
|
-
margin-right: 16px;
|
|
1590
|
-
}
|
|
1591
|
-
|
|
1592
|
-
.medplum-signin-buttons label {
|
|
1593
|
-
font-size: 12px;
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
.medplum-signin-google-container {
|
|
1597
|
-
padding: 20px 0 10px 0;
|
|
1598
|
-
margin: 20px 0 10px 0;
|
|
1599
|
-
text-align: center;
|
|
1600
|
-
display: flex;
|
|
1601
|
-
align-items: center;
|
|
1602
|
-
justify-content: center;
|
|
1603
|
-
border-top: 0.1px solid var(--medplum-gray-200);
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
.medplum-signin-google-icon {
|
|
1607
|
-
margin-right: 8px;
|
|
1608
|
-
}
|
|
1609
|
-
|
|
1610
|
-
.medplum-signin-google-icon svg {
|
|
1611
|
-
display: inline-block;
|
|
1612
|
-
vertical-align: top;
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
.medplum-left {
|
|
1616
|
-
text-align: left;
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
.medplum-center {
|
|
1620
|
-
text-align: center;
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
.medplum-right {
|
|
1624
|
-
text-align: right;
|
|
1625
|
-
}
|
|
1626
|
-
|
|
1627
1642
|
a.medplum-tab {
|
|
1628
1643
|
display: inline-block;
|
|
1629
1644
|
line-height: 50px;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatAddress, getDisplayString, getImageSrc, capitalize, globalSchema, getPropertyDisplayName, formatHumanName, stringify, buildTypeName, PropertyType, getTypedPropertyValue, createReference, toTypedValue, getReferenceString, evalFhirPath, getSearchParameterDetails, Operator, evalFhirPathTyped, SearchParameterType, formatSearchQuery, parseSearchDefinition, DEFAULT_SEARCH_COUNT, isUUID } from '@medplum/core';
|
|
1
|
+
import { formatAddress, getDisplayString, getImageSrc, capitalize, globalSchema, getPropertyDisplayName, formatHumanName, stringify, buildTypeName, PropertyType, getTypedPropertyValue, createReference, toTypedValue, getReferenceString, evalFhirPath, getSearchParameterDetails, Operator, evalFhirPathTyped, SearchParameterType, formatSearchQuery, parseSearchDefinition, DEFAULT_SEARCH_COUNT, isUUID, parseJWTPayload } from '@medplum/core';
|
|
2
2
|
import React, { useState, useRef, createContext, useEffect, useContext, useCallback, useMemo } from 'react';
|
|
3
3
|
import { useNavigate, useLocation } from 'react-router-dom';
|
|
4
4
|
|
|
@@ -1770,18 +1770,24 @@ function ResourceBadge(props) {
|
|
|
1770
1770
|
}
|
|
1771
1771
|
|
|
1772
1772
|
function DiagnosticReportDisplay(props) {
|
|
1773
|
-
var _a;
|
|
1773
|
+
var _a, _b;
|
|
1774
1774
|
const diagnosticReport = useResource(props.value);
|
|
1775
|
+
const specimen = useResource((_a = diagnosticReport === null || diagnosticReport === void 0 ? void 0 : diagnosticReport.specimen) === null || _a === void 0 ? void 0 : _a[0]);
|
|
1775
1776
|
if (!diagnosticReport) {
|
|
1776
1777
|
return null;
|
|
1777
1778
|
}
|
|
1778
|
-
let textContent =
|
|
1779
|
+
let textContent = '';
|
|
1779
1780
|
if (diagnosticReport.presentedForm && diagnosticReport.presentedForm.length > 0) {
|
|
1780
1781
|
const pf = diagnosticReport.presentedForm[0];
|
|
1781
|
-
if (((
|
|
1782
|
+
if (((_b = pf.contentType) === null || _b === void 0 ? void 0 : _b.startsWith('text/plain')) && pf.data) {
|
|
1782
1783
|
textContent = window.atob(pf.data);
|
|
1783
1784
|
}
|
|
1784
1785
|
}
|
|
1786
|
+
if (specimen === null || specimen === void 0 ? void 0 : specimen.note) {
|
|
1787
|
+
for (const note of specimen.note) {
|
|
1788
|
+
textContent += note.text + '\n\n';
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1785
1791
|
return (React.createElement("div", { className: "medplum-diagnostic-report" },
|
|
1786
1792
|
React.createElement("h1", null, "Diagnostic Report"),
|
|
1787
1793
|
React.createElement("div", { className: "medplum-diagnostic-report-header" },
|
|
@@ -1801,8 +1807,8 @@ function DiagnosticReportDisplay(props) {
|
|
|
1801
1807
|
diagnosticReport.status && (React.createElement("dl", null,
|
|
1802
1808
|
React.createElement("dt", null, "Status"),
|
|
1803
1809
|
React.createElement("dd", null, capitalize(diagnosticReport.status))))),
|
|
1804
|
-
|
|
1805
|
-
|
|
1810
|
+
diagnosticReport.result && React.createElement(ObservationTable, { value: diagnosticReport.result }),
|
|
1811
|
+
textContent && React.createElement("pre", null, textContent.trim())));
|
|
1806
1812
|
}
|
|
1807
1813
|
function ObservationTable(props) {
|
|
1808
1814
|
var _a;
|
|
@@ -4898,6 +4904,179 @@ function ensureQuestionnaireOptionKeys(options) {
|
|
|
4898
4904
|
return options.map((option) => (Object.assign(Object.assign({}, option), { id: option.id || generateId() })));
|
|
4899
4905
|
}
|
|
4900
4906
|
|
|
4907
|
+
/**
|
|
4908
|
+
* Dynamically creates a script tag for the specified JavaScript file.
|
|
4909
|
+
* @param src The JavaScript file URL.
|
|
4910
|
+
*/
|
|
4911
|
+
function createScriptTag(src, onload) {
|
|
4912
|
+
const head = document.getElementsByTagName('head')[0];
|
|
4913
|
+
const script = document.createElement('script');
|
|
4914
|
+
script.async = true;
|
|
4915
|
+
script.src = src;
|
|
4916
|
+
script.onload = onload || null;
|
|
4917
|
+
head.appendChild(script);
|
|
4918
|
+
}
|
|
4919
|
+
|
|
4920
|
+
function GoogleButton(props) {
|
|
4921
|
+
const medplum = useMedplum();
|
|
4922
|
+
const { googleClientId, handleGoogleCredential } = props;
|
|
4923
|
+
const parentRef = useRef(null);
|
|
4924
|
+
const [scriptLoaded, setScriptLoaded] = useState(typeof google !== 'undefined');
|
|
4925
|
+
const [initialized, setInitialized] = useState(false);
|
|
4926
|
+
const [buttonRendered, setButtonRendered] = useState(false);
|
|
4927
|
+
useEffect(() => {
|
|
4928
|
+
if (typeof google === 'undefined') {
|
|
4929
|
+
createScriptTag('https://accounts.google.com/gsi/client', () => setScriptLoaded(true));
|
|
4930
|
+
return;
|
|
4931
|
+
}
|
|
4932
|
+
if (!initialized) {
|
|
4933
|
+
google.accounts.id.initialize({
|
|
4934
|
+
client_id: googleClientId,
|
|
4935
|
+
callback: handleGoogleCredential,
|
|
4936
|
+
});
|
|
4937
|
+
setInitialized(true);
|
|
4938
|
+
}
|
|
4939
|
+
if (parentRef.current && !buttonRendered) {
|
|
4940
|
+
google.accounts.id.renderButton(parentRef.current, {});
|
|
4941
|
+
setButtonRendered(true);
|
|
4942
|
+
}
|
|
4943
|
+
}, [medplum, googleClientId, initialized, scriptLoaded, parentRef, buttonRendered, handleGoogleCredential]);
|
|
4944
|
+
if (!googleClientId) {
|
|
4945
|
+
return null;
|
|
4946
|
+
}
|
|
4947
|
+
return React.createElement("div", { ref: parentRef });
|
|
4948
|
+
}
|
|
4949
|
+
function getGoogleClientId(clientId) {
|
|
4950
|
+
var _a, _b;
|
|
4951
|
+
if (clientId) {
|
|
4952
|
+
return clientId;
|
|
4953
|
+
}
|
|
4954
|
+
const origin = window.location.protocol + '//' + window.location.host;
|
|
4955
|
+
const authorizedOrigins = (_b = (_a = "http://localhost:3000,http://localhost:6006,https://app.medplum.com,https://docs.medplum.com") === null || _a === void 0 ? void 0 : _a.split(',')) !== null && _b !== void 0 ? _b : [];
|
|
4956
|
+
if (authorizedOrigins.includes(origin)) {
|
|
4957
|
+
return "921088377005-3j1sa10vr6hj86jgmdfh2l53v3mp7lfi.apps.googleusercontent.com";
|
|
4958
|
+
}
|
|
4959
|
+
return undefined;
|
|
4960
|
+
}
|
|
4961
|
+
|
|
4962
|
+
/**
|
|
4963
|
+
* Dynamically loads the recaptcha script.
|
|
4964
|
+
* We do not want to load the script on page load unless the user needs it.
|
|
4965
|
+
* @param siteKey The reCAPTCHA site key, available from the reCAPTCHA admin page.
|
|
4966
|
+
*/
|
|
4967
|
+
function initRecaptcha(siteKey) {
|
|
4968
|
+
if (typeof grecaptcha === 'undefined') {
|
|
4969
|
+
createScriptTag('https://www.google.com/recaptcha/api.js?render=' + siteKey);
|
|
4970
|
+
}
|
|
4971
|
+
}
|
|
4972
|
+
/**
|
|
4973
|
+
* Starts a request to generate a recapcha token.
|
|
4974
|
+
* @param siteKey The reCAPTCHA site key, available from the reCAPTCHA admin page.
|
|
4975
|
+
* @returns Promise to a recaptcha token for the current user.
|
|
4976
|
+
*/
|
|
4977
|
+
function getRecaptcha(siteKey) {
|
|
4978
|
+
return new Promise((resolve) => {
|
|
4979
|
+
grecaptcha.ready(() => {
|
|
4980
|
+
grecaptcha.execute(siteKey, { action: 'submit' }).then(resolve);
|
|
4981
|
+
});
|
|
4982
|
+
});
|
|
4983
|
+
}
|
|
4984
|
+
|
|
4985
|
+
function RegisterForm(props) {
|
|
4986
|
+
const medplum = useMedplum();
|
|
4987
|
+
const googleClientId = getGoogleClientId(props.googleClientId);
|
|
4988
|
+
const recaptchaSiteKey = props.recaptchaSiteKey;
|
|
4989
|
+
const [outcome, setOutcome] = useState();
|
|
4990
|
+
const issues = getIssuesForExpression(outcome, undefined);
|
|
4991
|
+
useEffect(() => initRecaptcha(recaptchaSiteKey), [recaptchaSiteKey]);
|
|
4992
|
+
function handleAuthResponse(registerRequest, partialLogin) {
|
|
4993
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4994
|
+
try {
|
|
4995
|
+
let login;
|
|
4996
|
+
if (props.type === 'patient') {
|
|
4997
|
+
login = yield medplum.startNewPatient(registerRequest, partialLogin);
|
|
4998
|
+
}
|
|
4999
|
+
else {
|
|
5000
|
+
login = yield medplum.startNewProject(registerRequest, partialLogin);
|
|
5001
|
+
}
|
|
5002
|
+
yield medplum.processCode(login.code);
|
|
5003
|
+
props.onSuccess();
|
|
5004
|
+
}
|
|
5005
|
+
catch (err) {
|
|
5006
|
+
setOutcome(err);
|
|
5007
|
+
}
|
|
5008
|
+
});
|
|
5009
|
+
}
|
|
5010
|
+
return (React.createElement(Document, { width: 450 },
|
|
5011
|
+
React.createElement(Form, { style: { maxWidth: 400 }, onSubmit: (formData) => __awaiter(this, void 0, void 0, function* () {
|
|
5012
|
+
try {
|
|
5013
|
+
const recaptchaToken = yield getRecaptcha(recaptchaSiteKey);
|
|
5014
|
+
const registerRequest = Object.assign(Object.assign({}, formData), { recaptchaToken });
|
|
5015
|
+
const userLogin = yield medplum.startNewUser(registerRequest);
|
|
5016
|
+
handleAuthResponse(registerRequest, userLogin);
|
|
5017
|
+
}
|
|
5018
|
+
catch (err) {
|
|
5019
|
+
setOutcome(err);
|
|
5020
|
+
}
|
|
5021
|
+
}) },
|
|
5022
|
+
React.createElement("div", { className: "medplum-center" }, props.children),
|
|
5023
|
+
issues && (React.createElement("div", { className: "medplum-input-error" }, issues.map((issue) => {
|
|
5024
|
+
var _a, _b;
|
|
5025
|
+
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));
|
|
5026
|
+
}))),
|
|
5027
|
+
googleClientId && (React.createElement(React.Fragment, null,
|
|
5028
|
+
React.createElement("div", { className: "medplum-signin-google-container" },
|
|
5029
|
+
React.createElement(GoogleButton, { googleClientId: googleClientId, handleGoogleCredential: (response) => __awaiter(this, void 0, void 0, function* () {
|
|
5030
|
+
try {
|
|
5031
|
+
const loginRequest = {
|
|
5032
|
+
googleClientId: response.clientId,
|
|
5033
|
+
googleCredential: response.credential,
|
|
5034
|
+
};
|
|
5035
|
+
const userLogin = yield medplum.startGoogleLogin(loginRequest);
|
|
5036
|
+
const googleClaims = parseJWTPayload(loginRequest.googleCredential);
|
|
5037
|
+
const registerRequest = {
|
|
5038
|
+
firstName: googleClaims.given_name,
|
|
5039
|
+
lastName: googleClaims.family_name,
|
|
5040
|
+
email: googleClaims.email,
|
|
5041
|
+
};
|
|
5042
|
+
handleAuthResponse(registerRequest, userLogin);
|
|
5043
|
+
}
|
|
5044
|
+
catch (err) {
|
|
5045
|
+
setOutcome(err);
|
|
5046
|
+
}
|
|
5047
|
+
}) })),
|
|
5048
|
+
React.createElement("div", { className: "medplum-signin-separator" }, "or"))),
|
|
5049
|
+
React.createElement(FormSection, { title: "First Name", htmlFor: "firstName", outcome: outcome },
|
|
5050
|
+
React.createElement(Input, { name: "firstName", type: "text", testid: "firstName", placeholder: "First name", required: true, autoFocus: true, outcome: outcome })),
|
|
5051
|
+
React.createElement(FormSection, { title: "Last Name", htmlFor: "lastName", outcome: outcome },
|
|
5052
|
+
React.createElement(Input, { name: "lastName", type: "text", testid: "lastName", placeholder: "Last name", required: true, outcome: outcome })),
|
|
5053
|
+
props.type === 'project' && (React.createElement(FormSection, { title: "Project Name", htmlFor: "projectName", outcome: outcome },
|
|
5054
|
+
React.createElement(Input, { name: "projectName", type: "text", testid: "projectName", placeholder: "My Project", required: true, outcome: outcome }))),
|
|
5055
|
+
React.createElement(FormSection, { title: "Email", htmlFor: "email", outcome: outcome },
|
|
5056
|
+
React.createElement(Input, { name: "email", type: "email", testid: "email", placeholder: "name@domain.com", required: true, outcome: outcome })),
|
|
5057
|
+
React.createElement(FormSection, { title: "Password", htmlFor: "password", outcome: outcome },
|
|
5058
|
+
React.createElement(Input, { name: "password", type: "password", testid: "password", autoComplete: "off", required: true, outcome: outcome })),
|
|
5059
|
+
React.createElement("p", { style: { fontSize: '12px', color: '#888' } },
|
|
5060
|
+
"By clicking submit you agree to the Medplum ",
|
|
5061
|
+
React.createElement("a", { href: "https://www.medplum.com/privacy" }, "Privacy\u00A0Policy"),
|
|
5062
|
+
' and ',
|
|
5063
|
+
React.createElement("a", { href: "https://www.medplum.com/terms" }, "Terms\u00A0of\u00A0Service"),
|
|
5064
|
+
"."),
|
|
5065
|
+
React.createElement("p", { style: { fontSize: '12px', color: '#888' } },
|
|
5066
|
+
"This site is protected by reCAPTCHA and the Google",
|
|
5067
|
+
' ',
|
|
5068
|
+
React.createElement("a", { href: "https://policies.google.com/privacy" }, "Privacy\u00A0Policy"),
|
|
5069
|
+
' and ',
|
|
5070
|
+
React.createElement("a", { href: "https://policies.google.com/terms" }, "Terms\u00A0of\u00A0Service"),
|
|
5071
|
+
" apply."),
|
|
5072
|
+
React.createElement("div", { className: "medplum-signin-buttons" },
|
|
5073
|
+
React.createElement("div", null,
|
|
5074
|
+
React.createElement("input", { type: "checkbox", id: "remember", name: "remember", value: "true" }),
|
|
5075
|
+
React.createElement("label", { htmlFor: "remember" }, "Remember me")),
|
|
5076
|
+
React.createElement("div", null,
|
|
5077
|
+
React.createElement(Button, { type: "submit", testid: "submit" }, "Create account"))))));
|
|
5078
|
+
}
|
|
5079
|
+
|
|
4901
5080
|
function StatusBadge(props) {
|
|
4902
5081
|
return React.createElement("span", { className: `medplum-status medplum-status-${props.status}` }, props.status);
|
|
4903
5082
|
}
|
|
@@ -5471,62 +5650,6 @@ function ServiceRequestTimeline(props) {
|
|
|
5471
5650
|
}) }));
|
|
5472
5651
|
}
|
|
5473
5652
|
|
|
5474
|
-
/**
|
|
5475
|
-
* Dynamically creates a script tag for the specified JavaScript file.
|
|
5476
|
-
* @param src The JavaScript file URL.
|
|
5477
|
-
*/
|
|
5478
|
-
function createScriptTag(src, onload) {
|
|
5479
|
-
const head = document.getElementsByTagName('head')[0];
|
|
5480
|
-
const script = document.createElement('script');
|
|
5481
|
-
script.async = true;
|
|
5482
|
-
script.src = src;
|
|
5483
|
-
script.onload = onload || null;
|
|
5484
|
-
head.appendChild(script);
|
|
5485
|
-
}
|
|
5486
|
-
|
|
5487
|
-
function GoogleButton(props) {
|
|
5488
|
-
const medplum = useMedplum();
|
|
5489
|
-
const { handleGoogleCredential } = props;
|
|
5490
|
-
const googleClientId = getGoogleClientId(props.googleClientId);
|
|
5491
|
-
const parentRef = useRef(null);
|
|
5492
|
-
const [scriptLoaded, setScriptLoaded] = useState(typeof google !== 'undefined');
|
|
5493
|
-
const [initialized, setInitialized] = useState(false);
|
|
5494
|
-
const [buttonRendered, setButtonRendered] = useState(false);
|
|
5495
|
-
useEffect(() => {
|
|
5496
|
-
if (typeof google === 'undefined') {
|
|
5497
|
-
createScriptTag('https://accounts.google.com/gsi/client', () => setScriptLoaded(true));
|
|
5498
|
-
return;
|
|
5499
|
-
}
|
|
5500
|
-
if (!initialized) {
|
|
5501
|
-
google.accounts.id.initialize({
|
|
5502
|
-
client_id: googleClientId,
|
|
5503
|
-
callback: handleGoogleCredential,
|
|
5504
|
-
});
|
|
5505
|
-
setInitialized(true);
|
|
5506
|
-
}
|
|
5507
|
-
if (parentRef.current && !buttonRendered) {
|
|
5508
|
-
google.accounts.id.renderButton(parentRef.current, {});
|
|
5509
|
-
setButtonRendered(true);
|
|
5510
|
-
}
|
|
5511
|
-
}, [medplum, googleClientId, initialized, scriptLoaded, parentRef, buttonRendered, handleGoogleCredential]);
|
|
5512
|
-
if (!googleClientId) {
|
|
5513
|
-
return null;
|
|
5514
|
-
}
|
|
5515
|
-
return React.createElement("div", { ref: parentRef });
|
|
5516
|
-
}
|
|
5517
|
-
function getGoogleClientId(clientId) {
|
|
5518
|
-
var _a, _b;
|
|
5519
|
-
if (clientId) {
|
|
5520
|
-
return clientId;
|
|
5521
|
-
}
|
|
5522
|
-
const origin = window.location.protocol + '//' + window.location.host;
|
|
5523
|
-
const authorizedOrigins = (_b = (_a = "http://localhost:3000,http://localhost:6006,https://app.medplum.com,https://docs.medplum.com") === null || _a === void 0 ? void 0 : _a.split(',')) !== null && _b !== void 0 ? _b : [];
|
|
5524
|
-
if (authorizedOrigins.includes(origin)) {
|
|
5525
|
-
return "921088377005-3j1sa10vr6hj86jgmdfh2l53v3mp7lfi.apps.googleusercontent.com";
|
|
5526
|
-
}
|
|
5527
|
-
return undefined;
|
|
5528
|
-
}
|
|
5529
|
-
|
|
5530
5653
|
function SignInForm(props) {
|
|
5531
5654
|
const medplum = useMedplum();
|
|
5532
5655
|
const [login, setLogin] = useState(undefined);
|
|
@@ -5568,6 +5691,7 @@ function SignInForm(props) {
|
|
|
5568
5691
|
}
|
|
5569
5692
|
function AuthenticationForm(props) {
|
|
5570
5693
|
const medplum = useMedplum();
|
|
5694
|
+
const googleClientId = getGoogleClientId(props.googleClientId);
|
|
5571
5695
|
const [outcome, setOutcome] = useState();
|
|
5572
5696
|
const issues = getIssuesForExpression(outcome, undefined);
|
|
5573
5697
|
return (React.createElement(Form, { style: { maxWidth: 400 }, onSubmit: (formData) => {
|
|
@@ -5588,6 +5712,21 @@ function AuthenticationForm(props) {
|
|
|
5588
5712
|
var _a, _b;
|
|
5589
5713
|
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));
|
|
5590
5714
|
}))),
|
|
5715
|
+
googleClientId && (React.createElement(React.Fragment, null,
|
|
5716
|
+
React.createElement("div", { className: "medplum-signin-google-container" },
|
|
5717
|
+
React.createElement(GoogleButton, { googleClientId: googleClientId, handleGoogleCredential: (response) => {
|
|
5718
|
+
medplum
|
|
5719
|
+
.startGoogleLogin({
|
|
5720
|
+
clientId: props.clientId,
|
|
5721
|
+
scope: props.scope,
|
|
5722
|
+
nonce: props.nonce,
|
|
5723
|
+
googleClientId: response.clientId,
|
|
5724
|
+
googleCredential: response.credential,
|
|
5725
|
+
})
|
|
5726
|
+
.then(props.handleAuthResponse)
|
|
5727
|
+
.catch(setOutcome);
|
|
5728
|
+
} })),
|
|
5729
|
+
React.createElement("div", { className: "medplum-signin-separator" }, "or"))),
|
|
5591
5730
|
React.createElement(FormSection, { title: "Email", htmlFor: "email", outcome: outcome },
|
|
5592
5731
|
React.createElement(Input, { name: "email", type: "email", testid: "email", required: true, autoFocus: true, outcome: outcome })),
|
|
5593
5732
|
React.createElement(FormSection, { title: "Password", htmlFor: "password", outcome: outcome },
|
|
@@ -5600,20 +5739,7 @@ function AuthenticationForm(props) {
|
|
|
5600
5739
|
React.createElement("input", { type: "checkbox", id: "remember", name: "remember", value: "true" }),
|
|
5601
5740
|
React.createElement("label", { htmlFor: "remember" }, "Remember me")),
|
|
5602
5741
|
React.createElement("div", null,
|
|
5603
|
-
React.createElement(Button, { type: "submit", testid: "submit" }, "Sign in")))
|
|
5604
|
-
React.createElement("div", { className: "medplum-signin-google-container" },
|
|
5605
|
-
React.createElement(GoogleButton, { googleClientId: props.googleClientId, handleGoogleCredential: (response) => {
|
|
5606
|
-
medplum
|
|
5607
|
-
.startGoogleLogin({
|
|
5608
|
-
clientId: props.clientId,
|
|
5609
|
-
scope: props.scope,
|
|
5610
|
-
nonce: props.nonce,
|
|
5611
|
-
googleClientId: response.clientId,
|
|
5612
|
-
googleCredential: response.credential,
|
|
5613
|
-
})
|
|
5614
|
-
.then(props.handleAuthResponse)
|
|
5615
|
-
.catch(setOutcome);
|
|
5616
|
-
} }))));
|
|
5742
|
+
React.createElement(Button, { type: "submit", testid: "submit" }, "Sign in")))));
|
|
5617
5743
|
}
|
|
5618
5744
|
function ProfileForm(props) {
|
|
5619
5745
|
const medplum = useMedplum();
|
|
@@ -5685,5 +5811,5 @@ function TabSwitch(props) {
|
|
|
5685
5811
|
})));
|
|
5686
5812
|
}
|
|
5687
5813
|
|
|
5688
|
-
export { AddressDisplay, AddressInput, AttachmentArrayDisplay, AttachmentArrayInput, AttachmentInput, Autocomplete, Avatar, BackboneElementInput, Button, Checkbox, CheckboxFormSection, CodeInput, CodeableConceptDisplay, CodeableConceptInput, ContactDetailDisplay, ContactDetailInput, ContactPointDisplay, ContactPointInput, DateTimeDisplay, DateTimeInput, DefaultResourceTimeline, DiagnosticReportDisplay, Document, ElementDefinitionInputSelector, ElementDefinitionTypeInput, EncounterTimeline, ErrorBoundary, FhirPathTable, FooterLinks, Form, FormSection, Header, HumanNameDisplay, HumanNameInput, IdentifierInput, Input, Loading, Logo, MedplumLink, MedplumProvider, MemoizedFhirPathTable, MemoizedSearchControl, MenuItem, ObservationTable, PatientTimeline, PlanDefinitionBuilder, Popup, QuestionnaireBuilder, QuestionnaireForm, QuestionnaireFormItem, QuestionnaireItemType, RangeDisplay, RangeInput, ReferenceInput, RequestGroupDisplay, ResourceArrayDisplay, ResourceArrayInput, ResourceBadge, ResourceBlame, ResourceDiff, ResourceForm, ResourceHistoryTable, ResourceInput, ResourceName, ResourcePropertyDisplay, ResourcePropertyInput, ResourceTable, ResourceTimeline, Scheduler, Scrollable, SearchChangeEvent, SearchClickEvent, SearchControl, SearchFieldEditor, SearchFilterEditor, SearchLoadEvent, Select, ServiceRequestTimeline, SignInForm, StatusBadge, Tab, TabList, TabPanel, TabSwitch, TextArea, Timeline, TimelineItem, TitleBar, UploadButton, addDateEqualsFilter, addDateFilter, addDateFilterBetween, addField, addFilter, addLastMonthFilter, addMissingFilter, addNextMonthFilter, addQuestionnaireInitialValues, addThisMonthFilter, addTodayFilter, addTomorrowFilter, addYearToDateFilter, addYesterdayFilter, buildFieldNameString, clearFilters, clearFiltersOnField, convertIsoToLocal, convertLocalToIso, createScriptTag, deleteFilter, formatRangeString, getOpString, getSearchOperators, getSortField, getTimeString, getValueAndType, hasFilterOnField, isChoiceQuestion, isSortDescending, movePage, parseForm, renderValue, setFilters, setOffset, setPropertyValue, setSort, sortByDateAndPriority, toggleSort, useMedplum, useMedplumContext, useMedplumProfile, useResource };
|
|
5814
|
+
export { AddressDisplay, AddressInput, AttachmentArrayDisplay, AttachmentArrayInput, AttachmentInput, Autocomplete, Avatar, BackboneElementInput, Button, Checkbox, CheckboxFormSection, CodeInput, CodeableConceptDisplay, CodeableConceptInput, ContactDetailDisplay, ContactDetailInput, ContactPointDisplay, ContactPointInput, DateTimeDisplay, DateTimeInput, DefaultResourceTimeline, DiagnosticReportDisplay, Document, ElementDefinitionInputSelector, ElementDefinitionTypeInput, EncounterTimeline, ErrorBoundary, FhirPathTable, FooterLinks, Form, FormSection, Header, HumanNameDisplay, HumanNameInput, IdentifierInput, Input, InputRow, Loading, Logo, MedplumLink, MedplumProvider, MemoizedFhirPathTable, MemoizedSearchControl, MenuItem, ObservationTable, PatientTimeline, PlanDefinitionBuilder, Popup, QuestionnaireBuilder, QuestionnaireForm, QuestionnaireFormItem, QuestionnaireItemType, RangeDisplay, RangeInput, ReferenceInput, RegisterForm, RequestGroupDisplay, ResourceArrayDisplay, ResourceArrayInput, ResourceBadge, ResourceBlame, ResourceDiff, ResourceForm, ResourceHistoryTable, ResourceInput, ResourceName, ResourcePropertyDisplay, ResourcePropertyInput, ResourceTable, ResourceTimeline, Scheduler, Scrollable, SearchChangeEvent, SearchClickEvent, SearchControl, SearchFieldEditor, SearchFilterEditor, SearchLoadEvent, Select, ServiceRequestTimeline, SignInForm, StatusBadge, Tab, TabList, TabPanel, TabSwitch, TextArea, Timeline, TimelineItem, TitleBar, UploadButton, addDateEqualsFilter, addDateFilter, addDateFilterBetween, addField, addFilter, addLastMonthFilter, addMissingFilter, addNextMonthFilter, addQuestionnaireInitialValues, addThisMonthFilter, addTodayFilter, addTomorrowFilter, addYearToDateFilter, addYesterdayFilter, buildFieldNameString, clearFilters, clearFiltersOnField, convertIsoToLocal, convertLocalToIso, createScriptTag, deleteFilter, formatRangeString, getOpString, getRecaptcha, getSearchOperators, getSortField, getTimeString, getValueAndType, hasFilterOnField, initRecaptcha, isChoiceQuestion, isSortDescending, movePage, parseForm, renderValue, setFilters, setOffset, setPropertyValue, setSort, sortByDateAndPriority, toggleSort, useMedplum, useMedplumContext, useMedplumProfile, useResource };
|
|
5689
5815
|
//# sourceMappingURL=index.js.map
|