@medplum/react 0.9.38 → 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.
Files changed (249) hide show
  1. package/dist/cjs/AttachmentButton.d.ts +9 -0
  2. package/dist/cjs/CodeInput.d.ts +2 -1
  3. package/dist/cjs/CodeableConceptInput.d.ts +1 -0
  4. package/dist/cjs/CodingInput.d.ts +1 -0
  5. package/dist/cjs/DateTimeInput.d.ts +9 -2
  6. package/dist/cjs/ReferenceInput.d.ts +1 -0
  7. package/dist/cjs/ResourceAvatar.d.ts +8 -0
  8. package/dist/cjs/ResourceBadge.d.ts +0 -1
  9. package/dist/cjs/ResourceInput.d.ts +2 -3
  10. package/dist/cjs/SearchPopupMenu.d.ts +0 -4
  11. package/dist/cjs/SearchUtils.d.ts +5 -5
  12. package/dist/cjs/ValueSetAutocomplete.d.ts +10 -0
  13. package/dist/cjs/auth/RegisterForm.d.ts +0 -1
  14. package/dist/cjs/auth/SignInForm.d.ts +0 -1
  15. package/dist/cjs/defaulttheme.css +0 -51
  16. package/dist/cjs/index.d.ts +3 -14
  17. package/dist/cjs/index.js +793 -1493
  18. package/dist/cjs/index.js.map +1 -1
  19. package/dist/cjs/index.min.js +1 -1
  20. package/dist/cjs/index.min.js.map +1 -1
  21. package/dist/cjs/stories/{UploadButton.stories.d.ts → AttachmentButton.stories.d.ts} +1 -0
  22. package/dist/cjs/stories/{Input.stories.d.ts → PeriodInput.stories.d.ts} +1 -1
  23. package/dist/cjs/stories/{Avatar.stories.d.ts → ResourceAvatar.stories.d.ts} +0 -0
  24. package/dist/cjs/stories/ResourceForm.stories.d.ts +1 -0
  25. package/dist/cjs/stories/{Dialog.stories.d.ts → ResourceInput.stories.d.ts} +2 -1
  26. package/dist/cjs/stories/SearchControl.stories.d.ts +1 -0
  27. package/dist/cjs/styles.css +70 -1053
  28. package/dist/cjs/utils/outcomes.d.ts +1 -0
  29. package/dist/esm/AddressInput.js +9 -21
  30. package/dist/esm/AddressInput.js.map +1 -1
  31. package/dist/esm/AnnotationInput.js +2 -2
  32. package/dist/esm/AnnotationInput.js.map +1 -1
  33. package/dist/esm/AttachmentArrayInput.js +11 -8
  34. package/dist/esm/AttachmentArrayInput.js.map +1 -1
  35. package/dist/esm/AttachmentButton.d.ts +9 -0
  36. package/dist/esm/{UploadButton.js → AttachmentButton.js} +9 -9
  37. package/dist/esm/AttachmentButton.js.map +1 -0
  38. package/dist/esm/AttachmentInput.js +3 -3
  39. package/dist/esm/AttachmentInput.js.map +1 -1
  40. package/dist/esm/CalendarInput.js +6 -7
  41. package/dist/esm/CalendarInput.js.map +1 -1
  42. package/dist/esm/CodeInput.d.ts +2 -1
  43. package/dist/esm/CodeInput.js +16 -21
  44. package/dist/esm/CodeInput.js.map +1 -1
  45. package/dist/esm/CodeableConceptInput.d.ts +1 -0
  46. package/dist/esm/CodeableConceptInput.js +18 -33
  47. package/dist/esm/CodeableConceptInput.js.map +1 -1
  48. package/dist/esm/CodingInput.d.ts +1 -0
  49. package/dist/esm/CodingInput.js +24 -23
  50. package/dist/esm/CodingInput.js.map +1 -1
  51. package/dist/esm/ContactDetailInput.js +3 -4
  52. package/dist/esm/ContactDetailInput.js.map +1 -1
  53. package/dist/esm/ContactPointInput.js +5 -21
  54. package/dist/esm/ContactPointInput.js.map +1 -1
  55. package/dist/esm/DateTimeInput.d.ts +9 -2
  56. package/dist/esm/DateTimeInput.js +13 -3
  57. package/dist/esm/DateTimeInput.js.map +1 -1
  58. package/dist/esm/DiagnosticReportDisplay.js +16 -1
  59. package/dist/esm/DiagnosticReportDisplay.js.map +1 -1
  60. package/dist/esm/EncounterTimeline.js +2 -0
  61. package/dist/esm/EncounterTimeline.js.map +1 -1
  62. package/dist/esm/ExtensionInput.js +2 -2
  63. package/dist/esm/ExtensionInput.js.map +1 -1
  64. package/dist/esm/FhirPathTable.js +4 -5
  65. package/dist/esm/FhirPathTable.js.map +1 -1
  66. package/dist/esm/HumanNameInput.js +7 -17
  67. package/dist/esm/HumanNameInput.js.map +1 -1
  68. package/dist/esm/IdentifierInput.js +4 -5
  69. package/dist/esm/IdentifierInput.js.map +1 -1
  70. package/dist/esm/Logo.js +4 -4
  71. package/dist/esm/Logo.js.map +1 -1
  72. package/dist/esm/PatientTimeline.js +2 -0
  73. package/dist/esm/PatientTimeline.js.map +1 -1
  74. package/dist/esm/PeriodInput.js +5 -5
  75. package/dist/esm/PeriodInput.js.map +1 -1
  76. package/dist/esm/PlanDefinitionBuilder.js +17 -29
  77. package/dist/esm/PlanDefinitionBuilder.js.map +1 -1
  78. package/dist/esm/QuantityInput.js +5 -12
  79. package/dist/esm/QuantityInput.js.map +1 -1
  80. package/dist/esm/QuestionnaireBuilder.js +22 -25
  81. package/dist/esm/QuestionnaireBuilder.js.map +1 -1
  82. package/dist/esm/QuestionnaireForm.js +35 -29
  83. package/dist/esm/QuestionnaireForm.js.map +1 -1
  84. package/dist/esm/RangeInput.js +2 -2
  85. package/dist/esm/RangeInput.js.map +1 -1
  86. package/dist/esm/RatioInput.js +2 -2
  87. package/dist/esm/RatioInput.js.map +1 -1
  88. package/dist/esm/ReferenceInput.d.ts +1 -0
  89. package/dist/esm/ReferenceInput.js +4 -6
  90. package/dist/esm/ReferenceInput.js.map +1 -1
  91. package/dist/esm/RequestGroupDisplay.js +1 -1
  92. package/dist/esm/RequestGroupDisplay.js.map +1 -1
  93. package/dist/esm/ResourceArrayInput.js +10 -7
  94. package/dist/esm/ResourceArrayInput.js.map +1 -1
  95. package/dist/esm/ResourceAvatar.d.ts +8 -0
  96. package/dist/esm/ResourceAvatar.js +24 -0
  97. package/dist/esm/ResourceAvatar.js.map +1 -0
  98. package/dist/esm/ResourceBadge.d.ts +0 -1
  99. package/dist/esm/ResourceBadge.js +2 -3
  100. package/dist/esm/ResourceBadge.js.map +1 -1
  101. package/dist/esm/ResourceBlame.js +3 -3
  102. package/dist/esm/ResourceBlame.js.map +1 -1
  103. package/dist/esm/ResourceForm.js +10 -10
  104. package/dist/esm/ResourceForm.js.map +1 -1
  105. package/dist/esm/ResourceInput.d.ts +2 -3
  106. package/dist/esm/ResourceInput.js +37 -29
  107. package/dist/esm/ResourceInput.js.map +1 -1
  108. package/dist/esm/ResourcePropertyInput.js +30 -18
  109. package/dist/esm/ResourcePropertyInput.js.map +1 -1
  110. package/dist/esm/ResourceTimeline.js +19 -15
  111. package/dist/esm/ResourceTimeline.js.map +1 -1
  112. package/dist/esm/Scheduler.js +7 -7
  113. package/dist/esm/Scheduler.js.map +1 -1
  114. package/dist/esm/SearchControl.js +76 -58
  115. package/dist/esm/SearchControl.js.map +1 -1
  116. package/dist/esm/SearchControlField.js.map +1 -1
  117. package/dist/esm/SearchFieldEditor.js +7 -7
  118. package/dist/esm/SearchFieldEditor.js.map +1 -1
  119. package/dist/esm/SearchFilterEditor.js +10 -15
  120. package/dist/esm/SearchFilterEditor.js.map +1 -1
  121. package/dist/esm/SearchFilterValueDialog.js +4 -3
  122. package/dist/esm/SearchFilterValueDialog.js.map +1 -1
  123. package/dist/esm/SearchFilterValueInput.js +6 -7
  124. package/dist/esm/SearchFilterValueInput.js.map +1 -1
  125. package/dist/esm/SearchPopupMenu.d.ts +0 -4
  126. package/dist/esm/SearchPopupMenu.js +59 -73
  127. package/dist/esm/SearchPopupMenu.js.map +1 -1
  128. package/dist/esm/SearchUtils.d.ts +5 -5
  129. package/dist/esm/SearchUtils.js +11 -12
  130. package/dist/esm/SearchUtils.js.map +1 -1
  131. package/dist/esm/ServiceRequestTimeline.js +2 -0
  132. package/dist/esm/ServiceRequestTimeline.js.map +1 -1
  133. package/dist/esm/Timeline.js +12 -20
  134. package/dist/esm/Timeline.js.map +1 -1
  135. package/dist/esm/TimingInput.js +14 -17
  136. package/dist/esm/TimingInput.js.map +1 -1
  137. package/dist/esm/ValueSetAutocomplete.d.ts +10 -0
  138. package/dist/esm/ValueSetAutocomplete.js +57 -0
  139. package/dist/esm/ValueSetAutocomplete.js.map +1 -0
  140. package/dist/esm/auth/AuthenticationForm.js +12 -20
  141. package/dist/esm/auth/AuthenticationForm.js.map +1 -1
  142. package/dist/esm/auth/ChooseProfileForm.js +10 -10
  143. package/dist/esm/auth/ChooseProfileForm.js.map +1 -1
  144. package/dist/esm/auth/NewProjectForm.js +12 -15
  145. package/dist/esm/auth/NewProjectForm.js.map +1 -1
  146. package/dist/esm/auth/NewUserForm.js +25 -33
  147. package/dist/esm/auth/NewUserForm.js.map +1 -1
  148. package/dist/esm/auth/RegisterForm.d.ts +0 -1
  149. package/dist/esm/auth/RegisterForm.js.map +1 -1
  150. package/dist/esm/auth/SignInForm.d.ts +0 -1
  151. package/dist/esm/auth/SignInForm.js.map +1 -1
  152. package/dist/esm/defaulttheme.css +0 -51
  153. package/dist/esm/index.d.ts +3 -14
  154. package/dist/esm/index.js +4 -15
  155. package/dist/esm/index.js.map +1 -1
  156. package/dist/esm/index.min.js +1 -1
  157. package/dist/esm/index.min.js.map +1 -1
  158. package/dist/esm/node_modules/tslib/tslib.es6.js +13 -1
  159. package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -1
  160. package/dist/esm/stories/{UploadButton.stories.d.ts → AttachmentButton.stories.d.ts} +1 -0
  161. package/dist/{cjs/stories/Select.stories.d.ts → esm/stories/PeriodInput.stories.d.ts} +1 -1
  162. package/dist/esm/stories/{Avatar.stories.d.ts → ResourceAvatar.stories.d.ts} +0 -0
  163. package/dist/esm/stories/ResourceForm.stories.d.ts +1 -0
  164. package/dist/{cjs/stories/FormSection.stories.d.ts → esm/stories/ResourceInput.stories.d.ts} +2 -2
  165. package/dist/esm/stories/SearchControl.stories.d.ts +1 -0
  166. package/dist/esm/styles.css +70 -1053
  167. package/dist/esm/utils/outcomes.d.ts +1 -0
  168. package/dist/esm/utils/outcomes.js +5 -1
  169. package/dist/esm/utils/outcomes.js.map +1 -1
  170. package/package.json +27 -19
  171. package/dist/cjs/Autocomplete.d.ts +0 -20
  172. package/dist/cjs/Avatar.d.ts +0 -12
  173. package/dist/cjs/Button.d.ts +0 -15
  174. package/dist/cjs/Checkbox.d.ts +0 -12
  175. package/dist/cjs/Dialog.d.ts +0 -10
  176. package/dist/cjs/Header.d.ts +0 -12
  177. package/dist/cjs/HeaderSearchInput.d.ts +0 -10
  178. package/dist/cjs/Input.d.ts +0 -22
  179. package/dist/cjs/InputRow.d.ts +0 -7
  180. package/dist/cjs/Loading.d.ts +0 -3
  181. package/dist/cjs/MenuItem.d.ts +0 -9
  182. package/dist/cjs/MenuSeparator.d.ts +0 -3
  183. package/dist/cjs/Popup.d.ts +0 -14
  184. package/dist/cjs/Select.d.ts +0 -16
  185. package/dist/cjs/SubMenu.d.ts +0 -7
  186. package/dist/cjs/TextArea.d.ts +0 -18
  187. package/dist/cjs/UploadButton.d.ts +0 -7
  188. package/dist/cjs/stories/Autocomplete.stories.d.ts +0 -9
  189. package/dist/cjs/stories/Button.stories.d.ts +0 -9
  190. package/dist/cjs/stories/Header.stories.d.ts +0 -8
  191. package/dist/cjs/stories/Loading.stories.d.ts +0 -5
  192. package/dist/esm/Autocomplete.d.ts +0 -20
  193. package/dist/esm/Autocomplete.js +0 -281
  194. package/dist/esm/Autocomplete.js.map +0 -1
  195. package/dist/esm/Avatar.d.ts +0 -12
  196. package/dist/esm/Avatar.js +0 -24
  197. package/dist/esm/Avatar.js.map +0 -1
  198. package/dist/esm/Button.d.ts +0 -15
  199. package/dist/esm/Button.js +0 -13
  200. package/dist/esm/Button.js.map +0 -1
  201. package/dist/esm/Checkbox.d.ts +0 -12
  202. package/dist/esm/Checkbox.js +0 -13
  203. package/dist/esm/Checkbox.js.map +0 -1
  204. package/dist/esm/Dialog.d.ts +0 -10
  205. package/dist/esm/Dialog.js +0 -43
  206. package/dist/esm/Dialog.js.map +0 -1
  207. package/dist/esm/Header.d.ts +0 -12
  208. package/dist/esm/Header.js +0 -99
  209. package/dist/esm/Header.js.map +0 -1
  210. package/dist/esm/HeaderSearchInput.d.ts +0 -10
  211. package/dist/esm/HeaderSearchInput.js +0 -181
  212. package/dist/esm/HeaderSearchInput.js.map +0 -1
  213. package/dist/esm/Input.d.ts +0 -22
  214. package/dist/esm/Input.js +0 -26
  215. package/dist/esm/Input.js.map +0 -1
  216. package/dist/esm/InputRow.d.ts +0 -7
  217. package/dist/esm/InputRow.js +0 -8
  218. package/dist/esm/InputRow.js.map +0 -1
  219. package/dist/esm/Loading.d.ts +0 -3
  220. package/dist/esm/Loading.js +0 -11
  221. package/dist/esm/Loading.js.map +0 -1
  222. package/dist/esm/MenuItem.d.ts +0 -9
  223. package/dist/esm/MenuItem.js +0 -8
  224. package/dist/esm/MenuItem.js.map +0 -1
  225. package/dist/esm/MenuSeparator.d.ts +0 -3
  226. package/dist/esm/MenuSeparator.js +0 -8
  227. package/dist/esm/MenuSeparator.js.map +0 -1
  228. package/dist/esm/Popup.d.ts +0 -14
  229. package/dist/esm/Popup.js +0 -78
  230. package/dist/esm/Popup.js.map +0 -1
  231. package/dist/esm/Select.d.ts +0 -16
  232. package/dist/esm/Select.js +0 -16
  233. package/dist/esm/Select.js.map +0 -1
  234. package/dist/esm/SubMenu.d.ts +0 -7
  235. package/dist/esm/SubMenu.js +0 -38
  236. package/dist/esm/SubMenu.js.map +0 -1
  237. package/dist/esm/TextArea.d.ts +0 -18
  238. package/dist/esm/TextArea.js +0 -16
  239. package/dist/esm/TextArea.js.map +0 -1
  240. package/dist/esm/UploadButton.d.ts +0 -7
  241. package/dist/esm/UploadButton.js.map +0 -1
  242. package/dist/esm/stories/Autocomplete.stories.d.ts +0 -9
  243. package/dist/esm/stories/Button.stories.d.ts +0 -9
  244. package/dist/esm/stories/Dialog.stories.d.ts +0 -5
  245. package/dist/esm/stories/FormSection.stories.d.ts +0 -6
  246. package/dist/esm/stories/Header.stories.d.ts +0 -8
  247. package/dist/esm/stories/Input.stories.d.ts +0 -6
  248. package/dist/esm/stories/Loading.stories.d.ts +0 -5
  249. package/dist/esm/stories/Select.stories.d.ts +0 -6
