@medplum/react 0.9.37 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/AttachmentButton.d.ts +9 -0
- package/dist/cjs/CodeInput.d.ts +2 -1
- package/dist/cjs/CodeableConceptInput.d.ts +1 -0
- package/dist/cjs/CodingInput.d.ts +1 -0
- package/dist/cjs/DateTimeInput.d.ts +9 -2
- package/dist/cjs/ReferenceInput.d.ts +1 -0
- package/dist/cjs/ResourceAvatar.d.ts +8 -0
- package/dist/cjs/ResourceBadge.d.ts +0 -1
- package/dist/cjs/ResourceInput.d.ts +2 -3
- package/dist/cjs/SearchPopupMenu.d.ts +0 -4
- package/dist/cjs/SearchUtils.d.ts +5 -5
- package/dist/cjs/ValueSetAutocomplete.d.ts +10 -0
- package/dist/cjs/auth/RegisterForm.d.ts +0 -1
- package/dist/cjs/auth/SignInForm.d.ts +0 -1
- package/dist/cjs/defaulttheme.css +0 -51
- package/dist/cjs/index.d.ts +3 -13
- package/dist/cjs/index.js +793 -1492
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/cjs/stories/{UploadButton.stories.d.ts → AttachmentButton.stories.d.ts} +1 -0
- package/dist/cjs/stories/{Input.stories.d.ts → PeriodInput.stories.d.ts} +1 -1
- package/dist/cjs/stories/{Avatar.stories.d.ts → ResourceAvatar.stories.d.ts} +0 -0
- package/dist/cjs/stories/ResourceForm.stories.d.ts +1 -0
- package/dist/cjs/stories/{Dialog.stories.d.ts → ResourceInput.stories.d.ts} +2 -1
- package/dist/cjs/stories/SearchControl.stories.d.ts +1 -0
- package/dist/cjs/styles.css +72 -1053
- package/dist/cjs/utils/outcomes.d.ts +1 -0
- package/dist/esm/AddressInput.js +9 -21
- package/dist/esm/AddressInput.js.map +1 -1
- package/dist/esm/AnnotationInput.js +2 -2
- package/dist/esm/AnnotationInput.js.map +1 -1
- package/dist/esm/AttachmentArrayInput.js +11 -8
- package/dist/esm/AttachmentArrayInput.js.map +1 -1
- package/dist/esm/AttachmentButton.d.ts +9 -0
- package/dist/esm/{UploadButton.js → AttachmentButton.js} +9 -9
- package/dist/esm/AttachmentButton.js.map +1 -0
- package/dist/esm/AttachmentInput.js +3 -3
- package/dist/esm/AttachmentInput.js.map +1 -1
- package/dist/esm/CalendarInput.js +6 -7
- package/dist/esm/CalendarInput.js.map +1 -1
- package/dist/esm/CodeInput.d.ts +2 -1
- package/dist/esm/CodeInput.js +16 -21
- package/dist/esm/CodeInput.js.map +1 -1
- package/dist/esm/CodeableConceptInput.d.ts +1 -0
- package/dist/esm/CodeableConceptInput.js +18 -33
- package/dist/esm/CodeableConceptInput.js.map +1 -1
- package/dist/esm/CodingInput.d.ts +1 -0
- package/dist/esm/CodingInput.js +24 -23
- package/dist/esm/CodingInput.js.map +1 -1
- package/dist/esm/ContactDetailInput.js +3 -4
- package/dist/esm/ContactDetailInput.js.map +1 -1
- package/dist/esm/ContactPointInput.js +5 -21
- package/dist/esm/ContactPointInput.js.map +1 -1
- package/dist/esm/DateTimeInput.d.ts +9 -2
- package/dist/esm/DateTimeInput.js +13 -3
- package/dist/esm/DateTimeInput.js.map +1 -1
- package/dist/esm/DiagnosticReportDisplay.js +16 -1
- package/dist/esm/DiagnosticReportDisplay.js.map +1 -1
- package/dist/esm/EncounterTimeline.js +2 -0
- package/dist/esm/EncounterTimeline.js.map +1 -1
- package/dist/esm/ExtensionInput.js +2 -2
- package/dist/esm/ExtensionInput.js.map +1 -1
- package/dist/esm/FhirPathTable.js +4 -5
- package/dist/esm/FhirPathTable.js.map +1 -1
- package/dist/esm/HumanNameInput.js +7 -17
- package/dist/esm/HumanNameInput.js.map +1 -1
- package/dist/esm/IdentifierInput.js +4 -5
- package/dist/esm/IdentifierInput.js.map +1 -1
- package/dist/esm/Logo.js +4 -4
- package/dist/esm/Logo.js.map +1 -1
- package/dist/esm/PatientTimeline.js +2 -0
- package/dist/esm/PatientTimeline.js.map +1 -1
- package/dist/esm/PeriodInput.js +5 -5
- package/dist/esm/PeriodInput.js.map +1 -1
- package/dist/esm/PlanDefinitionBuilder.js +17 -29
- package/dist/esm/PlanDefinitionBuilder.js.map +1 -1
- package/dist/esm/QuantityInput.js +5 -12
- package/dist/esm/QuantityInput.js.map +1 -1
- package/dist/esm/QuestionnaireBuilder.js +22 -25
- package/dist/esm/QuestionnaireBuilder.js.map +1 -1
- package/dist/esm/QuestionnaireForm.js +35 -29
- package/dist/esm/QuestionnaireForm.js.map +1 -1
- package/dist/esm/RangeInput.js +2 -2
- package/dist/esm/RangeInput.js.map +1 -1
- package/dist/esm/RatioInput.js +2 -2
- package/dist/esm/RatioInput.js.map +1 -1
- package/dist/esm/ReferenceInput.d.ts +1 -0
- package/dist/esm/ReferenceInput.js +4 -6
- package/dist/esm/ReferenceInput.js.map +1 -1
- package/dist/esm/RequestGroupDisplay.js +1 -1
- package/dist/esm/RequestGroupDisplay.js.map +1 -1
- package/dist/esm/ResourceArrayInput.js +10 -7
- package/dist/esm/ResourceArrayInput.js.map +1 -1
- package/dist/esm/ResourceAvatar.d.ts +8 -0
- package/dist/esm/ResourceAvatar.js +24 -0
- package/dist/esm/ResourceAvatar.js.map +1 -0
- package/dist/esm/ResourceBadge.d.ts +0 -1
- package/dist/esm/ResourceBadge.js +2 -3
- package/dist/esm/ResourceBadge.js.map +1 -1
- package/dist/esm/ResourceBlame.js +3 -3
- package/dist/esm/ResourceBlame.js.map +1 -1
- package/dist/esm/ResourceForm.js +10 -10
- package/dist/esm/ResourceForm.js.map +1 -1
- package/dist/esm/ResourceInput.d.ts +2 -3
- package/dist/esm/ResourceInput.js +37 -29
- package/dist/esm/ResourceInput.js.map +1 -1
- package/dist/esm/ResourcePropertyInput.js +30 -18
- package/dist/esm/ResourcePropertyInput.js.map +1 -1
- package/dist/esm/ResourceTimeline.js +19 -15
- package/dist/esm/ResourceTimeline.js.map +1 -1
- package/dist/esm/Scheduler.js +7 -7
- package/dist/esm/Scheduler.js.map +1 -1
- package/dist/esm/SearchControl.js +76 -58
- package/dist/esm/SearchControl.js.map +1 -1
- package/dist/esm/SearchControlField.js.map +1 -1
- package/dist/esm/SearchFieldEditor.js +7 -7
- package/dist/esm/SearchFieldEditor.js.map +1 -1
- package/dist/esm/SearchFilterEditor.js +10 -15
- package/dist/esm/SearchFilterEditor.js.map +1 -1
- package/dist/esm/SearchFilterValueDialog.js +4 -3
- package/dist/esm/SearchFilterValueDialog.js.map +1 -1
- package/dist/esm/SearchFilterValueInput.js +6 -7
- package/dist/esm/SearchFilterValueInput.js.map +1 -1
- package/dist/esm/SearchPopupMenu.d.ts +0 -4
- package/dist/esm/SearchPopupMenu.js +59 -73
- package/dist/esm/SearchPopupMenu.js.map +1 -1
- package/dist/esm/SearchUtils.d.ts +5 -5
- package/dist/esm/SearchUtils.js +11 -12
- package/dist/esm/SearchUtils.js.map +1 -1
- package/dist/esm/ServiceRequestTimeline.js +2 -0
- package/dist/esm/ServiceRequestTimeline.js.map +1 -1
- package/dist/esm/Timeline.js +12 -20
- package/dist/esm/Timeline.js.map +1 -1
- package/dist/esm/TimingInput.js +14 -17
- package/dist/esm/TimingInput.js.map +1 -1
- package/dist/esm/ValueSetAutocomplete.d.ts +10 -0
- package/dist/esm/ValueSetAutocomplete.js +57 -0
- package/dist/esm/ValueSetAutocomplete.js.map +1 -0
- package/dist/esm/auth/AuthenticationForm.js +12 -20
- package/dist/esm/auth/AuthenticationForm.js.map +1 -1
- package/dist/esm/auth/ChooseProfileForm.js +10 -10
- package/dist/esm/auth/ChooseProfileForm.js.map +1 -1
- package/dist/esm/auth/NewProjectForm.js +12 -15
- package/dist/esm/auth/NewProjectForm.js.map +1 -1
- package/dist/esm/auth/NewUserForm.js +25 -33
- package/dist/esm/auth/NewUserForm.js.map +1 -1
- package/dist/esm/auth/RegisterForm.d.ts +0 -1
- package/dist/esm/auth/RegisterForm.js.map +1 -1
- package/dist/esm/auth/SignInForm.d.ts +0 -1
- package/dist/esm/auth/SignInForm.js.map +1 -1
- package/dist/esm/defaulttheme.css +0 -51
- package/dist/esm/index.d.ts +3 -13
- package/dist/esm/index.js +4 -14
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/node_modules/tslib/tslib.es6.js +13 -1
- package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/esm/stories/{UploadButton.stories.d.ts → AttachmentButton.stories.d.ts} +1 -0
- package/dist/{cjs/stories/Select.stories.d.ts → esm/stories/PeriodInput.stories.d.ts} +1 -1
- package/dist/esm/stories/{Avatar.stories.d.ts → ResourceAvatar.stories.d.ts} +0 -0
- package/dist/esm/stories/ResourceForm.stories.d.ts +1 -0
- package/dist/{cjs/stories/FormSection.stories.d.ts → esm/stories/ResourceInput.stories.d.ts} +2 -2
- package/dist/esm/stories/SearchControl.stories.d.ts +1 -0
- package/dist/esm/styles.css +72 -1053
- package/dist/esm/utils/outcomes.d.ts +1 -0
- package/dist/esm/utils/outcomes.js +5 -1
- package/dist/esm/utils/outcomes.js.map +1 -1
- package/package.json +27 -19
- package/dist/cjs/Autocomplete.d.ts +0 -20
- package/dist/cjs/Avatar.d.ts +0 -12
- package/dist/cjs/Button.d.ts +0 -15
- package/dist/cjs/Checkbox.d.ts +0 -12
- package/dist/cjs/Dialog.d.ts +0 -10
- package/dist/cjs/Header.d.ts +0 -12
- package/dist/cjs/HeaderSearchInput.d.ts +0 -10
- package/dist/cjs/Input.d.ts +0 -22
- package/dist/cjs/InputRow.d.ts +0 -7
- package/dist/cjs/Loading.d.ts +0 -3
- package/dist/cjs/MenuItem.d.ts +0 -9
- package/dist/cjs/MenuSeparator.d.ts +0 -3
- package/dist/cjs/Popup.d.ts +0 -14
- package/dist/cjs/Select.d.ts +0 -16
- package/dist/cjs/SubMenu.d.ts +0 -7
- package/dist/cjs/TextArea.d.ts +0 -18
- package/dist/cjs/UploadButton.d.ts +0 -7
- package/dist/cjs/stories/Autocomplete.stories.d.ts +0 -9
- package/dist/cjs/stories/Button.stories.d.ts +0 -9
- package/dist/cjs/stories/Header.stories.d.ts +0 -8
- package/dist/cjs/stories/Loading.stories.d.ts +0 -5
- package/dist/esm/Autocomplete.d.ts +0 -20
- package/dist/esm/Autocomplete.js +0 -281
- package/dist/esm/Autocomplete.js.map +0 -1
- package/dist/esm/Avatar.d.ts +0 -12
- package/dist/esm/Avatar.js +0 -24
- package/dist/esm/Avatar.js.map +0 -1
- package/dist/esm/Button.d.ts +0 -15
- package/dist/esm/Button.js +0 -13
- package/dist/esm/Button.js.map +0 -1
- package/dist/esm/Checkbox.d.ts +0 -12
- package/dist/esm/Checkbox.js +0 -13
- package/dist/esm/Checkbox.js.map +0 -1
- package/dist/esm/Dialog.d.ts +0 -10
- package/dist/esm/Dialog.js +0 -43
- package/dist/esm/Dialog.js.map +0 -1
- package/dist/esm/Header.d.ts +0 -12
- package/dist/esm/Header.js +0 -99
- package/dist/esm/Header.js.map +0 -1
- package/dist/esm/HeaderSearchInput.d.ts +0 -10
- package/dist/esm/HeaderSearchInput.js +0 -181
- package/dist/esm/HeaderSearchInput.js.map +0 -1
- package/dist/esm/Input.d.ts +0 -22
- package/dist/esm/Input.js +0 -26
- package/dist/esm/Input.js.map +0 -1
- package/dist/esm/InputRow.d.ts +0 -7
- package/dist/esm/InputRow.js +0 -8
- package/dist/esm/InputRow.js.map +0 -1
- package/dist/esm/Loading.d.ts +0 -3
- package/dist/esm/Loading.js +0 -11
- package/dist/esm/Loading.js.map +0 -1
- package/dist/esm/MenuItem.d.ts +0 -9
- package/dist/esm/MenuItem.js +0 -8
- package/dist/esm/MenuItem.js.map +0 -1
- package/dist/esm/MenuSeparator.d.ts +0 -3
- package/dist/esm/MenuSeparator.js +0 -8
- package/dist/esm/MenuSeparator.js.map +0 -1
- package/dist/esm/Popup.d.ts +0 -14
- package/dist/esm/Popup.js +0 -78
- package/dist/esm/Popup.js.map +0 -1
- package/dist/esm/Select.d.ts +0 -16
- package/dist/esm/Select.js +0 -16
- package/dist/esm/Select.js.map +0 -1
- package/dist/esm/SubMenu.d.ts +0 -7
- package/dist/esm/SubMenu.js +0 -38
- package/dist/esm/SubMenu.js.map +0 -1
- package/dist/esm/TextArea.d.ts +0 -18
- package/dist/esm/TextArea.js +0 -16
- package/dist/esm/TextArea.js.map +0 -1
- package/dist/esm/UploadButton.d.ts +0 -7
- package/dist/esm/UploadButton.js.map +0 -1
- package/dist/esm/stories/Autocomplete.stories.d.ts +0 -9
- package/dist/esm/stories/Button.stories.d.ts +0 -9
- package/dist/esm/stories/Dialog.stories.d.ts +0 -5
- package/dist/esm/stories/FormSection.stories.d.ts +0 -6
- package/dist/esm/stories/Header.stories.d.ts +0 -8
- package/dist/esm/stories/Input.stories.d.ts +0 -6
- package/dist/esm/stories/Loading.stories.d.ts +0 -5
- package/dist/esm/stories/Select.stories.d.ts +0 -6
|
@@ -1,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;
|
package/dist/esm/AddressInput.js
CHANGED
|
@@ -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(
|
|
49
|
-
React.createElement(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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 {
|
|
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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AC/B,QAAQ,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,EAChD,CAAA;AACF,QAAA,KAAA,CAAA,aAAA,CAAC,SAAS,EAAA,EACR,WAAW,EAAC,QAAQ,EACpB,YAAY,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,EAC/B,QAAQ,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,EAChD,CAAA;QACF,KAAC,CAAA,aAAA,CAAA,SAAS,EAAC,EAAA,WAAW,EAAC,MAAM,EAAC,YAAY,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,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(
|
|
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 {
|
|
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: "
|
|
21
|
-
React.createElement("col", { width: "
|
|
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(
|
|
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
|
-
} },
|
|
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(
|
|
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
|
|
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,GA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IAAI,EACT,OAAO,EAAE,CAAC,CAAmB,KAAI;4BAC/B,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;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
|
|
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
|
-
|
|
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 {
|
|
55
|
-
//# sourceMappingURL=
|
|
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,CAAo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OAAO,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAI,CAAC,CAAC;AAC5C,SAAC,CAAC,CAAC;KACN;AAED,IAAA,QACE,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA;AACE,QAAA,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EACE,IAAI,EAAC,MAAM,EAAA,aAAA,EACC,mBAAmB,EAC/B,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAC1B,GAAG,EAAE,YAAY,EACjB,QAAQ,EAAE,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,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(
|
|
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 {
|
|
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(
|
|
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("
|
|
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(
|
|
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 {
|
|
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 <\n </Button>\n <Button variant=\"outline\" aria-label=\"Next month\" onClick={() => moveMonth(1)}>\n >\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,KAAK,CAAC,KAAK,CAAC,CAAC,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AAI,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;;;;"}
|
package/dist/esm/CodeInput.d.ts
CHANGED
|
@@ -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;
|
package/dist/esm/CodeInput.js
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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,
|
|
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 {
|
|
2
|
-
import
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 {
|
|
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,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC5B,SAAA;KACF;AAED,IAAA,QACE,KAAC,CAAA,aAAA,CAAA,oBAAoB,EACnB,EAAA,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,YAAY,EAAE,KAAK,IAAI,gCAAgC,CAAC,KAAK,CAAC,EAC9D,QAAQ,EAAE,YAAY,EAAA,CACtB,EACF;AACJ,CAAC;AAED,SAAS,gCAAgC,CAAC,OAAwB,EAAA;;IAChE,OAAO;QACL,MAAM,EAAE,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAO,CAAC,MAAM,MAAG,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KA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