veiwer on event should return

This commit is contained in:
arpitnath 2023-11-06 19:11:11 +05:30
parent ea70a53f3c
commit 5fccede5a2
2 changed files with 11 additions and 5 deletions

View file

@ -4,6 +4,7 @@ import { resolveWidgetFieldValue } from '@/_helpers/utils';
import { toast } from 'react-hot-toast';
import * as XLSX from 'xlsx/xlsx.mjs';
import { useCurrentState } from '@/_stores/currentStateStore';
import { useAppInfo } from '@/_stores/appDataStore';
export const FilePicker = ({
id,
@ -54,6 +55,10 @@ export const FilePicker = ({
const parsedWidgetVisibility =
typeof widgetVisibility !== 'boolean' ? resolveWidgetFieldValue(widgetVisibility, currentState) : widgetVisibility;
const { events: allAppEvents } = useAppInfo();
const filePickerEvents = allAppEvents.filter((event) => event.target === 'component' && event.sourceId === id);
const bgThemeColor = darkMode ? '#232E3C' : '#fff';
const baseStyle = {
@ -235,7 +240,7 @@ export const FilePicker = ({
onComponentOptionChanged(component, 'file', [], id);
}
if (acceptedFiles.length !== 0) {
if (acceptedFiles.length !== 0 && onEvent) {
const fileData = parsedEnableMultiple ? [...selectedFiles] : [];
if (parseContent) {
onComponentOptionChanged(component, 'isParsing', true, id);
@ -250,7 +255,8 @@ export const FilePicker = ({
});
setSelectedFiles(fileData);
onComponentOptionChanged(component, 'file', fileData, id);
onEvent('onFileSelected', { component })
onEvent('onFileSelected', filePickerEvents, { component })
.then(() => {
setAccepted(true);
// eslint-disable-next-line no-unused-vars
@ -263,7 +269,7 @@ export const FilePicker = ({
}, 600);
});
})
.then(() => onEvent('onFileLoaded', { component }));
.then(() => onEvent('onFileLoaded', filePickerEvents, { component }));
}
if (fileRejections.length > 0) {
@ -286,7 +292,7 @@ export const FilePicker = ({
copy.splice(index, 1);
return copy;
});
onEvent('onFileDeselected', { component });
onEvent('onFileDeselected', filePickerEvents);
};
useEffect(() => {

View file

@ -506,7 +506,7 @@ class ViewerComponent extends React.Component {
};
handleEvent = (eventName, events, options) => {
onEvent(this.getViewerRef(), eventName, events, options, 'view');
return onEvent(this.getViewerRef(), eventName, events, options, 'view');
};
computeCanvasMaxWidth = () => {