@npm-tuan17tuii/ui-components 1.0.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) 2026 tuan17tui
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,107 @@
1
+ # @tuan17tui/ui-components
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@tuan17tui/ui-components.svg)](https://www.npmjs.com/package/@tuan17tui/ui-components)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Thư viện UI Components cho React, được build bằng TypeScript và tsup.
7
+
8
+ ## 🚀 Cài đặt
9
+
10
+ ```bash
11
+ npm install @tuan17tui/ui-components
12
+ ```
13
+
14
+ hoặc
15
+
16
+ ```bash
17
+ yarn add @tuan17tui/ui-components
18
+ ```
19
+
20
+ ## 📦 Sử dụng
21
+
22
+ ### Import Components
23
+
24
+ ```tsx
25
+ import { Button, Prompt } from '@tuan17tui/ui-components';
26
+
27
+ function App() {
28
+ return (
29
+ <div>
30
+ <Button variant="primary" size="medium">
31
+ Click me
32
+ </Button>
33
+
34
+ <Prompt
35
+ type="success"
36
+ title="Thành công!"
37
+ message="Thao tác đã được thực hiện thành công."
38
+ />
39
+ </div>
40
+ );
41
+ }
42
+ ```
43
+
44
+ ## 🎨 Components
45
+
46
+ ### Button
47
+
48
+ Component button với nhiều variants và sizes.
49
+
50
+ **Props:**
51
+ - `variant`: `'primary' | 'secondary' | 'outline'` (default: `'primary'`)
52
+ - `size`: `'small' | 'medium' | 'large'` (default: `'medium'`)
53
+ - `loading`: `boolean` (default: `false`)
54
+ - Kế thừa tất cả props của HTML button element
55
+
56
+ **Ví dụ:**
57
+
58
+ ```tsx
59
+ <Button variant="primary" size="large" onClick={() => alert('Clicked!')}>
60
+ Primary Button
61
+ </Button>
62
+
63
+ <Button variant="outline" size="small" loading>
64
+ Loading...
65
+ </Button>
66
+ ```
67
+
68
+ ### Prompt
69
+
70
+ Component hiển thị thông báo với các loại khác nhau.
71
+
72
+ **Props:**
73
+ - `title`: `string` (required) - Tiêu đề prompt
74
+ - `message`: `string` (required) - Nội dung thông báo
75
+ - `type`: `'info' | 'success' | 'warning' | 'error'` (default: `'info'`)
76
+ - `closable`: `boolean` (default: `true`)
77
+ - `onClose`: `() => void` - Callback khi đóng
78
+ - Kế thừa tất cả props của HTML div element
79
+
80
+ **Ví dụ:**
81
+
82
+ ```tsx
83
+ <Prompt
84
+ type="error"
85
+ title="Lỗi"
86
+ message="Đã xảy ra lỗi trong quá trình xử lý."
87
+ onClose={() => console.log('Prompt closed')}
88
+ />
89
+ ```
90
+
91
+ ## 🛠️ Development
92
+
93
+ ### Build
94
+
95
+ ```bash
96
+ npm run build
97
+ ```
98
+
99
+ ### Watch mode
100
+
101
+ ```bash
102
+ npm run dev
103
+ ```
104
+
105
+ ## 📄 License
106
+
107
+ MIT © tuan17tui
@@ -0,0 +1,43 @@
1
+ import React, { ButtonHTMLAttributes, HTMLAttributes } from 'react';
2
+
3
+ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
4
+ /**
5
+ * Kích thước của button
6
+ */
7
+ size?: 'small' | 'medium' | 'large';
8
+ /**
9
+ * Kiểu button
10
+ */
11
+ variant?: 'primary' | 'secondary' | 'outline';
12
+ /**
13
+ * Trạng thái loading
14
+ */
15
+ loading?: boolean;
16
+ }
17
+ declare const Button: React.FC<ButtonProps>;
18
+
19
+ interface PromptProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
20
+ /**
21
+ * Tiêu đề của prompt
22
+ */
23
+ title: string;
24
+ /**
25
+ * Nội dung mô tả
26
+ */
27
+ message: string;
28
+ /**
29
+ * Kiểu prompt
30
+ */
31
+ type?: 'info' | 'success' | 'warning' | 'error';
32
+ /**
33
+ * Có thể đóng được không
34
+ */
35
+ closable?: boolean;
36
+ /**
37
+ * Callback khi đóng
38
+ */
39
+ onClose?: () => void;
40
+ }
41
+ declare const Prompt: React.FC<PromptProps>;
42
+
43
+ export { Button, type ButtonProps, Prompt, type PromptProps };
@@ -0,0 +1,43 @@
1
+ import React, { ButtonHTMLAttributes, HTMLAttributes } from 'react';
2
+
3
+ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
4
+ /**
5
+ * Kích thước của button
6
+ */
7
+ size?: 'small' | 'medium' | 'large';
8
+ /**
9
+ * Kiểu button
10
+ */
11
+ variant?: 'primary' | 'secondary' | 'outline';
12
+ /**
13
+ * Trạng thái loading
14
+ */
15
+ loading?: boolean;
16
+ }
17
+ declare const Button: React.FC<ButtonProps>;
18
+
19
+ interface PromptProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
20
+ /**
21
+ * Tiêu đề của prompt
22
+ */
23
+ title: string;
24
+ /**
25
+ * Nội dung mô tả
26
+ */
27
+ message: string;
28
+ /**
29
+ * Kiểu prompt
30
+ */
31
+ type?: 'info' | 'success' | 'warning' | 'error';
32
+ /**
33
+ * Có thể đóng được không
34
+ */
35
+ closable?: boolean;
36
+ /**
37
+ * Callback khi đóng
38
+ */
39
+ onClose?: () => void;
40
+ }
41
+ declare const Prompt: React.FC<PromptProps>;
42
+
43
+ export { Button, type ButtonProps, Prompt, type PromptProps };
package/dist/index.js ADDED
@@ -0,0 +1,96 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var react = require('react');
5
+
6
+ // src/Button/Button.tsx
7
+ var Button = ({
8
+ children,
9
+ size = "medium",
10
+ variant = "primary",
11
+ loading = false,
12
+ disabled,
13
+ className = "",
14
+ style,
15
+ ...props
16
+ }) => {
17
+ const baseStyles = {
18
+ padding: size === "small" ? "6px 12px" : size === "large" ? "12px 24px" : "8px 16px",
19
+ fontSize: size === "small" ? "14px" : size === "large" ? "18px" : "16px",
20
+ border: "none",
21
+ borderRadius: "4px",
22
+ cursor: disabled || loading ? "not-allowed" : "pointer",
23
+ fontWeight: 500,
24
+ transition: "all 0.2s ease",
25
+ opacity: disabled || loading ? 0.6 : 1,
26
+ ...style
27
+ };
28
+ const variantStyles = variant === "primary" ? { backgroundColor: "#007bff", color: "#fff" } : variant === "secondary" ? { backgroundColor: "#6c757d", color: "#fff" } : { backgroundColor: "transparent", color: "#007bff", border: "1px solid #007bff" };
29
+ const combinedStyles = { ...baseStyles, ...variantStyles };
30
+ return /* @__PURE__ */ jsxRuntime.jsx(
31
+ "button",
32
+ {
33
+ className,
34
+ style: combinedStyles,
35
+ disabled: disabled || loading,
36
+ ...props,
37
+ children: loading ? "Loading..." : children
38
+ }
39
+ );
40
+ };
41
+ var Prompt = ({
42
+ title,
43
+ message,
44
+ type = "info",
45
+ closable = true,
46
+ onClose,
47
+ className = "",
48
+ style,
49
+ ...props
50
+ }) => {
51
+ const [isVisible, setIsVisible] = react.useState(true);
52
+ const handleClose = () => {
53
+ setIsVisible(false);
54
+ onClose?.();
55
+ };
56
+ if (!isVisible) return null;
57
+ const baseStyles = {
58
+ padding: "16px",
59
+ borderRadius: "6px",
60
+ marginBottom: "16px",
61
+ position: "relative",
62
+ border: "1px solid",
63
+ ...style
64
+ };
65
+ const typeStyles = type === "success" ? { backgroundColor: "#d4edda", borderColor: "#c3e6cb", color: "#155724" } : type === "warning" ? { backgroundColor: "#fff3cd", borderColor: "#ffeaa7", color: "#856404" } : type === "error" ? { backgroundColor: "#f8d7da", borderColor: "#f5c6cb", color: "#721c24" } : { backgroundColor: "#d1ecf1", borderColor: "#bee5eb", color: "#0c5460" };
66
+ const combinedStyles = { ...baseStyles, ...typeStyles };
67
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: combinedStyles, role: "alert", ...props, children: [
68
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontWeight: "bold", marginBottom: "8px", fontSize: "16px" }, children: title }),
69
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "14px", lineHeight: "1.5" }, children: message }),
70
+ closable && /* @__PURE__ */ jsxRuntime.jsx(
71
+ "button",
72
+ {
73
+ onClick: handleClose,
74
+ style: {
75
+ position: "absolute",
76
+ top: "12px",
77
+ right: "12px",
78
+ background: "none",
79
+ border: "none",
80
+ fontSize: "20px",
81
+ cursor: "pointer",
82
+ color: "inherit",
83
+ opacity: 0.7,
84
+ padding: "0 4px"
85
+ },
86
+ "aria-label": "Close",
87
+ children: "\xD7"
88
+ }
89
+ )
90
+ ] });
91
+ };
92
+
93
+ exports.Button = Button;
94
+ exports.Prompt = Prompt;
95
+ //# sourceMappingURL=index.js.map
96
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Button/Button.tsx","../src/Prompt/Prompt.tsx"],"names":["jsx","useState","jsxs"],"mappings":";;;;;;AAiBO,IAAM,SAAgC,CAAC;AAAA,EAC5C,QAAA;AAAA,EACA,IAAA,GAAO,QAAA;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,cAAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,EAAE,UAAA,EAAY,MAAA,EAAQ,YAAA,EAAc,KAAA,EAAO,QAAA,EAAU,MAAA,EAAO,EACrE,QAAA,EAAA,KAAA,EACH,CAAA;AAAA,oBACAA,cAAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,EAAE,UAAU,MAAA,EAAQ,UAAA,EAAY,KAAA,EAAM,EAAI,QAAA,EAAA,OAAA,EAAQ,CAAA;AAAA,IAC7D,4BACCA,cAAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QACC,OAAA,EAAS,WAAA;AAAA,QACT,KAAA,EAAO;AAAA,UACL,QAAA,EAAU,UAAA;AAAA,UACV,GAAA,EAAK,MAAA;AAAA,UACL,KAAA,EAAO,MAAA;AAAA,UACP,UAAA,EAAY,MAAA;AAAA,UACZ,MAAA,EAAQ,MAAA;AAAA,UACR,QAAA,EAAU,MAAA;AAAA,UACV,MAAA,EAAQ,SAAA;AAAA,UACR,KAAA,EAAO,SAAA;AAAA,UACP,OAAA,EAAS,GAAA;AAAA,UACT,OAAA,EAAS;AAAA,SACX;AAAA,QACA,YAAA,EAAW,OAAA;AAAA,QACZ,QAAA,EAAA;AAAA;AAAA;AAED,GAAA,EAEJ,CAAA;AAEJ","file":"index.js","sourcesContent":["import React, { ButtonHTMLAttributes } from 'react';\r\n\r\nexport interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\r\n /**\r\n * Kích thước của button\r\n */\r\n size?: 'small' | 'medium' | 'large';\r\n /**\r\n * Kiểu button\r\n */\r\n variant?: 'primary' | 'secondary' | 'outline';\r\n /**\r\n * Trạng thái loading\r\n */\r\n loading?: boolean;\r\n}\r\n\r\nexport const Button: React.FC<ButtonProps> = ({\r\n children,\r\n size = 'medium',\r\n variant = 'primary',\r\n loading = false,\r\n disabled,\r\n className = '',\r\n style,\r\n ...props\r\n}) => {\r\n // Base styles\r\n const baseStyles: React.CSSProperties = {\r\n padding: size === 'small' ? '6px 12px' : size === 'large' ? '12px 24px' : '8px 16px',\r\n fontSize: size === 'small' ? '14px' : size === 'large' ? '18px' : '16px',\r\n border: 'none',\r\n borderRadius: '4px',\r\n cursor: disabled || loading ? 'not-allowed' : 'pointer',\r\n fontWeight: 500,\r\n transition: 'all 0.2s ease',\r\n opacity: disabled || loading ? 0.6 : 1,\r\n ...style,\r\n };\r\n\r\n // Variant styles\r\n \r\n const variantStyles: React.CSSProperties = \r\n variant === 'primary'\r\n ? { backgroundColor: '#007bff', color: '#fff' }\r\n : variant === 'secondary'\r\n ? { backgroundColor: '#6c757d', color: '#fff' }\r\n : { backgroundColor: 'transparent', color: '#007bff', border: '1px solid #007bff' };\r\n\r\n const combinedStyles = { ...baseStyles, ...variantStyles };\r\n\r\n return (\r\n <button\r\n className={className}\r\n style={combinedStyles}\r\n disabled={disabled || loading}\r\n {...props}\r\n >\r\n {loading ? 'Loading...' : children}\r\n </button>\r\n );\r\n};\r\n","import React, { HTMLAttributes, useState } from 'react';\r\n\r\nexport interface PromptProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\r\n /**\r\n * Tiêu đề của prompt\r\n */\r\n title: string;\r\n /**\r\n * Nội dung mô tả\r\n */\r\n message: string;\r\n /**\r\n * Kiểu prompt\r\n */\r\n type?: 'info' | 'success' | 'warning' | 'error';\r\n /**\r\n * Có thể đóng được không\r\n */\r\n closable?: boolean;\r\n /**\r\n * Callback khi đóng\r\n */\r\n onClose?: () => void;\r\n}\r\n\r\nexport const Prompt: React.FC<PromptProps> = ({\r\n title,\r\n message,\r\n type = 'info',\r\n closable = true,\r\n onClose,\r\n className = '',\r\n style,\r\n ...props\r\n}) => {\r\n const [isVisible, setIsVisible] = useState(true);\r\n\r\n const handleClose = () => {\r\n setIsVisible(false);\r\n onClose?.();\r\n };\r\n\r\n if (!isVisible) return null;\r\n\r\n // Base styles\r\n const baseStyles: React.CSSProperties = {\r\n padding: '16px',\r\n borderRadius: '6px',\r\n marginBottom: '16px',\r\n position: 'relative',\r\n border: '1px solid',\r\n ...style,\r\n };\r\n\r\n // Type styles\r\n const typeStyles: React.CSSProperties =\r\n type === 'success'\r\n ? { backgroundColor: '#d4edda', borderColor: '#c3e6cb', color: '#155724' }\r\n : type === 'warning'\r\n ? { backgroundColor: '#fff3cd', borderColor: '#ffeaa7', color: '#856404' }\r\n : type === 'error'\r\n ? { backgroundColor: '#f8d7da', borderColor: '#f5c6cb', color: '#721c24' }\r\n : { backgroundColor: '#d1ecf1', borderColor: '#bee5eb', color: '#0c5460' };\r\n\r\n const combinedStyles = { ...baseStyles, ...typeStyles };\r\n\r\n return (\r\n <div className={className} style={combinedStyles} role=\"alert\" {...props}>\r\n <div style={{ fontWeight: 'bold', marginBottom: '8px', fontSize: '16px' }}>\r\n {title}\r\n </div>\r\n <div style={{ fontSize: '14px', lineHeight: '1.5' }}>{message}</div>\r\n {closable && (\r\n <button\r\n onClick={handleClose}\r\n style={{\r\n position: 'absolute',\r\n top: '12px',\r\n right: '12px',\r\n background: 'none',\r\n border: 'none',\r\n fontSize: '20px',\r\n cursor: 'pointer',\r\n color: 'inherit',\r\n opacity: 0.7,\r\n padding: '0 4px',\r\n }}\r\n aria-label=\"Close\"\r\n >\r\n ×\r\n </button>\r\n )}\r\n </div>\r\n );\r\n};\r\n"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,93 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { useState } from 'react';
3
+
4
+ // src/Button/Button.tsx
5
+ var Button = ({
6
+ children,
7
+ size = "medium",
8
+ variant = "primary",
9
+ loading = false,
10
+ disabled,
11
+ className = "",
12
+ style,
13
+ ...props
14
+ }) => {
15
+ const baseStyles = {
16
+ padding: size === "small" ? "6px 12px" : size === "large" ? "12px 24px" : "8px 16px",
17
+ fontSize: size === "small" ? "14px" : size === "large" ? "18px" : "16px",
18
+ border: "none",
19
+ borderRadius: "4px",
20
+ cursor: disabled || loading ? "not-allowed" : "pointer",
21
+ fontWeight: 500,
22
+ transition: "all 0.2s ease",
23
+ opacity: disabled || loading ? 0.6 : 1,
24
+ ...style
25
+ };
26
+ const variantStyles = variant === "primary" ? { backgroundColor: "#007bff", color: "#fff" } : variant === "secondary" ? { backgroundColor: "#6c757d", color: "#fff" } : { backgroundColor: "transparent", color: "#007bff", border: "1px solid #007bff" };
27
+ const combinedStyles = { ...baseStyles, ...variantStyles };
28
+ return /* @__PURE__ */ jsx(
29
+ "button",
30
+ {
31
+ className,
32
+ style: combinedStyles,
33
+ disabled: disabled || loading,
34
+ ...props,
35
+ children: loading ? "Loading..." : children
36
+ }
37
+ );
38
+ };
39
+ var Prompt = ({
40
+ title,
41
+ message,
42
+ type = "info",
43
+ closable = true,
44
+ onClose,
45
+ className = "",
46
+ style,
47
+ ...props
48
+ }) => {
49
+ const [isVisible, setIsVisible] = useState(true);
50
+ const handleClose = () => {
51
+ setIsVisible(false);
52
+ onClose?.();
53
+ };
54
+ if (!isVisible) return null;
55
+ const baseStyles = {
56
+ padding: "16px",
57
+ borderRadius: "6px",
58
+ marginBottom: "16px",
59
+ position: "relative",
60
+ border: "1px solid",
61
+ ...style
62
+ };
63
+ const typeStyles = type === "success" ? { backgroundColor: "#d4edda", borderColor: "#c3e6cb", color: "#155724" } : type === "warning" ? { backgroundColor: "#fff3cd", borderColor: "#ffeaa7", color: "#856404" } : type === "error" ? { backgroundColor: "#f8d7da", borderColor: "#f5c6cb", color: "#721c24" } : { backgroundColor: "#d1ecf1", borderColor: "#bee5eb", color: "#0c5460" };
64
+ const combinedStyles = { ...baseStyles, ...typeStyles };
65
+ return /* @__PURE__ */ jsxs("div", { className, style: combinedStyles, role: "alert", ...props, children: [
66
+ /* @__PURE__ */ jsx("div", { style: { fontWeight: "bold", marginBottom: "8px", fontSize: "16px" }, children: title }),
67
+ /* @__PURE__ */ jsx("div", { style: { fontSize: "14px", lineHeight: "1.5" }, children: message }),
68
+ closable && /* @__PURE__ */ jsx(
69
+ "button",
70
+ {
71
+ onClick: handleClose,
72
+ style: {
73
+ position: "absolute",
74
+ top: "12px",
75
+ right: "12px",
76
+ background: "none",
77
+ border: "none",
78
+ fontSize: "20px",
79
+ cursor: "pointer",
80
+ color: "inherit",
81
+ opacity: 0.7,
82
+ padding: "0 4px"
83
+ },
84
+ "aria-label": "Close",
85
+ children: "\xD7"
86
+ }
87
+ )
88
+ ] });
89
+ };
90
+
91
+ export { Button, Prompt };
92
+ //# sourceMappingURL=index.mjs.map
93
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Button/Button.tsx","../src/Prompt/Prompt.tsx"],"names":["jsx"],"mappings":";;;;AAiBO,IAAM,SAAgC,CAAC;AAAA,EAC5C,QAAA;AAAA,EACA,IAAA,GAAO,QAAA;AAAA,EACP,OAAA,GAAU,SAAA;AAAA,EACV,OAAA,GAAU,KAAA;AAAA,EACV,QAAA;AAAA,EACA,SAAA,GAAY,EAAA;AAAA,EACZ,KAAA;AAAA,EACA,GAAG;AACL,CAAA,KAAM;AAEJ,EAAA,MAAM,UAAA,GAAkC;AAAA,IACtC,SAAS,IAAA,KAAS,OAAA,GAAU,UAAA,GAAa,IAAA,KAAS,UAAU,WAAA,GAAc,UAAA;AAAA,IAC1E,UAAU,IAAA,KAAS,OAAA,GAAU,MAAA,GAAS,IAAA,KAAS,UAAU,MAAA,GAAS,MAAA;AAAA,IAClE,MAAA,EAAQ,MAAA;AAAA,IACR,YAAA,EAAc,KAAA;AAAA,IACd,MAAA,EAAQ,QAAA,IAAY,OAAA,GAAU,aAAA,GAAgB,SAAA;AAAA,IAC9C,UAAA,EAAY,GAAA;AAAA,IACZ,UAAA,EAAY,eAAA;AAAA,IACZ,OAAA,EAAS,QAAA,IAAY,OAAA,GAAU,GAAA,GAAM,CAAA;AAAA,IACrC,GAAG;AAAA,GACL;AAIA,EAAA,MAAM,aAAA,GACJ,YAAY,SAAA,GACR,EAAE,iBAAiB,SAAA,EAAW,KAAA,EAAO,MAAA,EAAO,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,EAAA;AAAA;AAAA;AAED,GAAA,EAEJ,CAAA;AAEJ","file":"index.mjs","sourcesContent":["import React, { ButtonHTMLAttributes } from 'react';\r\n\r\nexport interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\r\n /**\r\n * Kích thước của button\r\n */\r\n size?: 'small' | 'medium' | 'large';\r\n /**\r\n * Kiểu button\r\n */\r\n variant?: 'primary' | 'secondary' | 'outline';\r\n /**\r\n * Trạng thái loading\r\n */\r\n loading?: boolean;\r\n}\r\n\r\nexport const Button: React.FC<ButtonProps> = ({\r\n children,\r\n size = 'medium',\r\n variant = 'primary',\r\n loading = false,\r\n disabled,\r\n className = '',\r\n style,\r\n ...props\r\n}) => {\r\n // Base styles\r\n const baseStyles: React.CSSProperties = {\r\n padding: size === 'small' ? '6px 12px' : size === 'large' ? '12px 24px' : '8px 16px',\r\n fontSize: size === 'small' ? '14px' : size === 'large' ? '18px' : '16px',\r\n border: 'none',\r\n borderRadius: '4px',\r\n cursor: disabled || loading ? 'not-allowed' : 'pointer',\r\n fontWeight: 500,\r\n transition: 'all 0.2s ease',\r\n opacity: disabled || loading ? 0.6 : 1,\r\n ...style,\r\n };\r\n\r\n // Variant styles\r\n \r\n const variantStyles: React.CSSProperties = \r\n variant === 'primary'\r\n ? { backgroundColor: '#007bff', color: '#fff' }\r\n : variant === 'secondary'\r\n ? { backgroundColor: '#6c757d', color: '#fff' }\r\n : { backgroundColor: 'transparent', color: '#007bff', border: '1px solid #007bff' };\r\n\r\n const combinedStyles = { ...baseStyles, ...variantStyles };\r\n\r\n return (\r\n <button\r\n className={className}\r\n style={combinedStyles}\r\n disabled={disabled || loading}\r\n {...props}\r\n >\r\n {loading ? 'Loading...' : children}\r\n </button>\r\n );\r\n};\r\n","import React, { HTMLAttributes, useState } from 'react';\r\n\r\nexport interface PromptProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\r\n /**\r\n * Tiêu đề của prompt\r\n */\r\n title: string;\r\n /**\r\n * Nội dung mô tả\r\n */\r\n message: string;\r\n /**\r\n * Kiểu prompt\r\n */\r\n type?: 'info' | 'success' | 'warning' | 'error';\r\n /**\r\n * Có thể đóng được không\r\n */\r\n closable?: boolean;\r\n /**\r\n * Callback khi đóng\r\n */\r\n onClose?: () => void;\r\n}\r\n\r\nexport const Prompt: React.FC<PromptProps> = ({\r\n title,\r\n message,\r\n type = 'info',\r\n closable = true,\r\n onClose,\r\n className = '',\r\n style,\r\n ...props\r\n}) => {\r\n const [isVisible, setIsVisible] = useState(true);\r\n\r\n const handleClose = () => {\r\n setIsVisible(false);\r\n onClose?.();\r\n };\r\n\r\n if (!isVisible) return null;\r\n\r\n // Base styles\r\n const baseStyles: React.CSSProperties = {\r\n padding: '16px',\r\n borderRadius: '6px',\r\n marginBottom: '16px',\r\n position: 'relative',\r\n border: '1px solid',\r\n ...style,\r\n };\r\n\r\n // Type styles\r\n const typeStyles: React.CSSProperties =\r\n type === 'success'\r\n ? { backgroundColor: '#d4edda', borderColor: '#c3e6cb', color: '#155724' }\r\n : type === 'warning'\r\n ? { backgroundColor: '#fff3cd', borderColor: '#ffeaa7', color: '#856404' }\r\n : type === 'error'\r\n ? { backgroundColor: '#f8d7da', borderColor: '#f5c6cb', color: '#721c24' }\r\n : { backgroundColor: '#d1ecf1', borderColor: '#bee5eb', color: '#0c5460' };\r\n\r\n const combinedStyles = { ...baseStyles, ...typeStyles };\r\n\r\n return (\r\n <div className={className} style={combinedStyles} role=\"alert\" {...props}>\r\n <div style={{ fontWeight: 'bold', marginBottom: '8px', fontSize: '16px' }}>\r\n {title}\r\n </div>\r\n <div style={{ fontSize: '14px', lineHeight: '1.5' }}>{message}</div>\r\n {closable && (\r\n <button\r\n onClick={handleClose}\r\n style={{\r\n position: 'absolute',\r\n top: '12px',\r\n right: '12px',\r\n background: 'none',\r\n border: 'none',\r\n fontSize: '20px',\r\n cursor: 'pointer',\r\n color: 'inherit',\r\n opacity: 0.7,\r\n padding: '0 4px',\r\n }}\r\n aria-label=\"Close\"\r\n >\r\n ×\r\n </button>\r\n )}\r\n </div>\r\n );\r\n};\r\n"]}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@npm-tuan17tuii/ui-components",
3
+ "version": "1.0.0",
4
+ "description": "A lightweight React + TypeScript UI Component Library",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "require": "./dist/index.js",
11
+ "import": "./dist/index.mjs"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsup",
19
+ "dev": "tsup --watch",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "keywords": [
23
+ "react",
24
+ "typescript",
25
+ "ui",
26
+ "components",
27
+ "library"
28
+ ],
29
+ "author": "tuan17tui",
30
+ "license": "MIT",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/tuan17tuii/ui-components.git"
34
+ },
35
+ "peerDependencies": {
36
+ "react": "^18.0.0",
37
+ "react-dom": "^18.0.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/react": "^18.2.0",
41
+ "@types/react-dom": "^18.2.0",
42
+ "react": "^18.2.0",
43
+ "react-dom": "^18.2.0",
44
+ "tsup": "^8.0.0",
45
+ "typescript": "^5.3.0"
46
+ }
47
+ }