shapes-ui 0.5.0 → 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.
Files changed (83) hide show
  1. package/.github/workflows/pr-preview.yml +9 -2
  2. package/CHANGELOG.md +11 -0
  3. package/README.md +13 -0
  4. package/content/components/accordion.mdx +13 -0
  5. package/content/components/alert-dialog.mdx +34 -0
  6. package/content/components/autocomplete.mdx +62 -0
  7. package/content/components/avatar.mdx +11 -0
  8. package/content/components/button.mdx +8 -0
  9. package/content/components/checkbox.mdx +11 -0
  10. package/content/components/collapsible.mdx +11 -0
  11. package/content/components/combobox.mdx +33 -0
  12. package/content/components/context-menu.mdx +29 -0
  13. package/content/components/dialog.mdx +33 -0
  14. package/content/components/drawer.mdx +38 -0
  15. package/content/components/field.mdx +21 -0
  16. package/content/components/fieldset.mdx +10 -0
  17. package/content/components/form.mdx +8 -0
  18. package/content/components/input.mdx +4 -0
  19. package/content/components/menu.mdx +27 -0
  20. package/content/components/menubar.mdx +31 -0
  21. package/content/components/meter.mdx +14 -0
  22. package/content/components/navigation-menu.mdx +28 -0
  23. package/content/components/number-field.mdx +25 -0
  24. package/content/components/popover.mdx +22 -0
  25. package/content/components/preview-card.mdx +14 -2
  26. package/content/components/progress.mdx +15 -1
  27. package/content/components/radio.mdx +11 -0
  28. package/content/components/scroll-area.mdx +23 -0
  29. package/content/components/select.mdx +27 -0
  30. package/content/components/separator.mdx +29 -0
  31. package/content/components/slider.mdx +4 -0
  32. package/content/components/switch.mdx +4 -0
  33. package/content/components/tabs.mdx +15 -0
  34. package/content/components/toast.mdx +10 -0
  35. package/content/components/toggle-group.mdx +37 -0
  36. package/content/components/toggle.mdx +12 -0
  37. package/content/components/toolbar.mdx +22 -0
  38. package/content/components/tooltip.mdx +13 -0
  39. package/content/docs/installation.mdx +30 -0
  40. package/content-collections.ts +65 -1
  41. package/dist/cli.js +947 -101
  42. package/examples/__index.tsx +136 -68
  43. package/examples/autocomplete-align.tsx +39 -0
  44. package/examples/autocomplete-controlled.tsx +44 -0
  45. package/examples/autocomplete-groups.tsx +65 -0
  46. package/examples/autocomplete-no-clear.tsx +40 -0
  47. package/examples/avatar-demo.tsx +3 -3
  48. package/examples/input-group-with-button.tsx +1 -1
  49. package/examples/separator-demo.tsx +13 -0
  50. package/examples/separator-horizontal.tsx +18 -0
  51. package/package.json +19 -18
  52. package/public/base-ui.svg +1 -0
  53. package/src/assets/base-ui.svg +1 -0
  54. package/src/commands/add.ts +79 -38
  55. package/src/commands/cli.ts +50 -3
  56. package/src/commands/create.ts +262 -0
  57. package/src/commands/init.ts +45 -12
  58. package/src/commands/palette.ts +55 -0
  59. package/src/components/docs/layout/footer.tsx +2 -2
  60. package/src/components/docs/layout/header.tsx +7 -9
  61. package/src/components/docs/layout/mobile-menu.tsx +0 -1
  62. package/src/components/docs/layout/nav-list.tsx +2 -2
  63. package/src/components/docs/layout/page-header.tsx +52 -7
  64. package/src/components/docs/layout/split-layout.tsx +9 -10
  65. package/src/components/docs/layout/table-of-content.tsx +145 -0
  66. package/src/components/docs/markdown/components.tsx +142 -29
  67. package/src/components/docs/markdown/copy-button.tsx +41 -0
  68. package/src/components/docs/markdown/installation-block.tsx +5 -24
  69. package/src/components/docs/markdown/render-preview.tsx +1 -1
  70. package/src/components/ui/button-group.tsx +1 -1
  71. package/src/components/ui/scroll-area.tsx +11 -2
  72. package/src/lib/docs-headings.ts +72 -0
  73. package/src/routeTree.gen.ts +60 -3
  74. package/src/routes/__root.tsx +2 -2
  75. package/src/routes/components.$slug.tsx +20 -4
  76. package/src/routes/docs.$slug.tsx +78 -0
  77. package/src/routes/docs.tsx +15 -0
  78. package/src/styles/styles.css +1 -1
  79. package/src/utils/cli-utils.ts +8 -8
  80. package/src/utils/dependency-installer.ts +30 -0
  81. package/src/utils/package-manager.ts +4 -4
  82. package/src/utils/palette.ts +666 -0
  83. package/src/utils/schema.ts +6 -0
