@medplum/react 0.9.37 → 0.10.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.
- package/dist/cjs/AttachmentButton.d.ts +9 -0
- package/dist/cjs/CodeInput.d.ts +2 -1
- package/dist/cjs/CodeableConceptInput.d.ts +1 -0
- package/dist/cjs/CodingInput.d.ts +1 -0
- package/dist/cjs/DateTimeInput.d.ts +9 -2
- package/dist/cjs/ReferenceInput.d.ts +1 -0
- package/dist/cjs/ResourceAvatar.d.ts +8 -0
- package/dist/cjs/ResourceBadge.d.ts +0 -1
- package/dist/cjs/ResourceInput.d.ts +2 -3
- package/dist/cjs/SearchPopupMenu.d.ts +0 -4
- package/dist/cjs/SearchUtils.d.ts +5 -5
- package/dist/cjs/ValueSetAutocomplete.d.ts +10 -0
- package/dist/cjs/auth/RegisterForm.d.ts +0 -1
- package/dist/cjs/auth/SignInForm.d.ts +0 -1
- package/dist/cjs/defaulttheme.css +0 -51
- package/dist/cjs/index.d.ts +3 -13
- package/dist/cjs/index.js +793 -1492
- 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/stories/{UploadButton.stories.d.ts → AttachmentButton.stories.d.ts} +1 -0
- package/dist/cjs/stories/{Input.stories.d.ts → PeriodInput.stories.d.ts} +1 -1
- package/dist/cjs/stories/{Avatar.stories.d.ts → ResourceAvatar.stories.d.ts} +0 -0
- package/dist/cjs/stories/ResourceForm.stories.d.ts +1 -0
- package/dist/cjs/stories/{Dialog.stories.d.ts → ResourceInput.stories.d.ts} +2 -1
- package/dist/cjs/stories/SearchControl.stories.d.ts +1 -0
- package/dist/cjs/styles.css +72 -1053
- package/dist/cjs/utils/outcomes.d.ts +1 -0
- package/dist/esm/AddressInput.js +9 -21
- package/dist/esm/AddressInput.js.map +1 -1
- package/dist/esm/AnnotationInput.js +2 -2
- package/dist/esm/AnnotationInput.js.map +1 -1
- package/dist/esm/AttachmentArrayInput.js +11 -8
- package/dist/esm/AttachmentArrayInput.js.map +1 -1
- package/dist/esm/AttachmentButton.d.ts +9 -0
- package/dist/esm/{UploadButton.js → AttachmentButton.js} +9 -9
- package/dist/esm/AttachmentButton.js.map +1 -0
- package/dist/esm/AttachmentInput.js +3 -3
- package/dist/esm/AttachmentInput.js.map +1 -1
- package/dist/esm/CalendarInput.js +6 -7
- package/dist/esm/CalendarInput.js.map +1 -1
- package/dist/esm/CodeInput.d.ts +2 -1
- package/dist/esm/CodeInput.js +16 -21
- package/dist/esm/CodeInput.js.map +1 -1
- package/dist/esm/CodeableConceptInput.d.ts +1 -0
- package/dist/esm/CodeableConceptInput.js +18 -33
- package/dist/esm/CodeableConceptInput.js.map +1 -1
- package/dist/esm/CodingInput.d.ts +1 -0
- package/dist/esm/CodingInput.js +24 -23
- package/dist/esm/CodingInput.js.map +1 -1
- package/dist/esm/ContactDetailInput.js +3 -4
- package/dist/esm/ContactDetailInput.js.map +1 -1
- package/dist/esm/ContactPointInput.js +5 -21
- package/dist/esm/ContactPointInput.js.map +1 -1
- package/dist/esm/DateTimeInput.d.ts +9 -2
- package/dist/esm/DateTimeInput.js +13 -3
- package/dist/esm/DateTimeInput.js.map +1 -1
- package/dist/esm/DiagnosticReportDisplay.js +16 -1
- package/dist/esm/DiagnosticReportDisplay.js.map +1 -1
- package/dist/esm/EncounterTimeline.js +2 -0
- package/dist/esm/EncounterTimeline.js.map +1 -1
- package/dist/esm/ExtensionInput.js +2 -2
- package/dist/esm/ExtensionInput.js.map +1 -1
- package/dist/esm/FhirPathTable.js +4 -5
- package/dist/esm/FhirPathTable.js.map +1 -1
- package/dist/esm/HumanNameInput.js +7 -17
- package/dist/esm/HumanNameInput.js.map +1 -1
- package/dist/esm/IdentifierInput.js +4 -5
- package/dist/esm/IdentifierInput.js.map +1 -1
- package/dist/esm/Logo.js +4 -4
- package/dist/esm/Logo.js.map +1 -1
- package/dist/esm/PatientTimeline.js +2 -0
- package/dist/esm/PatientTimeline.js.map +1 -1
- package/dist/esm/PeriodInput.js +5 -5
- package/dist/esm/PeriodInput.js.map +1 -1
- package/dist/esm/PlanDefinitionBuilder.js +17 -29
- package/dist/esm/PlanDefinitionBuilder.js.map +1 -1
- package/dist/esm/QuantityInput.js +5 -12
- package/dist/esm/QuantityInput.js.map +1 -1
- package/dist/esm/QuestionnaireBuilder.js +22 -25
- package/dist/esm/QuestionnaireBuilder.js.map +1 -1
- package/dist/esm/QuestionnaireForm.js +35 -29
- package/dist/esm/QuestionnaireForm.js.map +1 -1
- package/dist/esm/RangeInput.js +2 -2
- package/dist/esm/RangeInput.js.map +1 -1
- package/dist/esm/RatioInput.js +2 -2
- package/dist/esm/RatioInput.js.map +1 -1
- package/dist/esm/ReferenceInput.d.ts +1 -0
- package/dist/esm/ReferenceInput.js +4 -6
- package/dist/esm/ReferenceInput.js.map +1 -1
- package/dist/esm/RequestGroupDisplay.js +1 -1
- package/dist/esm/RequestGroupDisplay.js.map +1 -1
- package/dist/esm/ResourceArrayInput.js +10 -7
- package/dist/esm/ResourceArrayInput.js.map +1 -1
- package/dist/esm/ResourceAvatar.d.ts +8 -0
- package/dist/esm/ResourceAvatar.js +24 -0
- package/dist/esm/ResourceAvatar.js.map +1 -0
- package/dist/esm/ResourceBadge.d.ts +0 -1
- package/dist/esm/ResourceBadge.js +2 -3
- package/dist/esm/ResourceBadge.js.map +1 -1
- package/dist/esm/ResourceBlame.js +3 -3
- package/dist/esm/ResourceBlame.js.map +1 -1
- package/dist/esm/ResourceForm.js +10 -10
- package/dist/esm/ResourceForm.js.map +1 -1
- package/dist/esm/ResourceInput.d.ts +2 -3
- package/dist/esm/ResourceInput.js +37 -29
- package/dist/esm/ResourceInput.js.map +1 -1
- package/dist/esm/ResourcePropertyInput.js +30 -18
- package/dist/esm/ResourcePropertyInput.js.map +1 -1
- package/dist/esm/ResourceTimeline.js +19 -15
- package/dist/esm/ResourceTimeline.js.map +1 -1
- package/dist/esm/Scheduler.js +7 -7
- package/dist/esm/Scheduler.js.map +1 -1
- package/dist/esm/SearchControl.js +76 -58
- package/dist/esm/SearchControl.js.map +1 -1
- package/dist/esm/SearchControlField.js.map +1 -1
- package/dist/esm/SearchFieldEditor.js +7 -7
- package/dist/esm/SearchFieldEditor.js.map +1 -1
- package/dist/esm/SearchFilterEditor.js +10 -15
- package/dist/esm/SearchFilterEditor.js.map +1 -1
- package/dist/esm/SearchFilterValueDialog.js +4 -3
- package/dist/esm/SearchFilterValueDialog.js.map +1 -1
- package/dist/esm/SearchFilterValueInput.js +6 -7
- package/dist/esm/SearchFilterValueInput.js.map +1 -1
- package/dist/esm/SearchPopupMenu.d.ts +0 -4
- package/dist/esm/SearchPopupMenu.js +59 -73
- package/dist/esm/SearchPopupMenu.js.map +1 -1
- package/dist/esm/SearchUtils.d.ts +5 -5
- package/dist/esm/SearchUtils.js +11 -12
- package/dist/esm/SearchUtils.js.map +1 -1
- package/dist/esm/ServiceRequestTimeline.js +2 -0
- package/dist/esm/ServiceRequestTimeline.js.map +1 -1
- package/dist/esm/Timeline.js +12 -20
- package/dist/esm/Timeline.js.map +1 -1
- package/dist/esm/TimingInput.js +14 -17
- package/dist/esm/TimingInput.js.map +1 -1
- package/dist/esm/ValueSetAutocomplete.d.ts +10 -0
- package/dist/esm/ValueSetAutocomplete.js +57 -0
- package/dist/esm/ValueSetAutocomplete.js.map +1 -0
- package/dist/esm/auth/AuthenticationForm.js +12 -20
- package/dist/esm/auth/AuthenticationForm.js.map +1 -1
- package/dist/esm/auth/ChooseProfileForm.js +10 -10
- package/dist/esm/auth/ChooseProfileForm.js.map +1 -1
- package/dist/esm/auth/NewProjectForm.js +12 -15
- package/dist/esm/auth/NewProjectForm.js.map +1 -1
- package/dist/esm/auth/NewUserForm.js +25 -33
- package/dist/esm/auth/NewUserForm.js.map +1 -1
- package/dist/esm/auth/RegisterForm.d.ts +0 -1
- package/dist/esm/auth/RegisterForm.js.map +1 -1
- package/dist/esm/auth/SignInForm.d.ts +0 -1
- package/dist/esm/auth/SignInForm.js.map +1 -1
- package/dist/esm/defaulttheme.css +0 -51
- package/dist/esm/index.d.ts +3 -13
- package/dist/esm/index.js +4 -14
- 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/node_modules/tslib/tslib.es6.js +13 -1
- package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/esm/stories/{UploadButton.stories.d.ts → AttachmentButton.stories.d.ts} +1 -0
- package/dist/{cjs/stories/Select.stories.d.ts → esm/stories/PeriodInput.stories.d.ts} +1 -1
- package/dist/esm/stories/{Avatar.stories.d.ts → ResourceAvatar.stories.d.ts} +0 -0
- package/dist/esm/stories/ResourceForm.stories.d.ts +1 -0
- package/dist/{cjs/stories/FormSection.stories.d.ts → esm/stories/ResourceInput.stories.d.ts} +2 -2
- package/dist/esm/stories/SearchControl.stories.d.ts +1 -0
- package/dist/esm/styles.css +72 -1053
- package/dist/esm/utils/outcomes.d.ts +1 -0
- package/dist/esm/utils/outcomes.js +5 -1
- package/dist/esm/utils/outcomes.js.map +1 -1
- package/package.json +27 -19
- package/dist/cjs/Autocomplete.d.ts +0 -20
- package/dist/cjs/Avatar.d.ts +0 -12
- package/dist/cjs/Button.d.ts +0 -15
- package/dist/cjs/Checkbox.d.ts +0 -12
- package/dist/cjs/Dialog.d.ts +0 -10
- package/dist/cjs/Header.d.ts +0 -12
- package/dist/cjs/HeaderSearchInput.d.ts +0 -10
- package/dist/cjs/Input.d.ts +0 -22
- package/dist/cjs/InputRow.d.ts +0 -7
- package/dist/cjs/Loading.d.ts +0 -3
- package/dist/cjs/MenuItem.d.ts +0 -9
- package/dist/cjs/MenuSeparator.d.ts +0 -3
- package/dist/cjs/Popup.d.ts +0 -14
- package/dist/cjs/Select.d.ts +0 -16
- package/dist/cjs/SubMenu.d.ts +0 -7
- package/dist/cjs/TextArea.d.ts +0 -18
- package/dist/cjs/UploadButton.d.ts +0 -7
- package/dist/cjs/stories/Autocomplete.stories.d.ts +0 -9
- package/dist/cjs/stories/Button.stories.d.ts +0 -9
- package/dist/cjs/stories/Header.stories.d.ts +0 -8
- package/dist/cjs/stories/Loading.stories.d.ts +0 -5
- package/dist/esm/Autocomplete.d.ts +0 -20
- package/dist/esm/Autocomplete.js +0 -281
- package/dist/esm/Autocomplete.js.map +0 -1
- package/dist/esm/Avatar.d.ts +0 -12
- package/dist/esm/Avatar.js +0 -24
- package/dist/esm/Avatar.js.map +0 -1
- package/dist/esm/Button.d.ts +0 -15
- package/dist/esm/Button.js +0 -13
- package/dist/esm/Button.js.map +0 -1
- package/dist/esm/Checkbox.d.ts +0 -12
- package/dist/esm/Checkbox.js +0 -13
- package/dist/esm/Checkbox.js.map +0 -1
- package/dist/esm/Dialog.d.ts +0 -10
- package/dist/esm/Dialog.js +0 -43
- package/dist/esm/Dialog.js.map +0 -1
- package/dist/esm/Header.d.ts +0 -12
- package/dist/esm/Header.js +0 -99
- package/dist/esm/Header.js.map +0 -1
- package/dist/esm/HeaderSearchInput.d.ts +0 -10
- package/dist/esm/HeaderSearchInput.js +0 -181
- package/dist/esm/HeaderSearchInput.js.map +0 -1
- package/dist/esm/Input.d.ts +0 -22
- package/dist/esm/Input.js +0 -26
- package/dist/esm/Input.js.map +0 -1
- package/dist/esm/InputRow.d.ts +0 -7
- package/dist/esm/InputRow.js +0 -8
- package/dist/esm/InputRow.js.map +0 -1
- package/dist/esm/Loading.d.ts +0 -3
- package/dist/esm/Loading.js +0 -11
- package/dist/esm/Loading.js.map +0 -1
- package/dist/esm/MenuItem.d.ts +0 -9
- package/dist/esm/MenuItem.js +0 -8
- package/dist/esm/MenuItem.js.map +0 -1
- package/dist/esm/MenuSeparator.d.ts +0 -3
- package/dist/esm/MenuSeparator.js +0 -8
- package/dist/esm/MenuSeparator.js.map +0 -1
- package/dist/esm/Popup.d.ts +0 -14
- package/dist/esm/Popup.js +0 -78
- package/dist/esm/Popup.js.map +0 -1
- package/dist/esm/Select.d.ts +0 -16
- package/dist/esm/Select.js +0 -16
- package/dist/esm/Select.js.map +0 -1
- package/dist/esm/SubMenu.d.ts +0 -7
- package/dist/esm/SubMenu.js +0 -38
- package/dist/esm/SubMenu.js.map +0 -1
- package/dist/esm/TextArea.d.ts +0 -18
- package/dist/esm/TextArea.js +0 -16
- package/dist/esm/TextArea.js.map +0 -1
- package/dist/esm/UploadButton.d.ts +0 -7
- package/dist/esm/UploadButton.js.map +0 -1
- package/dist/esm/stories/Autocomplete.stories.d.ts +0 -9
- package/dist/esm/stories/Button.stories.d.ts +0 -9
- package/dist/esm/stories/Dialog.stories.d.ts +0 -5
- package/dist/esm/stories/FormSection.stories.d.ts +0 -6
- package/dist/esm/stories/Header.stories.d.ts +0 -8
- package/dist/esm/stories/Input.stories.d.ts +0 -6
- package/dist/esm/stories/Loading.stories.d.ts +0 -5
- package/dist/esm/stories/Select.stories.d.ts +0 -6
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { ActionIcon } from '@mantine/core';
|
|
2
|
+
import { IconCircleMinus, IconCirclePlus } from '@tabler/icons';
|
|
1
3
|
import React, { useState, useRef } from 'react';
|
|
2
|
-
import { Button } from './Button.js';
|
|
3
4
|
import { ResourcePropertyInput } from './ResourcePropertyInput.js';
|
|
4
5
|
import { killEvent } from './utils/dom.js';
|
|
5
6
|
|
|
@@ -15,8 +16,8 @@ function ResourceArrayInput(props) {
|
|
|
15
16
|
}
|
|
16
17
|
return (React.createElement("table", { style: { width: '100%', borderCollapse: 'collapse' } },
|
|
17
18
|
React.createElement("colgroup", null,
|
|
18
|
-
React.createElement("col", { width: "
|
|
19
|
-
React.createElement("col", { width: "
|
|
19
|
+
React.createElement("col", { width: "97%" }),
|
|
20
|
+
React.createElement("col", { width: "3%" })),
|
|
20
21
|
React.createElement("tbody", null,
|
|
21
22
|
values.map((v, index) => (React.createElement("tr", { key: `${index}-${values.length}` },
|
|
22
23
|
React.createElement("td", null,
|
|
@@ -26,21 +27,23 @@ function ResourceArrayInput(props) {
|
|
|
26
27
|
setValuesWrapper(copy);
|
|
27
28
|
} })),
|
|
28
29
|
React.createElement("td", { style: { textAlign: 'right' } },
|
|
29
|
-
React.createElement(
|
|
30
|
+
React.createElement(ActionIcon, { title: "Remove", size: "sm", onClick: (e) => {
|
|
30
31
|
killEvent(e);
|
|
31
32
|
const copy = [...valuesRef.current];
|
|
32
33
|
copy.splice(index, 1);
|
|
33
34
|
setValuesWrapper(copy);
|
|
34
|
-
} },
|
|
35
|
+
} },
|
|
36
|
+
React.createElement(IconCircleMinus, null)))))),
|
|
35
37
|
React.createElement("tr", null,
|
|
36
38
|
React.createElement("td", null),
|
|
37
39
|
React.createElement("td", { style: { textAlign: 'right' } },
|
|
38
|
-
React.createElement(
|
|
40
|
+
React.createElement(ActionIcon, { title: "Add", size: "sm", color: "green", onClick: (e) => {
|
|
39
41
|
killEvent(e);
|
|
40
42
|
const copy = [...valuesRef.current];
|
|
41
43
|
copy.push(undefined);
|
|
42
44
|
setValuesWrapper(copy);
|
|
43
|
-
} },
|
|
45
|
+
} },
|
|
46
|
+
React.createElement(IconCirclePlus, null)))))));
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
export { ResourceArrayInput };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceArrayInput.js","sources":["../../src/ResourceArrayInput.tsx"],"sourcesContent":["import { ElementDefinition } from '@medplum/fhirtypes';\nimport
|
|
1
|
+
{"version":3,"file":"ResourceArrayInput.js","sources":["../../src/ResourceArrayInput.tsx"],"sourcesContent":["import { ActionIcon } from '@mantine/core';\nimport { ElementDefinition } from '@medplum/fhirtypes';\nimport { IconCircleMinus, IconCirclePlus } from '@tabler/icons';\nimport React, { useRef, useState } from 'react';\nimport { ResourcePropertyInput } from './ResourcePropertyInput';\nimport { killEvent } from './utils/dom';\n\ninterface ResourceArrayInputProps {\n property: ElementDefinition;\n name: string;\n defaultValue?: any[];\n arrayElement?: boolean;\n onChange?: (value: any[]) => void;\n}\n\nexport function ResourceArrayInput(props: ResourceArrayInputProps): JSX.Element {\n const [values, setValues] = useState(\n props.defaultValue && Array.isArray(props.defaultValue) ? props.defaultValue : []\n );\n\n const valuesRef = useRef<any[]>();\n valuesRef.current = values;\n\n function setValuesWrapper(newValues: any[]): void {\n setValues(newValues);\n if (props.onChange) {\n props.onChange(newValues);\n }\n }\n\n return (\n <table style={{ width: '100%', borderCollapse: 'collapse' }}>\n <colgroup>\n <col width=\"97%\" />\n <col width=\"3%\" />\n </colgroup>\n <tbody>\n {values.map((v, index) => (\n <tr key={`${index}-${values.length}`}>\n <td>\n <ResourcePropertyInput\n arrayElement={true}\n property={props.property}\n name={props.name + '.' + index}\n defaultValue={v}\n onChange={(newValue: any) => {\n const copy = [...(valuesRef.current as any[])];\n copy[index] = newValue;\n setValuesWrapper(copy);\n }}\n />\n </td>\n <td style={{ textAlign: 'right' }}>\n <ActionIcon\n title=\"Remove\"\n size=\"sm\"\n onClick={(e: React.MouseEvent) => {\n killEvent(e);\n const copy = [...(valuesRef.current as any[])];\n copy.splice(index, 1);\n setValuesWrapper(copy);\n }}\n >\n <IconCircleMinus />\n </ActionIcon>\n </td>\n </tr>\n ))}\n <tr>\n <td></td>\n <td style={{ textAlign: 'right' }}>\n <ActionIcon\n title=\"Add\"\n size=\"sm\"\n color=\"green\"\n onClick={(e: React.MouseEvent) => {\n killEvent(e);\n const copy = [...(valuesRef.current as any[])];\n copy.push(undefined);\n setValuesWrapper(copy);\n }}\n >\n <IconCirclePlus />\n </ActionIcon>\n </td>\n </tr>\n </tbody>\n </table>\n );\n}\n"],"names":[],"mappings":";;;;;;AAeM,SAAU,kBAAkB,CAAC,KAA8B,EAAA;AAC/D,IAAA,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAClC,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,YAAY,GAAG,EAAE,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AC;yBACxB,EAAA;wBAED,KAAC,CAAA,aAAA,CAAA,cAAc,OAAG,CACP,CACV,CACF,CACC,CACF,EACR;AACJ;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AvatarProps } from '@mantine/core';
|
|
3
|
+
import { Reference, Resource } from '@medplum/fhirtypes';
|
|
4
|
+
export interface ResourceAvatarProps extends AvatarProps {
|
|
5
|
+
value?: Reference | Resource;
|
|
6
|
+
link?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function ResourceAvatar(props: ResourceAvatarProps): JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Avatar } from '@mantine/core';
|
|
2
|
+
import { getDisplayString, getImageSrc } from '@medplum/core';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { MedplumLink } from './MedplumLink.js';
|
|
5
|
+
import { useResource } from './useResource.js';
|
|
6
|
+
|
|
7
|
+
function ResourceAvatar(props) {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
const resource = useResource(props.value);
|
|
10
|
+
const text = resource ? getDisplayString(resource) : (_a = props.alt) !== null && _a !== void 0 ? _a : '';
|
|
11
|
+
const imageUrl = (_b = (resource && getImageSrc(resource))) !== null && _b !== void 0 ? _b : props.src;
|
|
12
|
+
const radius = (_c = props.radius) !== null && _c !== void 0 ? _c : 'xl';
|
|
13
|
+
const avatarProps = Object.assign({}, props);
|
|
14
|
+
delete avatarProps.value;
|
|
15
|
+
delete avatarProps.link;
|
|
16
|
+
if (props.link) {
|
|
17
|
+
return (React.createElement(MedplumLink, { to: resource },
|
|
18
|
+
React.createElement(Avatar, Object.assign({ src: imageUrl, alt: text, radius: radius }, avatarProps))));
|
|
19
|
+
}
|
|
20
|
+
return React.createElement(Avatar, Object.assign({ src: imageUrl, alt: text, radius: radius }, avatarProps));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { ResourceAvatar };
|
|
24
|
+
//# sourceMappingURL=ResourceAvatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourceAvatar.js","sources":["../../src/ResourceAvatar.tsx"],"sourcesContent":["import { Avatar, AvatarProps } from '@mantine/core';\nimport { getDisplayString, getImageSrc } from '@medplum/core';\nimport { Reference, Resource } from '@medplum/fhirtypes';\nimport React from 'react';\nimport { MedplumLink } from './MedplumLink';\nimport { useResource } from './useResource';\n\nexport interface ResourceAvatarProps extends AvatarProps {\n value?: Reference | Resource;\n link?: boolean;\n}\n\nexport function ResourceAvatar(props: ResourceAvatarProps): JSX.Element {\n const resource = useResource(props.value);\n const text = resource ? getDisplayString(resource) : props.alt ?? '';\n const imageUrl = (resource && getImageSrc(resource)) ?? props.src;\n const radius = props.radius ?? 'xl';\n\n const avatarProps = { ...props };\n delete avatarProps.value;\n delete avatarProps.link;\n\n if (props.link) {\n return (\n <MedplumLink to={resource}>\n <Avatar src={imageUrl} alt={text} radius={radius} {...avatarProps} />\n </MedplumLink>\n );\n }\n\n return <Avatar src={imageUrl} alt={text} radius={radius} {...avatarProps} />;\n}\n"],"names":[],"mappings":";;;;;;AAYM,SAAU,cAAc,CAAC,KAA0B,EAAA;;IACvD,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC1C,IAAA,MAAM,IAAI,GAAG,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAA,EAAA,GAAA,KAAK,CAAC,GAAG,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,EAAE,CAAC;AACrE,IAAA,MAAM,QAAQ,GAAG,CAAA,EAAA,IAAC,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,KAAK,CAAC,GAAG,CAAC;IAClE,MAAM,MAAM,GAAG,CAAA,EAAA,GAAA,KAAK,CAAC,MAAM,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,IAAI,CAAC;AAEpC,IAAA,MAAM,WAAW,GAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAQ,KAAK,CAAE,CAAC;IACjC,OAAO,WAAW,CAAC,KAAK,CAAC;IACzB,OAAO,WAAW,CAAC,IAAI,CAAC;IAExB,IAAI,KAAK,CAAC,IAAI,EAAE;AACd,QAAA,QACE,KAAC,CAAA,aAAA,CAAA,WAAW,EAAC,EAAA,EAAE,EAAE,QAAQ,EAAA;AACvB,YAAA,KAAA,CAAA,aAAA,CAAC,MAAM,EAAC,MAAA,CAAA,MAAA,CAAA,EAAA,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAA,EAAM,WAAW,CAAI,CAAA,CACzD,EACd;AACH,KAAA;AAED,IAAA,OAAO,oBAAC,MAAM,EAAA,MAAA,CAAA,MAAA,CAAA,EAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAM,EAAA,WAAW,EAAI,CAAC;AAC/E;;;;"}
|
|
@@ -3,7 +3,6 @@ import { Reference, Resource } from '@medplum/fhirtypes';
|
|
|
3
3
|
import './ResourceBadge.css';
|
|
4
4
|
export interface ResourceBadgeProps {
|
|
5
5
|
value?: Reference | Resource;
|
|
6
|
-
size?: 'xsmall' | 'small' | 'medium' | 'large';
|
|
7
6
|
link?: boolean;
|
|
8
7
|
}
|
|
9
8
|
export declare function ResourceBadge(props: ResourceBadgeProps): JSX.Element;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ResourceAvatar } from './ResourceAvatar.js';
|
|
3
3
|
import { ResourceName } from './ResourceName.js';
|
|
4
4
|
|
|
5
5
|
function ResourceBadge(props) {
|
|
6
|
-
var _a;
|
|
7
6
|
return (React.createElement("div", { className: "medplum-resource-badge" },
|
|
8
|
-
React.createElement(
|
|
7
|
+
React.createElement(ResourceAvatar, { size: 24, radius: 12, value: props.value, link: props.link }),
|
|
9
8
|
React.createElement(ResourceName, { value: props.value, link: props.link })));
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceBadge.js","sources":["../../src/ResourceBadge.tsx"],"sourcesContent":["import { Reference, Resource } from '@medplum/fhirtypes';\nimport React from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"ResourceBadge.js","sources":["../../src/ResourceBadge.tsx"],"sourcesContent":["import { Reference, Resource } from '@medplum/fhirtypes';\nimport React from 'react';\nimport { ResourceAvatar } from './ResourceAvatar';\nimport { ResourceName } from './ResourceName';\n\nimport './ResourceBadge.css';\n\nexport interface ResourceBadgeProps {\n value?: Reference | Resource;\n link?: boolean;\n}\n\nexport function ResourceBadge(props: ResourceBadgeProps): JSX.Element {\n return (\n <div className=\"medplum-resource-badge\">\n <ResourceAvatar size={24} radius={12} value={props.value} link={props.link} />\n <ResourceName value={props.value} link={props.link} />\n </div>\n );\n}\n"],"names":[],"mappings":";;;;AAYM,SAAU,aAAa,CAAC,KAAyB,EAAA;AACrD,IAAA,QACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,wBAAwB,EAAA;QACrC,KAAC,CAAA,aAAA,CAAA,cAAc,IAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAI,CAAA;AAC9E,QAAA,KAAA,CAAA,aAAA,CAAC,YAAY,EAAC,EAAA,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAI,CAAA,CAClD,EACN;AACJ;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Group } from '@mantine/core';
|
|
1
2
|
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { InputRow } from './InputRow.js';
|
|
3
3
|
import { MedplumLink } from './MedplumLink.js';
|
|
4
4
|
import { useMedplum } from './MedplumProvider.js';
|
|
5
5
|
import { ResourceBadge } from './ResourceBadge.js';
|
|
@@ -23,8 +23,8 @@ function ResourceBlame(props) {
|
|
|
23
23
|
React.createElement("table", { className: "medplum-blame" },
|
|
24
24
|
React.createElement("tbody", null, table.map((row, index) => (React.createElement("tr", { key: 'row-' + index, className: row.span > 0 ? 'start-row' : 'normal-row' },
|
|
25
25
|
row.span > 0 && (React.createElement("td", { className: "details", rowSpan: row.span },
|
|
26
|
-
React.createElement(
|
|
27
|
-
React.createElement(ResourceBadge, { value: row.meta.author,
|
|
26
|
+
React.createElement(Group, { spacing: "xs", grow: true, noWrap: true },
|
|
27
|
+
React.createElement(ResourceBadge, { value: row.meta.author, link: true }),
|
|
28
28
|
React.createElement(MedplumLink, { to: getVersionUrl(resource, row.meta.versionId) }, getTimeString(row.meta.lastUpdated))))),
|
|
29
29
|
React.createElement("td", { className: "line-number" }, index + 1),
|
|
30
30
|
React.createElement("td", { className: "line" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceBlame.js","sources":["../../src/ResourceBlame.tsx"],"sourcesContent":["import { Bundle, Resource, ResourceType } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"ResourceBlame.js","sources":["../../src/ResourceBlame.tsx"],"sourcesContent":["import { Group } from '@mantine/core';\nimport { Bundle, Resource, ResourceType } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport { MedplumLink } from './MedplumLink';\nimport { useMedplum } from './MedplumProvider';\nimport { ResourceBadge } from './ResourceBadge';\nimport { blame } from './utils/blame';\n\nimport './ResourceBlame.css';\n\nexport interface ResourceBlameProps {\n history?: Bundle;\n resourceType?: ResourceType;\n id?: string;\n}\n\nexport function ResourceBlame(props: ResourceBlameProps): JSX.Element {\n const medplum = useMedplum();\n const [value, setValue] = useState<Bundle | undefined>(props.history);\n\n useEffect(() => {\n if (!props.history && props.resourceType && props.id) {\n medplum.readHistory(props.resourceType, props.id).then(setValue).catch(console.log);\n }\n }, [medplum, props.history, props.resourceType, props.id]);\n\n if (!value) {\n return <div>Loading...</div>;\n }\n\n const resource = value.entry?.[0]?.resource as Resource;\n const table = blame(value);\n return (\n <div className=\"medplum-blame-container\">\n <table className=\"medplum-blame\">\n <tbody>\n {table.map((row, index) => (\n <tr key={'row-' + index} className={row.span > 0 ? 'start-row' : 'normal-row'}>\n {row.span > 0 && (\n <td className=\"details\" rowSpan={row.span}>\n <Group spacing=\"xs\" grow noWrap>\n <ResourceBadge value={row.meta.author} link={true} />\n <MedplumLink to={getVersionUrl(resource, row.meta.versionId as string)}>\n {getTimeString(row.meta.lastUpdated as string)}\n </MedplumLink>\n </Group>\n </td>\n )}\n <td className=\"line-number\">{index + 1}</td>\n <td className=\"line\">\n <pre className=\"line-pre\">{row.value}</pre>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n}\n\nfunction getVersionUrl(resource: Resource, versionId: string): string {\n return `/${resource.resourceType}/${resource.id}/_history/${versionId}`;\n}\n\nexport function getTimeString(lastUpdated: string): string {\n const seconds = Math.floor((Date.now() - Date.parse(lastUpdated)) / 1000);\n\n const years = Math.floor(seconds / 31536000);\n if (years > 0) {\n return pluralizeTime(years, 'year');\n }\n\n const months = Math.floor(seconds / 2592000);\n if (months > 0) {\n return pluralizeTime(months, 'month');\n }\n\n const days = Math.floor(seconds / 86400);\n if (days > 0) {\n return pluralizeTime(days, 'day');\n }\n\n const hours = Math.floor(seconds / 3600);\n if (hours > 0) {\n return pluralizeTime(hours, 'hour');\n }\n\n const minutes = Math.floor(seconds / 60);\n if (minutes > 0) {\n return pluralizeTime(minutes, 'minute');\n }\n\n return pluralizeTime(seconds, 'second');\n}\n\nfunction pluralizeTime(count: number, noun: string): string {\n return `${count}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CAAC,CAAC;AACzC,KAAA;AAED,IAAA,OAAO,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,aAAa,CAAC,KAAa,EAAE,IAAY,EAAA;AAChD,IAAA,OAAO,GAAG,KAAK,CAAA,CAAA,EAAI,KAAK,KAAK,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,MAAM,CAAC;AAC3D;;;;"}
|
package/dist/esm/ResourceForm.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { TextInput, Group, Button } from '@mantine/core';
|
|
1
2
|
import { capitalize } from '@medplum/core';
|
|
2
3
|
import React, { useState, useEffect } from 'react';
|
|
3
4
|
import { BackboneElementInput } from './BackboneElementInput.js';
|
|
4
|
-
import { Button } from './Button.js';
|
|
5
5
|
import { FormSection } from './FormSection.js';
|
|
6
|
-
import { Input } from './Input.js';
|
|
7
6
|
import { useMedplum } from './MedplumProvider.js';
|
|
8
7
|
import { useResource } from './useResource.js';
|
|
9
8
|
|
|
@@ -27,15 +26,16 @@ function ResourceForm(props) {
|
|
|
27
26
|
props.onSubmit(value);
|
|
28
27
|
}
|
|
29
28
|
} },
|
|
30
|
-
React.createElement(FormSection, { title: "Resource Type" },
|
|
31
|
-
React.createElement(
|
|
32
|
-
React.createElement(FormSection, { title: "ID" },
|
|
33
|
-
React.createElement(
|
|
29
|
+
React.createElement(FormSection, { title: "Resource Type", htmlFor: "resourceType", outcome: props.outcome },
|
|
30
|
+
React.createElement(TextInput, { name: "resourceType", defaultValue: value.resourceType, disabled: true })),
|
|
31
|
+
React.createElement(FormSection, { title: "ID", htmlFor: "id", outcome: props.outcome },
|
|
32
|
+
React.createElement(TextInput, { name: "id", defaultValue: value.id, disabled: true })),
|
|
34
33
|
React.createElement(BackboneElementInput, { typeName: value.resourceType, defaultValue: value, outcome: props.outcome, onChange: setValue }),
|
|
35
|
-
React.createElement(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
React.createElement(Group, null,
|
|
35
|
+
React.createElement(Button, { type: "submit" }, "OK"),
|
|
36
|
+
props.onDelete && (React.createElement(Button, { variant: "outline", color: "red", type: "button", onClick: () => {
|
|
37
|
+
props.onDelete(value);
|
|
38
|
+
} }, "Delete")))));
|
|
39
39
|
}
|
|
40
40
|
function setPropertyValue(obj, key, propName, elementDefinition, value) {
|
|
41
41
|
const types = elementDefinition.type;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceForm.js","sources":["../../src/ResourceForm.tsx"],"sourcesContent":["import { capitalize, IndexedStructureDefinition } from '@medplum/core';\nimport { ElementDefinition, ElementDefinitionType, OperationOutcome, Reference, Resource } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport { BackboneElementInput } from './BackboneElementInput';\nimport {
|
|
1
|
+
{"version":3,"file":"ResourceForm.js","sources":["../../src/ResourceForm.tsx"],"sourcesContent":["import { Button, Group, TextInput } from '@mantine/core';\nimport { capitalize, IndexedStructureDefinition } from '@medplum/core';\nimport { ElementDefinition, ElementDefinitionType, OperationOutcome, Reference, Resource } from '@medplum/fhirtypes';\nimport React, { useEffect, useState } from 'react';\nimport { BackboneElementInput } from './BackboneElementInput';\nimport { FormSection } from './FormSection';\nimport { useMedplum } from './MedplumProvider';\nimport { useResource } from './useResource';\n\nexport interface ResourceFormProps {\n defaultValue: Resource | Reference;\n outcome?: OperationOutcome;\n onSubmit: (resource: Resource) => void;\n onDelete?: (resource: Resource) => void;\n}\n\nexport function ResourceForm(props: ResourceFormProps): JSX.Element {\n const medplum = useMedplum();\n const defaultValue = useResource(props.defaultValue);\n const [schema, setSchema] = useState<IndexedStructureDefinition | undefined>();\n const [value, setValue] = useState<Resource | undefined>();\n\n useEffect(() => {\n if (defaultValue) {\n setValue(JSON.parse(JSON.stringify(defaultValue)));\n medplum.requestSchema(defaultValue.resourceType).then(setSchema).catch(console.log);\n }\n }, [medplum, defaultValue]);\n\n if (!schema || !value) {\n return <div>Loading...</div>;\n }\n\n return (\n <form\n noValidate\n autoComplete=\"off\"\n onSubmit={(e: React.FormEvent) => {\n e.preventDefault();\n if (props.onSubmit) {\n props.onSubmit(value);\n }\n }}\n >\n <FormSection title=\"Resource Type\" htmlFor=\"resourceType\" outcome={props.outcome}>\n <TextInput name=\"resourceType\" defaultValue={value.resourceType} disabled={true} />\n </FormSection>\n <FormSection title=\"ID\" htmlFor=\"id\" outcome={props.outcome}>\n <TextInput name=\"id\" defaultValue={value.id} disabled={true} />\n </FormSection>\n <BackboneElementInput\n typeName={value.resourceType}\n defaultValue={value}\n outcome={props.outcome}\n onChange={setValue}\n />\n <Group>\n <Button type=\"submit\">OK</Button>\n {props.onDelete && (\n <Button\n variant=\"outline\"\n color=\"red\"\n type=\"button\"\n onClick={() => {\n (props.onDelete as (resource: Resource) => void)(value);\n }}\n >\n Delete\n </Button>\n )}\n </Group>\n </form>\n );\n}\n\nexport function setPropertyValue(\n obj: any,\n key: string,\n propName: string,\n elementDefinition: ElementDefinition,\n value: any\n): any {\n const types = elementDefinition.type as ElementDefinitionType[];\n if (types.length > 1) {\n for (const type of types) {\n const compoundKey = key.replace('[x]', capitalize(type.code as string));\n if (compoundKey in obj) {\n delete obj[compoundKey];\n }\n }\n }\n obj[propName] = value;\n return obj;\n}\n"],"names":[],"mappings":";;;;;;;;AAgBM,SAAU,YAAY,CAAC,KAAwB,EAAA;AACnD,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACrD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,EAA0C,CAAC;IAC/E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAwB,CAAC;IAE3D,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,YAAY,EAAE;AAChB,YAAA,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAA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ource } from '@medplum/fhirtypes';
|
|
2
|
+
import { Reference, Resource, ResourceType } from '@medplum/fhirtypes';
|
|
3
3
|
export interface ResourceInputProps<T extends Resource = Resource> {
|
|
4
|
-
readonly resourceType:
|
|
4
|
+
readonly resourceType: ResourceType;
|
|
5
5
|
readonly name: string;
|
|
6
6
|
readonly defaultValue?: T | Reference<T>;
|
|
7
|
-
readonly className?: string;
|
|
8
7
|
readonly placeholder?: string;
|
|
9
8
|
readonly loadOnFocus?: boolean;
|
|
10
9
|
readonly onChange?: (value: T | undefined) => void;
|
|
@@ -1,41 +1,49 @@
|
|
|
1
|
-
import { __awaiter } from './node_modules/tslib/tslib.es6.js';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { __rest, __awaiter } from './node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { Group, Text, Autocomplete, Loader } from '@mantine/core';
|
|
3
|
+
import { getDisplayString } from '@medplum/core';
|
|
4
|
+
import React, { forwardRef, useState } from 'react';
|
|
5
5
|
import { useMedplum } from './MedplumProvider.js';
|
|
6
|
-
import {
|
|
6
|
+
import { ResourceAvatar } from './ResourceAvatar.js';
|
|
7
7
|
import { useResource } from './useResource.js';
|
|
8
8
|
|
|
9
9
|
function ResourceInput(props) {
|
|
10
10
|
const medplum = useMedplum();
|
|
11
|
-
const
|
|
12
|
-
const [value, setValue] = useState();
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const defaultValue = useResource(props.defaultValue);
|
|
12
|
+
const [value, setValue] = useState(defaultValue ? getDisplayString(defaultValue) : '');
|
|
13
|
+
const [loading, setLoading] = useState(false);
|
|
14
|
+
const [data, setData] = useState([]);
|
|
15
|
+
function loadValues(input) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
setLoading(true);
|
|
18
|
+
const resources = yield medplum.searchResources(props.resourceType, 'name=' + encodeURIComponent(input) + '&_count=10');
|
|
19
|
+
setData(resources.map((resource) => ({ value: getDisplayString(resource), resource })));
|
|
20
|
+
setLoading(false);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function handleChange(val) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
setValue(val);
|
|
26
|
+
return loadValues(val);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function handleSelect(item) {
|
|
30
|
+
setValue(item.value);
|
|
31
|
+
setData([]);
|
|
20
32
|
if (props.onChange) {
|
|
21
|
-
props.onChange(
|
|
33
|
+
props.onChange(item.resource);
|
|
22
34
|
}
|
|
23
35
|
}
|
|
24
|
-
return (React.createElement(Autocomplete, {
|
|
25
|
-
return medplum
|
|
26
|
-
.search(resourceTypeRef.current, 'name=' + encodeURIComponent(input) + '&_count=10')
|
|
27
|
-
.then((bundle) => bundle.entry.map((entry) => entry.resource));
|
|
28
|
-
}), getId: (item) => {
|
|
29
|
-
return item.id;
|
|
30
|
-
}, getIcon: (item) => React.createElement(Avatar, { value: item }), getDisplay: (item) => React.createElement(ResourceName, { value: item }), getHelpText: (item) => {
|
|
31
|
-
if (item.resourceType === 'Patient' && item.birthDate) {
|
|
32
|
-
return 'DoB: ' + item.birthDate;
|
|
33
|
-
}
|
|
34
|
-
return undefined;
|
|
35
|
-
}, name: props.name, defaultValue: value ? [value] : undefined, className: props.className, placeholder: props.placeholder, loadOnFocus: props.loadOnFocus, onChange: (items) => {
|
|
36
|
-
setValueWrapper(items.length > 0 ? items[0] : undefined);
|
|
37
|
-
} }));
|
|
36
|
+
return (React.createElement(Autocomplete, { itemComponent: ItemComponent, value: value, data: data, placeholder: props.placeholder, onFocus: () => loadValues(value), onChange: handleChange, onItemSubmit: handleSelect, rightSection: loading ? React.createElement(Loader, { size: 16 }) : null }));
|
|
38
37
|
}
|
|
38
|
+
const ItemComponent = forwardRef((_a, ref) => {
|
|
39
|
+
var { value, resource } = _a, others = __rest(_a, ["value", "resource"]);
|
|
40
|
+
return (React.createElement("div", Object.assign({ ref: ref }, others),
|
|
41
|
+
React.createElement(Group, { noWrap: true },
|
|
42
|
+
React.createElement(ResourceAvatar, { value: resource }),
|
|
43
|
+
React.createElement("div", null,
|
|
44
|
+
React.createElement(Text, null, value),
|
|
45
|
+
React.createElement(Text, { size: "xs", color: "dimmed" }, resource.birthDate)))));
|
|
46
|
+
});
|
|
39
47
|
|
|
40
48
|
export { ResourceInput };
|
|
41
49
|
//# sourceMappingURL=ResourceInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceInput.js","sources":["../../src/ResourceInput.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"ResourceInput.js","sources":["../../src/ResourceInput.tsx"],"sourcesContent":["import { Autocomplete, AutocompleteItem, Group, Loader, Text } from '@mantine/core';\nimport { getDisplayString } from '@medplum/core';\nimport { Patient, Reference, Resource, ResourceType } from '@medplum/fhirtypes';\nimport React, { forwardRef, useState } from 'react';\nimport { useMedplum } from './MedplumProvider';\nimport { ResourceAvatar } from './ResourceAvatar';\nimport { useResource } from './useResource';\n\nexport interface ResourceInputProps<T extends Resource = Resource> {\n readonly resourceType: ResourceType;\n readonly name: string;\n readonly defaultValue?: T | Reference<T>;\n readonly placeholder?: string;\n readonly loadOnFocus?: boolean;\n readonly onChange?: (value: T | undefined) => void;\n}\n\nexport function ResourceInput<T extends Resource = Resource>(props: ResourceInputProps<T>): JSX.Element {\n const medplum = useMedplum();\n const defaultValue = useResource(props.defaultValue);\n const [value, setValue] = useState<string>(defaultValue ? getDisplayString(defaultValue) : '');\n const [loading, setLoading] = useState(false);\n const [data, setData] = useState<AutocompleteItem[]>([]);\n\n async function loadValues(input: string): Promise<void> {\n setLoading(true);\n const resources = await medplum.searchResources(\n props.resourceType,\n 'name=' + encodeURIComponent(input) + '&_count=10'\n );\n setData(resources.map((resource) => ({ value: getDisplayString(resource), resource })));\n setLoading(false);\n }\n\n async function handleChange(val: string): Promise<void> {\n setValue(val);\n return loadValues(val);\n }\n\n function handleSelect(item: AutocompleteItem): void {\n setValue(item.value);\n setData([]);\n if (props.onChange) {\n props.onChange(item.resource);\n }\n }\n\n return (\n <Autocomplete\n itemComponent={ItemComponent}\n value={value}\n data={data}\n placeholder={props.placeholder}\n onFocus={() => loadValues(value)}\n onChange={handleChange}\n onItemSubmit={handleSelect}\n rightSection={loading ? <Loader size={16} /> : null}\n />\n );\n}\n\nconst ItemComponent = forwardRef<HTMLDivElement, any>(({ value, resource, ...others }: any, ref) => {\n return (\n <div ref={ref} {...others}>\n <Group noWrap>\n <ResourceAvatar value={resource} />\n <div>\n <Text>{value}</Text>\n <Text size=\"xs\" color=\"dimmed\">\n {(resource as Patient).birthDate}\n </Text>\n </div>\n </Group>\n </div>\n );\n});\n"],"names":[],"mappings":";;;;;;;;AAiBM,SAAU,aAAa,CAAgC,KAA4B,EAAA;AACvF,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACrD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAS,YAAY,GAAG,gBAAgB,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC;IAC/F,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAqB,EAAE,CAAC,CAAC;IAEzD,SAAe,UAAU,CAAC,KAAa,EAAA;;YACrC,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,eAAe,CAC7C,KAAK,CAAC,YAAY,EAClB,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,YAAY,CACnD,CAAC;YACF,OAAO,CAAC,SAAS,CAAC,GAAG,CAA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AA,EAAA,GAAG,EAAE,GAAG,IAAM,MAAM,CAAA;QACvB,KAAC,CAAA,aAAA,CAAA,KAAK,IAAC,MAAM,EAAA,IAAA,EAAA;AACX,YAAA,KAAA,CAAA,aAAA,CAAC,cAAc,EAAA,EAAC,KAAK,EAAE,QAAQ,EAAI,CAAA;AACnC,YAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,IAAA;gBACE,KAAC,CAAA,aAAA,CAAA,IAAI,EAAE,IAAA,EAAA,KAAK,CAAQ;AACpB,gBAAA,KAAA,CAAA,aAAA,CAAC,IAAI,EAAC,EAAA,IAAI,EAAC,IAAI,EAAC,KAAK,EAAC,QAAQ,EAC1B,EAAA,QAAoB,CAAC,SAAS,CAC3B,CACH,CACA,CACJ,EACN;AACJ,CAAC,CAAC;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Group, NativeSelect, Textarea, Checkbox, TextInput } from '@mantine/core';
|
|
1
2
|
import { capitalize, buildTypeName, PropertyType } from '@medplum/core';
|
|
2
3
|
import React, { useState } from 'react';
|
|
3
4
|
import { AddressInput } from './AddressInput.js';
|
|
@@ -5,7 +6,6 @@ import { AnnotationInput } from './AnnotationInput.js';
|
|
|
5
6
|
import { AttachmentArrayInput } from './AttachmentArrayInput.js';
|
|
6
7
|
import { AttachmentInput } from './AttachmentInput.js';
|
|
7
8
|
import { BackboneElementInput } from './BackboneElementInput.js';
|
|
8
|
-
import { Checkbox } from './Checkbox.js';
|
|
9
9
|
import { CodeableConceptInput } from './CodeableConceptInput.js';
|
|
10
10
|
import { CodeInput } from './CodeInput.js';
|
|
11
11
|
import { CodingInput } from './CodingInput.js';
|
|
@@ -15,17 +15,14 @@ import { DateTimeInput } from './DateTimeInput.js';
|
|
|
15
15
|
import { ExtensionInput } from './ExtensionInput.js';
|
|
16
16
|
import { HumanNameInput } from './HumanNameInput.js';
|
|
17
17
|
import { IdentifierInput } from './IdentifierInput.js';
|
|
18
|
-
import { Input } from './Input.js';
|
|
19
|
-
import { InputRow } from './InputRow.js';
|
|
20
18
|
import { PeriodInput } from './PeriodInput.js';
|
|
21
19
|
import { QuantityInput } from './QuantityInput.js';
|
|
22
20
|
import { RangeInput } from './RangeInput.js';
|
|
23
21
|
import { RatioInput } from './RatioInput.js';
|
|
24
22
|
import { ReferenceInput } from './ReferenceInput.js';
|
|
25
23
|
import { ResourceArrayInput } from './ResourceArrayInput.js';
|
|
26
|
-
import { Select } from './Select.js';
|
|
27
|
-
import { TextArea } from './TextArea.js';
|
|
28
24
|
import { TimingInput } from './TimingInput.js';
|
|
25
|
+
import { getErrorsForInput } from './utils/outcomes.js';
|
|
29
26
|
|
|
30
27
|
function ResourcePropertyInput(props) {
|
|
31
28
|
var _a, _b, _c;
|
|
@@ -57,10 +54,13 @@ function ElementDefinitionInputSelector(props) {
|
|
|
57
54
|
initialPropertyType = propertyTypes[0];
|
|
58
55
|
}
|
|
59
56
|
const [selectedType, setSelectedType] = useState(initialPropertyType);
|
|
60
|
-
return (React.createElement(
|
|
61
|
-
React.createElement(
|
|
62
|
-
setSelectedType(propertyTypes.find((type) => type.code ===
|
|
63
|
-
}
|
|
57
|
+
return (React.createElement(Group, { spacing: "xs", grow: true, noWrap: true },
|
|
58
|
+
React.createElement(NativeSelect, { style: { width: '200px' }, defaultValue: selectedType === null || selectedType === void 0 ? void 0 : selectedType.code, onChange: (e) => {
|
|
59
|
+
setSelectedType(propertyTypes.find((type) => type.code === e.currentTarget.value));
|
|
60
|
+
}, data: propertyTypes.map((type) => ({
|
|
61
|
+
value: type.code,
|
|
62
|
+
label: type.code,
|
|
63
|
+
})) }),
|
|
64
64
|
React.createElement(ElementDefinitionTypeInput, Object.assign({}, props, { elementDefinitionType: selectedType, onChange: (newValue) => {
|
|
65
65
|
if (props.onChange) {
|
|
66
66
|
props.onChange(newValue, props.name.replace('[x]', capitalize(selectedType.code)));
|
|
@@ -82,31 +82,43 @@ function ElementDefinitionTypeInput(props) {
|
|
|
82
82
|
case PropertyType.time:
|
|
83
83
|
case PropertyType.uri:
|
|
84
84
|
case PropertyType.url:
|
|
85
|
-
return (React.createElement(
|
|
85
|
+
return (React.createElement(TextInput, { id: name, name: name, "data-testid": name, defaultValue: value, onChange: (e) => {
|
|
86
|
+
if (props.onChange) {
|
|
87
|
+
props.onChange(e.currentTarget.value);
|
|
88
|
+
}
|
|
89
|
+
}, error: getErrorsForInput(props.outcome, name) }));
|
|
86
90
|
case PropertyType.date:
|
|
87
|
-
return (React.createElement(
|
|
91
|
+
return (React.createElement(TextInput, { type: "date", id: name, name: name, "data-testid": name, defaultValue: value, onChange: (e) => {
|
|
92
|
+
if (props.onChange) {
|
|
93
|
+
props.onChange(e.currentTarget.value);
|
|
94
|
+
}
|
|
95
|
+
}, error: getErrorsForInput(props.outcome, name) }));
|
|
88
96
|
case PropertyType.dateTime:
|
|
89
97
|
case PropertyType.instant:
|
|
90
|
-
return
|
|
98
|
+
return React.createElement(DateTimeInput, { name: name, defaultValue: value, onChange: props.onChange, outcome: props.outcome });
|
|
91
99
|
case PropertyType.decimal:
|
|
92
100
|
case PropertyType.integer:
|
|
93
101
|
case PropertyType.positiveInt:
|
|
94
102
|
case PropertyType.unsignedInt:
|
|
95
|
-
return (React.createElement(
|
|
103
|
+
return (React.createElement(TextInput, { type: "number", step: propertyType === PropertyType.decimal ? 'any' : '1', id: name, name: name, "data-testid": name, defaultValue: value, onChange: (e) => {
|
|
96
104
|
if (props.onChange) {
|
|
97
|
-
props.onChange(
|
|
105
|
+
props.onChange(e.currentTarget.valueAsNumber);
|
|
98
106
|
}
|
|
99
|
-
}
|
|
107
|
+
} }));
|
|
100
108
|
case PropertyType.code:
|
|
101
109
|
return React.createElement(CodeInput, { property: property, name: name, defaultValue: value, onChange: props.onChange });
|
|
102
110
|
case PropertyType.boolean:
|
|
103
|
-
return (React.createElement(Checkbox, { name: name, testid: name,
|
|
111
|
+
return (React.createElement(Checkbox, { id: name, name: name, "data-testid": name, defaultChecked: !!value, onChange: (e) => {
|
|
104
112
|
if (props.onChange) {
|
|
105
|
-
props.onChange(
|
|
113
|
+
props.onChange(e.currentTarget.checked);
|
|
106
114
|
}
|
|
107
115
|
} }));
|
|
108
116
|
case PropertyType.markdown:
|
|
109
|
-
return React.createElement(
|
|
117
|
+
return (React.createElement(Textarea, { id: name, name: name, "data-testid": name, defaultValue: value, onChange: (e) => {
|
|
118
|
+
if (props.onChange) {
|
|
119
|
+
props.onChange(e.currentTarget.value);
|
|
120
|
+
}
|
|
121
|
+
} }));
|
|
110
122
|
// 2.24.0.2 Complex Types
|
|
111
123
|
// https://www.hl7.org/fhir/datatypes.html#complex
|
|
112
124
|
case PropertyType.Address:
|