@@ -1,2 +1,3 @@
1
1
  import { OperationOutcome, OperationOutcomeIssue } from '@medplum/fhirtypes';
2
+ export declare function getErrorsForInput(outcome: OperationOutcome | undefined, expression: string | undefined): string | undefined;
2
3
  export declare function getIssuesForExpression(outcome: OperationOutcome | undefined, expression: string | undefined): OperationOutcomeIssue[] | undefined;
@@ -1,7 +1,5 @@
1
+ import { Group, NativeSelect, TextInput } from '@mantine/core';
1
2
  import React, { useState, useRef } from 'react';
2
- import { Input } from './Input.js';
3
- import { InputRow } from './InputRow.js';
4
- import { Select } from './Select.js';
5
3
 
6
4
  function getLine(address, index) {
7
5
  return address && address.line && address.line.length > index ? address.line[index] : '';
@@ -45,24 +43,14 @@ function AddressInput(props) {
45
43
  function setPostalCode(postalCode) {
46
44
  setValueWrapper(Object.assign(Object.assign({}, valueRef.current), { postalCode }));
47
45
  }
48
- return (React.createElement(InputRow, null,
49
- React.createElement(Select, { testid: "address-use", defaultValue: value === null || value === void 0 ? void 0 : value.use, onChange: setUse },
50
- React.createElement("option", null),
51
- React.createElement("option", null, "home"),
52
- React.createElement("option", null, "mobile"),
53
- React.createElement("option", null, "old"),
54
- React.createElement("option", null, "temp"),
55
- React.createElement("option", null, "work")),
56
- React.createElement(Select, { testid: "address-type", defaultValue: value === null || value === void 0 ? void 0 : value.type, onChange: setType },
57
- React.createElement("option", null),
58
- React.createElement("option", null, "postal"),
59
- React.createElement("option", null, "physical"),
60
- React.createElement("option", null, "both")),
61
- React.createElement(Input, { placeholder: "Line 1", defaultValue: getLine(value, 0), onChange: setLine1 }),
62
- React.createElement(Input, { placeholder: "Line 2", defaultValue: getLine(value, 1), onChange: setLine2 }),
63
- React.createElement(Input, { placeholder: "City", defaultValue: value.city, onChange: setCity }),
64
- React.createElement(Input, { placeholder: "State", defaultValue: value.state, onChange: setState }),
65
- React.createElement(Input, { placeholder: "Postal Code", defaultValue: value.postalCode, onChange: setPostalCode })));
46
+ return (React.createElement(Group, { spacing: "xs", grow: true, noWrap: true },
47
+ React.createElement(NativeSelect, { "data-testid": "address-use", defaultValue: value === null || value === void 0 ? void 0 : value.use, onChange: (e) => setUse(e.currentTarget.value), data: ['', 'home', 'work', 'temp', 'old', 'billing'] }),
48
+ React.createElement(NativeSelect, { "data-testid": "address-type", defaultValue: value === null || value === void 0 ? void 0 : value.type, onChange: (e) => setType(e.currentTarget.value), data: ['', 'postal', 'physical', 'both'] }),
49
+ React.createElement(TextInput, { placeholder: "Line 1", defaultValue: getLine(value, 0), onChange: (e) => setLine1(e.currentTarget.value) }),
50
+ React.createElement(TextInput, { placeholder: "Line 2", defaultValue: getLine(value, 1), onChange: (e) => setLine2(e.currentTarget.value) }),
51
+ React.createElement(TextInput, { placeholder: "City", defaultValue: value.city, onChange: (e) => setCity(e.currentTarget.value) }),
52
+ React.createElement(TextInput, { placeholder: "State", defaultValue: value.state, onChange: (e) => setState(e.currentTarget.value) }),
53
+ React.createElement(TextInput, { placeholder: "Postal Code", defaultValue: value.postalCode, onChange: (e) => setPostalCode(e.currentTarget.value) })));
66
54
  }
67
55
 
68
56
  export { AddressInput };
@@ -1 +1 @@
1
- {"version":3,"file":"AddressInput.js","sources":["../../src/AddressInput.tsx"],"sourcesContent":["import { Address } from '@medplum/fhirtypes';\nimport React, { useRef, useState } from 'react';\nimport { Input } from './Input';\nimport { InputRow } from './InputRow';\nimport { Select } from './Select';\n\nfunction getLine(address: Address, index: number): string {\n return address && address.line && address.line.length > index ? address.line[index] : '';\n}\n\nfunction setLine(address: Address, index: number, str: string): Address {\n const line: string[] = address.line || [];\n while (line.length <= index) {\n line.push('');\n }\n line[index] = str;\n return { ...address, line };\n}\n\nexport interface AddressInputProps {\n name: string;\n defaultValue?: Address;\n onChange?: (value: Address) => void;\n}\n\nexport function AddressInput(props: AddressInputProps): JSX.Element {\n const [value, setValue] = useState<Address>(props.defaultValue || {});\n\n const valueRef = useRef<Address>();\n valueRef.current = value;\n\n function setValueWrapper(newValue: Address): void {\n setValue(newValue);\n if (props.onChange) {\n props.onChange(newValue);\n }\n }\n\n function setUse(use: 'home' | 'work' | 'temp' | 'old' | 'billing'): void {\n setValueWrapper({ ...valueRef.current, use });\n }\n\n function setType(type: 'postal' | 'physical' | 'both'): void {\n setValueWrapper({ ...valueRef.current, type });\n }\n\n function setLine1(line1: string): void {\n setValueWrapper(setLine(valueRef.current || {}, 0, line1));\n }\n\n function setLine2(line2: string): void {\n setValueWrapper(setLine(valueRef.current || {}, 1, line2));\n }\n\n function setCity(city: string): void {\n setValueWrapper({ ...valueRef.current, city });\n }\n\n function setState(state: string): void {\n setValueWrapper({ ...valueRef.current, state });\n }\n\n function setPostalCode(postalCode: string): void {\n setValueWrapper({ ...valueRef.current, postalCode });\n }\n\n return (\n <InputRow>\n <Select testid=\"address-use\" defaultValue={value?.use} onChange={setUse as (use: string) => void}>\n <option></option>\n <option>home</option>\n <option>mobile</option>\n <option>old</option>\n <option>temp</option>\n <option>work</option>\n </Select>\n <Select testid=\"address-type\" defaultValue={value?.type} onChange={setType as (use: string) => void}>\n <option></option>\n <option>postal</option>\n <option>physical</option>\n <option>both</option>\n </Select>\n <Input placeholder=\"Line 1\" defaultValue={getLine(value, 0)} onChange={setLine1} />\n <Input placeholder=\"Line 2\" defaultValue={getLine(value, 1)} onChange={setLine2} />\n <Input placeholder=\"City\" defaultValue={value.city} onChange={setCity} />\n <Input placeholder=\"State\" defaultValue={value.state} onChange={setState} />\n <Input placeholder=\"Postal Code\" defaultValue={value.postalCode} onChange={setPostalCode} />\n </InputRow>\n );\n}\n"],"names":[],"mappings":";;;;;AAMA,SAAS,OAAO,CAAC,OAAgB,EAAE,KAAa,EAAA;IAC9C,OAAO,OAAO,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAC3F,CAAC;AAED,SAAS,OAAO,CAAC,OAAgB,EAAE,KAAa,EAAE,GAAW,EAAA;AAC3D,IAAA,MAAM,IAAI,GAAa,OAAO,CAAC,IAA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,EAAE,OAAgC,EAAA;YACjG,KAAiB,CAAA,aAAA,CAAA,QAAA,EAAA,IAAA,CAAA;YACjB,KAAuB,CAAA,aAAA,CAAA,QAAA,EAAA,IAAA,EAAA,QAAA,CAAA;YACvB,KAAyB,CAAA,aAAA,CAAA,QAAA,EAAA,IAAA,EAAA,UAAA,CAAA;AACzB,YAAA,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,IAAA,EAAA,MAAA,CAAqB,CACd;AACT,QAAA,KAAA,CAAA,aAAA,CAAC,KAAK,EAAC,EAAA,WAAW,EAAC,QAAQ,EAAC,YAAY,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAI,CAAA;AACnF,QAAA,KAAA,CAAA,aAAA,CAAC,KAAK,EAAC,EAAA,WAAW,EAAC,QAAQ,EAAC,YAAY,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAI,CAAA;AACnF,QAAA,KAAA,CAAA,aAAA,CAAC,KAAK,EAAA,EAAC,WAAW,EAAC,MAAM,EAAC,YAAY,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAI,CAAA;AACzE,QAAA,KAAA,CAAA,aAAA,CAAC,KAAK,EAAA,EAAC,WAAW,EAAC,OAAO,EAAC,YAAY,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAI,CAAA;AAC5E,QAAA,KAAA,CAAA,aAAA,CAAC,KAAK,EAAC,EAAA,WAAW,EAAC,aAAa,EAAC,YAAY,EAAE,KAAK,CAAC,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAI,CAAA,CACnF,EACX;AACJ;;;;"}
1
+ {"version":3,"file":"AddressInput.js","sources":["../../src/AddressInput.tsx"],"sourcesContent":["import { Group, NativeSelect, TextInput } from '@mantine/core';\nimport { Address } from '@medplum/fhirtypes';\nimport React, { useRef, useState } from 'react';\n\nfunction getLine(address: Address, index: number): string {\n return address && address.line && address.line.length > index ? address.line[index] : '';\n}\n\nfunction setLine(address: Address, index: number, str: string): Address {\n const line: string[] = address.line || [];\n while (line.length <= index) {\n line.push('');\n }\n line[index] = str;\n return { ...address, line };\n}\n\nexport interface AddressInputProps {\n name: string;\n defaultValue?: Address;\n onChange?: (value: Address) => void;\n}\n\nexport function AddressInput(props: AddressInputProps): JSX.Element {\n const [value, setValue] = useState<Address>(props.defaultValue || {});\n\n const valueRef = useRef<Address>();\n valueRef.current = value;\n\n function setValueWrapper(newValue: Address): void {\n setValue(newValue);\n if (props.onChange) {\n props.onChange(newValue);\n }\n }\n\n function setUse(use: 'home' | 'work' | 'temp' | 'old' | 'billing'): void {\n setValueWrapper({ ...valueRef.current, use });\n }\n\n function setType(type: 'postal' | 'physical' | 'both'): void {\n setValueWrapper({ ...valueRef.current, type });\n }\n\n function setLine1(line1: string): void {\n setValueWrapper(setLine(valueRef.current || {}, 0, line1));\n }\n\n function setLine2(line2: string): void {\n setValueWrapper(setLine(valueRef.current || {}, 1, line2));\n }\n\n function setCity(city: string): void {\n setValueWrapper({ ...valueRef.current, city });\n }\n\n function setState(state: string): void {\n setValueWrapper({ ...valueRef.current, state });\n }\n\n function setPostalCode(postalCode: string): void {\n setValueWrapper({ ...valueRef.current, postalCode });\n }\n\n return (\n <Group spacing=\"xs\" grow noWrap>\n <NativeSelect\n data-testid=\"address-use\"\n defaultValue={value?.use}\n onChange={(e) => setUse(e.currentTarget.value as 'home' | 'work' | 'temp' | 'old' | 'billing')}\n data={['', 'home', 'work', 'temp', 'old', 'billing']}\n />\n <NativeSelect\n data-testid=\"address-type\"\n defaultValue={value?.type}\n onChange={(e) => setType(e.currentTarget.value as 'postal' | 'physical' | 'both')}\n data={['', 'postal', 'physical', 'both']}\n />\n <TextInput\n placeholder=\"Line 1\"\n defaultValue={getLine(value, 0)}\n onChange={(e) => setLine1(e.currentTarget.value)}\n />\n <TextInput\n placeholder=\"Line 2\"\n defaultValue={getLine(value, 1)}\n onChange={(e) => setLine2(e.currentTarget.value)}\n />\n <TextInput placeholder=\"City\" defaultValue={value.city} onChange={(e) => setCity(e.currentTarget.value)} />\n <TextInput placeholder=\"State\" defaultValue={value.state} onChange={(e) => setState(e.currentTarget.value)} />\n <TextInput\n placeholder=\"Postal Code\"\n defaultValue={value.postalCode}\n onChange={(e) => setPostalCode(e.currentTarget.value)}\n />\n </Group>\n );\n}\n"],"names":[],"mappings":";;;AAIA,SAAS,OAAO,CAAC,OAAgB,EAAE,KAAa,EAAA;IAC9C,OAAO,OAAO,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAC3F,CAAC;AAED,SAAS,OAAO,CAAC,OAAgB,EAAE,KAAa,EAAE,GAAW,EAAA;AAC3D,IAAA,MAAM,IAAI,GAAa,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;AAC1C,IAAA,OAAO,IAAI,CAAC,MAAM,IAAI,KAAK,EAAE;AAC3B,QAAA,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACf,KAAA;AACD,IAAA,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;IAClB,OAAY,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,OAAO,CAAE,EAAA,EAAA,IAAI,EAAG,CAAA,CAAA;AAC9B,CAAC;AAQK,SAAU,YAAY,CAAC,KAAwB,EAAA;AACnD,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;AAEtE,IAAA,MAAM,QAAQ,GAAG,MAAM,EAAW,CAAC;AACnC,IAAA,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;IAEzB,SAAS,eAAe,CAAC,QAAiB,EAAA;QACxC,QA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C,KAAK,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,EAAI,CAAA;QAC3G,KAAC,CAAA,aAAA,CAAA,SAAS,EAAC,EAAA,WAAW,EAAC,OAAO,EAAC,YAAY,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,EAAI,CAAA;AAC9G,QAAA,KAAA,CAAA,aAAA,CAAC,SAAS,EAAA,EACR,WAAW,EAAC,aAAa,EACzB,YAAY,EAAE,KAAK,CAAC,UAAU,EAC9B,QAAQ,EAAE,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,EACrD,CAAA,CACI,EACR;AACJ;;;;"}
@@ -1,6 +1,6 @@
1
+ import { TextInput } from '@mantine/core';
1
2
  import { createReference } from '@medplum/core';
2
3
  import React, { useState, useRef } from 'react';
3
- import { Input } from './Input.js';
4
4
  import { useMedplumProfile } from './MedplumProvider.js';
5
5
 
6
6
  function AnnotationInput(props) {
@@ -21,7 +21,7 @@ function AnnotationInput(props) {
21
21
  props.onChange(newValue);
22
22
  }
23
23
  }
24
- return (React.createElement(Input, { name: props.name, type: "text", placeholder: "Annotation text", defaultValue: value.text, onChange: setText }));
24
+ return (React.createElement(TextInput, { name: props.name, placeholder: "Annotation text", defaultValue: value.text, onChange: (e) => setText(e.currentTarget.value) }));
25
25
  }
