@squidflare/squidui 0.0.0-stage → 0.0.1

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.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { join, relative, resolve, isAbsolute } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ const registryRoot = fileURLToPath(new URL("../registry/", import.meta.url));
6
+ const registry = JSON.parse(readFileSync(join(registryRoot, "manifest.json"), "utf8"));
7
+ const utilityFile = "squidui-utils.ts";
8
+ const args = process.argv.slice(2);
9
+ const command = args[0];
10
+ const valueFlags = new Set(["--dir", "--root"]);
11
+ function flag(name) {
12
+ const index = args.indexOf(name);
13
+ return index >= 0 ? args[index + 1] : undefined;
14
+ }
15
+ function fail(message) {
16
+ console.error(`squidui: ${message}`);
17
+ process.exit(1);
18
+ }
19
+ function jsonMode() { return args.includes("--json"); }
20
+ function projectRoot() { return resolve(flag("--root") ?? process.cwd()); }
21
+ function destination(root) {
22
+ const target = resolve(root, flag("--dir") ?? "src/components/ui");
23
+ const outside = relative(root, target);
24
+ if (outside === ".." || outside.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || isAbsolute(outside))
25
+ fail("--dir precisa permanecer dentro da raiz do projeto");
26
+ return target;
27
+ }
28
+ function componentNames() {
29
+ const names = [];
30
+ for (let index = 1; index < args.length; index += 1) {
31
+ const current = args[index];
32
+ if (current.startsWith("--")) {
33
+ if (valueFlags.has(current))
34
+ index += 1;
35
+ continue;
36
+ }
37
+ names.push(current);
38
+ }
39
+ return names;
40
+ }
41
+ function entries(names) {
42
+ if (names.length === 0)
43
+ fail("informe pelo menos um componente");
44
+ return names.map((name) => {
45
+ const entry = registry[name];
46
+ if (!entry)
47
+ fail(`componente desconhecido: ${name}`);
48
+ return [name, entry];
49
+ });
50
+ }
51
+ function runAdd(root) {
52
+ const targetDirectory = destination(root);
53
+ const force = args.includes("--force");
54
+ const dryRun = args.includes("--dry-run");
55
+ const selected = entries(componentNames());
56
+ const changes = [...selected.map(([name, entry]) => ({ name, target: join(targetDirectory, entry.file), exists: existsSync(join(targetDirectory, entry.file)) })), { name: "squidui-utils", target: join(targetDirectory, utilityFile), exists: existsSync(join(targetDirectory, utilityFile)) }];
57
+ const conflict = changes.find((change) => change.name !== "squidui-utils" && change.exists && !force);
58
+ if (conflict)
59
+ fail(`arquivo já existe: ${conflict.target}; use --force após revisar o diff`);
60
+ if (jsonMode())
61
+ console.log(JSON.stringify({ command: "add", dryRun, changes }, null, 2));
62
+ else
63
+ changes.forEach((change) => console.log(`${dryRun ? "create" : "created"} ${change.target}`));
64
+ if (dryRun)
65
+ return;
66
+ mkdirSync(targetDirectory, { recursive: true });
67
+ selected.forEach(([, entry]) => writeFileSync(join(targetDirectory, entry.file), readFileSync(join(registryRoot, entry.file), "utf8"), "utf8"));
68
+ if (!existsSync(join(targetDirectory, utilityFile)) || force)
69
+ writeFileSync(join(targetDirectory, utilityFile), readFileSync(join(registryRoot, utilityFile), "utf8"), "utf8");
70
+ }
71
+ function runInit(root) {
72
+ const config = join(root, "squidui.config.json");
73
+ if (existsSync(config) && !args.includes("--force"))
74
+ fail(`configuração já existe: ${config}`);
75
+ const content = `${JSON.stringify({ componentDir: "src/components/ui", registryVersion: 1 }, null, 2)}\n`;
76
+ if (!args.includes("--dry-run"))
77
+ writeFileSync(config, content, "utf8");
78
+ console.log(`${args.includes("--dry-run") ? "create" : "created"} ${config}`);
79
+ }
80
+ function runList() {
81
+ const components = Object.keys(registry);
82
+ console.log(jsonMode() ? JSON.stringify({ components }, null, 2) : components.join("\n"));
83
+ }
84
+ function runDiff(root) {
85
+ const targetDirectory = destination(root);
86
+ const changes = entries(componentNames()).map(([name, entry]) => ({ name, path: join(targetDirectory, entry.file), status: existsSync(join(targetDirectory, entry.file)) ? "present" : "missing" }));
87
+ console.log(jsonMode() ? JSON.stringify({ command: "diff", changes }, null, 2) : changes.map((change) => `${change.status}\t${change.path}`).join("\n"));
88
+ }
89
+ function runDoctor(root) {
90
+ const packageJson = existsSync(join(root, "package.json"));
91
+ const report = { root, packageJson, node: process.versions.node, registryComponents: Object.keys(registry).length, ok: packageJson };
92
+ console.log(jsonMode() ? JSON.stringify(report, null, 2) : [`root: ${root}`, `package.json: ${packageJson ? "found" : "missing"}`, `node: ${process.versions.node}`, `registry components: ${report.registryComponents}`, `status: ${report.ok ? "ok" : "error"}`].join("\n"));
93
+ if (!report.ok)
94
+ process.exitCode = 1;
95
+ }
96
+ const root = projectRoot();
97
+ switch (command) {
98
+ case "add":
99
+ runAdd(root);
100
+ break;
101
+ case "init":
102
+ runInit(root);
103
+ break;
104
+ case "list":
105
+ runList();
106
+ break;
107
+ case "diff":
108
+ runDiff(root);
109
+ break;
110
+ case "doctor":
111
+ runDoctor(root);
112
+ break;
113
+ default: fail("use: init | add <component...> | list | diff <component...> | doctor");
114
+ }
package/package.json CHANGED
@@ -1,6 +1,22 @@
1
1
  {
2
2
  "name": "@squidflare/squidui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.1",
4
+ "description": "Copy-source CLI for installing SquidUI components",
5
+ "type": "module",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "bin": {
10
+ "squidui": "dist/index.js"
11
+ },
12
+ "files": [
13
+ "dist/index.js",
14
+ "dist/index.d.ts",
15
+ "dist/index.d.ts.map",
16
+ "registry"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc -p tsconfig.json",
20
+ "typecheck": "tsc -p tsconfig.json --noEmit"
21
+ }
6
22
  }
