tango-ui-cw 0.2.6 → 0.2.8

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.
Files changed (38) hide show
  1. package/dist/index.js +256 -15
  2. package/dist/index.mjs +26118 -1301
  3. package/package.json +3 -6
  4. package/src/component/CSSFab/useTangoStyle.jsx +0 -182
  5. package/src/component/MaterialButton/MaterialButton.module.css +0 -64
  6. package/src/component/MaterialButton/index.jsx +0 -70
  7. package/src/component/MaterialInput/MaterialInput.module.css +0 -37
  8. package/src/component/MaterialInput/index.jsx +0 -35
  9. package/src/component/TButton/TButton.module.css +0 -184
  10. package/src/component/TButton/index.jsx +0 -81
  11. package/src/component/TColorPicker/TColorPicker.module.css +0 -24
  12. package/src/component/TColorPicker/index.jsx +0 -107
  13. package/src/component/TDate/index.jsx +0 -145
  14. package/src/component/TDatePicker/TDatePicker.module.css +0 -12
  15. package/src/component/TDatePicker/index.jsx +0 -72
  16. package/src/component/TDrawer/TDrawer.module.css +0 -203
  17. package/src/component/TDrawer/index.jsx +0 -80
  18. package/src/component/TInput/TInput.module.css +0 -67
  19. package/src/component/TInput/index.jsx +0 -94
  20. package/src/component/TLayout/TLayout.css +0 -88
  21. package/src/component/TLayout/index.jsx +0 -76
  22. package/src/component/TLine/TLine.module.css +0 -52
  23. package/src/component/TLine/index.jsx +0 -47
  24. package/src/component/TMark/TMark.module.css +0 -6
  25. package/src/component/TMark/index.jsx +0 -68
  26. package/src/component/TModal/TModal.module.css +0 -109
  27. package/src/component/TModal/index.jsx +0 -75
  28. package/src/component/TNotice/TNotice.module.css +0 -50
  29. package/src/component/TNotice/index.jsx +0 -37
  30. package/src/component/TNotice/useNotice.jsx +0 -53
  31. package/src/component/TSearch/TSearch.module.css +0 -80
  32. package/src/component/TSearch/index.jsx +0 -86
  33. package/src/component/TSpace/TSpace.module.css +0 -43
  34. package/src/component/TSpace/index.jsx +0 -60
  35. package/src/component/TTable/TTable.module.css +0 -26
  36. package/src/component/TTable/index.jsx +0 -72
  37. package/src/component/TTooltip/TTooltip.module.css +0 -66
  38. package/src/component/TTooltip/index.jsx +0 -33
