@aehrc/smart-forms-renderer 0.13.2 → 0.14.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/lib/components/FormComponents/AttachmentItem/AttachmentField.d.ts +13 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentField.js +39 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentField.js.map +1 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentFieldWrapper.d.ts +14 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentFieldWrapper.js +34 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentFieldWrapper.js.map +1 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentFileCollector.d.ts +8 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentFileCollector.js +61 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentFileCollector.js.map +1 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentFileDropBox.d.ts +11 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentFileDropBox.js +49 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentFileDropBox.js.map +1 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentFileDropBox.styles.d.ts +7 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentFileDropBox.styles.js +30 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentFileDropBox.styles.js.map +1 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentItem.d.ts +14 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentItem.js +86 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentItem.js.map +1 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentUrlField.d.ts +10 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentUrlField.js +39 -0
- package/lib/components/FormComponents/AttachmentItem/AttachmentUrlField.js.map +1 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteField.d.ts +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteField.js +2 -2
- package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteField.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.d.ts +2 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.js +6 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js +3 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.d.ts +2 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js +6 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js +3 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.js +2 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.d.ts +2 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.js +8 -5
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js +3 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/DateItem/DateField.js +2 -1
- package/lib/components/FormComponents/DateItem/DateField.js.map +1 -1
- package/lib/components/FormComponents/DateTimeItem/DateTimeField.js +2 -1
- package/lib/components/FormComponents/DateTimeItem/DateTimeField.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.js +2 -2
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.js +2 -2
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.d.ts +2 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.js +7 -4
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js +3 -3
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.js +28 -16
- package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.js.map +1 -1
- package/lib/components/FormComponents/SliderItem/SliderField.js +2 -1
- package/lib/components/FormComponents/SliderItem/SliderField.js.map +1 -1
- package/lib/components/FormComponents/Textfield.styles.d.ts +1 -0
- package/lib/components/FormComponents/Textfield.styles.js +2 -1
- package/lib/components/FormComponents/Textfield.styles.js.map +1 -1
- package/lib/components/FormComponents/TimeItem/TimeField.js +2 -1
- package/lib/components/FormComponents/TimeItem/TimeField.js.map +1 -1
- package/lib/hooks/UseFileDrop.d.ts +10 -0
- package/lib/hooks/UseFileDrop.js +40 -0
- package/lib/hooks/UseFileDrop.js.map +1 -0
- package/lib/hooks/useAttachmentUrlValidation.d.ts +2 -0
- package/lib/hooks/useAttachmentUrlValidation.js +27 -0
- package/lib/hooks/useAttachmentUrlValidation.js.map +1 -0
- package/lib/hooks/useValueSetCodings.d.ts +5 -1
- package/lib/hooks/useValueSetCodings.js +1 -1
- package/lib/hooks/useValueSetCodings.js.map +1 -1
- package/lib/utils/fileUtils.d.ts +3 -0
- package/lib/utils/fileUtils.js +64 -0
- package/lib/utils/fileUtils.js.map +1 -0
- package/lib/utils/validateQuestionnaire.d.ts +3 -5
- package/lib/utils/validateQuestionnaire.js +8 -5
- package/lib/utils/validateQuestionnaire.js.map +1 -1
- package/package.json +3 -1
- package/src/components/FormComponents/AttachmentItem/AttachmentField.tsx +96 -0
- package/src/components/FormComponents/AttachmentItem/AttachmentFieldWrapper.tsx +87 -0
- package/src/components/FormComponents/AttachmentItem/AttachmentFileCollector.tsx +101 -0
- package/src/components/FormComponents/AttachmentItem/AttachmentFileDropBox.styles.ts +31 -0
- package/src/components/FormComponents/AttachmentItem/AttachmentFileDropBox.tsx +66 -0
- package/src/components/FormComponents/AttachmentItem/AttachmentItem.tsx +123 -0
- package/src/components/FormComponents/AttachmentItem/AttachmentUrlField.tsx +78 -0
- package/src/components/FormComponents/ChoiceItems/ChoiceAutocompleteField.tsx +3 -3
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.tsx +6 -4
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.tsx +3 -3
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.tsx +7 -4
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.tsx +3 -3
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.tsx +2 -1
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.tsx +9 -6
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.tsx +3 -3
- package/src/components/FormComponents/DateItem/DateField.tsx +2 -1
- package/src/components/FormComponents/DateTimeItem/DateTimeField.tsx +2 -1
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.tsx +2 -2
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.tsx +2 -2
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.tsx +9 -6
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.tsx +3 -3
- package/src/components/FormComponents/SingleItem/SingleItemSwitcher.tsx +67 -31
- package/src/components/FormComponents/SliderItem/SliderField.tsx +2 -1
- package/src/components/FormComponents/Textfield.styles.ts +3 -1
- package/src/components/FormComponents/TimeItem/TimeField.tsx +2 -1
- package/src/hooks/UseFileDrop.ts +53 -0
- package/src/hooks/useAttachmentUrlValidation.ts +27 -0
- package/src/hooks/useValueSetCodings.ts +10 -2
- package/src/utils/fileUtils.ts +66 -0
- package/src/utils/validateQuestionnaire.ts +17 -13
|
@@ -17,10 +17,11 @@
|
|
|
17
17
|
import React from 'react';
|
|
18
18
|
import { LocalizationProvider, TimePicker as MuiTimePicker } from '@mui/x-date-pickers';
|
|
19
19
|
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
20
|
+
import { TEXT_FIELD_WIDTH } from '../Textfield.styles';
|
|
20
21
|
function TimeField(props) {
|
|
21
22
|
const { value, displayPrompt, entryFormat, readOnly, isTabled, onTimeChange } = props;
|
|
22
23
|
return (React.createElement(LocalizationProvider, { dateAdapter: AdapterDayjs },
|
|
23
|
-
React.createElement(MuiTimePicker, { format: entryFormat !== '' ? entryFormat : 'hh:mm a', value: value, disabled: readOnly, label: displayPrompt, sx: { maxWidth: !isTabled ?
|
|
24
|
+
React.createElement(MuiTimePicker, { format: entryFormat !== '' ? entryFormat : 'hh:mm a', value: value, disabled: readOnly, label: displayPrompt, sx: { maxWidth: !isTabled ? TEXT_FIELD_WIDTH : 3000, minWidth: 160 }, slotProps: {
|
|
24
25
|
textField: {
|
|
25
26
|
fullWidth: true
|
|
26
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeField.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/TimeItem/TimeField.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,oBAAoB,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"TimeField.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/TimeItem/TimeField.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,oBAAoB,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAUvD,SAAS,SAAS,CAAC,KAAqB;IACtC,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAEtF,OAAO,CACL,oBAAC,oBAAoB,IAAC,WAAW,EAAE,YAAY;QAC7C,oBAAC,aAAa,IACZ,MAAM,EAAE,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EACpD,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,aAAa,EACpB,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,EACpE,SAAS,EAAE;gBACT,SAAS,EAAE;oBACT,SAAS,EAAE,IAAI;iBAChB;aACF,EACD,QAAQ,EAAE,YAAY,GACtB,CACmB,CACxB,CAAC;AACJ,CAAC;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ConnectDropTarget } from 'react-dnd';
|
|
2
|
+
interface UseFileDrop {
|
|
3
|
+
canDrop: boolean;
|
|
4
|
+
isOver: boolean;
|
|
5
|
+
dropTarget: ConnectDropTarget;
|
|
6
|
+
}
|
|
7
|
+
declare function UseFileDrop(onDrop: (item: {
|
|
8
|
+
files: any[];
|
|
9
|
+
}) => void): UseFileDrop;
|
|
10
|
+
export default UseFileDrop;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
+
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { useDrop } from 'react-dnd';
|
|
18
|
+
import { NativeTypes } from 'react-dnd-html5-backend';
|
|
19
|
+
function UseFileDrop(onDrop) {
|
|
20
|
+
const [{ canDrop, isOver }, drop] = useDrop(() => ({
|
|
21
|
+
accept: [NativeTypes.FILE],
|
|
22
|
+
drop(item) {
|
|
23
|
+
if (onDrop) {
|
|
24
|
+
onDrop(item);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
canDrop() {
|
|
28
|
+
return true;
|
|
29
|
+
},
|
|
30
|
+
collect: (monitor) => {
|
|
31
|
+
return {
|
|
32
|
+
isOver: monitor.isOver(),
|
|
33
|
+
canDrop: monitor.canDrop()
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}), [onDrop]);
|
|
37
|
+
return { canDrop, isOver, dropTarget: drop };
|
|
38
|
+
}
|
|
39
|
+
export default UseFileDrop;
|
|
40
|
+
//# sourceMappingURL=UseFileDrop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseFileDrop.js","sourceRoot":"","sources":["../../src/hooks/UseFileDrop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAQtD,SAAS,WAAW,CAAC,MAAwC;IAC3D,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,GAAG,OAAO,CACzC,GAAG,EAAE,CAAC,CAAC;QACL,MAAM,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;QAC1B,IAAI,CAAC,IAAsB;YACzB,IAAI,MAAM,EAAE;gBACV,MAAM,CAAC,IAAI,CAAC,CAAC;aACd;QACH,CAAC;QACD,OAAO;YACL,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,EAAE,CAAC,OAA0B,EAAE,EAAE;YACtC,OAAO;gBACL,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;gBACxB,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;aAC3B,CAAC;QACJ,CAAC;KACF,CAAC,EACF,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AAC/C,CAAC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Commonwealth Scientific and Industrial Research
|
|
3
|
+
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
function useAttachmentUrlValidation(url) {
|
|
18
|
+
try {
|
|
19
|
+
new URL(url);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export default useAttachmentUrlValidation;
|
|
27
|
+
//# sourceMappingURL=useAttachmentUrlValidation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAttachmentUrlValidation.js","sourceRoot":"","sources":["../../src/hooks/useAttachmentUrlValidation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,SAAS,0BAA0B,CAAC,GAAW;IAC7C,IAAI;QACF,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACb,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Coding, QuestionnaireItem } from 'fhir/r4';
|
|
2
|
+
export interface TerminologyError {
|
|
3
|
+
error: Error | null;
|
|
4
|
+
answerValueSet: string;
|
|
5
|
+
}
|
|
2
6
|
declare function useValueSetCodings(qItem: QuestionnaireItem): {
|
|
3
7
|
codings: Coding[];
|
|
4
|
-
|
|
8
|
+
terminologyError: TerminologyError;
|
|
5
9
|
};
|
|
6
10
|
export default useValueSetCodings;
|
|
@@ -120,7 +120,7 @@ function useValueSetCodings(qItem) {
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
}, [qItem]);
|
|
123
|
-
return { codings, serverError };
|
|
123
|
+
return { codings, terminologyError: { error: serverError, answerValueSet: valueSetUrl !== null && valueSetUrl !== void 0 ? valueSetUrl : '' } };
|
|
124
124
|
}
|
|
125
125
|
export default useValueSetCodings;
|
|
126
126
|
//# sourceMappingURL=useValueSetCodings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useValueSetCodings.js","sourceRoot":"","sources":["../../src/hooks/useValueSetCodings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"useValueSetCodings.js","sourceRoot":"","sources":["../../src/hooks/useValueSetCodings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,QAAQ,M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,CAAC,CAAC;gBAC7C,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;oBACtB,gBAAgB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;oBACvC,UAAU,CAAC,OAAO,CAAC,CAAC;iBACrB;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;gBACtB,cAAc,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC;SACN;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,EAAE,EAAE,CAAC;AAClG,CAAC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
+
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
export function getFileSize(fileSizeString) {
|
|
27
|
+
if (fileSizeString.length < 7) {
|
|
28
|
+
return `${Math.round(+fileSizeString / 1024)}kb`;
|
|
29
|
+
}
|
|
30
|
+
return `${Math.round(+fileSizeString / 1024) / 1000}MB`;
|
|
31
|
+
}
|
|
32
|
+
const fileToBase64 = (file) => new Promise((resolve, reject) => {
|
|
33
|
+
const reader = new FileReader();
|
|
34
|
+
reader.readAsDataURL(file);
|
|
35
|
+
reader.onload = () => resolve(reader.result);
|
|
36
|
+
reader.onerror = reject;
|
|
37
|
+
});
|
|
38
|
+
export function createAttachmentAnswer(file, url, fileName) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (!file || url === '') {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const base64Data = (yield fileToBase64(file));
|
|
45
|
+
const attachment = {
|
|
46
|
+
contentType: file.type,
|
|
47
|
+
data: base64Data,
|
|
48
|
+
size: file.size
|
|
49
|
+
};
|
|
50
|
+
if (url) {
|
|
51
|
+
attachment.url = url;
|
|
52
|
+
}
|
|
53
|
+
if (fileName) {
|
|
54
|
+
attachment.title = fileName;
|
|
55
|
+
}
|
|
56
|
+
return attachment;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
console.error(error);
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=fileUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileUtils.js","sourceRoot":"","sources":["../../src/utils/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;YAED,OAAO,UAAU,CAAC;SACnB;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;SACb;IACH,CAAC;CAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { QuestionnaireResponse } from 'fhir/r4';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { RegexValidation } from '../interfaces/regex.interface';
|
|
1
|
+
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
2
|
+
import type { EnableWhenExpression, EnableWhenItems } from '../interfaces/enableWhen.interface';
|
|
3
|
+
import type { RegexValidation } from '../interfaces/regex.interface';
|
|
5
4
|
export type InvalidType = 'regex' | 'minLength' | 'maxLength' | 'required';
|
|
6
5
|
interface ValidateQuestionnaireParams {
|
|
7
6
|
questionnaire: Questionnaire;
|
|
@@ -14,7 +13,6 @@ interface ValidateQuestionnaireParams {
|
|
|
14
13
|
/**
|
|
15
14
|
* Recursively go through the questionnaireResponse and check for un-filled required qItems
|
|
16
15
|
* At the moment item.required for group items are not checked
|
|
17
|
-
* FIXME will eventually be renamed to validate questionnaire
|
|
18
16
|
*
|
|
19
17
|
* @author Sean Fong
|
|
20
18
|
*/
|
|
@@ -21,7 +21,6 @@ import { structuredDataCapture } from 'fhir-sdc-helpers';
|
|
|
21
21
|
/**
|
|
22
22
|
* Recursively go through the questionnaireResponse and check for un-filled required qItems
|
|
23
23
|
* At the moment item.required for group items are not checked
|
|
24
|
-
* FIXME will eventually be renamed to validate questionnaire
|
|
25
24
|
*
|
|
26
25
|
* @author Sean Fong
|
|
27
26
|
*/
|
|
@@ -72,7 +71,7 @@ function validateItemRecursive(params) {
|
|
|
72
71
|
}
|
|
73
72
|
// FIXME repeat groups not working
|
|
74
73
|
if (qItem.type === 'group' && qItem.repeats) {
|
|
75
|
-
return
|
|
74
|
+
return;
|
|
76
75
|
}
|
|
77
76
|
const childQItems = qItem.item;
|
|
78
77
|
if (childQItems && childQItems.length > 0) {
|
|
@@ -148,9 +147,13 @@ function validateSingleItem(qItem, qrItem, invalidItems) {
|
|
|
148
147
|
}
|
|
149
148
|
return invalidItems;
|
|
150
149
|
}
|
|
151
|
-
function validateRepeatGroup(
|
|
152
|
-
|
|
153
|
-
|
|
150
|
+
// function validateRepeatGroup(
|
|
151
|
+
// qItem: QuestionnaireItem,
|
|
152
|
+
// qrItems: QuestionnaireResponseItem,
|
|
153
|
+
// invalidLinkIds: Record<string, InvalidType>
|
|
154
|
+
// ) {
|
|
155
|
+
// return;
|
|
156
|
+
// }
|
|
154
157
|
function getInputInString(answer) {
|
|
155
158
|
if (answer.valueString) {
|
|
156
159
|
return answer.valueString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateQuestionnaire.js","sourceRoot":"","sources":["../../src/utils/validateQuestionnaire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"validateQuestionnaire.js","sourceRoot":"","sources":["../../src/utils/validateQuestionnaire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAczD;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAAmC;;IAEnC,MAAM,EACJ,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACtB,GAAG,MAAM,CAAC;IAEX,IACE,CAAC,aAAa,CAAC,IAAI;QACnB,aAAa,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QAC/B,CAAC,qBAAqB,CAAC,IAAI;QAC3B,qBAAqB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
4
4
|
"description": "FHIR Structured Data Captured (SDC) rendering engine for Smart Forms",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
"lodash.debounce": "^4.0.8",
|
|
36
36
|
"nanoid": "^5.0.1",
|
|
37
37
|
"react-beautiful-dnd": "^13.1.1",
|
|
38
|
+
"react-dnd": "^16.0.1",
|
|
39
|
+
"react-dnd-html5-backend": "^16.0.1",
|
|
38
40
|
"react-markdown": "^8.0.7",
|
|
39
41
|
"zustand": "^4.4.6"
|
|
40
42
|
},
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Commonwealth Scientific and Industrial Research
|
|
3
|
+
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import type { PropsWithIsTabledAttribute } from '../../../interfaces/renderProps.interface';
|
|
20
|
+
import { StandardTextField } from '../Textfield.styles';
|
|
21
|
+
import AttachmentFileCollector from './AttachmentFileCollector';
|
|
22
|
+
import Typography from '@mui/material/Typography';
|
|
23
|
+
import Box from '@mui/material/Box';
|
|
24
|
+
import Stack from '@mui/material/Stack';
|
|
25
|
+
import type { AttachmentValues } from './AttachmentItem';
|
|
26
|
+
import AttachmentUrlField from './AttachmentUrlField';
|
|
27
|
+
|
|
28
|
+
interface AttachmentFieldProps extends PropsWithIsTabledAttribute {
|
|
29
|
+
linkId: string;
|
|
30
|
+
attachmentValues: AttachmentValues;
|
|
31
|
+
readOnly: boolean;
|
|
32
|
+
onUploadFile: (file: File | null) => void;
|
|
33
|
+
onUrlChange: (url: string) => void;
|
|
34
|
+
onFileNameChange: (fileName: string) => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function AttachmentField(props: AttachmentFieldProps) {
|
|
38
|
+
const {
|
|
39
|
+
linkId,
|
|
40
|
+
attachmentValues,
|
|
41
|
+
readOnly,
|
|
42
|
+
isTabled,
|
|
43
|
+
onUploadFile,
|
|
44
|
+
onUrlChange,
|
|
45
|
+
onFileNameChange
|
|
46
|
+
} = props;
|
|
47
|
+
|
|
48
|
+
const { uploadedFile, url, fileName } = attachmentValues;
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<Stack rowGap={1}>
|
|
53
|
+
<Typography variant="subtitle2">
|
|
54
|
+
An attachment must either have a file or a URL, or both.
|
|
55
|
+
</Typography>
|
|
56
|
+
<Box>
|
|
57
|
+
<AttachmentFileCollector
|
|
58
|
+
uploadedFile={uploadedFile}
|
|
59
|
+
isTabled={isTabled}
|
|
60
|
+
onUploadFile={onUploadFile}
|
|
61
|
+
/>
|
|
62
|
+
</Box>
|
|
63
|
+
|
|
64
|
+
<AttachmentUrlField
|
|
65
|
+
linkId={linkId}
|
|
66
|
+
url={url}
|
|
67
|
+
readOnly={readOnly}
|
|
68
|
+
isTabled={isTabled}
|
|
69
|
+
onUrlChange={onUrlChange}
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
<Box>
|
|
73
|
+
<Typography variant="body2">File name (optional)</Typography>
|
|
74
|
+
<StandardTextField
|
|
75
|
+
fullWidth
|
|
76
|
+
isTabled={isTabled}
|
|
77
|
+
id={linkId}
|
|
78
|
+
value={fileName}
|
|
79
|
+
onChange={(event) => onFileNameChange(event.target.value)}
|
|
80
|
+
disabled={readOnly}
|
|
81
|
+
size="small"
|
|
82
|
+
data-test="q-item-attachment-field"
|
|
83
|
+
/>
|
|
84
|
+
</Box>
|
|
85
|
+
|
|
86
|
+
{uploadedFile && url ? (
|
|
87
|
+
<Typography variant="subtitle2">
|
|
88
|
+
Ensure that the attached file and URL has the same content.
|
|
89
|
+
</Typography>
|
|
90
|
+
) : null}
|
|
91
|
+
</Stack>
|
|
92
|
+
</>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default AttachmentField;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Commonwealth Scientific and Industrial Research
|
|
3
|
+
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
19
|
+
//
|
|
20
|
+
// <DndProvider backend={HTML5Backend}>
|
|
21
|
+
|
|
22
|
+
import React from 'react';
|
|
23
|
+
import AttachmentField from './AttachmentField';
|
|
24
|
+
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
25
|
+
import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
|
|
26
|
+
import type {
|
|
27
|
+
PropsWithIsRepeatedAttribute,
|
|
28
|
+
PropsWithIsTabledAttribute
|
|
29
|
+
} from '../../../interfaces/renderProps.interface';
|
|
30
|
+
import type { QuestionnaireItem } from 'fhir/r4';
|
|
31
|
+
import type { AttachmentValues } from './AttachmentItem';
|
|
32
|
+
|
|
33
|
+
interface AttachmentFieldWrapperProps
|
|
34
|
+
extends PropsWithIsRepeatedAttribute,
|
|
35
|
+
PropsWithIsTabledAttribute {
|
|
36
|
+
qItem: QuestionnaireItem;
|
|
37
|
+
attachmentValues: AttachmentValues;
|
|
38
|
+
readOnly: boolean;
|
|
39
|
+
onUploadFile: (file: File | null) => void;
|
|
40
|
+
onUrlChange: (url: string) => void;
|
|
41
|
+
onFileNameChange: (fileName: string) => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function AttachmentFieldWrapper(props: AttachmentFieldWrapperProps) {
|
|
45
|
+
const {
|
|
46
|
+
qItem,
|
|
47
|
+
attachmentValues,
|
|
48
|
+
readOnly,
|
|
49
|
+
isRepeated,
|
|
50
|
+
isTabled,
|
|
51
|
+
onUploadFile,
|
|
52
|
+
onUrlChange,
|
|
53
|
+
onFileNameChange
|
|
54
|
+
} = props;
|
|
55
|
+
|
|
56
|
+
if (isRepeated) {
|
|
57
|
+
return (
|
|
58
|
+
<AttachmentField
|
|
59
|
+
linkId={qItem.linkId}
|
|
60
|
+
attachmentValues={attachmentValues}
|
|
61
|
+
readOnly={readOnly}
|
|
62
|
+
isTabled={isTabled}
|
|
63
|
+
onUploadFile={onUploadFile}
|
|
64
|
+
onUrlChange={onUrlChange}
|
|
65
|
+
onFileNameChange={onFileNameChange}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<FullWidthFormComponentBox data-test="q-item-attachment-box">
|
|
72
|
+
<ItemFieldGrid qItem={qItem} readOnly={readOnly}>
|
|
73
|
+
<AttachmentField
|
|
74
|
+
linkId={qItem.linkId}
|
|
75
|
+
attachmentValues={attachmentValues}
|
|
76
|
+
readOnly={readOnly}
|
|
77
|
+
isTabled={isTabled}
|
|
78
|
+
onUploadFile={onUploadFile}
|
|
79
|
+
onUrlChange={onUrlChange}
|
|
80
|
+
onFileNameChange={onFileNameChange}
|
|
81
|
+
/>
|
|
82
|
+
</ItemFieldGrid>
|
|
83
|
+
</FullWidthFormComponentBox>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default AttachmentFieldWrapper;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
+
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type { ChangeEvent } from 'react';
|
|
19
|
+
import React, { memo, useCallback } from 'react';
|
|
20
|
+
import { Box, IconButton, Stack, Tooltip } from '@mui/material';
|
|
21
|
+
import { useSnackbar } from 'notistack';
|
|
22
|
+
import AttachmentFileDropBox from './AttachmentFileDropBox';
|
|
23
|
+
import Iconify from '../../Iconify/Iconify';
|
|
24
|
+
import type { PropsWithIsTabledAttribute } from '../../../interfaces/renderProps.interface';
|
|
25
|
+
|
|
26
|
+
interface AttachmentFileCollectorProps extends PropsWithIsTabledAttribute {
|
|
27
|
+
uploadedFile: File | null;
|
|
28
|
+
onUploadFile: (file: File | null) => void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const AttachmentFileCollector = memo(function AttachmentFileCollector(
|
|
32
|
+
props: AttachmentFileCollectorProps
|
|
33
|
+
) {
|
|
34
|
+
const { uploadedFile, isTabled, onUploadFile } = props;
|
|
35
|
+
|
|
36
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
37
|
+
|
|
38
|
+
const handleFileDrop = useCallback(
|
|
39
|
+
(item: { files: any[] }) => {
|
|
40
|
+
if (item) {
|
|
41
|
+
const files = item.files;
|
|
42
|
+
|
|
43
|
+
if (files.length > 1) {
|
|
44
|
+
enqueueSnackbar('Only one file allowed', {
|
|
45
|
+
variant: 'warning',
|
|
46
|
+
preventDuplicate: true
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (files[0] instanceof File) {
|
|
51
|
+
const file = files[0];
|
|
52
|
+
|
|
53
|
+
onUploadFile(file);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
[onUploadFile, enqueueSnackbar]
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
function handleAttachFile(event: ChangeEvent<HTMLInputElement>) {
|
|
61
|
+
const file = event.target.files?.[0];
|
|
62
|
+
|
|
63
|
+
if (file instanceof File) {
|
|
64
|
+
onUploadFile(file);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<>
|
|
70
|
+
<AttachmentFileDropBox
|
|
71
|
+
onDrop={handleFileDrop}
|
|
72
|
+
file={uploadedFile}
|
|
73
|
+
errorMessage={''}
|
|
74
|
+
isTabled={isTabled}
|
|
75
|
+
/>
|
|
76
|
+
<Stack direction="row" justifyContent="space-between" pt={0.5}>
|
|
77
|
+
<Box>
|
|
78
|
+
<Tooltip title="Attach file">
|
|
79
|
+
<IconButton component="label" size="small">
|
|
80
|
+
<Iconify icon="fluent:attach-24-regular" />
|
|
81
|
+
<input type="file" hidden onChange={handleAttachFile} />
|
|
82
|
+
</IconButton>
|
|
83
|
+
</Tooltip>
|
|
84
|
+
<Tooltip title="Remove file">
|
|
85
|
+
<span>
|
|
86
|
+
<IconButton
|
|
87
|
+
disabled={!uploadedFile}
|
|
88
|
+
color="error"
|
|
89
|
+
size="small"
|
|
90
|
+
onClick={() => onUploadFile(null)}>
|
|
91
|
+
<Iconify icon="ant-design:delete" />
|
|
92
|
+
</IconButton>
|
|
93
|
+
</span>
|
|
94
|
+
</Tooltip>
|
|
95
|
+
</Box>
|
|
96
|
+
</Stack>
|
|
97
|
+
</>
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export default AttachmentFileCollector;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Commonwealth Scientific and Industrial Research
|
|
3
|
+
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { styled } from '@mui/material/styles';
|
|
19
|
+
import { Box } from '@mui/material';
|
|
20
|
+
import { TEXT_FIELD_WIDTH } from '../Textfield.styles';
|
|
21
|
+
|
|
22
|
+
export const AttachmentFileDropBoxWrapper = styled(Box, {
|
|
23
|
+
shouldForwardProp: (prop) => prop !== 'isActive' && prop !== 'isTabled'
|
|
24
|
+
})<{ isActive: boolean; isTabled: boolean }>(({ theme, isActive, isTabled }) => ({
|
|
25
|
+
backgroundColor: theme.palette.background.paper,
|
|
26
|
+
border: '2px dashed',
|
|
27
|
+
borderColor: isActive ? theme.palette.secondary.main : theme.palette.primary.main,
|
|
28
|
+
borderRadius: '4px',
|
|
29
|
+
maxWidth: !isTabled ? TEXT_FIELD_WIDTH : 3000,
|
|
30
|
+
minWidth: 160
|
|
31
|
+
}));
|