26
26
 
27
27
  export { AnnotationInput };
@@ -1 +1 @@
1
- {"version":3,"file":"AnnotationInput.js","sources":["../../src/AnnotationInput.tsx"],"sourcesContent":["import { createReference } from '@medplum/core';\nimport { Annotation } from '@medplum/fhirtypes';\nimport React, { useRef, useState } from 'react';\nimport { Input } from './Input';\nimport { useMedplumProfile } from './MedplumProvider';\n\nexport interface AnnotationInputProps {\n name: string;\n defaultValue?: Annotation;\n onChange?: (value: Annotation) => void;\n}\n\nexport function AnnotationInput(props: AnnotationInputProps): JSX.Element {\n const author = useMedplumProfile();\n const [value, setValue] = useState<Annotation>(props.defaultValue || {});\n\n const valueRef = useRef<Annotation>();\n valueRef.current = value;\n\n function setText(text: string): void {\n const newValue: Annotation = text\n ? {\n text,\n authorReference: author && createReference(author),\n time: new Date().toISOString(),\n }\n : {};\n\n setValue(newValue);\n if (props.onChange) {\n props.onChange(newValue);\n }\n }\n\n return (\n <Input name={props.name} type=\"text\" placeholder=\"Annotation text\" defaultValue={value.text} onChange={setText} />\n );\n}\n"],"names":[],"mappings":";;;;;AAYM,SAAU,eAAe,CAAC,KAA2B,EAAA;AACzD,IAAA,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;AACnC,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAa,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;AAEzE,IAAA,MAAM,QAAQ,GAAG,MAAM,EAAc,CAAC;AACtC,IAAA,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;IAEzB,SAAS,OAAO,CAAC,IAAY,EAAA;QAC3B,MAAM,QAAQ,GAAe,IAAI;AAC/B,cAAE;gBACE,IAAI;AACJ,gBAAA,eAAe,EAAE,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC;AAClD,gBAAA,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;AAC/B,aAAA;cACD,EAAE,CAAC;QAEP,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnB,IAAI,KAAK,CAAC,QAAQ,EAAE;AAClB,YAAA,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC1B,SAAA;KACF;AAED,IAAA,QACE,KAAA,CAAA,aAAA,CAAC,KAAK,EAAA,EAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAC,MAAM,EAAC,WAAW,EAAC,iBAAiB,EAAC,YAAY,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAA,CAAI,EAClH;AACJ;;;;"}
1
+ {"version":3,"file":"AnnotationInput.js","sources":["../../src/AnnotationInput.tsx"],"sourcesContent":["import { TextInput } from '@mantine/core';\nimport { createReference } from '@medplum/core';\nimport { Annotation } from '@medplum/fhirtypes';\nimport React, { useRef, useState } from 'react';\nimport { useMedplumProfile } from './MedplumProvider';\n\nexport interface AnnotationInputProps {\n name: string;\n defaultValue?: Annotation;\n onChange?: (value: Annotation) => void;\n}\n\nexport function AnnotationInput(props: AnnotationInputProps): JSX.Element {\n const author = useMedplumProfile();\n const [value, setValue] = useState<Annotation>(props.defaultValue || {});\n\n const valueRef = useRef<Annotation>();\n valueRef.current = value;\n\n function setText(text: string): void {\n const newValue: Annotation = text\n ? {\n text,\n authorReference: author && createReference(author),\n time: new Date().toISOString(),\n }\n : {};\n\n setValue(newValue);\n if (props.onChange) {\n props.onChange(newValue);\n }\n }\n\n return (\n <TextInput\n name={props.name}\n placeholder=\"Annotation text\"\n defaultValue={value.text}\n onChange={(e) => setText(e.currentTarget.value)}\n />\n );\n}\n"],"names":[],"mappings":";;;;;AAYM,SAAU,eAAe,CAAC,KAA2B,EAAA;AACzD,IAAA,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;AACnC,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAa,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;AAEzE,IAAA,MAAM,QAAQ,GAAG,MAAM,EAAc,CAAC;AACtC,IAAA,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;IAEzB,SAAS,OAAO,CAAC,IAAY,EAAA;QAC3B,MAAM,QAAQ,GAAe,IAAI;AAC/B,cAAE;gBACE,IAAI;AACJ,gBAAA,eAAe,EAAE,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC;AAClD,gBAAA,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;AAC/B,aAAA;cACD,EAAE,CAAC;QAEP,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnB,IAAI,KAAK,CAAC,QAAQ,EAAE;AAClB,YAAA,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC1B,SAAA;KACF;AAED,IAAA,QACE,KAAC,CAAA,aAAA,CAAA,SAAS,EACR,EAAA,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,WAAW,EAAC,iBAAiB,EAC7B,YAAY,EAAE,KAAK,CAAC,IAAI,EACxB,QAAQ,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,EAAA,CAC/C,EACF;AACJ;;;;"}
@@ -1,7 +1,8 @@
1
+ import { ActionIcon } from '@mantine/core';
2
+ import { IconCircleMinus, IconCloudUpload } from '@tabler/icons';
1
3
  import React, { useState, useRef } from 'react';
