@s_mart/dropzone 0.0.0-font-awesome-20240308181754
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/index.d.ts +49 -0
- package/dist/index.mjs +27 -0
- package/package.json +49 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { FileValidated } from '@dropzone-ui/react';
|
|
3
|
+
import { DropzoneProps as DropzoneProps$1 } from '@dropzone-ui/react/build/components/dropzone/components/Dropzone/DropzoneProps';
|
|
4
|
+
import { FileItemProps } from '@dropzone-ui/react/build/components/file-item/components/FileItem/FileItemProps';
|
|
5
|
+
|
|
6
|
+
interface DropzoneProps extends Omit<DropzoneProps$1, 'children' | 'onReset' | 'onClean'> {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* @description Prop responsável por exibir o botão de deletar todos os arquivos no canto superior direito do dropzone
|
|
10
|
+
* @default true
|
|
11
|
+
* @type boolean
|
|
12
|
+
*/
|
|
13
|
+
showDeleteAllFilesButton?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* @description Texto que é renderizado no centro do dropzone quando não há arquivos selecionados
|
|
16
|
+
* @default "Arraste os arquivos aqui ou clique para selecionar"
|
|
17
|
+
*/
|
|
18
|
+
placeholder?: React.ReactNode | string;
|
|
19
|
+
/**
|
|
20
|
+
* @description Props que são passadas para o componente FileItem do dropzone
|
|
21
|
+
* @default {}
|
|
22
|
+
*/
|
|
23
|
+
fileItemProps?: FileItemProps;
|
|
24
|
+
/**
|
|
25
|
+
* @description Valor inicial do state que armazena os arquivos selecionados no dropzone
|
|
26
|
+
* @default []
|
|
27
|
+
* @type FileValidated[]
|
|
28
|
+
**/
|
|
29
|
+
initialValue?: DropzoneFile[];
|
|
30
|
+
/**
|
|
31
|
+
* @description Função que é chamada quando o usuário clica no botão de deletar um arquivo
|
|
32
|
+
* @param files Lista de arquivos que restaram no dropzone
|
|
33
|
+
*/
|
|
34
|
+
onClean?: (files: DropzoneFile[]) => void;
|
|
35
|
+
/**
|
|
36
|
+
* @description Função que é chamada quando o usuário clica no botão de deletar todos os arquivos
|
|
37
|
+
*/
|
|
38
|
+
onReset?: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* @description Função que é chamada dentro do OnChange para caso necessário fazer um tratamento nos files
|
|
41
|
+
*/
|
|
42
|
+
tratamentoFilesOnChange?: (incomingFiles: FileValidated[]) => Promise<FileValidated[]> | FileValidated[];
|
|
43
|
+
}
|
|
44
|
+
interface DropzoneFile extends FileValidated {
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare const Dropzone: ({ showDeleteAllFilesButton, placeholder, fileItemProps, initialValue, onClean, onReset, tratamentoFilesOnChange, ...rest }: DropzoneProps) => react_jsx_runtime.JSX.Element;
|
|
48
|
+
|
|
49
|
+
export { Dropzone, DropzoneFile, DropzoneProps };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import P,{useEffect as T}from"react";import{Dropzone as b,FileItem as A}from"@dropzone-ui/react";import{Typography as q}from"@s_mart/core";import{LIcon as w,Tooltip as N}from"@s_mart/core";import{lineTimes as k}from"@s_mart/regular-icons";import x from"@emotion/styled";import{colorPalette as c}from"@s_mart/tokens";var m=x.button`
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
|
|
6
|
+
position: absolute;
|
|
7
|
+
top: 12px;
|
|
8
|
+
right: 12px;
|
|
9
|
+
|
|
10
|
+
width: 24px;
|
|
11
|
+
height: 24px;
|
|
12
|
+
|
|
13
|
+
padding: 4px;
|
|
14
|
+
border: none;
|
|
15
|
+
border-radius: 50%;
|
|
16
|
+
background-color: transparent;
|
|
17
|
+
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
transition: all 0.3s ease;
|
|
20
|
+
|
|
21
|
+
color: ${c.neutral[500]};
|
|
22
|
+
|
|
23
|
+
&:hover {
|
|
24
|
+
background-color: ${c.neutral[40]};
|
|
25
|
+
transition: all 0.3s ease;
|
|
26
|
+
}
|
|
27
|
+
`;import{useNotification as B}from"@s_mart/hooks";import{Fragment as U,jsx as t,jsxs as _}from"react/jsx-runtime";var I=({showDeleteAllFilesButton:u=!0,placeholder:h,fileItemProps:D,initialValue:n=[],onClean:v,onReset:g,tratamentoFilesOnChange:p,...f})=>{let{setNotification:d}=B(),[l,a]=P.useState(n),z=e=>{let o=e.filter(i=>i.valid===!0);a(o);let r={variant:"warning",autoHideDuration:5e3};if(e.length>0){let i=e.filter(s=>s.valid===!1);i.length===1?d({...r,title:`Arquivo ${i[0].file.name} inv\xE1lido`,message:i[0].errors?.[0]}):i.length>1&&i.forEach(s=>{d({...r,title:`Arquivo ${s.file.name} inv\xE1lido`,message:s.errors?.[0]})})}},y=()=>{a([]),g?.()},F=e=>{let o=l.filter(r=>r.id!==e.id);a(o),v?.(o)};return T(()=>{n.length&&a(n)},[n]),t(b,{localization:"PT-pt",header:!1,footer:!1,headerClassName:"header",view:"grid",value:l,...f,onChange:async e=>{let o=e;if(p){let r=await p(e);r&&(o=r)}z(o),f.onChange?.(o)},children:l.length===0?t("div",{children:h||"Arraste os arquivos aqui ou clique para selecionar"}):_(U,{children:[u&&t(N,{title:t(q,{variant:"bodyMD",children:"Remover"}),children:t(m,{onClick:e=>{e.preventDefault(),e.stopPropagation(),y()},children:t(w,{icon:k,size:"24px"})})}),t("div",{style:{display:"flex"},children:l?.map(e=>t(A,{info:!0,localization:"PT-pt",preview:!0,...e,...D,onDelete:()=>F(e)},e.id))})]})})};export{I as Dropzone};
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@s_mart/dropzone",
|
|
3
|
+
"version": "0.0.0-font-awesome-20240308181754",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"module": "./dist/index.mjs",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/**"
|
|
11
|
+
],
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@dropzone-ui/react": "^6.7.20",
|
|
14
|
+
"tsup": "^6.7.0",
|
|
15
|
+
"@types/react": ">=18.2.21",
|
|
16
|
+
"@types/react-dom": ">=18.2.4",
|
|
17
|
+
"typescript": "^5.2.2",
|
|
18
|
+
"@s_mart/core": "0.0.0-font-awesome-20240308181754",
|
|
19
|
+
"@s_mart/hooks": "0.0.0-font-awesome-20240308181754",
|
|
20
|
+
"@s_mart/regular-icons": "0.0.0-font-awesome-20240308181754",
|
|
21
|
+
"eslint-config-smarten": "4.0.1",
|
|
22
|
+
"@s_mart/tokens": "0.0.0-font-awesome-20240308181754",
|
|
23
|
+
"@s_mart/typed": "0.0.0-font-awesome-20240308181754",
|
|
24
|
+
"@s_mart/tsconfig": "0.0.0-font-awesome-20240308181754"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@emotion/react": ">=11.10.8",
|
|
28
|
+
"@emotion/styled": ">=11.10.8",
|
|
29
|
+
"@types/react": ">=18.2.21",
|
|
30
|
+
"@types/react-dom": ">=18.2.4",
|
|
31
|
+
"axios": ">=1.3.3",
|
|
32
|
+
"react": ">=18.2.0",
|
|
33
|
+
"react-dom": ">=18.2.0",
|
|
34
|
+
"typescript": ">=5.2.2",
|
|
35
|
+
"@s_mart/core": "0.0.0-font-awesome-20240308181754",
|
|
36
|
+
"@s_mart/hooks": "0.0.0-font-awesome-20240308181754",
|
|
37
|
+
"@s_mart/regular-icons": "0.0.0-font-awesome-20240308181754",
|
|
38
|
+
"@s_mart/tokens": "0.0.0-font-awesome-20240308181754",
|
|
39
|
+
"@s_mart/typed": "0.0.0-font-awesome-20240308181754"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"eslint": "^8.47.0"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsup src/index.tsx --minify --format esm --dts --external react",
|
|
46
|
+
"dev": "tsup src/index.tsx --format esm --watch --dts --external react",
|
|
47
|
+
"lint": "eslint src/**/*.ts* --fix"
|
|
48
|
+
}
|
|
49
|
+
}
|