@becklyn/components 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Becklyn Studios
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @becklyn/components
2
+
3
+ A collection of reusable React components built with TypeScript and SCSS modules. This library provides a shadcn-ui-like experience but uses SCSS modules instead of Tailwind CSS for styling.
4
+
5
+ ## Before using this library
6
+
7
+ This library is designed to be used with Next.js. You won't be able to use all components properly without Next.js.
8
+
9
+ We also add storybook stories to the components. You need to have storybook installed in your project to use them.
10
+
11
+ ## CLI Commands
12
+
13
+ ### `init`
14
+
15
+ Initialize your project with the necessary configuration.
16
+
17
+ ```bash
18
+ npx becklyn-components init [options]
19
+ ```
20
+
21
+ This command will:
22
+
23
+ - Install required dependencies
24
+
25
+ ### `add`
26
+
27
+ Add components to your project by copying them from the library.
28
+
29
+ ```bash
30
+ npx becklyn-components add <component> [component...] [options]
31
+ ```
32
+
33
+ **Options:**
34
+
35
+ - `--components <path>` - Components directory (default: "src/components")
36
+ - `--overwrite` - Overwrite existing files
37
+ - `-y, --yes` - Skip confirmation prompts
38
+
39
+ **Examples:**
40
+
41
+ ```bash
42
+ # Add a single component
43
+ npx becklyn-components add button
44
+
45
+ # Add multiple components
46
+ npx becklyn-components add button card dialog
47
+
48
+ # Specify custom directories
49
+ npx becklyn-components add button --components src/ui
50
+ ```
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../bin/cli.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const commander_1 = require("commander");
5
+ const add_1 = require("../cli/add");
6
+ const init_1 = require("../cli/init");
7
+ const registry_1 = require("../cli/registry");
8
+ commander_1.program
9
+ .name("becklyn-components")
10
+ .description("CLI for @becklyn/components - Add components to your project")
11
+ .version("1.0.0");
12
+ commander_1.program
13
+ .command("init")
14
+ .description("Initialize your project and install dependencies")
15
+ .action(init_1.init);
16
+ commander_1.program
17
+ .command("add")
18
+ .description(`
19
+ Add a component to your project
20
+
21
+ Available components:
22
+ - ${(0, registry_1.getAvailableComponents)().join("\n - ")}
23
+
24
+ Example:
25
+ npx @becklyn/components add Button`)
26
+ .argument("<components...>", "The components to add")
27
+ .option("-y, --yes", "Skip confirmation prompts")
28
+ .option("--overwrite", "Overwrite existing files")
29
+ .option("--components <path>", "Components directory", "components")
30
+ .action(add_1.add);
31
+ commander_1.program.parse();
@@ -0,0 +1,8 @@
1
+ interface AddOptions {
2
+ yes?: boolean;
3
+ overwrite?: boolean;
4
+ components?: string;
5
+ }
6
+ export declare function add(components: string[], options: AddOptions): Promise<void>;
7
+ export {};
8
+ //# sourceMappingURL=add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../cli/add.ts"],"names":[],"mappings":"AAIA,UAAU,UAAU;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAsB,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,iBA+ClE"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.add = add;
46
+ const fs = __importStar(require("fs"));
47
+ const path = __importStar(require("path"));
48
+ const registry_1 = require("./registry");
49
+ function add(components, options) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ console.log(`🔥 Adding components: ${components.join(", ")}\n`);
52
+ const cwd = process.cwd();
53
+ const componentsDir = path.join(cwd, options.components || "components");
54
+ try {
55
+ for (const componentName of components) {
56
+ const componentConfig = (0, registry_1.getComponent)(componentName);
57
+ if (!componentConfig) {
58
+ console.log(`❌ Component "${componentName}" not found. Available components: ${(0, registry_1.getAvailableComponents)().join(", ")}`);
59
+ continue;
60
+ }
61
+ console.log(`📦 Adding ${componentConfig.name}...`);
62
+ // Create component files
63
+ for (const file of componentConfig.files) {
64
+ const filePath = path.join(componentsDir, file.path);
65
+ const fileDir = path.dirname(filePath);
66
+ // Create directory if it doesn't exist
67
+ yield fs.promises.mkdir(fileDir, { recursive: true });
68
+ // Check if file exists and handle overwrite
69
+ if (fs.existsSync(filePath) && !options.overwrite) {
70
+ console.log(`⚠️ ${file.path} already exists. Use --overwrite to replace it.`);
71
+ continue;
72
+ }
73
+ yield fs.promises.writeFile(filePath, file.content);
74
+ console.log(`✅ Created ${file.path}`);
75
+ }
76
+ console.log(`🎉 Successfully added ${componentConfig.name}!`);
77
+ }
78
+ console.log(`
79
+ 📁 Components added to: ${componentsDir}
80
+ `);
81
+ }
82
+ catch (error) {
83
+ console.error("❌ Error adding components:", error);
84
+ process.exit(1);
85
+ }
86
+ });
87
+ }
@@ -0,0 +1,2 @@
1
+ export declare function init(): Promise<void>;
2
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../cli/init.ts"],"names":[],"mappings":"AAWA,wBAAsB,IAAI,kBAiCzB"}
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.init = init;
46
+ const child_process_1 = require("child_process");
47
+ const fs = __importStar(require("fs"));
48
+ const path = __importStar(require("path"));
49
+ const util_1 = require("util");
50
+ const execAsync = (0, util_1.promisify)(child_process_1.exec);
51
+ const requiredPeerDependencies = ["next", "react", "react-dom", "@types/react", "@types/react-dom"];
52
+ const devDependencies = ["sass", "typescript"];
53
+ const dependencies = ["zod", "clsx", "@becklyn/next"];
54
+ function init() {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ console.log("🚀 Initializing @becklyn/components in your project...\n");
57
+ const cwd = process.cwd();
58
+ try {
59
+ // Check if package.json exists
60
+ const packageJsonPath = path.join(cwd, "package.json");
61
+ if (!fs.existsSync(packageJsonPath)) {
62
+ console.error("❌ No package.json found in current directory");
63
+ process.exit(1);
64
+ }
65
+ // Check if Next.js is installed
66
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
67
+ assertDependencies(packageJson, requiredPeerDependencies);
68
+ console.log("✅ All required dependencies detected");
69
+ console.log("📦 Installing dependencies...");
70
+ ensureDependencies(packageJson, dependencies, devDependencies);
71
+ console.log("✅ Dependencies installed!");
72
+ console.log("✅ Project initialized successfully!");
73
+ console.log(`
74
+ 🎉 You can now add components with:
75
+ npx becklyn-components add <component>
76
+ `);
77
+ }
78
+ catch (error) {
79
+ console.error("❌ Error during initialization:", error);
80
+ process.exit(1);
81
+ }
82
+ });
83
+ }
84
+ const assertDependencies = (packageJson, dependencies) => __awaiter(void 0, void 0, void 0, function* () {
85
+ for (const dependency of dependencies) {
86
+ if (!hasAnyDependency(packageJson, dependency)) {
87
+ console.error(`❌ Dependency ${dependency} is not installed in this project`);
88
+ console.error(`💡 Please install ${dependency} first`);
89
+ process.exit(1);
90
+ }
91
+ }
92
+ });
93
+ const ensureDependencies = (packageJson, dependencies, devDependencies) => __awaiter(void 0, void 0, void 0, function* () {
94
+ for (const dependency of dependencies) {
95
+ if (!hasDependency(packageJson, dependency)) {
96
+ yield execAsync(`npm install ${dependency}`);
97
+ }
98
+ }
99
+ for (const devDependency of devDependencies) {
100
+ if (!hasDevDependency(packageJson, devDependency)) {
101
+ yield execAsync(`npm install --save-dev ${devDependency}`);
102
+ }
103
+ }
104
+ });
105
+ const hasAnyDependency = (packageJson, dependency) => {
106
+ return ((packageJson.dependencies && packageJson.dependencies[dependency]) ||
107
+ (packageJson.devDependencies && packageJson.devDependencies[dependency]));
108
+ };
109
+ const hasDevDependency = (packageJson, dependency) => {
110
+ return packageJson.devDependencies && packageJson.devDependencies[dependency];
111
+ };
112
+ const hasDependency = (packageJson, dependency) => {
113
+ return packageJson.dependencies && packageJson.dependencies[dependency];
114
+ };
@@ -0,0 +1,11 @@
1
+ export interface ComponentConfig {
2
+ name: string;
3
+ files: Array<{
4
+ path: string;
5
+ content: string;
6
+ }>;
7
+ dependencies?: string[];
8
+ }
9
+ export declare function getAvailableComponents(): string[];
10
+ export declare function getComponent(name: string): ComponentConfig | undefined;
11
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../cli/registry.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;QACT,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AA0HD,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAejD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAqCtE"}
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getAvailableComponents = getAvailableComponents;
37
+ exports.getComponent = getComponent;
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ /**
41
+ * Get the path to the components directory relative to this registry file
42
+ */
43
+ function getComponentsPath() {
44
+ // When running from compiled code in dist/, we need to go up more levels
45
+ // From dist/cjs/cli/ or dist/es/cli/ to the components/ directory
46
+ const currentDir = __dirname;
47
+ // Check if we're running from compiled code
48
+ if (currentDir.includes("/dist/")) {
49
+ // From dist/cjs/cli/ -> ../../../components/
50
+ // From dist/es/cli/ -> ../../../components/
51
+ return path.join(__dirname, "../../../components");
52
+ }
53
+ else {
54
+ // Running from source code
55
+ return path.join(__dirname, "../components");
56
+ }
57
+ }
58
+ /**
59
+ * Check if a directory is a valid component directory
60
+ */
61
+ function isValidComponentDir(dirPath) {
62
+ try {
63
+ const tsxFile = fs.readdirSync(dirPath).find(file => file.endsWith(".tsx"));
64
+ return tsxFile !== undefined;
65
+ }
66
+ catch (_a) {
67
+ return false;
68
+ }
69
+ }
70
+ /**
71
+ * Recursively scan for components in nested directories (atoms, molecules, organisms, etc.)
72
+ */
73
+ function scanComponentsRecursively(basePath, relativePath = "") {
74
+ const components = [];
75
+ try {
76
+ const entries = fs.readdirSync(basePath, { withFileTypes: true });
77
+ for (const entry of entries) {
78
+ if (entry.isDirectory()) {
79
+ // Skip hidden directories (starting with .) and common non-component directories
80
+ if (entry.name.startsWith(".") ||
81
+ entry.name === "node_modules" ||
82
+ entry.name === "dist" ||
83
+ entry.name === "__tests__" ||
84
+ entry.name === "test" ||
85
+ entry.name === "tests") {
86
+ continue;
87
+ }
88
+ const fullPath = path.join(basePath, entry.name);
89
+ const currentRelativePath = relativePath
90
+ ? `${relativePath}/${entry.name}`
91
+ : entry.name;
92
+ // Check if this directory is a component directory
93
+ if (isValidComponentDir(fullPath)) {
94
+ components.push({
95
+ name: entry.name,
96
+ path: currentRelativePath,
97
+ });
98
+ }
99
+ else {
100
+ // Recursively scan subdirectories (like atoms/, molecules/, etc.)
101
+ const nestedComponents = scanComponentsRecursively(fullPath, currentRelativePath);
102
+ components.push(...nestedComponents);
103
+ }
104
+ }
105
+ }
106
+ }
107
+ catch (_a) {
108
+ // Silently ignore directories that can't be read
109
+ }
110
+ return components;
111
+ }
112
+ /**
113
+ * Read all files in a component directory and return them as file objects
114
+ */
115
+ function readComponentFiles(componentName, componentDir, relativePath) {
116
+ const files = [];
117
+ try {
118
+ const dirContents = fs.readdirSync(componentDir, { withFileTypes: true });
119
+ for (const item of dirContents) {
120
+ if (item.isFile()) {
121
+ const filePath = path.join(componentDir, item.name);
122
+ const content = fs.readFileSync(filePath, "utf-8");
123
+ // Use the full relative path from components directory if provided
124
+ const fileRelativePath = relativePath
125
+ ? `${relativePath}/${item.name}`
126
+ : `${componentName}/${item.name}`;
127
+ files.push({
128
+ path: fileRelativePath,
129
+ content: content,
130
+ });
131
+ }
132
+ }
133
+ }
134
+ catch (error) {
135
+ console.error(`Error reading files from ${componentDir}:`, error);
136
+ }
137
+ return files;
138
+ }
139
+ function getAvailableComponents() {
140
+ try {
141
+ const componentsPath = getComponentsPath();
142
+ if (!fs.existsSync(componentsPath)) {
143
+ console.warn(`Components directory not found at: ${componentsPath}`);
144
+ return [];
145
+ }
146
+ const components = scanComponentsRecursively(componentsPath);
147
+ return components.map(component => component.name.toLowerCase());
148
+ }
149
+ catch (error) {
150
+ console.error("Error reading components directory:", error);
151
+ return [];
152
+ }
153
+ }
154
+ function getComponent(name) {
155
+ try {
156
+ const componentsPath = getComponentsPath();
157
+ const componentName = name.toLowerCase();
158
+ // Scan for all components and find the matching one
159
+ const allComponents = scanComponentsRecursively(componentsPath);
160
+ const matchingComponent = allComponents.find(component => component.name.toLowerCase() === componentName);
161
+ if (!matchingComponent) {
162
+ return undefined;
163
+ }
164
+ const componentDir = path.join(componentsPath, matchingComponent.path);
165
+ if (!isValidComponentDir(componentDir)) {
166
+ return undefined;
167
+ }
168
+ // Remove any "components/" prefix from the path to avoid double nesting
169
+ const cleanPath = matchingComponent.path.startsWith("components/")
170
+ ? matchingComponent.path.substring("components/".length)
171
+ : matchingComponent.path;
172
+ const files = readComponentFiles(matchingComponent.name, componentDir, cleanPath);
173
+ return {
174
+ name: matchingComponent.name,
175
+ files: files,
176
+ dependencies: [], // Could be enhanced to parse dependencies from package.json or imports
177
+ };
178
+ }
179
+ catch (error) {
180
+ console.error(`Error reading component "${name}":`, error);
181
+ return undefined;
182
+ }
183
+ }
@@ -0,0 +1,4 @@
1
+ import { FC, PropsWithChildren } from "react";
2
+ import { ButtonProps } from "./ButtonSchema";
3
+ export declare const Button: FC<PropsWithChildren<ButtonProps>>;
4
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../components/atoms/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAwB,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAI3E,OAAO,EAAE,WAAW,EAAgB,MAAM,gBAAgB,CAAC;AAgB3D,eAAO,MAAM,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAqBrD,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Button = void 0;
18
+ const jsx_runtime_1 = require("react/jsx-runtime");
19
+ const link_1 = __importDefault(require("next/link"));
20
+ const clsx_1 = __importDefault(require("clsx"));
21
+ const Button_module_scss_1 = __importDefault(require("./Button.module.scss"));
22
+ const ButtonSchema_1 = require("./ButtonSchema");
23
+ const ButtonWrapperComponent = (_a) => {
24
+ var { children } = _a, props = __rest(_a, ["children"]);
25
+ return props.href ? ((0, jsx_runtime_1.jsx)(link_1.default, Object.assign({ href: props.href }, props, { children: children }))) : ((0, jsx_runtime_1.jsx)("button", Object.assign({ type: props.type || "button" }, props, { children: children })));
26
+ };
27
+ const Button = props => {
28
+ const validatedProps = ButtonSchema_1.ButtonSchema.safeParse(props);
29
+ if (!validatedProps.data) {
30
+ return undefined;
31
+ }
32
+ const _a = validatedProps.data, { variant, disabled, className } = _a, restProps = __rest(_a, ["variant", "disabled", "className"]);
33
+ return ((0, jsx_runtime_1.jsx)(ButtonWrapperComponent, Object.assign({}, restProps, { className: (0, clsx_1.default)(Button_module_scss_1.default.button, Button_module_scss_1.default[variant], disabled && Button_module_scss_1.default.disabled, className), children: props.children })));
34
+ };
35
+ exports.Button = Button;
@@ -0,0 +1,12 @@
1
+ import type { Meta, StoryObj } from "@storybook/nextjs";
2
+ import { Button } from "./Button";
3
+ declare const meta: Meta<typeof Button>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Button>;
6
+ export declare const Primary: Story;
7
+ export declare const PrimaryDisabled: Story;
8
+ export declare const Secondary: Story;
9
+ export declare const SecondaryDisabled: Story;
10
+ export declare const Tertiary: Story;
11
+ export declare const TertiaryDisabled: Story;
12
+ //# sourceMappingURL=Button.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.stories.d.ts","sourceRoot":"","sources":["../../../../components/atoms/Button/Button.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,MAAM,CA8B7B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,MAAM,CAAC,CAAC;AAErC,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAM7B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAKvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAM/B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAKtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAM9B,CAAC"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TertiaryDisabled = exports.Tertiary = exports.SecondaryDisabled = exports.Secondary = exports.PrimaryDisabled = exports.Primary = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const clsx_1 = __importDefault(require("clsx"));
9
+ const Story_module_scss_1 = __importDefault(require("@becklyn/components/.storybook/Story.module.scss"));
10
+ const Button_1 = require("./Button");
11
+ const meta = {
12
+ title: "Atoms/Button/Button",
13
+ component: Button_1.Button,
14
+ parameters: {
15
+ layout: "centered",
16
+ },
17
+ argTypes: {
18
+ variant: {
19
+ control: { type: "select" },
20
+ options: ["primary", "secondary", "tertiary"],
21
+ },
22
+ disabled: {
23
+ control: "boolean",
24
+ },
25
+ onClick: { action: "clicked" },
26
+ },
27
+ render: args => {
28
+ const handleOnClick = () => {
29
+ alert("Button clicked!");
30
+ };
31
+ return ((0, jsx_runtime_1.jsxs)("div", { className: (0, clsx_1.default)(Story_module_scss_1.default.storyContainer, Story_module_scss_1.default.large, Story_module_scss_1.default.flex), children: [(0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({}, args, { onClick: handleOnClick })), (0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({}, args, { href: "#", children: "Button as Link" }))] }));
32
+ },
33
+ };
34
+ exports.default = meta;
35
+ exports.Primary = {
36
+ args: {
37
+ variant: "primary",
38
+ children: "Button",
39
+ },
40
+ };
41
+ exports.PrimaryDisabled = {
42
+ args: {
43
+ variant: "primary",
44
+ children: "Button",
45
+ disabled: true,
46
+ },
47
+ };
48
+ exports.Secondary = {
49
+ args: {
50
+ variant: "secondary",
51
+ children: "Button",
52
+ },
53
+ };
54
+ exports.SecondaryDisabled = {
55
+ args: {
56
+ variant: "secondary",
57
+ children: "Button",
58
+ disabled: true,
59
+ },
60
+ };
61
+ exports.Tertiary = {
62
+ args: {
63
+ variant: "tertiary",
64
+ children: "Button",
65
+ },
66
+ };
67
+ exports.TertiaryDisabled = {
68
+ args: {
69
+ variant: "tertiary",
70
+ children: "Button",
71
+ disabled: true,
72
+ },
73
+ };
@@ -0,0 +1,27 @@
1
+ import { type AnchorHTMLAttributes, type ButtonHTMLAttributes } from "react";
2
+ import { z } from "zod";
3
+ export declare const ButtonVariantSchema: z.ZodEnum<{
4
+ primary: "primary";
5
+ secondary: "secondary";
6
+ tertiary: "tertiary";
7
+ }>;
8
+ export type ButtonVariant = z.input<typeof ButtonVariantSchema>;
9
+ /**
10
+ * Zod schema for Button component props validation
11
+ */
12
+ export declare const ButtonSchema: z.ZodObject<{
13
+ variant: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
14
+ primary: "primary";
15
+ secondary: "secondary";
16
+ tertiary: "tertiary";
17
+ }>>>;
18
+ disabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
19
+ type: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
20
+ button: "button";
21
+ submit: "submit";
22
+ reset: "reset";
23
+ }>>>;
24
+ className: z.ZodDefault<z.ZodOptional<z.ZodString>>;
25
+ }, z.core.$loose>;
26
+ export type ButtonProps = z.input<typeof ButtonSchema> & (ButtonHTMLAttributes<HTMLButtonElement> | AnchorHTMLAttributes<HTMLAnchorElement>);
27
+ //# sourceMappingURL=ButtonSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonSchema.d.ts","sourceRoot":"","sources":["../../../../components/atoms/Button/ButtonSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,mBAAmB;;;;EAA+C,CAAC;AAChF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;iBASvB,CAAC;AAGH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,GAClD,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ButtonSchema = exports.ButtonVariantSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ // Zod schema for button variants
6
+ exports.ButtonVariantSchema = zod_1.z.enum(["primary", "secondary", "tertiary"]);
7
+ /**
8
+ * Zod schema for Button component props validation
9
+ */
10
+ exports.ButtonSchema = zod_1.z.looseObject({
11
+ // Visual style variant
12
+ variant: exports.ButtonVariantSchema.optional().default("primary"),
13
+ // Full width button
14
+ disabled: zod_1.z.boolean().optional().default(false),
15
+ // type of the button, defaults to "button"
16
+ type: zod_1.z.enum(["button", "submit", "reset"]).optional().default("button"),
17
+ // CSS class
18
+ className: zod_1.z.string().optional().default(""),
19
+ });
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@becklyn/components",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "homepage": "https://github.com/Becklyn-Studios/ts-libs/tree/main/packages/components",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Becklyn-Studios/ts-libs.git"
9
+ },
10
+ "scripts": {
11
+ "lint": "eslint . --max-warnings 0 && prettier --check \"./**/*.{ts,tsx}\"",
12
+ "fix": "eslint . --fix && prettier --write \"./**/*.{ts,tsx,scss}\"",
13
+ "build": "rm -rf dist && tsc && chmod +x dist/bin/cli.js",
14
+ "prepublishOnly": "npm run lint && npm run build",
15
+ "storybook": "storybook dev -p 6006",
16
+ "storybook-build": "storybook build"
17
+ },
18
+ "dependencies": {
19
+ "commander": "^14.0.0"
20
+ },
21
+ "devDependencies": {
22
+ "@becklyn/eslint": "*",
23
+ "@becklyn/next": "^3.0.0",
24
+ "@becklyn/tsconfig": "*",
25
+ "@storybook/addon-designs": "^10.0.2",
26
+ "@storybook/addon-docs": "^9.1.1",
27
+ "@storybook/addon-links": "^9.1.1",
28
+ "@storybook/nextjs": "^9.1.1",
29
+ "@types/node": "^24.2.0",
30
+ "@types/react": "^19.1.9",
31
+ "clsx": "^2.1.1",
32
+ "eslint-plugin-storybook": "^9.1.1",
33
+ "next": "^15.4.6",
34
+ "react": "^19.1.1",
35
+ "react-dom": "^19.1.1",
36
+ "sass": "^1.90.0",
37
+ "storybook": "^9.1.1",
38
+ "zod": "^4.0.15"
39
+ },
40
+ "peerDependencies": {
41
+ "react": "^18.3.1 || ^19.0.0",
42
+ "react-dom": "^18.3.1 || ^19.0.0"
43
+ },
44
+ "bin": {
45
+ "becklyn-components": "dist/bin/cli.js"
46
+ },
47
+ "files": [
48
+ "dist"
49
+ ]
50
+ }