etendo-ui-library 1.7.2 → 1.7.4
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/index.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 +1 -0
- package/dist-native/components/inputBase/file-search-input/FileSearchInput.styles.js +1 -1
- package/dist-web/components/index.d.ts +1 -1
- package/dist-web/components/index.js +1 -1
- package/dist-web/components/inputBase/file-search-input/FileSearchInput.js +3 -4
- package/dist-web/components/inputBase/file-search-input/FileSearchInput.styles.d.ts +1 -0
- package/dist-web/components/inputBase/file-search-input/FileSearchInput.styles.js +3 -3
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +1 -1
|
@@ -15,4 +15,4 @@ import { Cards } from './cards';
|
|
|
15
15
|
import { Alert, setAlertDefaultDuration, show } from './alert';
|
|
16
16
|
import { Signature } from './signature';
|
|
17
17
|
import { TextMessageRN } from './text-message-rn';
|
|
18
|
-
export { Alert, Button, CardDropdown, Cards, DatePickerInput, DrawerLateral, FileSearchInput, Input, InputBase, DropdownInput, SearchInput, PasswordInput, TextInput, Layout, Modal, Navbar, Pagination, SearchContainer, setAlertDefaultDuration, show, SkeletonItem, StatusBar, Signature, Tab, Table,
|
|
18
|
+
export { Alert, Button, CardDropdown, Cards, DatePickerInput, DrawerLateral, FileSearchInput, Input, InputBase, DropdownInput, SearchInput, PasswordInput, TextInput, Layout, Modal, Navbar, Pagination, SearchContainer, setAlertDefaultDuration, show, SkeletonItem, StatusBar, Signature, Tab, Table, TitleContainer, TextMessageRN, ViewEtendo, };
|
|
@@ -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 _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));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 _FileIcon=require("../../../assets/images/icons/FileIcon");var _button=require("../../button");var _secondaryComponents=require("../../secondaryComponents");var _functions_utils=require("../../../helpers/functions_utils");var _icons=require("../../../assets/images/icons");var _FileSearchInput2=require("./FileSearchInput.constants");var _excluded=["value","placeholder","onChangeText","onSubmit","setFile","onFileUploaded","onError","uploadConfig","maxFileSize","rightButtons","isAttachDisable","isSendDisable"];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&&{}.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(!(0,_functions_utils.isWebPlatform)()){try{import('react-native-document-picker').then(function(module){DocumentPicker=module.default;}).catch(function(error){console.error('Cannot load DocumentPicker',error);});}catch(error){console.error('Error importing DocumentPicker',error);}}var POSITION_DOWN_FILE=55;var POSITION_UP_FILE=60;var FileSearchInput=function FileSearchInput(_ref){var value=_ref.value,placeholder=_ref.placeholder,onChangeText=_ref.onChangeText,onSubmit=_ref.onSubmit,setFile=_ref.setFile,onFileUploaded=_ref.onFileUploaded,onError=_ref.onError,uploadConfig=_ref.uploadConfig,_ref$maxFileSize=_ref.maxFileSize,maxFileSize=_ref$maxFileSize===void 0?512:_ref$maxFileSize,rightButtons=_ref.rightButtons,isAttachDisable=_ref.isAttachDisable,isSendDisable=_ref.isSendDisable,inputBaseProps=(0,_objectWithoutProperties2.default)(_ref,_excluded);var _useState=(0,_react.useState)(0),_useState2=(0,_slicedToArray2.default)(_useState,2),progress=_useState2[0],setProgress=_useState2[1];var _useState3=(0,_react.useState)(null),_useState4=(0,_slicedToArray2.default)(_useState3,2),file=_useState4[0],setLocalFile=_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)(false),_useState8=(0,_slicedToArray2.default)(_useState7,2),isFileValid=_useState8[0],setIsFileValid=_useState8[1];var _useState9=(0,_react.useState)('none'),_useState10=(0,_slicedToArray2.default)(_useState9,2),fileStatus=_useState10[0],setFileStatus=_useState10[1];var _useState11=(0,_react.useState)({top:0,left:0,width:0}),_useState12=(0,_slicedToArray2.default)(_useState11,2),modalPosition=_useState12[0],setModalPosition=_useState12[1];var _Dimensions$get=_reactNative.Dimensions.get('window'),windowHeight=_Dimensions$get.height,windowWidth=_Dimensions$get.width;var refInput=(0,_react.useRef)(null);var dropAreaRef=(0,_react.useRef)(null);var fileInputRef=(0,_react.useRef)(null);var abortControllerRef=(0,_react.useRef)(null);var resetProgress=function resetProgress(){setLocalFile(null);setIsFileValid(false);setLoadingFile(false);setProgress(0);setFileStatus('none');};var handleDragOver=function handleDragOver(event){event.preventDefault();};var handleDrop=function handleDrop(event){event.preventDefault();var files=event.dataTransfer.files;if(files.length>0){var droppedFile=files[0];validateAndLoadFile(droppedFile);if(!!setFile)setFile(droppedFile);setLocalFile(droppedFile);}};var completeProgress=function completeProgress(){setProgress(100);animateProgress(100);setLoadingFile(false);setIsFileValid(true);setTimeout(function(){setFileStatus('loaded');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(!!setFile)setFile(pickedFile);setIsFileValid(true);startLoading(pickedFile);try{if(!!uploadFile)yield uploadFile(pickedFile);}catch(error){console.error('Error uploading file:',error);setFileStatus('error');onError==null?void 0:onError(error);}return true;});return function validateAndLoadFile(_x){return _ref2.apply(this,arguments);};}();var handleFileButtonClick=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(){if((0,_functions_utils.isWebPlatform)()){fileInputRef.current.click();}else{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(error){if(!DocumentPicker.isCancel(error)){console.error(error);onError==null?void 0:onError(error);}}}});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.";}}};var UploadButton=_react.default.createElement(_button.Button,{typeStyle:"white",onPress:handleFileButtonClick,disabled:isAttachDisable,iconLeft:_react.default.createElement(_icons.PaperclipIcon,{style:_FileSearchInput.styles.fileIcon,__self:_this,__source:{fileName:_jsxFileName,lineNumber:219,columnNumber:17}}),__self:_this,__source:{fileName:_jsxFileName,lineNumber:215,columnNumber:5}});var SendButton=_react.default.createElement(_button.Button,{typeStyle:"white",onPress:handleSendMessage,disabled:isSendDisable,iconLeft:_react.default.createElement(_icons.CornerDownRightIcon,{style:_FileSearchInput.styles.fileIcon,__self:_this,__source:{fileName:_jsxFileName,lineNumber:227,columnNumber:17}}),__self:_this,__source:{fileName:_jsxFileName,lineNumber:223,columnNumber:5}});var buttons=rightButtons;if(!!uploadConfig){buttons=buttons?[].concat((0,_toConsumableArray2.default)(buttons),[UploadButton]):[UploadButton];}if(!!onSubmit){buttons=buttons?[].concat((0,_toConsumableArray2.default)(buttons),[SendButton]):[SendButton];}var handleFileSelect=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(event){var file=event.target.files[0];if(file){if(yield validateAndLoadFile(file)){if(!!setFile)setFile(file);setLocalFile(file);}}event.target.value=null;});return function handleFileSelect(_x2){return _ref4.apply(this,arguments);};}();var uploadFile=function(){var _ref5=(0,_asyncToGenerator2.default)(function*(pickedFile){if(!!uploadConfig){var formData=new FormData();formData.append('file',pickedFile);abortControllerRef.current=new AbortController();var signal=abortControllerRef.current.signal;try{var response=yield fetch(uploadConfig.url,{method:uploadConfig.method,body:formData,headers:uploadConfig.headers,signal:signal});if(response.ok){completeProgress();setLoadingFile(false);setFileStatus('loaded');if(!!onFileUploaded){var data=yield response.json();onFileUploaded(data);}}else{var errorResponse=yield response.json();console.error('Error uploading file:',errorResponse);onError==null?void 0:onError(errorResponse);setFileStatus('error');resetProgress();if(!!setFile)setFile(null);}}catch(error){if(error.name==='AbortError'){console.error('File upload cancelled');setFileStatus('canceled');}else{console.error('Error uploading file:',error);setFileStatus('error');}resetProgress();if(!!setFile)setFile(null);}}});return function uploadFile(_x3){return _ref5.apply(this,arguments);};}();var handleCancelFile=function handleCancelFile(){if(abortControllerRef.current){abortControllerRef.current.abort();}resetProgress();animateProgress(0);if(!!setFile)setFile(null);setFileStatus('canceled');if(fileInputRef.current){fileInputRef.current.value=null;}};(0,_react.useEffect)(function(){return function(){if(abortControllerRef.current){abortControllerRef.current.abort();}};},[]);var adjustDropdownPosition=(0,_react.useCallback)(function(){if(refInput.current){refInput.current.measure(function(x,y,width,height,pageX,pageY){setModalPosition({top:pageY>=POSITION_UP_FILE?-POSITION_UP_FILE:POSITION_DOWN_FILE,left:pageX,width:width});});}},[windowHeight]);(0,_react.useEffect)(function(){adjustDropdownPosition();if((0,_functions_utils.isWebPlatform)()){var handleScroll=function handleScroll(){adjustDropdownPosition();};window.addEventListener('scroll',handleScroll,{passive:true});return function(){return window.removeEventListener('scroll',handleScroll);};}},[windowHeight,windowWidth,adjustDropdownPosition]);var onKeyPressHandler=function onKeyPressHandler(e){if(_FileSearchInput2.KEY_SHIFT in e&&e.nativeEvent.key===_FileSearchInput2.KEY_ENTER&&!e.nativeEvent.shiftKey){e.preventDefault();handleSendMessage();}};return _react.default.createElement(_reactNative.SafeAreaView,{style:_FileSearchInput.styles.container,__self:_this,__source:{fileName:_jsxFileName,lineNumber:360,columnNumber:5}},_react.default.createElement(_react.default.Fragment,null,(0,_functions_utils.isWebPlatform)()?_react.default.createElement("div",{ref:dropAreaRef,onDrop:handleDrop,onDragOver:handleDragOver,onDragEnter:handleDragOver,onDragLeave:handleDragOver,__self:_this,__source:{fileName:_jsxFileName,lineNumber:363,columnNumber:11}},_react.default.createElement(_InputBase.default,(0,_extends2.default)({},inputBaseProps,{refInputContainer:refInput,value:value,onChangeText:onChangeText,rightButtons:buttons,onSubmitEditing:handleSendMessage,placeholder:placeholder,onKeyPress:onKeyPressHandler,__self:_this,__source:{fileName:_jsxFileName,lineNumber:369,columnNumber:13}})),_react.default.createElement("input",{type:"file",ref:fileInputRef,style:{display:'none'},onChange:handleFileSelect,__self:_this,__source:{fileName:_jsxFileName,lineNumber:379,columnNumber:13}})):_react.default.createElement(_InputBase.default,(0,_extends2.default)({},inputBaseProps,{value:value,onChangeText:onChangeText,rightButtons:buttons,placeholder:placeholder,__self:_this,__source:{fileName:_jsxFileName,lineNumber:387,columnNumber:11}}))),file&&isFileValid&&fileStatus!=='canceled'&&_react.default.createElement(_reactNative.View,{onStartShouldSetResponder:function onStartShouldSetResponder(){return true;},style:[_FileSearchInput.styles.fileContainer,{top:modalPosition.top,width:modalPosition.width}],__self:_this,__source:{fileName:_jsxFileName,lineNumber:397,columnNumber:9}},_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:406,columnNumber:11}},_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameLoadedLeftContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:407,columnNumber:13}},_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileIconContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:408,columnNumber:15}},_react.default.createElement(_FileIcon.FileIcon,{style:_FileSearchInput.styles.fileIcon,__self:_this,__source:{fileName:_jsxFileName,lineNumber:409,columnNumber:17}})),_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileContent,__self:_this,__source:{fileName:_jsxFileName,lineNumber:411,columnNumber:15}},_react.default.createElement(_reactNative.Text,{style:_FileSearchInput.styles.fileNameText,numberOfLines:1,ellipsizeMode:"tail",__self:_this,__source:{fileName:_jsxFileName,lineNumber:412,columnNumber:17}},file==null?void 0:file.name),progress>0&&_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.progressBarContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:419,columnNumber:19}},_react.default.createElement(_secondaryComponents.SkeletonItem,{width:progress+"%",height:8,color:_colors.NEUTRAL_1000,borderRadius:16,__self:_this,__source:{fileName:_jsxFileName,lineNumber:420,columnNumber:21}})))),_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameRightContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:431,columnNumber:13}},fileStatus==='loaded'&&_react.default.createElement(_icons.CheckCircleFillIcon,{style:_FileSearchInput.styles.checkCircleIcon,fill:_colors.SUCCESS_600,__self:_this,__source:{fileName:_jsxFileName,lineNumber:433,columnNumber:17}}),_react.default.createElement(_reactNative.TouchableOpacity,{style:_FileSearchInput.styles.containerXicon,onPress:handleCancelFile,__self:_this,__source:{fileName:_jsxFileName,lineNumber:438,columnNumber:15}},_react.default.createElement(_icons.XIcon,{style:_FileSearchInput.styles.deleteIcon,__self:_this,__source:{fileName:_jsxFileName,lineNumber:441,columnNumber:17}}))))));};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 _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));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 _FileIcon=require("../../../assets/images/icons/FileIcon");var _button=require("../../button");var _secondaryComponents=require("../../secondaryComponents");var _functions_utils=require("../../../helpers/functions_utils");var _icons=require("../../../assets/images/icons");var _utilsTypes=require("../../../helpers/utilsTypes");var _FileSearchInput2=require("./FileSearchInput.constants");var _excluded=["value","placeholder","onChangeText","onSubmit","setFile","onFileUploaded","onError","uploadConfig","maxFileSize","rightButtons","isAttachDisable","isSendDisable"];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&&{}.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(!(0,_functions_utils.isWebPlatform)()){try{import('react-native-document-picker').then(function(module){DocumentPicker=module.default;}).catch(function(error){console.error('Cannot load DocumentPicker',error);});}catch(error){console.error('Error importing DocumentPicker',error);}}var POSITION_DOWN_FILE=55;var POSITION_UP_FILE=60;var FileSearchInput=function FileSearchInput(_ref){var value=_ref.value,placeholder=_ref.placeholder,onChangeText=_ref.onChangeText,onSubmit=_ref.onSubmit,setFile=_ref.setFile,onFileUploaded=_ref.onFileUploaded,onError=_ref.onError,uploadConfig=_ref.uploadConfig,_ref$maxFileSize=_ref.maxFileSize,maxFileSize=_ref$maxFileSize===void 0?512:_ref$maxFileSize,rightButtons=_ref.rightButtons,isAttachDisable=_ref.isAttachDisable,isSendDisable=_ref.isSendDisable,inputBaseProps=(0,_objectWithoutProperties2.default)(_ref,_excluded);var _useState=(0,_react.useState)(0),_useState2=(0,_slicedToArray2.default)(_useState,2),progress=_useState2[0],setProgress=_useState2[1];var _useState3=(0,_react.useState)(null),_useState4=(0,_slicedToArray2.default)(_useState3,2),file=_useState4[0],setLocalFile=_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)(false),_useState8=(0,_slicedToArray2.default)(_useState7,2),isFileValid=_useState8[0],setIsFileValid=_useState8[1];var _useState9=(0,_react.useState)('none'),_useState10=(0,_slicedToArray2.default)(_useState9,2),fileStatus=_useState10[0],setFileStatus=_useState10[1];var _useState11=(0,_react.useState)({top:0,left:0,width:0}),_useState12=(0,_slicedToArray2.default)(_useState11,2),modalPosition=_useState12[0],setModalPosition=_useState12[1];var _Dimensions$get=_reactNative.Dimensions.get('window'),windowHeight=_Dimensions$get.height,windowWidth=_Dimensions$get.width;var refInput=(0,_react.useRef)(null);var dropAreaRef=(0,_react.useRef)(null);var fileInputRef=(0,_react.useRef)(null);var abortControllerRef=(0,_react.useRef)(null);var resetProgress=function resetProgress(){setLocalFile(null);setIsFileValid(false);setLoadingFile(false);setProgress(0);setFileStatus('none');};var handleDragOver=function handleDragOver(event){event.preventDefault();};var handleDrop=function handleDrop(event){event.preventDefault();var files=event.dataTransfer.files;if(files.length>0){var droppedFile=files[0];validateAndLoadFile(droppedFile);if(!!setFile)setFile(droppedFile);setLocalFile(droppedFile);}};var completeProgress=function completeProgress(){setProgress(100);animateProgress(100);setLoadingFile(false);setIsFileValid(true);setTimeout(function(){setFileStatus('loaded');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(!!setFile)setFile(pickedFile);setIsFileValid(true);startLoading(pickedFile);try{if(!!uploadFile)yield uploadFile(pickedFile);}catch(error){console.error('Error uploading file:',error);setFileStatus('error');onError==null?void 0:onError(error);}return true;});return function validateAndLoadFile(_x){return _ref2.apply(this,arguments);};}();var handleFileButtonClick=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(){if((0,_functions_utils.isWebPlatform)()){fileInputRef.current.click();}else{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(error){if(!DocumentPicker.isCancel(error)){console.error(error);onError==null?void 0:onError(error);}}}});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.";}}};var UploadButton=_react.default.createElement(_button.Button,{typeStyle:"white",onPress:handleFileButtonClick,disabled:isAttachDisable,iconLeft:_react.default.createElement(_icons.PaperclipIcon,{style:_FileSearchInput.styles.fileIcon,__self:_this,__source:{fileName:_jsxFileName,lineNumber:215,columnNumber:17}}),__self:_this,__source:{fileName:_jsxFileName,lineNumber:211,columnNumber:5}});var SendButton=_react.default.createElement(_button.Button,{typeStyle:"white",onPress:handleSendMessage,disabled:isSendDisable,iconLeft:_react.default.createElement(_icons.CornerDownRightIcon,{style:_FileSearchInput.styles.fileIcon,__self:_this,__source:{fileName:_jsxFileName,lineNumber:223,columnNumber:17}}),__self:_this,__source:{fileName:_jsxFileName,lineNumber:219,columnNumber:5}});var buttons=rightButtons;if(!!uploadConfig){buttons=buttons?[].concat((0,_toConsumableArray2.default)(buttons),[UploadButton]):[UploadButton];}if(!!onSubmit){buttons=buttons?[].concat((0,_toConsumableArray2.default)(buttons),[SendButton]):[SendButton];}var handleFileSelect=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(event){var file=event.target.files[0];if(file){if(yield validateAndLoadFile(file)){if(!!setFile)setFile(file);setLocalFile(file);}}event.target.value=null;});return function handleFileSelect(_x2){return _ref4.apply(this,arguments);};}();var uploadFile=function(){var _ref5=(0,_asyncToGenerator2.default)(function*(pickedFile){if(!!uploadConfig){var formData=new FormData();formData.append('file',pickedFile);abortControllerRef.current=new AbortController();var signal=abortControllerRef.current.signal;try{var response=yield fetch(uploadConfig.url,{method:uploadConfig.method,body:formData,headers:uploadConfig.headers,signal:signal});if(response.ok){completeProgress();setLoadingFile(false);setFileStatus('loaded');if(!!onFileUploaded){var data=yield response.json();onFileUploaded(data);}}else{var errorResponse=yield response.json();console.error('Error uploading file:',errorResponse);onError==null?void 0:onError(errorResponse);setFileStatus('error');resetProgress();if(!!setFile)setFile(null);}}catch(error){if(error.name==='AbortError'){console.error('File upload cancelled');setFileStatus('canceled');}else{console.error('Error uploading file:',error);setFileStatus('error');}resetProgress();if(!!setFile)setFile(null);}}});return function uploadFile(_x3){return _ref5.apply(this,arguments);};}();var handleCancelFile=function handleCancelFile(){if(abortControllerRef.current){abortControllerRef.current.abort();}resetProgress();animateProgress(0);if(!!setFile)setFile(null);setFileStatus('canceled');if(fileInputRef.current){fileInputRef.current.value=null;}};(0,_react.useEffect)(function(){return function(){if(abortControllerRef.current){abortControllerRef.current.abort();}};},[]);var adjustDropdownPosition=(0,_react.useCallback)(function(){if(refInput.current){refInput.current.measure(function(x,y,width,height,pageX,pageY){setModalPosition({top:pageY>=POSITION_UP_FILE?-POSITION_UP_FILE:POSITION_DOWN_FILE,left:pageX,width:width});});}},[windowHeight]);(0,_react.useEffect)(function(){adjustDropdownPosition();if((0,_functions_utils.isWebPlatform)()){var handleScroll=function handleScroll(){adjustDropdownPosition();};window.addEventListener('scroll',handleScroll,{passive:true});return function(){return window.removeEventListener('scroll',handleScroll);};}},[windowHeight,windowWidth,adjustDropdownPosition]);var onKeyPressHandler=function onKeyPressHandler(e){if(_FileSearchInput2.KEY_SHIFT in e&&e.nativeEvent.key===_FileSearchInput2.KEY_ENTER&&!e.nativeEvent.shiftKey){e.preventDefault();handleSendMessage();}};return _react.default.createElement(_reactNative.SafeAreaView,{style:_FileSearchInput.styles.container,__self:_this,__source:{fileName:_jsxFileName,lineNumber:356,columnNumber:5}},_react.default.createElement(_react.default.Fragment,null,(0,_functions_utils.isWebPlatform)()?_react.default.createElement("div",{ref:dropAreaRef,onDrop:handleDrop,onDragOver:handleDragOver,onDragEnter:handleDragOver,onDragLeave:handleDragOver,__self:_this,__source:{fileName:_jsxFileName,lineNumber:359,columnNumber:11}},_react.default.createElement(_InputBase.default,(0,_extends2.default)({},inputBaseProps,{refInputContainer:refInput,value:value,onChangeText:onChangeText,rightButtons:buttons,onSubmitEditing:handleSendMessage,placeholder:placeholder,onKeyPress:onKeyPressHandler,__self:_this,__source:{fileName:_jsxFileName,lineNumber:365,columnNumber:13}})),_react.default.createElement("input",{type:"file",ref:fileInputRef,style:{display:'none'},onChange:handleFileSelect,__self:_this,__source:{fileName:_jsxFileName,lineNumber:375,columnNumber:13}})):_react.default.createElement(_InputBase.default,(0,_extends2.default)({},inputBaseProps,{value:value,onChangeText:onChangeText,rightButtons:buttons,placeholder:placeholder,__self:_this,__source:{fileName:_jsxFileName,lineNumber:383,columnNumber:11}}))),file&&isFileValid&&fileStatus!=='canceled'&&_react.default.createElement(_reactNative.View,{onStartShouldSetResponder:function onStartShouldSetResponder(){return true;},style:[_FileSearchInput.styles.fileContainer,{top:_reactNative.Platform.OS===_utilsTypes.AppPlatform.web?modalPosition.top:modalPosition.top-POSITION_UP_FILE}],__self:_this,__source:{fileName:_jsxFileName,lineNumber:393,columnNumber:9}},_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:401,columnNumber:11}},_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameLoadedLeftContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:402,columnNumber:13}},_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileIconContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:403,columnNumber:15}},_react.default.createElement(_FileIcon.FileIcon,{style:_FileSearchInput.styles.fileIcon,__self:_this,__source:{fileName:_jsxFileName,lineNumber:404,columnNumber:17}})),_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileContent,__self:_this,__source:{fileName:_jsxFileName,lineNumber:406,columnNumber:15}},_react.default.createElement(_reactNative.Text,{style:_FileSearchInput.styles.fileNameText,numberOfLines:1,ellipsizeMode:"tail",__self:_this,__source:{fileName:_jsxFileName,lineNumber:407,columnNumber:17}},file==null?void 0:file.name),progress>0&&_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.progressBarContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:414,columnNumber:19}},_react.default.createElement(_secondaryComponents.SkeletonItem,{width:progress+"%",height:8,color:_colors.NEUTRAL_1000,borderRadius:16,__self:_this,__source:{fileName:_jsxFileName,lineNumber:415,columnNumber:21}})))),_react.default.createElement(_reactNative.View,{style:_FileSearchInput.styles.fileNameRightContainer,__self:_this,__source:{fileName:_jsxFileName,lineNumber:426,columnNumber:13}},fileStatus==='loaded'&&_react.default.createElement(_icons.CheckCircleFillIcon,{style:_FileSearchInput.styles.checkCircleIcon,fill:_colors.SUCCESS_600,__self:_this,__source:{fileName:_jsxFileName,lineNumber:428,columnNumber:17}}),_react.default.createElement(_reactNative.TouchableOpacity,{style:_FileSearchInput.styles.containerXicon,onPress:handleCancelFile,__self:_this,__source:{fileName:_jsxFileName,lineNumber:433,columnNumber:15}},_react.default.createElement(_icons.XIcon,{style:_FileSearchInput.styles.deleteIcon,__self:_this,__source:{fileName:_jsxFileName,lineNumber:436,columnNumber:17}}))))));};var _default=exports.default=FileSearchInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.styles=exports.mediaQueryWidths=void 0;var _reactNative=require("react-native");var _colors=require("../../../styles/colors");var _functions_utils=require("../../../helpers/functions_utils");var
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.styles=exports.mediaQueryWidths=void 0;var _reactNative=require("react-native");var _colors=require("../../../styles/colors");var _functions_utils=require("../../../helpers/functions_utils");var mediaQueryWidths=exports.mediaQueryWidths={MOBILE:480,TABLET:768,DESKTOP:1280};var styles=exports.styles=_reactNative.StyleSheet.create({container:{width:'100%'},inputContainer:{flex:1},fileNameContainer:{alignItems:'center',backgroundColor:_colors.NEUTRAL_50,borderColor:_colors.NEUTRAL_400,borderRadius:8,borderWidth:1,flexDirection:'row',justifyContent:'space-between',marginBottom:4,paddingHorizontal:8,minHeight:56,flex:1},fileNameLeftContainer:{flexDirection:'row'},fileNameRightContainer:{flexDirection:'row',alignItems:'center',paddingLeft:8},fileNameLeftContent:{height:24,width:'100%'},fileNameLoadedLeftContainer:{alignItems:'center',flexDirection:'row',flex:1},checkCircleIcon:{height:24,width:24},errorIcon:{height:24,width:24},deleteIcon:{height:24,width:24},loadingContainer:{alignItems:'center',justifyContent:'center',paddingHorizontal:8,paddingVertical:16,width:'100%'},loadingText:{fontSize:14},fileContent:{height:(0,_functions_utils.isWebPlatform)()?undefined:28,flex:1},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%',marginLeft:_reactNative.Platform.OS==='web'?undefined:8},fileIcon:{height:24,width:24},fileContainer:{position:'absolute',width:"100%"},progressBarFill:{backgroundColor:_colors.NEUTRAL_100,borderRadius:10},progressBarContainer:{backgroundColor:_colors.NEUTRAL_300,borderRadius:16,marginLeft:_reactNative.Platform.OS==='web'?undefined:8,width:'100%'},progressBar:{backgroundColor:_colors.NEUTRAL_1000,borderRadius:2},containerXicon:{marginLeft:8,marginRight:4},fileIconContainer:{paddingRight:8}});
|
|
@@ -15,4 +15,4 @@ import { Cards } from './cards';
|
|
|
15
15
|
import { Alert, setAlertDefaultDuration, show } from './alert';
|
|
16
16
|
import { Signature } from './signature';
|
|
17
17
|
import { TextMessageRN } from './text-message-rn';
|
|
18
|
-
export { Alert, Button, CardDropdown, Cards, DatePickerInput, DrawerLateral, FileSearchInput, Input, InputBase, DropdownInput, SearchInput, PasswordInput, TextInput, Layout, Modal, Navbar, Pagination, SearchContainer, setAlertDefaultDuration, show, SkeletonItem, StatusBar, Signature, Tab, Table,
|
|
18
|
+
export { Alert, Button, CardDropdown, Cards, DatePickerInput, DrawerLateral, FileSearchInput, Input, InputBase, DropdownInput, SearchInput, PasswordInput, TextInput, Layout, Modal, Navbar, Pagination, SearchContainer, setAlertDefaultDuration, show, SkeletonItem, StatusBar, Signature, Tab, Table, TitleContainer, TextMessageRN, ViewEtendo, };
|
|
@@ -15,4 +15,4 @@ import { Cards } from "./cards";
|
|
|
15
15
|
import { Alert, setAlertDefaultDuration, show } from "./alert";
|
|
16
16
|
import { Signature } from "./signature";
|
|
17
17
|
import { TextMessageRN } from "./text-message-rn";
|
|
18
|
-
export { Alert, Button, CardDropdown, Cards, DatePickerInput, DrawerLateral, FileSearchInput, Input, InputBase, DropdownInput, SearchInput, PasswordInput, TextInput, Layout, Modal, Navbar, Pagination, SearchContainer, setAlertDefaultDuration, show, SkeletonItem, StatusBar, Signature, Tab, Table,
|
|
18
|
+
export { Alert, Button, CardDropdown, Cards, DatePickerInput, DrawerLateral, FileSearchInput, Input, InputBase, DropdownInput, SearchInput, PasswordInput, TextInput, Layout, Modal, Navbar, Pagination, SearchContainer, setAlertDefaultDuration, show, SkeletonItem, StatusBar, Signature, Tab, Table, TitleContainer, TextMessageRN, ViewEtendo };
|
|
@@ -17,7 +17,7 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
|
17
17
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
18
18
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
19
19
|
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
20
|
-
import { View, TouchableOpacity, Text, SafeAreaView, Dimensions } from "react-native-web";
|
|
20
|
+
import { View, TouchableOpacity, Text, SafeAreaView, Dimensions, Platform } from "react-native-web";
|
|
21
21
|
import InputBase from "../InputBase";
|
|
22
22
|
|
|
23
23
|
// Import styles
|
|
@@ -33,6 +33,7 @@ import { Button } from "../../button";
|
|
|
33
33
|
import { SkeletonItem } from "../../secondaryComponents";
|
|
34
34
|
import { isWebPlatform } from "../../../helpers/functions_utils";
|
|
35
35
|
import { CheckCircleFillIcon, CornerDownRightIcon, PaperclipIcon, XIcon } from "../../../assets/images/icons";
|
|
36
|
+
import { AppPlatform } from "../../../helpers/utilsTypes";
|
|
36
37
|
import { KEY_ENTER, KEY_SHIFT } from "./FileSearchInput.constants";
|
|
37
38
|
|
|
38
39
|
// Import DocumentPicker for mobile platforms only
|
|
@@ -270,7 +271,6 @@ var FileSearchInput = function FileSearchInput(_ref) {
|
|
|
270
271
|
};
|
|
271
272
|
|
|
272
273
|
// Define the right buttons for the input
|
|
273
|
-
|
|
274
274
|
var UploadButton = /*#__PURE__*/React.createElement(Button, {
|
|
275
275
|
typeStyle: "white",
|
|
276
276
|
onPress: handleFileButtonClick,
|
|
@@ -493,8 +493,7 @@ var FileSearchInput = function FileSearchInput(_ref) {
|
|
|
493
493
|
return true;
|
|
494
494
|
},
|
|
495
495
|
style: [styles.fileContainer, {
|
|
496
|
-
top: modalPosition.top
|
|
497
|
-
width: modalPosition.width
|
|
496
|
+
top: Platform.OS === AppPlatform.web ? modalPosition.top : modalPosition.top - POSITION_UP_FILE
|
|
498
497
|
}]
|
|
499
498
|
}, /*#__PURE__*/React.createElement(View, {
|
|
500
499
|
style: styles.fileNameContainer
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { StyleSheet, Platform
|
|
1
|
+
import { StyleSheet, Platform } from "react-native-web";
|
|
2
2
|
import { NEUTRAL_100, NEUTRAL_1000, NEUTRAL_300, NEUTRAL_400, NEUTRAL_50 } from "../../../styles/colors";
|
|
3
3
|
import { isWebPlatform } from "../../../helpers/functions_utils";
|
|
4
|
-
var windowWidth = Dimensions.get('window').width;
|
|
5
4
|
export var mediaQueryWidths = {
|
|
6
5
|
MOBILE: 480,
|
|
7
6
|
TABLET: 768,
|
|
@@ -85,7 +84,8 @@ export var styles = StyleSheet.create({
|
|
|
85
84
|
width: 24
|
|
86
85
|
},
|
|
87
86
|
fileContainer: {
|
|
88
|
-
position: 'absolute'
|
|
87
|
+
position: 'absolute',
|
|
88
|
+
width: "100%"
|
|
89
89
|
},
|
|
90
90
|
progressBarFill: {
|
|
91
91
|
backgroundColor: NEUTRAL_100,
|
package/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ const {
|
|
|
36
36
|
Tab,
|
|
37
37
|
Table,
|
|
38
38
|
TitleContainer,
|
|
39
|
+
TextMessageRN,
|
|
39
40
|
ViewEtendo,
|
|
40
41
|
} = isNativeEnvironment ? NativeComponents : WebComponents;
|
|
41
42
|
|
|
@@ -361,6 +362,7 @@ export {
|
|
|
361
362
|
Tab,
|
|
362
363
|
Table,
|
|
363
364
|
TitleContainer,
|
|
365
|
+
TextMessageRN,
|
|
364
366
|
ViewEtendo,
|
|
365
367
|
ActivityIcon,
|
|
366
368
|
ArrowUpRightIcon,
|
package/index.js
CHANGED
|
@@ -36,6 +36,7 @@ const {
|
|
|
36
36
|
Tab,
|
|
37
37
|
Table,
|
|
38
38
|
TitleContainer,
|
|
39
|
+
TextMessageRN,
|
|
39
40
|
ViewEtendo,
|
|
40
41
|
} = isNativeEnvironment ? NativeComponents : WebComponents;
|
|
41
42
|
|
|
@@ -361,6 +362,7 @@ export {
|
|
|
361
362
|
Tab,
|
|
362
363
|
Table,
|
|
363
364
|
TitleContainer,
|
|
365
|
+
TextMessageRN,
|
|
364
366
|
ViewEtendo,
|
|
365
367
|
ActivityIcon,
|
|
366
368
|
ArrowUpRightIcon,
|