@becklyn/components 0.2.2 → 0.3.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.
- package/README.md +5 -5
- package/components/atoms/Clickable/Clickable.module.scss +32 -0
- package/components/atoms/Clickable/Clickable.stories.tsx +82 -0
- package/components/atoms/Clickable/Clickable.tsx +47 -0
- package/components/atoms/TextInput/TextInput.module.scss +31 -0
- package/components/atoms/TextInput/TextInput.stories.tsx +56 -0
- package/components/atoms/TextInput/TextInput.tsx +64 -0
- package/dist/bin/cli.js +1 -1
- package/dist/cli/add.d.ts.map +1 -1
- package/dist/cli/add.js +3 -0
- package/dist/cli/dependencies.d.ts +12 -0
- package/dist/cli/dependencies.d.ts.map +1 -0
- package/dist/cli/dependencies.js +115 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +5 -84
- package/dist/cli/registry.d.ts +1 -1
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/cli/registry.js +9 -4
- package/dist/components/atoms/Clickable/Clickable.d.ts +2 -2
- package/dist/components/atoms/Clickable/Clickable.d.ts.map +1 -1
- package/dist/components/atoms/Clickable/Clickable.stories.d.ts.map +1 -1
- package/dist/components/atoms/Clickable/Clickable.stories.js +1 -6
- package/dist/components/atoms/TextInput/TextInput.d.ts +15 -0
- package/dist/components/atoms/TextInput/TextInput.d.ts.map +1 -0
- package/dist/components/atoms/TextInput/TextInput.js +17 -0
- package/dist/components/atoms/TextInput/TextInput.stories.d.ts +10 -0
- package/dist/components/atoms/TextInput/TextInput.stories.d.ts.map +1 -0
- package/dist/components/atoms/TextInput/TextInput.stories.js +50 -0
- package/package.json +16 -17
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ We also add storybook stories to the components. You need to have storybook inst
|
|
|
15
15
|
Initialize your project with the necessary configuration.
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npx becklyn
|
|
18
|
+
npx @becklyn/components init [options]
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
This command will:
|
|
@@ -27,7 +27,7 @@ This command will:
|
|
|
27
27
|
Add components to your project by copying them from the library.
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
|
-
npx becklyn
|
|
30
|
+
npx @becklyn/components add <component> [component...] [options]
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
**Options:**
|
|
@@ -40,11 +40,11 @@ npx becklyn-components add <component> [component...] [options]
|
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
# Add a single component
|
|
43
|
-
npx becklyn
|
|
43
|
+
npx @becklyn/components add button
|
|
44
44
|
|
|
45
45
|
# Add multiple components
|
|
46
|
-
npx becklyn
|
|
46
|
+
npx @becklyn/components add button card dialog
|
|
47
47
|
|
|
48
48
|
# Specify custom directories
|
|
49
|
-
npx becklyn
|
|
49
|
+
npx @becklyn/components add button --components src/ui
|
|
50
50
|
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@use "@becklyn/next/scss/mixins" as *;
|
|
2
|
+
|
|
3
|
+
.clickable {
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
|
|
6
|
+
&.disabled {
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
color: #777;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.primary {
|
|
13
|
+
@include hover {
|
|
14
|
+
background-color: #000;
|
|
15
|
+
color: #fff;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.secondary {
|
|
20
|
+
@include hover {
|
|
21
|
+
background-color: #00f;
|
|
22
|
+
color: #fff;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.tertiary {
|
|
27
|
+
text-decoration: underline;
|
|
28
|
+
|
|
29
|
+
@include hover {
|
|
30
|
+
text-decoration: none;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
2
|
+
import { Clickable } from "./Clickable";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Clickable> = {
|
|
5
|
+
title: "Atoms/Button/Button",
|
|
6
|
+
component: Clickable,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "centered",
|
|
9
|
+
},
|
|
10
|
+
argTypes: {
|
|
11
|
+
variant: {
|
|
12
|
+
control: { type: "select" },
|
|
13
|
+
options: ["primary", "secondary", "tertiary"],
|
|
14
|
+
},
|
|
15
|
+
disabled: {
|
|
16
|
+
control: "boolean",
|
|
17
|
+
},
|
|
18
|
+
onClick: { action: "clicked" },
|
|
19
|
+
},
|
|
20
|
+
render: args => {
|
|
21
|
+
const handleOnClick = () => {
|
|
22
|
+
alert("Button clicked!");
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className="story-container large flex">
|
|
27
|
+
<Clickable {...args} onClick={handleOnClick} />
|
|
28
|
+
<Clickable {...args} href="#">
|
|
29
|
+
Button as Link
|
|
30
|
+
</Clickable>
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default meta;
|
|
37
|
+
type Story = StoryObj<typeof Clickable>;
|
|
38
|
+
|
|
39
|
+
export const Primary: Story = {
|
|
40
|
+
args: {
|
|
41
|
+
variant: "primary",
|
|
42
|
+
children: "Button",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const PrimaryDisabled: Story = {
|
|
47
|
+
args: {
|
|
48
|
+
variant: "primary",
|
|
49
|
+
children: "Button",
|
|
50
|
+
disabled: true,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const Secondary: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
variant: "secondary",
|
|
57
|
+
children: "Button",
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const SecondaryDisabled: Story = {
|
|
62
|
+
args: {
|
|
63
|
+
variant: "secondary",
|
|
64
|
+
children: "Button",
|
|
65
|
+
disabled: true,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const Tertiary: Story = {
|
|
70
|
+
args: {
|
|
71
|
+
variant: "tertiary",
|
|
72
|
+
children: "Button",
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const TertiaryDisabled: Story = {
|
|
77
|
+
args: {
|
|
78
|
+
variant: "tertiary",
|
|
79
|
+
children: "Button",
|
|
80
|
+
disabled: true,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AnchorHTMLAttributes, ButtonHTMLAttributes, FC, PropsWithChildren } from "react";
|
|
2
|
+
import Link from "next/link";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { PropsWithClassName } from "@becklyn/next/types/style";
|
|
5
|
+
import styles from "./Clickable.module.scss";
|
|
6
|
+
|
|
7
|
+
interface ClickableProps {
|
|
8
|
+
href: string;
|
|
9
|
+
type: "button" | "submit" | "reset";
|
|
10
|
+
variant?: "primary" | "secondary" | "tertiary";
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
onClick?: () => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const ClickableWrapperComponent: FC<PropsWithChildren<PropsWithClassName<ClickableProps>>> = ({
|
|
16
|
+
children,
|
|
17
|
+
...props
|
|
18
|
+
}) => {
|
|
19
|
+
return props.href ? (
|
|
20
|
+
<Link href={props.href} {...(props as AnchorHTMLAttributes<HTMLAnchorElement>)}>
|
|
21
|
+
{children}
|
|
22
|
+
</Link>
|
|
23
|
+
) : (
|
|
24
|
+
<button
|
|
25
|
+
type={props.type || "button"}
|
|
26
|
+
{...(props as ButtonHTMLAttributes<HTMLButtonElement>)}>
|
|
27
|
+
{children}
|
|
28
|
+
</button>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const Clickable: FC<PropsWithChildren<PropsWithClassName<ClickableProps>>> = props => {
|
|
33
|
+
const { variant, disabled, className, ...restProps } = props;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ClickableWrapperComponent
|
|
37
|
+
{...restProps}
|
|
38
|
+
className={clsx(
|
|
39
|
+
styles.clickable,
|
|
40
|
+
variant ? styles[variant] : undefined,
|
|
41
|
+
disabled && styles.disabled,
|
|
42
|
+
className
|
|
43
|
+
)}>
|
|
44
|
+
{props.children}
|
|
45
|
+
</ClickableWrapperComponent>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
@use "@becklyn/next/scss/mixins" as *;
|
|
2
|
+
|
|
3
|
+
.wrapper {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
gap: 4px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.input {
|
|
10
|
+
background-color: #fff;
|
|
11
|
+
|
|
12
|
+
@include hover {
|
|
13
|
+
background-color: #bbb;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@include focus {
|
|
17
|
+
background-color: #ddd;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@include transition(background-color);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.error {
|
|
24
|
+
color: #eb1c23;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.disabled {
|
|
28
|
+
cursor: not-allowed;
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
color: #777;
|
|
31
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { FC, useState } from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
3
|
+
import { TextInput, TextInputProps } from "./TextInput";
|
|
4
|
+
|
|
5
|
+
const InteractiveInput: FC<TextInputProps> = args => {
|
|
6
|
+
const [value, setValue] = useState("");
|
|
7
|
+
|
|
8
|
+
return <TextInput {...args} value={value} onChange={setValue} />;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof TextInput> = {
|
|
12
|
+
title: "Atoms/TextInput",
|
|
13
|
+
component: TextInput,
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: "centered",
|
|
16
|
+
},
|
|
17
|
+
argTypes: {
|
|
18
|
+
label: { control: "text" },
|
|
19
|
+
placeholder: { control: "text" },
|
|
20
|
+
disabled: { control: "boolean" },
|
|
21
|
+
error: { control: "text" },
|
|
22
|
+
},
|
|
23
|
+
render: args => <InteractiveInput {...args} />,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default meta;
|
|
27
|
+
type Story = StoryObj<typeof TextInput>;
|
|
28
|
+
|
|
29
|
+
export const Default: Story = {
|
|
30
|
+
args: {
|
|
31
|
+
label: "Label",
|
|
32
|
+
placeholder: "Text Label",
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const WithoutLabel: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
placeholder: "Text Label",
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const Error: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
label: "Label",
|
|
45
|
+
placeholder: "Text Label",
|
|
46
|
+
error: "Lorem ipsum",
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const Disabled: Story = {
|
|
51
|
+
args: {
|
|
52
|
+
label: "Label",
|
|
53
|
+
placeholder: "Text Label",
|
|
54
|
+
disabled: true,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { FC, HTMLInputTypeAttribute, useId } from "react";
|
|
4
|
+
import clsx from "clsx";
|
|
5
|
+
import { PropsWithClassName } from "@becklyn/next/types/style";
|
|
6
|
+
import styles from "./TextInput.module.scss";
|
|
7
|
+
|
|
8
|
+
export interface TextInputProps {
|
|
9
|
+
id?: string;
|
|
10
|
+
label: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
value?: string;
|
|
13
|
+
onChange?: (value: string) => void;
|
|
14
|
+
error?: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
type?: HTMLInputTypeAttribute;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const TextInput: FC<PropsWithClassName<TextInputProps>> = ({
|
|
21
|
+
id: providedId,
|
|
22
|
+
label,
|
|
23
|
+
placeholder,
|
|
24
|
+
value,
|
|
25
|
+
error,
|
|
26
|
+
onChange,
|
|
27
|
+
disabled,
|
|
28
|
+
required,
|
|
29
|
+
className,
|
|
30
|
+
type = "text",
|
|
31
|
+
}) => {
|
|
32
|
+
const generatedId = useId();
|
|
33
|
+
const id = providedId ?? generatedId;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className={clsx(styles.wrapper, className)}>
|
|
37
|
+
{label && (
|
|
38
|
+
<label htmlFor={id} className={styles.label}>
|
|
39
|
+
{label}
|
|
40
|
+
{required && " *"}
|
|
41
|
+
</label>
|
|
42
|
+
)}
|
|
43
|
+
<input
|
|
44
|
+
id={id}
|
|
45
|
+
value={value}
|
|
46
|
+
onChange={e => onChange?.(e.target.value)}
|
|
47
|
+
placeholder={placeholder}
|
|
48
|
+
disabled={disabled}
|
|
49
|
+
required={required}
|
|
50
|
+
className={clsx(styles.input, disabled && styles.disabled)}
|
|
51
|
+
type={type}
|
|
52
|
+
/>
|
|
53
|
+
{error && (
|
|
54
|
+
<output
|
|
55
|
+
htmlFor={id}
|
|
56
|
+
name={`${id}_error`}
|
|
57
|
+
className={styles.error}
|
|
58
|
+
aria-invalid={true}>
|
|
59
|
+
{error}
|
|
60
|
+
</output>
|
|
61
|
+
)}
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
};
|
package/dist/bin/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ const add_1 = require("../cli/add");
|
|
|
6
6
|
const init_1 = require("../cli/init");
|
|
7
7
|
const registry_1 = require("../cli/registry");
|
|
8
8
|
commander_1.program
|
|
9
|
-
.name("becklyn
|
|
9
|
+
.name("@becklyn/components")
|
|
10
10
|
.description("CLI for @becklyn/components - Add components to your project")
|
|
11
11
|
.version("1.0.0");
|
|
12
12
|
commander_1.program
|
package/dist/cli/add.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../cli/add.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../cli/add.ts"],"names":[],"mappings":"AAKA,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,iBAmDlE"}
|
package/dist/cli/add.js
CHANGED
|
@@ -45,6 +45,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
45
45
|
exports.add = add;
|
|
46
46
|
const fs = __importStar(require("fs"));
|
|
47
47
|
const path = __importStar(require("path"));
|
|
48
|
+
const dependencies_1 = require("./dependencies");
|
|
48
49
|
const registry_1 = require("./registry");
|
|
49
50
|
function add(components, options) {
|
|
50
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -52,12 +53,14 @@ function add(components, options) {
|
|
|
52
53
|
const cwd = process.cwd();
|
|
53
54
|
const componentsDir = path.join(cwd, options.components || "components");
|
|
54
55
|
try {
|
|
56
|
+
const packageJson = (0, dependencies_1.loadPackageJson)();
|
|
55
57
|
for (const componentName of components) {
|
|
56
58
|
const componentConfig = (0, registry_1.getComponent)(componentName);
|
|
57
59
|
if (!componentConfig) {
|
|
58
60
|
console.log(`❌ Component "${componentName}" not found. Available components: ${(0, registry_1.getAvailableComponents)().join(", ")}`);
|
|
59
61
|
continue;
|
|
60
62
|
}
|
|
63
|
+
(0, dependencies_1.assertDependencies)(packageJson, componentConfig.dependencies || []);
|
|
61
64
|
console.log(`📦 Adding ${componentConfig.name}...`);
|
|
62
65
|
// Create component files
|
|
63
66
|
for (const file of componentConfig.files) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const requiredPeerDependencies: string[];
|
|
2
|
+
export declare const devDependencies: string[];
|
|
3
|
+
export declare const dependencies: string[];
|
|
4
|
+
type PackageJson = {
|
|
5
|
+
dependencies?: Record<string, string>;
|
|
6
|
+
devDependencies?: Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
export declare const loadPackageJson: () => PackageJson;
|
|
9
|
+
export declare const assertDependencies: (packageJson: PackageJson, dependencies: string[]) => void;
|
|
10
|
+
export declare const ensureDependencies: (packageJson: PackageJson, dependencies: string[], devDependencies: string[]) => Promise<void>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../cli/dependencies.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,wBAAwB,UAOpC,CAAC;AACF,eAAO,MAAM,eAAe,UAAyB,CAAC;AACtD,eAAO,MAAM,YAAY,UAA4B,CAAC;AAStD,KAAK,WAAW,GAAG;IACf,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C,CAAC;AAEF,eAAO,MAAM,eAAe,QAAO,WAYlC,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,aAAa,WAAW,EAAE,cAAc,MAAM,EAAE,SAclF,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC3B,aAAa,WAAW,EACxB,cAAc,MAAM,EAAE,EACtB,iBAAiB,MAAM,EAAE,kBAa5B,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
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.ensureDependencies = exports.assertDependencies = exports.loadPackageJson = exports.dependencies = exports.devDependencies = exports.requiredPeerDependencies = void 0;
|
|
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
|
+
exports.requiredPeerDependencies = [
|
|
52
|
+
"next",
|
|
53
|
+
"react",
|
|
54
|
+
"react-dom",
|
|
55
|
+
"@types/react",
|
|
56
|
+
"@types/react-dom",
|
|
57
|
+
"@storybook/nextjs-vite",
|
|
58
|
+
];
|
|
59
|
+
exports.devDependencies = ["sass", "typescript"];
|
|
60
|
+
exports.dependencies = ["clsx", "@becklyn/next"];
|
|
61
|
+
const installHints = {
|
|
62
|
+
next: "💡 To install Next.js please have a look at https://nextjs.org/docs/app/getting-started/installation",
|
|
63
|
+
"@types/react": "💡 To install @types/react run: npm i -D @types/react",
|
|
64
|
+
"@types/react-dom": "💡 To install @types/react-dom run: npm i -D @types/react-dom",
|
|
65
|
+
"@storybook/nextjs-vite": "💡 To install @storybook run: npm create storybook@latest",
|
|
66
|
+
};
|
|
67
|
+
const loadPackageJson = () => {
|
|
68
|
+
const cwd = process.cwd();
|
|
69
|
+
// Check if package.json exists
|
|
70
|
+
const packageJsonPath = path.join(cwd, "package.json");
|
|
71
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
72
|
+
console.error("❌ No package.json found in current directory");
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
// Check if Next.js is installed
|
|
76
|
+
return JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
77
|
+
};
|
|
78
|
+
exports.loadPackageJson = loadPackageJson;
|
|
79
|
+
const assertDependencies = (packageJson, dependencies) => {
|
|
80
|
+
for (const dependency of dependencies) {
|
|
81
|
+
if (!hasAnyDependency(packageJson, dependency)) {
|
|
82
|
+
console.error(`❌ Dependency ${dependency} is not installed in this project`);
|
|
83
|
+
console.error(`💡 Please install ${dependency} first`);
|
|
84
|
+
const hint = installHints[dependency];
|
|
85
|
+
if (hint) {
|
|
86
|
+
console.error(hint);
|
|
87
|
+
}
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
exports.assertDependencies = assertDependencies;
|
|
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
|
+
exports.ensureDependencies = ensureDependencies;
|
|
106
|
+
const hasAnyDependency = (packageJson, dependency) => {
|
|
107
|
+
return ((packageJson.dependencies && packageJson.dependencies[dependency]) ||
|
|
108
|
+
(packageJson.devDependencies && packageJson.devDependencies[dependency]));
|
|
109
|
+
};
|
|
110
|
+
const hasDevDependency = (packageJson, dependency) => {
|
|
111
|
+
return packageJson.devDependencies && packageJson.devDependencies[dependency];
|
|
112
|
+
};
|
|
113
|
+
const hasDependency = (packageJson, dependency) => {
|
|
114
|
+
return packageJson.dependencies && packageJson.dependencies[dependency];
|
|
115
|
+
};
|
package/dist/cli/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../cli/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../cli/init.ts"],"names":[],"mappings":"AASA,wBAAsB,IAAI,kBAuBzB"}
|
package/dist/cli/init.js
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
1
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
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -43,36 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
43
10
|
};
|
|
44
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
12
|
exports.init = init;
|
|
46
|
-
const
|
|
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 = ["clsx", "@becklyn/next"];
|
|
13
|
+
const dependencies_1 = require("./dependencies");
|
|
54
14
|
function init() {
|
|
55
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
16
|
console.log("🚀 Initializing @becklyn/components in your project...\n");
|
|
57
|
-
const cwd = process.cwd();
|
|
58
17
|
try {
|
|
59
|
-
|
|
60
|
-
|
|
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);
|
|
18
|
+
const packageJson = (0, dependencies_1.loadPackageJson)();
|
|
19
|
+
(0, dependencies_1.assertDependencies)(packageJson, dependencies_1.requiredPeerDependencies);
|
|
68
20
|
console.log("✅ All required dependencies detected");
|
|
69
21
|
console.log("📦 Installing dependencies...");
|
|
70
|
-
ensureDependencies(packageJson, dependencies, devDependencies);
|
|
22
|
+
yield (0, dependencies_1.ensureDependencies)(packageJson, dependencies_1.dependencies, dependencies_1.devDependencies);
|
|
71
23
|
console.log("✅ Dependencies installed!");
|
|
72
24
|
console.log("✅ Project initialized successfully!");
|
|
73
25
|
console.log(`
|
|
74
26
|
🎉 You can now add components with:
|
|
75
|
-
npx becklyn
|
|
27
|
+
npx @becklyn/components add <component>
|
|
76
28
|
`);
|
|
77
29
|
}
|
|
78
30
|
catch (error) {
|
|
@@ -81,34 +33,3 @@ function init() {
|
|
|
81
33
|
}
|
|
82
34
|
});
|
|
83
35
|
}
|
|
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
|
-
};
|
package/dist/cli/registry.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface ComponentConfig {
|
|
|
4
4
|
path: string;
|
|
5
5
|
content: string;
|
|
6
6
|
}>;
|
|
7
|
-
dependencies
|
|
7
|
+
dependencies: string[];
|
|
8
8
|
}
|
|
9
9
|
export declare function getAvailableComponents(): string[];
|
|
10
10
|
export declare function getComponent(name: string): ComponentConfig | undefined;
|
|
@@ -1 +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,
|
|
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,EAAE,MAAM,EAAE,CAAC;CAC1B;AAoID,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAejD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAyCtE"}
|
package/dist/cli/registry.js
CHANGED
|
@@ -114,12 +114,17 @@ function scanComponentsRecursively(basePath, relativePath = "") {
|
|
|
114
114
|
*/
|
|
115
115
|
function readComponentFiles(componentName, componentDir, relativePath) {
|
|
116
116
|
const files = [];
|
|
117
|
+
const dependencies = [];
|
|
117
118
|
try {
|
|
118
119
|
const dirContents = fs.readdirSync(componentDir, { withFileTypes: true });
|
|
119
120
|
for (const item of dirContents) {
|
|
120
121
|
if (item.isFile()) {
|
|
121
122
|
const filePath = path.join(componentDir, item.name);
|
|
122
123
|
const content = fs.readFileSync(filePath, "utf-8");
|
|
124
|
+
if (item.name.endsWith("dependencies.json")) {
|
|
125
|
+
console.log(item.name, content);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
123
128
|
// Use the full relative path from components directory if provided
|
|
124
129
|
const fileRelativePath = relativePath
|
|
125
130
|
? `${relativePath}/${item.name}`
|
|
@@ -134,7 +139,7 @@ function readComponentFiles(componentName, componentDir, relativePath) {
|
|
|
134
139
|
catch (error) {
|
|
135
140
|
console.error(`Error reading files from ${componentDir}:`, error);
|
|
136
141
|
}
|
|
137
|
-
return files;
|
|
142
|
+
return { files, dependencies };
|
|
138
143
|
}
|
|
139
144
|
function getAvailableComponents() {
|
|
140
145
|
try {
|
|
@@ -169,11 +174,11 @@ function getComponent(name) {
|
|
|
169
174
|
const cleanPath = matchingComponent.path.startsWith("components/")
|
|
170
175
|
? matchingComponent.path.substring("components/".length)
|
|
171
176
|
: matchingComponent.path;
|
|
172
|
-
const files = readComponentFiles(matchingComponent.name, componentDir, cleanPath);
|
|
177
|
+
const { files, dependencies } = readComponentFiles(matchingComponent.name, componentDir, cleanPath);
|
|
173
178
|
return {
|
|
174
179
|
name: matchingComponent.name,
|
|
175
|
-
files
|
|
176
|
-
dependencies
|
|
180
|
+
files,
|
|
181
|
+
dependencies,
|
|
177
182
|
};
|
|
178
183
|
}
|
|
179
184
|
catch (error) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from "react";
|
|
2
|
+
import { PropsWithClassName } from "@becklyn/next/types/style";
|
|
2
3
|
interface ClickableProps {
|
|
3
4
|
href: string;
|
|
4
5
|
type: "button" | "submit" | "reset";
|
|
5
6
|
variant?: "primary" | "secondary" | "tertiary";
|
|
6
7
|
disabled?: boolean;
|
|
7
|
-
className?: string;
|
|
8
8
|
onClick?: () => void;
|
|
9
9
|
}
|
|
10
|
-
export declare const Clickable: FC<PropsWithChildren<ClickableProps
|
|
10
|
+
export declare const Clickable: FC<PropsWithChildren<PropsWithClassName<ClickableProps>>>;
|
|
11
11
|
export {};
|
|
12
12
|
//# sourceMappingURL=Clickable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clickable.d.ts","sourceRoot":"","sources":["../../../../components/atoms/Clickable/Clickable.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"Clickable.d.ts","sourceRoot":"","sources":["../../../../components/atoms/Clickable/Clickable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8C,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/D,UAAU,cAAc;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAmBD,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC,CAe/E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clickable.stories.d.ts","sourceRoot":"","sources":["../../../../components/atoms/Clickable/Clickable.stories.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Clickable.stories.d.ts","sourceRoot":"","sources":["../../../../components/atoms/Clickable/Clickable.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,SAAS,CA8BhC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,SAAS,CAAC,CAAC;AAExC,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"}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.TertiaryDisabled = exports.Tertiary = exports.SecondaryDisabled = exports.Secondary = exports.PrimaryDisabled = exports.Primary = void 0;
|
|
7
4
|
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
5
|
const Clickable_1 = require("./Clickable");
|
|
11
6
|
const meta = {
|
|
12
7
|
title: "Atoms/Button/Button",
|
|
@@ -28,7 +23,7 @@ const meta = {
|
|
|
28
23
|
const handleOnClick = () => {
|
|
29
24
|
alert("Button clicked!");
|
|
30
25
|
};
|
|
31
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className:
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "story-container large flex", children: [(0, jsx_runtime_1.jsx)(Clickable_1.Clickable, Object.assign({}, args, { onClick: handleOnClick })), (0, jsx_runtime_1.jsx)(Clickable_1.Clickable, Object.assign({}, args, { href: "#", children: "Button as Link" }))] }));
|
|
32
27
|
},
|
|
33
28
|
};
|
|
34
29
|
exports.default = meta;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC, HTMLInputTypeAttribute } from "react";
|
|
2
|
+
import { PropsWithClassName } from "@becklyn/next/types/style";
|
|
3
|
+
export interface TextInputProps {
|
|
4
|
+
id?: string;
|
|
5
|
+
label: string;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
value?: string;
|
|
8
|
+
onChange?: (value: string) => void;
|
|
9
|
+
error?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
type?: HTMLInputTypeAttribute;
|
|
13
|
+
}
|
|
14
|
+
export declare const TextInput: FC<PropsWithClassName<TextInputProps>>;
|
|
15
|
+
//# sourceMappingURL=TextInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../../components/atoms/TextInput/TextInput.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,sBAAsB,EAAS,MAAM,OAAO,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/D,MAAM,WAAW,cAAc;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,sBAAsB,CAAC;CACjC;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,kBAAkB,CAAC,cAAc,CAAC,CA4C5D,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.TextInput = void 0;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
11
|
+
const TextInput_module_scss_1 = __importDefault(require("./TextInput.module.scss"));
|
|
12
|
+
const TextInput = ({ id: providedId, label, placeholder, value, error, onChange, disabled, required, className, type = "text", }) => {
|
|
13
|
+
const generatedId = (0, react_1.useId)();
|
|
14
|
+
const id = providedId !== null && providedId !== void 0 ? providedId : generatedId;
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, clsx_1.default)(TextInput_module_scss_1.default.wrapper, className), children: [label && ((0, jsx_runtime_1.jsxs)("label", { htmlFor: id, className: TextInput_module_scss_1.default.label, children: [label, required && " *"] })), (0, jsx_runtime_1.jsx)("input", { id: id, value: value, onChange: e => onChange === null || onChange === void 0 ? void 0 : onChange(e.target.value), placeholder: placeholder, disabled: disabled, required: required, className: (0, clsx_1.default)(TextInput_module_scss_1.default.input, disabled && TextInput_module_scss_1.default.disabled), type: type }), error && ((0, jsx_runtime_1.jsx)("output", { htmlFor: id, name: `${id}_error`, className: TextInput_module_scss_1.default.error, "aria-invalid": true, children: error }))] }));
|
|
16
|
+
};
|
|
17
|
+
exports.TextInput = TextInput;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
2
|
+
import { TextInput } from "./TextInput";
|
|
3
|
+
declare const meta: Meta<typeof TextInput>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof TextInput>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithoutLabel: Story;
|
|
8
|
+
export declare const Error: Story;
|
|
9
|
+
export declare const Disabled: Story;
|
|
10
|
+
//# sourceMappingURL=TextInput.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextInput.stories.d.ts","sourceRoot":"","sources":["../../../../components/atoms/TextInput/TextInput.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAkB,MAAM,aAAa,CAAC;AAQxD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,SAAS,CAahC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,SAAS,CAAC,CAAC;AAExC,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAI1B,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAMnB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAMtB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Disabled = exports.Error = exports.WithoutLabel = exports.Default = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const TextInput_1 = require("./TextInput");
|
|
7
|
+
const InteractiveInput = args => {
|
|
8
|
+
const [value, setValue] = (0, react_1.useState)("");
|
|
9
|
+
return (0, jsx_runtime_1.jsx)(TextInput_1.TextInput, Object.assign({}, args, { value: value, onChange: setValue }));
|
|
10
|
+
};
|
|
11
|
+
const meta = {
|
|
12
|
+
title: "Atoms/TextInput",
|
|
13
|
+
component: TextInput_1.TextInput,
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: "centered",
|
|
16
|
+
},
|
|
17
|
+
argTypes: {
|
|
18
|
+
label: { control: "text" },
|
|
19
|
+
placeholder: { control: "text" },
|
|
20
|
+
disabled: { control: "boolean" },
|
|
21
|
+
error: { control: "text" },
|
|
22
|
+
},
|
|
23
|
+
render: args => (0, jsx_runtime_1.jsx)(InteractiveInput, Object.assign({}, args)),
|
|
24
|
+
};
|
|
25
|
+
exports.default = meta;
|
|
26
|
+
exports.Default = {
|
|
27
|
+
args: {
|
|
28
|
+
label: "Label",
|
|
29
|
+
placeholder: "Text Label",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
exports.WithoutLabel = {
|
|
33
|
+
args: {
|
|
34
|
+
placeholder: "Text Label",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
exports.Error = {
|
|
38
|
+
args: {
|
|
39
|
+
label: "Label",
|
|
40
|
+
placeholder: "Text Label",
|
|
41
|
+
error: "Lorem ipsum",
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
exports.Disabled = {
|
|
45
|
+
args: {
|
|
46
|
+
label: "Label",
|
|
47
|
+
placeholder: "Text Label",
|
|
48
|
+
disabled: true,
|
|
49
|
+
},
|
|
50
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@becklyn/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://github.com/Becklyn-Studios/ts-libs/tree/main/packages/components",
|
|
6
6
|
"repository": {
|
|
@@ -16,25 +16,23 @@
|
|
|
16
16
|
"storybook-build": "storybook build"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"commander": "^14.0.
|
|
19
|
+
"commander": "^14.0.3"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@becklyn/eslint": "*",
|
|
23
|
-
"@becklyn/next": "
|
|
23
|
+
"@becklyn/next": "*",
|
|
24
24
|
"@becklyn/tsconfig": "*",
|
|
25
|
-
"@storybook/addon-
|
|
26
|
-
"@storybook/
|
|
27
|
-
"@
|
|
28
|
-
"@types/
|
|
29
|
-
"@types/react": "^19.2.7",
|
|
25
|
+
"@storybook/addon-docs": "^10.2.5",
|
|
26
|
+
"@storybook/nextjs-vite": "10.2.5",
|
|
27
|
+
"@types/node": "^25.2.0",
|
|
28
|
+
"@types/react": "^19.2.10",
|
|
30
29
|
"clsx": "^2.1.1",
|
|
31
|
-
"eslint-plugin-storybook": "^10.
|
|
32
|
-
"next": "^16.1.
|
|
33
|
-
"react": "^19.2.
|
|
34
|
-
"react-dom": "^19.2.
|
|
35
|
-
"sass": "^1.97.
|
|
36
|
-
"storybook": "^10.
|
|
37
|
-
"@storybook/nextjs-vite": "10.1.11",
|
|
30
|
+
"eslint-plugin-storybook": "^10.2.5",
|
|
31
|
+
"next": "^16.1.6",
|
|
32
|
+
"react": "^19.2.4",
|
|
33
|
+
"react-dom": "^19.2.4",
|
|
34
|
+
"sass": "^1.97.3",
|
|
35
|
+
"storybook": "^10.2.5",
|
|
38
36
|
"vite": "^7.3.1"
|
|
39
37
|
},
|
|
40
38
|
"peerDependencies": {
|
|
@@ -42,9 +40,10 @@
|
|
|
42
40
|
"react-dom": "^18.3.1 || ^19.0.0"
|
|
43
41
|
},
|
|
44
42
|
"bin": {
|
|
45
|
-
"
|
|
43
|
+
"components": "dist/bin/cli.js"
|
|
46
44
|
},
|
|
47
45
|
"files": [
|
|
48
|
-
"dist"
|
|
46
|
+
"dist",
|
|
47
|
+
"components"
|
|
49
48
|
]
|
|
50
49
|
}
|