pipesol-button 1.0.1-beta.7 → 1.0.1-beta.9

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.
@@ -1,78 +1,37 @@
1
1
  import React from 'react';
2
2
  /**
3
- * Propriedades do componente `NavigationButton`.
3
+ * Props para o componente DownloadButton
4
4
  */
5
- interface DownloadButtonProps {
6
- /**
7
- * **Arquivo a ser baixado**.
8
- *
9
- * - Pode ser um caminho relativo dentro do projeto (ex: `/arquivos/relatorio.pdf`),
10
- * que o navegador tratará como download automático.
11
- * - Pode ser uma URL absoluta/externa (ex: `https://exemplo.com/arquivo.zip`),
12
- * que será aberta em nova aba para que o usuário faça o download.
13
- */
5
+ export interface DownloadButtonProps {
6
+ /** URL do arquivo a ser baixado */
14
7
  file: string;
15
- /** Texto para acessibilidade (atributo `aria-label`). */
16
- aria_label: string;
17
- /** Cor de fundo padrão do botão (ex: `#1976d2` ou `transparent`). */
18
- background_color?: string;
19
- /** Cor de fundo quando o botão é focado/hover. Se não informado, usa a cor padrão. */
20
- background_color_hover?: string;
21
- /** Cor do texto padrão (ex: `#fff`). */
22
- color: string;
23
- /** Cor do texto no hover. Se não informado, usa a mesma cor padrão. */
24
- color_hover?: string;
25
- /**
26
- * Cor da borda (ex: `#1976d2`).
27
- * @default "transparent"
28
- */
29
- border_color?: string;
30
- /**
31
- * Raio de borda (ex: `8px`, `50%`).
32
- * @default "0"
33
- */
34
- border_radius?: string;
35
- /**
36
- * Sombra CSS (ex: `0 2px 4px rgba(0,0,0,0.2)`).
37
- * @default "none"
38
- */
39
- box_shadow?: string;
40
- /** Largura do botão (ex: `200px`, `100%`). */
41
- width: string;
42
- /**
43
- * Margem externa.
44
- * @default "0"
45
- */
46
- margin?: string;
47
- /**
48
- * Padding interno.
49
- * @default "8px 24px"
50
- */
51
- padding?: string;
52
- /** Conteúdo interno (texto ou elementos JSX). */
8
+ /** Nome do arquivo que será salvo */
9
+ fileName: string;
10
+ /** Cor de fundo padrão */
11
+ background?: string;
12
+ /** Cor de fundo no hover */
13
+ backgroundHover?: string;
14
+ /** Cor do texto padrão */
15
+ color?: string;
16
+ /** Cor do texto no hover */
17
+ colorHover?: string;
18
+ /** Raio da borda */
19
+ borderRadius?: string;
20
+ /** Sombra do botão */
21
+ boxShadow?: string;
22
+ /** Ícone opcional exibido à esquerda do texto */
23
+ icon?: React.ReactNode;
24
+ /** Texto do botão passado como children (deve ser um Typography) */
53
25
  children: React.ReactNode;
54
26
  }
55
27
  /**
56
- * Componente `DownloadButton`
28
+ * Botão de download customizável com suporte a ícone e texto centralizado.
29
+ * O texto deve ser passado via `Typography` como children.
57
30
  *
58
- * Botão estilizado para **download de arquivos**.
59
- * Cria um link em formato de botão que pode:
60
- * - Abrir o arquivo em nova aba (para URLs externas iniciando com `http`);
61
- * - Acionar o download direto de um arquivo local/relativo.
62
- *
63
- * Exemplo de uso:
64
- * ```tsx
65
- * <DownloadButton
66
- * file="/docs/manual.pdf"
67
- * aria_label="Baixar manual em PDF"
68
- * background_color="#1976d2"
69
- * color="#fff"
70
- * border_radius="8px"
71
- * width="200px"
72
- * >
73
- * Baixar Manual
74
- * </DownloadButton>
75
- * ```
31
+ * @default background="#1976d2"
32
+ * @default color="#fff"
33
+ * @default borderRadius="8px"
34
+ * @default boxShadow="none"
76
35
  */
77
36
  declare const DownloadButton: React.FC<DownloadButtonProps>;
78
37
  export default DownloadButton;
@@ -1,69 +1,44 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
2
  import { styled } from '@mui/material/styles';
4
- const ButtonStyled = styled('a', {
3
+ const StyledLink = styled('a', {
5
4
  shouldForwardProp: (prop) => ![
6
- 'background_color',
7
- 'background_color_hover',
5
+ 'background',
6
+ 'backgroundHover',
8
7
  'color',
9
- 'color_hover',
10
- 'padding',
11
- 'border_radius',
12
- 'border_color',
13
- 'color_hover',
14
- 'width',
15
- 'margin',
16
- 'boxshadow',
8
+ 'colorHover',
9
+ 'borderRadius',
10
+ 'boxShadow',
17
11
  ].includes(prop),
18
- })(({ background_color, background_color_hover, color, color_hover, padding, border_radius, border_color, width, margin, boxshadow, }) => ({
19
- width: width,
12
+ })(({ background, backgroundHover, color, colorHover, borderRadius, boxShadow }) => ({
13
+ display: 'inline-flex',
14
+ alignItems: 'center',
15
+ justifyContent: 'center',
16
+ gap: '8px',
17
+ background: background || '#1976d2',
18
+ color: color || '#fff',
19
+ borderRadius: borderRadius || '8px',
20
+ boxShadow: boxShadow || 'none',
21
+ padding: '8px 16px',
20
22
  cursor: 'pointer',
21
23
  textDecoration: 'none',
22
- textTransform: 'none',
23
- textAlign: 'center',
24
- boxShadow: boxshadow,
25
- backgroundColor: background_color,
26
- color: color,
27
- border: `1px solid ${border_color}`,
28
- borderRadius: border_radius,
29
- padding: padding,
30
- margin: margin,
24
+ transition: 'all 0.3s ease',
31
25
  '&:hover': {
32
- backgroundColor: background_color_hover,
33
- color: color_hover,
26
+ background: backgroundHover || '#1565c0',
27
+ color: colorHover || color || '#fff',
34
28
  },
35
29
  }));
36
30
  /**
37
- * Componente `DownloadButton`
31
+ * Botão de download customizável com suporte a ícone e texto centralizado.
32
+ * O texto deve ser passado via `Typography` como children.
38
33
  *
39
- * Botão estilizado para **download de arquivos**.
40
- * Cria um link em formato de botão que pode:
41
- * - Abrir o arquivo em nova aba (para URLs externas iniciando com `http`);
42
- * - Acionar o download direto de um arquivo local/relativo.
43
- *
44
- * Exemplo de uso:
45
- * ```tsx
46
- * <DownloadButton
47
- * file="/docs/manual.pdf"
48
- * aria_label="Baixar manual em PDF"
49
- * background_color="#1976d2"
50
- * color="#fff"
51
- * border_radius="8px"
52
- * width="200px"
53
- * >
54
- * Baixar Manual
55
- * </DownloadButton>
56
- * ```
34
+ * @default background="#1976d2"
35
+ * @default color="#fff"
36
+ * @default borderRadius="8px"
37
+ * @default boxShadow="none"
57
38
  */
58
- const DownloadButton = ({ file, aria_label, background_color, background_color_hover, color, color_hover, border_radius = '0', border_color = 'transparent', box_shadow = 'none', width, margin = '0', padding = '8px 24px', children, }) => {
59
- const backgroundColor = background_color !== null && background_color !== void 0 ? background_color : 'transparent';
60
- const backgroundColorHover = background_color_hover !== null && background_color_hover !== void 0 ? background_color_hover : backgroundColor;
61
- const colorHover = color_hover !== null && color_hover !== void 0 ? color_hover : color;
62
- // Se sua rota de download for algo como /api/files/[file]/download,
63
- // você pode ajustar aqui:
64
- const downloadHref = `${file}/download`;
65
- return (_jsx(ButtonStyled, { href: downloadHref, download // faz o navegador baixar ao invés de abrir, se suportado
66
- : true, width: width, background_color: backgroundColor, background_color_hover: backgroundColorHover, color: color, color_hover: colorHover, border_radius: border_radius, border_color: border_color, padding: padding, margin: margin, "aria-label": aria_label, boxshadow: box_shadow, children: children }));
39
+ const DownloadButton = ({ file, fileName, background, backgroundHover, color, colorHover, borderRadius, boxShadow, icon, children, }) => {
40
+ return (_jsxs(StyledLink, { href: file, download: fileName, background: background, backgroundHover: backgroundHover, color: color, colorHover: colorHover, borderRadius: borderRadius, boxShadow: boxShadow, children: [icon && _jsx("span", { children: icon }), children] }));
67
41
  };
42
+ DownloadButton.displayName = 'DownloadButton';
68
43
  export default DownloadButton;
69
44
  //# sourceMappingURL=DownloadButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DownloadButton.js","sourceRoot":"","sources":["../../src/components/DownloadButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,EAAE;IAC/B,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAC1B,CAAC;QACC,kBAAkB;QAClB,wBAAwB;QACxB,OAAO;QACP,aAAa;QACb,SAAS;QACT,eAAe;QACf,cAAc;QACd,aAAa;QACb,OAAO;QACP,QAAQ;QACR,WAAW;KACZ,CAAC,QAAQ,CAAC,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