tycho-components 0.15.8 → 0.15.10

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.
@@ -12,6 +12,7 @@ type Props = {
12
12
  title: string;
13
13
  action: () => void;
14
14
  };
15
+ disableConfirm?: boolean;
15
16
  };
16
- export default function AppDropzone({ folder, onClose, onSuccess, onError, accept, onDrop, keepName, title, alternativeButton, }: Props): import("react/jsx-runtime").JSX.Element;
17
+ export default function AppDropzone({ folder, onClose, onSuccess, onError, accept, onDrop, keepName, title, alternativeButton, disableConfirm, }: Props): import("react/jsx-runtime").JSX.Element;
17
18
  export {};
@@ -3,11 +3,11 @@ import { useRef } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import AppModal from '../AppModal';
5
5
  import AppDropzoneBody from './AppDropzoneBody';
6
- export default function AppDropzone({ folder, onClose, onSuccess, onError, accept, onDrop, keepName, title, alternativeButton, }) {
6
+ export default function AppDropzone({ folder, onClose, onSuccess, onError, accept, onDrop, keepName, title, alternativeButton, disableConfirm = false, }) {
7
7
  const { t } = useTranslation('upload');
8
8
  const bodyRef = useRef(null);
9
9
  const handleConfirm = () => {
10
10
  bodyRef.current?.upload();
11
11
  };
12
- return (_jsx(AppModal, { title: title || t('modal.title'), className: "modal-upload", close: onClose, confirm: handleConfirm, alternativeButton: alternativeButton, children: _jsx(AppDropzoneBody, { ref: bodyRef, folder: folder, onSuccess: onSuccess, onError: onError, accept: accept, onDrop: onDrop, keepName: keepName, showConfirmButton: false }) }));
12
+ return (_jsx(AppModal, { title: title || t('modal.title'), className: "modal-upload", close: onClose, confirm: handleConfirm, disableConfirm: disableConfirm, alternativeButton: alternativeButton, children: _jsx(AppDropzoneBody, { ref: bodyRef, folder: folder, onSuccess: onSuccess, onError: onError, accept: accept, onDrop: onDrop, keepName: keepName, showConfirmButton: false }) }));
13
13
  }
@@ -11,6 +11,8 @@ export type AppDropzoneBodyProps = {
11
11
  showConfirmButton?: boolean;
12
12
  /** When true, image preview is not rendered and filename message is shown instead */
13
13
  disablePreview?: boolean;
14
+ /** When true, confirm button is visible but disabled */
15
+ disableConfirm?: boolean;
14
16
  };
15
17
  export type AppDropzoneBodyRef = {
16
18
  upload: () => Promise<void>;
@@ -8,7 +8,7 @@ import { toastLoading } from '../configs/store/actions';
8
8
  import { useMessageUtils } from '../configs/useMessageUtils';
9
9
  import UploadService from './UploadService';
10
10
  import './style.scss';
11
- function AppDropzoneBodyInner({ folder, onSuccess, onError, accept, onDrop, keepName, showConfirmButton = true, disablePreview = false, }, ref) {
11
+ function AppDropzoneBodyInner({ folder, onSuccess, onError, accept, onDrop, keepName, showConfirmButton = true, disablePreview = false, disableConfirm = false, }, ref) {
12
12
  const { t } = useTranslation('upload');
13
13
  const { state, dispatch } = useContext(CommonContext);
14
14
  const { dispatchError } = useMessageUtils();
@@ -61,7 +61,10 @@ function AppDropzoneBodyInner({ folder, onSuccess, onError, accept, onDrop, keep
61
61
  setFile(files[0]);
62
62
  onDrop?.();
63
63
  };
64
- return (_jsxs("div", { className: "dropzone-container", children: [!file && (_jsx(Dropzone, { onDrop: (acceptedFiles) => handleDrop(acceptedFiles), accept: accept, maxFiles: 1, children: ({ getRootProps, getInputProps }) => (_jsxs("div", { ...getRootProps(), className: "dropzone", children: [_jsx("input", { ...getInputProps() }), _jsx("span", { children: t('label.dropzone') })] })) })), file && (_jsxs("div", { className: "uploaded-file", children: [preview && _jsx("img", { className: "preview", src: preview, alt: "" }), !preview && (_jsxs(_Fragment, { children: [_jsx("b", { children: t('label.uploaded.file') }), _jsx("span", { children: file.name })] })), showConfirmButton && (_jsx(Button, { onClick: upload, text: t('label.confirm'), size: "small", mode: "outlined" }))] }))] }));
64
+ const handleCancel = () => {
65
+ setFile(undefined);
66
+ };
67
+ return (_jsxs("div", { className: "dropzone-container", children: [!file && (_jsx(Dropzone, { onDrop: (acceptedFiles) => handleDrop(acceptedFiles), accept: accept, maxFiles: 1, children: ({ getRootProps, getInputProps }) => (_jsxs("div", { ...getRootProps(), className: "dropzone", children: [_jsx("input", { ...getInputProps() }), _jsx("span", { children: t('label.dropzone') })] })) })), file && (_jsxs("div", { className: "uploaded-file", children: [preview && _jsx("img", { className: "preview", src: preview, alt: "" }), !preview && (_jsxs(_Fragment, { children: [_jsx("b", { children: t('label.uploaded.file') }), _jsx("span", { children: file.name })] })), showConfirmButton && (_jsxs("div", { className: "buttons", children: [_jsx(Button, { onClick: handleCancel, text: t('common:button.cancel'), size: "small", mode: "outlined", color: "danger" }), _jsx(Button, { onClick: upload, text: t('label.confirm'), size: "small", mode: "outlined", disabled: disableConfirm })] }))] }))] }));
65
68
  }
66
69
  const AppDropzoneBody = forwardRef(AppDropzoneBodyInner);
67
70
  export default AppDropzoneBody;
@@ -27,10 +27,14 @@
27
27
  flex-direction: column;
28
28
  align-items: center;
29
29
  width: 100%;
30
- gap: 24px;
31
30
  text-align: center;
32
31
  border: 1px solid var(--border-subtle-3);
33
32
  border-radius: var(--radius-100);
34
33
  padding: 16px;
35
34
  }
35
+
36
+ .buttons {
37
+ display: flex;
38
+ gap: 16px;
39
+ }
36
40
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.15.8",
4
+ "version": "0.15.10",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {