etendo-ui-library 1.3.85 → 1.3.86
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-native/components/inputBase/InputBase.styles.js +1 -1
- package/dist-native/components/inputBase/file-search-input/FileSearchInput.d.ts +1 -1
- package/dist-native/components/inputBase/file-search-input/FileSearchInput.js +1 -1
- package/dist-native/components/inputBase/file-search-input/FileSearchInput.styles.d.ts +24 -17
- package/dist-native/components/inputBase/file-search-input/FileSearchInput.styles.js +1 -1
- package/dist-native/components/inputBase/file-search-input/FileSearchInput.types.d.ts +5 -7
- package/dist-web/components/inputBase/InputBase.styles.js +3 -3
- package/dist-web/components/inputBase/file-search-input/FileSearchInput.d.ts +1 -1
- package/dist-web/components/inputBase/file-search-input/FileSearchInput.js +202 -157
- package/dist-web/components/inputBase/file-search-input/FileSearchInput.styles.d.ts +24 -17
- package/dist-web/components/inputBase/file-search-input/FileSearchInput.styles.js +35 -28
- package/dist-web/components/inputBase/file-search-input/FileSearchInput.types.d.ts +5 -7
- package/package.json +1 -1
- package/dist-native/components/inputBase/file-search-input/FileStatusDisplay.d.ts +0 -4
- package/dist-native/components/inputBase/file-search-input/FileStatusDisplay.js +0 -1
- package/dist-web/components/inputBase/file-search-input/FileStatusDisplay.d.ts +0 -4
- package/dist-web/components/inputBase/file-search-input/FileStatusDisplay.js +0 -35
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.styles=void 0;var _reactNative=require("react-native");var _colors=require("../../styles/colors");var styles=exports.styles=_reactNative.StyleSheet.create({title:{fontFamily:'Inter',fontSize:16,fontWeight:'600',lineHeight:24,letterSpacing:-0.16,color:_colors.NEUTRAL_800},container:{backgroundColor:_colors.
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.styles=void 0;var _reactNative=require("react-native");var _colors=require("../../styles/colors");var styles=exports.styles=_reactNative.StyleSheet.create({title:{fontFamily:'Inter',fontSize:16,fontWeight:'600',lineHeight:24,letterSpacing:-0.16,color:_colors.NEUTRAL_800},container:{backgroundColor:_colors.NEUTRAL_50,height:48,borderRadius:8,borderColor:_colors.PRIMARY_100,overflow:'hidden',justifyContent:'center',alignItems:'center',flexDirection:'row'},containerIsError:{borderColor:_colors.DANGER_600},containerIsDisabled:{borderColor:_colors.NEUTRAL_400},containerPlaceholder:{borderColor:_colors.NEUTRAL_400},iconPlaceholder:{color:_colors.NEUTRAL_800},iconIsDisabled:{color:_colors.NEUTRAL_500},iconIsError:{color:_colors.NEUTRAL_800},iconIsFocus:{color:_colors.NEUTRAL_1000},textPlaceholder:{color:_colors.NEUTRAL_500},textIsError:{color:_colors.DANGER_700},textIsFocus:{color:_colors.NEUTRAL_800},textIsDisabled:{color:_colors.NEUTRAL_500},textInput:{paddingHorizontal:0,height:48,backgroundColor:_colors.NEUTRAL_50,fontFamily:'Inter',fontSize:16,fontStyle:'normal',fontWeight:'500',lineHeight:22,letterSpacing:-0.16,color:_colors.PRIMARY_100,flex:1},helperText:{fontFamily:'Inter',fontSize:14,fontWeight:'500',lineHeight:22,letterSpacing:-0.14,color:_colors.NEUTRAL_800},iconLeft:{width:24,height:24,marginRight:8},iconRight:{width:24,height:24,marginLeft:8},iconSize:{width:24,height:24},buttonContainer:{flexDirection:'row',paddingVertical:0,gap:0,marginLeft:5}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FileSearchInputProps } from './FileSearchInput.types';
|
|
3
|
-
declare const FileSearchInput: ({ value, placeholder, onChangeText, onSubmit, setFile,
|
|
3
|
+
declare const FileSearchInput: ({ value, placeholder, onChangeText, onSubmit, setFile, uploadFile, loadedFile, setLoadedFile, maxFileSize, ...inputBaseProps }: FileSearchInputProps) => React.JSX.Element;
|
|
4
4
|
export default FileSearchInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _InputBase=_interopRequireDefault(require("../InputBase"));var _FileSearchInput=require("./FileSearchInput.styles");var _colors=require("../../../styles/colors");var _CheckCircleIcon=require("../../../assets/images/icons/CheckCircleIcon");var _Clipboard=require("../../../assets/images/icons/Clipboard");var _DeleteIcon=require("../../../assets/images/icons/DeleteIcon");var _FileIcon=require("../../../assets/images/icons/FileIcon");var _button=require("../../button");var _FileStatusDisplay=_interopRequireDefault(require("./FileStatusDisplay"));var _excluded=["value","placeholder","onChangeText","onSubmit","setFile","fetchData"];var _this=this,_jsxFileName="/home/jenkins/agent/workspace/etendo_ui_library_develop/etendo_ui_library/src/components/inputBase/file-search-input/FileSearchInput.tsx";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var DocumentPicker=null;if(_reactNative.Platform.OS!=='web'){DocumentPicker=require('react-native-document-picker').default;}var FileSearchInput=function FileSearchInput(_ref){var value=_ref.value,placeholder=_ref.placeholder,onChangeText=_ref.onChangeText,onSubmit=_ref.onSubmit,setFile=_ref.setFile,fetchData=_ref.fetchData,inputBaseProps=(0,_objectWithoutProperties2.default)(_ref,_excluded);var _useState=(0,_react.useState)(null),_useState2=(0,_slicedToArray2.default)(_useState,2),file=_useState2[0],setLocalFile=_useState2[1];var _useState3=(0,_react.useState)(false),_useState4=(0,_slicedToArray2.default)(_useState3,2),loadingFile=_useState4[0],setLoadingFile=_useState4[1];var _useState5=(0,_react.useState)(0),_useState6=(0,_slicedToArray2.default)(_useState5,2),progress=_useState6[0],setProgress=_useState6[1];var dropAreaRef=(0,_react.useRef)(null);var fileInputRef=(0,_react.useRef)(null);var progressAnim=(0,_react.useRef)(new _reactNative.Animated.Value(0)).current;var progressSteps=[5,25,50,70,90];var currentStep=0;var resetProgress=function resetProgress(){setProgress(0);animateProgress(0);};var handleDrop=function handleDrop(event){event.preventDefault();var files=event.dataTransfer.files;if(files.length>0){var _file=files[0];startLoading(_file);setFile(_file);}};var completeProgress=function completeProgress(){setProgress(100);animateProgress(100);setLoadingFile(false);setTimeout(function(){setProgress(0);animateProgress(0);},2000);};var animateProgress=function animateProgress(toValue){_reactNative.Animated.timing(progressAnim,{toValue:toValue,duration:500,useNativeDriver:false}).start();};var startLoading=function startLoading(pickedFile){resetProgress();currentStep=0;setLoadingFile(true);setFile(pickedFile);setLocalFile(pickedFile);var lastStepIndex=progressSteps.length-1;var progressInterval=setInterval(function(){if(currentStep<lastStepIndex){currentStep++;setProgress(progressSteps[currentStep]);animateProgress(progressSteps[currentStep]);}else{clearInterval(progressInterval);}},1000);};var handleFileButtonClick=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(){if(_reactNative.Platform.OS==='web'){fileInputRef.current.click();}else if(_reactNative.Platform.OS==='android'||_reactNative.Platform.OS==='ios'){if(!DocumentPicker){console.error('DocumentPicker is not available on this platform.');return;}try{var response=yield DocumentPicker.pick({type:[DocumentPicker.types.allFiles]});var pickedFile={name:response[0].name,size:response[0].size,type:response[0].type,uri:response[0].uri};startLoading(pickedFile);setFile(pickedFile);}catch(err){if(!DocumentPicker.isCancel(err)){console.error(err);}}}});return function handleFileButtonClick(){return _ref2.apply(this,arguments);};}();var handleSendMessage=function handleSendMessage(){if(!loadingFile&&(value==null?void 0:value.trim())!==''){if(onSubmit){onSubmit(value,fileInputRef.current);setProgress(0);animateProgress(0);setLoadingFile(false);setLocalFile(null);}}else{_reactNative.Alert.alert('Message Incomplete','Please wait for the file to finish loading or ensure the message is not empty.');}};var rightButtons=[];if(fetchData){rightButtons.push(_react.default.createElement(_button.Button,{width:48,typeStyle:"white",onPress:handleFileButtonClick,iconLeft:_react.default.createElement(_Clipboard.ClipboardIcon,{style:{width:24,height:24},fill:_colors.PRIMARY_100,__self:_this,__source:{fileName:_jsxFileName,lineNumber:165,columnNumber:11}}),__self:_this,__source:{fileName:_jsxFileName,lineNumber:160,columnNumber:7}}));}var handleFileSelect=function handleFileSelect(event){var file=event.target.files[0];if(file){startLoading(file);setFile(file);setLocalFile(file);uploadFile(file);}event.target.value=null;};var handleDeleteFile=function handleDeleteFile(){resetProgress();setFile(null);setLocalFile(null);setLoadingFile(false);setProgress(0);animateProgress(0);if(fileInputRef.current){fileInputRef.current.value=null;}};;var uploadFile=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(file){if(!fetchData||!fetchData.url||!fetchData.method){_reactNative.Alert.alert('Fetch data is not properly defined.');return;}var formData=new FormData();formData.append(fetchData.file,file);var response;try{response=yield fetch(fetchData.url,{method:fetchData.method,body:formData});if(response.ok){var result=yield response.json();setFile(result);setLocalFile(result);completeProgress();}else{throw new Error('Failed to upload file');}}catch(error){setProgress(0);animateProgress(0);console.error('Error uploading file:',error);_reactNative.Alert.alert('Error','Failed to upload file');}finally{setLoadingFile(false);}});return function uploadFile(_x){return _ref3.apply(this,arguments);};}();return _react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.container,__self:_this,__source:{fileName:_jsxFileName,lineNumber:229,columnNumber:5}},file&&loadingFile?_react.default.createElement(_FileStatusDisplay.default,{file:file,progressAnim:progressAnim,handleDeleteFile:handleDeleteFile,__self:_this,__source:{fileName:_jsxFileName,lineNumber:232,columnNumber:9}}):file&&_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:239,columnNumber:11}},_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameLoadedLeftContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:240,columnNumber:13}},_react.default.createElement(_FileIcon.FileIcon,{style:_FileSearchInput.styles.fileIcon,__self:_this,__source:{fileName:_jsxFileName,lineNumber:241,columnNumber:15}}),_react.default.createElement(_reactNative.Text,{style:_FileSearchInput.styles.fileNameText,__self:_this,__source:{fileName:_jsxFileName,lineNumber:242,columnNumber:15}},file.name)),_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameRightContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:244,columnNumber:13}},_react.default.createElement(_CheckCircleIcon.CheckCircleIcon,{style:_FileSearchInput.styles.checkCircleIcon,fill:_colors.SUCCESS_600,__self:_this,__source:{fileName:_jsxFileName,lineNumber:245,columnNumber:15}}),_react.default.createElement(_reactNative.TouchableOpacity,{onPress:handleDeleteFile,__self:_this,__source:{fileName:_jsxFileName,lineNumber:249,columnNumber:15}},_react.default.createElement(_DeleteIcon.DeleteIcon,{style:_FileSearchInput.styles.deleteIcon,__self:_this,__source:{fileName:_jsxFileName,lineNumber:250,columnNumber:17}})))),_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.inputContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:257,columnNumber:7}},_reactNative.Platform.OS==='web'?_react.default.createElement("div",{ref:dropAreaRef,onDrop:handleDrop,__self:_this,__source:{fileName:_jsxFileName,lineNumber:259,columnNumber:11}},_react.default.createElement(_InputBase.default,(0,_extends2.default)({},inputBaseProps,{value:value,onChangeText:onChangeText,onSubmit:handleSendMessage,rightButtons:rightButtons,isLoading:loadingFile,placeholder:placeholder,__self:_this,__source:{fileName:_jsxFileName,lineNumber:260,columnNumber:13}})),_react.default.createElement("input",{type:"file",ref:fileInputRef,style:{display:'none'},onChange:handleFileSelect,__self:_this,__source:{fileName:_jsxFileName,lineNumber:269,columnNumber:13}})):_react.default.createElement(_InputBase.default,(0,_extends2.default)({},inputBaseProps,{value:value,onChangeText:onChangeText,onSubmit:handleSendMessage,rightButtons:rightButtons,isLoading:loadingFile,placeholder:placeholder,__self:_this,__source:{fileName:_jsxFileName,lineNumber:277,columnNumber:11}}))));};var _default=exports.default=FileSearchInput;
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _InputBase=_interopRequireDefault(require("../InputBase"));var _FileSearchInput=require("./FileSearchInput.styles");var _colors=require("../../../styles/colors");var _CheckCircleIcon=require("../../../assets/images/icons/CheckCircleIcon");var _Clipboard=require("../../../assets/images/icons/Clipboard");var _DeleteIcon=require("../../../assets/images/icons/DeleteIcon");var _FileIcon=require("../../../assets/images/icons/FileIcon");var _button=require("../../button");var _alert=require("../../alert");var _excluded=["value","placeholder","onChangeText","onSubmit","setFile","uploadFile","loadedFile","setLoadedFile","maxFileSize"];var _this=this,_jsxFileName="/home/jenkins/agent/workspace/etendo_ui_library_develop/etendo_ui_library/src/components/inputBase/file-search-input/FileSearchInput.tsx";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var DocumentPicker=null;if(_reactNative.Platform.OS!=='web'){DocumentPicker=require('react-native-document-picker').default;}var FileSearchInput=function FileSearchInput(_ref){var value=_ref.value,placeholder=_ref.placeholder,onChangeText=_ref.onChangeText,onSubmit=_ref.onSubmit,setFile=_ref.setFile,uploadFile=_ref.uploadFile,loadedFile=_ref.loadedFile,setLoadedFile=_ref.setLoadedFile,_ref$maxFileSize=_ref.maxFileSize,maxFileSize=_ref$maxFileSize===void 0?512:_ref$maxFileSize,inputBaseProps=(0,_objectWithoutProperties2.default)(_ref,_excluded);var _useState=(0,_react.useState)(null),_useState2=(0,_slicedToArray2.default)(_useState,2),file=_useState2[0],setLocalFile=_useState2[1];var _useState3=(0,_react.useState)(false),_useState4=(0,_slicedToArray2.default)(_useState3,2),isFileValid=_useState4[0],setIsFileValid=_useState4[1];var _useState5=(0,_react.useState)(false),_useState6=(0,_slicedToArray2.default)(_useState5,2),loadingFile=_useState6[0],setLoadingFile=_useState6[1];var _useState7=(0,_react.useState)(0),_useState8=(0,_slicedToArray2.default)(_useState7,2),progress=_useState8[0],setProgress=_useState8[1];var dropAreaRef=(0,_react.useRef)(null);var fileInputRef=(0,_react.useRef)(null);var resetProgress=function resetProgress(){setLocalFile(null);setIsFileValid(false);setLoadingFile(false);setProgress(0);if(!!setLoadedFile)setLoadedFile(false);};var handleDrop=function handleDrop(event){event.preventDefault();var files=event.dataTransfer.files;if(files.length>0){var _file=files[0];startLoading(_file);if(!!setFile)setFile(_file);}};var completeProgress=function completeProgress(){setProgress(100);animateProgress(100);setLoadingFile(false);setIsFileValid(true);setTimeout(function(){if(!!setLoadedFile)setLoadedFile(true);setProgress(0);},100);};var animateProgress=function animateProgress(toValue){setProgress(toValue);};var startLoading=function startLoading(pickedFile){setLoadingFile(true);if(!!setFile)pickedFile;setLocalFile(pickedFile);setProgress(25);animateProgress(25);};var validateAndLoadFile=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(pickedFile){resetProgress();if(maxFileSize&&pickedFile.size>maxFileSize*1024*1024){(0,_alert.show)("File size should not exceed "+maxFileSize+" MB",'error');setIsFileValid(false);setLoadingFile(false);setLocalFile(null);return false;}setIsFileValid(true);setLoadingFile(true);setLocalFile(pickedFile);startLoading(pickedFile);try{if(!!uploadFile)yield uploadFile(pickedFile);}catch(error){console.error('Error uploading file:',error);(0,_alert.show)('Error uploading file','error');}return true;});return function validateAndLoadFile(_x){return _ref2.apply(this,arguments);};}();var handleFileButtonClick=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(){if(_reactNative.Platform.OS==='web'){fileInputRef.current.click();}else if(_reactNative.Platform.OS==='android'||_reactNative.Platform.OS==='ios'){if(!DocumentPicker){console.error('DocumentPicker is not available on this platform.');return;}try{var response=yield DocumentPicker.pick({type:[DocumentPicker.types.allFiles]});var pickedFile={name:response[0].name,size:response[0].size,type:response[0].type,uri:response[0].uri};validateAndLoadFile(pickedFile);}catch(err){if(!DocumentPicker.isCancel(err)){console.error(err);}}}});return function handleFileButtonClick(){return _ref3.apply(this,arguments);};}();var handleSendMessage=function handleSendMessage(){if(!loadingFile&&value.trim()!==''){onSubmit==null?void 0:onSubmit(value,isFileValid?file:null);resetProgress();if(!!setFile)setFile(null);setLocalFile(null);setIsFileValid(false);}else{var errorMessage='Please wait for the file to finish loading.';if(value.trim()===''){errorMessage='Message cannot be empty.';}else if(file&&!isFileValid){errorMessage="File size should not exceed "+maxFileSize+" MB.";}(0,_alert.show)(errorMessage,'error');}};var rightButtons=[];if(!!uploadFile){rightButtons.push(_react.default.createElement(_button.Button,{width:48,typeStyle:"white",onPress:handleFileButtonClick,iconLeft:_react.default.createElement(_Clipboard.ClipboardIcon,{style:{width:24,height:24},fill:_colors.PRIMARY_100,__self:_this,__source:{fileName:_jsxFileName,lineNumber:185,columnNumber:11}}),__self:_this,__source:{fileName:_jsxFileName,lineNumber:180,columnNumber:7}}));}var handleFileSelect=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(event){var file=event.target.files[0];if(file){if(yield validateAndLoadFile(file)){startLoading(file);if(!!setFile)setFile(file);setLocalFile(file);if(!!uploadFile)yield uploadFile(function(file){setProgress(progress);animateProgress(progress);});}}event.target.value=null;});return function handleFileSelect(_x2){return _ref4.apply(this,arguments);};}();var handleDeleteFile=function handleDeleteFile(){resetProgress();setProgress(0);animateProgress(0);setLocalFile(null);setLoadingFile(false);if(!!setFile)setFile(null);if(!!setLoadedFile)setLoadedFile(false);if(fileInputRef.current){fileInputRef.current.value=null;}};(0,_react.useEffect)(function(){if(loadedFile){completeProgress();}},[loadedFile]);return _react.default.createElement(_reactNative.SafeAreaView,{style:_FileSearchInput.styles.container,__self:_this,__source:{fileName:_jsxFileName,lineNumber:230,columnNumber:5}},_react.default.createElement(_alert.Alert,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:231,columnNumber:7}}),file&&isFileValid&&_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:234,columnNumber:9}},_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameLoadedLeftContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:235,columnNumber:11}},_react.default.createElement(_FileIcon.FileIcon,{style:_FileSearchInput.styles.fileIcon,__self:_this,__source:{fileName:_jsxFileName,lineNumber:237,columnNumber:13}}),_react.default.createElement(_reactNative.View,{style:{height:_reactNative.Platform.OS==="web"?undefined:28,width:"80%"},__self:_this,__source:{fileName:_jsxFileName,lineNumber:239,columnNumber:13}},_react.default.createElement(_reactNative.Text,{style:_FileSearchInput.styles.fileNameText,numberOfLines:1,ellipsizeMode:"tail",__self:_this,__source:{fileName:_jsxFileName,lineNumber:240,columnNumber:15}},file.name),progress>0&&_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.progressBarContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:244,columnNumber:17}},_react.default.createElement(_reactNative.View,{style:{width:progress+"%",height:8,backgroundColor:_colors.NEUTRAL_1000,borderRadius:16},__self:_this,__source:{fileName:_jsxFileName,lineNumber:245,columnNumber:19}})))),_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameRightContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:250,columnNumber:11}},_react.default.createElement(_CheckCircleIcon.CheckCircleIcon,{style:_FileSearchInput.styles.checkCircleIcon,fill:_colors.SUCCESS_600,__self:_this,__source:{fileName:_jsxFileName,lineNumber:251,columnNumber:13}}),_react.default.createElement(_reactNative.TouchableOpacity,{onPress:handleDeleteFile,__self:_this,__source:{fileName:_jsxFileName,lineNumber:255,columnNumber:13}},_react.default.createElement(_DeleteIcon.DeleteIcon,{style:_FileSearchInput.styles.deleteIcon,__self:_this,__source:{fileName:_jsxFileName,lineNumber:256,columnNumber:15}})))),_react.default.createElement(_reactNative.View,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:262,columnNumber:7}},_reactNative.Platform.OS==='web'?_react.default.createElement("div",{ref:dropAreaRef,onDrop:handleDrop,__self:_this,__source:{fileName:_jsxFileName,lineNumber:264,columnNumber:11}},_react.default.createElement(_InputBase.default,(0,_extends2.default)({},inputBaseProps,{value:value,onChangeText:onChangeText,onSubmit:handleSendMessage,rightButtons:rightButtons,isLoading:loadingFile,placeholder:placeholder,__self:_this,__source:{fileName:_jsxFileName,lineNumber:265,columnNumber:13}})),_react.default.createElement("input",{type:"file",ref:fileInputRef,style:{display:'none'},onChange:handleFileSelect,__self:_this,__source:{fileName:_jsxFileName,lineNumber:274,columnNumber:13}})):_react.default.createElement(_InputBase.default,(0,_extends2.default)({},inputBaseProps,{value:value,onChangeText:onChangeText,onSubmit:handleSendMessage,rightButtons:rightButtons,isLoading:loadingFile,placeholder:placeholder,__self:_this,__source:{fileName:_jsxFileName,lineNumber:282,columnNumber:11}}))));};var _default=exports.default=FileSearchInput;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const styles: {
|
|
2
2
|
container: {
|
|
3
|
-
|
|
3
|
+
width: "100%";
|
|
4
|
+
height: "10%";
|
|
4
5
|
};
|
|
5
6
|
inputContainer: {
|
|
6
7
|
flex: number;
|
|
@@ -14,37 +15,33 @@ export declare const styles: {
|
|
|
14
15
|
flexDirection: "row";
|
|
15
16
|
gap: number;
|
|
16
17
|
height: "100%";
|
|
18
|
+
flex: number;
|
|
17
19
|
justifyContent: "space-between";
|
|
18
20
|
marginBottom: number;
|
|
19
|
-
|
|
20
|
-
paddingRight: number;
|
|
21
|
+
paddingHorizontal: number;
|
|
21
22
|
paddingVertical: number;
|
|
22
|
-
width: "100%";
|
|
23
23
|
};
|
|
24
24
|
fileNameLeftContainer: {
|
|
25
25
|
flexDirection: "row";
|
|
26
26
|
gap: number;
|
|
27
|
-
|
|
27
|
+
};
|
|
28
|
+
fileNameRightContainer: {
|
|
29
|
+
flexDirection: "row";
|
|
28
30
|
};
|
|
29
31
|
fileNameLeftContent: {
|
|
30
|
-
flex: number;
|
|
31
32
|
height: number;
|
|
33
|
+
width: "80%";
|
|
32
34
|
};
|
|
33
35
|
fileNameLoadedLeftContainer: {
|
|
34
36
|
alignItems: "center";
|
|
35
37
|
flexDirection: "row";
|
|
36
38
|
gap: number;
|
|
37
|
-
width: "85%" |
|
|
39
|
+
width: "85%" | "75%";
|
|
38
40
|
};
|
|
39
41
|
checkCircleIcon: {
|
|
40
42
|
height: number;
|
|
41
43
|
width: number;
|
|
42
|
-
|
|
43
|
-
fileNameRightContainer: {
|
|
44
|
-
flexDirection: "row";
|
|
45
|
-
alignItems: "center";
|
|
46
|
-
gap: number;
|
|
47
|
-
width: "15%" | undefined;
|
|
44
|
+
marginRight: number;
|
|
48
45
|
};
|
|
49
46
|
deleteIcon: {
|
|
50
47
|
height: number;
|
|
@@ -64,21 +61,31 @@ export declare const styles: {
|
|
|
64
61
|
color: string;
|
|
65
62
|
fontWeight: "500";
|
|
66
63
|
fontSize: number;
|
|
67
|
-
height: "100%";
|
|
68
64
|
paddingBottom: number | undefined;
|
|
65
|
+
overflow: "hidden";
|
|
66
|
+
whiteSpace: string;
|
|
67
|
+
width: "100%";
|
|
68
|
+
flex: number;
|
|
69
|
+
marginLeft: number | undefined;
|
|
69
70
|
};
|
|
70
71
|
fileIcon: {
|
|
71
72
|
height: number;
|
|
72
73
|
width: number;
|
|
73
74
|
};
|
|
74
|
-
|
|
75
|
+
progressBarFill: {
|
|
75
76
|
backgroundColor: string;
|
|
76
77
|
borderRadius: number;
|
|
77
|
-
height:
|
|
78
|
+
height: "100%";
|
|
78
79
|
};
|
|
79
|
-
|
|
80
|
+
progressBarContainer: {
|
|
80
81
|
backgroundColor: string;
|
|
82
|
+
width: "100%";
|
|
81
83
|
borderRadius: number;
|
|
84
|
+
marginLeft: number | undefined;
|
|
85
|
+
};
|
|
86
|
+
progressBar: {
|
|
82
87
|
height: "100%";
|
|
88
|
+
backgroundColor: string;
|
|
89
|
+
borderRadius: number;
|
|
83
90
|
};
|
|
84
91
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.styles=void 0;var _reactNative=require("react-native");var _colors=require("../../../styles/colors");var styles=exports.styles=_reactNative.StyleSheet.create({container:{
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.styles=void 0;var _reactNative=require("react-native");var _colors=require("../../../styles/colors");var styles=exports.styles=_reactNative.StyleSheet.create({container:{width:"100%",height:"10%"},inputContainer:{flex:1},fileNameContainer:{alignItems:'center',backgroundColor:_colors.NEUTRAL_50,borderColor:_colors.NEUTRAL_400,borderRadius:8,borderWidth:1,flexDirection:"row",gap:4,height:"100%",flex:1,justifyContent:"space-between",marginBottom:4,paddingHorizontal:8,paddingVertical:_reactNative.Platform.OS==="web"?16:32},fileNameLeftContainer:{flexDirection:"row",gap:4},fileNameRightContainer:{flexDirection:"row"},fileNameLeftContent:{height:24,width:"80%"},fileNameLoadedLeftContainer:{alignItems:"center",flexDirection:"row",gap:4,width:_reactNative.Platform.OS==="web"?"75%":"85%"},checkCircleIcon:{height:24,width:24,marginRight:8},deleteIcon:{height:20,width:20},loadingContainer:{alignItems:"center",justifyContent:"center",paddingHorizontal:8,paddingVertical:16,width:"100%"},loadingText:{fontSize:14},fileNameText:{color:_colors.NEUTRAL_1000,fontWeight:"500",fontSize:_reactNative.Platform.OS==="web"?14:16,paddingBottom:_reactNative.Platform.OS==="web"?4:undefined,overflow:'hidden',whiteSpace:'nowrap',width:"100%",flex:1,marginLeft:_reactNative.Platform.OS==="web"?undefined:8},fileIcon:{height:_reactNative.Platform.OS==="web"?40:36,width:_reactNative.Platform.OS==="web"?40:36},progressBarFill:{backgroundColor:_colors.NEUTRAL_100,borderRadius:10,height:'100%'},progressBarContainer:{backgroundColor:_colors.NEUTRAL_300,width:'100%',borderRadius:16,marginLeft:_reactNative.Platform.OS==="web"?undefined:8},progressBar:{height:'100%',backgroundColor:_colors.NEUTRAL_1000,borderRadius:2}});
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { Animated } from 'react-native';
|
|
2
2
|
import { IInputBase } from '../InputBase.types';
|
|
3
|
-
export type FetchData = {
|
|
4
|
-
file: any;
|
|
5
|
-
url: string;
|
|
6
|
-
method: string;
|
|
7
|
-
};
|
|
8
3
|
export interface FileSearchInputProps extends IInputBase {
|
|
9
4
|
value: string;
|
|
10
|
-
setFile
|
|
5
|
+
setFile?: (file: any) => void;
|
|
11
6
|
onChangeText: (text: string) => void;
|
|
12
7
|
onSubmit: (message: string, file?: any) => void;
|
|
13
8
|
placeholder: string;
|
|
14
|
-
|
|
9
|
+
uploadFile?: (file: any) => Promise<void>;
|
|
10
|
+
maxFileSize?: number;
|
|
11
|
+
loadedFile?: boolean;
|
|
12
|
+
setLoadedFile?: (loaded: boolean) => void;
|
|
15
13
|
}
|
|
16
14
|
export interface FileStatusDisplayProps {
|
|
17
15
|
file: any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native-web";
|
|
2
|
-
import { DANGER_600, DANGER_700,
|
|
2
|
+
import { DANGER_600, DANGER_700, NEUTRAL_1000, NEUTRAL_400, NEUTRAL_50, NEUTRAL_500, NEUTRAL_800, PRIMARY_100 } from "../../styles/colors";
|
|
3
3
|
export var styles = StyleSheet.create({
|
|
4
4
|
title: {
|
|
5
5
|
fontFamily: 'Inter',
|
|
@@ -10,7 +10,7 @@ export var styles = StyleSheet.create({
|
|
|
10
10
|
color: NEUTRAL_800
|
|
11
11
|
},
|
|
12
12
|
container: {
|
|
13
|
-
backgroundColor:
|
|
13
|
+
backgroundColor: NEUTRAL_50,
|
|
14
14
|
height: 48,
|
|
15
15
|
borderRadius: 8,
|
|
16
16
|
borderColor: PRIMARY_100,
|
|
@@ -55,7 +55,7 @@ export var styles = StyleSheet.create({
|
|
|
55
55
|
textInput: {
|
|
56
56
|
paddingHorizontal: 0,
|
|
57
57
|
height: 48,
|
|
58
|
-
backgroundColor:
|
|
58
|
+
backgroundColor: NEUTRAL_50,
|
|
59
59
|
fontFamily: 'Inter',
|
|
60
60
|
fontSize: 16,
|
|
61
61
|
fontStyle: 'normal',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FileSearchInputProps } from './FileSearchInput.types';
|
|
3
|
-
declare const FileSearchInput: ({ value, placeholder, onChangeText, onSubmit, setFile,
|
|
3
|
+
declare const FileSearchInput: ({ value, placeholder, onChangeText, onSubmit, setFile, uploadFile, loadedFile, setLoadedFile, maxFileSize, ...inputBaseProps }: FileSearchInputProps) => React.JSX.Element;
|
|
4
4
|
export default FileSearchInput;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["value", "placeholder", "onChangeText", "onSubmit", "setFile", "
|
|
2
|
+
var _excluded = ["value", "placeholder", "onChangeText", "onSubmit", "setFile", "uploadFile", "loadedFile", "setLoadedFile", "maxFileSize"];
|
|
3
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
5
5
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
@@ -12,13 +12,13 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
13
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
14
14
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
15
|
-
import React, { useState, useRef } from 'react';
|
|
16
|
-
import { View, TouchableOpacity,
|
|
15
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
16
|
+
import { View, TouchableOpacity, Platform, Text, SafeAreaView } from "react-native-web";
|
|
17
17
|
import InputBase from "../InputBase";
|
|
18
18
|
|
|
19
19
|
// Import styles
|
|
20
20
|
import { styles } from "./FileSearchInput.styles";
|
|
21
|
-
import { PRIMARY_100, SUCCESS_600 } from "../../../styles/colors";
|
|
21
|
+
import { NEUTRAL_1000, PRIMARY_100, SUCCESS_600 } from "../../../styles/colors";
|
|
22
22
|
|
|
23
23
|
// Import icons
|
|
24
24
|
import { CheckCircleIcon } from "../../../assets/images/icons/CheckCircleIcon";
|
|
@@ -29,7 +29,7 @@ import { FileIcon } from "../../../assets/images/icons/FileIcon";
|
|
|
29
29
|
// Import types
|
|
30
30
|
|
|
31
31
|
import { Button } from "../../button";
|
|
32
|
-
import
|
|
32
|
+
import { Alert, show } from "../../alert";
|
|
33
33
|
|
|
34
34
|
// Import DocumentPicker for mobile platforms only
|
|
35
35
|
var DocumentPicker = null;
|
|
@@ -42,152 +42,210 @@ var FileSearchInput = function FileSearchInput(_ref) {
|
|
|
42
42
|
onChangeText = _ref.onChangeText,
|
|
43
43
|
onSubmit = _ref.onSubmit,
|
|
44
44
|
setFile = _ref.setFile,
|
|
45
|
-
|
|
45
|
+
uploadFile = _ref.uploadFile,
|
|
46
|
+
loadedFile = _ref.loadedFile,
|
|
47
|
+
setLoadedFile = _ref.setLoadedFile,
|
|
48
|
+
_ref$maxFileSize = _ref.maxFileSize,
|
|
49
|
+
maxFileSize = _ref$maxFileSize === void 0 ? 512 : _ref$maxFileSize,
|
|
46
50
|
inputBaseProps = _objectWithoutProperties(_ref, _excluded);
|
|
51
|
+
// States
|
|
47
52
|
var _useState = useState(null),
|
|
48
53
|
_useState2 = _slicedToArray(_useState, 2),
|
|
49
54
|
file = _useState2[0],
|
|
50
55
|
setLocalFile = _useState2[1];
|
|
51
56
|
var _useState3 = useState(false),
|
|
52
57
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var _useState5 = useState(
|
|
58
|
+
isFileValid = _useState4[0],
|
|
59
|
+
setIsFileValid = _useState4[1];
|
|
60
|
+
var _useState5 = useState(false),
|
|
56
61
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
loadingFile = _useState6[0],
|
|
63
|
+
setLoadingFile = _useState6[1];
|
|
64
|
+
var _useState7 = useState(0),
|
|
65
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
66
|
+
progress = _useState8[0],
|
|
67
|
+
setProgress = _useState8[1];
|
|
68
|
+
|
|
69
|
+
// References
|
|
59
70
|
var dropAreaRef = useRef(null);
|
|
60
71
|
var fileInputRef = useRef(null);
|
|
61
|
-
var progressAnim = useRef(new Animated.Value(0)).current;
|
|
62
|
-
var progressSteps = [5, 25, 50, 70, 90];
|
|
63
|
-
var currentStep = 0;
|
|
64
72
|
|
|
65
73
|
// Function to reset progress bar
|
|
66
74
|
var resetProgress = function resetProgress() {
|
|
75
|
+
setLocalFile(null);
|
|
76
|
+
setIsFileValid(false);
|
|
77
|
+
setLoadingFile(false);
|
|
67
78
|
setProgress(0);
|
|
68
|
-
|
|
79
|
+
if (!!setLoadedFile) setLoadedFile(false);
|
|
69
80
|
};
|
|
81
|
+
|
|
82
|
+
// Handles file drop events, typically from drag-and-drop actions
|
|
70
83
|
var handleDrop = function handleDrop(event) {
|
|
71
84
|
event.preventDefault();
|
|
72
85
|
var files = event.dataTransfer.files;
|
|
73
86
|
if (files.length > 0) {
|
|
74
87
|
var _file = files[0];
|
|
75
88
|
startLoading(_file);
|
|
76
|
-
setFile(_file);
|
|
89
|
+
if (!!setFile) setFile(_file);
|
|
77
90
|
}
|
|
78
91
|
};
|
|
92
|
+
|
|
93
|
+
// Completes the file loading process, sets progress to 100%, and then resets
|
|
79
94
|
var completeProgress = function completeProgress() {
|
|
80
95
|
setProgress(100);
|
|
81
96
|
animateProgress(100);
|
|
82
97
|
setLoadingFile(false);
|
|
98
|
+
setIsFileValid(true);
|
|
83
99
|
setTimeout(function () {
|
|
100
|
+
if (!!setLoadedFile) setLoadedFile(true);
|
|
84
101
|
setProgress(0);
|
|
85
|
-
|
|
86
|
-
}, 2000);
|
|
102
|
+
}, 100);
|
|
87
103
|
};
|
|
104
|
+
|
|
105
|
+
// Updates the file loading progress
|
|
88
106
|
var animateProgress = function animateProgress(toValue) {
|
|
89
|
-
|
|
90
|
-
toValue: toValue,
|
|
91
|
-
duration: 500,
|
|
92
|
-
useNativeDriver: false
|
|
93
|
-
}).start();
|
|
107
|
+
setProgress(toValue);
|
|
94
108
|
};
|
|
109
|
+
|
|
110
|
+
// Initiates the file loading process by setting the initial progress
|
|
95
111
|
var startLoading = function startLoading(pickedFile) {
|
|
96
|
-
resetProgress();
|
|
97
|
-
currentStep = 0;
|
|
98
112
|
setLoadingFile(true);
|
|
99
|
-
setFile
|
|
113
|
+
if (!!setFile) pickedFile;
|
|
100
114
|
setLocalFile(pickedFile);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (currentStep < lastStepIndex) {
|
|
104
|
-
currentStep++;
|
|
105
|
-
setProgress(progressSteps[currentStep]);
|
|
106
|
-
animateProgress(progressSteps[currentStep]);
|
|
107
|
-
} else {
|
|
108
|
-
clearInterval(progressInterval);
|
|
109
|
-
}
|
|
110
|
-
}, 1000);
|
|
115
|
+
setProgress(25);
|
|
116
|
+
animateProgress(25);
|
|
111
117
|
};
|
|
112
118
|
|
|
119
|
+
// Validates the file size and starts the file loading process
|
|
120
|
+
var validateAndLoadFile = /*#__PURE__*/function () {
|
|
121
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(pickedFile) {
|
|
122
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
123
|
+
while (1) switch (_context.prev = _context.next) {
|
|
124
|
+
case 0:
|
|
125
|
+
resetProgress();
|
|
126
|
+
if (!(maxFileSize && pickedFile.size > maxFileSize * 1024 * 1024)) {
|
|
127
|
+
_context.next = 7;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
show("File size should not exceed ".concat(maxFileSize, " MB"), 'error');
|
|
131
|
+
setIsFileValid(false);
|
|
132
|
+
setLoadingFile(false);
|
|
133
|
+
setLocalFile(null);
|
|
134
|
+
return _context.abrupt("return", false);
|
|
135
|
+
case 7:
|
|
136
|
+
setIsFileValid(true);
|
|
137
|
+
setLoadingFile(true);
|
|
138
|
+
setLocalFile(pickedFile);
|
|
139
|
+
startLoading(pickedFile);
|
|
140
|
+
_context.prev = 11;
|
|
141
|
+
if (!uploadFile) {
|
|
142
|
+
_context.next = 15;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
_context.next = 15;
|
|
146
|
+
return uploadFile(pickedFile);
|
|
147
|
+
case 15:
|
|
148
|
+
_context.next = 21;
|
|
149
|
+
break;
|
|
150
|
+
case 17:
|
|
151
|
+
_context.prev = 17;
|
|
152
|
+
_context.t0 = _context["catch"](11);
|
|
153
|
+
console.error('Error uploading file:', _context.t0);
|
|
154
|
+
show('Error uploading file', 'error');
|
|
155
|
+
case 21:
|
|
156
|
+
return _context.abrupt("return", true);
|
|
157
|
+
case 22:
|
|
158
|
+
case "end":
|
|
159
|
+
return _context.stop();
|
|
160
|
+
}
|
|
161
|
+
}, _callee, null, [[11, 17]]);
|
|
162
|
+
}));
|
|
163
|
+
return function validateAndLoadFile(_x) {
|
|
164
|
+
return _ref2.apply(this, arguments);
|
|
165
|
+
};
|
|
166
|
+
}();
|
|
167
|
+
|
|
113
168
|
// Handles file button click - Opens file picker on web and uses DocumentPicker on mobile
|
|
114
169
|
var handleFileButtonClick = /*#__PURE__*/function () {
|
|
115
|
-
var
|
|
170
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
116
171
|
var response, pickedFile;
|
|
117
|
-
return _regeneratorRuntime().wrap(function
|
|
118
|
-
while (1) switch (
|
|
172
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
173
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
119
174
|
case 0:
|
|
120
175
|
if (!(Platform.OS === 'web')) {
|
|
121
|
-
|
|
176
|
+
_context2.next = 4;
|
|
122
177
|
break;
|
|
123
178
|
}
|
|
124
179
|
fileInputRef.current.click();
|
|
125
|
-
|
|
180
|
+
_context2.next = 19;
|
|
126
181
|
break;
|
|
127
182
|
case 4:
|
|
128
183
|
if (!(Platform.OS === 'android' || Platform.OS === 'ios')) {
|
|
129
|
-
|
|
184
|
+
_context2.next = 19;
|
|
130
185
|
break;
|
|
131
186
|
}
|
|
132
187
|
if (DocumentPicker) {
|
|
133
|
-
|
|
188
|
+
_context2.next = 8;
|
|
134
189
|
break;
|
|
135
190
|
}
|
|
136
191
|
console.error('DocumentPicker is not available on this platform.');
|
|
137
|
-
return
|
|
192
|
+
return _context2.abrupt("return");
|
|
138
193
|
case 8:
|
|
139
|
-
|
|
140
|
-
|
|
194
|
+
_context2.prev = 8;
|
|
195
|
+
_context2.next = 11;
|
|
141
196
|
return DocumentPicker.pick({
|
|
142
197
|
type: [DocumentPicker.types.allFiles]
|
|
143
198
|
});
|
|
144
199
|
case 11:
|
|
145
|
-
response =
|
|
200
|
+
response = _context2.sent;
|
|
146
201
|
pickedFile = {
|
|
147
202
|
name: response[0].name,
|
|
148
203
|
size: response[0].size,
|
|
149
204
|
type: response[0].type,
|
|
150
205
|
uri: response[0].uri
|
|
151
206
|
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
_context.next = 20;
|
|
207
|
+
validateAndLoadFile(pickedFile);
|
|
208
|
+
_context2.next = 19;
|
|
155
209
|
break;
|
|
156
|
-
case
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (!DocumentPicker.isCancel(
|
|
160
|
-
console.error(
|
|
210
|
+
case 16:
|
|
211
|
+
_context2.prev = 16;
|
|
212
|
+
_context2.t0 = _context2["catch"](8);
|
|
213
|
+
if (!DocumentPicker.isCancel(_context2.t0)) {
|
|
214
|
+
console.error(_context2.t0);
|
|
161
215
|
}
|
|
162
|
-
case
|
|
216
|
+
case 19:
|
|
163
217
|
case "end":
|
|
164
|
-
return
|
|
218
|
+
return _context2.stop();
|
|
165
219
|
}
|
|
166
|
-
},
|
|
220
|
+
}, _callee2, null, [[8, 16]]);
|
|
167
221
|
}));
|
|
168
222
|
return function handleFileButtonClick() {
|
|
169
|
-
return
|
|
223
|
+
return _ref3.apply(this, arguments);
|
|
170
224
|
};
|
|
171
225
|
}();
|
|
172
226
|
|
|
173
|
-
//
|
|
227
|
+
// Handles the sending of the message
|
|
174
228
|
var handleSendMessage = function handleSendMessage() {
|
|
175
|
-
if (!loadingFile &&
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
setLocalFile(null);
|
|
182
|
-
}
|
|
229
|
+
if (!loadingFile && value.trim() !== '') {
|
|
230
|
+
onSubmit === null || onSubmit === void 0 || onSubmit(value, isFileValid ? file : null);
|
|
231
|
+
resetProgress();
|
|
232
|
+
if (!!setFile) setFile(null);
|
|
233
|
+
setLocalFile(null);
|
|
234
|
+
setIsFileValid(false);
|
|
183
235
|
} else {
|
|
184
|
-
|
|
236
|
+
var errorMessage = 'Please wait for the file to finish loading.';
|
|
237
|
+
if (value.trim() === '') {
|
|
238
|
+
errorMessage = 'Message cannot be empty.';
|
|
239
|
+
} else if (file && !isFileValid) {
|
|
240
|
+
errorMessage = "File size should not exceed ".concat(maxFileSize, " MB.");
|
|
241
|
+
}
|
|
242
|
+
show(errorMessage, 'error');
|
|
185
243
|
}
|
|
186
244
|
};
|
|
187
245
|
|
|
188
246
|
// Define the right buttons for the input
|
|
189
247
|
var rightButtons = [];
|
|
190
|
-
if (
|
|
248
|
+
if (!!uploadFile) {
|
|
191
249
|
rightButtons.push( /*#__PURE__*/React.createElement(Button, {
|
|
192
250
|
width: 48,
|
|
193
251
|
typeStyle: "white",
|
|
@@ -203,107 +261,96 @@ var FileSearchInput = function FileSearchInput(_ref) {
|
|
|
203
261
|
}
|
|
204
262
|
|
|
205
263
|
// Handle file selection from the input - Web specific
|
|
206
|
-
var handleFileSelect = function
|
|
207
|
-
var
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
setLocalFile(file);
|
|
212
|
-
uploadFile(file);
|
|
213
|
-
}
|
|
214
|
-
event.target.value = null;
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
// Function to handle file deletion
|
|
218
|
-
var handleDeleteFile = function handleDeleteFile() {
|
|
219
|
-
resetProgress();
|
|
220
|
-
setFile(null);
|
|
221
|
-
setLocalFile(null);
|
|
222
|
-
setLoadingFile(false);
|
|
223
|
-
setProgress(0);
|
|
224
|
-
animateProgress(0);
|
|
225
|
-
if (fileInputRef.current) {
|
|
226
|
-
fileInputRef.current.value = null;
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
;
|
|
230
|
-
var uploadFile = /*#__PURE__*/function () {
|
|
231
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(file) {
|
|
232
|
-
var formData, response, result;
|
|
233
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
234
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
264
|
+
var handleFileSelect = /*#__PURE__*/function () {
|
|
265
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(event) {
|
|
266
|
+
var file;
|
|
267
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
268
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
235
269
|
case 0:
|
|
236
|
-
|
|
237
|
-
|
|
270
|
+
file = event.target.files[0];
|
|
271
|
+
if (!file) {
|
|
272
|
+
_context3.next = 11;
|
|
238
273
|
break;
|
|
239
274
|
}
|
|
240
|
-
|
|
241
|
-
return
|
|
242
|
-
case
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
response = _context2.sent;
|
|
253
|
-
if (!response.ok) {
|
|
254
|
-
_context2.next = 18;
|
|
275
|
+
_context3.next = 4;
|
|
276
|
+
return validateAndLoadFile(file);
|
|
277
|
+
case 4:
|
|
278
|
+
if (!_context3.sent) {
|
|
279
|
+
_context3.next = 11;
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
startLoading(file);
|
|
283
|
+
if (!!setFile) setFile(file);
|
|
284
|
+
setLocalFile(file);
|
|
285
|
+
if (!uploadFile) {
|
|
286
|
+
_context3.next = 11;
|
|
255
287
|
break;
|
|
256
288
|
}
|
|
257
|
-
|
|
258
|
-
return
|
|
289
|
+
_context3.next = 11;
|
|
290
|
+
return uploadFile(function (file) {
|
|
291
|
+
setProgress(progress);
|
|
292
|
+
animateProgress(progress);
|
|
293
|
+
});
|
|
294
|
+
case 11:
|
|
295
|
+
event.target.value = null;
|
|
259
296
|
case 12:
|
|
260
|
-
result = _context2.sent;
|
|
261
|
-
setFile(result);
|
|
262
|
-
setLocalFile(result);
|
|
263
|
-
completeProgress();
|
|
264
|
-
_context2.next = 19;
|
|
265
|
-
break;
|
|
266
|
-
case 18:
|
|
267
|
-
throw new Error('Failed to upload file');
|
|
268
|
-
case 19:
|
|
269
|
-
_context2.next = 27;
|
|
270
|
-
break;
|
|
271
|
-
case 21:
|
|
272
|
-
_context2.prev = 21;
|
|
273
|
-
_context2.t0 = _context2["catch"](5);
|
|
274
|
-
setProgress(0);
|
|
275
|
-
animateProgress(0);
|
|
276
|
-
console.error('Error uploading file:', _context2.t0);
|
|
277
|
-
Alert.alert('Error', 'Failed to upload file');
|
|
278
|
-
case 27:
|
|
279
|
-
_context2.prev = 27;
|
|
280
|
-
setLoadingFile(false);
|
|
281
|
-
return _context2.finish(27);
|
|
282
|
-
case 30:
|
|
283
297
|
case "end":
|
|
284
|
-
return
|
|
298
|
+
return _context3.stop();
|
|
285
299
|
}
|
|
286
|
-
},
|
|
300
|
+
}, _callee3);
|
|
287
301
|
}));
|
|
288
|
-
return function
|
|
289
|
-
return
|
|
302
|
+
return function handleFileSelect(_x2) {
|
|
303
|
+
return _ref4.apply(this, arguments);
|
|
290
304
|
};
|
|
291
305
|
}();
|
|
292
|
-
|
|
306
|
+
|
|
307
|
+
// Function to handle file deletion
|
|
308
|
+
var handleDeleteFile = function handleDeleteFile() {
|
|
309
|
+
resetProgress();
|
|
310
|
+
setProgress(0);
|
|
311
|
+
animateProgress(0);
|
|
312
|
+
setLocalFile(null);
|
|
313
|
+
setLoadingFile(false);
|
|
314
|
+
if (!!setFile) setFile(null);
|
|
315
|
+
if (!!setLoadedFile) setLoadedFile(false);
|
|
316
|
+
if (fileInputRef.current) {
|
|
317
|
+
fileInputRef.current.value = null;
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// Effect to complete progress
|
|
322
|
+
useEffect(function () {
|
|
323
|
+
if (loadedFile) {
|
|
324
|
+
completeProgress();
|
|
325
|
+
}
|
|
326
|
+
}, [loadedFile]);
|
|
327
|
+
return /*#__PURE__*/React.createElement(SafeAreaView, {
|
|
293
328
|
style: styles.container
|
|
294
|
-
}, file &&
|
|
295
|
-
file: file,
|
|
296
|
-
progressAnim: progressAnim,
|
|
297
|
-
handleDeleteFile: handleDeleteFile
|
|
298
|
-
}) : file && /*#__PURE__*/React.createElement(View, {
|
|
329
|
+
}, /*#__PURE__*/React.createElement(Alert, null), file && isFileValid && /*#__PURE__*/React.createElement(View, {
|
|
299
330
|
style: styles.fileNameContainer
|
|
300
331
|
}, /*#__PURE__*/React.createElement(View, {
|
|
301
332
|
style: styles.fileNameLoadedLeftContainer
|
|
302
333
|
}, /*#__PURE__*/React.createElement(FileIcon, {
|
|
303
334
|
style: styles.fileIcon
|
|
304
|
-
}), /*#__PURE__*/React.createElement(
|
|
305
|
-
style:
|
|
306
|
-
|
|
335
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
336
|
+
style: {
|
|
337
|
+
height: Platform.OS === "web" ? undefined : 28,
|
|
338
|
+
width: "80%"
|
|
339
|
+
}
|
|
340
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
341
|
+
style: styles.fileNameText,
|
|
342
|
+
numberOfLines: 1,
|
|
343
|
+
ellipsizeMode: "tail"
|
|
344
|
+
}, file.name), progress > 0 && /*#__PURE__*/React.createElement(View, {
|
|
345
|
+
style: styles.progressBarContainer
|
|
346
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
347
|
+
style: {
|
|
348
|
+
width: "".concat(progress, "%"),
|
|
349
|
+
height: 8,
|
|
350
|
+
backgroundColor: NEUTRAL_1000,
|
|
351
|
+
borderRadius: 16
|
|
352
|
+
}
|
|
353
|
+
})))), /*#__PURE__*/React.createElement(View, {
|
|
307
354
|
style: styles.fileNameRightContainer
|
|
308
355
|
}, /*#__PURE__*/React.createElement(CheckCircleIcon, {
|
|
309
356
|
style: styles.checkCircleIcon,
|
|
@@ -312,9 +359,7 @@ var FileSearchInput = function FileSearchInput(_ref) {
|
|
|
312
359
|
onPress: handleDeleteFile
|
|
313
360
|
}, /*#__PURE__*/React.createElement(DeleteIcon, {
|
|
314
361
|
style: styles.deleteIcon
|
|
315
|
-
})))), /*#__PURE__*/React.createElement(View, {
|
|
316
|
-
style: styles.inputContainer
|
|
317
|
-
}, Platform.OS === 'web' ? /*#__PURE__*/React.createElement("div", {
|
|
362
|
+
})))), /*#__PURE__*/React.createElement(View, null, Platform.OS === 'web' ? /*#__PURE__*/React.createElement("div", {
|
|
318
363
|
ref: dropAreaRef,
|
|
319
364
|
onDrop: handleDrop
|
|
320
365
|
}, /*#__PURE__*/React.createElement(InputBase, _extends({}, inputBaseProps, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const styles: {
|
|
2
2
|
container: {
|
|
3
|
-
|
|
3
|
+
width: "100%";
|
|
4
|
+
height: "10%";
|
|
4
5
|
};
|
|
5
6
|
inputContainer: {
|
|
6
7
|
flex: number;
|
|
@@ -14,37 +15,33 @@ export declare const styles: {
|
|
|
14
15
|
flexDirection: "row";
|
|
15
16
|
gap: number;
|
|
16
17
|
height: "100%";
|
|
18
|
+
flex: number;
|
|
17
19
|
justifyContent: "space-between";
|
|
18
20
|
marginBottom: number;
|
|
19
|
-
|
|
20
|
-
paddingRight: number;
|
|
21
|
+
paddingHorizontal: number;
|
|
21
22
|
paddingVertical: number;
|
|
22
|
-
width: "100%";
|
|
23
23
|
};
|
|
24
24
|
fileNameLeftContainer: {
|
|
25
25
|
flexDirection: "row";
|
|
26
26
|
gap: number;
|
|
27
|
-
|
|
27
|
+
};
|
|
28
|
+
fileNameRightContainer: {
|
|
29
|
+
flexDirection: "row";
|
|
28
30
|
};
|
|
29
31
|
fileNameLeftContent: {
|
|
30
|
-
flex: number;
|
|
31
32
|
height: number;
|
|
33
|
+
width: "80%";
|
|
32
34
|
};
|
|
33
35
|
fileNameLoadedLeftContainer: {
|
|
34
36
|
alignItems: "center";
|
|
35
37
|
flexDirection: "row";
|
|
36
38
|
gap: number;
|
|
37
|
-
width: "85%" |
|
|
39
|
+
width: "85%" | "75%";
|
|
38
40
|
};
|
|
39
41
|
checkCircleIcon: {
|
|
40
42
|
height: number;
|
|
41
43
|
width: number;
|
|
42
|
-
|
|
43
|
-
fileNameRightContainer: {
|
|
44
|
-
flexDirection: "row";
|
|
45
|
-
alignItems: "center";
|
|
46
|
-
gap: number;
|
|
47
|
-
width: "15%" | undefined;
|
|
44
|
+
marginRight: number;
|
|
48
45
|
};
|
|
49
46
|
deleteIcon: {
|
|
50
47
|
height: number;
|
|
@@ -64,21 +61,31 @@ export declare const styles: {
|
|
|
64
61
|
color: string;
|
|
65
62
|
fontWeight: "500";
|
|
66
63
|
fontSize: number;
|
|
67
|
-
height: "100%";
|
|
68
64
|
paddingBottom: number | undefined;
|
|
65
|
+
overflow: "hidden";
|
|
66
|
+
whiteSpace: string;
|
|
67
|
+
width: "100%";
|
|
68
|
+
flex: number;
|
|
69
|
+
marginLeft: number | undefined;
|
|
69
70
|
};
|
|
70
71
|
fileIcon: {
|
|
71
72
|
height: number;
|
|
72
73
|
width: number;
|
|
73
74
|
};
|
|
74
|
-
|
|
75
|
+
progressBarFill: {
|
|
75
76
|
backgroundColor: string;
|
|
76
77
|
borderRadius: number;
|
|
77
|
-
height:
|
|
78
|
+
height: "100%";
|
|
78
79
|
};
|
|
79
|
-
|
|
80
|
+
progressBarContainer: {
|
|
80
81
|
backgroundColor: string;
|
|
82
|
+
width: "100%";
|
|
81
83
|
borderRadius: number;
|
|
84
|
+
marginLeft: number | undefined;
|
|
85
|
+
};
|
|
86
|
+
progressBar: {
|
|
82
87
|
height: "100%";
|
|
88
|
+
backgroundColor: string;
|
|
89
|
+
borderRadius: number;
|
|
83
90
|
};
|
|
84
91
|
};
|
|
@@ -1,52 +1,49 @@
|
|
|
1
1
|
import { StyleSheet, Platform } from "react-native-web";
|
|
2
|
-
import {
|
|
2
|
+
import { NEUTRAL_100, NEUTRAL_1000, NEUTRAL_300, NEUTRAL_400, NEUTRAL_50 } from "../../../styles/colors";
|
|
3
3
|
export var styles = StyleSheet.create({
|
|
4
4
|
container: {
|
|
5
|
-
|
|
5
|
+
width: "100%",
|
|
6
|
+
height: "10%"
|
|
6
7
|
},
|
|
7
8
|
inputContainer: {
|
|
8
9
|
flex: 1
|
|
9
10
|
},
|
|
10
11
|
fileNameContainer: {
|
|
11
12
|
alignItems: 'center',
|
|
12
|
-
backgroundColor:
|
|
13
|
+
backgroundColor: NEUTRAL_50,
|
|
13
14
|
borderColor: NEUTRAL_400,
|
|
14
15
|
borderRadius: 8,
|
|
15
16
|
borderWidth: 1,
|
|
16
17
|
flexDirection: "row",
|
|
17
18
|
gap: 4,
|
|
18
19
|
height: "100%",
|
|
20
|
+
flex: 1,
|
|
19
21
|
justifyContent: "space-between",
|
|
20
22
|
marginBottom: 4,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
paddingVertical: Platform.OS === "web" ? 16 : 32,
|
|
24
|
-
width: "100%"
|
|
23
|
+
paddingHorizontal: 8,
|
|
24
|
+
paddingVertical: Platform.OS === "web" ? 16 : 32
|
|
25
25
|
},
|
|
26
26
|
fileNameLeftContainer: {
|
|
27
27
|
flexDirection: "row",
|
|
28
|
-
gap: 4
|
|
29
|
-
|
|
28
|
+
gap: 4
|
|
29
|
+
},
|
|
30
|
+
fileNameRightContainer: {
|
|
31
|
+
flexDirection: "row"
|
|
30
32
|
},
|
|
31
33
|
fileNameLeftContent: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
height: 24,
|
|
35
|
+
width: "80%"
|
|
34
36
|
},
|
|
35
37
|
fileNameLoadedLeftContainer: {
|
|
36
38
|
alignItems: "center",
|
|
37
39
|
flexDirection: "row",
|
|
38
40
|
gap: 4,
|
|
39
|
-
width: Platform.OS === "web" ?
|
|
41
|
+
width: Platform.OS === "web" ? "75%" : "85%"
|
|
40
42
|
},
|
|
41
43
|
checkCircleIcon: {
|
|
42
44
|
height: 24,
|
|
43
|
-
width: 24
|
|
44
|
-
|
|
45
|
-
fileNameRightContainer: {
|
|
46
|
-
flexDirection: "row",
|
|
47
|
-
alignItems: "center",
|
|
48
|
-
gap: 8,
|
|
49
|
-
width: Platform.OS === "web" ? undefined : "15%"
|
|
45
|
+
width: 24,
|
|
46
|
+
marginRight: 8
|
|
50
47
|
},
|
|
51
48
|
deleteIcon: {
|
|
52
49
|
height: 20,
|
|
@@ -66,21 +63,31 @@ export var styles = StyleSheet.create({
|
|
|
66
63
|
color: NEUTRAL_1000,
|
|
67
64
|
fontWeight: "500",
|
|
68
65
|
fontSize: Platform.OS === "web" ? 14 : 16,
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
paddingBottom: Platform.OS === "web" ? 4 : undefined,
|
|
67
|
+
overflow: 'hidden',
|
|
68
|
+
whiteSpace: 'nowrap',
|
|
69
|
+
width: "100%",
|
|
70
|
+
flex: 1,
|
|
71
|
+
marginLeft: Platform.OS === "web" ? undefined : 8
|
|
71
72
|
},
|
|
72
73
|
fileIcon: {
|
|
73
|
-
height: 36,
|
|
74
|
-
width: 36
|
|
75
|
-
},
|
|
76
|
-
progressBarBackground: {
|
|
77
|
-
backgroundColor: NEUTRAL_300,
|
|
78
|
-
borderRadius: 10,
|
|
79
|
-
height: 8
|
|
74
|
+
height: Platform.OS === "web" ? 40 : 36,
|
|
75
|
+
width: Platform.OS === "web" ? 40 : 36
|
|
80
76
|
},
|
|
81
77
|
progressBarFill: {
|
|
82
78
|
backgroundColor: NEUTRAL_100,
|
|
83
79
|
borderRadius: 10,
|
|
84
80
|
height: '100%'
|
|
81
|
+
},
|
|
82
|
+
progressBarContainer: {
|
|
83
|
+
backgroundColor: NEUTRAL_300,
|
|
84
|
+
width: '100%',
|
|
85
|
+
borderRadius: 16,
|
|
86
|
+
marginLeft: Platform.OS === "web" ? undefined : 8
|
|
87
|
+
},
|
|
88
|
+
progressBar: {
|
|
89
|
+
height: '100%',
|
|
90
|
+
backgroundColor: NEUTRAL_1000,
|
|
91
|
+
borderRadius: 2
|
|
85
92
|
}
|
|
86
93
|
});
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { Animated } from 'react-native';
|
|
2
2
|
import { IInputBase } from '../InputBase.types';
|
|
3
|
-
export type FetchData = {
|
|
4
|
-
file: any;
|
|
5
|
-
url: string;
|
|
6
|
-
method: string;
|
|
7
|
-
};
|
|
8
3
|
export interface FileSearchInputProps extends IInputBase {
|
|
9
4
|
value: string;
|
|
10
|
-
setFile
|
|
5
|
+
setFile?: (file: any) => void;
|
|
11
6
|
onChangeText: (text: string) => void;
|
|
12
7
|
onSubmit: (message: string, file?: any) => void;
|
|
13
8
|
placeholder: string;
|
|
14
|
-
|
|
9
|
+
uploadFile?: (file: any) => Promise<void>;
|
|
10
|
+
maxFileSize?: number;
|
|
11
|
+
loadedFile?: boolean;
|
|
12
|
+
setLoadedFile?: (loaded: boolean) => void;
|
|
15
13
|
}
|
|
16
14
|
export interface FileStatusDisplayProps {
|
|
17
15
|
file: any;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _FileSearchInput=require("./FileSearchInput.styles");var _DeleteIcon=require("../../../assets/images/icons/DeleteIcon");var _FileIcon=require("../../../assets/images/icons/FileIcon");var _this=this,_jsxFileName="/home/jenkins/agent/workspace/etendo_ui_library_develop/etendo_ui_library/src/components/inputBase/file-search-input/FileStatusDisplay.tsx";var FileStatusDisplay=function FileStatusDisplay(_ref){var file=_ref.file,progressAnim=_ref.progressAnim,handleDeleteFile=_ref.handleDeleteFile;return _react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:14,columnNumber:9}},_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameLeftContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:15,columnNumber:13}},_react.default.createElement(_FileIcon.FileIcon,{style:_FileSearchInput.styles.fileIcon,__self:_this,__source:{fileName:_jsxFileName,lineNumber:16,columnNumber:17}}),_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameLeftContent,__self:_this,__source:{fileName:_jsxFileName,lineNumber:17,columnNumber:17}},_react.default.createElement(_reactNative.Text,{style:_FileSearchInput.styles.fileNameText,__self:_this,__source:{fileName:_jsxFileName,lineNumber:18,columnNumber:21}},file.name),_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.progressBarBackground,__self:_this,__source:{fileName:_jsxFileName,lineNumber:19,columnNumber:21}},_react.default.createElement(_reactNative.Animated.View,{style:[_FileSearchInput.styles.progressBarFill,{width:progressAnim.interpolate({inputRange:[0,100],outputRange:['0%','100%']})}],__self:_this,__source:{fileName:_jsxFileName,lineNumber:20,columnNumber:25}})))),_react.default.createElement(_reactNative.TouchableOpacity,{onPress:handleDeleteFile,__self:_this,__source:{fileName:_jsxFileName,lineNumber:34,columnNumber:13}},_react.default.createElement(_DeleteIcon.DeleteIcon,{style:_FileSearchInput.styles.deleteIcon,__self:_this,__source:{fileName:_jsxFileName,lineNumber:35,columnNumber:17}})));};var _default=exports.default=FileStatusDisplay;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View, Text, TouchableOpacity, Animated } from "react-native-web";
|
|
3
|
-
import { styles } from "./FileSearchInput.styles";
|
|
4
|
-
import { DeleteIcon } from "../../../assets/images/icons/DeleteIcon";
|
|
5
|
-
import { FileIcon } from "../../../assets/images/icons/FileIcon";
|
|
6
|
-
var FileStatusDisplay = function FileStatusDisplay(_ref) {
|
|
7
|
-
var file = _ref.file,
|
|
8
|
-
progressAnim = _ref.progressAnim,
|
|
9
|
-
handleDeleteFile = _ref.handleDeleteFile;
|
|
10
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
11
|
-
style: styles.fileNameContainer
|
|
12
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
13
|
-
style: styles.fileNameLeftContainer
|
|
14
|
-
}, /*#__PURE__*/React.createElement(FileIcon, {
|
|
15
|
-
style: styles.fileIcon
|
|
16
|
-
}), /*#__PURE__*/React.createElement(View, {
|
|
17
|
-
style: styles.fileNameLeftContent
|
|
18
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
19
|
-
style: styles.fileNameText
|
|
20
|
-
}, file.name), /*#__PURE__*/React.createElement(View, {
|
|
21
|
-
style: styles.progressBarBackground
|
|
22
|
-
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
23
|
-
style: [styles.progressBarFill, {
|
|
24
|
-
width: progressAnim.interpolate({
|
|
25
|
-
inputRange: [0, 100],
|
|
26
|
-
outputRange: ['0%', '100%']
|
|
27
|
-
})
|
|
28
|
-
}]
|
|
29
|
-
})))), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
30
|
-
onPress: handleDeleteFile
|
|
31
|
-
}, /*#__PURE__*/React.createElement(DeleteIcon, {
|
|
32
|
-
style: styles.deleteIcon
|
|
33
|
-
})));
|
|
34
|
-
};
|
|
35
|
-
export default FileStatusDisplay;
|