clxx 2.1.7 → 2.1.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.
- package/build/Alert/Wrapper.js +10 -13
- package/build/Alert/style.js +40 -25
- package/build/CitySelect/index.js +51 -16
- package/build/Toast/style.d.ts +0 -3
- package/build/Toast/style.js +29 -25
- package/package.json +1 -1
- package/test/src/toast/index.jsx +1 -0
package/build/Alert/Wrapper.js
CHANGED
|
@@ -6,23 +6,20 @@ const Clickable_1 = require("../Clickable");
|
|
|
6
6
|
const Row_1 = require("../Flex/Row");
|
|
7
7
|
const style_1 = require("./style");
|
|
8
8
|
function AlertWrapper(props) {
|
|
9
|
-
const { title = '提示', description, confirm = '确定', confirmColor = '#
|
|
9
|
+
const { title = '提示', description, confirm = '确定', confirmColor = '#007aff', cancel = '取消', cancelColor = '#6b7280', showCancel = false, onConfirm, onCancel,
|
|
10
10
|
// 可定制的样式
|
|
11
11
|
titleStyle, descStyle, btnStyle, cancelStyle, confirmStyle, } = props;
|
|
12
|
-
// 标题样式
|
|
13
|
-
let titleCss = [
|
|
14
|
-
style_1.style.title,
|
|
15
|
-
description ? { paddingBottom: 0 } : {},
|
|
16
|
-
titleStyle
|
|
17
|
-
];
|
|
18
12
|
// 展示按钮组
|
|
19
|
-
|
|
13
|
+
const btnBoxCss = [
|
|
20
14
|
style_1.style.btnBox,
|
|
21
15
|
showCancel ? style_1.style.btnBoxWithCancel : {}
|
|
22
16
|
];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
const activeBg = { backgroundColor: 'rgba(0,0,0,.04)' };
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)("div", { css: style_1.style.container, children: [(0, jsx_runtime_1.jsxs)("div", { css: style_1.style.content, children: [(0, jsx_runtime_1.jsx)("div", { css: [style_1.style.title, titleStyle], children: title }), description && (0, jsx_runtime_1.jsx)("div", { css: [style_1.style.desc, descStyle], children: description })] }), (0, jsx_runtime_1.jsxs)(Row_1.Row, { alignItems: "stretch", css: btnBoxCss, children: [showCancel && ((0, jsx_runtime_1.jsx)(Clickable_1.Clickable, { css: [style_1.style.btn, btnStyle, cancelStyle, { color: cancelColor }], onClick: onCancel, activeStyle: activeBg, children: cancel })), (0, jsx_runtime_1.jsx)(Clickable_1.Clickable, { css: [
|
|
19
|
+
style_1.style.btn,
|
|
20
|
+
style_1.style.btnConfirm,
|
|
21
|
+
btnStyle,
|
|
22
|
+
confirmStyle,
|
|
23
|
+
{ color: confirmColor },
|
|
24
|
+
], onClick: onConfirm, activeStyle: activeBg, children: confirm })] })] }));
|
|
28
25
|
}
|
package/build/Alert/style.js
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.style = void 0;
|
|
4
|
+
// 1px 硬边框(高清屏 hairline)
|
|
5
|
+
const hairline = 1 / (typeof window !== "undefined" ? window.devicePixelRatio : 1);
|
|
6
|
+
const fontStack = '-apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif';
|
|
4
7
|
exports.style = {
|
|
5
8
|
container: {
|
|
6
9
|
position: "relative",
|
|
7
10
|
overflow: "hidden",
|
|
8
|
-
backgroundColor: "#
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
backgroundColor: "#ffffff",
|
|
12
|
+
borderRadius: ".28rem",
|
|
13
|
+
width: (750 * 0.78) / 100 + "rem",
|
|
14
|
+
fontFamily: fontStack,
|
|
15
|
+
color: "#1f2328",
|
|
16
|
+
WebkitFontSmoothing: "antialiased",
|
|
17
|
+
MozOsxFontSmoothing: "grayscale",
|
|
18
|
+
boxShadow: "0 .2rem .6rem rgba(0,0,0,.18)",
|
|
12
19
|
},
|
|
13
20
|
content: {
|
|
14
21
|
position: "relative",
|
|
22
|
+
paddingTop: ".4rem",
|
|
23
|
+
paddingBottom: ".4rem",
|
|
24
|
+
paddingLeft: ".36rem",
|
|
25
|
+
paddingRight: ".36rem",
|
|
15
26
|
"&:after,&::after": {
|
|
16
27
|
content: "''",
|
|
17
28
|
position: "absolute",
|
|
@@ -19,33 +30,30 @@ exports.style = {
|
|
|
19
30
|
left: 0,
|
|
20
31
|
right: 0,
|
|
21
32
|
height: "1px",
|
|
22
|
-
backgroundColor: "#
|
|
23
|
-
transform: `scale(1, ${
|
|
33
|
+
backgroundColor: "#e5e7eb",
|
|
34
|
+
transform: `scale(1, ${hairline})`,
|
|
35
|
+
transformOrigin: "0 100%",
|
|
24
36
|
},
|
|
25
37
|
},
|
|
26
38
|
title: {
|
|
27
39
|
textAlign: "center",
|
|
28
|
-
lineHeight: 1.
|
|
29
|
-
color: "#
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
paddingBottom: '.5rem',
|
|
34
|
-
fontSize: '.33rem',
|
|
40
|
+
lineHeight: 1.45,
|
|
41
|
+
color: "#1f2328",
|
|
42
|
+
fontSize: ".34rem",
|
|
43
|
+
fontWeight: 600,
|
|
44
|
+
letterSpacing: ".01rem",
|
|
35
45
|
},
|
|
36
46
|
desc: {
|
|
37
47
|
textAlign: "center",
|
|
38
|
-
lineHeight: 1.
|
|
39
|
-
color: "#
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
paddingBottom: '.5rem',
|
|
44
|
-
fontSize: '.29rem',
|
|
48
|
+
lineHeight: 1.55,
|
|
49
|
+
color: "#6b7280",
|
|
50
|
+
fontSize: ".28rem",
|
|
51
|
+
marginTop: ".18rem",
|
|
52
|
+
wordBreak: "break-word",
|
|
45
53
|
},
|
|
46
54
|
btnBox: {
|
|
47
55
|
position: "relative",
|
|
48
|
-
height:
|
|
56
|
+
height: ".92rem",
|
|
49
57
|
},
|
|
50
58
|
btnBoxWithCancel: {
|
|
51
59
|
"&:after,&::after": {
|
|
@@ -56,8 +64,9 @@ exports.style = {
|
|
|
56
64
|
left: "50%",
|
|
57
65
|
marginLeft: "-.5px",
|
|
58
66
|
width: "1px",
|
|
59
|
-
backgroundColor: "#
|
|
60
|
-
transform: `scale(${
|
|
67
|
+
backgroundColor: "#e5e7eb",
|
|
68
|
+
transform: `scale(${hairline}, 1)`,
|
|
69
|
+
transformOrigin: "0 0",
|
|
61
70
|
},
|
|
62
71
|
},
|
|
63
72
|
btn: {
|
|
@@ -66,7 +75,13 @@ exports.style = {
|
|
|
66
75
|
alignItems: "center",
|
|
67
76
|
justifyContent: "center",
|
|
68
77
|
userSelect: "none",
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
fontSize: ".32rem",
|
|
79
|
+
fontWeight: 500,
|
|
80
|
+
letterSpacing: ".01rem",
|
|
81
|
+
cursor: "pointer",
|
|
82
|
+
transition: "background-color .12s",
|
|
83
|
+
},
|
|
84
|
+
btnConfirm: {
|
|
85
|
+
fontWeight: 600,
|
|
71
86
|
},
|
|
72
87
|
};
|
|
@@ -201,7 +201,7 @@ function CitySelect(props) {
|
|
|
201
201
|
if (!el)
|
|
202
202
|
return;
|
|
203
203
|
let lastLetter = null;
|
|
204
|
-
const
|
|
204
|
+
const updateByY = (clientY) => {
|
|
205
205
|
var _a;
|
|
206
206
|
const list = lettersRef.current;
|
|
207
207
|
if (list.length === 0)
|
|
@@ -221,28 +221,63 @@ function CitySelect(props) {
|
|
|
221
221
|
(_a = onLetterChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onLetterChangeRef, letter);
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
|
-
|
|
224
|
+
// 优先使用触摸事件;不支持触摸才回退到鼠标事件,避免两套并存冲突
|
|
225
|
+
const isTouch = typeof window !== "undefined" &&
|
|
226
|
+
("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
227
|
+
if (isTouch) {
|
|
228
|
+
const handleTouchStart = (e) => {
|
|
229
|
+
setTouching(true);
|
|
230
|
+
updateByY(e.touches[0].clientY);
|
|
231
|
+
};
|
|
232
|
+
const handleTouchMove = (e) => {
|
|
233
|
+
// 阻止滚动,需要非 passive 监听器
|
|
234
|
+
e.preventDefault();
|
|
235
|
+
updateByY(e.touches[0].clientY);
|
|
236
|
+
};
|
|
237
|
+
const handleTouchEnd = () => {
|
|
238
|
+
setTouching(false);
|
|
239
|
+
lastLetter = null;
|
|
240
|
+
};
|
|
241
|
+
el.addEventListener("touchstart", handleTouchStart, { passive: false });
|
|
242
|
+
el.addEventListener("touchmove", handleTouchMove, { passive: false });
|
|
243
|
+
el.addEventListener("touchend", handleTouchEnd);
|
|
244
|
+
el.addEventListener("touchcancel", handleTouchEnd);
|
|
245
|
+
return () => {
|
|
246
|
+
el.removeEventListener("touchstart", handleTouchStart);
|
|
247
|
+
el.removeEventListener("touchmove", handleTouchMove);
|
|
248
|
+
el.removeEventListener("touchend", handleTouchEnd);
|
|
249
|
+
el.removeEventListener("touchcancel", handleTouchEnd);
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
// 鼠标端:按下后拖动,move/up 绑在 document 以支持拖出 sidebar
|
|
253
|
+
let dragging = false;
|
|
254
|
+
const handleMouseDown = (e) => {
|
|
255
|
+
if (e.button !== 0)
|
|
256
|
+
return;
|
|
257
|
+
e.preventDefault();
|
|
258
|
+
dragging = true;
|
|
225
259
|
setTouching(true);
|
|
226
|
-
|
|
260
|
+
updateByY(e.clientY);
|
|
227
261
|
};
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
262
|
+
const handleMouseMove = (e) => {
|
|
263
|
+
if (!dragging)
|
|
264
|
+
return;
|
|
265
|
+
updateByY(e.clientY);
|
|
232
266
|
};
|
|
233
|
-
const
|
|
267
|
+
const handleMouseUp = () => {
|
|
268
|
+
if (!dragging)
|
|
269
|
+
return;
|
|
270
|
+
dragging = false;
|
|
234
271
|
setTouching(false);
|
|
235
272
|
lastLetter = null;
|
|
236
273
|
};
|
|
237
|
-
el.addEventListener("
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
el.addEventListener("touchcancel", handleTouchEnd);
|
|
274
|
+
el.addEventListener("mousedown", handleMouseDown);
|
|
275
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
276
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
241
277
|
return () => {
|
|
242
|
-
el.removeEventListener("
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
el.removeEventListener("touchcancel", handleTouchEnd);
|
|
278
|
+
el.removeEventListener("mousedown", handleMouseDown);
|
|
279
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
280
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
246
281
|
};
|
|
247
282
|
}, [isSearching]);
|
|
248
283
|
// 手动滚动城市列表时,根据当前最靠上的区块激活对应字母(rAF 节流)
|
package/build/Toast/style.d.ts
CHANGED
|
@@ -37,9 +37,6 @@ export declare const bottomHideAnimation: {
|
|
|
37
37
|
} & string;
|
|
38
38
|
/**
|
|
39
39
|
* 根据位置和类型获取动画
|
|
40
|
-
* @param position
|
|
41
|
-
* @param type
|
|
42
|
-
* @returns
|
|
43
40
|
*/
|
|
44
41
|
export declare function getAnimation(position: "top" | "middle" | "bottom", type: "show" | "hide"): {
|
|
45
42
|
keyframes: Keyframes;
|
package/build/Toast/style.js
CHANGED
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.style = exports.bottomHideAnimation = exports.bottomShowAnimation = exports.topHideAnimation = exports.topShowAnimation = exports.middleHideAnimation = exports.middleShowAnimation = void 0;
|
|
4
4
|
exports.getAnimation = getAnimation;
|
|
5
5
|
const react_1 = require("@emotion/react");
|
|
6
|
+
const fontStack = '-apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif';
|
|
7
|
+
const easing = "cubic-bezier(.22,.61,.36,1)";
|
|
6
8
|
exports.middleShowAnimation = (0, react_1.keyframes) `
|
|
7
9
|
from {
|
|
8
10
|
opacity: 0;
|
|
9
|
-
transform: translateX(-50%) scale(0.
|
|
11
|
+
transform: translateX(-50%) scale(0.92);
|
|
10
12
|
}
|
|
11
13
|
to {
|
|
12
14
|
opacity: 1;
|
|
@@ -20,13 +22,13 @@ exports.middleHideAnimation = (0, react_1.keyframes) `
|
|
|
20
22
|
}
|
|
21
23
|
to {
|
|
22
24
|
opacity: 0;
|
|
23
|
-
transform: translateX(-50%) scale(0.
|
|
25
|
+
transform: translateX(-50%) scale(0.92);
|
|
24
26
|
}
|
|
25
27
|
`;
|
|
26
28
|
exports.topShowAnimation = (0, react_1.keyframes) `
|
|
27
29
|
from {
|
|
28
30
|
opacity: 0;
|
|
29
|
-
transform: translate(-50%, -
|
|
31
|
+
transform: translate(-50%, -120%);
|
|
30
32
|
}
|
|
31
33
|
to {
|
|
32
34
|
opacity: 1;
|
|
@@ -40,13 +42,13 @@ exports.topHideAnimation = (0, react_1.keyframes) `
|
|
|
40
42
|
}
|
|
41
43
|
to {
|
|
42
44
|
opacity: 0;
|
|
43
|
-
transform: translate(-50%, -
|
|
45
|
+
transform: translate(-50%, -120%);
|
|
44
46
|
}
|
|
45
47
|
`;
|
|
46
48
|
exports.bottomShowAnimation = (0, react_1.keyframes) `
|
|
47
49
|
from {
|
|
48
50
|
opacity: 0;
|
|
49
|
-
transform: translate(-50%,
|
|
51
|
+
transform: translate(-50%, 120%);
|
|
50
52
|
}
|
|
51
53
|
to {
|
|
52
54
|
opacity: 1;
|
|
@@ -60,14 +62,11 @@ exports.bottomHideAnimation = (0, react_1.keyframes) `
|
|
|
60
62
|
}
|
|
61
63
|
to {
|
|
62
64
|
opacity: 0;
|
|
63
|
-
transform: translate(-50%,
|
|
65
|
+
transform: translate(-50%, 120%);
|
|
64
66
|
}
|
|
65
67
|
`;
|
|
66
68
|
/**
|
|
67
69
|
* 根据位置和类型获取动画
|
|
68
|
-
* @param position
|
|
69
|
-
* @param type
|
|
70
|
-
* @returns
|
|
71
70
|
*/
|
|
72
71
|
function getAnimation(position, type) {
|
|
73
72
|
const animation = {
|
|
@@ -85,7 +84,7 @@ function getAnimation(position, type) {
|
|
|
85
84
|
return {
|
|
86
85
|
keyframes,
|
|
87
86
|
animation: (0, react_1.css)({
|
|
88
|
-
animation: `${keyframes}
|
|
87
|
+
animation: `${keyframes} 260ms ${easing}`,
|
|
89
88
|
}),
|
|
90
89
|
};
|
|
91
90
|
}
|
|
@@ -96,32 +95,37 @@ exports.style = {
|
|
|
96
95
|
left: "50%",
|
|
97
96
|
transform: "translateX(-50%)",
|
|
98
97
|
zIndex: 9999,
|
|
99
|
-
maxWidth:
|
|
98
|
+
maxWidth: "6rem",
|
|
99
|
+
pointerEvents: "none",
|
|
100
|
+
fontFamily: fontStack,
|
|
101
|
+
WebkitFontSmoothing: "antialiased",
|
|
102
|
+
MozOsxFontSmoothing: "grayscale",
|
|
100
103
|
});
|
|
101
104
|
},
|
|
102
105
|
top(offset) {
|
|
103
|
-
return (0, react_1.css)({ top: offset / 100 +
|
|
106
|
+
return (0, react_1.css)({ top: offset / 100 + "rem" });
|
|
104
107
|
},
|
|
105
108
|
middle: (0, react_1.css)({ top: "50%" }),
|
|
106
109
|
bottom(offset) {
|
|
107
|
-
return (0, react_1.css)({ bottom: offset / 100 +
|
|
110
|
+
return (0, react_1.css)({ bottom: offset / 100 + "rem" });
|
|
108
111
|
},
|
|
109
112
|
content: (radius) => {
|
|
110
113
|
return (0, react_1.css)({
|
|
111
114
|
position: "relative",
|
|
112
|
-
backgroundColor: "rgba(
|
|
113
|
-
color: "#
|
|
115
|
+
backgroundColor: "rgba(17,24,39,.88)",
|
|
116
|
+
color: "#ffffff",
|
|
114
117
|
margin: 0,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
lineHeight: 1,
|
|
119
|
-
fontSize:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
borderRadius: radius ? radius / 100 +
|
|
118
|
+
// 允许多行,超过 maxWidth 时自然换行
|
|
119
|
+
whiteSpace: "pre-wrap",
|
|
120
|
+
wordBreak: "break-word",
|
|
121
|
+
lineHeight: 1.5,
|
|
122
|
+
fontSize: ".28rem",
|
|
123
|
+
fontWeight: 400,
|
|
124
|
+
letterSpacing: ".01rem",
|
|
125
|
+
textAlign: "center",
|
|
126
|
+
padding: ".2rem .32rem",
|
|
127
|
+
borderRadius: radius ? radius / 100 + "rem" : 0,
|
|
128
|
+
boxShadow: "0 .12rem .32rem rgba(0,0,0,.25)",
|
|
125
129
|
});
|
|
126
130
|
},
|
|
127
131
|
contentMiddle: {
|
package/package.json
CHANGED