@mikezimm/fps-core-v7
Version:
Library of reusable core interfaces, types and constants migrated from fps-library-v2
33 lines • 1.52 kB
JavaScript
import { convertFileSizeStringToNum } from '../../../../logic/Math/convertFileSizeStringToNum';
import { makeid } from '../../../../logic/Strings/guids';
import { getMIMEObjectsFromSelectedTypes, Specific_MIME_Objects } from './fps-FileDropTypes';
/**
* This will convert wpProps to IFileDropBoxProps
* Be sure to add your fileNameHandleBars object in the web part similar to SPFx-Image-Form
* @param properties
* @returns
*/
export function convertFileDropWPPropsToFileDropBoxProps(properties) {
const { maxUploadCount, fileMaxSize, fileWarnSize, fileTypes, defaultPasteMode, } = properties;
const result = {
setParentFilesData: null,
fileTypes: [],
refreshId: makeid(5),
resetId: makeid(5),
useDropBox: true,
fileNameHandleBars: null, // Add this locally with function similar to buildPhotoFormFileNameHandleBarsDef in SPFx-Image-Form
};
if (maxUploadCount)
result.maxUploadCount = parseInt(maxUploadCount);
if (fileMaxSize)
result.fileMaxSize = convertFileSizeStringToNum(fileMaxSize);
if (fileWarnSize)
result.fileWarnSize = convertFileSizeStringToNum(fileWarnSize);
if (defaultPasteMode === true)
result.useDropBox = false;
if (fileTypes && fileTypes.length > 0) {
result.fileTypes = getMIMEObjectsFromSelectedTypes(Specific_MIME_Objects, properties.fileTypes);
}
return result;
}
//# sourceMappingURL=convertFileDropWPPropsToFileDropBoxProps.js.map