@synchat/webchat 0.0.1
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/README.md +77 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +26 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# React + TypeScript Component Library (tsup)
|
|
2
|
+
|
|
3
|
+
Starter para publicar um componente React no npm e consumir em outro projeto.
|
|
4
|
+
|
|
5
|
+
## Como usar este template
|
|
6
|
+
|
|
7
|
+
1. **Renomeie o pacote** em `package.json`:
|
|
8
|
+
- Para um pacote público com _scope_: `"name": "@seu-escopo/minha-lib"`
|
|
9
|
+
- O primeiro publish precisa de `--access public`
|
|
10
|
+
- Ou sem scope: `"name": "minha-lib"`
|
|
11
|
+
|
|
12
|
+
2. **Instale dependências**:
|
|
13
|
+
```bash
|
|
14
|
+
npm install
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
3. **Build**:
|
|
18
|
+
```bash
|
|
19
|
+
npm run build
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
4. **Publicar no npm**:
|
|
23
|
+
- Faça login (`npm login`).
|
|
24
|
+
- Se usar scope público: `npm publish --access public`
|
|
25
|
+
- Sem scope: `npm publish`
|
|
26
|
+
|
|
27
|
+
> Dica: mantenha `react` e `react-dom` como `peerDependencies` (já configurado).
|
|
28
|
+
> Isso evita múltiplas cópias do React no projeto consumidor.
|
|
29
|
+
|
|
30
|
+
## Estrutura
|
|
31
|
+
```
|
|
32
|
+
.
|
|
33
|
+
├─ src/
|
|
34
|
+
│ ├─ MyButton.tsx
|
|
35
|
+
│ └─ index.ts
|
|
36
|
+
├─ package.json
|
|
37
|
+
├─ tsconfig.json
|
|
38
|
+
├─ tsup.config.ts
|
|
39
|
+
├─ .gitignore
|
|
40
|
+
└─ .npmignore
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- Edite/adicione componentes em `src/` e reexporte em `src/index.ts`.
|
|
44
|
+
|
|
45
|
+
## Consumindo em outro projeto
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# em outro app (Vite, Next, CRA, etc.)
|
|
49
|
+
npm install minha-lib
|
|
50
|
+
# ou
|
|
51
|
+
npm install @seu-escopo/minha-lib
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
// Exemplo de uso
|
|
56
|
+
import { MyButton } from 'minha-lib'
|
|
57
|
+
|
|
58
|
+
export default function Page() {
|
|
59
|
+
return <MyButton onClick={() => alert('olá!')}>Enviar</MyButton>
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Versionamento
|
|
64
|
+
- Atualize `version` no `package.json` (ex.: `0.1.1`) antes de publicar novamente.
|
|
65
|
+
- Ou use `npm version patch|minor|major`.
|
|
66
|
+
|
|
67
|
+
## Teste local sem publicar (opcional)
|
|
68
|
+
- `npm pack` gera um `.tgz` local. No app consumidor: `npm install ../caminho/minha-lib-0.1.0.tgz`.
|
|
69
|
+
|
|
70
|
+
## Dicas de qualidade
|
|
71
|
+
- Adicione linters (`eslint`, `prettier`).
|
|
72
|
+
- Configure CI (GitHub Actions) e _release_ automatizado (semantic-release).
|
|
73
|
+
- Exporte CSS opcional com `style`/`files` ou mantenha apenas estilos inline/CSS-in-JS.
|
|
74
|
+
- Se for SSR/Next.js, prefira `exports` bem definidos (já incluso).
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
Feito com ❤️
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type MyButtonProps = {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
onClick?: () => void;
|
|
6
|
+
className?: string;
|
|
7
|
+
/** Desabilita o botão */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Um botão básico para exemplo da lib.
|
|
12
|
+
* Renderiza um <button> com estilos básicos inline (você pode trocar para CSS Modules/Tailwind/etc).
|
|
13
|
+
*/
|
|
14
|
+
declare const MyButton: React.FC<MyButtonProps>;
|
|
15
|
+
|
|
16
|
+
export { MyButton, type MyButtonProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type MyButtonProps = {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
onClick?: () => void;
|
|
6
|
+
className?: string;
|
|
7
|
+
/** Desabilita o botão */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Um botão básico para exemplo da lib.
|
|
12
|
+
* Renderiza um <button> com estilos básicos inline (você pode trocar para CSS Modules/Tailwind/etc).
|
|
13
|
+
*/
|
|
14
|
+
declare const MyButton: React.FC<MyButtonProps>;
|
|
15
|
+
|
|
16
|
+
export { MyButton, type MyButtonProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
|
|
5
|
+
// src/MyButton.tsx
|
|
6
|
+
var MyButton = ({ children = "Clique", onClick, className, disabled }) => {
|
|
7
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8
|
+
"button",
|
|
9
|
+
{
|
|
10
|
+
onClick,
|
|
11
|
+
disabled,
|
|
12
|
+
className,
|
|
13
|
+
style: {
|
|
14
|
+
padding: "8px 14px",
|
|
15
|
+
borderRadius: 8,
|
|
16
|
+
border: "1px solid #ddd",
|
|
17
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
18
|
+
background: disabled ? "#f2f2f2" : "#fff",
|
|
19
|
+
fontWeight: 600
|
|
20
|
+
},
|
|
21
|
+
children
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.MyButton = MyButton;
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/MyButton.tsx"],"names":["jsx"],"mappings":";;;;;AAcO,IAAM,QAAA,GAAoC,CAAC,EAAE,QAAA,GAAW,UAAU,OAAA,EAAS,SAAA,EAAW,UAAS,KAAM;AAC1G,EAAA,uBACEA,cAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,OAAA;AAAA,MACA,QAAA;AAAA,MACA,SAAA;AAAA,MACA,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,UAAA;AAAA,QACT,YAAA,EAAc,CAAA;AAAA,QACd,MAAA,EAAQ,gBAAA;AAAA,QACR,MAAA,EAAQ,WAAW,aAAA,GAAgB,SAAA;AAAA,QACnC,UAAA,EAAY,WAAW,SAAA,GAAY,MAAA;AAAA,QACnC,UAAA,EAAY;AAAA,OACd;AAAA,MAEC;AAAA;AAAA,GACH;AAEJ","file":"index.js","sourcesContent":["import * as React from 'react'\n\nexport type MyButtonProps = {\n children?: React.ReactNode\n onClick?: () => void\n className?: string\n /** Desabilita o botão */\n disabled?: boolean\n}\n\n/**\n * Um botão básico para exemplo da lib.\n * Renderiza um <button> com estilos básicos inline (você pode trocar para CSS Modules/Tailwind/etc).\n */\nexport const MyButton: React.FC<MyButtonProps> = ({ children = 'Clique', onClick, className, disabled }) => {\n return (\n <button\n onClick={onClick}\n disabled={disabled}\n className={className}\n style={{\n padding: '8px 14px',\n borderRadius: 8,\n border: '1px solid #ddd',\n cursor: disabled ? 'not-allowed' : 'pointer',\n background: disabled ? '#f2f2f2' : '#fff',\n fontWeight: 600\n }}\n >\n {children}\n </button>\n )\n}\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
// src/MyButton.tsx
|
|
4
|
+
var MyButton = ({ children = "Clique", onClick, className, disabled }) => {
|
|
5
|
+
return /* @__PURE__ */ jsx(
|
|
6
|
+
"button",
|
|
7
|
+
{
|
|
8
|
+
onClick,
|
|
9
|
+
disabled,
|
|
10
|
+
className,
|
|
11
|
+
style: {
|
|
12
|
+
padding: "8px 14px",
|
|
13
|
+
borderRadius: 8,
|
|
14
|
+
border: "1px solid #ddd",
|
|
15
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
16
|
+
background: disabled ? "#f2f2f2" : "#fff",
|
|
17
|
+
fontWeight: 600
|
|
18
|
+
},
|
|
19
|
+
children
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { MyButton };
|
|
25
|
+
//# sourceMappingURL=index.mjs.map
|
|
26
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/MyButton.tsx"],"names":[],"mappings":";;;AAcO,IAAM,QAAA,GAAoC,CAAC,EAAE,QAAA,GAAW,UAAU,OAAA,EAAS,SAAA,EAAW,UAAS,KAAM;AAC1G,EAAA,uBACE,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,OAAA;AAAA,MACA,QAAA;AAAA,MACA,SAAA;AAAA,MACA,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,UAAA;AAAA,QACT,YAAA,EAAc,CAAA;AAAA,QACd,MAAA,EAAQ,gBAAA;AAAA,QACR,MAAA,EAAQ,WAAW,aAAA,GAAgB,SAAA;AAAA,QACnC,UAAA,EAAY,WAAW,SAAA,GAAY,MAAA;AAAA,QACnC,UAAA,EAAY;AAAA,OACd;AAAA,MAEC;AAAA;AAAA,GACH;AAEJ","file":"index.mjs","sourcesContent":["import * as React from 'react'\n\nexport type MyButtonProps = {\n children?: React.ReactNode\n onClick?: () => void\n className?: string\n /** Desabilita o botão */\n disabled?: boolean\n}\n\n/**\n * Um botão básico para exemplo da lib.\n * Renderiza um <button> com estilos básicos inline (você pode trocar para CSS Modules/Tailwind/etc).\n */\nexport const MyButton: React.FC<MyButtonProps> = ({ children = 'Clique', onClick, className, disabled }) => {\n return (\n <button\n onClick={onClick}\n disabled={disabled}\n className={className}\n style={{\n padding: '8px 14px',\n borderRadius: 8,\n border: '1px solid #ddd',\n cursor: disabled ? 'not-allowed' : 'pointer',\n background: disabled ? '#f2f2f2' : '#fff',\n fontWeight: 600\n }}\n >\n {children}\n </button>\n )\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@synchat/webchat",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Starter de biblioteca de componentes React + TypeScript com tsup.",
|
|
5
|
+
"author": "synchat <contato@synchat.com.br>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.cjs",
|
|
8
|
+
"module": "dist/index.mjs",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/synchat-br/synchat-webchat"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"clean": "rimraf dist",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"prepublishOnly": "npm run build"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"react",
|
|
33
|
+
"typescript",
|
|
34
|
+
"component-library",
|
|
35
|
+
"tsup"
|
|
36
|
+
],
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"react": "19.2.0",
|
|
39
|
+
"react-dom": "19.2.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/react": "^18.3.0",
|
|
43
|
+
"@types/react-dom": "^18.3.0",
|
|
44
|
+
"tsup": "^8.0.1",
|
|
45
|
+
"typescript": "^5.6.0",
|
|
46
|
+
"rimraf": "^6.0.0"
|
|
47
|
+
}
|
|
48
|
+
}
|