@medplum/react 0.9.30 → 0.9.31

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 (48) 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 +2 -2
  8. package/dist/cjs/index.js +671 -648
  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/MedplumLink.js +29 -14
  14. package/dist/esm/MedplumLink.js.map +1 -1
  15. package/dist/esm/ResourceHistoryTable.js +15 -11
  16. package/dist/esm/ResourceHistoryTable.js.map +1 -1
  17. package/dist/esm/ResourceTimeline.js +3 -1
  18. package/dist/esm/ResourceTimeline.js.map +1 -1
  19. package/dist/esm/auth/AuthenticationForm.d.ts +14 -0
  20. package/dist/esm/auth/AuthenticationForm.js +67 -0
  21. package/dist/esm/auth/AuthenticationForm.js.map +1 -0
  22. package/dist/esm/auth/ChooseProfileForm.d.ts +8 -0
  23. package/dist/esm/auth/ChooseProfileForm.js +32 -0
  24. package/dist/esm/auth/ChooseProfileForm.js.map +1 -0
  25. package/dist/esm/auth/NewProjectForm.d.ts +7 -0
  26. package/dist/esm/auth/NewProjectForm.js +42 -0
  27. package/dist/esm/auth/NewProjectForm.js.map +1 -0
  28. package/dist/esm/auth/NewUserForm.d.ts +10 -0
  29. package/dist/esm/auth/NewUserForm.js +87 -0
  30. package/dist/esm/auth/NewUserForm.js.map +1 -0
  31. package/dist/esm/auth/RegisterForm.d.ts +12 -0
  32. package/dist/esm/auth/RegisterForm.js +39 -0
  33. package/dist/esm/auth/RegisterForm.js.map +1 -0
  34. package/dist/esm/{SignInForm.d.ts → auth/SignInForm.d.ts} +1 -1
  35. package/dist/esm/auth/SignInForm.js +52 -0
  36. package/dist/esm/auth/SignInForm.js.map +1 -0
  37. package/dist/esm/index.d.ts +2 -2
  38. package/dist/esm/index.js +2 -2
  39. package/dist/esm/index.min.js +1 -1
  40. package/dist/esm/index.min.js.map +1 -1
  41. package/dist/esm/styles.css +197 -197
  42. package/package.json +16 -18
  43. package/dist/cjs/RegisterForm.d.ts +0 -18
  44. package/dist/esm/RegisterForm.d.ts +0 -18
  45. package/dist/esm/RegisterForm.js +0 -121
  46. package/dist/esm/RegisterForm.js.map +0 -1
  47. package/dist/esm/SignInForm.js +0 -167
  48. package/dist/esm/SignInForm.js.map +0 -1
@@ -172,6 +172,203 @@ select.medplum-select:disabled {
172
172
  box-shadow: 0 0 0 2px var(--medplum-blue-200);
173
173
  }
174
174
 
