@nlabs/lex 1.49.5 → 1.50.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/.swcrc +35 -0
- package/README.md +43 -59
- package/config.json +32 -8
- package/examples/lex.config.js +110 -10
- package/lex.config.js +34 -7
- package/lib/Button.stories.js +99 -0
- package/lib/LexConfig.d.ts +60 -22
- package/lib/LexConfig.js +285 -244
- package/lib/commands/ai/ai.js +287 -288
- package/lib/commands/ai/index.js +8 -7
- package/lib/commands/build/build.d.ts +2 -2
- package/lib/commands/build/build.js +349 -458
- package/lib/commands/clean/clean.js +45 -33
- package/lib/commands/compile/compile.js +214 -228
- package/lib/commands/config/config.js +46 -42
- package/lib/commands/copy/copy.js +36 -35
- package/lib/commands/create/create.js +200 -121
- package/lib/commands/dev/dev.d.ts +1 -0
- package/lib/commands/dev/dev.js +261 -259
- package/lib/commands/init/init.js +108 -88
- package/lib/commands/link/link.js +18 -14
- package/lib/commands/lint/lint.js +735 -742
- package/lib/commands/migrate/migrate.js +49 -36
- package/lib/commands/publish/publish.js +116 -96
- package/lib/commands/serverless/serverless.js +611 -585
- package/lib/commands/storybook/storybook.js +242 -238
- package/lib/commands/test/test.js +381 -409
- package/lib/commands/update/update.js +141 -120
- package/lib/commands/upgrade/upgrade.js +51 -44
- package/lib/commands/versions/versions.d.ts +1 -1
- package/lib/commands/versions/versions.js +36 -38
- package/lib/create/changelog.js +136 -125
- package/lib/index.js +40 -38
- package/lib/lex.js +95 -68
- package/lib/storybook/index.js +6 -1
- package/lib/test-react/index.js +7 -84
- package/lib/types.d.ts +1 -1
- package/lib/types.js +7 -1
- package/lib/utils/aiService.js +240 -227
- package/lib/utils/app.js +274 -273
- package/lib/utils/deepMerge.js +37 -23
- package/lib/utils/file.js +218 -215
- package/lib/utils/log.js +29 -27
- package/lib/utils/reactShim.js +7 -85
- package/lib/utils/translations.js +92 -82
- package/package.json +59 -60
- package/templates/typescript/DataLayer.js.txt +218 -0
- package/templates/typescript/DataLayer.test.js.txt +268 -0
- package/templates/typescript/DataLayer.test.ts.txt +269 -0
- package/templates/typescript/DataLayer.ts.txt +227 -0
- package/webpack.config.js +38 -28
- package/lib/commands/lint/autofix.d.ts +0 -2
package/.swcrc
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsc": {
|
|
3
|
+
"parser": {
|
|
4
|
+
"syntax": "typescript",
|
|
5
|
+
"tsx": true,
|
|
6
|
+
"decorators": true,
|
|
7
|
+
"dynamicImport": true
|
|
8
|
+
},
|
|
9
|
+
"target": "es2020",
|
|
10
|
+
"transform": {
|
|
11
|
+
"react": {
|
|
12
|
+
"runtime": "automatic"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"externalHelpers": false,
|
|
16
|
+
"keepClassNames": false,
|
|
17
|
+
"loose": false
|
|
18
|
+
},
|
|
19
|
+
"module": {
|
|
20
|
+
"type": "es6",
|
|
21
|
+
"strict": false,
|
|
22
|
+
"strictMode": true,
|
|
23
|
+
"lazy": false,
|
|
24
|
+
"noInterop": false
|
|
25
|
+
},
|
|
26
|
+
"minify": false,
|
|
27
|
+
"sourceMaps": "inline",
|
|
28
|
+
"inlineSourcesContent": true,
|
|
29
|
+
"isModule": true
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Lex is the all-in-one development CLI that eliminates the complexity of modern R
|
|
|
22
22
|
|
|
23
23
|
### ⚡ **Lightning Fast**
|
|
24
24
|
|
|
25
|
-
-
|
|
25
|
+
- SWC-powered compilation (10-100x faster than Babel)
|
|
26
26
|
- Hot reloading development server
|
|
27
27
|
- Optimized production builds
|
|
28
28
|
- Parallel test execution
|
|
@@ -69,7 +69,7 @@ Lex comes with everything you need for modern React development:
|
|
|
69
69
|
|
|
70
70
|
| Tool | Purpose | Version |
|
|
71
71
|
|------|---------|---------|
|
|
72
|
-
| **
|
|
72
|
+
| **SWC** | Lightning-fast TypeScript/JavaScript compiler | Latest |
|
|
73
73
|
| **Jest** | Testing framework | Latest |
|
|
74
74
|
| **TypeScript** | Type safety | Latest |
|
|
75
75
|
| **Webpack** | Advanced bundling | Latest |
|
|
@@ -152,7 +152,7 @@ lex dev --usePublicIp
|
|
|
152
152
|
|
|
153
153
|
**📁 Static Assets**: If your HTML template references static assets (like favicon.ico, manifest.json, or images) with absolute paths, ensure these files exist in your source directory or use relative paths to avoid webpack compilation errors.
|
|
154
154
|
|
|
155
|
-
**🎨
|
|
155
|
+
**🎨 Static Assets**: Use the `webpack.staticPath` configuration to specify a directory for static assets (images, videos, audio, PDFs, etc.). Files in this directory will be automatically copied to the output and optimized for web delivery.
|
|
156
156
|
|
|
157
157
|
### 🚀 **Serverless Development Server** {#serverless}
|
|
158
158
|
|
|
@@ -182,8 +182,8 @@ lex serverless --debug --printOutput
|
|
|
182
182
|
# Standard production build
|
|
183
183
|
lex build --mode production
|
|
184
184
|
|
|
185
|
-
# With
|
|
186
|
-
lex build --bundler
|
|
185
|
+
# With SWC (faster)
|
|
186
|
+
lex build --bundler swc
|
|
187
187
|
|
|
188
188
|
# With AI optimization analysis
|
|
189
189
|
lex build --analyze
|
|
@@ -259,7 +259,7 @@ Lex works seamlessly with popular React frameworks and libraries:
|
|
|
259
259
|
|
|
260
260
|
Lex is designed for speed and efficiency:
|
|
261
261
|
|
|
262
|
-
- **⚡
|
|
262
|
+
- **⚡ SWC Integration** - 10-100x faster than Babel, faster than esbuild
|
|
263
263
|
- **🧠 Smart Caching** - Intelligent caching for faster rebuilds
|
|
264
264
|
- **🔄 Hot Reloading** - Instant feedback during development
|
|
265
265
|
- **📦 Tree Shaking** - Automatic dead code elimination
|
|
@@ -285,12 +285,8 @@ export default {
|
|
|
285
285
|
model: 'gpt-4'
|
|
286
286
|
},
|
|
287
287
|
|
|
288
|
-
//
|
|
289
|
-
|
|
290
|
-
minify: true,
|
|
291
|
-
sourcemap: true,
|
|
292
|
-
target: 'es2020'
|
|
293
|
-
},
|
|
288
|
+
// SWC configuration (defaults to ESM format)
|
|
289
|
+
// SWC is now the default transpiler for all compilation tasks
|
|
294
290
|
|
|
295
291
|
// Jest configuration (merged with Lex defaults)
|
|
296
292
|
jest: {
|
|
@@ -335,27 +331,26 @@ Lex provides extensive configuration options through the `lex.config.js` file. H
|
|
|
335
331
|
| `ai.provider` | `'cursor' \| 'copilot' \| 'openai' \| 'anthropic' \| 'none'` | `'none'` | AI service provider | `ai: { provider: 'openai' }` |
|
|
336
332
|
| `ai.temperature` | `number` | `0.1` | AI response creativity (0-1) | `ai: { temperature: 0.7 }` |
|
|
337
333
|
|
|
338
|
-
### ⚡ **
|
|
334
|
+
### ⚡ **SWC Configuration**
|
|
339
335
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
|
352
|
-
|
|
353
|
-
|
|
|
354
|
-
|
|
|
355
|
-
|
|
|
356
|
-
|
|
|
357
|
-
|
|
|
358
|
-
| `esbuild.treeShaking` | `boolean` | `true` | Enable tree shaking | `esbuild: { treeShaking: false }` |
|
|
336
|
+
SWC (Speedy Web Compiler) is now the default transpiler for all TypeScript and JavaScript compilation in Lex. SWC provides:
|
|
337
|
+
|
|
338
|
+
- **10-100x faster** compilation than Babel
|
|
339
|
+
- **Faster than esbuild** for TypeScript compilation
|
|
340
|
+
- **Zero configuration** - works out of the box
|
|
341
|
+
- **ESM by default** - modern module format
|
|
342
|
+
- **Automatic React JSX** transformation
|
|
343
|
+
- **TypeScript decorators** support
|
|
344
|
+
|
|
345
|
+
SWC is automatically configured and doesn't require additional configuration in most cases. The default settings provide optimal performance and compatibility.
|
|
346
|
+
|
|
347
|
+
| Feature | Description | Default |
|
|
348
|
+
|---------|-------------|---------|
|
|
349
|
+
| **Output Format** | JavaScript module format | `esm` |
|
|
350
|
+
| **Target** | JavaScript target version | `es2020` |
|
|
351
|
+
| **JSX Runtime** | React JSX transformation | `automatic` |
|
|
352
|
+
| **Decorators** | TypeScript decorators support | `enabled` |
|
|
353
|
+
| **Source Maps** | Debug information | `inline` |
|
|
359
354
|
|
|
360
355
|
### 🧪 **Jest Configuration**
|
|
361
356
|
|
|
@@ -384,7 +379,7 @@ Lex provides extensive configuration options through the `lex.config.js` file. H
|
|
|
384
379
|
| `webpack.module` | `object` | `undefined` | Webpack module configuration | `webpack: { module: { rules: [...] } }` |
|
|
385
380
|
| `webpack.output` | `object` | `undefined` | Webpack output configuration | `webpack: { output: { filename: 'bundle.js' } }` |
|
|
386
381
|
| `webpack.plugins` | `unknown[]` | `undefined` | Webpack plugins | `webpack: { plugins: [new MyPlugin()] }` |
|
|
387
|
-
| `webpack.
|
|
382
|
+
| `webpack.staticPath` | `string` | `'./src/static'` | Path to static assets directory. Files in this directory will be copied to the output and optimized (images/videos compressed, audio optimized) | `webpack: { staticPath: './assets' }` |
|
|
388
383
|
|
|
389
384
|
### 🔗 **Library Configuration**
|
|
390
385
|
|
|
@@ -424,12 +419,8 @@ export default {
|
|
|
424
419
|
preset: 'node',
|
|
425
420
|
targetEnvironment: 'node',
|
|
426
421
|
libraryName: 'MyLibrary',
|
|
427
|
-
libraryTarget: 'umd'
|
|
428
|
-
|
|
429
|
-
format: 'cjs',
|
|
430
|
-
platform: 'node',
|
|
431
|
-
external: ['lodash']
|
|
432
|
-
}
|
|
422
|
+
libraryTarget: 'umd'
|
|
423
|
+
// SWC automatically handles Node.js compilation with optimal settings
|
|
433
424
|
};
|
|
434
425
|
```
|
|
435
426
|
|
|
@@ -452,26 +443,19 @@ export default {
|
|
|
452
443
|
};
|
|
453
444
|
```
|
|
454
445
|
|
|
455
|
-
#### Advanced
|
|
446
|
+
#### Advanced SWC Configuration
|
|
456
447
|
|
|
457
448
|
```javascript
|
|
458
449
|
export default {
|
|
459
450
|
useTypescript: true,
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
'process.env.NODE_ENV': '"production"',
|
|
469
|
-
'global': 'globalThis'
|
|
470
|
-
},
|
|
471
|
-
banner: {
|
|
472
|
-
js: '// My Awesome Library v1.0.0'
|
|
473
|
-
}
|
|
474
|
-
}
|
|
451
|
+
// SWC provides optimal defaults for all compilation tasks
|
|
452
|
+
// No additional configuration needed for most use cases
|
|
453
|
+
// SWC automatically handles:
|
|
454
|
+
// - ESM output format (default)
|
|
455
|
+
// - ES2020 target
|
|
456
|
+
// - React JSX transformation
|
|
457
|
+
// - TypeScript decorators
|
|
458
|
+
// - Source map generation
|
|
475
459
|
};
|
|
476
460
|
```
|
|
477
461
|
|
|
@@ -490,13 +474,13 @@ If you see a 404 error with a message like "Static Paths /path/to/lib", this is
|
|
|
490
474
|
|
|
491
475
|
#### Port Already in Use
|
|
492
476
|
|
|
493
|
-
If you get an "address already in use" error, another process is using the default port (
|
|
477
|
+
If you get an "address already in use" error, another process is using the default port (3000).
|
|
494
478
|
|
|
495
479
|
**Solution**: Kill the existing process or use a different port:
|
|
496
480
|
|
|
497
481
|
```bash
|
|
498
|
-
# Kill processes on port
|
|
499
|
-
lsof -ti:
|
|
482
|
+
# Kill processes on port 3000
|
|
483
|
+
lsof -ti:3000 | xargs kill -9
|
|
500
484
|
|
|
501
485
|
# Or use a different port
|
|
502
486
|
lex dev --port 3000
|
|
@@ -583,7 +567,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
583
567
|
|
|
584
568
|
## 🙏 Acknowledgments
|
|
585
569
|
|
|
586
|
-
- **
|
|
570
|
+
- **SWC** - For lightning-fast TypeScript/JavaScript compilation
|
|
587
571
|
- **Jest** - For comprehensive testing
|
|
588
572
|
- **TypeScript** - For type safety
|
|
589
573
|
- **Webpack** - For advanced bundling features
|
package/config.json
CHANGED
|
@@ -11,15 +11,39 @@
|
|
|
11
11
|
"maxTokens": 4000,
|
|
12
12
|
"temperature": 0.1
|
|
13
13
|
},
|
|
14
|
-
"
|
|
14
|
+
"swc": {
|
|
15
|
+
"jsc": {
|
|
16
|
+
"parser": {
|
|
17
|
+
"syntax": "typescript",
|
|
18
|
+
"tsx": true,
|
|
19
|
+
"decorators": true,
|
|
20
|
+
"dynamicImport": true
|
|
21
|
+
},
|
|
22
|
+
"target": "es2020",
|
|
23
|
+
"transform": {
|
|
24
|
+
"react": {
|
|
25
|
+
"runtime": "automatic"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"externalHelpers": false,
|
|
29
|
+
"keepClassNames": false,
|
|
30
|
+
"loose": false,
|
|
31
|
+
"minify": {
|
|
32
|
+
"compress": true,
|
|
33
|
+
"mangle": true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"module": {
|
|
37
|
+
"type": "es6",
|
|
38
|
+
"strict": false,
|
|
39
|
+
"strictMode": true,
|
|
40
|
+
"lazy": false,
|
|
41
|
+
"noInterop": false
|
|
42
|
+
},
|
|
15
43
|
"minify": true,
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"legalComments": "none",
|
|
20
|
-
"splitting": true,
|
|
21
|
-
"metafile": false,
|
|
22
|
-
"sourcemap": false
|
|
44
|
+
"sourceMaps": false,
|
|
45
|
+
"inlineSourcesContent": true,
|
|
46
|
+
"isModule": true
|
|
23
47
|
},
|
|
24
48
|
"webpack": {},
|
|
25
49
|
"jest": {},
|
package/examples/lex.config.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Lex configuration file
|
|
3
3
|
* This file contains configuration options for the Lex CLI tool
|
|
4
|
+
*
|
|
5
|
+
* Note: SWC has replaced esbuild as the default transpiler.
|
|
6
|
+
* The 'swc' configuration section below replaces the old 'esbuild' configuration.
|
|
4
7
|
*/
|
|
5
8
|
|
|
6
9
|
export default {
|
|
@@ -35,21 +38,79 @@ export default {
|
|
|
35
38
|
|
|
36
39
|
// Webpack configuration
|
|
37
40
|
webpack: {
|
|
38
|
-
// Path to
|
|
39
|
-
|
|
41
|
+
// Path to static assets directory (defaults to './src/static')
|
|
42
|
+
staticPath: './src/static',
|
|
40
43
|
|
|
41
44
|
// Other webpack configuration options
|
|
42
45
|
devtool: 'source-map',
|
|
43
46
|
plugins: []
|
|
44
47
|
},
|
|
45
48
|
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
// SWC configuration (replaces esbuild)
|
|
50
|
+
// SWC is now the default transpiler for all TypeScript/JavaScript compilation
|
|
51
|
+
swc: {
|
|
52
|
+
// JavaScript Compiler (JSC) configuration
|
|
53
|
+
jsc: {
|
|
54
|
+
// Parser configuration
|
|
55
|
+
parser: {
|
|
56
|
+
syntax: 'typescript', // 'typescript' or 'ecmascript'
|
|
57
|
+
tsx: true, // Enable TSX support for React components
|
|
58
|
+
decorators: true, // Enable TypeScript decorators
|
|
59
|
+
dynamicImport: true // Enable dynamic imports
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// Target JavaScript version
|
|
63
|
+
target: 'es2020', // 'es3', 'es5', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023'
|
|
64
|
+
|
|
65
|
+
// Transform configuration
|
|
66
|
+
transform: {
|
|
67
|
+
react: {
|
|
68
|
+
runtime: 'automatic', // 'automatic' or 'classic'
|
|
69
|
+
// pragma: 'React.createElement', // For classic runtime
|
|
70
|
+
// pragmaFrag: 'React.Fragment', // For classic runtime
|
|
71
|
+
throwIfNamespace: false,
|
|
72
|
+
development: false,
|
|
73
|
+
useBuiltins: false,
|
|
74
|
+
refresh: false
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// Additional JSC options
|
|
79
|
+
externalHelpers: false, // Use external helpers
|
|
80
|
+
keepClassNames: false, // Keep class names
|
|
81
|
+
loose: false // Use loose mode
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
// Module configuration
|
|
85
|
+
module: {
|
|
86
|
+
type: 'es6', // 'es6', 'commonjs', 'amd', 'umd', 'systemjs'
|
|
87
|
+
strict: false, // Use strict mode
|
|
88
|
+
strictMode: true, // Use strict mode
|
|
89
|
+
lazy: false, // Lazy loading
|
|
90
|
+
noInterop: false // No interop
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
// Build options
|
|
94
|
+
minify: false, // Enable minification
|
|
95
|
+
sourceMaps: 'inline', // 'inline', true, false
|
|
96
|
+
inlineSourcesContent: true, // Inline source content
|
|
97
|
+
isModule: true, // Treat as module
|
|
98
|
+
|
|
99
|
+
// Environment configuration (optional)
|
|
100
|
+
// env: {
|
|
101
|
+
// targets: 'node >= 18', // Browser targets or Node.js version
|
|
102
|
+
// mode: 'usage', // 'usage' or 'entry'
|
|
103
|
+
// coreJs: '3', // Core-js version
|
|
104
|
+
// debug: false, // Debug mode
|
|
105
|
+
// dynamicImport: true, // Dynamic imports
|
|
106
|
+
// loose: false, // Loose mode
|
|
107
|
+
// bugfixes: false, // Bug fixes
|
|
108
|
+
// include: [], // Include specific features
|
|
109
|
+
// exclude: [], // Exclude specific features
|
|
110
|
+
// forceAllTransforms: false, // Force all transforms
|
|
111
|
+
// modules: 'auto', // Module format
|
|
112
|
+
// shippedProposals: false // Shipped proposals
|
|
113
|
+
// }
|
|
53
114
|
},
|
|
54
115
|
|
|
55
116
|
// Test configuration
|
|
@@ -57,4 +118,43 @@ export default {
|
|
|
57
118
|
roots: ['<rootDir>/src'],
|
|
58
119
|
testEnvironment: 'node'
|
|
59
120
|
}
|
|
60
|
-
};
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// Example: Minimal SWC configuration
|
|
124
|
+
// export default {
|
|
125
|
+
// useTypescript: true,
|
|
126
|
+
// swc: {
|
|
127
|
+
// jsc: {
|
|
128
|
+
// target: 'es2020',
|
|
129
|
+
// parser: {
|
|
130
|
+
// syntax: 'typescript',
|
|
131
|
+
// tsx: true
|
|
132
|
+
// }
|
|
133
|
+
// }
|
|
134
|
+
// }
|
|
135
|
+
// };
|
|
136
|
+
|
|
137
|
+
// Example: Production SWC configuration with minification
|
|
138
|
+
// export default {
|
|
139
|
+
// useTypescript: true,
|
|
140
|
+
// swc: {
|
|
141
|
+
// jsc: {
|
|
142
|
+
// target: 'es2020',
|
|
143
|
+
// parser: {
|
|
144
|
+
// syntax: 'typescript',
|
|
145
|
+
// tsx: true,
|
|
146
|
+
// decorators: true
|
|
147
|
+
// },
|
|
148
|
+
// transform: {
|
|
149
|
+
// react: {
|
|
150
|
+
// runtime: 'automatic'
|
|
151
|
+
// }
|
|
152
|
+
// }
|
|
153
|
+
// },
|
|
154
|
+
// module: {
|
|
155
|
+
// type: 'es6'
|
|
156
|
+
// },
|
|
157
|
+
// minify: true,
|
|
158
|
+
// sourceMaps: true
|
|
159
|
+
// }
|
|
160
|
+
// };
|
package/lex.config.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Lex configuration file
|
|
3
3
|
* This file contains configuration options for the Lex CLI tool
|
|
4
|
+
*
|
|
5
|
+
* Note: SWC has replaced esbuild as the default transpiler.
|
|
6
|
+
* The 'swc' configuration section below replaces the old 'esbuild' configuration.
|
|
4
7
|
*/
|
|
5
8
|
|
|
6
9
|
export default {
|
|
@@ -33,13 +36,37 @@ export default {
|
|
|
33
36
|
temperature: 0.1
|
|
34
37
|
},
|
|
35
38
|
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
// SWC configuration (replaces esbuild)
|
|
40
|
+
// SWC is now the default transpiler for all TypeScript/JavaScript compilation
|
|
41
|
+
swc: {
|
|
42
|
+
jsc: {
|
|
43
|
+
parser: {
|
|
44
|
+
syntax: 'typescript',
|
|
45
|
+
tsx: true,
|
|
46
|
+
decorators: true,
|
|
47
|
+
dynamicImport: true
|
|
48
|
+
},
|
|
49
|
+
target: 'es2020',
|
|
50
|
+
transform: {
|
|
51
|
+
react: {
|
|
52
|
+
runtime: 'automatic'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
externalHelpers: false,
|
|
56
|
+
keepClassNames: false,
|
|
57
|
+
loose: false
|
|
58
|
+
},
|
|
59
|
+
module: {
|
|
60
|
+
type: 'es6',
|
|
61
|
+
strict: false,
|
|
62
|
+
strictMode: true,
|
|
63
|
+
lazy: false,
|
|
64
|
+
noInterop: false
|
|
65
|
+
},
|
|
66
|
+
minify: false,
|
|
67
|
+
sourceMaps: 'inline',
|
|
68
|
+
inlineSourcesContent: true,
|
|
69
|
+
isModule: true
|
|
43
70
|
},
|
|
44
71
|
|
|
45
72
|
// Test configuration
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
const Button = ({ children, disabled = false, onClick, size = 'md', variant = 'primary' })=>{
|
|
4
|
+
const baseClasses = 'font-medium rounded-lg transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2';
|
|
5
|
+
const variantClasses = {
|
|
6
|
+
outline: 'border-2 border-blue-600 text-blue-600 hover:bg-blue-50 focus:ring-blue-500',
|
|
7
|
+
primary: 'bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500',
|
|
8
|
+
secondary: 'bg-gray-600 text-white hover:bg-gray-700 focus:ring-gray-500'
|
|
9
|
+
};
|
|
10
|
+
const sizeClasses = {
|
|
11
|
+
lg: 'px-6 py-3 text-lg',
|
|
12
|
+
md: 'px-4 py-2 text-base',
|
|
13
|
+
sm: 'px-3 py-1.5 text-sm'
|
|
14
|
+
};
|
|
15
|
+
const disabledClasses = disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer';
|
|
16
|
+
const classes = `${baseClasses} ${variantClasses[variant]} ${sizeClasses[size]} ${disabledClasses}`;
|
|
17
|
+
return /*#__PURE__*/ _jsx("button", {
|
|
18
|
+
className: classes,
|
|
19
|
+
disabled: disabled,
|
|
20
|
+
onClick: onClick,
|
|
21
|
+
children: children
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const meta = {
|
|
25
|
+
argTypes: {
|
|
26
|
+
disabled: {
|
|
27
|
+
control: {
|
|
28
|
+
type: 'boolean'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
size: {
|
|
32
|
+
control: {
|
|
33
|
+
type: 'select'
|
|
34
|
+
},
|
|
35
|
+
options: [
|
|
36
|
+
'sm',
|
|
37
|
+
'md',
|
|
38
|
+
'lg'
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
variant: {
|
|
42
|
+
control: {
|
|
43
|
+
type: 'select'
|
|
44
|
+
},
|
|
45
|
+
options: [
|
|
46
|
+
'primary',
|
|
47
|
+
'secondary',
|
|
48
|
+
'outline'
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
component: Button,
|
|
53
|
+
parameters: {
|
|
54
|
+
layout: 'centered'
|
|
55
|
+
},
|
|
56
|
+
tags: [
|
|
57
|
+
'autodocs'
|
|
58
|
+
],
|
|
59
|
+
title: 'Components/Button'
|
|
60
|
+
};
|
|
61
|
+
export default meta;
|
|
62
|
+
export const Primary = {
|
|
63
|
+
args: {
|
|
64
|
+
children: 'Primary Button',
|
|
65
|
+
variant: 'primary'
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export const Secondary = {
|
|
69
|
+
args: {
|
|
70
|
+
children: 'Secondary Button',
|
|
71
|
+
variant: 'secondary'
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export const Outline = {
|
|
75
|
+
args: {
|
|
76
|
+
children: 'Outline Button',
|
|
77
|
+
variant: 'outline'
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
export const Small = {
|
|
81
|
+
args: {
|
|
82
|
+
children: 'Small Button',
|
|
83
|
+
size: 'sm'
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
export const Large = {
|
|
87
|
+
args: {
|
|
88
|
+
children: 'Large Button',
|
|
89
|
+
size: 'lg'
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
export const Disabled = {
|
|
93
|
+
args: {
|
|
94
|
+
children: 'Disabled Button',
|
|
95
|
+
disabled: true
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9CdXR0b24uc3Rvcmllcy50c3giXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0IGZyb20gJ3JlYWN0JztcblxuaW1wb3J0IHR5cGUge01ldGEsIFN0b3J5T2JqfSBmcm9tICdAc3Rvcnlib29rL3JlYWN0JztcblxuaW50ZXJmYWNlIEJ1dHRvblByb3BzIHtcbiAgY2hpbGRyZW46IFJlYWN0LlJlYWN0Tm9kZTtcbiAgZGlzYWJsZWQ/OiBib29sZWFuO1xuICBvbkNsaWNrPzogKCkgPT4gdm9pZDtcbiAgc2l6ZT86ICdsZycgfCAnbWQnIHwgJ3NtJztcbiAgdmFyaWFudD86ICdvdXRsaW5lJyB8ICdwcmltYXJ5JyB8ICdzZWNvbmRhcnknO1xufVxuXG5jb25zdCBCdXR0b246IFJlYWN0LkZDPEJ1dHRvblByb3BzPiA9ICh7XG4gIGNoaWxkcmVuLFxuICBkaXNhYmxlZCA9IGZhbHNlLFxuICBvbkNsaWNrLFxuICBzaXplID0gJ21kJyxcbiAgdmFyaWFudCA9ICdwcmltYXJ5J1xufSkgPT4ge1xuICBjb25zdCBiYXNlQ2xhc3NlcyA9ICdmb250LW1lZGl1bSByb3VuZGVkLWxnIHRyYW5zaXRpb24tY29sb3JzIGR1cmF0aW9uLTIwMCBm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