@medplum/react 0.9.19 → 0.9.20

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/esm/index.js CHANGED
@@ -19,7 +19,7 @@ function Input(props) {
19
19
  const className = 'medplum-input';
20
20
  const issues = getIssuesForExpression(props.outcome, props.name);
21
21
  const invalid = issues && issues.length > 0;
22
- return (React.createElement("input", { id: props.name, name: props.name, type: getInputType(props.type), size: props.size, step: props.step, className: className, defaultValue: props.defaultValue || '', required: props.required, autoCapitalize: props.autoCapitalize, autoComplete: props.autoComplete, autoFocus: props.autoFocus, ref: props.inputRef, "aria-invalid": invalid, "aria-describedby": invalid ? props.name + '-errors' : '', placeholder: props.placeholder, "data-testid": props.testid, disabled: props.disabled, onChange: (e) => {
22
+ return (React.createElement("input", { id: props.name, name: props.name, type: getInputType(props.type), size: props.size, step: props.step, className: className, style: props.style, defaultValue: props.defaultValue || '', required: props.required, autoCapitalize: props.autoCapitalize, autoComplete: props.autoComplete, autoFocus: props.autoFocus, ref: props.inputRef, "aria-invalid": invalid, "aria-describedby": invalid ? props.name + '-errors' : '', placeholder: props.placeholder, "data-testid": props.testid, disabled: props.disabled, onChange: (e) => {
23
23
  if (props.onChange) {
24
24
  props.onChange(e.currentTarget.value);
25
25
  }
@@ -870,6 +870,18 @@ function ContactPointDisplay(props) {
870
870
  return React.createElement(React.Fragment, null, builder.join('').trim());
871
871
  }
872
872
 
873
+ function ContactDetailDisplay(props) {
874
+ var _a;
875
+ const contactDetail = props.value;
876
+ if (!contactDetail) {
877
+ return null;
878
+ }
879
+ return (React.createElement(React.Fragment, null,
880
+ contactDetail.name,
881
+ contactDetail.name && ': ', (_a = contactDetail.telecom) === null || _a === void 0 ? void 0 :
882
+ _a.map((telecom, index) => (React.createElement(ContactPointDisplay, { key: 'telecom-' + index, value: telecom })))));
883
+ }
884
+
873
885
  function DateTimeDisplay(props) {
874
886
  if (!props.value) {
875
887
  return null;
@@ -1018,6 +1030,8 @@ function ResourcePropertyDisplay(props) {
1018
1030
  return React.createElement(CodeableConceptDisplay, { value: value });
1019
1031
  case PropertyType.Coding:
1020
1032
  return React.createElement(CodingDisplay, { value: value });
1033
+ case PropertyType.ContactDetail:
1034
+ return React.createElement(ContactDetailDisplay, { value: value });
1021
1035
  case PropertyType.ContactPoint:
1022
1036
  return React.createElement(ContactPointDisplay, { value: value });
1023
1037
  case PropertyType.HumanName:
@@ -1187,19 +1201,34 @@ function ContactPointInput(props) {
1187
1201
  const ref = useRef();
1188
1202
  ref.current = contactPoint;
1189
1203
  function setContactPointWrapper(newValue) {
1204
+ if (newValue && Object.keys(newValue).length === 0) {
1205
+ newValue = undefined;
1206
+ }
1190
1207
  setContactPoint(newValue);
1191
1208
  if (props.onChange) {
1192
1209
  props.onChange(newValue);
1193
1210
  }
1194
1211
  }
1195
1212
  function setSystem(system) {
1196
- setContactPointWrapper(Object.assign(Object.assign({}, ref.current), { system: system ? system : undefined }));
1213
+ const newValue = Object.assign(Object.assign({}, ref.current), { system });
1214
+ if (!system) {
1215
+ delete newValue.system;
1216
+ }
1217
+ setContactPointWrapper(newValue);
1197
1218
  }
1198
1219
  function setUse(use) {
1199
- setContactPointWrapper(Object.assign(Object.assign({}, ref.current), { use: use ? use : undefined }));
1220
+ const newValue = Object.assign(Object.assign({}, ref.current), { use });
1221
+ if (!use) {
1222
+ delete newValue.use;
1223
+ }
1224
+ setContactPointWrapper(newValue);
1200
1225
  }
1201
1226
  function setValue(value) {
1202
- setContactPointWrapper(Object.assign(Object.assign({}, ref.current), { value: value ? value : undefined }));
1227
+ const newValue = Object.assign(Object.assign({}, ref.current), { value });
1228
+ if (!value) {
1229
+ delete newValue.value;
1230
+ }
1231
+ setContactPointWrapper(newValue);
1203
1232
  }
1204
1233
  return (React.createElement(InputRow, null,
1205
1234
  React.createElement(Select, { defaultValue: contactPoint === null || contactPoint === void 0 ? void 0 : contactPoint.system, onChange: setSystem, testid: "system" },
@@ -1220,6 +1249,36 @@ function ContactPointInput(props) {
1220
1249
  React.createElement(Input, { placeholder: "Value", defaultValue: contactPoint === null || contactPoint === void 0 ? void 0 : contactPoint.value, onChange: setValue })));
1221
1250
  }
1222
1251
 
1252
+ function ContactDetailInput(props) {
1253
+ var _a;
1254
+ const [contactPoint, setContactDetail] = useState(props.defaultValue);
1255
+ const ref = useRef();
1256
+ ref.current = contactPoint;
1257
+ function setContactDetailWrapper(newValue) {
1258
+ setContactDetail(newValue);
1259
+ if (props.onChange) {
1260
+ props.onChange(newValue);
1261
+ }
1262
+ }
1263
+ function setName(name) {
1264
+ const newValue = Object.assign(Object.assign({}, ref.current), { name });
1265
+ if (!name) {
1266
+ delete newValue.name;
1267
+ }
1268
+ setContactDetailWrapper(newValue);
1269
+ }
1270
+ function setTelecom(telecom) {
1271
+ const newValue = Object.assign(Object.assign({}, ref.current), { telecom: telecom && [telecom] });
1272
+ if (!telecom) {
1273
+ delete newValue.telecom;
1274
+ }
1275
+ setContactDetailWrapper(newValue);
1276
+ }
1277
+ return (React.createElement(InputRow, null,
1278
+ React.createElement(Input, { name: props.name + '-name', placeholder: "Name", style: { width: 180 }, defaultValue: contactPoint === null || contactPoint === void 0 ? void 0 : contactPoint.name, onChange: setName }),
1279
+ React.createElement(ContactPointInput, { name: props.name + '-telecom', defaultValue: (_a = contactPoint === null || contactPoint === void 0 ? void 0 : contactPoint.telecom) === null || _a === void 0 ? void 0 : _a[0], onChange: setTelecom })));
1280
+ }
1281
+
1223
1282
  /**
1224
1283
  * The DateTimeInput component is a wrapper around the HTML5 input type="datetime-local".
1225
1284
  * The main purpose is to reconcile time zones.
@@ -1634,6 +1693,8 @@ function ElementDefinitionTypeInput(props) {
1634
1693
  return React.createElement(CodeableConceptInput, { property: property, name: name, defaultValue: value, onChange: props.onChange });
1635
1694
  case PropertyType.Coding:
1636
1695
  return React.createElement(CodingInput, { property: property, name: name, defaultValue: value, onChange: props.onChange });
1696
+ case PropertyType.ContactDetail:
1697
+ return React.createElement(ContactDetailInput, { name: name, defaultValue: value, onChange: props.onChange });
1637
1698
  case PropertyType.ContactPoint:
1638
1699
  return React.createElement(ContactPointInput, { name: name, defaultValue: value, onChange: props.onChange });
1639
1700
  case PropertyType.Extension:
@@ -5226,7 +5287,7 @@ function createScriptTag(src, onload) {
5226
5287
 
5227
5288
  function GoogleButton(props) {
5228
5289
  const medplum = useMedplum();
5229
- const { handleAuthResponse } = props;
5290
+ const { handleGoogleCredential } = props;
5230
5291
  const googleClientId = getGoogleClientId(props.googleClientId);
5231
5292
  const parentRef = useRef(null);
5232
5293
  const [scriptLoaded, setScriptLoaded] = useState(typeof google !== 'undefined');
@@ -5240,7 +5301,7 @@ function GoogleButton(props) {
5240
5301
  if (!initialized) {
5241
5302
  google.accounts.id.initialize({
5242
5303
  client_id: googleClientId,
5243
- callback: (response) => medplum.startGoogleLogin(response).then(handleAuthResponse),
5304
+ callback: handleGoogleCredential,
5244
5305
  });
5245
5306
  setInitialized(true);
5246
5307
  }
@@ -5248,7 +5309,7 @@ function GoogleButton(props) {
5248
5309
  google.accounts.id.renderButton(parentRef.current, {});
5249
5310
  setButtonRendered(true);
5250
5311
  }
5251
- }, [medplum, googleClientId, initialized, scriptLoaded, parentRef, buttonRendered, handleAuthResponse]);
5312
+ }, [medplum, googleClientId, initialized, scriptLoaded, parentRef, buttonRendered, handleGoogleCredential]);
5252
5313
  if (!googleClientId) {
5253
5314
  return null;
5254
5315
  }
@@ -5279,19 +5340,24 @@ function SignInForm(props) {
5279
5340
  setMemberships(response.memberships);
5280
5341
  }
5281
5342
  if (response.code) {
5282
- medplum
5283
- .processCode(response.code)
5284
- .then(() => {
5285
- if (props.onSuccess) {
5286
- props.onSuccess();
5287
- }
5288
- })
5289
- .catch(console.log);
5343
+ if (props.onCode) {
5344
+ props.onCode(response.code);
5345
+ }
5346
+ else {
5347
+ medplum
5348
+ .processCode(response.code)
5349
+ .then(() => {
5350
+ if (props.onSuccess) {
5351
+ props.onSuccess();
5352
+ }
5353
+ })
5354
+ .catch(console.log);
5355
+ }
5290
5356
  }
5291
5357
  }
5292
5358
  return (React.createElement(Document, { width: 450 }, (() => {
5293
5359
  if (!login) {
5294
- return (React.createElement(AuthenticationForm, { googleClientId: props.googleClientId, onForgotPassword: props.onForgotPassword, onRegister: props.onRegister, handleAuthResponse: handleAuthResponse }, props.children));
5360
+ return (React.createElement(AuthenticationForm, { clientId: props.clientId, scope: props.scope, nonce: props.nonce, googleClientId: props.googleClientId, onForgotPassword: props.onForgotPassword, onRegister: props.onRegister, handleAuthResponse: handleAuthResponse }, props.children));
5295
5361
  }
5296
5362
  else if (memberships) {
5297
5363
  return React.createElement(ProfileForm, { login: login, memberships: memberships, handleAuthResponse: handleAuthResponse });
@@ -5308,6 +5374,9 @@ function AuthenticationForm(props) {
5308
5374
  return (React.createElement(Form, { style: { maxWidth: 400 }, onSubmit: (formData) => {
5309
5375
  medplum
5310
5376
  .startLogin({
5377
+ clientId: props.clientId,
5378
+ scope: props.scope,
5379
+ nonce: props.nonce,
5311
5380
  email: formData.email,
5312
5381
  password: formData.password,
5313
5382
  remember: formData.remember === 'true',
@@ -5334,7 +5403,18 @@ function AuthenticationForm(props) {
5334
5403
  React.createElement("div", null,
5335
5404
  React.createElement(Button, { type: "submit", testid: "submit" }, "Sign in"))),
5336
5405
  React.createElement("div", { className: "medplum-signin-google-container" },
5337
- React.createElement(GoogleButton, { googleClientId: props.googleClientId, handleAuthResponse: props.handleAuthResponse }))));
5406
+ React.createElement(GoogleButton, { googleClientId: props.googleClientId, handleGoogleCredential: (response) => {
5407
+ medplum
5408
+ .startGoogleLogin({
5409
+ clientId: props.clientId,
5410
+ scope: props.scope,
5411
+ nonce: props.nonce,
5412
+ googleClientId: response.clientId,
5413
+ googleCredential: response.credential,
5414
+ })
5415
+ .then(props.handleAuthResponse)
5416
+ .catch(setOutcome);
5417
+ } }))));
5338
5418
  }
5339
5419
  function ProfileForm(props) {
5340
5420
  const medplum = useMedplum();
@@ -5406,5 +5486,5 @@ function TabSwitch(props) {
5406
5486
  })));
5407
5487
  }
5408
5488
 
5409
- export { AddressDisplay, AddressInput, AttachmentArrayDisplay, AttachmentArrayInput, AttachmentInput, Autocomplete, Avatar, BackboneElementInput, Button, Checkbox, CheckboxFormSection, CodeInput, CodeableConceptDisplay, CodeableConceptInput, 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, 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 };
5489
+ 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, 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 };
5410
5490
  //# sourceMappingURL=index.js.map