@causw/components 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.
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +83 -0
- package/dist/index.mjs +46 -0
- package/package.json +44 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
4
|
+
variant?: 'primary' | 'secondary' | 'outline';
|
|
5
|
+
size?: 'sm' | 'md' | 'lg';
|
|
6
|
+
fullWidth?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
|
|
10
|
+
export { Button, type ButtonProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
4
|
+
variant?: 'primary' | 'secondary' | 'outline';
|
|
5
|
+
size?: 'sm' | 'md' | 'lg';
|
|
6
|
+
fullWidth?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
|
|
10
|
+
export { Button, type ButtonProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
Button: () => Button
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
|
|
37
|
+
// src/Button/Button.tsx
|
|
38
|
+
var import_react = __toESM(require("react"));
|
|
39
|
+
|
|
40
|
+
// src/Button/Button.styles.ts
|
|
41
|
+
var buttonStyles = ({ variant, size, fullWidth }) => {
|
|
42
|
+
const baseStyles = `
|
|
43
|
+
inline-flex items-center justify-center
|
|
44
|
+
font-medium rounded-md
|
|
45
|
+
transition-colors duration-200
|
|
46
|
+
focus:outline-none focus:ring-2 focus:ring-offset-2
|
|
47
|
+
disabled:opacity-50 disabled:cursor-not-allowed
|
|
48
|
+
`.replace(/\s+/g, " ").trim();
|
|
49
|
+
const variantStyles = {
|
|
50
|
+
primary: `bg-primary-500 text-white hover:bg-primary-600 focus:ring-primary-500`,
|
|
51
|
+
secondary: `bg-gray-500 text-white hover:bg-gray-600 focus:ring-gray-500`,
|
|
52
|
+
outline: `border-2 border-primary-500 text-primary-500 hover:bg-primary-50 focus:ring-primary-500`
|
|
53
|
+
};
|
|
54
|
+
const sizeStyles = {
|
|
55
|
+
sm: `px-3 py-1.5 text-sm`,
|
|
56
|
+
md: `px-4 py-2 text-base`,
|
|
57
|
+
lg: `px-6 py-3 text-lg`
|
|
58
|
+
};
|
|
59
|
+
const widthStyle = fullWidth ? "w-full" : "";
|
|
60
|
+
return `${baseStyles} ${variantStyles[variant]} ${sizeStyles[size]} ${widthStyle}`.trim();
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/Button/Button.tsx
|
|
64
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
65
|
+
var Button = import_react.default.forwardRef(
|
|
66
|
+
({ variant = "primary", size = "md", fullWidth = false, children, className = "", ...props }, ref) => {
|
|
67
|
+
const classes = buttonStyles({ variant, size, fullWidth });
|
|
68
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
69
|
+
"button",
|
|
70
|
+
{
|
|
71
|
+
ref,
|
|
72
|
+
className: `${classes} ${className}`,
|
|
73
|
+
...props,
|
|
74
|
+
children
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
Button.displayName = "Button";
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
Button
|
|
83
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/Button/Button.tsx
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
// src/Button/Button.styles.ts
|
|
5
|
+
var buttonStyles = ({ variant, size, fullWidth }) => {
|
|
6
|
+
const baseStyles = `
|
|
7
|
+
inline-flex items-center justify-center
|
|
8
|
+
font-medium rounded-md
|
|
9
|
+
transition-colors duration-200
|
|
10
|
+
focus:outline-none focus:ring-2 focus:ring-offset-2
|
|
11
|
+
disabled:opacity-50 disabled:cursor-not-allowed
|
|
12
|
+
`.replace(/\s+/g, " ").trim();
|
|
13
|
+
const variantStyles = {
|
|
14
|
+
primary: `bg-primary-500 text-white hover:bg-primary-600 focus:ring-primary-500`,
|
|
15
|
+
secondary: `bg-gray-500 text-white hover:bg-gray-600 focus:ring-gray-500`,
|
|
16
|
+
outline: `border-2 border-primary-500 text-primary-500 hover:bg-primary-50 focus:ring-primary-500`
|
|
17
|
+
};
|
|
18
|
+
const sizeStyles = {
|
|
19
|
+
sm: `px-3 py-1.5 text-sm`,
|
|
20
|
+
md: `px-4 py-2 text-base`,
|
|
21
|
+
lg: `px-6 py-3 text-lg`
|
|
22
|
+
};
|
|
23
|
+
const widthStyle = fullWidth ? "w-full" : "";
|
|
24
|
+
return `${baseStyles} ${variantStyles[variant]} ${sizeStyles[size]} ${widthStyle}`.trim();
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/Button/Button.tsx
|
|
28
|
+
import { jsx } from "react/jsx-runtime";
|
|
29
|
+
var Button = React.forwardRef(
|
|
30
|
+
({ variant = "primary", size = "md", fullWidth = false, children, className = "", ...props }, ref) => {
|
|
31
|
+
const classes = buttonStyles({ variant, size, fullWidth });
|
|
32
|
+
return /* @__PURE__ */ jsx(
|
|
33
|
+
"button",
|
|
34
|
+
{
|
|
35
|
+
ref,
|
|
36
|
+
className: `${classes} ${className}`,
|
|
37
|
+
...props,
|
|
38
|
+
children
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
Button.displayName = "Button";
|
|
44
|
+
export {
|
|
45
|
+
Button
|
|
46
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@causw/components",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "UI components for CAUSW Design System",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@causw/tokens": "0.0.1"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react": "^18.2.0",
|
|
23
|
+
"react-dom": "^18.2.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@testing-library/react": "^14.0.0",
|
|
27
|
+
"@types/react": "^18.2.0",
|
|
28
|
+
"@types/react-dom": "^18.2.0",
|
|
29
|
+
"react": "^18.2.0",
|
|
30
|
+
"react-dom": "^18.2.0",
|
|
31
|
+
"tsup": "^8.0.0",
|
|
32
|
+
"typescript": "^5.3.0",
|
|
33
|
+
"vitest": "^1.0.0"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --external react",
|
|
40
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --external react --watch",
|
|
41
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
42
|
+
"test": "vitest"
|
|
43
|
+
}
|
|
44
|
+
}
|