175
+ .medplum-document {
176
+ margin: 20px auto 6px auto;
177
+ padding: 10px;
178
+ clear: both;
179
+ text-align: center;
180
+ }
181
+
182
+ .medplum-document article {
183
+ background-color: var(--medplum-surface);
184
+ max-width: 900px;
185
+ margin: 8px auto 16px auto;
186
+ padding: 15px 25px;
187
+ text-align: left;
188
+ border: 0.1px solid var(--medplum-gray-300);
189
+ border-radius: 8px;
190
+ box-shadow: 0 1px 3px 0 var(--medplum-shadow);
191
+ }
192
+
193
+ .medplum-document h1,
194
+ .medplum-document h2,
195
+ .medplum-document h3 {
196
+ margin: 12px 0;
197
+ }
198
+
199
+ .medplum-document p,
200
+ .medplum-document li {
201
+ line-height: 175%;
202
+ margin: 8px 0;
203
+ }
204
+
205
+ @media (max-width: 700px) {
206
+ .medplum-document {
207
+ margin: 10px auto 6px auto;
208
+ padding: 6px;
209
+ }
210
+
211
+ .medplum-document article {
212
+ padding: 6px 12px;
213
+ }
214
+ }
215
+
216
+ .medplum-document img,
217
+ .medplum-document video {
218
+ width: 100%;
219
+ }
220
+
221
+ .medplum-document textarea {
222
+ margin: 0;
223
+ min-height: 100px;
224
+ width: 100%;
225
+ }
226
+
227
+ fieldset.medplum-form-section {
228
+ border: 0;
229
+ margin: 6px 0 12px 0;
230
+ padding: 2px 0 8px 0;
231
+ }
232
+
233
+ fieldset.medplum-form-section > label,
234
+ fieldset.medplum-form-section > legend {
235
+ display: block;
236
+ margin: 1px 0 3px 0;
237
+ line-height: 1.75;
238
+ font-weight: 500;
239
+ }
240
+
241
+ fieldset.medplum-form-section > p {
242
+ margin: 1px 0 4px 0;
243
+ padding: 1px 0 4px 0;
244
+ line-height: 1.75;
245
+ }
246
+
247
+ .medplum-signin-buttons {
248
+ display: flex;
249
+ justify-content: space-between;
250
+ line-height: 32px;
251
+ }
252
+
253
+ .medplum-signin-buttons > div {
254
+ display: flex;
255
+ align-items: center;
256
+ }
257
+
258
+ .medplum-signin-buttons a {
259
+ font-size: 12px;
260
+ margin-right: 16px;
261
+ }
262
+
263
+ .medplum-signin-buttons label {
264
+ font-size: 12px;
265
+ }
266
+
267
+ .medplum-signin-google-container {
268
+ padding: 20px 0 10px 0;
269
+ margin: 20px 0 10px 0;
270
+ height: 70px;
271
+ text-align: center;
272
+ display: flex;
273
+ align-items: center;
274
+ justify-content: center;
275
+ }
276
+
277
+ .medplum-signin-separator {
278
+ padding: 12px 0;
279
+ margin: 12px 0;
280
+ overflow: hidden;
281
+ text-align: center;
282
+ font-size: var(--medplum-font-small);
283
+ }
284
+
285
+ .medplum-signin-separator::before,
286
+ .medplum-signin-separator::after {
287
+ background-color: var(--medplum-gray-400);
288
+ content: '';
289
+ display: inline-block;
290
+ height: 0.1px;
291
+ position: relative;
292
+ vertical-align: middle;
293
+ width: 50%;
294
+ }
295
+
296
+ .medplum-signin-separator::before {
297
+ right: 0.5em;
298
+ margin-left: -50%;
299
+ }
300
+
301
+ .medplum-signin-separator::after {
302
+ left: 0.5em;
303
+ margin-right: -50%;
304
+ }
305
+
306
+ .medplum-left {
307
+ text-align: left;
308
+ }
309
+
310
+ .medplum-center {
311
+ text-align: center;
312
+ }
313
+
314
+ .medplum-right {
315
+ text-align: right;
316
+ }
317
+
318
+ .medplum-avatar {
319
+ padding: 0;
320
+ width: 32px;
321
+ height: 32px;
322
+ min-width: 32px;
323
+ min-height: 32px;
324
+ line-height: 32px;
325
+ user-select: none;
326
+ border-radius: 50%;
327
+ overflow: hidden;
328
+ text-align: center;
329
+ color: var(--medplum-surface);
330
+ background-color: var(--medplum-gray-500);
331
+ font-size: 18px;
332
+ }
333
+
334
+ .medplum-avatar img {
335
+ width: 100%;
336
+ height: 100%;
337
+ object-fit: cover;
338
+ }
339
+
340
+ .medplum-avatar.xsmall {
341
+ width: 20px;
342
+ height: 20px;
343
+ min-width: 20px;
344
+ min-height: 20px;
345
+ line-height: 20px;
346
+ font-size: 10px;
347
+ }
348
+
349
+ .medplum-avatar.small {
350
+ width: 24px;
351
+ height: 24px;
352
+ min-width: 24px;
353
+ min-height: 24px;
354
+ line-height: 24px;
355
+ font-size: 11px;
356
+ }
357
+
358
+ .medplum-avatar.large {
359
+ width: 56px;
360
+ height: 56px;
361
+ min-width: 56px;
362
+ min-height: 56px;
363
+ line-height: 56px;
364
+ font-size: 28px;
365
+ }
366
+
367
+ .medplum-avatar > a {
368
+ color: var(--medplum-surface);
369
+ text-decoration: none;
370
+ }
371
+
175
372
  .medplum-autocomplete-container {
176
373
  border: 0.1px solid var(--medplum-gray-300);
177
374
  border-radius: 3px;
@@ -306,60 +503,6 @@ select.medplum-select:disabled {
306
503
  color: var(--medplum-gray-500);
307
504
  }
308
505
 
309
- .medplum-avatar {
310
- padding: 0;
311
- width: 32px;
312
- height: 32px;
313
- min-width: 32px;
314
- min-height: 32px;
315
- line-height: 32px;
316
- user-select: none;
317
- border-radius: 50%;
318
- overflow: hidden;
319
- text-align: center;
320
- color: var(--medplum-surface);
321
- background-color: var(--medplum-gray-500);
322
- font-size: 18px;
323
- }
324
-
325
- .medplum-avatar img {
326
- width: 100%;
327
- height: 100%;
328
- object-fit: cover;
329
- }
330
-
331
- .medplum-avatar.xsmall {
332
- width: 20px;
333
- height: 20px;
334
- min-width: 20px;
335
- min-height: 20px;
336
- line-height: 20px;
337
- font-size: 10px;
338
- }
339
-
340
- .medplum-avatar.small {
341
- width: 24px;
342
- height: 24px;
343
- min-width: 24px;
344
- min-height: 24px;
345
- line-height: 24px;
346
- font-size: 11px;
347
- }
348
-
349
- .medplum-avatar.large {
350
- width: 56px;
351
- height: 56px;
352
- min-width: 56px;
353
- min-height: 56px;
354
- line-height: 56px;
355
- font-size: 28px;
356
- }
357
-
358
- .medplum-avatar > a {
359
- color: var(--medplum-surface);
360
- text-decoration: none;
361
- }
362
-
363
506
  .medplum-checkbox-form-section {
364
507
  display: flex;
365
508
  justify-content: space-between;
@@ -378,26 +521,6 @@ select.medplum-select:disabled {
378
521
  font-weight: 500;
379
522
  }
380
523
 
381
- fieldset.medplum-form-section {
382
- border: 0;
383
- margin: 6px 0 12px 0;
384
- padding: 2px 0 8px 0;
385
- }
386
-
387
- fieldset.medplum-form-section > label,
388
- fieldset.medplum-form-section > legend {
389
- display: block;
390
- margin: 1px 0 3px 0;
391
- line-height: 1.75;
392
- font-weight: 500;
393
- }
394
-
395
- fieldset.medplum-form-section > p {
396
- margin: 1px 0 4px 0;
397
- padding: 1px 0 4px 0;
398
- line-height: 1.75;
399
- }
400
-
401
524
  dl.medplum-description-list {
402
525
  display: grid;
403
526
  grid-template-columns: 30% 70%;
@@ -816,58 +939,6 @@ table.medplum-diff-table td {
816
939
  margin-right: 4px;
817
940
  }
818
941
 
819
- .medplum-document {
820
- margin: 20px auto 6px auto;
821
- padding: 10px;
822
- clear: both;
823
- text-align: center;
824
- }
825
-
826
- .medplum-document article {
827
- background-color: var(--medplum-surface);
828
- max-width: 900px;
829
- margin: 8px auto 16px auto;
830
- padding: 15px 25px;
831
- text-align: left;
832
- border: 0.1px solid var(--medplum-gray-300);
833
- border-radius: 8px;
834
- box-shadow: 0 1px 3px 0 var(--medplum-shadow);
835
- }
836
-
837
- .medplum-document h1,
838
- .medplum-document h2,
839
- .medplum-document h3 {
840
- margin: 12px 0;
841
- }
842
-
843
- .medplum-document p,
844
- .medplum-document li {
845
- line-height: 175%;
846
- margin: 8px 0 16px 0;
847
- }
848
-
849
- @media (max-width: 700px) {
850
- .medplum-document {
851
- margin: 10px auto 6px auto;
852
- padding: 6px;
853
- }
854
-
855
- .medplum-document article {
856
- padding: 6px 12px;
857
- }
858
- }
859
-
860
- .medplum-document img,
861
- .medplum-document video {
862
- width: 100%;
863
- }
864
-
865
- .medplum-document textarea {
866
- margin: 0;
867
- min-height: 100px;
868
- width: 100%;
869
- }
870
-
871
942
  .medplum-search-control {
872
943
  max-width: 100%;
873
944
  overflow: auto;
@@ -1374,77 +1445,6 @@ div.medplum-nav-menu-container {
1374
1445
  color: var(--medplum-blue-500);
1375
1446
  }
1376
1447
 
1377
- .medplum-signin-buttons {
1378
- display: flex;
1379
- justify-content: space-between;
1380
- line-height: 32px;
1381
- }
1382
-
1383
- .medplum-signin-buttons > div {
1384
- display: flex;
1385
- align-items: center;
1386
- }
1387
-
1388
- .medplum-signin-buttons a {
1389
- font-size: 12px;
1390
- margin-right: 16px;
1391
- }
1392
-
1393
- .medplum-signin-buttons label {
1394
- font-size: 12px;
1395
- }
1396
-
1397
- .medplum-signin-google-container {
1398
- padding: 20px 0 10px 0;
1399
- margin: 20px 0 10px 0;
1400
- height: 70px;
1401
- text-align: center;
1402
- display: flex;
1403
- align-items: center;
1404
- justify-content: center;
1405
- }
1406
-
1407
- .medplum-signin-separator {
1408
- padding: 12px 0;
1409
- margin: 12px 0;
1410
- overflow: hidden;
1411
- text-align: center;
1412
- font-size: var(--medplum-font-small);
1413
- }
1414
-
1415
- .medplum-signin-separator::before,
1416
- .medplum-signin-separator::after {
1417
- background-color: var(--medplum-gray-400);
1418
- content: '';
1419
- display: inline-block;
1420
- height: 0.1px;
1421
- position: relative;
1422
- vertical-align: middle;
1423
- width: 50%;
1424
- }
1425
-
1426
- .medplum-signin-separator::before {
1427
- right: 0.5em;
1428
- margin-left: -50%;
1429
- }
1430
-
1431
- .medplum-signin-separator::after {
1432
- left: 0.5em;
1433
- margin-right: -50%;
1434
- }
1435
-
1436
- .medplum-left {
1437
- text-align: left;
1438
- }
1439
-
1440
- .medplum-center {
1441
- text-align: center;
1442
- }
1443
-
1444
- .medplum-right {
1445
- text-align: right;
1446
- }
1447
-
1448
1448
  .medplum-status {
1449
1449
  padding: 1px 6px;
1450
1450
  font-size: 80%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/react",
3
- "version": "0.9.30",
3
+ "version": "0.9.31",
4
4
  "description": "Medplum React Component Library",
5
5
  "author": "Medplum <hello@medplum.com>",
6
6
  "license": "Apache-2.0",
@@ -19,21 +19,21 @@
19
19
  "storybook": "build-storybook"
20
20
  },
21
21
  "devDependencies": {
22
- "@medplum/core": "0.9.30",
23
- "@medplum/fhirtypes": "0.9.30",
24
- "@medplum/mock": "0.9.30",
25
- "@storybook/addon-actions": "6.5.9",
26
- "@storybook/addon-essentials": "6.5.9",
27
- "@storybook/addon-links": "6.5.9",
28
- "@storybook/builder-webpack5": "6.5.9",
29
- "@storybook/manager-webpack5": "6.5.9",
30
- "@storybook/react": "6.5.9",
31
- "@testing-library/dom": "8.16.0",
32
- "@testing-library/jest-dom": "5.16.4",
22
+ "@medplum/core": "0.9.31",
23
+ "@medplum/fhirtypes": "0.9.31",
24
+ "@medplum/mock": "0.9.31",
25
+ "@storybook/addon-actions": "6.5.10",
26
+ "@storybook/addon-essentials": "6.5.10",
27
+ "@storybook/addon-links": "6.5.10",
28
+ "@storybook/builder-webpack5": "6.5.10",
29
+ "@storybook/manager-webpack5": "6.5.10",
30
+ "@storybook/react": "6.5.10",
31
+ "@testing-library/dom": "8.17.1",
32
+ "@testing-library/jest-dom": "5.16.5",
33
33
  "@testing-library/react": "13.3.0",
34
34
  "@types/jest": "28.1.6",
35
- "@types/node": "18.6.3",
36
- "@types/react": "18.0.15",
35
+ "@types/node": "18.7.1",
36
+ "@types/react": "18.0.17",
37
37
  "@types/react-dom": "18.0.6",
38
38
  "@types/react-router-dom": "5.3.3",
39
39
  "dotenv-webpack": "8.0.0",
@@ -48,7 +48,7 @@
48
48
  "typescript": "4.7.4"
49
49
  },
50
50
  "peerDependencies": {
51
- "@medplum/core": "0.9.30",
51
+ "@medplum/core": "0.9.31",
52
52
  "react": "^17.0.2 || ^18.0.0",
53
53
  "react-dom": "^17.0.2 || ^18.0.0",
54
54
  "react-router-dom": "^6.2.2"
@@ -70,9 +70,7 @@
70
70
  }
71
71
  },
72
72
  "types": "dist/esm/index.d.ts",
73
- "sideEffects": [
74
- "*.css"
75
- ],
73
+ "sideEffects": false,
76
74
  "keywords": [
77
75
  "medplum",
78
76
  "fhir",
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import './SignInForm.css';
3
- import './util.css';
4
- export interface BaseRegisterFormProps {
5
- readonly googleClientId?: string;
6
- readonly recaptchaSiteKey: string;
7
- readonly children?: React.ReactNode;
8
- readonly onSuccess: () => void;
9
- }
10
- export interface PatientRegisterFormProps extends BaseRegisterFormProps {
11
- readonly type: 'patient';
12
- readonly projectId: string;
13
- }
14
- export interface ProjectRegisterFormProps extends BaseRegisterFormProps {
15
- readonly type: 'project';
16
- }
17
- export declare type RegisterFormProps = PatientRegisterFormProps | ProjectRegisterFormProps;
18
- export declare function RegisterForm(props: RegisterFormProps): JSX.Element;
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import './SignInForm.css';
3
- import './util.css';
4
- export interface BaseRegisterFormProps {
5
- readonly googleClientId?: string;
6
- readonly recaptchaSiteKey: string;
7
- readonly children?: React.ReactNode;
8
- readonly onSuccess: () => void;
9
- }
10
- export interface PatientRegisterFormProps extends BaseRegisterFormProps {
11
- readonly type: 'patient';
12
- readonly projectId: string;
13
- }
14
- export interface ProjectRegisterFormProps extends BaseRegisterFormProps {
15
- readonly type: 'project';
16
- }
17
- export declare type RegisterFormProps = PatientRegisterFormProps | ProjectRegisterFormProps;
18
- export declare function RegisterForm(props: RegisterFormProps): JSX.Element;
@@ -1,121 +0,0 @@
1
- import { __awaiter } from './node_modules/tslib/tslib.es6.js';
2
- import { parseJWTPayload } from '@medplum/core';
3
- import React, { useState, useEffect } from 'react';
4
- import { Button } from './Button.js';
5
- import { Document } from './Document.js';
6
- import { Form } from './Form.js';
7
- import { FormSection } from './FormSection.js';
8
- import { getGoogleClientId, GoogleButton } from './GoogleButton.js';
9
- import { Input } from './Input.js';
10
- import { useMedplum } from './MedplumProvider.js';
11
- import { getIssuesForExpression } from './utils/outcomes.js';
12
- import { initRecaptcha, getRecaptcha } from './utils/recaptcha.js';
13
-
14
- function RegisterForm(props) {
15
- const medplum = useMedplum();
16
- const googleClientId = getGoogleClientId(props.googleClientId);
17
- const recaptchaSiteKey = props.recaptchaSiteKey;
18
- const [outcome, setOutcome] = useState();
19
- const issues = getIssuesForExpression(outcome, undefined);
20
- useEffect(() => initRecaptcha(recaptchaSiteKey), [recaptchaSiteKey]);
21
- function handleAuthResponse(registerRequest, partialLogin) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- try {
24
- let login;
25
- if (props.type === 'patient') {
26
- login = yield medplum.startNewPatient(registerRequest, partialLogin);
27
- }
28
- else {
29
- login = yield medplum.startNewProject(registerRequest, partialLogin);
30
- }
31
- yield medplum.processCode(login.code);
32
- props.onSuccess();
33
- }
34
- catch (err) {
35
- setOutcome(err);
36
- }
37
- });
38
- }
39
- return (React.createElement(Document, { width: 450 },
40
- React.createElement(Form, { style: { maxWidth: 400 }, onSubmit: (formData) => __awaiter(this, void 0, void 0, function* () {
41
- try {
42
- const recaptchaToken = yield getRecaptcha(recaptchaSiteKey);
43
- const registerRequest = {
44
- projectId: props.projectId,
45
- projectName: formData.projectName,
46
- firstName: formData.firstName,
47
- lastName: formData.lastName,
48
- email: formData.email,
49
- password: formData.password,
50
- remember: formData.remember === 'true',
51
- recaptchaSiteKey,
52
- recaptchaToken,
53
- };
54
- const userLogin = yield medplum.startNewUser(registerRequest);
55
- yield handleAuthResponse(registerRequest, userLogin);
56
- }
57
- catch (err) {
58
- setOutcome(err);
59
- }
60
- }) },
61
- React.createElement("div", { className: "medplum-center" }, props.children),
62
- issues && (React.createElement("div", { className: "medplum-input-error" }, issues.map((issue) => {
63
- var _a, _b;
64
- 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));
65
- }))),
66
- googleClientId && (React.createElement(React.Fragment, null,
67
- React.createElement("div", { className: "medplum-signin-google-container" },
68
- React.createElement(GoogleButton, { googleClientId: googleClientId, handleGoogleCredential: (response) => __awaiter(this, void 0, void 0, function* () {
69
- try {
70
- const loginRequest = {
71
- googleClientId: response.clientId,
72
- googleCredential: response.credential,
73
- };
74
- const userLogin = yield medplum.startGoogleLogin(loginRequest);
75
- const googleClaims = parseJWTPayload(loginRequest.googleCredential);
76
- const registerRequest = {
77
- projectId: props.projectId,
78
- firstName: googleClaims.given_name,
79
- lastName: googleClaims.family_name,
80
- email: googleClaims.email,
81
- };
82
- yield handleAuthResponse(registerRequest, userLogin);
83
- }
84
- catch (err) {
85
- setOutcome(err);
86
- }
87
- }) })),
88
- React.createElement("div", { className: "medplum-signin-separator" }, "or"))),
89
- React.createElement(FormSection, { title: "First Name", htmlFor: "firstName", outcome: outcome },
90
- React.createElement(Input, { name: "firstName", type: "text", testid: "firstName", placeholder: "First name", required: true, autoFocus: true, outcome: outcome })),
91
- React.createElement(FormSection, { title: "Last Name", htmlFor: "lastName", outcome: outcome },
92
- React.createElement(Input, { name: "lastName", type: "text", testid: "lastName", placeholder: "Last name", required: true, outcome: outcome })),
93
- props.type === 'project' && (React.createElement(FormSection, { title: "Project Name", htmlFor: "projectName", outcome: outcome },
94
- React.createElement(Input, { name: "projectName", type: "text", testid: "projectName", placeholder: "My Project", required: true, outcome: outcome }))),
95
- React.createElement(FormSection, { title: "Email", htmlFor: "email", outcome: outcome },
96
- React.createElement(Input, { name: "email", type: "email", testid: "email", placeholder: "name@domain.com", required: true, outcome: outcome })),
97
- React.createElement(FormSection, { title: "Password", htmlFor: "password", outcome: outcome },
98
- React.createElement(Input, { name: "password", type: "password", testid: "password", autoComplete: "off", required: true, outcome: outcome })),
99
- React.createElement("p", { style: { fontSize: '12px', color: '#888' } },
100
- "By clicking submit you agree to the Medplum ",
101
- React.createElement("a", { href: "https://www.medplum.com/privacy" }, "Privacy\u00A0Policy"),
102
- ' and ',
103
- React.createElement("a", { href: "https://www.medplum.com/terms" }, "Terms\u00A0of\u00A0Service"),
104
- "."),
105
- React.createElement("p", { style: { fontSize: '12px', color: '#888' } },
106
- "This site is protected by reCAPTCHA and the Google",
107
- ' ',
108
- React.createElement("a", { href: "https://policies.google.com/privacy" }, "Privacy\u00A0Policy"),
109
- ' and ',
110
- React.createElement("a", { href: "https://policies.google.com/terms" }, "Terms\u00A0of\u00A0Service"),
111
- " apply."),
112
- React.createElement("div", { className: "medplum-signin-buttons" },
113
- React.createElement("div", null,
114
- React.createElement("input", { type: "checkbox", id: "remember", name: "remember", value: "true" }),
115
- React.createElement("label", { htmlFor: "remember" }, "Remember me")),
116
- React.createElement("div", null,
117
- React.createElement(Button, { type: "submit", testid: "submit" }, "Create account"))))));
118
- }
119
-
120
- export { RegisterForm };
121
- //# sourceMappingURL=RegisterForm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RegisterForm.js","sources":["../../src/RegisterForm.tsx"],"sourcesContent":["import {\n GoogleCredentialResponse,\n LoginAuthenticationResponse,\n NewPatientRequest,\n NewProjectRequest,\n parseJWTPayload,\n} from '@medplum/core';\nimport { OperationOutcome } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport { Button } from './Button';\nimport { Document } from './Document';\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';\nimport './SignInForm.css';\nimport './util.css';\n\nexport interface BaseRegisterFormProps {\n readonly googleClientId?: string;\n readonly recaptchaSiteKey: string;\n readonly children?: React.ReactNode;\n readonly onSuccess: () => void;\n}\n\nexport interface PatientRegisterFormProps extends BaseRegisterFormProps {\n readonly type: 'patient';\n readonly projectId: string;\n}\n\nexport interface ProjectRegisterFormProps extends BaseRegisterFormProps {\n readonly type: 'project';\n}\n\nexport type RegisterFormProps = PatientRegisterFormProps | ProjectRegisterFormProps;\n\nexport function RegisterForm(props: RegisterFormProps): JSX.Element {\n const medplum = useMedplum();\n const googleClientId = getGoogleClientId(props.googleClientId);\n const recaptchaSiteKey = props.recaptchaSiteKey;\n const [outcome, setOutcome] = useState<OperationOutcome>();\n const issues = getIssuesForExpression(outcome, undefined);\n\n useEffect(() => initRecaptcha(recaptchaSiteKey), [recaptchaSiteKey]);\n\n async function handleAuthResponse(\n registerRequest: NewPatientRequest | NewProjectRequest,\n partialLogin: LoginAuthenticationResponse\n ): Promise<void> {\n try {\n let login;\n if (props.type === 'patient') {\n login = await medplum.startNewPatient(registerRequest as NewPatientRequest, partialLogin);\n } else {\n login = await medplum.startNewProject(registerRequest as NewProjectRequest, partialLogin);\n }\n await medplum.processCode(login.code as string);\n props.onSuccess();\n } catch (err) {\n setOutcome(err as OperationOutcome);\n }\n }\n\n return (\n <Document width={450}>\n <Form\n style={{ maxWidth: 400 }}\n onSubmit={async (formData: Record<string, string>) => {\n try {\n const recaptchaToken = await getRecaptcha(recaptchaSiteKey);\n const registerRequest = {\n projectId: (props as PatientRegisterFormProps).projectId,\n projectName: formData.projectName,\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 const userLogin = await medplum.startNewUser(registerRequest);\n await handleAuthResponse(registerRequest, userLogin);\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 const loginRequest = {\n googleClientId: response.clientId,\n googleCredential: response.credential,\n };\n const userLogin = await medplum.startGoogleLogin(loginRequest);\n const googleClaims = parseJWTPayload(loginRequest.googleCredential);\n const registerRequest = {\n projectId: (props as PatientRegisterFormProps).projectId,\n firstName: googleClaims.given_name as string,\n lastName: googleClaims.family_name as string,\n email: googleClaims.email as string,\n };\n await handleAuthResponse(registerRequest, userLogin);\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 {props.type === 'project' && (\n <FormSection title=\"Project Name\" htmlFor=\"projectName\" outcome={outcome}>\n <Input\n name=\"projectName\"\n type=\"text\"\n testid=\"projectName\"\n placeholder=\"My Project\"\n required={true}\n outcome={outcome}\n />\n </FormSection>\n )}\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\n name=\"password\"\n type=\"password\"\n testid=\"password\"\n autoComplete=\"off\"\n required={true}\n outcome={outcome}\n />\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 </Document>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAuCM,SAAU,YAAY,CAAC,KAAwB,EAAA;AACnD,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,cAAc,GAAG,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAC/D,IAAA,MAAM,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;IAChD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAAoB,CAAC;IAC3D,MAAM,MAAM,GAAG,sBAAsB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAE1D,IAAA,SAAS,CAAC,MAAM,aAAa,CAAC,gBAAgB,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAErE,IAAA,SAAe,kBAAkB,CAC/B,eAAsD,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