@@ -0,0 +1,78 @@
1
+ import { MDXContent } from "@content-collections/mdx/react";
2
+ import { createFileRoute, notFound } from "@tanstack/react-router";
3
+ import { allDocs } from "content-collections";
4
+ import { useEffect, useState } from "react";
5
+
6
+ import { PageHeader } from "@/components/docs/layout/page-header";
7
+ import { mdxComponents } from "@/components/docs/markdown/components";
8
+ import { RenderPreview } from "@/components/docs/markdown/render-preview";
9
+
10
+ const markdownFiles = import.meta.glob("../../content/docs/*.mdx", {
11
+ query: "?url",
12
+ import: "default",
13
+ eager: true,
14
+ }) as Record<string, string>;
15
+
16
+ export const Route = createFileRoute("/docs/$slug")({
17
+ loader: ({ params }) => {
18
+ const { slug } = params;
19
+ const doc = allDocs?.find((d) => d.slug === slug);
20
+
21
+ if (!doc) {
22
+ throw notFound();
23
+ }
24
+
25
+ const markdownLink = markdownFiles[`../../content/docs/${doc.slug}.mdx`];
26
+
27
+ return {
28
+ ...doc,
29
+ markdownLink,
30
+ };
31
+ },
32
+ head: ({ loaderData }) => ({
33
+ meta: [
34
+ {
35
+ charSet: "utf-8",
36
+ },
37
+ {
38
+ name: "viewport",
39
+ content: "width=device-width, initial-scale=1",
40
+ },
41
+ {
42
+ title: `${loaderData?.title} - Shapes UI`,
43
+ },
44
+ ],
45
+ links: [
46
+ {
47
+ rel: "icon",
48
+ href: "/favicon.ico",
49
+ },
50
+ ],
51
+ }),
52
+ component: RouteComponent,
53
+ });
54
+
55
+ function RouteComponent() {
56
+ const doc = Route.useLoaderData();
57
+ const [isMounted, setIsMounted] = useState(false);
58
+
59
+ useEffect(() => {
60
+ setIsMounted(true);
61
+ }, []);
62
+
63
+ return (
64
+ <div className=" flex flex-col gap-6 ">
65
+ <PageHeader
66
+ title={doc?.title}
67
+ subtitle={doc?.description}
68
+ baseUILink={doc?.referenceLink}
69
+ markdownLink={doc?.markdownLink}
70
+ />
71
+ <div data-docs-content className="container mx-auto max-w-4xl min-w-0 p-6">
72
+ {isMounted ? (
73
+ <MDXContent code={doc.mdx} components={{ ...mdxComponents, RenderPreview }} />
74
+ ) : null}
75
+ </div>
76
+ </div>
77
+ );
78
+ }
@@ -0,0 +1,15 @@
1
+ import { createFileRoute, Outlet } from "@tanstack/react-router";
2
+
3
+ import { SplitLayout } from "@/components/docs/layout/split-layout";
4
+
5
+ export const Route = createFileRoute("/docs")({
6
+ component: RouteComponent,
7
+ });
8
+
9
+ function RouteComponent() {
10
+ return (
11
+ <SplitLayout>
12
+ <Outlet />
13
+ </SplitLayout>
14
+ );
15
+ }
@@ -15,7 +15,7 @@
15
15
  --secondary: oklch(0.97 0 0);
16
16
  --secondary-foreground: oklch(0.205 0 0);
17
17
  --muted: oklch(0.97 0 0);