4
+ import { AttachmentButton } from './AttachmentButton.js';
2
5
  import { AttachmentDisplay } from './AttachmentDisplay.js';
3
- import { Button } from './Button.js';
4
- import { UploadButton } from './UploadButton.js';
5
6
  import { killEvent } from './utils/dom.js';
6
7
 
7
8
  function AttachmentArrayInput(props) {
@@ -17,25 +18,27 @@ function AttachmentArrayInput(props) {
17
18
  }
18
19
  return (React.createElement("table", { style: { width: '100%' } },
19
20
  React.createElement("colgroup", null,
20
- React.createElement("col", { width: "90%" }),
21
- React.createElement("col", { width: "10%" })),
21
+ React.createElement("col", { width: "97%" }),
22
+ React.createElement("col", { width: "3%" })),
22
23
  React.createElement("tbody", null,
23
24
  values.map((v, index) => (React.createElement("tr", { key: `${index}-${values.length}` },
24
25
  React.createElement("td", null,
25
26
  React.createElement(AttachmentDisplay, { value: v, maxWidth: 200 })),
26
27
  React.createElement("td", { className: "medplum-right" },
27
- React.createElement(Button, { onClick: (e) => {
28
+ React.createElement(ActionIcon, { title: "Remove", size: "sm", onClick: (e) => {
28
29
  killEvent(e);
29
30
  const copy = values.slice();
30
31
  copy.splice(index, 1);
31
32
  setValuesWrapper(copy);
32
- } }, "Remove"))))),
33
+ } },
34
+ React.createElement(IconCircleMinus, null)))))),
33
35
  React.createElement("tr", null,
34
36
  React.createElement("td", null),
35
37
  React.createElement("td", { className: "medplum-right" },
36
- React.createElement(UploadButton, { onUpload: (attachment) => {
38
+ React.createElement(AttachmentButton, { onUpload: (attachment) => {
37
39
  setValuesWrapper([...valuesRef.current, attachment]);
38
- } }))))));
40
+ } }, (props) => (React.createElement(ActionIcon, Object.assign({}, props, { title: "Add", size: "sm", color: "green" }),
41
+ React.createElement(IconCloudUpload, { size: 16 })))))))));
39
42
  }
40
43
 
41
44
  export { AttachmentArrayInput };
@@ -1 +1 @@
1
- {"version":3,"file":"AttachmentArrayInput.js","sources":["../../src/AttachmentArrayInput.tsx"],"sourcesContent":["import { Attachment } from '@medplum/fhirtypes';\nimport React, { useRef, useState } from 'react';\nimport { AttachmentDisplay } from './AttachmentDisplay';\nimport { Button } from './Button';\nimport { UploadButton } from './UploadButton';\nimport { killEvent } from './utils/dom';\n\nexport interface AttachmentArrayInputProps {\n name: string;\n defaultValue?: Attachment[];\n arrayElement?: boolean;\n onChange?: (value: Attachment[]) => void;\n}\n\nexport function AttachmentArrayInput(props: AttachmentArrayInputProps): JSX.Element {\n const [values, setValues] = useState<Attachment[]>(props.defaultValue ?? []);\n\n const valuesRef = useRef<Attachment[]>();\n valuesRef.current = values;\n\n function setValuesWrapper(newValues: Attachment[]): void {\n setValues(newValues);\n if (props.onChange) {\n props.onChange(newValues);\n }\n }\n\n return (\n <table style={{ width: '100%' }}>\n <colgroup>\n <col width=\"90%\" />\n <col width=\"10%\" />\n </colgroup>\n <tbody>\n {values.map((v: Attachment, index: number) => (\n <tr key={`${index}-${values.length}`}>\n <td>\n <AttachmentDisplay value={v} maxWidth={200} />\n </td>\n <td className=\"medplum-right\">\n <Button\n onClick={(e) => {\n killEvent(e);\n const copy = values.slice();\n copy.splice(index, 1);\n setValuesWrapper(copy);\n }}\n >\n Remove\n </Button>\n </td>\n </tr>\n ))}\n <tr>\n <td></td>\n <td className=\"medplum-right\">\n <UploadButton\n onUpload={(attachment: Attachment) => {\n setValuesWrapper([...(valuesRef.current as Attachment[]), attachment]);\n }}\n />\n </td>\n </tr>\n </tbody>\n </table>\n );\n}\n"],"names":[],"mappings":";;;;;;AAcM,SAAU,oBAAoB,CAAC,KAAgC,EAAA;;AACnE,IAAA,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAe,CAAA,EAAA,GAAA,KAAK,CAAC,YAAY,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,EAAE,CAAC,CAAC;AAE7E,IAAA,MAAM,SAAS,GAAG,MAAM,EAAgB,CAAC;AACzC,IAAA,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;IAE3B,SAAS,gBAAgB,CAAC,SAAuB,EAAA;QAC/C,SAAS,CAAC,SAAS,CAAC,CAAC;QACrB,IAAI,KAAK,CAAC,QAAQ,EAAE;AAClB,YAAA,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC3B,SAAA;KACF;IAED,QACE,+BAAO,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAA;AAC7B,QAAA,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,IAAA;YACE,KAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,KAAK,EAAC,KAAK,EAAG,CAAA;AACnB,YAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,KAAK,EAAC,KAAK,EAAA,CAAG,CACV;AACX,QAAA,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAA;YACG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAa,EAAE,KAAa,MACvC,KAAI,CAAA,aAAA,CAAA,IAAA,EAAA,EAAA,GAAG,EAAE,CAAG,EAAA,KAAK,IAAI,MAAM,CAAC,MAAM,CAAE,CAAA,EAAA;AAClC,gBAAA,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA;oBACE,KAAC,CAAA,aAAA,CAAA,iBAAiB,EAAC,EAAA,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAA,CAAI,CAC3C;gBACL,KAAI,CAAA,aAAA,CAAA,IAAA,EAAA,EAAA,SAAS,EAAC,eAAe,EAAA;AAC3B,oBAAA,KAAA,CAAA,aAAA,CAAC,MAAM,EACL,EAAA,OAAO,EAAE,CAAC,CAAC,KAAI;4BACb,SAAS,CAAC,CAAC,CAAC,CAAC;AACb,4BAAA,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;AAC5B,4BAAA,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;4BACtB,gBAAgB,CAAC,IAAI,CAAC,CAAC;AACzB,yBAAC,EAGM,EAAA,QAAA,CAAA,CACN,CACF,CACN,CAAC;AACF,YAAA,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA;gBACE,KAAS,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,CAAA;gBACT,KAAI,CAAA,aAAA,CAAA,IAAA,EAAA,EAAA,SAAS,EAAC,eAAe,EAAA;AAC3B,oBAAA,KAAA,CAAA,aAAA,CAAC,YAAY,EACX,EAAA,QAAQ,EAAE,CAAC,UAAsB,KAAI;4BACnC,gBAAgB,CAAC,CAAC,GAAI,SAAS,CAAC,OAAwB,EAAE,UAAU,CAAC,CAAC,CAAC;AACzE,yBAAC,GACD,CACC,CACF,CACC,CACF,EACR;AACJ;;;;"}
1
+ {"version":3,"file":"AttachmentArrayInput.js","sources":["../../src/AttachmentArrayInput.tsx"],"sourcesContent":["import { ActionIcon } from '@mantine/core';\nimport { Attachment } from '@medplum/fhirtypes';\nimport { IconCircleMinus, IconCloudUpload } from '@tabler/icons';\nimport React, { useRef, useState } from 'react';\nimport { AttachmentButton } from './AttachmentButton';\nimport { AttachmentDisplay } from './AttachmentDisplay';\nimport { killEvent } from './utils/dom';\n\nexport interface AttachmentArrayInputProps {\n name: string;\n defaultValue?: Attachment[];\n arrayElement?: boolean;\n onChange?: (value: Attachment[]) => void;\n}\n\nexport function AttachmentArrayInput(props: AttachmentArrayInputProps): JSX.Element {\n const [values, setValues] = useState<Attachment[]>(props.defaultValue ?? []);\n\n const valuesRef = useRef<Attachment[]>();\n valuesRef.current = values;\n\n function setValuesWrapper(newValues: Attachment[]): void {\n setValues(newValues);\n if (props.onChange) {\n props.onChange(newValues);\n }\n }\n\n return (\n <table style={{ width: '100%' }}>\n <colgroup>\n <col width=\"97%\" />\n <col width=\"3%\" />\n </colgroup>\n <tbody>\n {values.map((v: Attachment, index: number) => (\n <tr key={`${index}-${values.length}`}>\n <td>\n <AttachmentDisplay value={v} maxWidth={200} />\n </td>\n <td className=\"medplum-right\">\n <ActionIcon\n title=\"Remove\"\n size=\"sm\"\n onClick={(e: React.MouseEvent) => {\n killEvent(e);\n const copy = values.slice();\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 className=\"medplum-right\">\n <AttachmentButton\n onUpload={(attachment: Attachment) => {\n setValuesWrapper([...(valuesRef.current as Attachment[]), attachment]);\n }}\n >\n {(props) => (\n <ActionIcon {...props} title=\"Add\" size=\"sm\" color=\"green\">\n <IconCloudUpload size={16} />\n </ActionIcon>\n )}\n </AttachmentButton>\n </td>\n </tr>\n </tbody>\n </table>\n );\n}\n"],"names":[],"mappings":";;;;;;;AAeM,SAAU,oBAAoB,CAAC,KAAgC,EAAA;;AACnE,IAAA,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAe,CAAA,EAAA,GAAA,KAAK,CAAC,YAAY,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,EAAE,CAAC,CAAC;AAE7E,IAAA,MAAM,SAAS,GAAG,MAAM,EAAgB,CAAC;AACzC,IAAA,SAAS,CAAC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CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;4BACtB,gBAAgB,CAAC,IAAI,CAAC,CAAC;yBACxB,EAAA;AAED,wBAAA,KAAA,CAAA,aAAA,CAAC,eAAe,EAAG,IAAA,CAAA,CACR,CACV,CACF,CACN,CAAC;AACF,YAAA,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA;gBACE,KAAS,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,CAAA;gBACT,KAAI,CAAA,aAAA,CAAA,IAAA,EAAA,EAAA,SAAS,EAAC,eAAe,EAAA;AAC3B,oBAAA,KAAA,CAAA,aAAA,CAAC,gBAAgB,EACf,EAAA,QAAQ,EAAE,CAAC,UAAsB,KAAI;4BACnC,gBAAgB,CAAC,CAAC,GAAI,SAAS,CAAC,OAAwB,EAAE,UAAU,CAAC,CAAC,CAAC;yBACxE,EAAA,EAEA,CAAC,KAAK,MACL,KAAC,CAAA,aAAA,CAAA,UAAU,EAAK,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,KAAK,IAAE,KAAK,EAAC,KAAK,EAAC,IAAI,EAAC,IAAI,EAAC,KAAK,EAAC,OAAO,EAAA,CAAA;AACxD,wBAAA,KAAA,CAAA,aAAA,CAAC,eAAe,EAAA,EAAC,IAAI,EAAE,EAAE,EAAI,CAAA,CAClB,CACd,CACgB,CAChB,CACF,CACC,CACF,EACR;AACJ;;;;"}
@@ -0,0 +1,9 @@
1
+ import { Attachment } from '@medplum/fhirtypes';
2
+ import React from 'react';
3
+ export interface AttachmentButtonProps {
4
+ onUpload: (attachment: Attachment) => void;
5
+ children(props: {
6
+ onClick(e: React.MouseEvent): void;
7
+ }): React.ReactNode;
8
+ }
9
+ export declare function AttachmentButton(props: AttachmentButtonProps): JSX.Element;
@@ -1,11 +1,15 @@
1
1
  import React, { useRef } from 'react';