@@ -1,107 +0,0 @@
1
- // 封装的 ColorPicker 组件
2
- import React, { useState } from "react";
3
- import PropTypes from "prop-types";
4
- import styles from "./TColorPicker.module.css";
5
- import { useTangoStyle } from "../CSSFab/useTangoStyle";
6
-
7
- export default function ColorPicker(props) {
8
- const {
9
- sx = {},
10
- style: userStyle = {},
11
- className: userClassName = "",
12
- disabled,
13
- onChange,
14
- showText
15
- } = props;
16
-
17
- const [color, setColor] = useState("#4caf50");
18
-
19
- const handleChange = (e) => {
20
- const value = e.target.value;
21
- setColor(value);
22
- if (onChange) onChange(value);
23
- };
24
-
25
- const className = `${styles.colorPicker} ${
26
- disabled ? styles.colorPickerDisabled : ""
27
- } ${userClassName}`;
28
-
29
- const sxStyle = useTangoStyle(sx);
30
- const combinedStyle = { ...sxStyle, ...userStyle };
31
-
32
- const hexToRgb = (hex) => {
33
- const r = parseInt(hex.slice(1, 3), 16);
34
- const g = parseInt(hex.slice(3, 5), 16);
35
- const b = parseInt(hex.slice(5, 7), 16);
36
- return `rgb(${r}, ${g}, ${b})`;
37
- };
38
-
39
- const hexToHsl = (hex) => {
40
- let r = parseInt(hex.slice(1, 3), 16) / 255;
41
- let g = parseInt(hex.slice(3, 5), 16) / 255;
42
- let b = parseInt(hex.slice(5, 7), 16) / 255;
43
- let max = Math.max(r, g, b),
44
- min = Math.min(r, g, b);
45
- let h, s, l = (max + min) / 2;
46
-
47
- if (max === min) {
48
- h = s = 0;
49
- } else {
50
- let d = max - min;
51
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
52
- switch (max) {
53
- case r:
54
- h = (g - b) / d + (g < b ? 6 : 0);
55
- break;
56
- case g:
57
- h = (b - r) / d + 2;
58
- break;
59
- case b:
60
- h = (r - g) / d + 4;
61
- break;
62
- }
63
- h /= 6;
64
- }
65
-
66
- return `hsl(${Math.round(h * 360)}, ${Math.round(s * 100)}%, ${Math.round(
67
- l * 100
68
- )}%)`;
69
- };
70
-
71
- return (
72
- <div className={styles.colorPickerWrapper} style={combinedStyle}>
73
- <input
74
- type="color"
75
- value={color}
76
- onChange={handleChange}
77
- className={className}
78
- disabled={disabled}
79
- />
80
- {showText && (
81
- <div className={styles.colorText}>
82
- <div>{color.toUpperCase()}</div>
83
- <div>{hexToRgb(color)}</div>
84
- <div>{hexToHsl(color)}</div>
85
- </div>
86
- )}
87
- </div>
88
- );
89
- };
90
-
91
- ColorPicker.propTypes = {
92
- sx: PropTypes.object,
93
- style: PropTypes.object,
94
- className: PropTypes.string,
95
- disabled: PropTypes.bool,
96
- onChange: PropTypes.func,
97
- showText: PropTypes.bool,
98
- };
99
-
100
- ColorPicker.defaultProps = {
101
- sx: {},
102
- style: {},
103
- className: "",
104
- disabled: false,
105
- onChange: () => {},
106
- showText: false,
107
- };
@@ -1,145 +0,0 @@
1
- import PropTypes from "prop-types";
2
- import { useTangoStyle } from "../CSSFab/useTangoStyle"; // 导入 useFastStyle 函数
3
-
4
- export default function Date(props) {
5
- const { type = "default", single = false, sx = {}, style: userStyle = {}, en = false } = props|| {};
6
- // 用于接收 sx 属性设置的样式
7
- const sxStyle = useTangoStyle(sx);
8
-
9
- // 合并 sx 和 style,确保 style 优先级更高
10
- const combinedStyle = { ...sxStyle, ...userStyle };
11
-
12
- Date.propTypes = {
13
- type: PropTypes.oneOf([
14
- "line",
15
- "full",
16
- "full-line",
17
- "year-week",
18
- "year-week-line",
19
- "week-time",
20
- "no-s",
21
- "no-s-line",
22
- "us-full",
23
- "us-full-line",
24
- ]),
25
- single: PropTypes.bool, // 控制显示“周”或“星期”
26
- sx: PropTypes.object, // 自定义样式对象
27
- style: PropTypes.object, // 用户传入的 style 属性
28
- en: PropTypes.bool, // 控制英文格式
29
- };
30
-
31
- Date.defaultProps = {
32
- type: "default", // 默认无 type 的格式
33
- single: false, // 默认显示 "星期"
34
- sx: {},
35
- style: {},
36
- en: false, // 默认不使用英文
37
- };
38
-
39
- // 各类时间格式
40
- const formatDate = (type) => {
41
- const date = new Date();
42
- let locale = en ? "en-US" : "zh-CN";
43
- let formattedWeekday = date.toLocaleString(locale, { weekday: "long" });
44
-
45
- // 如果 single 为 true,替换 "星期" 为 "周",英文模式不需要转换
46
- if (!en && single) {
47
- formattedWeekday = formattedWeekday.replace("星期", "周");
48
- }
49
-
50
- switch (type) {
51
- case "line":
52
- return date.toLocaleDateString(locale, {
53
- year: "numeric",
54
- month: "2-digit",
55
- day: "2-digit",
56
- }).replaceAll("/", "-");
57
- case "full":
58
- return `${date.toLocaleDateString(locale, {
59
- year: "numeric",
60
- month: "2-digit",
61
- day: "2-digit",
62
- })} ${formattedWeekday} ${date.toLocaleTimeString(locale, {
63
- hour: "2-digit",
64
- minute: "2-digit",
65
- second: "2-digit",
66
- })}`;
67
- case "full-line":
68
- return `${date.toLocaleDateString(locale, {
69
- year: "numeric",
70
- month: "2-digit",
71
- day: "2-digit",
72
- }).replaceAll("/", "-")} ${formattedWeekday} ${date.toLocaleTimeString(locale, {
73
- hour: "2-digit",
74
- minute: "2-digit",
75
- second: "2-digit",
76
- })}`;
77
- case "year-week":
78
- return `${date.toLocaleDateString(locale, {
79
- year: "numeric",
80
- month: "2-digit",
81
- day: "2-digit",
82
- })} ${formattedWeekday}`;
83
- case "year-week-line":
84
- return `${date.toLocaleDateString(locale, {
85
- year: "numeric",
86
- month: "2-digit",
87
- day: "2-digit",
88
- }).replaceAll("/", "-")} ${formattedWeekday}`;
89
- case "week-time":
90
- return `${formattedWeekday} ${date.toLocaleTimeString(locale, {
91
- hour: "2-digit",
92
- minute: "2-digit",
93
- second: "2-digit",
94
- })}`;
95
- case "no-s":
96
- return `${date.toLocaleDateString(locale, {
97
- year: "numeric",
98
- month: "2-digit",
99
- day: "2-digit",
100
- })} ${formattedWeekday} ${date.toLocaleTimeString(locale, {
101
- hour: "2-digit",
102
- minute: "2-digit",
103
- })}`;
104
- case "no-s-line":
105
- return `${date.toLocaleDateString(locale, {
106
- year: "numeric",
107
- month: "2-digit",
108
- day: "2-digit",
109
- }).replaceAll("/", "-")} ${formattedWeekday} ${date.toLocaleTimeString(locale, {
110
- hour: "2-digit",
111
- minute: "2-digit",
112
- })}`;
113
- case "us-full":
114
- return `${date.toLocaleDateString("en-US", {
115
- year: "numeric",
116
- month: "2-digit",
117
- day: "2-digit",
118
- })} ${formattedWeekday} ${date.toLocaleTimeString(locale, {
119
- hour: "2-digit",
120
- minute: "2-digit",
121
- second: "2-digit",
122
- })}`;
123
- case "us-full-line":
124
- return `${date.toLocaleDateString("en-US", {
125
- year: "numeric",
126
- month: "2-digit",
127
- day: "2-digit",
128
- }).replaceAll("/", "-")} ${formattedWeekday} ${date.toLocaleTimeString(locale, {
129
- hour: "2-digit",
130
- minute: "2-digit",
131
- second: "2-digit",
132
- })}`;
133
- default:
134
- // 默认格式 年/月/日
135
- return date.toLocaleDateString(locale, {
136
- year: "numeric",
137
- month: "2-digit",
138
- day: "2-digit",
139
- });
140
- }
141
- };
142
-
143
- return <div style={combinedStyle}>{formatDate(type)}</div>;
144
- };
145
-
@@ -1,12 +0,0 @@
1
- .datePicker {
2
- padding: 6px 8px;
3
- font-size: 14px;
4
- border: 1px solid #ccc;
5
- border-radius: 6px;
6
- outline: none;
7
- }
8
-
9
- .datePickerDisabled {
10
- background-color: #f0f0f0;
11
- color: #999;
12
- }
@@ -1,72 +0,0 @@
1
- import React, { useState } from "react";
2
- import PropTypes from "prop-types";
3
- import styles from "./TDatePicker.module.css";
4
- import { useTangoStyle } from "../CSSFab/useTangoStyle";
5
-
6
- export default function DatePicker(props) {
7
- const {
8
- sx = {},
9
- style: userStyle = {},
10
- className: userClassName = "",
11
- disabled,
12
- onChange,
13
- time,
14
- } = props;
15
-
16
- const [value, setValue] = useState("");
17
-
18
- const formatDate = (date) => {
19
- const d = new Date(date);
20
- const year = d.getFullYear();
21
- const month = (d.getMonth() + 1).toString().padStart(2, "0");
22
- const day = d.getDate().toString().padStart(2, "0");
23
- const hours = d.getHours().toString().padStart(2, "0");
24
- const minutes = d.getMinutes().toString().padStart(2, "0");
25
- return `${year}-${month}-${day} ${hours}:${minutes}`;
26
- };
27
-
28
- const handleChange = (e) => {
29
- const val = e.target.value;
30
- setValue(val);
31
- const formattedValue = time ? formatDate(val) : val;
32
- if (onChange) onChange(formattedValue, val);
33
- };
34
-
35
- const inputType = time ? "datetime-local" : "date";
36
-
37
- const className = `${styles.datePicker} ${
38
- disabled ? styles.datePickerDisabled : ""
39
- } ${userClassName}`;
40
-
41
- const sxStyle = useTangoStyle(sx);
42
- const combinedStyle = { ...sxStyle, ...userStyle };
43
-
44
- return (
45
- <input
46
- type={inputType}
47
- value={value}
48
- onChange={handleChange}
49
- className={className}
50
- style={combinedStyle}
51
- disabled={disabled}
52
- />
53
- );
54
- }
55
-
56
- DatePicker.propTypes = {
57
- sx: PropTypes.object,
58
- style: PropTypes.object,
59
- className: PropTypes.string,
60
- disabled: PropTypes.bool,
61
- onChange: PropTypes.func,
62
- time: PropTypes.bool,
63
- };
64
-
65
- DatePicker.defaultProps = {
66
- sx: {},
67
- style: {},
68
- className: "",
69
- disabled: false,
70
- onChange: () => {},
71
- time: false,
72
- };
@@ -1,203 +0,0 @@
1
- .drawerOverlay {
2
- position: fixed;
3
- top: 0;
4
- left: 0;
5
- width: 100vw;
6
- height: 100vh;
7
- background-color: rgba(0, 0, 0, 0.5);
8
- z-index: 999;
9
- display: flex;
10
- justify-content: flex-end;
11
- }
12
-
13
- .drawerContainer {
14
- background-color: #fff;
15
- padding: 20px;
16
- width: 320px;
17
- height: 100vh;
18
- position: relative;
19
- }
20
-
21
- .drawerHeader {
22
- font-size: 18px;
23
- font-weight: bold;
24
- margin-bottom: 16px;
25
- display: flex;
26
- justify-content: space-between;
27
- }
28
-
29
- .drawerContent {
30
- margin-bottom: 24px;
31
- }
32
-
33
- .drawerFooter {
34
- position: absolute;
35
- bottom: 0;
36
- right: 0;
37
- display: flex;
38
- gap: 10px;
39
- padding: 10px 20px;
40
- background-color: #fff;
41
- }
42
-
43
- .drawerCloseBtn {
44
- background-image: url('../../assets/关闭.png');
45
- width: 15px;
46
- height: 15px;
47
- background-size: 100% 100%;
48
- cursor: pointer;
49
- }
50
-
51
- /* 位置类 */
52
- .drawerRight {
53
- right: 0;
54
- top: 0;
55
- position: fixed;
56
- height: 100vh;
57
- width: 320px;
58
- }
59
-
60
- .drawerLeft {
61
- left: 0;
62
- top: 0;
63
- position: fixed;
64
- height: 100vh;
65
- width: 320px;
66
- }
67
-
68
- .drawerTop {
69
- top: 0;
70
- left: 0;
71
- position: fixed;
72
- width: 100vw;
73
- height: 300px;
74
- }
75
-
76
- .drawerBottom {
77
- bottom: 0;
78
- left: 0;
79
- position: fixed;
80
- width: 100vw;
81
- height: 300px;
82
- }
83
-
84
- /* 动画类 */
85
- @keyframes comeInRight {
86
- from {
87
- transform: translateX(100%);
88
- opacity: 0;
89
- }
90
- to {
91
- transform: translateX(0);
92
- opacity: 1;
93
- }
94
- }
95
-
96
- @keyframes comeOutRight {
97
- from {
98
- transform: translateX(0);
99
- opacity: 1;
100
- }
101
- to {
102
- transform: translateX(100%);
103
- opacity: 0;
104
- }
105
- }
106
-
107
- @keyframes comeInLeft {
108
- from {
109
- transform: translateX(-100%);
110
- opacity: 0;
111
- }
112
- to {
113
- transform: translateX(0);
114
- opacity: 1;
115
- }
116
- }
117
-
118
- @keyframes comeOutLeft {
119
- from {
120
- transform: translateX(0);
121
- opacity: 1;
122
- }
123
- to {
124
- transform: translateX(-100%);
125
- opacity: 0;
126
- }
127
- }
128
-
129
- @keyframes comeInTop {
130
- from {
131
- transform: translateY(-100%);
132
- opacity: 0;
133
- }
134
- to {
135
- transform: translateY(0);
136
- opacity: 1;
137
- }
138
- }
139
-
140
- @keyframes comeOutTop {
141
- from {
142
- transform: translateY(0);
143
- opacity: 1;
144
- }
145
- to {
146
- transform: translateY(-100%);
147
- opacity: 0;
148
- }
149
- }
150
-
151
- @keyframes comeInBottom {
152
- from {
153
- transform: translateY(100%);
154
- opacity: 0;
155
- }
156
- to {
157
- transform: translateY(0);
158
- opacity: 1;
159
- }
160
- }
161
-
162
- @keyframes comeOutBottom {
163
- from {
164
- transform: translateY(0);
165
- opacity: 1;
166
- }
167
- to {
168
- transform: translateY(100%);
169
- opacity: 0;
170
- }
171
- }
172
-
173
- .comeInRight {
174
- animation: comeInRight 0.3s ease-in-out;
175
- }
176
-
177
- .comeOutRight {
178
- animation: comeOutRight 0.3s ease-in-out;
179
- }
180
-
181
- .comeInLeft {
182
- animation: comeInLeft 0.3s ease-in-out;
183
- }
184
-
185
- .comeOutLeft {
186
- animation: comeOutLeft 0.3s ease-in-out;
187
- }
188
-
189
- .comeInTop {
190
- animation: comeInTop 0.3s ease-in-out;
191
- }
192
-
193
- .comeOutTop {
194
- animation: comeOutTop 0.3s ease-in-out;
195
- }
196
-
197
- .comeInBottom {
198
- animation: comeInBottom 0.3s ease-in-out;
199
- }
200
-
201
- .comeOutBottom {
202
- animation: comeOutBottom 0.3s ease-in-out;
203
- }
@@ -1,80 +0,0 @@
1
- import React, { useEffect, useState } from "react";
2
- import PropTypes from "prop-types";
3
- import styles from "./TDrawer.module.css";
4
- import TButton from "../TButton";
5
-
6
- export default function Drawer(props) {
7
- const { children, title, onText, cancelText, open, onClose, type } = props;
8
- const [showAnimation, setShowAnimation] = useState(false);
9
- const [closing, setClosing] = useState(false);
10
-
11
- useEffect(() => {
12
- if (open) {
13
- setShowAnimation(true);
14
- setClosing(false);
15
- } else if (showAnimation) {
16
- setClosing(true);
17
- setTimeout(() => {
18
- setShowAnimation(false);
19
- setClosing(false);
20
- }, 300);
21
- }
22
- }, [open]);
23
-
24
- function ok() {
25
- if (onClose) onClose();
26
- }
27
-
28
- return (
29
- <>
30
- {showAnimation && (
31
- <div
32
- className={`${styles.drawerOverlay} ${
33
- closing ? styles.fadeOut : styles.fadeIn
34
- }`}
35
- >
36
- <div
37
- className={`${styles.drawerContainer} ${
38
- styles[`drawer${type.charAt(0).toUpperCase() + type.slice(1)}`]
39
- } ${
40
- closing
41
- ? styles[`comeOut${type.charAt(0).toUpperCase() + type.slice(1)}`]
42
- : styles[`comeIn${type.charAt(0).toUpperCase() + type.slice(1)}`]
43
- }`}
44
- >
45
- <div className={styles.drawerHeader}>
46
- <h3>{title}</h3>
47
- <div className={styles.drawerCloseBtn} onClick={onClose}></div>
48
- </div>
49
- <div className={styles.drawerContent}>{children}</div>
50
- <div className={styles.drawerFooter}>
51
- <TButton type="success" onClick={ok}>
52
- {onText}
53
- </TButton>
54
- <TButton onClick={onClose}>{cancelText}</TButton>
55
- </div>
56
- </div>
57
- </div>
58
- )}
59
- </>
60
- );
61
- };
62
-
63
- Drawer.propTypes = {
64
- children: PropTypes.node.isRequired,
65
- title: PropTypes.string,
66
- onText: PropTypes.string,
67
- cancelText: PropTypes.string,
68
- open: PropTypes.bool,
69
- onClose: PropTypes.func,
70
- type: PropTypes.oneOf(["top", "bottom", "left", "right"]),
71
- };
72
-
73
- Drawer.defaultProps = {
74
- title: "基础标题",
75
- onText: "确定",
76
- cancelText: "取消",
77
- open: false,
78
- onClose: () => {},
79
- type: "right",
80
- };
@@ -1,67 +0,0 @@
1
- .input {
2
- width: 300px;
3
- border-radius: 8px;
4
- border: 1px solid #ccc;
5
- padding: 8px 12px;
6
- font-size: 14px;
7
- color: black;
8
- outline: none;
9
- transition: all 0.3s ease;
10
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
11
- background-color: #fff;
12
- }
13
-
14
- .input:hover {
15
- border-color: #888;
16
- }
17
-
18
- .input:focus {
19
- border-color: #4caf50;
20
- box-shadow: 0 0 5px rgba(0, 120, 212, 0.5);
21
- }
22
-
23
- .inputSmall {
24
- height: 32px;
25
- font-size: 12px;
26
- padding: 6px 10px;
27
- }
28
-
29
- .inputMedium {
30
- height: 40px;
31
- font-size: 14px;
32
- }
33
-
34
- .inputLarge {
35
- height: 48px;
36
- font-size: 16px;
37
- padding: 10px 14px;
38
- }
39
-
40
- .inputHuge {
41
- height: 56px;
42
- font-size: 18px;
43
- padding: 12px 16px;
44
- }
45
-
46
- .inputDisabled {
47
- background-color: #f5f5f5;
48
- color: #999;
49
- border-color: #ddd;
50
- cursor: not-allowed;
51
- box-shadow: none;
52
- }
53
-
54
- .inputTextarea {
55
- min-height: 32px;
56
- font-size: 14px;
57
- }
58
-
59
- .inputError {
60
- border-color: #d93025;
61
- background-color: #fef2f2;
62
- color: #d93025;
63
- }
64
-
65
- .inputError:focus {
66
- box-shadow: 0 0 5px rgba(217, 48, 37, 0.5);
67
- }