@neoptocom/neopto-ui 0.5.1 → 0.6.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/CONSUMER_SETUP.md +41 -58
- package/README.md +2 -23
- package/dist/index.cjs +80 -95
- package/dist/index.d.cts +27 -223
- package/dist/index.d.ts +27 -223
- package/dist/index.js +80 -95
- package/package.json +2 -9
- package/src/components/Avatar.tsx +15 -15
- package/src/components/Button.tsx +40 -32
- package/src/components/IconButton.tsx +37 -36
- package/src/components/Typo.tsx +43 -37
- package/scripts/init.mjs +0 -201
package/scripts/init.mjs
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
4
|
-
import { resolve, join } from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
import { dirname } from 'path';
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = dirname(__filename);
|
|
10
|
-
|
|
11
|
-
// ANSI color codes
|
|
12
|
-
const colors = {
|
|
13
|
-
reset: '\x1b[0m',
|
|
14
|
-
green: '\x1b[32m',
|
|
15
|
-
yellow: '\x1b[33m',
|
|
16
|
-
blue: '\x1b[36m',
|
|
17
|
-
red: '\x1b[31m',
|
|
18
|
-
bold: '\x1b[1m',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
function log(message, color = 'reset') {
|
|
22
|
-
console.log(`${colors[color]}${message}${colors.reset}`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function findCssFile() {
|
|
26
|
-
const possiblePaths = [
|
|
27
|
-
'src/index.css',
|
|
28
|
-
'src/app.css',
|
|
29
|
-
'src/main.css',
|
|
30
|
-
'src/styles.css',
|
|
31
|
-
'src/global.css',
|
|
32
|
-
'src/globals.css',
|
|
33
|
-
'app/globals.css', // Next.js
|
|
34
|
-
'styles/globals.css', // Next.js alternative
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
for (const path of possiblePaths) {
|
|
38
|
-
if (existsSync(path)) {
|
|
39
|
-
return path;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function checkTailwindInstalled() {
|
|
47
|
-
try {
|
|
48
|
-
const packageJson = JSON.parse(readFileSync('package.json', 'utf-8'));
|
|
49
|
-
const hasTailwind =
|
|
50
|
-
packageJson.dependencies?.tailwindcss ||
|
|
51
|
-
packageJson.devDependencies?.tailwindcss;
|
|
52
|
-
|
|
53
|
-
if (!hasTailwind) {
|
|
54
|
-
log('⚠️ Warning: Tailwind CSS not found in package.json', 'yellow');
|
|
55
|
-
log(' Make sure to install: npm install -D tailwindcss@latest @tailwindcss/postcss', 'yellow');
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
return true;
|
|
59
|
-
} catch (error) {
|
|
60
|
-
log('⚠️ Warning: Could not read package.json', 'yellow');
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function updateCssFile(cssPath) {
|
|
66
|
-
let content = readFileSync(cssPath, 'utf-8');
|
|
67
|
-
|
|
68
|
-
const neededLines = [
|
|
69
|
-
'@import "tailwindcss";',
|
|
70
|
-
'@source "../node_modules/@neoptocom/neopto-ui/src";',
|
|
71
|
-
'@import "@neoptocom/neopto-ui/styles";',
|
|
72
|
-
];
|
|
73
|
-
|
|
74
|
-
let modified = false;
|
|
75
|
-
const addedLines = [];
|
|
76
|
-
|
|
77
|
-
// Check and add @import "tailwindcss"
|
|
78
|
-
if (!content.includes('@import "tailwindcss"')) {
|
|
79
|
-
content = `@import "tailwindcss";\n\n${content}`;
|
|
80
|
-
modified = true;
|
|
81
|
-
addedLines.push('@import "tailwindcss"');
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Check and add @source directive
|
|
85
|
-
if (!content.includes('@source') || !content.includes('@neoptocom/neopto-ui')) {
|
|
86
|
-
const importIndex = content.indexOf('@import "tailwindcss"');
|
|
87
|
-
if (importIndex !== -1) {
|
|
88
|
-
const lineEnd = content.indexOf('\n', importIndex);
|
|
89
|
-
content =
|
|
90
|
-
content.slice(0, lineEnd + 1) +
|
|
91
|
-
'\n/* Scan neopto-ui components */\n' +
|
|
92
|
-
'@source "../node_modules/@neoptocom/neopto-ui/src";\n' +
|
|
93
|
-
content.slice(lineEnd + 1);
|
|
94
|
-
modified = true;
|
|
95
|
-
addedLines.push('@source directive');
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Check and add library styles import
|
|
100
|
-
if (!content.includes('@import "@neoptocom/neopto-ui/styles"')) {
|
|
101
|
-
const sourceIndex = content.indexOf('@source "../node_modules/@neoptocom/neopto-ui/src"');
|
|
102
|
-
if (sourceIndex !== -1) {
|
|
103
|
-
const lineEnd = content.indexOf('\n', sourceIndex);
|
|
104
|
-
content =
|
|
105
|
-
content.slice(0, lineEnd + 1) +
|
|
106
|
-
'\n/* Import neopto-ui design tokens and styles */\n' +
|
|
107
|
-
'@import "@neoptocom/neopto-ui/styles";\n' +
|
|
108
|
-
content.slice(lineEnd + 1);
|
|
109
|
-
modified = true;
|
|
110
|
-
addedLines.push('library styles import');
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (modified) {
|
|
115
|
-
writeFileSync(cssPath, content, 'utf-8');
|
|
116
|
-
log(`\n✅ Updated ${cssPath}`, 'green');
|
|
117
|
-
if (addedLines.length > 0) {
|
|
118
|
-
log(` Added: ${addedLines.join(', ')}`, 'blue');
|
|
119
|
-
}
|
|
120
|
-
return true;
|
|
121
|
-
} else {
|
|
122
|
-
log(`\n✅ ${cssPath} already configured!`, 'green');
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function createPostCssConfig() {
|
|
128
|
-
const configPath = 'postcss.config.js';
|
|
129
|
-
|
|
130
|
-
if (existsSync(configPath)) {
|
|
131
|
-
const content = readFileSync(configPath, 'utf-8');
|
|
132
|
-
if (content.includes('@tailwindcss/postcss')) {
|
|
133
|
-
log('✅ postcss.config.js already configured', 'green');
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const config = `export default {
|
|
139
|
-
plugins: {
|
|
140
|
-
"@tailwindcss/postcss": {},
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
`;
|
|
144
|
-
|
|
145
|
-
writeFileSync(configPath, config, 'utf-8');
|
|
146
|
-
log('✅ Created postcss.config.js', 'green');
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async function main() {
|
|
151
|
-
log('\n╔══════════════════════════════════════════╗', 'blue');
|
|
152
|
-
log('║ NeoPTO UI Component Library Setup ║', 'blue');
|
|
153
|
-
log('╚══════════════════════════════════════════╝\n', 'blue');
|
|
154
|
-
|
|
155
|
-
// Check if we're in a project root
|
|
156
|
-
if (!existsSync('package.json')) {
|
|
157
|
-
log('❌ Error: package.json not found. Please run this command from your project root.', 'red');
|
|
158
|
-
process.exit(1);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Check Tailwind installation
|
|
162
|
-
log('📦 Checking dependencies...', 'blue');
|
|
163
|
-
checkTailwindInstalled();
|
|
164
|
-
|
|
165
|
-
// Create PostCSS config
|
|
166
|
-
log('\n⚙️ Setting up PostCSS...', 'blue');
|
|
167
|
-
createPostCssConfig();
|
|
168
|
-
|
|
169
|
-
// Find and update CSS file
|
|
170
|
-
log('\n🎨 Setting up CSS configuration...', 'blue');
|
|
171
|
-
const cssFile = findCssFile();
|
|
172
|
-
|
|
173
|
-
if (cssFile) {
|
|
174
|
-
updateCssFile(cssFile);
|
|
175
|
-
} else {
|
|
176
|
-
log('\n⚠️ Could not find main CSS file', 'yellow');
|
|
177
|
-
log(' Please manually add the following to your CSS file:\n', 'yellow');
|
|
178
|
-
log(' @import "tailwindcss";', 'bold');
|
|
179
|
-
log(' @source "../node_modules/@neoptocom/neopto-ui/src";', 'bold');
|
|
180
|
-
log(' @import "@neoptocom/neopto-ui/styles";\n', 'bold');
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
log('\n╔══════════════════════════════════════════╗', 'green');
|
|
184
|
-
log('║ Setup Complete! 🎉 ║', 'green');
|
|
185
|
-
log('╚══════════════════════════════════════════╝\n', 'green');
|
|
186
|
-
|
|
187
|
-
log('Next steps:', 'blue');
|
|
188
|
-
log(' 1. Import your CSS file in your main entry file', 'reset');
|
|
189
|
-
log(' 2. Start using components:', 'reset');
|
|
190
|
-
log(' import { Button, Input } from "@neoptocom/neopto-ui";\n', 'bold');
|
|
191
|
-
|
|
192
|
-
log('📚 Documentation: https://github.com/neoptocom/neopto-ui', 'blue');
|
|
193
|
-
log('💡 Need help? Check CONSUMER_SETUP.md in node_modules/@neoptocom/neopto-ui', 'blue');
|
|
194
|
-
log('🔧 Run this setup again anytime with: npx neopto-ui\n', 'blue');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
main().catch((error) => {
|
|
198
|
-
log(`\n❌ Error: ${error.message}`, 'red');
|
|
199
|
-
process.exit(1);
|
|
200
|
-
});
|
|
201
|
-
|