2
- import { Button } from './Button.js';
3
2
  import { useMedplum } from './MedplumProvider.js';
4
3
  import { killEvent } from './utils/dom.js';
5
4
 
6
- function UploadButton(props) {
5
+ function AttachmentButton(props) {
7
6
  const medplum = useMedplum();
8
7
  const fileInputRef = useRef(null);
8
+ function onClick(e) {
9
+ var _a;
10
+ killEvent(e);
11
+ (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click();
12
+ }
9
13
  function onFileChange(e) {
10
14
  killEvent(e);
11
15
  const files = e.target.files;
@@ -44,12 +48,8 @@ function UploadButton(props) {
44
48
  }
45
49
  return (React.createElement(React.Fragment, null,
46
50
  React.createElement("input", { type: "file", "data-testid": "upload-file-input", style: { display: 'none' }, ref: fileInputRef, onChange: (e) => onFileChange(e) }),
47
- React.createElement(Button, { testid: "upload-button", onClick: (e) => {
48
- var _a;
49
- killEvent(e);
50
- (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click();
51
- } }, props.children || 'Upload...')));
51
+ props.children({ onClick })));
52
52
  }
53
53
 
54
- export { UploadButton };
55
- //# sourceMappingURL=UploadButton.js.map
54
+ export { AttachmentButton };
55
+ //# sourceMappingURL=AttachmentButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttachmentButton.js","sources":["../../src/AttachmentButton.tsx"],"sourcesContent":["import { Attachment, Binary, OperationOutcome } from '@medplum/fhirtypes';\nimport React, { useRef } from 'react';\nimport { useMedplum } from './MedplumProvider';\nimport { killEvent } from './utils/dom';\n\nexport interface AttachmentButtonProps {\n onUpload: (attachment: Attachment) => void;\n children(props: { onClick(e: React.MouseEvent): void }): React.ReactNode;\n}\n\nexport function AttachmentButton(props: AttachmentButtonProps): JSX.Element {\n const medplum = useMedplum();\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n function onClick(e: React.MouseEvent): void {\n killEvent(e);\n fileInputRef.current?.click();\n }\n\n function onFileChange(e: React.ChangeEvent): void {\n killEvent(e);\n const files = (e.target as HTMLInputElement).files;\n if (files) {\n Array.from(files).forEach(processFile);\n }\n }\n\n /**\n * Processes a single file.\n *\n * @param {File} file The file descriptor.\n */\n function processFile(file: File): void {\n if (!file) {\n return;\n }\n\n const fileName = file.name;\n if (!fileName) {\n return;\n }\n\n const filename = file.name;\n const contentType = file.type || 'application/octet-stream';\n medplum\n .createBinary(file, filename, contentType)\n .then((binary: Binary) => {\n props.onUpload({\n contentType: binary.contentType,\n url: binary.url,\n title: filename,\n });\n })\n .catch((outcome: OperationOutcome) => {\n alert(outcome?.issue?.[0]?.details?.text);\n });\n }\n\n return (\n <>\n <input\n type=\"file\"\n data-testid=\"upload-file-input\"\n style={{ display: 'none' }}\n ref={fileInputRef}\n onChange={(e) => onFileChange(e)}\n />\n {props.children({ onClick })}\n </>\n );\n}\n"],"names":[],"mappings":";;;;AAUM,SAAU,gBAAgB,CAAC,KAA4B,EAAA;AAC3D,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,IAAA,MAAM,YAAY,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAEpD,SAAS,OAAO,CAAC,CAAmB,EAAA;;QAClC,SAAS,CAAC,CAAC,CAAC,CAAC;AACb,QAAA,CAAA,EAAA,GAAA,YAAY,CAAC,OAAO,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,KAAK,EAAE,CAAC;KAC/B;IAED,SAAS,YAAY,CAAC,CAAoB,EAAA;QACxC,SAAS,CAAC,CAAC,CAAC,CAAC;AACb,QAAA,MAAM,KAAK,GAAI,CAAC,CAAC,MAA2B,CAAC,KAAK,CAAC;AACnD,QAAA,IAAI,KAAK,EAAE;YACT,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AACxC,SAAA;KACF;AAED;;;;AAIG;IACH,SAAS,WAAW,CAAC,IAAU,EAAA;QAC7B,IAAI,CAAC,IAAI,EAAE;YACT,OAAO;AACR,SAAA;AAED,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;QAC3B,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO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EAChC,CAAA;QACD,KAAK,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,CAC3B,EACH;AACJ;;;;"}
@@ -1,7 +1,7 @@
1
+ import { Button } from '@mantine/core';
1
2
  import React, { useState } from 'react';
3
+ import { AttachmentButton } from './AttachmentButton.js';
2
4
  import { AttachmentDisplay } from './AttachmentDisplay.js';
3
- import { Button } from './Button.js';
4
- import { UploadButton } from './UploadButton.js';
5
5
  import { killEvent } from './utils/dom.js';
6
6
 
7
7
  function AttachmentInput(props) {
@@ -20,7 +20,7 @@ function AttachmentInput(props) {
20
20
  setValueWrapper(undefined);
21
21
  } }, "Remove")));
22
22
  }
23
- return React.createElement(UploadButton, { onUpload: setValueWrapper });
23
+ return (React.createElement(AttachmentButton, { onUpload: setValueWrapper }, (props) => React.createElement(Button, Object.assign({}, props), "Upload...")));
24
24
  }
25
25
 
26
26
  export { AttachmentInput };