18
- --muted-foreground: oklch(0.556 0 0);
18
+ --muted-foreground: oklch(55.553% 0.00006 271.152);
19
19
  --accent: oklch(0.97 0 0);
20
20
  --accent-foreground: oklch(0.205 0 0);
21
21
  --destructive: oklch(57.7% 0.245 27.325);
@@ -13,14 +13,14 @@ export function exitIfCancelled<T>(value: T): Exclude<T, symbol> {
13
13
  return value as Exclude<T, symbol>;
14
14
  }
15
15
 
16
- export async function getConfig(): Promise<Config | null> {
17
- const configPath = path.join(process.cwd(), "shapes.json");
16
+ export async function getConfig(cwd = process.cwd()): Promise<Config | null> {
17
+ const configPath = path.join(cwd, "shapes.json");
18
18
  if (!fs.existsSync(configPath)) return null;
19
19
  return configSchema.parse(await fs.readJSON(configPath));
20
20
  }
21
21
 
22
- export async function readPackageJson() {
23
- const pkgPath = path.join(process.cwd(), "package.json");
22
+ export async function readPackageJson(cwd = process.cwd()) {
23
+ const pkgPath = path.join(cwd, "package.json");
24
24
  if (!(await fs.pathExists(pkgPath))) return null;
25
25
  return fs.readJSON(pkgPath);
26
26
  }
@@ -45,10 +45,10 @@ export function getMissingDeps(pkg: Record<string, any> | null, deps: string[])
45
45
  return deps.filter((dep) => !pkg.dependencies?.[dep] && !pkg.devDependencies?.[dep]);
46
46
  }
47
47
 
48
- export async function isViteProject() {
49
- const viteConfigTs = path.join(process.cwd(), "vite.config.ts");
50
- const viteConfigJs = path.join(process.cwd(), "vite.config.js");
51
- const viteConfigMjs = path.join(process.cwd(), "vite.config.mjs");
48
+ export async function isViteProject(cwd = process.cwd()) {
49
+ const viteConfigTs = path.join(cwd, "vite.config.ts");
50
+ const viteConfigJs = path.join(cwd, "vite.config.js");
51
+ const viteConfigMjs = path.join(cwd, "vite.config.mjs");
52
52
 
53
53
  return (
54
54
  (await fs.pathExists(viteConfigTs)) ||
@@ -0,0 +1,30 @@
1
+ import { spinner } from "@clack/prompts";
2
+ import { execa } from "execa";
3
+
4
+ import { getInstallCommand } from "@/utils/package-manager";
5
+
6
+ type InstallDependenciesOptions = {
7
+ dev?: boolean;
8
+ label?: string;
9
+ successMessage?: string;
10
+ cwd?: string;
11
+ };
12
+
13
+ export async function installDependencies(
14
+ deps: string[],
15
+ options: InstallDependenciesOptions = {},
16
+ ) {
17
+ if (!deps.length) return;
18
+
19
+ const spin = spinner();
20
+ const label =
21
+ options.label ?? (options.dev ? "Installing dev dependencies" : "Installing dependencies");
22
+
23
+ spin.start(label);
24
+
25
+ const cwd = options.cwd ?? process.cwd();
26
+ const [command, ...args] = await getInstallCommand(deps, options.dev ?? false, cwd);
27
+ await execa(command, args, { cwd });
28
+
29
+ spin.stop(options.successMessage ?? "Dependencies installed");
30
+ }
@@ -1,15 +1,15 @@
1
1
  import { detect } from "detect-package-manager";
2
2
 
3
- export async function getPackageManager() {
3
+ export async function getPackageManager(cwd = process.cwd()) {
4
4
  try {
5
- return await detect();
5
+ return await detect({ cwd });
6
6
  } catch {
7
7
  return "npm";
8
8
  }
9
9
  }
10
10
 
11
- export async function getInstallCommand(deps: string[], dev = false) {
12
- const pm = await getPackageManager();
11
+ export async function getInstallCommand(deps: string[], dev = false, cwd = process.cwd()) {
12
+ const pm = await getPackageManager(cwd);
13
13
 
14
14
  if (pm === "yarn") {
15
15
  return ["yarn", "add", ...(dev ? ["-D"] : []), ...deps];