burne-ui 1.3.6 → 1.5.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 +37 -0
- package/cli/burne-ui.js +58 -0
- package/cli/init.js +389 -0
- package/cli/prompts.js +117 -0
- package/dist/components/core/Button/buttonStyles.d.ts +2 -0
- package/dist/components/core/Expandable/expandableStyles.d.ts +1 -4
- package/dist/index.cjs +14 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15802 -13975
- package/dist/theme/BurneUIProvider.d.ts +38 -0
- package/dist/theme/ThemeProvider.d.ts +32 -0
- package/dist/theme/colorPresets.d.ts +13 -0
- package/dist/theme/index.d.ts +6 -0
- package/dist/theme/themeConfig.d.ts +64 -0
- package/dist/theme/themeDefaults.d.ts +340 -0
- package/dist/theme/themePalettes.d.ts +116 -0
- package/dist/ui.css +6 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -11,6 +11,20 @@ npm install burne-ui
|
|
|
11
11
|
|
|
12
12
|
**Полная пошаговая настройка** (Tailwind v4, Next.js, тема, motion, SSR, troubleshooting): **[docs/SETUP.md](./docs/SETUP.md)**.
|
|
13
13
|
|
|
14
|
+
**Готовый проект одной командой** (npm / pnpm / bun):
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm create burne-app@latest my-app
|
|
18
|
+
# pnpm create burne-app my-app
|
|
19
|
+
# bunx create-burne-app my-app
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
В существующий проект:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx burne-ui@latest init
|
|
26
|
+
```
|
|
27
|
+
|
|
14
28
|
### Peer-зависимости
|
|
15
29
|
|
|
16
30
|
Убедитесь, что в приложении установлены совместимые версии:
|
|
@@ -36,6 +50,29 @@ import "burne-ui/styles.css";
|
|
|
36
50
|
|
|
37
51
|
## Кастомизация темы
|
|
38
52
|
|
|
53
|
+
### BurneUIProvider (рекомендуется)
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
"use client";
|
|
57
|
+
|
|
58
|
+
import { BurneUIProvider } from "burne-ui";
|
|
59
|
+
// import burneTheme from "./burne-theme"; // после Copy config с сайта
|
|
60
|
+
|
|
61
|
+
export function AppProviders({ children }: { children: React.ReactNode }) {
|
|
62
|
+
return (
|
|
63
|
+
<BurneUIProvider defaultTheme="system" toast>
|
|
64
|
+
{children}
|
|
65
|
+
</BurneUIProvider>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
На сайте в theme builder: **Copy config** → сохраните как `burne-theme.ts` → `<BurneUIProvider config={burneTheme}>`.
|
|
71
|
+
|
|
72
|
+
Только переключение `data-theme`: `ThemeProvider` + `useBurneTheme()`. Подробности — [docs/SETUP.md](./docs/SETUP.md).
|
|
73
|
+
|
|
74
|
+
### CSS-переопределения
|
|
75
|
+
|
|
39
76
|
Чтобы поменять палитру, отступы, шрифты, шкалу типографики и прочее, переопределите те же переменные **после** импорта `burne-ui/styles.css`:
|
|
40
77
|
|
|
41
78
|
```ts
|
package/cli/burne-ui.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { runInit } from "./init.js";
|
|
4
|
+
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
const { version } = require("../package.json");
|
|
7
|
+
|
|
8
|
+
const argv = process.argv.slice(2);
|
|
9
|
+
const cmd = argv[0];
|
|
10
|
+
|
|
11
|
+
function printHelp() {
|
|
12
|
+
console.log(`
|
|
13
|
+
burne-ui v${version}
|
|
14
|
+
|
|
15
|
+
Add Burne UI to an existing project, or see create-burne-app for a new one.
|
|
16
|
+
|
|
17
|
+
Usage:
|
|
18
|
+
npx burne-ui@latest init [options]
|
|
19
|
+
pnpm dlx burne-ui init
|
|
20
|
+
bunx burne-ui init
|
|
21
|
+
|
|
22
|
+
Commands:
|
|
23
|
+
init Patch CSS, install deps, add BurneUIProvider
|
|
24
|
+
|
|
25
|
+
Options (init):
|
|
26
|
+
--yes, -y skip prompts (arrow menus)
|
|
27
|
+
--pm npm | pnpm | bun | yarn
|
|
28
|
+
--theme system | dark | light (default: system)
|
|
29
|
+
--no-toast do not wrap Toast.Provider
|
|
30
|
+
--skip-install do not install packages
|
|
31
|
+
--css <path> global CSS file to patch
|
|
32
|
+
--help, -h
|
|
33
|
+
--version, -v
|
|
34
|
+
|
|
35
|
+
New project:
|
|
36
|
+
npm create burne-app@latest
|
|
37
|
+
`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!cmd || cmd === "--help" || cmd === "-h" || cmd === "help") {
|
|
41
|
+
printHelp();
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (cmd === "--version" || cmd === "-v") {
|
|
46
|
+
console.log(version);
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (cmd === "init") {
|
|
51
|
+
runInit(argv.slice(1), version).catch((err) => {
|
|
52
|
+
console.error(err instanceof Error ? err.message : err);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
console.error(`Unknown command: ${cmd}\n\nRun: burne-ui init`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
package/cli/init.js
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
import * as prompts from "./prompts.js";
|
|
6
|
+
|
|
7
|
+
/** @typedef {"npm" | "pnpm" | "bun" | "yarn"} PackageManager */
|
|
8
|
+
/** @typedef {"system" | "dark" | "light"} ThemeMode */
|
|
9
|
+
/** @typedef {"next" | "vite" | "unknown"} Framework */
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @returns {PackageManager}
|
|
13
|
+
*/
|
|
14
|
+
export function detectPackageManager() {
|
|
15
|
+
const ua = process.env.npm_config_user_agent ?? "";
|
|
16
|
+
if (ua.startsWith("pnpm")) return "pnpm";
|
|
17
|
+
if (ua.startsWith("yarn")) return "yarn";
|
|
18
|
+
if (ua.startsWith("bun")) return "bun";
|
|
19
|
+
const execpath = process.env.npm_execpath ?? "";
|
|
20
|
+
if (execpath.includes("pnpm")) return "pnpm";
|
|
21
|
+
if (execpath.includes("yarn")) return "yarn";
|
|
22
|
+
if (execpath.includes("bun")) return "bun";
|
|
23
|
+
return "npm";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {string} cwd
|
|
28
|
+
* @returns {Framework}
|
|
29
|
+
*/
|
|
30
|
+
export function detectFramework(cwd) {
|
|
31
|
+
if (
|
|
32
|
+
fs.existsSync(path.join(cwd, "next.config.ts")) ||
|
|
33
|
+
fs.existsSync(path.join(cwd, "next.config.js")) ||
|
|
34
|
+
fs.existsSync(path.join(cwd, "next.config.mjs"))
|
|
35
|
+
) {
|
|
36
|
+
return "next";
|
|
37
|
+
}
|
|
38
|
+
if (
|
|
39
|
+
fs.existsSync(path.join(cwd, "vite.config.ts")) ||
|
|
40
|
+
fs.existsSync(path.join(cwd, "vite.config.js")) ||
|
|
41
|
+
fs.existsSync(path.join(cwd, "vite.config.mjs"))
|
|
42
|
+
) {
|
|
43
|
+
return "vite";
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf8"));
|
|
47
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
48
|
+
if (deps?.next) return "next";
|
|
49
|
+
if (deps?.vite) return "vite";
|
|
50
|
+
} catch {
|
|
51
|
+
/* ignore */
|
|
52
|
+
}
|
|
53
|
+
return "unknown";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @param {string} cwd
|
|
58
|
+
* @param {Framework} framework
|
|
59
|
+
*/
|
|
60
|
+
export function findCssCandidates(cwd, framework) {
|
|
61
|
+
const candidates =
|
|
62
|
+
framework === "vite"
|
|
63
|
+
? ["src/index.css", "src/styles.css", "src/App.css", "index.css"]
|
|
64
|
+
: [
|
|
65
|
+
"app/globals.css",
|
|
66
|
+
"src/app/globals.css",
|
|
67
|
+
"styles/globals.css",
|
|
68
|
+
"src/styles/globals.css",
|
|
69
|
+
"app/global.css",
|
|
70
|
+
];
|
|
71
|
+
return candidates.filter((rel) => fs.existsSync(path.join(cwd, rel)));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @param {string} cssPath
|
|
76
|
+
*/
|
|
77
|
+
export function patchCssFile(cssPath) {
|
|
78
|
+
let css = fs.readFileSync(cssPath, "utf8");
|
|
79
|
+
const hadBurne = css.includes("burne-ui/styles.css");
|
|
80
|
+
const hadTailwind = /@import\s+["']tailwindcss["']/.test(css);
|
|
81
|
+
|
|
82
|
+
if (!hadBurne) {
|
|
83
|
+
if (hadTailwind) {
|
|
84
|
+
const importLine = `\n@import "burne-ui/styles.css";\n`;
|
|
85
|
+
const sourceBlocks = [...css.matchAll(/@source\s+[^;]+;/g)];
|
|
86
|
+
if (sourceBlocks.length > 0) {
|
|
87
|
+
const last = sourceBlocks[sourceBlocks.length - 1];
|
|
88
|
+
const insertAt = last.index + last[0].length;
|
|
89
|
+
css = css.slice(0, insertAt) + importLine + css.slice(insertAt);
|
|
90
|
+
} else {
|
|
91
|
+
css = css.replace(
|
|
92
|
+
/@import\s+["']tailwindcss["']\s*;/,
|
|
93
|
+
`@import "tailwindcss";${importLine}`,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
css =
|
|
98
|
+
`/* Burne UI — recommend Tailwind v4: @import "tailwindcss" */\n` +
|
|
99
|
+
`@import "burne-ui/styles.css";\n\n` +
|
|
100
|
+
css;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!css.includes("burne-ui/styles.css")) {
|
|
105
|
+
css += `\n@import "burne-ui/styles.css";\n`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
fs.writeFileSync(cssPath, css);
|
|
109
|
+
return { hadBurne, hadTailwind };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @param {ThemeMode} theme
|
|
114
|
+
* @param {boolean} toast
|
|
115
|
+
*/
|
|
116
|
+
function providerSource(theme, toast) {
|
|
117
|
+
const toastLine = toast ? " toast" : " toast={false}";
|
|
118
|
+
return `"use client";
|
|
119
|
+
|
|
120
|
+
import { BurneUIProvider } from "burne-ui";
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Generated by \`burne-ui init\`.
|
|
124
|
+
* Optional: Copy config from the docs site → burne-theme.ts → config={burneTheme}.
|
|
125
|
+
*/
|
|
126
|
+
export function BurneProviders({ children }: { children: React.ReactNode }) {
|
|
127
|
+
return (
|
|
128
|
+
<BurneUIProvider defaultTheme="${theme}"${toastLine}>
|
|
129
|
+
{children}
|
|
130
|
+
</BurneUIProvider>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @param {string} cwd
|
|
138
|
+
* @param {Framework} framework
|
|
139
|
+
*/
|
|
140
|
+
function resolveProviderPath(cwd, framework) {
|
|
141
|
+
if (framework === "vite") {
|
|
142
|
+
const dir = path.join(cwd, "src", "components");
|
|
143
|
+
return {
|
|
144
|
+
dir,
|
|
145
|
+
file: path.join(dir, "burne-providers.tsx"),
|
|
146
|
+
importHint: "./components/burne-providers",
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const dir = path.join(cwd, "components", "providers");
|
|
150
|
+
return {
|
|
151
|
+
dir,
|
|
152
|
+
file: path.join(dir, "burne-providers.tsx"),
|
|
153
|
+
importHint: "@/components/providers/burne-providers",
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @param {Framework} framework
|
|
159
|
+
* @param {string} importHint
|
|
160
|
+
*/
|
|
161
|
+
function layoutSnippet(framework, importHint) {
|
|
162
|
+
if (framework === "vite") {
|
|
163
|
+
return `// src/main.tsx
|
|
164
|
+
import { BurneProviders } from "${importHint}";
|
|
165
|
+
|
|
166
|
+
createRoot(document.getElementById("root")!).render(
|
|
167
|
+
<StrictMode>
|
|
168
|
+
<BurneProviders>
|
|
169
|
+
<App />
|
|
170
|
+
</BurneProviders>
|
|
171
|
+
</StrictMode>,
|
|
172
|
+
);
|
|
173
|
+
`;
|
|
174
|
+
}
|
|
175
|
+
return `// app/layout.tsx
|
|
176
|
+
import { BurneProviders } from "${importHint}";
|
|
177
|
+
|
|
178
|
+
export default function RootLayout({ children }) {
|
|
179
|
+
return (
|
|
180
|
+
<html lang="en" suppressHydrationWarning>
|
|
181
|
+
<body className="min-h-[100dvh] bg-background text-foreground antialiased">
|
|
182
|
+
<BurneProviders>{children}</BurneProviders>
|
|
183
|
+
</body>
|
|
184
|
+
</html>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @param {string} pmBin
|
|
192
|
+
* @param {string[]} args
|
|
193
|
+
* @param {string} cwd
|
|
194
|
+
*/
|
|
195
|
+
function runCommand(pmBin, args, cwd) {
|
|
196
|
+
return new Promise((resolve, reject) => {
|
|
197
|
+
const child = spawn(pmBin, args, {
|
|
198
|
+
cwd,
|
|
199
|
+
stdio: "inherit",
|
|
200
|
+
shell: process.platform === "win32",
|
|
201
|
+
env: process.env,
|
|
202
|
+
});
|
|
203
|
+
child.on("error", reject);
|
|
204
|
+
child.on("close", (code) => {
|
|
205
|
+
if (code === 0) resolve();
|
|
206
|
+
else reject(new Error(`${pmBin} ${args.join(" ")} exited with code ${code}`));
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* @param {PackageManager} pm
|
|
213
|
+
* @param {string} cwd
|
|
214
|
+
*/
|
|
215
|
+
async function installDeps(pm, cwd) {
|
|
216
|
+
const pkgs = ["burne-ui", "react-icons"];
|
|
217
|
+
if (pm === "npm") await runCommand("npm", ["install", ...pkgs], cwd);
|
|
218
|
+
else if (pm === "pnpm") await runCommand("pnpm", ["add", ...pkgs], cwd);
|
|
219
|
+
else if (pm === "bun") await runCommand("bun", ["add", ...pkgs], cwd);
|
|
220
|
+
else await runCommand("yarn", ["add", ...pkgs], cwd);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @param {string[]} argv
|
|
225
|
+
*/
|
|
226
|
+
function parseInitArgs(argv) {
|
|
227
|
+
/** @type {{
|
|
228
|
+
* yes: boolean;
|
|
229
|
+
* skipInstall: boolean;
|
|
230
|
+
* toast: boolean;
|
|
231
|
+
* pm?: PackageManager;
|
|
232
|
+
* theme?: ThemeMode;
|
|
233
|
+
* css?: string;
|
|
234
|
+
* help: boolean;
|
|
235
|
+
* }} */
|
|
236
|
+
const out = {
|
|
237
|
+
yes: false,
|
|
238
|
+
skipInstall: false,
|
|
239
|
+
toast: true,
|
|
240
|
+
help: false,
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
for (let i = 0; i < argv.length; i++) {
|
|
244
|
+
const arg = argv[i];
|
|
245
|
+
if (arg === "--help" || arg === "-h") out.help = true;
|
|
246
|
+
else if (arg === "--yes" || arg === "-y") out.yes = true;
|
|
247
|
+
else if (arg === "--skip-install") out.skipInstall = true;
|
|
248
|
+
else if (arg === "--no-toast") out.toast = false;
|
|
249
|
+
else if (arg === "--pm") {
|
|
250
|
+
const v = argv[++i];
|
|
251
|
+
if (v === "npm" || v === "pnpm" || v === "bun" || v === "yarn") out.pm = v;
|
|
252
|
+
else throw new Error(`Unknown --pm "${v}"`);
|
|
253
|
+
} else if (arg === "--theme") {
|
|
254
|
+
const v = argv[++i];
|
|
255
|
+
if (v === "system" || v === "dark" || v === "light") out.theme = v;
|
|
256
|
+
else throw new Error(`Unknown --theme "${v}"`);
|
|
257
|
+
} else if (arg === "--css") {
|
|
258
|
+
out.css = argv[++i];
|
|
259
|
+
if (!out.css) throw new Error("--css requires a path");
|
|
260
|
+
} else if (arg.startsWith("-")) {
|
|
261
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return out;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @param {string[]} argv
|
|
269
|
+
* @param {string} cliVersion
|
|
270
|
+
*/
|
|
271
|
+
export async function runInit(argv, cliVersion) {
|
|
272
|
+
const args = parseInitArgs(argv);
|
|
273
|
+
if (args.help) {
|
|
274
|
+
console.log(`burne-ui init v${cliVersion}\nRun: burne-ui --help`);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const cwd = process.cwd();
|
|
279
|
+
if (!fs.existsSync(path.join(cwd, "package.json"))) {
|
|
280
|
+
throw new Error("No package.json here. Run from your app root.");
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const interactive = !args.yes && process.stdin.isTTY;
|
|
284
|
+
const framework = detectFramework(cwd);
|
|
285
|
+
const detectedPm = detectPackageManager();
|
|
286
|
+
const cssCandidates = findCssCandidates(cwd, framework);
|
|
287
|
+
|
|
288
|
+
console.log(`\nburne-ui init v${cliVersion}`);
|
|
289
|
+
console.log(
|
|
290
|
+
framework === "unknown"
|
|
291
|
+
? "Framework: not detected (will use components/providers)\n"
|
|
292
|
+
: `Detected: ${framework}\n`,
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
/** @type {PackageManager} */
|
|
296
|
+
let pm = args.pm ?? detectedPm;
|
|
297
|
+
if (!args.pm && interactive) {
|
|
298
|
+
pm = await prompts.select({
|
|
299
|
+
message: "Package manager",
|
|
300
|
+
initialValue: detectedPm,
|
|
301
|
+
options: [
|
|
302
|
+
{ value: "npm", label: "npm" },
|
|
303
|
+
{ value: "pnpm", label: "pnpm" },
|
|
304
|
+
{ value: "bun", label: "bun" },
|
|
305
|
+
{ value: "yarn", label: "yarn" },
|
|
306
|
+
],
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** @type {ThemeMode} */
|
|
311
|
+
let theme = args.theme ?? "system";
|
|
312
|
+
if (!args.theme && interactive) {
|
|
313
|
+
theme = await prompts.select({
|
|
314
|
+
message: "Default theme",
|
|
315
|
+
initialValue: "system",
|
|
316
|
+
options: [
|
|
317
|
+
{ value: "system", label: "System", hint: "OS preference" },
|
|
318
|
+
{ value: "dark", label: "Dark" },
|
|
319
|
+
{ value: "light", label: "Light" },
|
|
320
|
+
],
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
let toast = args.toast;
|
|
325
|
+
if (!args.yes && interactive && args.toast) {
|
|
326
|
+
toast = await prompts.confirm({
|
|
327
|
+
message: "Include Toast.Provider?",
|
|
328
|
+
initialValue: true,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** @type {string | null} */
|
|
333
|
+
let cssRel = args.css ?? null;
|
|
334
|
+
if (!cssRel && cssCandidates.length === 1) {
|
|
335
|
+
cssRel = cssCandidates[0];
|
|
336
|
+
} else if (!cssRel && cssCandidates.length > 1 && interactive) {
|
|
337
|
+
cssRel = await prompts.select({
|
|
338
|
+
message: "CSS file to patch",
|
|
339
|
+
options: cssCandidates.map((c) => ({ value: c, label: c })),
|
|
340
|
+
});
|
|
341
|
+
} else if (!cssRel && cssCandidates.length > 1) {
|
|
342
|
+
cssRel = cssCandidates[0];
|
|
343
|
+
} else if (!cssRel && interactive) {
|
|
344
|
+
const custom = await prompts.text({
|
|
345
|
+
message: "Global CSS path (empty = skip)",
|
|
346
|
+
placeholder: framework === "vite" ? "src/index.css" : "app/globals.css",
|
|
347
|
+
defaultValue: "",
|
|
348
|
+
});
|
|
349
|
+
cssRel = custom.trim() || null;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const fw = framework === "unknown" ? "next" : framework;
|
|
353
|
+
const provider = resolveProviderPath(cwd, fw);
|
|
354
|
+
|
|
355
|
+
if (!args.skipInstall) {
|
|
356
|
+
console.log(`\nInstalling burne-ui + react-icons with ${pm}…\n`);
|
|
357
|
+
await installDeps(pm, cwd);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (cssRel) {
|
|
361
|
+
const abs = path.resolve(cwd, cssRel);
|
|
362
|
+
if (!fs.existsSync(abs)) throw new Error(`CSS not found: ${cssRel}`);
|
|
363
|
+
const { hadBurne, hadTailwind } = patchCssFile(abs);
|
|
364
|
+
console.log(hadBurne ? `CSS OK (already linked): ${cssRel}` : `Patched CSS: ${cssRel}`);
|
|
365
|
+
if (!hadTailwind) {
|
|
366
|
+
console.log('Note: no @import "tailwindcss" — add Tailwind v4 for className utilities.');
|
|
367
|
+
}
|
|
368
|
+
} else {
|
|
369
|
+
console.log('Skipped CSS — add: @import "burne-ui/styles.css";');
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
fs.mkdirSync(provider.dir, { recursive: true });
|
|
373
|
+
const relProvider = path.relative(cwd, provider.file);
|
|
374
|
+
|
|
375
|
+
if (fs.existsSync(provider.file) && interactive) {
|
|
376
|
+
const overwrite = await prompts.confirm({
|
|
377
|
+
message: `Overwrite ${relProvider}?`,
|
|
378
|
+
initialValue: false,
|
|
379
|
+
});
|
|
380
|
+
if (overwrite) fs.writeFileSync(provider.file, providerSource(theme, toast));
|
|
381
|
+
} else {
|
|
382
|
+
fs.writeFileSync(provider.file, providerSource(theme, toast));
|
|
383
|
+
console.log(`Wrote ${relProvider}`);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const snippet = layoutSnippet(fw, provider.importHint);
|
|
387
|
+
console.log(`\n── Wrap your root layout ──\n\n${snippet}`);
|
|
388
|
+
console.log("Optional: docs site → Copy config → burne-theme.ts → config={burneTheme}\n");
|
|
389
|
+
}
|
package/cli/prompts.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal interactive prompts (↑↓ + Enter). No npm dependencies.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import readline from "node:readline";
|
|
6
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @template T
|
|
10
|
+
* @param {{
|
|
11
|
+
* message: string;
|
|
12
|
+
* options: { value: T; label: string; hint?: string }[];
|
|
13
|
+
* initialValue?: T;
|
|
14
|
+
* }} opts
|
|
15
|
+
* @returns {Promise<T>}
|
|
16
|
+
*/
|
|
17
|
+
export function select(opts) {
|
|
18
|
+
const { message, options, initialValue } = opts;
|
|
19
|
+
if (!options.length) throw new Error("select: no options");
|
|
20
|
+
|
|
21
|
+
let index = options.findIndex((o) => o.value === initialValue);
|
|
22
|
+
if (index < 0) index = 0;
|
|
23
|
+
|
|
24
|
+
if (!input.isTTY) {
|
|
25
|
+
return Promise.resolve(options[index].value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
const rl = readline.createInterface({ input, output });
|
|
30
|
+
readline.emitKeypressEvents(input, rl);
|
|
31
|
+
input.setRawMode(true);
|
|
32
|
+
|
|
33
|
+
const lineCount = options.length + 1; // message + options
|
|
34
|
+
|
|
35
|
+
const draw = (first) => {
|
|
36
|
+
if (!first) {
|
|
37
|
+
output.write(`\x1b[${lineCount}A`);
|
|
38
|
+
}
|
|
39
|
+
output.write(`\x1b[2K\r? ${message}\n`);
|
|
40
|
+
options.forEach((opt, i) => {
|
|
41
|
+
const mark = i === index ? "›" : " ";
|
|
42
|
+
const hint = opt.hint ? ` \x1b[2m${opt.hint}\x1b[0m` : "";
|
|
43
|
+
const label =
|
|
44
|
+
i === index ? `\x1b[36m${opt.label}\x1b[0m` : opt.label;
|
|
45
|
+
output.write(`\x1b[2K\r ${mark} ${label}${hint}\n`);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
draw(true);
|
|
50
|
+
|
|
51
|
+
const done = (fn) => {
|
|
52
|
+
input.off("keypress", onKey);
|
|
53
|
+
input.setRawMode(false);
|
|
54
|
+
rl.close();
|
|
55
|
+
fn();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const onKey = (_str, key) => {
|
|
59
|
+
if (!key) return;
|
|
60
|
+
if (key.ctrl && key.name === "c") {
|
|
61
|
+
done(() => {
|
|
62
|
+
output.write("\n");
|
|
63
|
+
reject(new Error("Cancelled"));
|
|
64
|
+
});
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (key.name === "up" || key.name === "k") {
|
|
68
|
+
index = (index - 1 + options.length) % options.length;
|
|
69
|
+
draw(false);
|
|
70
|
+
} else if (key.name === "down" || key.name === "j") {
|
|
71
|
+
index = (index + 1) % options.length;
|
|
72
|
+
draw(false);
|
|
73
|
+
} else if (key.name === "return") {
|
|
74
|
+
done(() => {
|
|
75
|
+
output.write(`✔ ${message} · ${options[index].label}\n`);
|
|
76
|
+
resolve(options[index].value);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
input.on("keypress", onKey);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @param {{ message: string; placeholder?: string; defaultValue?: string }} opts
|
|
87
|
+
* @returns {Promise<string>}
|
|
88
|
+
*/
|
|
89
|
+
export function text(opts) {
|
|
90
|
+
const { message, placeholder, defaultValue = "" } = opts;
|
|
91
|
+
if (!input.isTTY) return Promise.resolve(defaultValue);
|
|
92
|
+
|
|
93
|
+
const rl = readline.createInterface({ input, output });
|
|
94
|
+
const hint = placeholder || defaultValue;
|
|
95
|
+
return new Promise((resolve) => {
|
|
96
|
+
rl.question(`? ${message}${hint ? ` (${hint})` : ""}: `, (answer) => {
|
|
97
|
+
rl.close();
|
|
98
|
+
resolve(answer.trim() || defaultValue);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @param {{ message: string; initialValue?: boolean }} opts
|
|
105
|
+
* @returns {Promise<boolean>}
|
|
106
|
+
*/
|
|
107
|
+
export function confirm(opts) {
|
|
108
|
+
const { message, initialValue = true } = opts;
|
|
109
|
+
return select({
|
|
110
|
+
message,
|
|
111
|
+
initialValue: initialValue ? "yes" : "no",
|
|
112
|
+
options: [
|
|
113
|
+
{ value: "yes", label: "Yes" },
|
|
114
|
+
{ value: "no", label: "No" },
|
|
115
|
+
],
|
|
116
|
+
}).then((v) => v === "yes");
|
|
117
|
+
}
|
|
@@ -23,6 +23,8 @@ export declare const BUTTON_LABEL_LAYER_CLASS = "col-start-1 row-start-1 inline-
|
|
|
23
23
|
export declare const BUTTON_LEFT_ICON_SLOT_CLASS = "inline-flex shrink-0 items-center justify-center";
|
|
24
24
|
export declare const BUTTON_LABEL_TEXT_CLASS = "min-w-0 shrink";
|
|
25
25
|
export declare const BUTTON_ASYNC_GRID_LAYER_CLASS = "col-start-1 row-start-1 flex items-center justify-center";
|
|
26
|
+
/** SSR fallback in app CSS: `button [data-button-async-layer][aria-hidden="true"]` */
|
|
27
|
+
export declare const BUTTON_ASYNC_LAYER_DATA_ATTR = "data-button-async-layer";
|
|
26
28
|
export declare const BUTTON_SUCCESS_LAYER_CLASS = "text-success";
|
|
27
29
|
export declare const BUTTON_ERROR_LAYER_CLASS = "text-danger";
|
|
28
30
|
export declare const BUTTON_SPINNER_MOTION_CLASS = "animate-spin motion-reduce:animate-none";
|
|
@@ -18,10 +18,7 @@ export declare const EXPANDABLE_TRIGGER_LIFT_BASE_CLASS = "relative z-[1] w-full
|
|
|
18
18
|
export declare const EXPANDABLE_COMPOUND_CONTENTS_CLASS = "contents";
|
|
19
19
|
export declare const EXPANDABLE_TRIGGER_CHEVRON_WRAP_CLASS = "relative z-[1] flex shrink-0 origin-center self-center";
|
|
20
20
|
export declare const EXPANDABLE_MESSAGE_CLASS = "contents";
|
|
21
|
-
export declare const EXPANDABLE_ICON_BASE_CLASS = "
|
|
22
|
-
/** Default svg size per control size — same pattern as Alert (`[&_svg]:icon-*`). */
|
|
23
|
-
export declare const EXPANDABLE_ICON_SVG_CLASS: Record<ExpandableSize, string>;
|
|
24
|
-
export declare const EXPANDABLE_ICON_GRID_CELL_CLASS = "col-start-1 row-start-1 self-center shrink-0";
|
|
21
|
+
export declare const EXPANDABLE_ICON_BASE_CLASS = "shrink-0 text-primary [&_svg]:size-full";
|
|
25
22
|
export declare const EXPANDABLE_CONTENT_CLASS = "contents";
|
|
26
23
|
export declare const EXPANDABLE_DESCRIPTION_CLASS = "text-muted";
|
|
27
24
|
export declare const EXPANDABLE_TITLE_CLASS = "font-w-mid";
|