@@ -1 +1 @@
1
- {"version":3,"file":"AttachmentInput.js","sources":["../../src/AttachmentInput.tsx"],"sourcesContent":["import { Attachment } from '@medplum/fhirtypes';\nimport React, { useState } from 'react';\nimport { AttachmentDisplay } from './AttachmentDisplay';\nimport { Button } from './Button';\nimport { UploadButton } from './UploadButton';\nimport { killEvent } from './utils/dom';\n\nexport interface AttachmentInputProps {\n name: string;\n defaultValue?: Attachment;\n arrayElement?: boolean;\n onChange?: (value: Attachment | undefined) => void;\n}\n\nexport function AttachmentInput(props: AttachmentInputProps): JSX.Element {\n const [value, setValue] = useState(props.defaultValue);\n\n function setValueWrapper(newValue: Attachment | undefined): void {\n setValue(newValue);\n if (props.onChange) {\n props.onChange(newValue);\n }\n }\n\n if (value) {\n return (\n <>\n <AttachmentDisplay value={value} maxWidth={200} />\n <Button\n onClick={(e) => {\n killEvent(e);\n setValueWrapper(undefined);\n }}\n >\n Remove\n </Button>\n </>\n );\n }\n\n return <UploadButton onUpload={setValueWrapper} />;\n}\n"],"names":[],"mappings":";;;;;;AAcM,SAAU,eAAe,CAAC,KAA2B,EAAA;AACzD,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAEvD,SAAS,eAAe,CAAC,QAAgC,EAAA;QACvD,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnB,IAAI,KAAK,CAAC,QAAQ,EAAE;AAClB,YAAA,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC1B,SAAA;KACF;AAED,IAAA,IAAI,KAAK,EAAE;AACT,QAAA,QACE,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA;YACE,KAAC,CAAA,aAAA,CAAA,iBAAiB,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAI,CAAA;AAClD,YAAA,KAAA,CAAA,aAAA,CAAC,MAAM,EACL,EAAA,OAAO,EAAE,CAAC,CAAC,KAAI;oBACb,SAAS,CAAC,CAAC,CAAC,CAAC;oBACb,eAAe,CAAC,SAAS,CAAC,CAAC;iBAC5B,EAAA,EAAA,QAAA,CAGM,CACR,EACH;AACH,KAAA;AAED,IAAA,OAAO,oBAAC,YAAY,EAAA,EAAC,QAAQ,EAAE,eAAe,GAAI,CAAC;AACrD;;;;"}
1
+ {"version":3,"file":"AttachmentInput.js","sources":["../../src/AttachmentInput.tsx"],"sourcesContent":["import { Button } from '@mantine/core';\nimport { Attachment } from '@medplum/fhirtypes';\nimport React, { useState } from 'react';\nimport { AttachmentButton } from './AttachmentButton';\nimport { AttachmentDisplay } from './AttachmentDisplay';\nimport { killEvent } from './utils/dom';\n\nexport interface AttachmentInputProps {\n name: string;\n defaultValue?: Attachment;\n arrayElement?: boolean;\n onChange?: (value: Attachment | undefined) => void;\n}\n\nexport function AttachmentInput(props: AttachmentInputProps): JSX.Element {\n const [value, setValue] = useState(props.defaultValue);\n\n function setValueWrapper(newValue: Attachment | undefined): void {\n setValue(newValue);\n if (props.onChange) {\n props.onChange(newValue);\n }\n }\n\n if (value) {\n return (\n <>\n <AttachmentDisplay value={value} maxWidth={200} />\n <Button\n onClick={(e: React.MouseEvent) => {\n killEvent(e);\n setValueWrapper(undefined);\n }}\n >\n Remove\n </Button>\n </>\n );\n }\n\n return (\n <AttachmentButton onUpload={setValueWrapper}>{(props) => <Button {...props}>Upload...</Button>}</AttachmentButton>\n );\n}\n"],"names":[],"mappings":";;;;;;AAcM,SAAU,eAAe,CAAC,KAA2B,EAAA;AACzD,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAEvD,SAAS,eAAe,CAAC,QAAgC,EAAA;QACvD,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnB,IAAI,KAAK,CAAC,QAAQ,EAAE;AAClB,YAAA,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC1B,SAAA;KACF;AAED,IAAA,IAAI,KAAK,EAAE;AACT,QAAA,QACE,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA;YACE,KAAC,CAAA,aAAA,CAAA,iBAAiB,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAI,CAAA;AAClD,YAAA,KAAA,CAAA,aAAA,CAAC,MAAM,EACL,EAAA,OAAO,EAAE,CAAC,CAAmB,KAAI;oBAC/B,SAAS,CAAC,CAAC,CAAC,CAAC;oBACb,eAAe,CAAC,SAAS,CAAC,CAAC;iBAC5B,EAAA,EAAA,QAAA,CAGM,CACR,EACH;AACH,KAAA;IAED,QACE,oBAAC,gBAAgB,EAAA,EAAC,QAAQ,EAAE,eAAe,IAAG,CAAC,KAAK,KAAK,oBAAC,MAAM,EAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,KAAK,CAAoB,EAAA,WAAA,CAAA,CAAoB,EAClH;AACJ;;;;"}
@@ -1,6 +1,5 @@
1
+ import { Group, Button } from '@mantine/core';
1
2
  import React, { useState, useMemo } from 'react';
2
- import { Button } from './Button.js';
3
- import { InputRow } from './InputRow.js';
4
3
 
5
4
  /**
6
5
  * Returns a month display string (e.g. "January 2020").
@@ -23,11 +22,11 @@ function CalendarInput(props) {
23
22
  }
24
23
  const grid = useMemo(() => buildGrid(month, props.slots), [month, props.slots]);
25
24
  return (React.createElement("div", null,
26
- React.createElement(InputRow, null,
25
+ React.createElement(Group, { position: "apart", spacing: "xs", grow: true, noWrap: true },
27
26
  React.createElement("p", { style: { flex: 1 } }, getMonthString(month)),
28
- React.createElement("p", null,
29
- React.createElement(Button, { label: "Previous month", onClick: () => moveMonth(-1) }, "<"),
30
- React.createElement(Button, { label: "Next month", onClick: () => moveMonth(1) }, ">"))),
27
+ React.createElement(Group, { position: "right", spacing: "xs" },
28
+ React.createElement(Button, { variant: "outline", "aria-label": "Previous month", onClick: () => moveMonth(-1) }, "<"),
29
+ React.createElement(Button, { variant: "outline", "aria-label": "Next month", onClick: () => moveMonth(1) }, ">"))),
31
30
  React.createElement("table", { className: "medplum-calendar-table" },
32
31
  React.createElement("thead", null,
33
32
  React.createElement("tr", null,
@@ -38,7 +37,7 @@ function CalendarInput(props) {
38
37
  React.createElement("th", null, "THU"),
39
38
  React.createElement("th", null, "FRI"),
40
39
  React.createElement("th", null, "SAT"))),
41
- React.createElement("tbody", null, grid.map((week, weekIndex) => (React.createElement("tr", { key: 'week-' + weekIndex }, week.map((day, dayIndex) => (React.createElement("td", { key: 'day-' + dayIndex }, day && (React.createElement("button", { disabled: !day.available, onClick: () => onClick(day.date) }, day.date.getDate()))))))))))));
40
+ React.createElement("tbody", null, grid.map((week, weekIndex) => (React.createElement("tr", { key: 'week-' + weekIndex }, week.map((day, dayIndex) => (React.createElement("td", { key: 'day-' + dayIndex }, day && (React.createElement(Button, { disabled: !day.available, onClick: () => onClick(day.date) }, day.date.getDate()))))))))))));
42
41
  }
43
42
  function getStartMonth() {
44
43
  const result = new Date();
@@ -1 +1 @@
1
- {"version":3,"file":"CalendarInput.js","sources":["../../src/CalendarInput.tsx"],"sourcesContent":["import { Slot } from '@medplum/fhirtypes';\nimport React, { useMemo, useState } from 'react';\nimport { Button } from './Button';\nimport { InputRow } from './InputRow';\nimport './CalendarInput.css';\n\nexport interface CalendarInputProps {\n slots: Slot[];\n onChangeMonth: (date: Date) => void;\n onClick: (date: Date) => void;\n}\n\n/**\n * Returns a month display string (e.g. \"January 2020\").\n * @param date Any date within the month.\n * @returns The month display string (e.g. \"January 2020\")\n */\nexport function getMonthString(date: Date): string {\n return date.toLocaleString('default', { month: 'long' }) + ' ' + date.getFullYear();\n}\n\ninterface CalendarCell {\n date: Date;\n available: boolean;\n}\n\ntype OptionalCalendarCell = CalendarCell | undefined;\n\nexport function CalendarInput(props: CalendarInputProps): JSX.Element {\n const { onChangeMonth, onClick } = props;\n const [month, setMonth] = useState<Date>(getStartMonth);\n\n function moveMonth(delta: number): void {\n setMonth((currMonth) => {\n const newMonth = new Date(currMonth.getTime());\n newMonth.setMonth(currMonth.getMonth() + delta);\n onChangeMonth(newMonth);\n return newMonth;\n });\n }\n\n const grid = useMemo(() => buildGrid(month, props.slots), [month, props.slots]);\n\n return (\n <div>\n <InputRow>\n <p style={{ flex: 1 }}>{getMonthString(month)}</p>\n <p>\n <Button label=\"Previous month\" onClick={() => moveMonth(-1)}>\n &lt;\n </Button>\n <Button label=\"Next month\" onClick={() => moveMonth(1)}>\n &gt;\n </Button>\n </p>\n </InputRow>\n <table className=\"medplum-calendar-table\">\n <thead>\n <tr>\n <th>SUN</th>\n <th>MON</th>\n <th>TUE</th>\n <th>WED</th>\n <th>THU</th>\n <th>FRI</th>\n <th>SAT</th>\n </tr>\n </thead>\n <tbody>\n {grid.map((week, weekIndex) => (\n <tr key={'week-' + weekIndex}>\n {week.map((day, dayIndex) => (\n <td key={'day-' + dayIndex}>\n {day && (\n <button disabled={!day.available} onClick={() => onClick(day.date)}>\n {day.date.getDate()}\n </button>\n )}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n}\n\nexport function getStartMonth(): Date {\n const result = new Date();\n result.setDate(1);\n result.setHours(0, 0, 0, 0);\n return result;\n}\n\nfunction buildGrid(startDate: Date, slots: Slot[]): OptionalCalendarCell[][] {\n const d = new Date(startDate.getFullYear(), startDate.getMonth());\n const grid: OptionalCalendarCell[][] = [];\n let row: OptionalCalendarCell[] = [];\n\n // Fill leading empty days\n for (let i = 0; i < d.getDay(); i++) {\n row.push(undefined);\n }\n\n while (d.getMonth() === startDate.getMonth()) {\n row.push({\n date: new Date(d.getTime()),\n available: isDayAvailable(d, slots),\n });\n\n if (d.getDay() === 6) {\n grid.push(row);\n row = [];\n }\n\n d.setDate(d.getDate() + 1);\n }\n\n // Fill trailing empty days\n if (d.getDay() !== 0) {\n for (let i = d.getDay(); i < 7; i++) {\n row.push(undefined);\n }\n grid.push(row);\n }\n\n return grid;\n}\n\n/**\n * Returns true if the given date is available for booking.\n * @param day The day to check.\n * @param slots The list of available slots.\n * @returns True if there are any available slots for the day.\n */\nfunction isDayAvailable(day: Date, slots: Slot[]): boolean {\n // Note that slot start and end time may or may not be in UTC.\n for (const slot of slots) {\n const slotStart = new Date(slot.start as string);\n if (\n slotStart.getFullYear() === day.getFullYear() &&\n slotStart.getMonth() === day.getMonth() &&\n slotStart.getDate() === day.getDate()\n ) {\n return true;\n }\n }\n\n return false;\n}\n"],"names":[],"mappings":";;;;AAYA;;;;AAIG;AACG,SAAU,cAAc,CAAC,IAAU,EAAA;AACvC,IAAA,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;AACtF,CAAC;AASK,SAAU,aAAa,CAAC,KAAyB,EAAA;AACrD,IAAA,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IACzC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAA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EAAE,CAAC,EAAE,EAAE;AACnC,YAAA,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACrB,SAAA;AACD,QAAA,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChB,KAAA;AAED,IAAA,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;AAKG;AACH,SAAS,cAAc,CAAC,GAAS,EAAE,KAAa,EAAA;;AAE9C,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,KAAe,CAAC,CAAC;QACjD,IACE,SAAS,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE;AAC7C,YAAA,SAAS,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,QAAQ,EAAE;YACvC,SAAS,CAAC,OAAO,EAAE,KAAK,GAAG,CAAC,OAAO,EAAE,EACrC;AACA,YAAA,OAAO,IAAI,CAAC;AACb,SAAA;AACF,KAAA;AAED,IAAA,OAAO,KAAK,CAAC;AACf;;;;"}
1
+ {"version":3,"file":"CalendarInput.js","sources":["../../src/CalendarInput.tsx"],"sourcesContent":["import { Button, Group } from '@mantine/core';\nimport { Slot } from '@medplum/fhirtypes';\nimport React, { useMemo, useState } from 'react';\n\nimport './CalendarInput.css';\n\nexport interface CalendarInputProps {\n slots: Slot[];\n onChangeMonth: (date: Date) => void;\n onClick: (date: Date) => void;\n}\n\n/**\n * Returns a month display string (e.g. \"January 2020\").\n * @param date Any date within the month.\n * @returns The month display string (e.g. \"January 2020\")\n */\nexport function getMonthString(date: Date): string {\n return date.toLocaleString('default', { month: 'long' }) + ' ' + date.getFullYear();\n}\n\ninterface CalendarCell {\n date: Date;\n available: boolean;\n}\n\ntype OptionalCalendarCell = CalendarCell | undefined;\n\nexport function CalendarInput(props: CalendarInputProps): JSX.Element {\n const { onChangeMonth, onClick } = props;\n const [month, setMonth] = useState<Date>(getStartMonth);\n\n function moveMonth(delta: number): void {\n setMonth((currMonth) => {\n const newMonth = new Date(currMonth.getTime());\n newMonth.setMonth(currMonth.getMonth() + delta);\n onChangeMonth(newMonth);\n return newMonth;\n });\n }\n\n const grid = useMemo(() => buildGrid(month, props.slots), [month, props.slots]);\n\n return (\n <div>\n <Group position=\"apart\" spacing=\"xs\" grow noWrap>\n <p style={{ flex: 1 }}>{getMonthString(month)}</p>\n <Group position=\"right\" spacing=\"xs\">\n <Button variant=\"outline\" aria-label=\"Previous month\" onClick={() => moveMonth(-1)}>\n &lt;\n </Button>\n <Button variant=\"outline\" aria-label=\"Next month\" onClick={() => moveMonth(1)}>\n &gt;\n </Button>\n </Group>\n </Group>\n <table className=\"medplum-calendar-table\">\n <thead>\n <tr>\n <th>SUN</th>\n <th>MON</th>\n <th>TUE</th>\n <th>WED</th>\n <th>THU</th>\n <th>FRI</th>\n <th>SAT</th>\n </tr>\n </thead>\n <tbody>\n {grid.map((week, weekIndex) => (\n <tr key={'week-' + weekIndex}>\n {week.map((day, dayIndex) => (\n <td key={'day-' + dayIndex}>\n {day && (\n <Button disabled={!day.available} onClick={() => onClick(day.date)}>\n {day.date.getDate()}\n </Button>\n )}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n}\n\nexport function getStartMonth(): Date {\n const result = new Date();\n result.setDate(1);\n result.setHours(0, 0, 0, 0);\n return result;\n}\n\nfunction buildGrid(startDate: Date, slots: Slot[]): OptionalCalendarCell[][] {\n const d = new Date(startDate.getFullYear(), startDate.getMonth());\n const grid: OptionalCalendarCell[][] = [];\n let row: OptionalCalendarCell[] = [];\n\n // Fill leading empty days\n for (let i = 0; i < d.getDay(); i++) {\n row.push(undefined);\n }\n\n while (d.getMonth() === startDate.getMonth()) {\n row.push({\n date: new Date(d.getTime()),\n available: isDayAvailable(d, slots),\n });\n\n if (d.getDay() === 6) {\n grid.push(row);\n row = [];\n }\n\n d.setDate(d.getDate() + 1);\n }\n\n // Fill trailing empty days\n if (d.getDay() !== 0) {\n for (let i = d.getDay(); i < 7; i++) {\n row.push(undefined);\n }\n grid.push(row);\n }\n\n return grid;\n}\n\n/**\n * Returns true if the given date is available for booking.\n * @param day The day to check.\n * @param slots The list of available slots.\n * @returns True if there are any available slots for the day.\n */\nfunction isDayAvailable(day: Date, slots: Slot[]): boolean {\n // Note that slot start and end time may or may not be in UTC.\n for (const slot of slots) {\n const slotStart = new Date(slot.start as string);\n if (\n slotStart.getFullYear() === day.getFullYear() &&\n slotStart.getMonth() === day.getMonth() &&\n slotStart.getDate() === day.getDate()\n ) {\n return true;\n }\n }\n\n return false;\n}\n"],"names":[],"mappings":";;;AAYA;;;;AAIG;AACG,SAAU,cAAc,CAAC,IAAU,EAAA;AACvC,IAAA,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;AACtF,CAAC;AASK,SAAU,aAAa,CAAC,KAAyB,EAAA;AACrD,IAAA,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IACzC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAO,aAAa,CAAC,CAAC;IAExD,SAAS,SAAS,CAAC,KAAa,EAAA;AAC9B,QAAA,QAAQ,CAAC,CAAC,SAAS,KAAI;YACrB,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;YAC/C,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC;YAChD,aAAa,CAAC,QAAQ,CAAC,CAAC;AACxB,YAAA,OAAO,QAAQ,CAAC;AAClB,SAAC,CAAC,CAAC;KACJ;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE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EAAE;QACxB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,KAAe,CAAC,CAAC;QACjD,IACE,SAAS,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE;AAC7C,YAAA,SAAS,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,QAAQ,EAAE;YACvC,SAAS,CAAC,OAAO,EAAE,KAAK,GAAG,CAAC,OAAO,EAAE,EACrC;AACA,YAAA,OAAO,IAAI,CAAC;AACb,SAAA;AACF,KAAA;AAED,IAAA,OAAO,KAAK,CAAC;AACf;;;;"}
@@ -3,7 +3,8 @@ import { ElementDefinition } from '@medplum/fhirtypes';
3
3
  export interface CodeInputProps {
4
4
  property: ElementDefinition;
5
5
  name: string;
6
+ placeholder?: string;
6
7
  defaultValue?: string;
7
- onChange?: (value: string) => void;
8
+ onChange?: (value: string | undefined) => void;
8
9
  }
