create-lacspace-app 2.13.0 → 2.14.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/dist/lib.cjs CHANGED
@@ -2438,8 +2438,364 @@ var FEATURES = [
2438
2438
  "SSE auto-reconnects and needs no WebSocket server \u2014 great for notifications and live feeds."
2439
2439
  ],
2440
2440
  learn: "https://developer.lacspace.com/packages/sse"
2441
+ },
2442
+ {
2443
+ key: "ui",
2444
+ label: "UI components",
2445
+ description: "The @lacspace/components library wired into this template \u2014 96 accessible components, a theme bridge so they inherit your accent and dark mode, and a working settings page. Frontend, any template.",
2446
+ deps: { "@lacspace/components": "^1.0.1" },
2447
+ files: () => ({
2448
+ "app/lacspace-ui.css": uiThemeBridge(),
2449
+ "app/ui/layout.tsx": uiRouteLayout(),
2450
+ "app/ui/page.tsx": uiShowcasePage(),
2451
+ "components/ui-provider.tsx": uiProviderComponent()
2452
+ }),
2453
+ nextSteps: [
2454
+ "Run `npm run dev` and open http://localhost:3000/ui \u2014 a real form, a confirm dialog and toasts, already themed.",
2455
+ 'Use the kit anywhere: import "@lacspace/components/styles.css" and "./lacspace-ui.css" in app/layout.tsx, then wrap <body> with <UIProvider> from @/components/ui-provider.',
2456
+ "Rebrand everything from app/lacspace-ui.css \u2014 it maps this template's accent, radius and font onto the kit's --lac-* variables, so dark mode follows your theme toggle."
2457
+ ],
2458
+ learn: "https://developer.lacspace.com/components"
2459
+ },
2460
+ {
2461
+ key: "dataviz",
2462
+ label: "Charts, tables & dates",
2463
+ description: "A working insights page from @lacspace/charts, @lacspace/table and @lacspace/date \u2014 SVG charts, a sortable/exportable data table and a date-range filter. No canvas, no D3, no grid licence. Frontend, any template.",
2464
+ deps: {
2465
+ "@lacspace/components": "^1.0.1",
2466
+ "@lacspace/charts": "^1.0.0",
2467
+ "@lacspace/table": "^1.0.0",
2468
+ "@lacspace/date": "^1.0.0"
2469
+ },
2470
+ files: () => ({
2471
+ "app/lacspace-ui.css": uiThemeBridge(),
2472
+ "app/insights/layout.tsx": dataVizRouteLayout(),
2473
+ "app/insights/page.tsx": dataVizPage()
2474
+ }),
2475
+ nextSteps: [
2476
+ "Run `npm run dev` and open http://localhost:3000/insights \u2014 stats, a line chart, a date-range filter and an exportable table.",
2477
+ "Swap the sample arrays at the top of app/insights/page.tsx for your own data; everything else is already wired.",
2478
+ "The CSV export neutralises leading =, +, - and @, so an exported cell can never run as a formula in Excel."
2479
+ ],
2480
+ learn: "https://developer.lacspace.com/components#charts"
2481
+ }
2482
+ ];
2483
+ var uiThemeBridge = () => `/* Map this app's tokens onto @lacspace/components.
2484
+ *
2485
+ * The kit's own dark palette lives behind \`prefers-color-scheme\` and a
2486
+ * \`data-theme\` attribute, but this app switches themes with a \`.dark\` class on
2487
+ * <html>. The repeated \`:root\` below is deliberate: it raises specificity just
2488
+ * enough to win against the kit's own theme blocks, whatever the OS setting is,
2489
+ * so the components follow YOUR toggle and never fight it.
2490
+ *
2491
+ * Every line here is a suggestion \u2014 change any of them and the whole kit
2492
+ * follows. The full token list is at the top of @lacspace/components/styles.css.
2493
+ */
2494
+ :root:root:root {
2495
+ /* Brand */
2496
+ --lac-accent: var(--accent-to);
2497
+ --lac-accent-hover: var(--accent-from);
2498
+ --lac-accent-active: var(--accent-from);
2499
+ --lac-accent-fg: var(--on-accent);
2500
+ --lac-accent-soft: color-mix(in oklab, var(--accent-to) 14%, transparent);
2501
+ --lac-accent-ring: color-mix(in oklab, var(--accent-to) 38%, transparent);
2502
+
2503
+ /* Surfaces & text \u2014 these already swap with the .dark class, so dark mode
2504
+ comes along for free. */
2505
+ --lac-bg: var(--bg);
2506
+ --lac-bg-subtle: var(--surface);
2507
+ --lac-bg-muted: var(--panel);
2508
+ --lac-surface: var(--surface);
2509
+ --lac-surface-raised: var(--panel);
2510
+ --lac-fg: var(--fg);
2511
+ --lac-fg-muted: var(--muted);
2512
+ --lac-fg-faint: var(--faint);
2513
+ --lac-fg-on-accent: var(--on-accent);
2514
+
2515
+ /* Lines & depth */
2516
+ --lac-border: var(--hairline);
2517
+ --lac-border-strong: color-mix(in oklab, var(--fg) 22%, transparent);
2518
+ --lac-shadow-sm: var(--shadow-sm);
2519
+ --lac-shadow: var(--shadow);
2520
+ --lac-shadow-lg: var(--shadow-lg);
2521
+
2522
+ /* Shape & type */
2523
+ --lac-radius: var(--radius);
2524
+ --lac-radius-lg: var(--radius-lg);
2525
+ --lac-font: var(--font-inter), ui-sans-serif, system-ui, sans-serif;
2526
+ }
2527
+ `;
2528
+ var uiRouteLayout = () => `import "@lacspace/components/styles.css";
2529
+ import "../lacspace-ui.css";
2530
+ import { ToastProvider } from "@lacspace/components";
2531
+
2532
+ // Scoped to this route so the add-on needs no edits to app/layout.tsx. To use
2533
+ // the kit across the whole app, move these two imports there and wrap <body>
2534
+ // with <UIProvider> from @/components/ui-provider instead.
2535
+ export default function UILayout({ children }: { children: React.ReactNode }) {
2536
+ return <ToastProvider>{children}</ToastProvider>;
2537
+ }
2538
+ `;
2539
+ var uiProviderComponent = () => `"use client";
2540
+ import { ToastProvider } from "@lacspace/components";
2541
+
2542
+ /**
2543
+ * Wrap <body> with this once to use the component kit across the whole app,
2544
+ * and import the two stylesheets in app/layout.tsx:
2545
+ *
2546
+ * import "@lacspace/components/styles.css";
2547
+ * import "./lacspace-ui.css";
2548
+ */
2549
+ export function UIProvider({ children }: { children: React.ReactNode }) {
2550
+ return <ToastProvider position="bottom-right">{children}</ToastProvider>;
2551
+ }
2552
+ `;
2553
+ var uiShowcasePage = () => `"use client";
2554
+ import { useState } from "react";
2555
+ import {
2556
+ Alert,
2557
+ Badge,
2558
+ Button,
2559
+ Card,
2560
+ CardBody,
2561
+ CardDescription,
2562
+ CardHeader,
2563
+ CardTitle,
2564
+ ConfirmDialog,
2565
+ Field,
2566
+ Input,
2567
+ PasswordInput,
2568
+ Select,
2569
+ Stack,
2570
+ Switch,
2571
+ useToast,
2572
+ } from "@lacspace/components";
2573
+
2574
+ // Everything below is real: a form that validates, a dialog that waits for its
2575
+ // promise, and a toast queue \u2014 none of it styled with utility classes. The look
2576
+ // comes from app/lacspace-ui.css, which maps this template's tokens onto the kit.
2577
+ export default function UIPage() {
2578
+ const { toast } = useToast();
2579
+ const [confirming, setConfirming] = useState(false);
2580
+ const [updates, setUpdates] = useState(true);
2581
+ const [errors, setErrors] = useState<{ email?: string }>({});
2582
+
2583
+ function save(form: FormData) {
2584
+ const email = String(form.get("email") ?? "");
2585
+ if (!email.includes("@")) {
2586
+ setErrors({ email: "That doesn't look like an email address." });
2587
+ return;
2588
+ }
2589
+ setErrors({});
2590
+ toast({ title: "Settings saved", tone: "success" });
2441
2591
  }
2592
+
2593
+ return (
2594
+ <main className="mx-auto max-w-2xl px-6 py-16">
2595
+ <Stack gap={4}>
2596
+ <Card>
2597
+ <CardHeader>
2598
+ <CardTitle>Account settings</CardTitle>
2599
+ <CardDescription>
2600
+ 96 components from @lacspace/components \u2014 accessible, server-render safe, and
2601
+ themed by CSS variables instead of utility classes.
2602
+ </CardDescription>
2603
+ </CardHeader>
2604
+ <CardBody>
2605
+ <form action={save}>
2606
+ <Stack gap={3}>
2607
+ <Field label="Work email" hint="We never share it." error={errors.email}>
2608
+ {({ id, describedBy, invalid }) => (
2609
+ <Input
2610
+ id={id}
2611
+ name="email"
2612
+ type="email"
2613
+ defaultValue="you@company.com"
2614
+ aria-describedby={describedBy}
2615
+ invalid={invalid}
2616
+ />
2617
+ )}
2618
+ </Field>
2619
+
2620
+ <Field label="New password" hint="At least 12 characters.">
2621
+ {({ id, describedBy }) => (
2622
+ <PasswordInput id={id} name="password" aria-describedby={describedBy} strength />
2623
+ )}
2624
+ </Field>
2625
+
2626
+ <Field label="Plan">
2627
+ {({ id }) => (
2628
+ <Select
2629
+ id={id}
2630
+ name="plan"
2631
+ defaultValue="pro"
2632
+ options={[
2633
+ { value: "free", label: "Free" },
2634
+ { value: "pro", label: "Pro" },
2635
+ { value: "team", label: "Team" },
2636
+ ]}
2637
+ />
2638
+ )}
2639
+ </Field>
2640
+
2641
+ <Switch checked={updates} onChange={setUpdates} label="Email me about product updates" />
2642
+
2643
+ <Button type="submit" full>
2644
+ Save changes
2645
+ </Button>
2646
+ </Stack>
2647
+ </form>
2648
+ </CardBody>
2649
+ </Card>
2650
+
2651
+ <Alert tone="info" title="Rebrand the whole kit from one file">
2652
+ Open <code>app/lacspace-ui.css</code>. It maps this template&rsquo;s accent, radius and font
2653
+ onto the kit&rsquo;s variables, so the components already match \u2014 and they follow your
2654
+ existing dark-mode toggle.
2655
+ </Alert>
2656
+
2657
+ <Card>
2658
+ <CardBody>
2659
+ <Stack direction="row" gap={2} align="center" wrap>
2660
+ <Badge tone="success" dot>
2661
+ Live
2662
+ </Badge>
2663
+ <Button variant="soft" onClick={() => toast("Saved to drafts")}>
2664
+ Show a toast
2665
+ </Button>
2666
+ <Button tone="danger" variant="soft" onClick={() => setConfirming(true)}>
2667
+ Delete account
2668
+ </Button>
2669
+ </Stack>
2670
+ </CardBody>
2671
+ </Card>
2672
+ </Stack>
2673
+
2674
+ <ConfirmDialog
2675
+ open={confirming}
2676
+ onOpenChange={setConfirming}
2677
+ tone="danger"
2678
+ title="Delete this account?"
2679
+ message="Everything in it goes with it. This cannot be undone."
2680
+ confirmLabel="Delete account"
2681
+ onConfirm={async () => {
2682
+ // Return a promise and the button spins, blocks repeat clicks, and
2683
+ // keeps the dialog open if it rejects \u2014 a failed delete never looks
2684
+ // like a successful one.
2685
+ await new Promise((resolve) => setTimeout(resolve, 700));
2686
+ toast({ title: "Account deleted", tone: "success" });
2687
+ }}
2688
+ />
2689
+ </main>
2690
+ );
2691
+ }
2692
+ `;
2693
+ var dataVizRouteLayout = () => `import "@lacspace/components/styles.css";
2694
+ import "@lacspace/charts/styles.css";
2695
+ import "@lacspace/table/styles.css";
2696
+ import "@lacspace/date/styles.css";
2697
+ import "../lacspace-ui.css";
2698
+
2699
+ // Scoped to this route; move these imports to app/layout.tsx to use the kit
2700
+ // everywhere. Order matters: lacspace-ui.css maps this app's tokens onto the
2701
+ // kit, so it comes last.
2702
+ export default function InsightsLayout({ children }: { children: React.ReactNode }) {
2703
+ return <>{children}</>;
2704
+ }
2705
+ `;
2706
+ var dataVizPage = () => `"use client";
2707
+ import { useState } from "react";
2708
+ import { Heading, Grid, Stack, Stat, Text } from "@lacspace/components";
2709
+ import { LineChart } from "@lacspace/charts";
2710
+ import { DataTable, textColumn, badgeColumn, currencyColumn, numberColumn } from "@lacspace/table";
2711
+ import { DateRangePicker, defaultPresets } from "@lacspace/date";
2712
+
2713
+ // Swap these three arrays for your own data \u2014 nothing else needs to change.
2714
+ const MONTHS = ["Apr", "May", "Jun", "Jul", "Aug", "Sep"];
2715
+ const REVENUE = [18, 21, 25, 24, 31, 38];
2716
+ const TARGET = [20, 22, 24, 26, 28, 30];
2717
+
2718
+ type Account = {
2719
+ id: string;
2720
+ account: string;
2721
+ plan: string;
2722
+ seats: number;
2723
+ mrr: number;
2724
+ };
2725
+
2726
+ const ACCOUNTS: Account[] = [
2727
+ { id: "1", account: "Northwind", plan: "team", seats: 42, mrr: 1890 },
2728
+ { id: "2", account: "Umbrella", plan: "pro", seats: 12, mrr: 540 },
2729
+ { id: "3", account: "Initech", plan: "team", seats: 68, mrr: 3060 },
2730
+ { id: "4", account: "Hooli", plan: "free", seats: 3, mrr: 0 },
2731
+ { id: "5", account: "Stark Industries", plan: "pro", seats: 19, mrr: 855 },
2732
+ { id: "6", account: "Wayne Enterprises", plan: "team", seats: 51, mrr: 2295 },
2442
2733
  ];
2734
+
2735
+ export default function InsightsPage() {
2736
+ const [range, setRange] = useState<unknown>(null);
2737
+
2738
+ return (
2739
+ <main className="mx-auto max-w-5xl px-6 py-16">
2740
+ <Stack gap={5}>
2741
+ <Stack direction="row" justify="between" align="center" gap={3} wrap>
2742
+ <div>
2743
+ <Heading level={1}>Insights</Heading>
2744
+ <Text tone="muted">Charts, a data table and a date filter \u2014 all zero-dependency.</Text>
2745
+ </div>
2746
+ <DateRangePicker
2747
+ numberOfMonths={2}
2748
+ presets={defaultPresets()}
2749
+ separator=" \u2013 "
2750
+ onChange={setRange}
2751
+ />
2752
+ </Stack>
2753
+
2754
+ <Grid columns={{ base: 1, md: 3 }} gap={3}>
2755
+ <Stat label="MRR" value="$8,640" delta={12.4} comparison="vs last month" />
2756
+ <Stat label="Seats" value="195" delta={6.1} comparison="vs last month" />
2757
+ <Stat label="Churn" value="1.8%" delta={-0.3} invertDelta comparison="vs last month" />
2758
+ </Grid>
2759
+
2760
+ <LineChart
2761
+ labels={MONTHS}
2762
+ series={[
2763
+ { name: "Revenue", data: REVENUE, area: true },
2764
+ { name: "Target", data: TARGET, dashed: true },
2765
+ ]}
2766
+ curve
2767
+ dots
2768
+ tooltip
2769
+ responsive
2770
+ dataTable
2771
+ formatValue={(n) => "$" + n + "k"}
2772
+ />
2773
+
2774
+ <DataTable<Account>
2775
+ caption="Accounts"
2776
+ data={ACCOUNTS}
2777
+ getRowId={(row) => row.id}
2778
+ columns={[
2779
+ textColumn<Account>("account", { header: "Account", key: "account", pinned: "left" }),
2780
+ badgeColumn<Account>("plan", {
2781
+ header: "Plan",
2782
+ key: "plan",
2783
+ tones: { team: "success", pro: "info", free: "default" },
2784
+ }),
2785
+ numberColumn<Account>("seats", { header: "Seats", key: "seats", aggregate: "sum" }),
2786
+ currencyColumn<Account>("mrr", { header: "MRR", key: "mrr", currency: "USD", aggregate: "sum" }),
2787
+ ]}
2788
+ defaultSort={[{ id: "mrr", direction: "desc" }]}
2789
+ searchable
2790
+ selectable
2791
+ exportable
2792
+ stickyHeader
2793
+ />
2794
+ </Stack>
2795
+ </main>
2796
+ );
2797
+ }
2798
+ `;
2443
2799
  var aiChatRoute = (_ctx) => `import { resolveConfig } from "@lacspace/providers";
2444
2800
  import { stream } from "@lacspace/ai";
2445
2801
  import type { Message } from "@lacspace/ai";
@@ -8018,9 +8374,24 @@ function backendFiles(ctx) {
8018
8374
  }
8019
8375
  return files;
8020
8376
  }
8377
+ function cliVersion() {
8378
+ try {
8379
+ const here = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('lib.cjs', document.baseURI).href))));
8380
+ for (const rel of ["../package.json", "./package.json", "../../package.json"]) {
8381
+ const file = path.resolve(here, rel);
8382
+ if (!fs.existsSync(file)) continue;
8383
+ const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
8384
+ const version = parsed.version;
8385
+ const name = parsed.name;
8386
+ if (typeof version === "string" && (name === "create-lacspace-app" || rel !== "../../package.json")) return version;
8387
+ }
8388
+ } catch {
8389
+ }
8390
+ return "unknown";
8391
+ }
8021
8392
  var splitList = (s) => s.split(",").map((x) => x.trim()).filter(Boolean);
8022
8393
  function parseArgs(list) {
8023
- const a = { features: [], yes: false, install: true, git: true, pm: "npm", help: false, dryRun: false };
8394
+ const a = { features: [], yes: false, install: true, git: true, pm: "npm", help: false, version: false, dryRun: false, unknown: [] };
8024
8395
  for (let i = 0; i < list.length; i++) {
8025
8396
  const arg = list[i];
8026
8397
  const next = () => list[++i] ?? "";
@@ -8043,6 +8414,7 @@ function parseArgs(list) {
8043
8414
  } else if (arg === "--recipe") a.recipe = next();
8044
8415
  else if (arg.startsWith("--recipe=")) a.recipe = arg.slice(9);
8045
8416
  else if (arg === "-h" || arg === "--help") a.help = true;
8417
+ else if (arg === "-v" || arg === "-V" || arg === "--version") a.version = true;
8046
8418
  else if (arg.startsWith("--template=")) a.template = arg.slice(11);
8047
8419
  else if (arg.startsWith("--theme=")) a.theme = arg.slice(8);
8048
8420
  else if (arg.startsWith("--accent=")) a.theme = arg.slice(9);
@@ -8050,6 +8422,7 @@ function parseArgs(list) {
8050
8422
  else if (arg.startsWith("--with=")) a.features.push(...splitList(arg.slice(7)));
8051
8423
  else if (arg.startsWith("--features=")) a.features.push(...splitList(arg.slice(11)));
8052
8424
  else if (!arg.startsWith("-") && !a.name) a.name = arg;
8425
+ else if (arg.startsWith("-")) a.unknown.push(arg);
8053
8426
  }
8054
8427
  return a;
8055
8428
  }
@@ -8157,6 +8530,7 @@ ${c("bold", "Options")}
8157
8530
  --no-git Skip git init
8158
8531
  -y, --yes Accept defaults (needs <name>)
8159
8532
  -h, --help Show this help
8533
+ -v, --version Print the version and exit
8160
8534
 
8161
8535
  ${c("bold", "Feature add-ons")} ${c("dim", "(--with) \u2014 free & keyless, local by default")}
8162
8536
  ${FEATURES.map((f) => ` ${f.key.padEnd(11)} ${f.description}`).join("\n")}
@@ -8630,6 +9004,16 @@ async function main() {
8630
9004
  process$1.stdout.write(HELP + "\n");
8631
9005
  return;
8632
9006
  }
9007
+ if (args.version) {
9008
+ process$1.stdout.write(`create-lacspace-app ${cliVersion()}
9009
+ `);
9010
+ return;
9011
+ }
9012
+ if (args.unknown.length) {
9013
+ process$1.stdout.write(c("yellow", `
9014
+ ! Unknown option${args.unknown.length > 1 ? "s" : ""}: ${args.unknown.join(", ")} \u2014 ignoring. Run with --help to see every flag.
9015
+ `));
9016
+ }
8633
9017
  process$1.stdout.write(`