@@ -0,0 +1,4 @@
1
+ import type { HTMLAttributes } from "react";
2
+ import { cn } from "./squidui-utils";
3
+ export type AlertProps = HTMLAttributes<HTMLDivElement> & { variant?: "default" | "destructive"; title?: string };
4
+ export function Alert({ className = "", variant = "default", title, children, ...props }: AlertProps) { return <div role="alert" className={cn("rounded-lg border p-4 text-sm", variant === "destructive" ? "border-squid-destructive/50 text-squid-destructive" : "border-squid-border bg-squid-card text-squid-card-foreground", className)} {...props}>{title && <h3 className="mb-1 font-medium">{title}</h3>}{children}</div>; }
@@ -0,0 +1,4 @@
1
+ import type { HTMLAttributes, ReactNode } from "react";
2
+ import { cn } from "./squidui-utils";
3
+ export type AvatarProps = HTMLAttributes<HTMLSpanElement> & { src?: string; alt?: string; fallback?: ReactNode };
4
+ export function Avatar({ className = "", src, alt = "", fallback, children, ...props }: AvatarProps) { return <span className={cn("relative flex size-10 overflow-hidden rounded-full bg-squid-muted", className)} {...props}>{src ? <img className="size-full object-cover" src={src} alt={alt} /> : <span className="flex size-full items-center justify-center text-sm font-medium">{fallback ?? children}</span>}</span>; }
@@ -0,0 +1,4 @@
1
+ import type { HTMLAttributes } from "react";
2
+ import { cn } from "./squidui-utils";
3
+ export type BadgeProps = HTMLAttributes<HTMLSpanElement> & { variant?: "default" | "secondary" | "outline" | "destructive" };
4
+ export function Badge({ className = "", variant = "default", ...props }: BadgeProps) { const styles = { default: "bg-squid-primary text-squid-primary-foreground", secondary: "bg-squid-secondary text-squid-secondary-foreground", outline: "border border-squid-border", destructive: "bg-squid-destructive text-squid-destructive-foreground" }; return <span className={cn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium", styles[variant], className)} {...props} />; }
@@ -0,0 +1,11 @@
1
+ import type { ButtonHTMLAttributes, ReactNode } from "react";
2
+ import { cn } from "./squidui-utils";
3
+
4
+ export type ButtonVariant = "primary" | "secondary" | "outline" | "ghost" | "destructive";
5
+ export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & { variant?: ButtonVariant; loading?: boolean; children?: ReactNode };
6
+
7
+ const variants: Record<ButtonVariant, string> = { primary: "bg-squid-primary text-squid-primary-foreground hover:bg-squid-primary/90", secondary: "bg-squid-secondary text-squid-secondary-foreground hover:bg-squid-secondary/80", outline: "border-squid-border bg-transparent text-squid-foreground hover:bg-squid-muted", ghost: "border-transparent bg-transparent text-squid-foreground hover:bg-squid-muted", destructive: "border-squid-destructive bg-squid-destructive text-squid-destructive-foreground hover:bg-squid-destructive/90" };
8
+
9
+ export function Button({ variant = "primary", loading = false, disabled, children, className, ...props }: ButtonProps) {
10
+ return <button type="button" data-squid-variant={variant} aria-busy={loading || undefined} disabled={disabled || loading} className={cn("inline-flex min-h-10 items-center justify-center whitespace-nowrap rounded-md border px-4 py-2 text-sm font-medium transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-squid-ring disabled:pointer-events-none disabled:opacity-50", variants[variant], className)} {...props}>{loading ? "Loading…" : children}</button>;
11
+ }
@@ -0,0 +1,8 @@
1
+ import type { HTMLAttributes, ReactNode } from "react";
2
+ import { cn } from "./squidui-utils";
3
+
4
+ export type CardProps = HTMLAttributes<HTMLElement> & { children?: ReactNode };
5
+
6
+ export function Card({ children, className, ...props }: CardProps) {
7
+ return <section className={cn("rounded-lg border border-squid-border bg-squid-surface p-4 text-squid-foreground", className)} {...props}>{children}</section>;
8
+ }
@@ -0,0 +1,4 @@
1
+ import type { InputHTMLAttributes } from "react";
2
+ import { cn } from "./squidui-utils";
3
+ export type CheckboxProps = Omit<InputHTMLAttributes<HTMLInputElement>, "type">;
4
+ export function Checkbox({ className = "", ...props }: CheckboxProps) { return <input type="checkbox" className={cn("size-4 rounded border-squid-border accent-squid-primary focus-visible:outline-2", className)} {...props} />; }
@@ -0,0 +1,4 @@
1
+ import { useState, type ReactNode } from "react";
2
+ import { cn } from "./squidui-utils";
3
+ export type DialogProps = { className?: string; trigger?: ReactNode; title: string; description?: string; children?: ReactNode; defaultOpen?: boolean };
4
+ export function Dialog({ className, trigger, title, description, children, defaultOpen = false }: DialogProps) { const [open, setOpen] = useState(defaultOpen); return <>{trigger && <span onClick={() => setOpen(true)}>{trigger}</span>}{open && <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4" onMouseDown={() => setOpen(false)}><div role="dialog" aria-modal="true" className={cn("w-full max-w-lg rounded-lg border bg-squid-background p-6", className)} onMouseDown={(event) => event.stopPropagation()}><h2 className="text-lg font-semibold">{title}</h2>{description && <p className="mt-1 text-sm text-squid-muted-foreground">{description}</p>}<div className="mt-4">{children}</div><button type="button" className="absolute" aria-label="Close dialog" onClick={() => setOpen(false)}>×</button></div></div>}</>; }
@@ -0,0 +1,8 @@
1
+ import type { InputHTMLAttributes } from "react";
2
+ import { cn } from "./squidui-utils";
3
+
4
+ export type InputProps = InputHTMLAttributes<HTMLInputElement> & { invalid?: boolean };
5
+
6
+ export function Input({ invalid = false, className, ...props }: InputProps) {
7
+ return <input aria-invalid={invalid || undefined} data-squid-invalid={invalid || undefined} className={cn("flex min-h-10 w-full rounded-md border border-squid-border bg-squid-background px-3 py-2 text-sm text-squid-foreground outline-none transition-colors placeholder:text-squid-muted-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-squid-ring disabled:cursor-not-allowed disabled:opacity-50", invalid && "border-squid-destructive", className)} {...props} />;
8
+ }
@@ -0,0 +1,8 @@
1
+ import type { LabelHTMLAttributes, ReactNode } from "react";
2
+ import { cn } from "./squidui-utils";
3
+
4
+ export type LabelProps = LabelHTMLAttributes<HTMLLabelElement> & { children?: ReactNode };
5
+
6
+ export function Label({ children, className, ...props }: LabelProps) {
7
+ return <label className={cn("text-sm font-medium leading-none text-squid-foreground", className)} {...props}>{children}</label>;
8
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "button": { "file": "button.tsx", "platform": "web", "version": 1 },
3
+ "input": { "file": "input.tsx", "platform": "web", "version": 1 },
4
+ "label": { "file": "label.tsx", "platform": "web", "version": 1 },
5
+ "card": { "file": "card.tsx", "platform": "web", "version": 1 },
6
+ "badge": { "file": "badge.tsx", "platform": "web", "version": 1 },
7
+ "avatar": { "file": "avatar.tsx", "platform": "web", "version": 1 },
8
+ "checkbox": { "file": "checkbox.tsx", "platform": "web", "version": 1 },
9
+ "switch": { "file": "switch.tsx", "platform": "web", "version": 1 },
10
+ "separator": { "file": "separator.tsx", "platform": "web", "version": 1 },
11
+ "skeleton": { "file": "skeleton.tsx", "platform": "web", "version": 1 },
12
+ "alert": { "file": "alert.tsx", "platform": "web", "version": 1 },
13
+ "tooltip": { "file": "tooltip.tsx", "platform": "web", "version": 1 },
14
+ "tabs": { "file": "tabs.tsx", "platform": "web", "version": 1 },
15
+ "dialog": { "file": "dialog.tsx", "platform": "web", "version": 1 }
16
+ }
@@ -0,0 +1,4 @@
1
+ import type { HTMLAttributes } from "react";
2
+ import { cn } from "./squidui-utils";
3
+ export type SeparatorProps = HTMLAttributes<HTMLDivElement> & { orientation?: "horizontal" | "vertical" };
4
+ export function Separator({ className = "", orientation = "horizontal", ...props }: SeparatorProps) { return <div role="separator" aria-orientation={orientation} className={cn(orientation === "horizontal" ? "h-px w-full" : "h-full w-px", "shrink-0 bg-squid-border", className)} {...props} />; }
@@ -0,0 +1,4 @@
1
+ import type { HTMLAttributes } from "react";
2
+ import { cn } from "./squidui-utils";
3
+ export type SkeletonProps = HTMLAttributes<HTMLDivElement>;
4
+ export function Skeleton({ className = "", ...props }: SkeletonProps) { return <div aria-hidden="true" className={cn("animate-pulse rounded-md bg-squid-muted", className)} {...props} />; }
@@ -0,0 +1,19 @@
1
+ export type ClassValue = string | false | null | undefined;
2
+
3
+ const conflictGroups = [/^bg-/, /^text-/, /^border(?:-|$)/, /^rounded(?:-|$)/, /^p[trblxyse]?-/ , /^m[trblxyse]?-/ , /^h-/, /^w-/, /^min-h-/, /^min-w-/, /^max-h-/, /^max-w-/, /^flex(?:-|$)/, /^items-/, /^justify-/, /^gap-/];
4
+
5
+ function conflictKey(token: string): string | undefined {
6
+ const normalized = token.replace(/^(?:hover|focus|focus-visible|active|disabled|dark|sm|md|lg|xl):/, "");
7
+ return conflictGroups.find((pattern) => pattern.test(normalized))?.source;
8
+ }
9
+
10
+ export function cn(...classes: ClassValue[]) {
11
+ const output: string[] = [];
12
+ const indexes = new Map<string, number>();
13
+ for (const value of classes) for (const token of value?.split(/\s+/).filter(Boolean) ?? []) {
14
+ const key = conflictKey(token);
15
+ if (key && indexes.has(key)) output[indexes.get(key)!] = token;
16
+ else { if (key) indexes.set(key, output.length); output.push(token); }
17
+ }
18
+ return output.join(" ");
19
+ }
@@ -0,0 +1,4 @@
1
+ import { useState, type ButtonHTMLAttributes } from "react";
2
+ import { cn } from "./squidui-utils";
3
+ export type SwitchProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onChange"> & { checked?: boolean; defaultChecked?: boolean; onCheckedChange?: (checked: boolean) => void };
4
+ export function Switch({ className = "", checked, defaultChecked = false, onCheckedChange, ...props }: SwitchProps) { const [internal, setInternal] = useState(defaultChecked); const value = checked ?? internal; return <button type="button" role="switch" aria-checked={value} className={cn("inline-flex h-6 w-11 items-center rounded-full bg-squid-muted p-0.5", value && "bg-squid-primary", className)} onClick={() => { const next = !value; if (checked === undefined) setInternal(next); onCheckedChange?.(next); }} {...props}><span className={cn("size-5 rounded-full bg-white transition-transform", value && "translate-x-5")} /></button>; }
@@ -0,0 +1,5 @@
1
+ import { useState, type HTMLAttributes, type ReactNode } from "react";
2
+ import { cn } from "./squidui-utils";
3
+ export type TabItem = { value: string; label: ReactNode; content: ReactNode };
4
+ export type TabsProps = HTMLAttributes<HTMLDivElement> & { items: TabItem[]; defaultValue?: string };
5
+ export function Tabs({ className = "", items, defaultValue, ...props }: TabsProps) { const [value, setValue] = useState(defaultValue ?? items[0]?.value); const active = items.find((item) => item.value === value) ?? items[0]; return <div className={cn(className)} {...props}><div role="tablist" className="inline-flex rounded-md bg-squid-muted p-1">{items.map((item) => <button type="button" role="tab" aria-selected={item.value === active?.value} className="rounded px-3 py-1.5 text-sm" onClick={() => setValue(item.value)} key={item.value}>{item.label}</button>)}</div><div role="tabpanel" className="mt-3">{active?.content}</div></div>; }
@@ -0,0 +1,4 @@
1
+ import type { HTMLAttributes, ReactNode } from "react";
2
+ import { cn } from "./squidui-utils";
3
+ export type TooltipProps = Omit<HTMLAttributes<HTMLSpanElement>, "content"> & { content: ReactNode; children: ReactNode };
4
+ export function Tooltip({ className = "", content, children, ...props }: TooltipProps) { return <span className={cn("group relative inline-flex", className)} {...props}><span tabIndex={0}>{children}</span><span role="tooltip" className="pointer-events-none absolute bottom-full left-1/2 mb-2 -translate-x-1/2 rounded bg-squid-foreground px-2 py-1 text-xs text-squid-background opacity-0 group-hover:opacity-100 group-focus-within:opacity-100">{content}</span></span>; }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.