@nucleux/button 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 +21 -0
- package/dist/index.cjs +67 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nucleux
|
|
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/dist/index.cjs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var utils = require('@nucleux/utils');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
27
|
+
|
|
28
|
+
// src/index.tsx
|
|
29
|
+
var buttonVariants = {
|
|
30
|
+
primary: "border border-border bg-primary text-primary-foreground shadow-sm hover:bg-primary/90",
|
|
31
|
+
cta: "border border-border bg-info text-info-foreground shadow-sm hover:bg-info/90",
|
|
32
|
+
secondary: "border border-border bg-background text-foreground shadow-sm hover:bg-accent",
|
|
33
|
+
ghost: "text-foreground hover:bg-accent",
|
|
34
|
+
destructive: "border border-border bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90"
|
|
35
|
+
};
|
|
36
|
+
var buttonSizes = {
|
|
37
|
+
sm: "h-8 rounded-lg px-3 text-sm",
|
|
38
|
+
md: "h-9 rounded-lg px-4 text-sm",
|
|
39
|
+
lg: "h-10 rounded-lg px-5 text-sm",
|
|
40
|
+
icon: "size-9 rounded-lg"
|
|
41
|
+
};
|
|
42
|
+
var Button = React__namespace.forwardRef(
|
|
43
|
+
({ variant = "primary", size = "md", leftIcon, rightIcon, type = "button", className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
44
|
+
"button",
|
|
45
|
+
{
|
|
46
|
+
ref,
|
|
47
|
+
type,
|
|
48
|
+
className: utils.cn(
|
|
49
|
+
"inline-flex select-none items-center justify-center gap-1.5 whitespace-nowrap font-semibold tracking-[0.005em] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50",
|
|
50
|
+
buttonVariants[variant],
|
|
51
|
+
buttonSizes[size],
|
|
52
|
+
className
|
|
53
|
+
),
|
|
54
|
+
...props,
|
|
55
|
+
children: [
|
|
56
|
+
leftIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex shrink-0 items-center", children: leftIcon }),
|
|
57
|
+
children,
|
|
58
|
+
rightIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex shrink-0 items-center", children: rightIcon })
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
Button.displayName = "Button";
|
|
64
|
+
|
|
65
|
+
exports.Button = Button;
|
|
66
|
+
//# sourceMappingURL=index.cjs.map
|
|
67
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":["React","jsxs","cn","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAM,cAAA,GAAgD;AAAA,EACpD,OAAA,EAAS,uFAAA;AAAA,EACT,GAAA,EAAK,8EAAA;AAAA,EACL,SAAA,EAAW,8EAAA;AAAA,EACX,KAAA,EAAO,iCAAA;AAAA,EACP,WAAA,EACE;AACJ,CAAA;AAEA,IAAM,WAAA,GAA0C;AAAA,EAC9C,EAAA,EAAI,6BAAA;AAAA,EACJ,EAAA,EAAI,6BAAA;AAAA,EACJ,EAAA,EAAI,8BAAA;AAAA,EACJ,IAAA,EAAM;AACR,CAAA;AAWO,IAAM,MAAA,GAAeA,gBAAA,CAAA,UAAA;AAAA,EAC1B,CACE,EAAE,OAAA,GAAU,SAAA,EAAW,OAAO,IAAA,EAAM,QAAA,EAAU,SAAA,EAAW,IAAA,GAAO,UAAU,SAAA,EAAW,QAAA,EAAU,GAAG,KAAA,IAClG,GAAA,qBAEAC,eAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,IAAA;AAAA,MACA,SAAA,EAAWC,QAAA;AAAA,QACT,4TAAA;AAAA,QACA,eAAe,OAAO,CAAA;AAAA,QACtB,YAAY,IAAI,CAAA;AAAA,QAChB;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA,QAAA,QAAA,oBAAYC,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,mCAAA,EAAqC,QAAA,EAAA,QAAA,EAAS,CAAA;AAAA,QAC1E,QAAA;AAAA,QACA,SAAA,oBAAaA,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,qCAAqC,QAAA,EAAA,SAAA,EAAU;AAAA;AAAA;AAAA;AAGnF;AACA,MAAA,CAAO,WAAA,GAAc,QAAA","file":"index.cjs","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\n\nexport type ButtonVariant =\n | \"primary\"\n | \"cta\"\n | \"secondary\"\n | \"ghost\"\n | \"destructive\";\n\nexport type ButtonSize = \"sm\" | \"md\" | \"lg\" | \"icon\";\n\n// Canonical spec (Figma \"Button\"): rounded-lg, semibold 14px, subtle border +\n// shadow-sm on filled/outline variants; ghost is chromeless.\nconst buttonVariants: Record<ButtonVariant, string> = {\n primary: \"border border-border bg-primary text-primary-foreground shadow-sm hover:bg-primary/90\",\n cta: \"border border-border bg-info text-info-foreground shadow-sm hover:bg-info/90\",\n secondary: \"border border-border bg-background text-foreground shadow-sm hover:bg-accent\",\n ghost: \"text-foreground hover:bg-accent\",\n destructive:\n \"border border-border bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90\",\n};\n\nconst buttonSizes: Record<ButtonSize, string> = {\n sm: \"h-8 rounded-lg px-3 text-sm\",\n md: \"h-9 rounded-lg px-4 text-sm\",\n lg: \"h-10 rounded-lg px-5 text-sm\",\n icon: \"size-9 rounded-lg\",\n};\n\nexport interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: ButtonVariant;\n size?: ButtonSize;\n /** Icon rendered before the label. */\n leftIcon?: React.ReactNode;\n /** Icon rendered after the label. */\n rightIcon?: React.ReactNode;\n}\n\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n { variant = \"primary\", size = \"md\", leftIcon, rightIcon, type = \"button\", className, children, ...props },\n ref,\n ) => (\n <button\n ref={ref}\n type={type}\n className={cn(\n \"inline-flex select-none items-center justify-center gap-1.5 whitespace-nowrap font-semibold tracking-[0.005em] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50\",\n buttonVariants[variant],\n buttonSizes[size],\n className,\n )}\n {...props}\n >\n {leftIcon && <span className=\"inline-flex shrink-0 items-center\">{leftIcon}</span>}\n {children}\n {rightIcon && <span className=\"inline-flex shrink-0 items-center\">{rightIcon}</span>}\n </button>\n ),\n);\nButton.displayName = \"Button\";\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type ButtonVariant = "primary" | "cta" | "secondary" | "ghost" | "destructive";
|
|
4
|
+
type ButtonSize = "sm" | "md" | "lg" | "icon";
|
|
5
|
+
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
6
|
+
variant?: ButtonVariant;
|
|
7
|
+
size?: ButtonSize;
|
|
8
|
+
/** Icon rendered before the label. */
|
|
9
|
+
leftIcon?: React.ReactNode;
|
|
10
|
+
/** Icon rendered after the label. */
|
|
11
|
+
rightIcon?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
14
|
+
|
|
15
|
+
export { Button, type ButtonProps, type ButtonSize, type ButtonVariant };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type ButtonVariant = "primary" | "cta" | "secondary" | "ghost" | "destructive";
|
|
4
|
+
type ButtonSize = "sm" | "md" | "lg" | "icon";
|
|
5
|
+
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
6
|
+
variant?: ButtonVariant;
|
|
7
|
+
size?: ButtonSize;
|
|
8
|
+
/** Icon rendered before the label. */
|
|
9
|
+
leftIcon?: React.ReactNode;
|
|
10
|
+
/** Icon rendered after the label. */
|
|
11
|
+
rightIcon?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
14
|
+
|
|
15
|
+
export { Button, type ButtonProps, type ButtonSize, type ButtonVariant };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cn } from '@nucleux/utils';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/index.tsx
|
|
7
|
+
var buttonVariants = {
|
|
8
|
+
primary: "border border-border bg-primary text-primary-foreground shadow-sm hover:bg-primary/90",
|
|
9
|
+
cta: "border border-border bg-info text-info-foreground shadow-sm hover:bg-info/90",
|
|
10
|
+
secondary: "border border-border bg-background text-foreground shadow-sm hover:bg-accent",
|
|
11
|
+
ghost: "text-foreground hover:bg-accent",
|
|
12
|
+
destructive: "border border-border bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90"
|
|
13
|
+
};
|
|
14
|
+
var buttonSizes = {
|
|
15
|
+
sm: "h-8 rounded-lg px-3 text-sm",
|
|
16
|
+
md: "h-9 rounded-lg px-4 text-sm",
|
|
17
|
+
lg: "h-10 rounded-lg px-5 text-sm",
|
|
18
|
+
icon: "size-9 rounded-lg"
|
|
19
|
+
};
|
|
20
|
+
var Button = React.forwardRef(
|
|
21
|
+
({ variant = "primary", size = "md", leftIcon, rightIcon, type = "button", className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
22
|
+
"button",
|
|
23
|
+
{
|
|
24
|
+
ref,
|
|
25
|
+
type,
|
|
26
|
+
className: cn(
|
|
27
|
+
"inline-flex select-none items-center justify-center gap-1.5 whitespace-nowrap font-semibold tracking-[0.005em] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50",
|
|
28
|
+
buttonVariants[variant],
|
|
29
|
+
buttonSizes[size],
|
|
30
|
+
className
|
|
31
|
+
),
|
|
32
|
+
...props,
|
|
33
|
+
children: [
|
|
34
|
+
leftIcon && /* @__PURE__ */ jsx("span", { className: "inline-flex shrink-0 items-center", children: leftIcon }),
|
|
35
|
+
children,
|
|
36
|
+
rightIcon && /* @__PURE__ */ jsx("span", { className: "inline-flex shrink-0 items-center", children: rightIcon })
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
Button.displayName = "Button";
|
|
42
|
+
|
|
43
|
+
export { Button };
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":";;;;;AAcA,IAAM,cAAA,GAAgD;AAAA,EACpD,OAAA,EAAS,uFAAA;AAAA,EACT,GAAA,EAAK,8EAAA;AAAA,EACL,SAAA,EAAW,8EAAA;AAAA,EACX,KAAA,EAAO,iCAAA;AAAA,EACP,WAAA,EACE;AACJ,CAAA;AAEA,IAAM,WAAA,GAA0C;AAAA,EAC9C,EAAA,EAAI,6BAAA;AAAA,EACJ,EAAA,EAAI,6BAAA;AAAA,EACJ,EAAA,EAAI,8BAAA;AAAA,EACJ,IAAA,EAAM;AACR,CAAA;AAWO,IAAM,MAAA,GAAe,KAAA,CAAA,UAAA;AAAA,EAC1B,CACE,EAAE,OAAA,GAAU,SAAA,EAAW,OAAO,IAAA,EAAM,QAAA,EAAU,SAAA,EAAW,IAAA,GAAO,UAAU,SAAA,EAAW,QAAA,EAAU,GAAG,KAAA,IAClG,GAAA,qBAEA,IAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,IAAA;AAAA,MACA,SAAA,EAAW,EAAA;AAAA,QACT,4TAAA;AAAA,QACA,eAAe,OAAO,CAAA;AAAA,QACtB,YAAY,IAAI,CAAA;AAAA,QAChB;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA,QAAA,QAAA,oBAAY,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,mCAAA,EAAqC,QAAA,EAAA,QAAA,EAAS,CAAA;AAAA,QAC1E,QAAA;AAAA,QACA,SAAA,oBAAa,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,qCAAqC,QAAA,EAAA,SAAA,EAAU;AAAA;AAAA;AAAA;AAGnF;AACA,MAAA,CAAO,WAAA,GAAc,QAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\n\nexport type ButtonVariant =\n | \"primary\"\n | \"cta\"\n | \"secondary\"\n | \"ghost\"\n | \"destructive\";\n\nexport type ButtonSize = \"sm\" | \"md\" | \"lg\" | \"icon\";\n\n// Canonical spec (Figma \"Button\"): rounded-lg, semibold 14px, subtle border +\n// shadow-sm on filled/outline variants; ghost is chromeless.\nconst buttonVariants: Record<ButtonVariant, string> = {\n primary: \"border border-border bg-primary text-primary-foreground shadow-sm hover:bg-primary/90\",\n cta: \"border border-border bg-info text-info-foreground shadow-sm hover:bg-info/90\",\n secondary: \"border border-border bg-background text-foreground shadow-sm hover:bg-accent\",\n ghost: \"text-foreground hover:bg-accent\",\n destructive:\n \"border border-border bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90\",\n};\n\nconst buttonSizes: Record<ButtonSize, string> = {\n sm: \"h-8 rounded-lg px-3 text-sm\",\n md: \"h-9 rounded-lg px-4 text-sm\",\n lg: \"h-10 rounded-lg px-5 text-sm\",\n icon: \"size-9 rounded-lg\",\n};\n\nexport interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: ButtonVariant;\n size?: ButtonSize;\n /** Icon rendered before the label. */\n leftIcon?: React.ReactNode;\n /** Icon rendered after the label. */\n rightIcon?: React.ReactNode;\n}\n\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n { variant = \"primary\", size = \"md\", leftIcon, rightIcon, type = \"button\", className, children, ...props },\n ref,\n ) => (\n <button\n ref={ref}\n type={type}\n className={cn(\n \"inline-flex select-none items-center justify-center gap-1.5 whitespace-nowrap font-semibold tracking-[0.005em] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50\",\n buttonVariants[variant],\n buttonSizes[size],\n className,\n )}\n {...props}\n >\n {leftIcon && <span className=\"inline-flex shrink-0 items-center\">{leftIcon}</span>}\n {children}\n {rightIcon && <span className=\"inline-flex shrink-0 items-center\">{rightIcon}</span>}\n </button>\n ),\n);\nButton.displayName = \"Button\";\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nucleux/button",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"react": ">=18",
|
|
21
|
+
"react-dom": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@nucleux/utils": "0.1.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"tsup": "^8.3.5",
|
|
28
|
+
"typescript": "^5.7.2",
|
|
29
|
+
"@types/react": "^18.3.18",
|
|
30
|
+
"react": "^18.3.1",
|
|
31
|
+
"lucide-react": "^0.469.0"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/intelligaia-open-labs/nucleux.git",
|
|
40
|
+
"directory": "packages/button"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/intelligaia-open-labs/nucleux#readme",
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsup"
|
|
45
|
+
}
|
|
46
|
+
}
|