burne-ui 1.4.0 → 1.5.3
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 +14 -0
- package/cli/burne-ui.js +58 -0
- package/cli/init.js +398 -0
- package/cli/prompts.js +117 -0
- package/dist/components/core/Button/buttonStyles.d.ts +1 -1
- package/dist/components/core/ToggleButton/useToggleButtonFillAnimation.d.ts +5 -0
- package/dist/index.cjs +10 -10
- package/dist/index.js +5068 -5064
- package/dist/ui.css +22 -2
- 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
|
Убедитесь, что в приложении установлены совместимые версии:
|
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,398 @@
|
|
|
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");
|
|
143
|
+
return {
|
|
144
|
+
dir,
|
|
145
|
+
file: path.join(dir, "burne-providers.tsx"),
|
|
146
|
+
importHint: "./burne-providers",
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const dir = path.join(cwd, "app");
|
|
150
|
+
const srcApp = path.join(cwd, "src", "app");
|
|
151
|
+
if (fs.existsSync(srcApp) && !fs.existsSync(dir)) {
|
|
152
|
+
return {
|
|
153
|
+
dir: srcApp,
|
|
154
|
+
file: path.join(srcApp, "burne-providers.tsx"),
|
|
155
|
+
importHint: "./burne-providers",
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
dir,
|
|
160
|
+
file: path.join(dir, "burne-providers.tsx"),
|
|
161
|
+
importHint: "./burne-providers",
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @param {Framework} framework
|
|
167
|
+
* @param {string} importHint
|
|
168
|
+
*/
|
|
169
|
+
function layoutSnippet(framework, importHint) {
|
|
170
|
+
if (framework === "vite") {
|
|
171
|
+
return `// src/main.tsx
|
|
172
|
+
import { BurneProviders } from "${importHint}";
|
|
173
|
+
|
|
174
|
+
createRoot(document.getElementById("root")!).render(
|
|
175
|
+
<StrictMode>
|
|
176
|
+
<BurneProviders>
|
|
177
|
+
<App />
|
|
178
|
+
</BurneProviders>
|
|
179
|
+
</StrictMode>,
|
|
180
|
+
);
|
|
181
|
+
`;
|
|
182
|
+
}
|
|
183
|
+
return `// app/layout.tsx
|
|
184
|
+
import { BurneProviders } from "${importHint}";
|
|
185
|
+
import "./globals.css";
|
|
186
|
+
|
|
187
|
+
export default function RootLayout({ children }) {
|
|
188
|
+
return (
|
|
189
|
+
<html lang="en" suppressHydrationWarning>
|
|
190
|
+
<body className="min-h-[100dvh] bg-background text-foreground antialiased">
|
|
191
|
+
<BurneProviders>{children}</BurneProviders>
|
|
192
|
+
</body>
|
|
193
|
+
</html>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @param {string} pmBin
|
|
201
|
+
* @param {string[]} args
|
|
202
|
+
* @param {string} cwd
|
|
203
|
+
*/
|
|
204
|
+
function runCommand(pmBin, args, cwd) {
|
|
205
|
+
return new Promise((resolve, reject) => {
|
|
206
|
+
const child = spawn(pmBin, args, {
|
|
207
|
+
cwd,
|
|
208
|
+
stdio: "inherit",
|
|
209
|
+
shell: process.platform === "win32",
|
|
210
|
+
env: process.env,
|
|
211
|
+
});
|
|
212
|
+
child.on("error", reject);
|
|
213
|
+
child.on("close", (code) => {
|
|
214
|
+
if (code === 0) resolve();
|
|
215
|
+
else reject(new Error(`${pmBin} ${args.join(" ")} exited with code ${code}`));
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* @param {PackageManager} pm
|
|
222
|
+
* @param {string} cwd
|
|
223
|
+
*/
|
|
224
|
+
async function installDeps(pm, cwd) {
|
|
225
|
+
const pkgs = ["burne-ui", "react-icons"];
|
|
226
|
+
if (pm === "npm") await runCommand("npm", ["install", ...pkgs], cwd);
|
|
227
|
+
else if (pm === "pnpm") await runCommand("pnpm", ["add", ...pkgs], cwd);
|
|
228
|
+
else if (pm === "bun") await runCommand("bun", ["add", ...pkgs], cwd);
|
|
229
|
+
else await runCommand("yarn", ["add", ...pkgs], cwd);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* @param {string[]} argv
|
|
234
|
+
*/
|
|
235
|
+
function parseInitArgs(argv) {
|
|
236
|
+
/** @type {{
|
|
237
|
+
* yes: boolean;
|
|
238
|
+
* skipInstall: boolean;
|
|
239
|
+
* toast: boolean;
|
|
240
|
+
* pm?: PackageManager;
|
|
241
|
+
* theme?: ThemeMode;
|
|
242
|
+
* css?: string;
|
|
243
|
+
* help: boolean;
|
|
244
|
+
* }} */
|
|
245
|
+
const out = {
|
|
246
|
+
yes: false,
|
|
247
|
+
skipInstall: false,
|
|
248
|
+
toast: true,
|
|
249
|
+
help: false,
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
for (let i = 0; i < argv.length; i++) {
|
|
253
|
+
const arg = argv[i];
|
|
254
|
+
if (arg === "--help" || arg === "-h") out.help = true;
|
|
255
|
+
else if (arg === "--yes" || arg === "-y") out.yes = true;
|
|
256
|
+
else if (arg === "--skip-install") out.skipInstall = true;
|
|
257
|
+
else if (arg === "--no-toast") out.toast = false;
|
|
258
|
+
else if (arg === "--pm") {
|
|
259
|
+
const v = argv[++i];
|
|
260
|
+
if (v === "npm" || v === "pnpm" || v === "bun" || v === "yarn") out.pm = v;
|
|
261
|
+
else throw new Error(`Unknown --pm "${v}"`);
|
|
262
|
+
} else if (arg === "--theme") {
|
|
263
|
+
const v = argv[++i];
|
|
264
|
+
if (v === "system" || v === "dark" || v === "light") out.theme = v;
|
|
265
|
+
else throw new Error(`Unknown --theme "${v}"`);
|
|
266
|
+
} else if (arg === "--css") {
|
|
267
|
+
out.css = argv[++i];
|
|
268
|
+
if (!out.css) throw new Error("--css requires a path");
|
|
269
|
+
} else if (arg.startsWith("-")) {
|
|
270
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return out;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @param {string[]} argv
|
|
278
|
+
* @param {string} cliVersion
|
|
279
|
+
*/
|
|
280
|
+
export async function runInit(argv, cliVersion) {
|
|
281
|
+
const args = parseInitArgs(argv);
|
|
282
|
+
if (args.help) {
|
|
283
|
+
console.log(`burne-ui init v${cliVersion}\nRun: burne-ui --help`);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const cwd = process.cwd();
|
|
288
|
+
if (!fs.existsSync(path.join(cwd, "package.json"))) {
|
|
289
|
+
throw new Error("No package.json here. Run from your app root.");
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const interactive = !args.yes && process.stdin.isTTY;
|
|
293
|
+
const framework = detectFramework(cwd);
|
|
294
|
+
const detectedPm = detectPackageManager();
|
|
295
|
+
const cssCandidates = findCssCandidates(cwd, framework);
|
|
296
|
+
|
|
297
|
+
console.log(`\nburne-ui init v${cliVersion}`);
|
|
298
|
+
console.log(
|
|
299
|
+
framework === "unknown"
|
|
300
|
+
? "Framework: not detected (will use app/burne-providers.tsx)\n"
|
|
301
|
+
: `Detected: ${framework}\n`,
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
/** @type {PackageManager} */
|
|
305
|
+
let pm = args.pm ?? detectedPm;
|
|
306
|
+
if (!args.pm && interactive) {
|
|
307
|
+
pm = await prompts.select({
|
|
308
|
+
message: "Package manager",
|
|
309
|
+
initialValue: detectedPm,
|
|
310
|
+
options: [
|
|
311
|
+
{ value: "npm", label: "npm" },
|
|
312
|
+
{ value: "pnpm", label: "pnpm" },
|
|
313
|
+
{ value: "bun", label: "bun" },
|
|
314
|
+
{ value: "yarn", label: "yarn" },
|
|
315
|
+
],
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** @type {ThemeMode} */
|
|
320
|
+
let theme = args.theme ?? "system";
|
|
321
|
+
if (!args.theme && interactive) {
|
|
322
|
+
theme = await prompts.select({
|
|
323
|
+
message: "Default theme",
|
|
324
|
+
initialValue: "system",
|
|
325
|
+
options: [
|
|
326
|
+
{ value: "system", label: "System", hint: "OS preference" },
|
|
327
|
+
{ value: "dark", label: "Dark" },
|
|
328
|
+
{ value: "light", label: "Light" },
|
|
329
|
+
],
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
let toast = args.toast;
|
|
334
|
+
if (!args.yes && interactive && args.toast) {
|
|
335
|
+
toast = await prompts.confirm({
|
|
336
|
+
message: "Include Toast.Provider?",
|
|
337
|
+
initialValue: true,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/** @type {string | null} */
|
|
342
|
+
let cssRel = args.css ?? null;
|
|
343
|
+
if (!cssRel && cssCandidates.length === 1) {
|
|
344
|
+
cssRel = cssCandidates[0];
|
|
345
|
+
} else if (!cssRel && cssCandidates.length > 1 && interactive) {
|
|
346
|
+
cssRel = await prompts.select({
|
|
347
|
+
message: "CSS file to patch",
|
|
348
|
+
options: cssCandidates.map((c) => ({ value: c, label: c })),
|
|
349
|
+
});
|
|
350
|
+
} else if (!cssRel && cssCandidates.length > 1) {
|
|
351
|
+
cssRel = cssCandidates[0];
|
|
352
|
+
} else if (!cssRel && interactive) {
|
|
353
|
+
const custom = await prompts.text({
|
|
354
|
+
message: "Global CSS path (empty = skip)",
|
|
355
|
+
placeholder: framework === "vite" ? "src/index.css" : "app/globals.css",
|
|
356
|
+
defaultValue: "",
|
|
357
|
+
});
|
|
358
|
+
cssRel = custom.trim() || null;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const fw = framework === "unknown" ? "next" : framework;
|
|
362
|
+
const provider = resolveProviderPath(cwd, fw);
|
|
363
|
+
|
|
364
|
+
if (!args.skipInstall) {
|
|
365
|
+
console.log(`\nInstalling burne-ui + react-icons with ${pm}…\n`);
|
|
366
|
+
await installDeps(pm, cwd);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (cssRel) {
|
|
370
|
+
const abs = path.resolve(cwd, cssRel);
|
|
371
|
+
if (!fs.existsSync(abs)) throw new Error(`CSS not found: ${cssRel}`);
|
|
372
|
+
const { hadBurne, hadTailwind } = patchCssFile(abs);
|
|
373
|
+
console.log(hadBurne ? `CSS OK (already linked): ${cssRel}` : `Patched CSS: ${cssRel}`);
|
|
374
|
+
if (!hadTailwind) {
|
|
375
|
+
console.log('Note: no @import "tailwindcss" — add Tailwind v4 for className utilities.');
|
|
376
|
+
}
|
|
377
|
+
} else {
|
|
378
|
+
console.log('Skipped CSS — add: @import "burne-ui/styles.css";');
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
fs.mkdirSync(provider.dir, { recursive: true });
|
|
382
|
+
const relProvider = path.relative(cwd, provider.file);
|
|
383
|
+
|
|
384
|
+
if (fs.existsSync(provider.file) && interactive) {
|
|
385
|
+
const overwrite = await prompts.confirm({
|
|
386
|
+
message: `Overwrite ${relProvider}?`,
|
|
387
|
+
initialValue: false,
|
|
388
|
+
});
|
|
389
|
+
if (overwrite) fs.writeFileSync(provider.file, providerSource(theme, toast));
|
|
390
|
+
} else {
|
|
391
|
+
fs.writeFileSync(provider.file, providerSource(theme, toast));
|
|
392
|
+
console.log(`Wrote ${relProvider}`);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const snippet = layoutSnippet(fw, provider.importHint);
|
|
396
|
+
console.log(`\n── Wrap your root layout ──\n\n${snippet}`);
|
|
397
|
+
console.log("Optional: docs site → Copy config → burne-theme.ts → config={burneTheme}\n");
|
|
398
|
+
}
|
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,7 +23,7 @@ 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
|
|
26
|
+
/** SSR: inactive layers hidden in `styles.css` via `[data-button-async-layer][aria-hidden="true"]` */
|
|
27
27
|
export declare const BUTTON_ASYNC_LAYER_DATA_ATTR = "data-button-async-layer";
|
|
28
28
|
export declare const BUTTON_SUCCESS_LAYER_CLASS = "text-success";
|
|
29
29
|
export declare const BUTTON_ERROR_LAYER_CLASS = "text-danger";
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
+
/** Marks ToggleButton / Calendar cell fill for SSR CSS in `styles.css`. */
|
|
3
|
+
export declare const SELECTION_FILL_DATA_ATTR = "data-selection-fill";
|
|
4
|
+
/** Set by GSAP init — removes SSR hide rule so animations own visibility. */
|
|
5
|
+
export declare const SELECTION_FILL_READY_ATTR = "data-selection-fill-ready";
|
|
2
6
|
/**
|
|
3
7
|
* Fill for ToggleButton / CalendarInteractiveCell.
|
|
4
8
|
* Do not set `style={{ transform, opacity }}` on fill — React will overwrite GSAP on parent re-render.
|
|
9
|
+
* SSR: CSS hides via `[data-selection-fill]:not([data-selection-fill-ready])[data-pressed="false"]`.
|
|
5
10
|
*/
|
|
6
11
|
export declare function applyToggleButtonFillInstant(fill: HTMLElement, pressed: boolean): void;
|
|
7
12
|
export declare function createToggleButtonFillRefCallback(ref: RefObject<HTMLElement | null>, initialPressed: boolean): (node: HTMLElement | null) => void;
|