@medplum/react 0.9.18 → 0.9.19
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/defaulttheme.css +9 -7
- package/dist/cjs/index.js +135 -102
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/cjs/styles.css +75 -59
- package/dist/esm/defaulttheme.css +9 -7
- package/dist/esm/index.js +135 -104
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/styles.css +75 -59
- package/dist/types/BackboneElementInput.d.ts +2 -3
- package/dist/types/Checkbox.d.ts +12 -0
- package/dist/types/CheckboxFormSection.d.ts +9 -0
- package/dist/types/TextArea.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +5 -5
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
--medplum-navbar-textbox: rgba(255, 255, 255, 0.2);
|
|
7
7
|
--medplum-navbar-placeholder: rgba(255, 255, 255, 0.6);
|
|
8
8
|
--medplum-shadow: rgba(0, 0, 0, 0.1);
|
|
9
|
-
/*
|
|
9
|
+
/* fonts */
|
|
10
|
+
--medplum-font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;
|
|
11
|
+
--medplum-monospace-font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
|
|
10
12
|
--medplum-font-small: 12px;
|
|
11
13
|
--medplum-font-normal: 13px;
|
|
12
14
|
--medplum-font-big: 18px;
|
|
@@ -184,7 +186,7 @@
|
|
|
184
186
|
|
|
185
187
|
html {
|
|
186
188
|
height: 100%;
|
|
187
|
-
font-family: -
|
|
189
|
+
font-family: var(--medplum-font-family);
|
|
188
190
|
position: relative;
|
|
189
191
|
}
|
|
190
192
|
|
|
@@ -216,14 +218,14 @@ input[type='tel'],
|
|
|
216
218
|
input[type='text'],
|
|
217
219
|
input[type='time'],
|
|
218
220
|
input[type='url'],
|
|
219
|
-
select
|
|
220
|
-
|
|
221
|
+
select,
|
|
222
|
+
textarea {
|
|
223
|
+
font-family: var(--medplum-font-family);
|
|
221
224
|
}
|
|
222
225
|
|
|
223
226
|
code,
|
|
224
|
-
pre
|
|
225
|
-
|
|
226
|
-
font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
|
|
227
|
+
pre {
|
|
228
|
+
font-family: var(--medplum-monospace-font-family);
|
|
227
229
|
}
|
|
228
230
|
|
|
229
231
|
a {
|
package/dist/cjs/index.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function Input(props) {
|
|
25
|
-
const className = 'medplum-input';
|
|
25
|
+
const className = 'medplum-input';
|
|
26
26
|
const issues = getIssuesForExpression(props.outcome, props.name);
|
|
27
27
|
const invalid = issues && issues.length > 0;
|
|
28
28
|
return (React__default["default"].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) => {
|
|
@@ -287,7 +287,7 @@
|
|
|
287
287
|
props.onChange(newValues);
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
-
return (React__default["default"].createElement("table",
|
|
290
|
+
return (React__default["default"].createElement("table", { style: { width: '100%' } },
|
|
291
291
|
React__default["default"].createElement("colgroup", null,
|
|
292
292
|
React__default["default"].createElement("col", { width: "90%" }),
|
|
293
293
|
React__default["default"].createElement("col", { width: "10%" })),
|
|
@@ -713,6 +713,14 @@
|
|
|
713
713
|
.join('');
|
|
714
714
|
}
|
|
715
715
|
|
|
716
|
+
function CheckboxFormSection(props) {
|
|
717
|
+
return (React__default["default"].createElement("div", { className: "medplum-checkbox-form-section" },
|
|
718
|
+
React__default["default"].createElement("div", { className: "medplum-checkbox-form-section-checkbox-container" }, props.children),
|
|
719
|
+
React__default["default"].createElement("div", { className: "medplum-checkbox-form-section-details-container" },
|
|
720
|
+
React__default["default"].createElement("label", { htmlFor: props.htmlFor }, props.title),
|
|
721
|
+
React__default["default"].createElement("p", null, props.description))));
|
|
722
|
+
}
|
|
723
|
+
|
|
716
724
|
const DEFAULT_IGNORED_PROPERTIES = [
|
|
717
725
|
'meta',
|
|
718
726
|
'implicitRules',
|
|
@@ -726,9 +734,9 @@
|
|
|
726
734
|
function FormSection(props) {
|
|
727
735
|
const issues = getIssuesForExpression(props.outcome, props.htmlFor);
|
|
728
736
|
const invalid = issues && issues.length > 0;
|
|
729
|
-
return (React__default["default"].createElement("fieldset",
|
|
737
|
+
return (React__default["default"].createElement("fieldset", { className: "medplum-form-section" },
|
|
730
738
|
props.title && React__default["default"].createElement("label", { htmlFor: props.htmlFor }, props.title),
|
|
731
|
-
props.description && React__default["default"].createElement("
|
|
739
|
+
props.description && React__default["default"].createElement("p", null, props.description),
|
|
732
740
|
props.children,
|
|
733
741
|
invalid && (React__default["default"].createElement("div", { id: props.htmlFor + '-errors', className: "medplum-input-error" }, issues === null || issues === void 0 ? void 0 : issues.map((issue) => {
|
|
734
742
|
var _a, _b;
|
|
@@ -736,6 +744,50 @@
|
|
|
736
744
|
})))));
|
|
737
745
|
}
|
|
738
746
|
|
|
747
|
+
function ResourceForm(props) {
|
|
748
|
+
const medplum = useMedplum();
|
|
749
|
+
const defaultValue = useResource(props.defaultValue);
|
|
750
|
+
const [schema, setSchema] = React.useState();
|
|
751
|
+
const [value, setValue] = React.useState();
|
|
752
|
+
React.useEffect(() => {
|
|
753
|
+
if (defaultValue) {
|
|
754
|
+
setValue(JSON.parse(JSON.stringify(defaultValue)));
|
|
755
|
+
medplum.requestSchema(defaultValue.resourceType).then(setSchema);
|
|
756
|
+
}
|
|
757
|
+
}, [medplum, defaultValue]);
|
|
758
|
+
if (!schema || !value) {
|
|
759
|
+
return React__default["default"].createElement("div", null, "Loading...");
|
|
760
|
+
}
|
|
761
|
+
return (React__default["default"].createElement("form", { noValidate: true, autoComplete: "off", onSubmit: (e) => {
|
|
762
|
+
e.preventDefault();
|
|
763
|
+
if (props.onSubmit) {
|
|
764
|
+
props.onSubmit(value);
|
|
765
|
+
}
|
|
766
|
+
} },
|
|
767
|
+
React__default["default"].createElement(FormSection, { title: "Resource Type" },
|
|
768
|
+
React__default["default"].createElement(Input, { name: "resourceType", defaultValue: value.resourceType, disabled: true })),
|
|
769
|
+
React__default["default"].createElement(FormSection, { title: "ID" },
|
|
770
|
+
React__default["default"].createElement(Input, { name: "id", defaultValue: value.id, disabled: true })),
|
|
771
|
+
React__default["default"].createElement(BackboneElementInput, { typeName: value.resourceType, defaultValue: value, outcome: props.outcome, onChange: setValue }),
|
|
772
|
+
React__default["default"].createElement(Button, { type: "submit", size: "large" }, "OK"),
|
|
773
|
+
props.onDelete && (React__default["default"].createElement(Button, { type: "button", size: "large", onClick: () => {
|
|
774
|
+
props.onDelete(value);
|
|
775
|
+
} }, "Delete"))));
|
|
776
|
+
}
|
|
777
|
+
function setPropertyValue(obj, key, propName, elementDefinition, value) {
|
|
778
|
+
const types = elementDefinition.type;
|
|
779
|
+
if (types.length > 1) {
|
|
780
|
+
for (const type of types) {
|
|
781
|
+
const compoundKey = key.replace('[x]', core.capitalize(type.code));
|
|
782
|
+
if (compoundKey in obj) {
|
|
783
|
+
delete obj[compoundKey];
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
obj[propName] = value;
|
|
788
|
+
return obj;
|
|
789
|
+
}
|
|
790
|
+
|
|
739
791
|
function DescriptionList(props) {
|
|
740
792
|
return React__default["default"].createElement("dl", { className: 'medplum-description-list' + (props.compact ? ' compact' : '') }, props.children);
|
|
741
793
|
}
|
|
@@ -1037,6 +1089,15 @@
|
|
|
1037
1089
|
return (React__default["default"].createElement(Input, { name: props.name, type: "text", placeholder: "Annotation text", defaultValue: value.text, onChange: setText }));
|
|
1038
1090
|
}
|
|
1039
1091
|
|
|
1092
|
+
function Checkbox(props) {
|
|
1093
|
+
const className = 'medplum-checkbox';
|
|
1094
|
+
return (React__default["default"].createElement("input", { id: props.name, name: props.name, className: className, type: "checkbox", value: "true", defaultChecked: !!props.defaultValue, required: props.required, ref: props.inputRef, "data-testid": props.testid, disabled: props.disabled, onChange: (e) => {
|
|
1095
|
+
if (props.onChange) {
|
|
1096
|
+
props.onChange(e.currentTarget.checked);
|
|
1097
|
+
}
|
|
1098
|
+
} }));
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1040
1101
|
function CodeableConceptInput(props) {
|
|
1041
1102
|
const medplum = useMedplum();
|
|
1042
1103
|
let defaultValue = undefined;
|
|
@@ -1223,7 +1284,7 @@
|
|
|
1223
1284
|
}
|
|
1224
1285
|
|
|
1225
1286
|
function TextArea(props) {
|
|
1226
|
-
const className = 'medplum-textarea';
|
|
1287
|
+
const className = 'medplum-textarea' + (props.monospace ? ' monospace' : '');
|
|
1227
1288
|
const issues = getIssuesForExpression(props.outcome, props.name);
|
|
1228
1289
|
const invalid = issues && issues.length > 0;
|
|
1229
1290
|
return (React__default["default"].createElement("textarea", { id: props.name, name: props.name, className: className, defaultValue: props.defaultValue || '', required: props.required, 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, style: props.style, onChange: (e) => {
|
|
@@ -1234,7 +1295,7 @@
|
|
|
1234
1295
|
}
|
|
1235
1296
|
|
|
1236
1297
|
function ExtensionInput(props) {
|
|
1237
|
-
return (React__default["default"].createElement(TextArea, { testid: "extension-input", name: props.name, defaultValue: core.stringify(props.defaultValue), onChange: (newValue) => {
|
|
1298
|
+
return (React__default["default"].createElement(TextArea, { testid: "extension-input", name: props.name, defaultValue: core.stringify(props.defaultValue), monospace: true, onChange: (newValue) => {
|
|
1238
1299
|
if (props.onChange) {
|
|
1239
1300
|
props.onChange(JSON.parse(newValue));
|
|
1240
1301
|
}
|
|
@@ -1457,35 +1518,34 @@
|
|
|
1457
1518
|
props.onChange(newValues);
|
|
1458
1519
|
}
|
|
1459
1520
|
}
|
|
1460
|
-
return (React__default["default"].createElement("
|
|
1461
|
-
React__default["default"].createElement("
|
|
1462
|
-
React__default["default"].createElement("
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
React__default["default"].createElement("
|
|
1466
|
-
|
|
1467
|
-
React__default["default"].createElement(
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
React__default["default"].createElement(
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
React__default["default"].createElement("
|
|
1481
|
-
|
|
1482
|
-
React__default["default"].createElement(
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
} }, "Add")))))));
|
|
1521
|
+
return (React__default["default"].createElement("table", { style: { width: '100%', borderCollapse: 'collapse' } },
|
|
1522
|
+
React__default["default"].createElement("colgroup", null,
|
|
1523
|
+
React__default["default"].createElement("col", { width: "90%" }),
|
|
1524
|
+
React__default["default"].createElement("col", { width: "10%" })),
|
|
1525
|
+
React__default["default"].createElement("tbody", null,
|
|
1526
|
+
values.map((v, index) => (React__default["default"].createElement("tr", { key: `${index}-${values.length}` },
|
|
1527
|
+
React__default["default"].createElement("td", null,
|
|
1528
|
+
React__default["default"].createElement(ResourcePropertyInput, { arrayElement: true, property: props.property, name: props.name + '.' + index, defaultValue: v, onChange: (newValue) => {
|
|
1529
|
+
const copy = [...valuesRef.current];
|
|
1530
|
+
copy[index] = newValue;
|
|
1531
|
+
setValuesWrapper(copy);
|
|
1532
|
+
} })),
|
|
1533
|
+
React__default["default"].createElement("td", { style: { textAlign: 'right' } },
|
|
1534
|
+
React__default["default"].createElement(Button, { onClick: (e) => {
|
|
1535
|
+
killEvent(e);
|
|
1536
|
+
const copy = [...valuesRef.current];
|
|
1537
|
+
copy.splice(index, 1);
|
|
1538
|
+
setValuesWrapper(copy);
|
|
1539
|
+
} }, "Remove"))))),
|
|
1540
|
+
React__default["default"].createElement("tr", null,
|
|
1541
|
+
React__default["default"].createElement("td", null),
|
|
1542
|
+
React__default["default"].createElement("td", { style: { textAlign: 'right' } },
|
|
1543
|
+
React__default["default"].createElement(Button, { onClick: (e) => {
|
|
1544
|
+
killEvent(e);
|
|
1545
|
+
const copy = [...valuesRef.current];
|
|
1546
|
+
copy.push(undefined);
|
|
1547
|
+
setValuesWrapper(copy);
|
|
1548
|
+
} }, "Add"))))));
|
|
1489
1549
|
}
|
|
1490
1550
|
|
|
1491
1551
|
function ResourcePropertyInput(props) {
|
|
@@ -1529,6 +1589,7 @@
|
|
|
1529
1589
|
} }))));
|
|
1530
1590
|
}
|
|
1531
1591
|
function ElementDefinitionTypeInput(props) {
|
|
1592
|
+
var _a;
|
|
1532
1593
|
const property = props.property;
|
|
1533
1594
|
const propertyType = props.elementDefinitionType.code;
|
|
1534
1595
|
const name = props.name;
|
|
@@ -1560,7 +1621,11 @@
|
|
|
1560
1621
|
case core.PropertyType.code:
|
|
1561
1622
|
return React__default["default"].createElement(CodeInput, { property: property, name: name, defaultValue: value, onChange: props.onChange });
|
|
1562
1623
|
case core.PropertyType.boolean:
|
|
1563
|
-
return (React__default["default"].createElement(
|
|
1624
|
+
return (React__default["default"].createElement(Checkbox, { name: name, testid: name, defaultValue: !!value, onChange: (newValue) => {
|
|
1625
|
+
if (props.onChange) {
|
|
1626
|
+
props.onChange(newValue);
|
|
1627
|
+
}
|
|
1628
|
+
} }));
|
|
1564
1629
|
case core.PropertyType.markdown:
|
|
1565
1630
|
return React__default["default"].createElement(TextArea, { name: name, testid: name, defaultValue: value, onChange: props.onChange });
|
|
1566
1631
|
// 2.24.0.2 Complex Types
|
|
@@ -1594,7 +1659,7 @@
|
|
|
1594
1659
|
case core.PropertyType.Reference:
|
|
1595
1660
|
return (React__default["default"].createElement(ReferenceInput, { name: name, defaultValue: value, targetTypes: getTargetTypes(property), onChange: props.onChange }));
|
|
1596
1661
|
default:
|
|
1597
|
-
return (React__default["default"].createElement(BackboneElementInput, {
|
|
1662
|
+
return (React__default["default"].createElement(BackboneElementInput, { typeName: core.buildTypeName((_a = property.path) === null || _a === void 0 ? void 0 : _a.split('.')), defaultValue: value, onChange: props.onChange, outcome: props.outcome }));
|
|
1598
1663
|
}
|
|
1599
1664
|
}
|
|
1600
1665
|
function getTargetTypes(property) {
|
|
@@ -1602,65 +1667,8 @@
|
|
|
1602
1667
|
return (_c = (_b = (_a = property === null || property === void 0 ? void 0 : property.type) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.targetProfile) === null || _c === void 0 ? void 0 : _c.map((p) => p.split('/').pop());
|
|
1603
1668
|
}
|
|
1604
1669
|
|
|
1605
|
-
function ResourceForm(props) {
|
|
1606
|
-
const medplum = useMedplum();
|
|
1607
|
-
const defaultValue = useResource(props.defaultValue);
|
|
1608
|
-
const [schema, setSchema] = React.useState();
|
|
1609
|
-
const [value, setValue] = React.useState();
|
|
1610
|
-
React.useEffect(() => {
|
|
1611
|
-
if (defaultValue) {
|
|
1612
|
-
setValue(JSON.parse(JSON.stringify(defaultValue)));
|
|
1613
|
-
medplum.requestSchema(defaultValue.resourceType).then(setSchema);
|
|
1614
|
-
}
|
|
1615
|
-
}, [medplum, defaultValue]);
|
|
1616
|
-
if (!schema || !value) {
|
|
1617
|
-
return React__default["default"].createElement("div", null, "Loading...");
|
|
1618
|
-
}
|
|
1619
|
-
const typeSchema = schema.types[value.resourceType];
|
|
1620
|
-
const typedValue = { type: value.resourceType, value };
|
|
1621
|
-
return (React__default["default"].createElement("form", { noValidate: true, autoComplete: "off", onSubmit: (e) => {
|
|
1622
|
-
e.preventDefault();
|
|
1623
|
-
if (props.onSubmit) {
|
|
1624
|
-
props.onSubmit(value);
|
|
1625
|
-
}
|
|
1626
|
-
} },
|
|
1627
|
-
React__default["default"].createElement(FormSection, { title: "Resource Type" },
|
|
1628
|
-
React__default["default"].createElement(Input, { name: "resourceType", defaultValue: value.resourceType, disabled: true })),
|
|
1629
|
-
React__default["default"].createElement(FormSection, { title: "ID" },
|
|
1630
|
-
React__default["default"].createElement(Input, { name: "id", defaultValue: value.id, disabled: true })),
|
|
1631
|
-
Object.entries(typeSchema.properties).map((entry) => {
|
|
1632
|
-
const key = entry[0];
|
|
1633
|
-
if (key === 'id' || DEFAULT_IGNORED_PROPERTIES.indexOf(key) >= 0) {
|
|
1634
|
-
return null;
|
|
1635
|
-
}
|
|
1636
|
-
const property = entry[1];
|
|
1637
|
-
const [propertyValue, propertyType] = getValueAndType(typedValue, key);
|
|
1638
|
-
return (React__default["default"].createElement(FormSection, { key: key, title: core.getPropertyDisplayName(key), description: property.definition, htmlFor: key, outcome: props.outcome },
|
|
1639
|
-
React__default["default"].createElement(ResourcePropertyInput, { property: property, name: key, defaultValue: propertyValue, defaultPropertyType: propertyType, outcome: props.outcome, onChange: (newValue, propName) => {
|
|
1640
|
-
setValue(setPropertyValue(value, key, propName !== null && propName !== void 0 ? propName : key, entry[1], newValue));
|
|
1641
|
-
} })));
|
|
1642
|
-
}),
|
|
1643
|
-
React__default["default"].createElement(Button, { type: "submit", size: "large" }, "OK"),
|
|
1644
|
-
props.onDelete && (React__default["default"].createElement(Button, { type: "button", size: "large", onClick: () => {
|
|
1645
|
-
props.onDelete(value);
|
|
1646
|
-
} }, "Delete"))));
|
|
1647
|
-
}
|
|
1648
|
-
function setPropertyValue(obj, key, propName, elementDefinition, value) {
|
|
1649
|
-
const types = elementDefinition.type;
|
|
1650
|
-
if (types.length > 1) {
|
|
1651
|
-
for (const type of types) {
|
|
1652
|
-
const compoundKey = key.replace('[x]', core.capitalize(type.code));
|
|
1653
|
-
if (compoundKey in obj) {
|
|
1654
|
-
delete obj[compoundKey];
|
|
1655
|
-
}
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
obj[propName] = value;
|
|
1659
|
-
return obj;
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
1670
|
function BackboneElementInput(props) {
|
|
1663
|
-
var _a
|
|
1671
|
+
var _a;
|
|
1664
1672
|
const [value, setValue] = React.useState((_a = props.defaultValue) !== null && _a !== void 0 ? _a : {});
|
|
1665
1673
|
function setValueWrapper(newValue) {
|
|
1666
1674
|
setValue(newValue);
|
|
@@ -1668,13 +1676,14 @@
|
|
|
1668
1676
|
props.onChange(newValue);
|
|
1669
1677
|
}
|
|
1670
1678
|
}
|
|
1671
|
-
const typeName =
|
|
1679
|
+
const typeName = props.typeName;
|
|
1672
1680
|
const typeSchema = core.globalSchema.types[typeName];
|
|
1673
1681
|
if (!typeSchema) {
|
|
1674
1682
|
return React__default["default"].createElement("div", null,
|
|
1675
1683
|
typeName,
|
|
1676
1684
|
"\u00A0not implemented");
|
|
1677
1685
|
}
|
|
1686
|
+
const typedValue = { type: typeName, value };
|
|
1678
1687
|
return (React__default["default"].createElement(React__default["default"].Fragment, null, Object.entries(typeSchema.properties).map((entry) => {
|
|
1679
1688
|
const key = entry[0];
|
|
1680
1689
|
if (key === 'id' || DEFAULT_IGNORED_PROPERTIES.indexOf(key) >= 0) {
|
|
@@ -1684,7 +1693,13 @@
|
|
|
1684
1693
|
if (!property.type) {
|
|
1685
1694
|
return null;
|
|
1686
1695
|
}
|
|
1687
|
-
const [propertyValue, propertyType] = getValueAndType(
|
|
1696
|
+
const [propertyValue, propertyType] = getValueAndType(typedValue, key);
|
|
1697
|
+
if (property.type.length === 1 && property.type[0].code === 'boolean') {
|
|
1698
|
+
return (React__default["default"].createElement(CheckboxFormSection, { key: key, title: core.getPropertyDisplayName(key), description: property.definition, htmlFor: key },
|
|
1699
|
+
React__default["default"].createElement(ResourcePropertyInput, { property: property, name: key, defaultValue: propertyValue, defaultPropertyType: propertyType, outcome: props.outcome, onChange: (newValue, propName) => {
|
|
1700
|
+
setValueWrapper(setPropertyValue(value, key, propName !== null && propName !== void 0 ? propName : key, entry[1], newValue));
|
|
1701
|
+
} })));
|
|
1702
|
+
}
|
|
1688
1703
|
return (React__default["default"].createElement(FormSection, { key: key, title: core.getPropertyDisplayName(key), description: property.definition, htmlFor: key, outcome: props.outcome },
|
|
1689
1704
|
React__default["default"].createElement(ResourcePropertyInput, { property: property, name: key, defaultValue: propertyValue, defaultPropertyType: propertyType, outcome: props.outcome, onChange: (newValue, propName) => {
|
|
1690
1705
|
setValueWrapper(setPropertyValue(value, key, propName !== null && propName !== void 0 ? propName : key, entry[1], newValue));
|
|
@@ -3202,7 +3217,7 @@
|
|
|
3202
3217
|
}
|
|
3203
3218
|
} }));
|
|
3204
3219
|
case core.SearchParameterType.BOOLEAN:
|
|
3205
|
-
return (React__default["default"].createElement(
|
|
3220
|
+
return (React__default["default"].createElement(Checkbox, { name: name, testid: name, defaultValue: props.defaultValue === 'true', onChange: (newValue) => props.onChange(newValue.toString()) }));
|
|
3206
3221
|
case core.SearchParameterType.DATE:
|
|
3207
3222
|
return React__default["default"].createElement(Input, { type: "date", testid: name, defaultValue: props.defaultValue, onChange: props.onChange });
|
|
3208
3223
|
case core.SearchParameterType.DATETIME:
|
|
@@ -3898,7 +3913,7 @@
|
|
|
3898
3913
|
function HeaderSearchInput(props) {
|
|
3899
3914
|
const medplum = useMedplum();
|
|
3900
3915
|
return (React__default["default"].createElement(Autocomplete, { loadOptions: (input, signal) => __awaiter(this, void 0, void 0, function* () {
|
|
3901
|
-
return getResourcesFromResponse((yield medplum.graphql(buildGraphQLQuery(input), { signal })), input);
|
|
3916
|
+
return getResourcesFromResponse((yield medplum.graphql(buildGraphQLQuery(input), undefined, undefined, { signal })), input);
|
|
3902
3917
|
}), getId: (item) => {
|
|
3903
3918
|
return item.id;
|
|
3904
3919
|
}, getIcon: (item) => React__default["default"].createElement(Avatar, { value: item }), getDisplay: (item) => React__default["default"].createElement(ResourceName, { value: item }), getHelpText: (item) => {
|
|
@@ -4472,8 +4487,24 @@
|
|
|
4472
4487
|
setResponseItems(newResponseItems);
|
|
4473
4488
|
props.onChange(newResponseItems);
|
|
4474
4489
|
}
|
|
4475
|
-
return (React__default["default"].createElement(React__default["default"].Fragment, null, props.items.map((item, index) =>
|
|
4476
|
-
|
|
4490
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null, props.items.map((item, index) => {
|
|
4491
|
+
if (item.type === exports.QuestionnaireItemType.display) {
|
|
4492
|
+
return React__default["default"].createElement("p", { key: item.linkId }, item.text);
|
|
4493
|
+
}
|
|
4494
|
+
if (item.type === exports.QuestionnaireItemType.group) {
|
|
4495
|
+
return (React__default["default"].createElement(QuestionnaireFormItem, { key: item.linkId, item: item, onChange: (newResponseItem) => setResponseItem(index, newResponseItem) }));
|
|
4496
|
+
}
|
|
4497
|
+
if (item.type === exports.QuestionnaireItemType.boolean) {
|
|
4498
|
+
const initial = item.initial && item.initial.length > 0 ? item.initial[0] : undefined;
|
|
4499
|
+
return (React__default["default"].createElement(CheckboxFormSection, { key: item.linkId, title: item.text, htmlFor: item.linkId },
|
|
4500
|
+
React__default["default"].createElement(Checkbox, { name: item.linkId, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueBoolean, onChange: (newValue) => setResponseItem(index, {
|
|
4501
|
+
linkId: item.linkId,
|
|
4502
|
+
answer: [{ valueBoolean: newValue }],
|
|
4503
|
+
}) })));
|
|
4504
|
+
}
|
|
4505
|
+
return (React__default["default"].createElement(FormSection, { key: item.linkId, htmlFor: item.linkId, title: item.text || '' },
|
|
4506
|
+
React__default["default"].createElement(QuestionnaireFormItem, { item: item, onChange: (newResponseItem) => setResponseItem(index, newResponseItem) })));
|
|
4507
|
+
})));
|
|
4477
4508
|
}
|
|
4478
4509
|
function QuestionnaireFormItem(props) {
|
|
4479
4510
|
const item = props.item;
|
|
@@ -4504,7 +4535,7 @@
|
|
|
4504
4535
|
React__default["default"].createElement("h3", null, item.text),
|
|
4505
4536
|
item.item && React__default["default"].createElement(QuestionnaireFormItemArray, { items: item.item, onChange: onChangeItem })));
|
|
4506
4537
|
case exports.QuestionnaireItemType.boolean:
|
|
4507
|
-
return (React__default["default"].createElement(
|
|
4538
|
+
return (React__default["default"].createElement(Checkbox, { name: name, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueBoolean, onChange: (newValue) => onChangeAnswer({ valueBoolean: newValue }) }));
|
|
4508
4539
|
case exports.QuestionnaireItemType.decimal:
|
|
4509
4540
|
return (React__default["default"].createElement(Input, { type: "number", step: "any", name: name, defaultValue: initial === null || initial === void 0 ? void 0 : initial.valueDecimal, onChange: (newValue) => onChangeAnswer({ valueDecimal: parseFloat(newValue) }) }));
|
|
4510
4541
|
case exports.QuestionnaireItemType.integer:
|
|
@@ -5390,6 +5421,8 @@
|
|
|
5390
5421
|
exports.Avatar = Avatar;
|
|
5391
5422
|
exports.BackboneElementInput = BackboneElementInput;
|
|
5392
5423
|
exports.Button = Button;
|
|
5424
|
+
exports.Checkbox = Checkbox;
|
|
5425
|
+
exports.CheckboxFormSection = CheckboxFormSection;
|
|
5393
5426
|
exports.CodeInput = CodeInput;
|
|
5394
5427
|
exports.CodeableConceptDisplay = CodeableConceptDisplay;
|
|
5395
5428
|
exports.CodeableConceptInput = CodeableConceptInput;
|