@dartech/arsenal-ui 1.3.85 → 1.3.87
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/index.js
CHANGED
@@ -70,6 +70,8 @@ import StepContent from '@mui/material/StepContent';
|
|
70
70
|
import StepConnector from '@mui/material/StepConnector';
|
71
71
|
import Select from '@mui/material/Select';
|
72
72
|
import InputLabel from '@mui/material/InputLabel';
|
73
|
+
import CheckCircleOutlineOutlinedIcon from '@mui/icons-material/CheckCircleOutlineOutlined';
|
74
|
+
import BlockOutlinedIcon from '@mui/icons-material/BlockOutlined';
|
73
75
|
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
74
76
|
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
75
77
|
import classnames from 'classnames';
|
@@ -750,7 +752,7 @@ const ControlAutocomplete = _a => {
|
|
750
752
|
useEffect(() => {
|
751
753
|
if (typeof value === 'string' && valueKey && useStringValue && !localValue && options.length && !!options[0] && typeof options[0] === 'object') {
|
752
754
|
setLocalValue(options.find(el => el[valueKey] === value));
|
753
|
-
}
|
755
|
+
} else setLocalValue(value);
|
754
756
|
}, [localValue, options, useStringValue, value, valueKey]);
|
755
757
|
return jsx(Autocomplete, Object.assign({}, fieldProps, {
|
756
758
|
value: useStringValue ? localValue !== null && localValue !== void 0 ? localValue : null : value,
|
@@ -3745,7 +3747,6 @@ const FileValueWidget = ({
|
|
3745
3747
|
setValue,
|
3746
3748
|
register
|
3747
3749
|
} = useFormContext();
|
3748
|
-
const [fileType, setFileType] = useState(null);
|
3749
3750
|
const fileValue = useWatch({
|
3750
3751
|
control,
|
3751
3752
|
name
|
@@ -3757,34 +3758,33 @@ const FileValueWidget = ({
|
|
3757
3758
|
const base64 = yield convertBase64(file);
|
3758
3759
|
setValue(name, base64);
|
3759
3760
|
}), [name, setValue]);
|
3760
|
-
useEffect(() => {
|
3761
|
-
if (fileValue) {
|
3762
|
-
const type = fileValue.substring(fileValue.indexOf(':') + 1, fileValue.indexOf(';base64'));
|
3763
|
-
if (type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
|
3764
|
-
setFileType('application/xls');
|
3765
|
-
} else if (type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') {
|
3766
|
-
setFileType('application/docx');
|
3767
|
-
} else {
|
3768
|
-
setFileType(type);
|
3769
|
-
}
|
3770
|
-
}
|
3771
|
-
}, [fileValue]);
|
3772
3761
|
return jsxs(Fragment, {
|
3773
|
-
children: [
|
3774
|
-
mb: 2
|
3762
|
+
children: [jsxs(Box, Object.assign({
|
3763
|
+
mb: 2,
|
3764
|
+
display: "flex",
|
3765
|
+
flex: "row"
|
3775
3766
|
}, {
|
3776
|
-
children: jsx(Typography,
|
3777
|
-
|
3778
|
-
}, {
|
3779
|
-
|
3780
|
-
|
3767
|
+
children: [jsx(Typography, {
|
3768
|
+
children: "Does file uploaded:"
|
3769
|
+
}), fileValue ? jsx(CheckCircleOutlineOutlinedIcon, {
|
3770
|
+
sx: {
|
3771
|
+
paddingLeft: 2
|
3772
|
+
}
|
3773
|
+
}) : jsx(BlockOutlinedIcon, {
|
3774
|
+
sx: {
|
3775
|
+
paddingLeft: 2
|
3776
|
+
}
|
3777
|
+
})]
|
3781
3778
|
})), jsxs(Button, Object.assign({
|
3782
3779
|
component: "label",
|
3783
3780
|
variant: "contained",
|
3784
3781
|
size: "large",
|
3785
|
-
color: "primary"
|
3782
|
+
color: "primary",
|
3783
|
+
sx: {
|
3784
|
+
marginTop: 4
|
3785
|
+
}
|
3786
3786
|
}, {
|
3787
|
-
children: [
|
3787
|
+
children: [fileValue ? 'Change file' : 'Upload file', jsx("input", Object.assign({
|
3788
3788
|
type: "hidden"
|
3789
3789
|
}, register(`${name}`, {
|
3790
3790
|
required: true
|
@@ -5660,6 +5660,34 @@ const DefinitionFiller = ({
|
|
5660
5660
|
}));
|
5661
5661
|
};
|
5662
5662
|
|
5663
|
+
const FileDefinitionValueView = ({
|
5664
|
+
property,
|
5665
|
+
data
|
5666
|
+
}) => {
|
5667
|
+
const {
|
5668
|
+
name
|
5669
|
+
} = property;
|
5670
|
+
const downloadFile = useCallback((contentBase64, fileName) => {
|
5671
|
+
const linkSource = contentBase64;
|
5672
|
+
const downloadLink = document.createElement('a');
|
5673
|
+
document.body.appendChild(downloadLink);
|
5674
|
+
downloadLink.href = linkSource;
|
5675
|
+
downloadLink.target = '_self';
|
5676
|
+
downloadLink.download = fileName;
|
5677
|
+
downloadLink.click();
|
5678
|
+
}, []);
|
5679
|
+
return jsx(Button, Object.assign({
|
5680
|
+
component: "label",
|
5681
|
+
variant: "contained",
|
5682
|
+
size: "large",
|
5683
|
+
color: "primary",
|
5684
|
+
onClick: () => downloadFile(data, name)
|
5685
|
+
}, {
|
5686
|
+
children: "Download File"
|
5687
|
+
}));
|
5688
|
+
};
|
5689
|
+
var FileDefinitionValueView$1 = FileDefinitionValueView;
|
5690
|
+
|
5663
5691
|
const PropertyValueComponent = ({
|
5664
5692
|
property,
|
5665
5693
|
data,
|
@@ -5670,7 +5698,10 @@ const PropertyValueComponent = ({
|
|
5670
5698
|
backgroundColor: '#fff',
|
5671
5699
|
border: '1px solid #ccc',
|
5672
5700
|
borderRadius: '4px',
|
5673
|
-
padding: '4px'
|
5701
|
+
padding: '4px',
|
5702
|
+
overflow: 'hidden',
|
5703
|
+
whiteSpace: 'nowrap',
|
5704
|
+
textOverflow: 'ellipsis'
|
5674
5705
|
}
|
5675
5706
|
}, {
|
5676
5707
|
children: value === null ? 'null' : value.toString()
|
@@ -5690,6 +5721,24 @@ const PropertyValueComponent = ({
|
|
5690
5721
|
return typeof data === 'object' ? jsx(JsonView, {
|
5691
5722
|
value: data
|
5692
5723
|
}) : defaultRender(data);
|
5724
|
+
case PropertyType.FILE_REFERENCE:
|
5725
|
+
return data === null ? defaultRender(data) : jsx(Button, Object.assign({
|
5726
|
+
component: Link,
|
5727
|
+
color: "primary",
|
5728
|
+
variant: "contained",
|
5729
|
+
target: "_blank",
|
5730
|
+
to: data,
|
5731
|
+
sx: {
|
5732
|
+
marginTop: 4
|
5733
|
+
}
|
5734
|
+
}, {
|
5735
|
+
children: "Download via link"
|
5736
|
+
}));
|
5737
|
+
case PropertyType.FILE:
|
5738
|
+
return data === null ? defaultRender(data) : jsx(FileDefinitionValueView$1, {
|
5739
|
+
data: data,
|
5740
|
+
property: property
|
5741
|
+
});
|
5693
5742
|
default:
|
5694
5743
|
return defaultRender(data);
|
5695
5744
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dartech/arsenal-ui",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.87",
|
4
4
|
"author": "DAR",
|
5
5
|
"publishConfig": {
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
@@ -27,7 +27,6 @@
|
|
27
27
|
"classnames": "^2.3.1",
|
28
28
|
"@tanstack/react-query": "^4.24.10",
|
29
29
|
"@rollup/plugin-node-resolve": "13.3.0",
|
30
|
-
"axios": "1.4.0",
|
31
30
|
"qs": "6.11.0"
|
32
31
|
},
|
33
32
|
"module": "./index.js",
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import { FileProperty } from '../../../interfaces';
|
3
|
+
type Props = {
|
4
|
+
property: FileProperty;
|
5
|
+
data: string;
|
6
|
+
};
|
7
|
+
declare const FileDefinitionValueView: ({ property, data }: Props) => JSX.Element;
|
8
|
+
export default FileDefinitionValueView;
|