maquinaweb-ui 1.0.0
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 +284 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# MaquinaWeb UI
|
|
2
|
+
|
|
3
|
+
A minimal React component library built with TypeScript, formatted with Biome, and powered by Bun.
|
|
4
|
+
|
|
5
|
+
## π Quick Start
|
|
6
|
+
|
|
7
|
+
### Prerequisites
|
|
8
|
+
|
|
9
|
+
- [Bun](https://bun.sh) installed on your system
|
|
10
|
+
|
|
11
|
+
### Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Install dependencies
|
|
15
|
+
bun install
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## π¦ Project Structure
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
maquinaweb-ui/
|
|
22
|
+
βββ src/
|
|
23
|
+
β βββ components/
|
|
24
|
+
β β βββ Button/
|
|
25
|
+
β β βββ Button.tsx # Component implementation
|
|
26
|
+
β β βββ Button.fixture.tsx # React Cosmos fixtures
|
|
27
|
+
β β βββ index.ts # Component exports
|
|
28
|
+
β βββ index.ts # Library entry point
|
|
29
|
+
βββ app/
|
|
30
|
+
β βββ layout.tsx # Next.js root layout
|
|
31
|
+
β βββ page.tsx # Next.js preview page
|
|
32
|
+
βββ dist/ # Build output (generated)
|
|
33
|
+
βββ package.json
|
|
34
|
+
βββ tsconfig.json
|
|
35
|
+
βββ biome.json
|
|
36
|
+
βββ tsup.config.ts
|
|
37
|
+
βββ cosmos.config.json
|
|
38
|
+
βββ next.config.ts
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## π οΈ Development
|
|
42
|
+
|
|
43
|
+
### Run Next.js Dev Server
|
|
44
|
+
|
|
45
|
+
Preview components in a Next.js environment:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
bun dev
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Open [http://localhost:3000](http://localhost:3000) to see the preview.
|
|
52
|
+
|
|
53
|
+
### Run React Cosmos
|
|
54
|
+
|
|
55
|
+
Develop components in isolation with React Cosmos. React Cosmos uses Next.js as a renderer, so you need both running:
|
|
56
|
+
|
|
57
|
+
**Terminal 1 - Start Next.js:**
|
|
58
|
+
```bash
|
|
59
|
+
bun dev
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Terminal 2 - Start Cosmos:**
|
|
63
|
+
```bash
|
|
64
|
+
bun cosmos
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Open [http://localhost:5000](http://localhost:5000) to see the Cosmos UI.
|
|
68
|
+
|
|
69
|
+
> **Note:** Cosmos connects to Next.js running at `http://localhost:3000/cosmos/` to render your fixtures.
|
|
70
|
+
|
|
71
|
+
### Linting & Formatting
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Check for issues
|
|
75
|
+
bun lint
|
|
76
|
+
|
|
77
|
+
# Fix issues automatically
|
|
78
|
+
bun lint:fix
|
|
79
|
+
|
|
80
|
+
# Format code
|
|
81
|
+
bun format
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## ποΈ Building
|
|
85
|
+
|
|
86
|
+
Build the library for publishing:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
bun build
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This will:
|
|
93
|
+
- Generate ESM bundles in the `dist/` directory
|
|
94
|
+
- Create TypeScript declaration files (`.d.ts`)
|
|
95
|
+
- Add source maps for debugging
|
|
96
|
+
|
|
97
|
+
## π Deploying to Vercel
|
|
98
|
+
|
|
99
|
+
You can deploy your Cosmos component documentation to Vercel with automatic configuration.
|
|
100
|
+
|
|
101
|
+
**Quick Start:**
|
|
102
|
+
1. Push your code to GitHub/GitLab/Bitbucket
|
|
103
|
+
2. Connect your repository at [vercel.com](https://vercel.com)
|
|
104
|
+
3. Click Deploy - it will use the pre-configured `vercel.json` settings
|
|
105
|
+
4. Your Cosmos documentation will be live! π
|
|
106
|
+
|
|
107
|
+
**Configuration is already set up:**
|
|
108
|
+
- β
Build Command: `bun run build:vercel`
|
|
109
|
+
- β
Output Directory: `cosmos-export`
|
|
110
|
+
- β
Install Command: `bun install`
|
|
111
|
+
|
|
112
|
+
**π For detailed instructions in Portuguese, see [DEPLOY_VERCEL.md](./DEPLOY_VERCEL.md)**
|
|
113
|
+
|
|
114
|
+
**Manual Build (optional):**
|
|
115
|
+
```bash
|
|
116
|
+
bun run build:vercel
|
|
117
|
+
```
|
|
118
|
+
This will build Next.js and export static Cosmos files to `cosmos-export/`.
|
|
119
|
+
|
|
120
|
+
## π€ Publishing
|
|
121
|
+
|
|
122
|
+
Este projeto usa **semantic-release** para automatizar versionamento e publicaΓ§Γ£o.
|
|
123
|
+
|
|
124
|
+
### π€ PublicaΓ§Γ£o AutomΓ‘tica (Recomendado)
|
|
125
|
+
|
|
126
|
+
O versionamento e publicaΓ§Γ£o sΓ£o **100% automΓ‘ticos** via GitHub Actions:
|
|
127
|
+
|
|
128
|
+
1. **Configure o NPM_TOKEN no GitHub:**
|
|
129
|
+
- Gere um token em [npmjs.com](https://www.npmjs.com/) β Settings β Access Tokens
|
|
130
|
+
- Adicione como secret `NPM_TOKEN` no repositΓ³rio GitHub
|
|
131
|
+
|
|
132
|
+
2. **Configure o `package.json` (jΓ‘ configurado):**
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"name": "maquinaweb-ui",
|
|
136
|
+
"author": "MaquinaWeb",
|
|
137
|
+
"repository": {
|
|
138
|
+
"type": "git",
|
|
139
|
+
"url": "https://github.com/maquinaweb/maquinaweb-ui.git"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
3. **FaΓ§a commits usando Conventional Commits:**
|
|
145
|
+
```bash
|
|
146
|
+
git commit -m "feat: adiciona novo componente" # β versΓ£o minor
|
|
147
|
+
git commit -m "fix: corrige bug no Button" # β versΓ£o patch
|
|
148
|
+
git commit -m "feat!: breaking change" # β versΓ£o major
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
4. **Push para main:**
|
|
152
|
+
```bash
|
|
153
|
+
git push origin main
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
O GitHub Actions automaticamente vai:
|
|
157
|
+
- β
Executar testes e build
|
|
158
|
+
- β
Determinar a nova versΓ£o
|
|
159
|
+
- β
Gerar/atualizar CHANGELOG.md
|
|
160
|
+
- β
Criar release no GitHub
|
|
161
|
+
- β
Publicar no npm
|
|
162
|
+
|
|
163
|
+
**π Para mais detalhes, veja [SEMANTIC_RELEASE.md](./SEMANTIC_RELEASE.md)**
|
|
164
|
+
|
|
165
|
+
### π§ PublicaΓ§Γ£o Manual (Opcional)
|
|
166
|
+
|
|
167
|
+
Se preferir publicar manualmente:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Login no npm
|
|
171
|
+
npm login
|
|
172
|
+
|
|
173
|
+
# Execute o semantic-release localmente
|
|
174
|
+
bunx semantic-release
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## π Adding New Components
|
|
178
|
+
|
|
179
|
+
1. Create a new component directory:
|
|
180
|
+
```bash
|
|
181
|
+
mkdir -p src/components/YourComponent
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
2. Create the component file:
|
|
185
|
+
```tsx
|
|
186
|
+
// src/components/YourComponent/YourComponent.tsx
|
|
187
|
+
export interface YourComponentProps {
|
|
188
|
+
// Your props
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function YourComponent(props: YourComponentProps) {
|
|
192
|
+
// Your implementation
|
|
193
|
+
return <div>Hello</div>;
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
3. Create an index file:
|
|
198
|
+
```tsx
|
|
199
|
+
// src/components/YourComponent/index.ts
|
|
200
|
+
export { YourComponent } from "./YourComponent";
|
|
201
|
+
export type { YourComponentProps } from "./YourComponent";
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
4. Create Cosmos fixtures:
|
|
205
|
+
```tsx
|
|
206
|
+
// src/components/YourComponent/YourComponent.fixture.tsx
|
|
207
|
+
import { YourComponent } from "./YourComponent";
|
|
208
|
+
|
|
209
|
+
export default {
|
|
210
|
+
"Default": <YourComponent />,
|
|
211
|
+
"Variant": <YourComponent variant="custom" />,
|
|
212
|
+
};
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
5. Export from the library entry point:
|
|
216
|
+
```tsx
|
|
217
|
+
// src/index.ts
|
|
218
|
+
export { YourComponent } from "./components/YourComponent";
|
|
219
|
+
export type { YourComponentProps } from "./components/YourComponent";
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## π§ Configuration Files
|
|
223
|
+
|
|
224
|
+
### `tsup.config.ts`
|
|
225
|
+
|
|
226
|
+
Handles the build process:
|
|
227
|
+
- Bundles TypeScript to ESM
|
|
228
|
+
- Generates type declarations
|
|
229
|
+
- Adds "use client" directive for Next.js compatibility
|
|
230
|
+
- Excludes React/React-DOM from bundle
|
|
231
|
+
|
|
232
|
+
### `cosmos.config.json`
|
|
233
|
+
|
|
234
|
+
Configures React Cosmos:
|
|
235
|
+
- Uses custom renderer URL to connect with Next.js
|
|
236
|
+
- Watches `src` directory for changes
|
|
237
|
+
- Static files served from `public` directory
|
|
238
|
+
|
|
239
|
+
### `biome.json`
|
|
240
|
+
|
|
241
|
+
Linting and formatting rules:
|
|
242
|
+
- 2-space indentation
|
|
243
|
+
- Double quotes
|
|
244
|
+
- Semicolons required
|
|
245
|
+
- 100 character line width
|
|
246
|
+
|
|
247
|
+
### `tsconfig.json`
|
|
248
|
+
|
|
249
|
+
TypeScript configuration:
|
|
250
|
+
- ESNext target for modern JavaScript
|
|
251
|
+
- Bundler module resolution
|
|
252
|
+
- Strict type checking enabled
|
|
253
|
+
- Next.js plugin support
|
|
254
|
+
|
|
255
|
+
## π Example Component Usage
|
|
256
|
+
|
|
257
|
+
After installing your published package:
|
|
258
|
+
|
|
259
|
+
```tsx
|
|
260
|
+
import { Button } from "maquinaweb-ui";
|
|
261
|
+
|
|
262
|
+
function App() {
|
|
263
|
+
return (
|
|
264
|
+
<div>
|
|
265
|
+
<Button variant="primary" size="medium">
|
|
266
|
+
Click me
|
|
267
|
+
</Button>
|
|
268
|
+
</div>
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## π€ Contributing
|
|
274
|
+
|
|
275
|
+
1. Create a new branch for your feature
|
|
276
|
+
2. Develop your component with Cosmos fixtures
|
|
277
|
+
3. Test in the Next.js preview environment
|
|
278
|
+
4. Run linting and formatting
|
|
279
|
+
5. Build to ensure no errors
|
|
280
|
+
6. Submit a pull request
|
|
281
|
+
|
|
282
|
+
## π License
|
|
283
|
+
|
|
284
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as react0 from "react";
|
|
2
|
+
import { ButtonHTMLAttributes, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/hello-world/Button.d.ts
|
|
5
|
+
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
6
|
+
/** The content of the button */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** The visual variant of the button */
|
|
9
|
+
variant?: "primary" | "secondary" | "outline";
|
|
10
|
+
/** The size of the button */
|
|
11
|
+
size?: "small" | "medium" | "large";
|
|
12
|
+
}
|
|
13
|
+
declare function Button({
|
|
14
|
+
children,
|
|
15
|
+
variant,
|
|
16
|
+
size,
|
|
17
|
+
className,
|
|
18
|
+
...props
|
|
19
|
+
}: ButtonProps): react0.JSX.Element;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { Button, type ButtonProps };
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/components/hello-world/Button.tsx"],"sourcesContent":[],"mappings":";;;;UAEiB,WAAA,SAAoB,qBAAqB;;YAE9C;EAFK;EAAY,OAAA,CAAA,EAAA,SAAA,GAAA,WAAA,GAAA,SAAA;;MAEjB,CAAA,EAAA,OAAA,GAAA,QAAA,GAAA,OAAA;;AAF6C,iBASzC,MAAA,CATyC;EAAA,QAAA;EAAA,OAAA;EAAA,IAAA;EAAA,SAAA;EAAA,GAAA;AAAA,CAAA,EAetD,WAfsD,CAAA,EAe3C,MAAA,CAAA,GAAA,CAAA,OAf2C"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/components/hello-world/Button.tsx
|
|
2
|
+
function Button({ children, variant = "primary", size = "medium", className = "",...props }) {
|
|
3
|
+
const combinedClassName = `inline-flex items-center justify-center font-medium rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none ${{
|
|
4
|
+
primary: "bg-blue-600 text-white hover:bg-blue-700 focus-visible:ring-blue-500",
|
|
5
|
+
secondary: "bg-gray-600 text-white hover:bg-gray-700 focus-visible:ring-gray-500",
|
|
6
|
+
outline: "border-2 border-blue-600 text-blue-600 hover:bg-blue-50 focus-visible:ring-blue-500"
|
|
7
|
+
}[variant]} ${{
|
|
8
|
+
small: "px-3 py-1.5 text-sm",
|
|
9
|
+
medium: "px-4 py-2 text-base",
|
|
10
|
+
large: "px-6 py-3 text-lg"
|
|
11
|
+
}[size]} ${className}`;
|
|
12
|
+
return <button type="button" className={combinedClassName} {...props}>
|
|
13
|
+
{children}
|
|
14
|
+
</button>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { Button };
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/components/hello-world/Button.tsx"],"sourcesContent":["import type { ButtonHTMLAttributes, ReactNode } from \"react\";\n\nexport interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n /** The content of the button */\n children: ReactNode;\n /** The visual variant of the button */\n variant?: \"primary\" | \"secondary\" | \"outline\";\n /** The size of the button */\n size?: \"small\" | \"medium\" | \"large\";\n}\n\nexport function Button({\n children,\n variant = \"primary\",\n size = \"medium\",\n className = \"\",\n ...props\n}: ButtonProps) {\n const baseStyles =\n \"inline-flex items-center justify-center font-medium rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none\";\n\n const variantStyles = {\n primary: \"bg-blue-600 text-white hover:bg-blue-700 focus-visible:ring-blue-500\",\n secondary: \"bg-gray-600 text-white hover:bg-gray-700 focus-visible:ring-gray-500\",\n outline: \"border-2 border-blue-600 text-blue-600 hover:bg-blue-50 focus-visible:ring-blue-500\",\n };\n\n const sizeStyles = {\n small: \"px-3 py-1.5 text-sm\",\n medium: \"px-4 py-2 text-base\",\n large: \"px-6 py-3 text-lg\",\n };\n\n const combinedClassName = `${baseStyles} ${variantStyles[variant]} ${sizeStyles[size]} ${className}`;\n\n return (\n <button type=\"button\" className={combinedClassName} {...props}>\n {children}\n </button>\n );\n}\n"],"mappings":";AAWA,SAAgB,OAAO,EACrB,UACA,UAAU,WACV,OAAO,UACP,YAAY,GACZ,GAAG,SACW;CAgBd,MAAM,oBAAoB,iNAZJ;EACpB,SAAS;EACT,WAAW;EACX,SAAS;EACV,CAQwD,SAAS,GAN/C;EACjB,OAAO;EACP,QAAQ;EACR,OAAO;EACR,CAE+E,MAAM,GAAG;AAEzF,QACE,CAAC,OAAO,cAAc,WAAW,uBAAuB,OAAO;OAC5D,SAAS;IACZ,EAAE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "maquinaweb-ui",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A minimal React component library",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "cosmos --expose-imports & next dev",
|
|
20
|
+
"build": "tsdown",
|
|
21
|
+
"build:vercel": "cosmos-export --expose-imports && next build && cp -R ./out/_next ./cosmos-export && cp -R ./out/cosmos ./cosmos-export",
|
|
22
|
+
"prepublishOnly": "bun run build",
|
|
23
|
+
"lint": "biome check .",
|
|
24
|
+
"lint:fix": "biome check --write .",
|
|
25
|
+
"format": "biome format --write ."
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react": "^18.0.0",
|
|
29
|
+
"react-dom": "^18.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@biomejs/biome": "^1.9.4",
|
|
33
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
34
|
+
"@semantic-release/git": "^10.0.1",
|
|
35
|
+
"@semantic-release/npm": "^12.0.2",
|
|
36
|
+
"@types/bun": "latest",
|
|
37
|
+
"@types/react": "^18.3.12",
|
|
38
|
+
"@types/react-dom": "^18.3.1",
|
|
39
|
+
"next": "^15.1.0",
|
|
40
|
+
"react": "^18.3.1",
|
|
41
|
+
"react-cosmos": "^6.2.0",
|
|
42
|
+
"react-cosmos-next": "^6.2.0",
|
|
43
|
+
"react-cosmos-plugin-open-fixture": "^7.0.0",
|
|
44
|
+
"react-dom": "^18.3.1",
|
|
45
|
+
"semantic-release": "^24.2.9",
|
|
46
|
+
"tsdown": "^0.15.6",
|
|
47
|
+
"typescript": "^5.7.2"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"react",
|
|
51
|
+
"component-library",
|
|
52
|
+
"ui",
|
|
53
|
+
"typescript"
|
|
54
|
+
],
|
|
55
|
+
"author": "MaquinaWeb",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "https://github.com/maquinaweb/maquinaweb-ui.git"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
},
|
|
64
|
+
"packageManager": "pnpm@10.15.1+sha512.34e538c329b5553014ca8e8f4535997f96180a1d0f614339357449935350d924e22f8614682191264ec33d1462ac21561aff97f6bb18065351c162c7e8f6de67"
|
|
65
|
+
}
|