9
10
  export declare function CodeInput(props: CodeInputProps): JSX.Element;
@@ -1,27 +1,22 @@
1
- import React from 'react';
2
- import { Autocomplete } from './Autocomplete.js';
3
- import { useMedplum } from './MedplumProvider.js';
1
+ import React, { useState } from 'react';
2
+ import { ValueSetAutocomplete } from './ValueSetAutocomplete.js';
4
3
 
5
- const cachedDisplayValues = {};
6
4
  function CodeInput(props) {
7
- const medplum = useMedplum();
8
- let defaultValue = undefined;
9
- if (props.defaultValue) {
10
- defaultValue = [props.defaultValue];
5
+ const [value, setValue] = useState(props.defaultValue);
6
+ function handleChange(newValue) {
7
+ const newCode = valueSetElementToCode(newValue);
8
+ setValue(newCode);
9
+ if (props.onChange) {
10
+ props.onChange(newCode);
11
+ }
11
12
  }
12
- return (React.createElement(Autocomplete, { loadOptions: (input) => {
13
- var _a;
14
- const system = (_a = props.property.binding) === null || _a === void 0 ? void 0 : _a.valueSet;
15
- return medplum.searchValueSet(system, input).then((valueSet) => {
16
- const contains = valueSet.expansion.contains;
17
- contains.forEach((e) => (cachedDisplayValues[e.code] = e.display));
18
- return contains.map((e) => e.code);
19
- });
20
- }, buildUnstructured: (str) => str, getId: (item) => item, getDisplay: (item) => React.createElement(React.Fragment, null, cachedDisplayValues[item] || item), name: props.name, defaultValue: defaultValue, loadOnFocus: true, onChange: (values) => {
21
- if (props.onChange) {
22
- props.onChange(values[0]);
23
- }
24
- } }));
13
+ return (React.createElement(ValueSetAutocomplete, { property: props.property, name: props.name, placeholder: props.placeholder, defaultValue: codeToValueSetElement(value), onChange: handleChange }));
14
+ }
15
+ function codeToValueSetElement(code) {
16
+ return { code };
17
+ }
18
+ function valueSetElementToCode(element) {
19
+ return element.code;
25
20
  }
26
21
 
27
22
  export { CodeInput };
@@ -1 +1 @@
1
- {"version":3,"file":"CodeInput.js","sources":["../../src/CodeInput.tsx"],"sourcesContent":["import { ElementDefinition, ValueSet, ValueSetExpansion, ValueSetExpansionContains } from '@medplum/fhirtypes';\nimport React from 'react';\nimport { Autocomplete } from './Autocomplete';\nimport { useMedplum } from './MedplumProvider';\n\nexport interface CodeInputProps {\n property: ElementDefinition;\n name: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n}\n\nconst cachedDisplayValues: Record<string, string> = {};\n\nexport function CodeInput(props: CodeInputProps): JSX.Element {\n const medplum = useMedplum();\n\n let defaultValue = undefined;\n if (props.defaultValue) {\n defaultValue = [props.defaultValue];\n }\n\n return (\n <Autocomplete\n loadOptions={(input: string): Promise<string[]> => {\n const system = props.property.binding?.valueSet as string;\n return medplum.searchValueSet(system, input).then((valueSet: ValueSet) => {\n const contains = (valueSet.expansion as ValueSetExpansion).contains as ValueSetExpansionContains[];\n contains.forEach((e) => (cachedDisplayValues[e.code as string] = e.display as string));\n return contains.map((e) => e.code as string);\n });\n }}\n buildUnstructured={(str: string) => str}\n getId={(item: string) => item}\n getDisplay={(item: string) => <>{cachedDisplayValues[item] || item}</>}\n name={props.name}\n defaultValue={defaultValue}\n loadOnFocus={true}\n onChange={(values: string[]) => {\n if (props.onChange) {\n props.onChange(values[0]);\n }\n }}\n />\n );\n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AAY,EAAE,YAAY,EAC1B,WAAW,EAAE,IAAI,EACjB,QAAQ,EAAE,CAAC,MAAgB,KAAI;YAC7B,IAAI,KAAK,CAAC,QAAQ,EAAE;gBAClB,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3B,aAAA;SACF,EAAA,CACD,EACF;AACJ;;;;"}
1
+ {"version":3,"file":"CodeInput.js","sources":["../../src/CodeInput.tsx"],"sourcesContent":["import { ElementDefinition, ValueSetExpansionContains } from '@medplum/fhirtypes';\nimport React, { useState } from 'react';\nimport { ValueSetAutocomplete } from './ValueSetAutocomplete';\n\nexport interface CodeInputProps {\n property: ElementDefinition;\n name: string;\n placeholder?: string;\n defaultValue?: string;\n onChange?: (value: string | undefined) => void;\n}\n\nexport function CodeInput(props: CodeInputProps): JSX.Element {\n const [value, setValue] = useState<string | undefined>(props.defaultValue);\n\n function handleChange(newValue: ValueSetExpansionContains): void {\n const newCode = valueSetElementToCode(newValue);\n setValue(newCode);\n if (props.onChange) {\n props.onChange(newCode);\n }\n }\n\n return (\n <ValueSetAutocomplete\n property={props.property}\n name={props.name}\n placeholder={props.placeholder}\n defaultValue={codeToValueSetElement(value)}\n onChange={handleChange}\n />\n );\n}\n\nfunction codeToValueSetElement(code: string | undefined): ValueSetExpansionContains {\n return { code };\n}\n\nfunction valueSetElementToCode(element: ValueSetExpansionContains): string | undefined {\n return element.code;\n}\n"],"names":[],"mappings":";;;AAYM,SAAU,SAAS,CAAC,KAAqB,EAAA;AAC7C,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAqB,KAAK,CAAC,YAAY,CAAC,CAAC;IAE3E,SAAS,YAAY,CAAC,QAAmC,EAAA;AACvD,QAAA,MAAM,OAAO,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAChD,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClB,IAAI,KAAK,CAAC,QAAQ,EAAE;AAClB,YAAA,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACzB,SAAA;KACF;AAED,IAAA,QACE,KAAA,CAAA,aAAA,CAAC,oBAAoB,EAAA,EACnB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,YAAY,EAAE,qBAAqB,CAAC,KAAK,CAAC,EAC1C,QAAQ,EAAE,YAAY,EAAA,CACtB,EACF;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAwB,EAAA;IACrD,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAkC,EAAA;IAC/D,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB;;;;"}
@@ -3,6 +3,7 @@ import { CodeableConcept, ElementDefinition } from '@medplum/fhirtypes';
3
3
  export interface CodeableConceptInputProps {
4
4
  property: ElementDefinition;
5
5
  name: string;
6
+ placeholder?: string;
6
7
  defaultValue?: CodeableConcept;
7
8
  onChange?: (value: CodeableConcept) => void;
8
9
  }
@@ -1,25 +1,24 @@
1
- import { stringify } from '@medplum/core';
2
- import React from 'react';
3
- import { Autocomplete } from './Autocomplete.js';
4
- import { useMedplum } from './MedplumProvider.js';
1
+ import React, { useState } from 'react';
2
+ import { ValueSetAutocomplete } from './ValueSetAutocomplete.js';
5
3
 
6
4
  function CodeableConceptInput(props) {
7
- const medplum = useMedplum();
8
- let defaultValue = undefined;
9
- if (props.defaultValue) {
10
- defaultValue = [props.defaultValue];
5
+ const [value, setValue] = useState(props.defaultValue);
6
+ function handleChange(newValue) {
7
+ const newConcept = valueSetElementToCodeableConcept(newValue);
8
+ setValue(newConcept);
9
+ if (props.onChange) {
10
+ props.onChange(newConcept);
11
+ }
11
12
  }
12
- return (React.createElement(Autocomplete, { loadOptions: (input) => {
13
- var _a;
14
- const system = (_a = props.property.binding) === null || _a === void 0 ? void 0 : _a.valueSet;
15
- return medplum.searchValueSet(system, input).then((valueSet) => {
16
- return valueSet.expansion.contains.map(valueSetElementToCodeableConcept);
17
- });
18
- }, buildUnstructured: buildUnstructured, getId: getId, getDisplay: getDisplay, name: props.name, defaultValue: defaultValue, loadOnFocus: true, onChange: (values) => {
19
- if (props.onChange) {
20
- props.onChange(values[0]);
21
- }
22
- } }));
13
+ return (React.createElement(ValueSetAutocomplete, { property: props.property, name: props.name, placeholder: props.placeholder, defaultValue: value && codeableConceptToValueSetElement(value), onChange: handleChange }));
14
+ }
15
+ function codeableConceptToValueSetElement(concept) {
16
+ var _a, _b, _c, _d, _e, _f;
17
+ return {
18
+ system: (_b = (_a = concept.coding) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.system,
19
+ code: (_d = (_c = concept.coding) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.code,
20
+ display: (_f = (_e = concept.coding) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.display,
21
+ };
23
22
  }
24
23
  function valueSetElementToCodeableConcept(element) {
25
24
  return {
@@ -33,20 +32,6 @@ function valueSetElementToCodeableConcept(element) {
33
32
  ],
34
33
  };
35
34
  }
36
- function buildUnstructured(str) {
37
- return { text: str };
38
- }
39
- function getId(concept) {
40
- if (concept.coding && concept.coding.length > 0) {
41
- return concept.coding[0].code;
42
- }
43
- return stringify(concept);
44
- }
45
- function getDisplay(concept) {
46
- var _a, _b, _c, _d, _e, _f;
47
- const text = (_f = (_c = (_b = (_a = concept.coding) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.display) !== null && _c !== void 0 ? _c : (_e = (_d = concept.coding) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.code) !== null && _f !== void 0 ? _f : concept.text;
48
- return React.createElement(React.Fragment, null, text);
49
- }
50
35
 
51
36
  export { CodeableConceptInput };
52
37
  //# sourceMappingURL=CodeableConceptInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeableConceptInput.js","sources":["../../src/CodeableConceptInput.tsx"],"sourcesContent":["import { stringify } from '@medplum/core';\nimport {\n CodeableConcept,\n ElementDefinition,\n ValueSet,\n ValueSetExpansion,\n ValueSetExpansionContains,\n} from '@medplum/fhirtypes';\nimport React from 'react';\nimport { Autocomplete } from './Autocomplete';\nimport { useMedplum } from './MedplumProvider';\n\nexport interface CodeableConceptInputProps {\n property: ElementDefinition;\n name: string;\n defaultValue?: CodeableConcept;\n onChange?: (value: CodeableConcept) => void;\n}\n\nexport function CodeableConceptInput(props: CodeableConceptInputProps): JSX.Element {\n const medplum = useMedplum();\n\n let defaultValue = undefined;\n if (props.defaultValue) {\n defaultValue = [props.defaultValue];\n }\n\n return (\n <Autocomplete\n loadOptions={(input: string): Promise<CodeableConcept[]> => {\n const system = props.property.binding?.valueSet as string;\n return medplum.searchValueSet(system, input).then((valueSet: ValueSet) => {\n return ((valueSet.expansion as ValueSetExpansion).contains as ValueSetExpansionContains[]).map(\n valueSetElementToCodeableConcept\n );\n });\n }}\n buildUnstructured={buildUnstructured}\n getId={getId}\n getDisplay={getDisplay}\n name={props.name}\n defaultValue={defaultValue}\n loadOnFocus={true}\n onChange={(values: CodeableConcept[]) => {\n if (props.onChange) {\n props.onChange(values[0]);\n }\n }}\n />\n );\n}\n\nfunction valueSetElementToCodeableConcept(element: ValueSetExpansionContains): CodeableConcept {\n return {\n text: element.display,\n coding: [\n {\n system: element.system,\n code: element.code,\n display: element.display,\n },\n ],\n };\n}\n\nfunction buildUnstructured(str: string): CodeableConcept {\n return { text: str };\n}\n\nfunction getId(concept: CodeableConcept): string {\n if (concept.coding && concept.coding.length > 0) {\n return concept.coding[0].code as string;\n }\n return stringify(concept);\n}\n\nfunction getDisplay(concept: CodeableConcept): JSX.Element {\n const text = concept.coding?.[0]?.display ?? concept.coding?.[0]?.code ?? concept.text;\n return <>{text}</>;\n}\n"],"names":[],"mappings":";;;;;AAmBM,S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AI,CAAC;AACrB;;;;"}
1
+ {"version":3,"file":"CodeableConceptInput.js","sources":["../../src/CodeableConceptInput.tsx"],"sourcesContent":["import { CodeableConcept, ElementDefinition, ValueSetExpansionContains } from '@medplum/fhirtypes';\nimport React, { useState } from 'react';\nimport { ValueSetAutocomplete } from './ValueSetAutocomplete';\n\nexport interface CodeableConceptInputProps {\n property: ElementDefinition;\n name: string;\n placeholder?: string;\n defaultValue?: CodeableConcept;\n onChange?: (value: CodeableConcept) => void;\n}\n\nexport function CodeableConceptInput(props: CodeableConceptInputProps): JSX.Element {\n const [value, setValue] = useState<CodeableConcept | undefined>(props.defaultValue);\n\n function handleChange(newValue: ValueSetExpansionContains): void {\n const newConcept = valueSetElementToCodeableConcept(newValue);\n setValue(newConcept);\n if (props.onChange) {\n props.onChange(newConcept);\n }\n }\n\n return (\n <ValueSetAutocomplete\n property={props.property}\n name={props.name}\n placeholder={props.placeholder}\n defaultValue={value && codeableConceptToValueSetElement(value)}\n onChange={handleChange}\n />\n );\n}\n\nfunction codeableConceptToValueSetElement(concept: CodeableConcept): ValueSetExpansionContains {\n return {\n system: concept.coding?.[0]?.system,\n code: concept.coding?.[0]?.code,\n display: concept.coding?.[0]?.display,\n };\n}\n\nfunction valueSetElementToCodeableConcept(element: ValueSetExpansionContains): CodeableConcept {\n return {\n text: element.display,\n coding: [\n {\n system: element.system,\n code: element.code,\n display: element.display,\n },\n ],\n };\n}\n"],"names":[],"mappings":";;;AAYM,SAAU,oBAAoB,CAAC,KAAgC,EAAA;AACnE,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA8B,KAAK,CAAC,YAAY,CAAC,CAAC;IAEpF,SAAS,YAAY,CAAC,QAAmC,EAAA;AACvD,QAAA,MAAM,UAAU,GAAG,gCAAgC,CAAC,QAAQ,CAAC,CAAC;QAC9D,QAAQ,CAAC,UAAU,CAAC,CAAC;QACrB,IAAI,KAAK,CAAC,QAAQ,EAAE;AAClB,YAAA,K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C,OAAO;AACrB,QAAA,MAAM,EAAE;AACN,YAAA;gBACE,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,OAAO,EAAE,OAAO,CAAC,OAAO;AACzB,aAAA;AACF,SAAA;KACF,CAAC;AACJ;;;;"}
@@ -3,6 +3,7 @@ import { Coding, ElementDefinition } from '@medplum/fhirtypes';
3
3
  export interface CodingInputProps {
4
4
  property: ElementDefinition;
5
5
  name: string;
6
+ placeholder?: string;
6
7
  defaultValue?: Coding;
7
8
  onChange?: (value: Coding) => void;
8
9
  }