8634
9018
  ${c("bold", c("magenta", "\u25C6 create-lacspace-app"))} ${c("dim", "\u2014 a gorgeous Next.js starter, batteries wired")}
8635
9019
 
@@ -8828,8 +9212,18 @@ ${c("bold", "Your feature add-ons")} ${c("dim", "\u2014 details in LEARN.md")}
8828
9212
 
8829
9213
  `);
8830
9214
  }
8831
- var invokedAsCli = process$1.argv[1] ? (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('lib.cjs', document.baseURI).href)) === url.pathToFileURL(process$1.argv[1]).href : false;
8832
- if (invokedAsCli) {
9215
+ function isDirectRun() {
9216
+ const entry = process$1.argv[1];
9217
+ if (!entry) return false;
9218
+ const here = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('lib.cjs', document.baseURI).href));
9219
+ if (here === url.pathToFileURL(entry).href) return true;
9220
+ try {
9221
+ if (here === url.pathToFileURL(fs.realpathSync(entry)).href) return true;
9222
+ } catch {
9223
+ }
9224
+ return path.basename(entry).replace(/\.[cm]?js$/, "") === "create-lacspace-app";
9225
+ }
9226
+ if (isDirectRun()) {
8833
9227
  main().catch((err) => {
8834
9228
  process$1.stdout.write(c("red", `
8835
9229
  \u2717 ${err instanceof Error ? err.message : String(err)}