wz-h5-design 1.0.4 → 1.0.6
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/Button/index.js +10 -2
- package/dist/Button/index.umd.cjs +1 -1
- package/dist/Button/style/index.css +1 -1
- package/dist/Button/style.css +1 -1
- package/dist/ButtonGroup/index.js +1 -1
- package/dist/ButtonGroup/index.umd.cjs +1 -1
- package/dist/ButtonGroup/style/index.css +1 -1
- package/dist/ButtonGroup/style.css +1 -1
- package/dist/Cell/style/index.css +1 -1
- package/dist/Cell/style.css +1 -1
- package/dist/Checkbox/style/index.css +1 -1
- package/dist/Checkbox/style.css +1 -1
- package/dist/Dialog/index.js +10 -2
- package/dist/Dialog/index.umd.cjs +1 -1
- package/dist/Dialog/style.css +1 -1
- package/dist/Divider/style/index.css +1 -1
- package/dist/Divider/style.css +1 -1
- package/dist/GridView/index.js +26 -2
- package/dist/GridView/index.umd.cjs +1 -1
- package/dist/GridView/style/index.css +1 -1
- package/dist/GridView/style.css +1 -1
- package/dist/Input/index.js +47 -5
- package/dist/Input/index.umd.cjs +1 -1
- package/dist/Input/style/index.css +1 -1
- package/dist/Input/style.css +1 -1
- package/dist/Popup/style/index.css +1 -1
- package/dist/Popup/style.css +1 -1
- package/dist/Radio/style/index.css +1 -1
- package/dist/Radio/style.css +1 -1
- package/dist/Search/index.js +10 -2
- package/dist/Search/index.umd.cjs +1 -1
- package/dist/Search/style/index.css +1 -1
- package/dist/Search/style.css +1 -1
- package/dist/Switch/index.js +10 -3
- package/dist/Switch/index.umd.cjs +1 -1
- package/dist/Switch/style/index.css +1 -1
- package/dist/Switch/style.css +1 -1
- package/dist/Tabbar/index.js +6 -3
- package/dist/Tabbar/index.umd.cjs +1 -1
- package/dist/Tabbar/style/index.css +1 -1
- package/dist/Tabbar/style.css +1 -1
- package/dist/Tabs/index.js +57 -17
- package/dist/Tabs/index.umd.cjs +1 -1
- package/dist/Tabs/style/index.css +1 -1
- package/dist/Tabs/style.css +1 -1
- package/dist/Tooltip/index.js +59 -14
- package/dist/Tooltip/index.umd.cjs +2 -2
- package/dist/Tooltip/style/index.css +1 -1
- package/dist/Tooltip/style.css +1 -1
- package/dist/style.css +1 -1
- package/dist/types/components/GridView/GridView.d.ts +8 -0
- package/dist/types/components/Input/Input.d.ts +11 -1
- package/dist/types/components/Search/Search.d.ts +1 -0
- package/dist/types/components/Tabbar/Tabbar.d.ts +2 -0
- package/dist/types/components/Tabs/Tabs.d.ts +4 -1
- package/dist/types/components/Tooltip/Tooltip.d.ts +6 -2
- package/dist/wz-h5-design.es.js +196 -46
- package/dist/wz-h5-design.umd.js +2 -2
- package/package.json +1 -1
|
@@ -5,8 +5,16 @@ export interface GridViewItemProps {
|
|
|
5
5
|
icon?: React.ReactNode;
|
|
6
6
|
/** 文本内容 */
|
|
7
7
|
text?: React.ReactNode;
|
|
8
|
+
/** 文本颜色 */
|
|
9
|
+
textColor?: string;
|
|
10
|
+
/** 文本大小 */
|
|
11
|
+
textSize?: number | string;
|
|
8
12
|
/** 描述文本 */
|
|
9
13
|
description?: React.ReactNode;
|
|
14
|
+
/** 描述文本颜色 */
|
|
15
|
+
descriptionColor?: string;
|
|
16
|
+
/** 描述文本大小 */
|
|
17
|
+
descriptionSize?: number | string;
|
|
10
18
|
/** 徽章内容 */
|
|
11
19
|
badge?: React.ReactNode;
|
|
12
20
|
/** 角标内容 */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import "./Input.scss";
|
|
3
|
-
type InputTypes = "text" | "password" | "textarea" | "number";
|
|
3
|
+
type InputTypes = "text" | "password" | "textarea" | "number" | "code";
|
|
4
4
|
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type"> {
|
|
5
5
|
clearable?: boolean;
|
|
6
6
|
align?: "left" | "center" | "right";
|
|
@@ -12,6 +12,16 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
|
|
|
12
12
|
borderRadius?: string;
|
|
13
13
|
backgroundColor?: string;
|
|
14
14
|
bordered?: true;
|
|
15
|
+
/** 验证码倒计时秒数,默认60秒 */
|
|
16
|
+
codeCountdown?: number;
|
|
17
|
+
/** 点击获取验证码回调 */
|
|
18
|
+
onGetCode?: () => void | Promise<void>;
|
|
19
|
+
/** 获取验证码按钮文字 */
|
|
20
|
+
codeText?: string;
|
|
21
|
+
/** 倒计时中的文字,{s}会被替换为秒数 */
|
|
22
|
+
codeCountingText?: string;
|
|
23
|
+
/** 重新获取验证码文字 */
|
|
24
|
+
codeResendText?: string;
|
|
15
25
|
}
|
|
16
26
|
export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement | HTMLTextAreaElement>>;
|
|
17
27
|
export {};
|
|
@@ -11,6 +11,7 @@ export interface SearchProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
|
|
|
11
11
|
suffix?: React.ReactNode;
|
|
12
12
|
leftIcon?: React.ReactNode;
|
|
13
13
|
actionText?: React.ReactNode;
|
|
14
|
+
actionColor?: string;
|
|
14
15
|
showCancel?: boolean;
|
|
15
16
|
cancelText?: React.ReactNode;
|
|
16
17
|
background?: string;
|
|
@@ -7,7 +7,8 @@ export interface TabPaneProps {
|
|
|
7
7
|
badge?: ReactNode;
|
|
8
8
|
}
|
|
9
9
|
export interface TabsProps {
|
|
10
|
-
type?: 'line' | 'card' | '
|
|
10
|
+
type?: 'line' | 'card' | 'text';
|
|
11
|
+
align?: 'center' | 'left';
|
|
11
12
|
value?: number;
|
|
12
13
|
defaultValue?: number;
|
|
13
14
|
onChange?: (index: number) => void;
|
|
@@ -18,6 +19,8 @@ export interface TabsProps {
|
|
|
18
19
|
contentClassName?: string;
|
|
19
20
|
contentStyle?: React.CSSProperties;
|
|
20
21
|
children: ReactNode;
|
|
22
|
+
/** 最大标签数量,默认5 */
|
|
23
|
+
maxTabs?: number;
|
|
21
24
|
}
|
|
22
25
|
export declare const TabPane: React.FC<TabPaneProps>;
|
|
23
26
|
export declare const Tabs: React.FC<TabsProps> & {
|
|
@@ -11,7 +11,11 @@ export interface TooltipProps {
|
|
|
11
11
|
visible?: boolean;
|
|
12
12
|
onVisibleChange?: (visible: boolean) => void;
|
|
13
13
|
showMask?: boolean;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
/** 操作按钮文字 */
|
|
15
|
+
actionText?: string;
|
|
16
|
+
/** 操作按钮点击回调 */
|
|
17
|
+
onAction?: () => void;
|
|
18
|
+
/** 是否显示关闭按钮 */
|
|
19
|
+
closable?: boolean;
|
|
16
20
|
}
|
|
17
21
|
export declare const Tooltip: FC<TooltipProps>;
|
package/dist/wz-h5-design.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import React, { forwardRef, useState, useRef, useMemo, useContext, createContext, createElement, Children, useEffect, useImperativeHandle, useLayoutEffect } from "react";
|
|
2
|
+
import React, { forwardRef, useState, useRef, useMemo, useContext, createContext, createElement, useCallback, Children, useEffect, useImperativeHandle, useLayoutEffect } from "react";
|
|
3
3
|
import { createRoot } from "react-dom/client";
|
|
4
4
|
const Button = forwardRef(({
|
|
5
5
|
type = "primary",
|
|
@@ -25,11 +25,19 @@ const Button = forwardRef(({
|
|
|
25
25
|
if (value === void 0) return void 0;
|
|
26
26
|
return typeof value === "number" ? `${value}px` : value;
|
|
27
27
|
};
|
|
28
|
+
const calcBorderRadius = () => {
|
|
29
|
+
if (height !== void 0) {
|
|
30
|
+
const h = typeof height === "number" ? height : parseFloat(height);
|
|
31
|
+
if (!isNaN(h)) return `${h / 2}px`;
|
|
32
|
+
}
|
|
33
|
+
return void 0;
|
|
34
|
+
};
|
|
28
35
|
const buttonStyle = useMemo(() => {
|
|
29
36
|
const customStyle = {
|
|
30
37
|
width: formatSize(width),
|
|
31
38
|
height: formatSize(height),
|
|
32
|
-
fontSize: formatSize(fontSize)
|
|
39
|
+
fontSize: formatSize(fontSize),
|
|
40
|
+
borderRadius: calcBorderRadius()
|
|
33
41
|
};
|
|
34
42
|
if (type === "cancel") {
|
|
35
43
|
return {
|
|
@@ -61,7 +69,7 @@ const Button = forwardRef(({
|
|
|
61
69
|
if (type === "plain") {
|
|
62
70
|
return {
|
|
63
71
|
color: textColor || "#666666",
|
|
64
|
-
borderColor: borderColor || "
|
|
72
|
+
borderColor: borderColor || "rgba(102, 102, 102, 0.2)",
|
|
65
73
|
background: "transparent",
|
|
66
74
|
...style,
|
|
67
75
|
...customStyle
|
|
@@ -121,7 +129,7 @@ const ButtonGroup = ({
|
|
|
121
129
|
height,
|
|
122
130
|
padding = "2px 10px",
|
|
123
131
|
fixed = false,
|
|
124
|
-
gap =
|
|
132
|
+
gap = 9,
|
|
125
133
|
className = "",
|
|
126
134
|
style = {},
|
|
127
135
|
children
|
|
@@ -356,11 +364,17 @@ const Switch = ({
|
|
|
356
364
|
const [innerValue, setInnerValue] = useState(defaultValue);
|
|
357
365
|
const isControlled = value !== void 0;
|
|
358
366
|
const checked = isControlled ? value : innerValue;
|
|
359
|
-
const
|
|
367
|
+
const activeTextDisplay = activeText || DEFAULT_ACTIVE_TEXT;
|
|
368
|
+
const inactiveTextDisplay = inactiveText || DEFAULT_INACTIVE_TEXT;
|
|
369
|
+
const text = checked ? activeTextDisplay : inactiveTextDisplay;
|
|
360
370
|
const textWidth = showText ? `${text.length * 12 + 8}px` : "0px";
|
|
371
|
+
const maxTextLen = Math.max(activeTextDisplay.length, inactiveTextDisplay.length);
|
|
361
372
|
const baseWidth = size === "large" ? 62 : 60;
|
|
362
|
-
const
|
|
373
|
+
const calculatedWidth = showText ? maxTextLen * 12 + 40 : baseWidth;
|
|
374
|
+
const switchWidthNum = Math.max(calculatedWidth, baseWidth);
|
|
363
375
|
const switchWidth = `${switchWidthNum}px`;
|
|
376
|
+
const sliderSize = size === "large" ? 24 : 22;
|
|
377
|
+
const sliderTranslateX = checked ? switchWidthNum - sliderSize - 4 : 0;
|
|
364
378
|
const onBg = activeColor ? activeColor.includes("gradient") ? activeColor : activeColor : void 0;
|
|
365
379
|
const handleClick = () => {
|
|
366
380
|
if (disabled) return;
|
|
@@ -379,7 +393,8 @@ const Switch = ({
|
|
|
379
393
|
/* @__PURE__ */ jsx(
|
|
380
394
|
"div",
|
|
381
395
|
{
|
|
382
|
-
className: `wz-switch-slider ${checked ? "wz-switch-slider-on" : "wz-switch-slider-off"}
|
|
396
|
+
className: `wz-switch-slider ${checked ? "wz-switch-slider-on" : "wz-switch-slider-off"}`,
|
|
397
|
+
style: { transform: `translateX(${sliderTranslateX}px)` }
|
|
383
398
|
}
|
|
384
399
|
)
|
|
385
400
|
]
|
|
@@ -438,14 +453,17 @@ var classnames = { exports: {} };
|
|
|
438
453
|
var classnamesExports = classnames.exports;
|
|
439
454
|
const classNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
|
|
440
455
|
const TabbarItem = (props) => {
|
|
441
|
-
const { title, icon, activeIcon, badge, badgeAsBubble, hump, active, onItemClick, onClick, activeColor } = props;
|
|
456
|
+
const { title, icon, activeIcon, badge, badgeAsBubble, dot, hump, active, onItemClick, onClick, activeColor } = props;
|
|
442
457
|
const renderIcon = (iconSource) => {
|
|
443
458
|
if (typeof iconSource === "string") {
|
|
444
|
-
return /* @__PURE__ */ jsx(Icon, { name: iconSource });
|
|
459
|
+
return /* @__PURE__ */ jsx(Icon, { size: 22, name: iconSource });
|
|
445
460
|
}
|
|
446
461
|
return iconSource;
|
|
447
462
|
};
|
|
448
463
|
const renderBadge = () => {
|
|
464
|
+
if (dot) {
|
|
465
|
+
return /* @__PURE__ */ jsx("div", { className: "wz-tabbar-item-dot" });
|
|
466
|
+
}
|
|
449
467
|
if (!badge) return null;
|
|
450
468
|
if (badgeAsBubble) {
|
|
451
469
|
return /* @__PURE__ */ jsx("div", { className: "wz-tabbar-item-badge-custom", children: /* @__PURE__ */ jsxs("div", { className: "wz-tabbar-item-badge-bubble", children: [
|
|
@@ -474,7 +492,7 @@ const TabbarItem = (props) => {
|
|
|
474
492
|
active ? renderIcon(activeIcon || icon) : renderIcon(icon),
|
|
475
493
|
renderBadge()
|
|
476
494
|
] }),
|
|
477
|
-
/* @__PURE__ */ jsx("div", { className: "wz-tabbar-item-title", children: title })
|
|
495
|
+
!hump && /* @__PURE__ */ jsx("div", { className: "wz-tabbar-item-title", children: title })
|
|
478
496
|
] });
|
|
479
497
|
};
|
|
480
498
|
const Tabbar = (props) => {
|
|
@@ -625,6 +643,7 @@ const TabPane = ({ children }) => {
|
|
|
625
643
|
};
|
|
626
644
|
const Tabs = ({
|
|
627
645
|
type = "line",
|
|
646
|
+
align = "center",
|
|
628
647
|
value,
|
|
629
648
|
defaultValue = 0,
|
|
630
649
|
onChange,
|
|
@@ -634,33 +653,72 @@ const Tabs = ({
|
|
|
634
653
|
headerStyle,
|
|
635
654
|
contentClassName = "",
|
|
636
655
|
contentStyle,
|
|
637
|
-
children
|
|
656
|
+
children,
|
|
657
|
+
maxTabs = 5
|
|
638
658
|
}) => {
|
|
639
659
|
const isControlled = value !== void 0;
|
|
640
660
|
const [innerValue, setInnerValue] = useState(defaultValue);
|
|
641
661
|
const activeIndex = isControlled ? value : innerValue;
|
|
642
|
-
const
|
|
662
|
+
const headerRef = useRef(null);
|
|
663
|
+
const isDragging = useRef(false);
|
|
664
|
+
const startX = useRef(0);
|
|
665
|
+
const scrollLeft = useRef(0);
|
|
666
|
+
const handleMouseDown = useCallback((e) => {
|
|
667
|
+
if (align !== "left" || !headerRef.current) return;
|
|
668
|
+
isDragging.current = true;
|
|
669
|
+
startX.current = e.pageX - headerRef.current.offsetLeft;
|
|
670
|
+
scrollLeft.current = headerRef.current.scrollLeft;
|
|
671
|
+
}, [align]);
|
|
672
|
+
const handleMouseMove = useCallback((e) => {
|
|
673
|
+
if (!isDragging.current || !headerRef.current) return;
|
|
674
|
+
e.preventDefault();
|
|
675
|
+
const x = e.pageX - headerRef.current.offsetLeft;
|
|
676
|
+
const walk = (x - startX.current) * 1.5;
|
|
677
|
+
headerRef.current.scrollLeft = scrollLeft.current - walk;
|
|
678
|
+
}, []);
|
|
679
|
+
const handleMouseUp = useCallback(() => {
|
|
680
|
+
isDragging.current = false;
|
|
681
|
+
}, []);
|
|
682
|
+
const handleMouseLeave = useCallback(() => {
|
|
683
|
+
isDragging.current = false;
|
|
684
|
+
}, []);
|
|
685
|
+
const allPanes = Children.toArray(children).filter(Boolean);
|
|
686
|
+
const panes = allPanes.slice(0, maxTabs);
|
|
643
687
|
const handleTabClick = (idx, disabled) => {
|
|
644
688
|
if (disabled) return;
|
|
645
689
|
if (!isControlled) setInnerValue(idx);
|
|
646
690
|
onChange == null ? void 0 : onChange(idx);
|
|
647
691
|
};
|
|
648
|
-
|
|
649
|
-
|
|
692
|
+
const cardTabStyle = type === "card" ? {
|
|
693
|
+
flex: panes.length > 3 ? "0 0 calc((100% - 28px) / 3)" : "1"
|
|
694
|
+
} : void 0;
|
|
695
|
+
return /* @__PURE__ */ jsxs("div", { className: `wz-tabs wz-tabs-${type}${align === "left" ? " wz-tabs-align-left" : ""} ${className}`, style, children: [
|
|
696
|
+
/* @__PURE__ */ jsx(
|
|
650
697
|
"div",
|
|
651
698
|
{
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
699
|
+
ref: headerRef,
|
|
700
|
+
className: `wz-tabs-header ${headerClassName}`,
|
|
701
|
+
style: headerStyle,
|
|
702
|
+
onMouseDown: handleMouseDown,
|
|
703
|
+
onMouseMove: handleMouseMove,
|
|
704
|
+
onMouseUp: handleMouseUp,
|
|
705
|
+
onMouseLeave: handleMouseLeave,
|
|
706
|
+
children: panes.map((pane, idx) => /* @__PURE__ */ jsx(
|
|
707
|
+
"div",
|
|
708
|
+
{
|
|
709
|
+
className: `wz-tabs-tab${idx === activeIndex ? " wz-tabs-tab-active" : ""}${pane.props.disabled ? " wz-tabs-tab-disabled" : ""}`,
|
|
710
|
+
style: cardTabStyle,
|
|
711
|
+
onClick: () => handleTabClick(idx, pane.props.disabled),
|
|
712
|
+
children: /* @__PURE__ */ jsxs("div", { className: "wz-tabs-tab-text", children: [
|
|
713
|
+
pane.props.title,
|
|
714
|
+
pane.props.badge && /* @__PURE__ */ jsx("div", { className: "wz-tabs-badge", children: pane.props.badge }),
|
|
715
|
+
idx === activeIndex && type === "line" && /* @__PURE__ */ jsx("div", { className: "wz-tabs-underline" })
|
|
716
|
+
] })
|
|
717
|
+
},
|
|
718
|
+
idx
|
|
719
|
+
))
|
|
720
|
+
}
|
|
721
|
+
),
|
|
664
722
|
/* @__PURE__ */ jsx("div", { className: `wz-tabs-content ${contentClassName}`, style: contentStyle, children: panes[activeIndex] })
|
|
665
723
|
] });
|
|
666
724
|
};
|
|
@@ -1051,7 +1109,7 @@ const Cascader = ({
|
|
|
1051
1109
|
const Input = forwardRef(
|
|
1052
1110
|
({
|
|
1053
1111
|
clearable = false,
|
|
1054
|
-
align = "
|
|
1112
|
+
align = "left",
|
|
1055
1113
|
value,
|
|
1056
1114
|
defaultValue,
|
|
1057
1115
|
onChange,
|
|
@@ -1066,12 +1124,49 @@ const Input = forwardRef(
|
|
|
1066
1124
|
borderRadius,
|
|
1067
1125
|
backgroundColor,
|
|
1068
1126
|
bordered,
|
|
1127
|
+
codeCountdown = 60,
|
|
1128
|
+
onGetCode,
|
|
1129
|
+
codeText = "获取验证码",
|
|
1130
|
+
codeCountingText = "{s}s后重新获取",
|
|
1131
|
+
codeResendText = "重新获取验证码",
|
|
1069
1132
|
...props
|
|
1070
1133
|
}, ref) => {
|
|
1071
1134
|
const isControlled = value !== void 0;
|
|
1072
1135
|
const [innerValue, setInnerValue] = useState(defaultValue || "");
|
|
1073
1136
|
const showClear = clearable && !!(isControlled ? value : innerValue);
|
|
1074
1137
|
const [passwordVisible, setPasswordVisible] = useState(false);
|
|
1138
|
+
const [counting, setCounting] = useState(false);
|
|
1139
|
+
const [countdown, setCountdown] = useState(codeCountdown);
|
|
1140
|
+
const [hasSent, setHasSent] = useState(false);
|
|
1141
|
+
const [suffixWidth, setSuffixWidth] = useState(0);
|
|
1142
|
+
const suffixRef = useRef(null);
|
|
1143
|
+
useEffect(() => {
|
|
1144
|
+
if (suffixRef.current) {
|
|
1145
|
+
const width = suffixRef.current.offsetWidth;
|
|
1146
|
+
setSuffixWidth(width);
|
|
1147
|
+
}
|
|
1148
|
+
}, [counting, countdown, hasSent, suffix, codeText, codeCountingText, codeResendText]);
|
|
1149
|
+
useEffect(() => {
|
|
1150
|
+
let timer;
|
|
1151
|
+
if (counting && countdown > 0) {
|
|
1152
|
+
timer = setInterval(() => {
|
|
1153
|
+
setCountdown((prev) => prev - 1);
|
|
1154
|
+
}, 1e3);
|
|
1155
|
+
} else if (countdown === 0) {
|
|
1156
|
+
setCounting(false);
|
|
1157
|
+
setCountdown(codeCountdown);
|
|
1158
|
+
}
|
|
1159
|
+
return () => clearInterval(timer);
|
|
1160
|
+
}, [counting, countdown, codeCountdown]);
|
|
1161
|
+
const handleGetCode = useCallback(async () => {
|
|
1162
|
+
if (counting) return;
|
|
1163
|
+
try {
|
|
1164
|
+
await (onGetCode == null ? void 0 : onGetCode());
|
|
1165
|
+
setCounting(true);
|
|
1166
|
+
setHasSent(true);
|
|
1167
|
+
} catch {
|
|
1168
|
+
}
|
|
1169
|
+
}, [counting, onGetCode]);
|
|
1075
1170
|
const handleChange = (e) => {
|
|
1076
1171
|
if (!isControlled) setInnerValue(e.target.value);
|
|
1077
1172
|
onChange == null ? void 0 : onChange(e);
|
|
@@ -1096,7 +1191,8 @@ const Input = forwardRef(
|
|
|
1096
1191
|
textAlign: align,
|
|
1097
1192
|
borderRadius,
|
|
1098
1193
|
backgroundColor,
|
|
1099
|
-
border: bordered !== void 0 ? void 0 : "none"
|
|
1194
|
+
border: bordered !== void 0 ? void 0 : "none",
|
|
1195
|
+
...suffixWidth > 0 && (suffix || type === "code") ? { paddingRight: suffixWidth + 22 + 12 } : {}
|
|
1100
1196
|
};
|
|
1101
1197
|
const currentValue = isControlled ? value : innerValue;
|
|
1102
1198
|
const count = (currentValue == null ? void 0 : currentValue.toString().length) || 0;
|
|
@@ -1148,15 +1244,19 @@ const Input = forwardRef(
|
|
|
1148
1244
|
return /* @__PURE__ */ jsxs(
|
|
1149
1245
|
"div",
|
|
1150
1246
|
{
|
|
1151
|
-
className: `wz-input-affix-wrapper ${type === "textarea" ? "wz-input-affix-wrapper-textarea" : ""} ${suffix ? "wz-input-has-suffix" : ""} ${bordered === void 0 ? "wz-input-no-border" : ""}`,
|
|
1247
|
+
className: `wz-input-affix-wrapper ${type === "textarea" ? "wz-input-affix-wrapper-textarea" : ""} ${suffix || type === "code" ? "wz-input-has-suffix" : ""} ${bordered === void 0 ? "wz-input-no-border" : ""} ${clearable ? "wz-input-has-clear" : ""} ${type === "password" ? "wz-input-has-password" : ""}`,
|
|
1152
1248
|
style: wrapperStyle,
|
|
1153
1249
|
children: [
|
|
1154
1250
|
renderInput(),
|
|
1155
1251
|
showClear && !props.disabled && type !== "textarea" && !suffix && /* @__PURE__ */ jsx("span", { className: "wz-input-clear", onClick: handleClear, children: /* @__PURE__ */ jsx(Icon, { name: "close", size: 22 }) }),
|
|
1156
1252
|
type === "password" && !suffix && /* @__PURE__ */ jsx("span", { className: "wz-input-password", onClick: handlePasswordVisible, children: /* @__PURE__ */ jsx(Icon, { name: passwordVisible ? "eyes-close" : "eyes-open", size: 22 }) }),
|
|
1157
|
-
suffix && /* @__PURE__ */ jsxs("div", { className: "wz-input-suffix", children: [
|
|
1253
|
+
suffix && /* @__PURE__ */ jsxs("div", { className: "wz-input-suffix", ref: suffixRef, children: [
|
|
1158
1254
|
/* @__PURE__ */ jsx("span", { className: "wz-input-suffix-divider" }),
|
|
1159
1255
|
suffix
|
|
1256
|
+
] }),
|
|
1257
|
+
type === "code" && /* @__PURE__ */ jsxs("div", { className: "wz-input-suffix", ref: !suffix ? suffixRef : void 0, children: [
|
|
1258
|
+
/* @__PURE__ */ jsx("span", { className: "wz-input-suffix-divider" }),
|
|
1259
|
+
counting ? /* @__PURE__ */ jsx("span", { className: "wz-input-code-btn wz-input-code-btn--disabled", children: codeCountingText.replace("{s}", String(countdown)) }) : /* @__PURE__ */ jsx("span", { className: "wz-input-code-btn", onClick: handleGetCode, children: hasSent ? codeResendText : codeText })
|
|
1160
1260
|
] })
|
|
1161
1261
|
]
|
|
1162
1262
|
}
|
|
@@ -1238,6 +1338,7 @@ const Search = forwardRef(
|
|
|
1238
1338
|
suffix,
|
|
1239
1339
|
leftIcon = /* @__PURE__ */ jsx(Icon, { name: "search", size: 16 }),
|
|
1240
1340
|
actionText = "搜索",
|
|
1341
|
+
actionColor,
|
|
1241
1342
|
showCancel = false,
|
|
1242
1343
|
cancelText = "返回",
|
|
1243
1344
|
background,
|
|
@@ -1334,13 +1435,20 @@ const Search = forwardRef(
|
|
|
1334
1435
|
...props
|
|
1335
1436
|
}
|
|
1336
1437
|
),
|
|
1337
|
-
showClear && /* @__PURE__ */ jsx("div", { className: "wz-search-clear", onMouseDown: handleClear, children: /* @__PURE__ */ jsx(Icon, { name: "close", size: 16, color: "#
|
|
1438
|
+
showClear && /* @__PURE__ */ jsx("div", { className: "wz-search-clear", onMouseDown: handleClear, children: /* @__PURE__ */ jsx(Icon, { name: "close", size: 16, color: "#CCCCCC" }) })
|
|
1338
1439
|
]
|
|
1339
1440
|
}
|
|
1340
1441
|
),
|
|
1341
1442
|
actionText && /* @__PURE__ */ jsxs("div", { className: "wz-search-action", onClick: handleSearch, children: [
|
|
1342
1443
|
/* @__PURE__ */ jsx("div", { className: "wz-search-divider" }),
|
|
1343
|
-
/* @__PURE__ */ jsx(
|
|
1444
|
+
/* @__PURE__ */ jsx(
|
|
1445
|
+
"div",
|
|
1446
|
+
{
|
|
1447
|
+
className: "wz-search-action-text",
|
|
1448
|
+
style: actionColor ? { color: actionColor } : void 0,
|
|
1449
|
+
children: actionText
|
|
1450
|
+
}
|
|
1451
|
+
)
|
|
1344
1452
|
] })
|
|
1345
1453
|
]
|
|
1346
1454
|
}
|
|
@@ -1925,7 +2033,11 @@ Grid.Item = GridItem;
|
|
|
1925
2033
|
const GridViewItem = ({
|
|
1926
2034
|
icon,
|
|
1927
2035
|
text,
|
|
2036
|
+
textColor,
|
|
2037
|
+
textSize,
|
|
1928
2038
|
description,
|
|
2039
|
+
descriptionColor,
|
|
2040
|
+
descriptionSize,
|
|
1929
2041
|
badge,
|
|
1930
2042
|
corner,
|
|
1931
2043
|
onClick,
|
|
@@ -1972,8 +2084,28 @@ const GridViewItem = ({
|
|
|
1972
2084
|
/* @__PURE__ */ jsxs("div", { className: "wz-grid-view-item__content", children: [
|
|
1973
2085
|
icon && /* @__PURE__ */ jsx("div", { className: "wz-grid-view-item__icon", children: icon }),
|
|
1974
2086
|
/* @__PURE__ */ jsxs("div", { className: "wz-grid-view-item__text", children: [
|
|
1975
|
-
text && /* @__PURE__ */ jsx(
|
|
1976
|
-
|
|
2087
|
+
text && /* @__PURE__ */ jsx(
|
|
2088
|
+
"div",
|
|
2089
|
+
{
|
|
2090
|
+
className: "wz-grid-view-item__title",
|
|
2091
|
+
style: {
|
|
2092
|
+
...textColor ? { color: textColor } : {},
|
|
2093
|
+
...textSize ? { fontSize: typeof textSize === "number" ? `${textSize}px` : textSize } : {}
|
|
2094
|
+
},
|
|
2095
|
+
children: text
|
|
2096
|
+
}
|
|
2097
|
+
),
|
|
2098
|
+
description && /* @__PURE__ */ jsx(
|
|
2099
|
+
"div",
|
|
2100
|
+
{
|
|
2101
|
+
className: "wz-grid-view-item__desc",
|
|
2102
|
+
style: {
|
|
2103
|
+
...descriptionColor ? { color: descriptionColor } : {},
|
|
2104
|
+
...descriptionSize ? { fontSize: typeof descriptionSize === "number" ? `${descriptionSize}px` : descriptionSize } : {}
|
|
2105
|
+
},
|
|
2106
|
+
children: description
|
|
2107
|
+
}
|
|
2108
|
+
)
|
|
1977
2109
|
] })
|
|
1978
2110
|
] }),
|
|
1979
2111
|
badge && /* @__PURE__ */ jsx("div", { className: "wz-grid-view-item__badge", children: badge })
|
|
@@ -2367,8 +2499,9 @@ const Tooltip = ({
|
|
|
2367
2499
|
visible,
|
|
2368
2500
|
onVisibleChange,
|
|
2369
2501
|
showMask = false,
|
|
2370
|
-
|
|
2371
|
-
|
|
2502
|
+
actionText,
|
|
2503
|
+
onAction,
|
|
2504
|
+
closable = false
|
|
2372
2505
|
}) => {
|
|
2373
2506
|
const [internalVisible, setInternalVisible] = useState(false);
|
|
2374
2507
|
const [computedStyle, setComputedStyle] = useState({});
|
|
@@ -2383,8 +2516,8 @@ const Tooltip = ({
|
|
|
2383
2516
|
}
|
|
2384
2517
|
onVisibleChange == null ? void 0 : onVisibleChange(newVisible);
|
|
2385
2518
|
};
|
|
2386
|
-
|
|
2387
|
-
if (
|
|
2519
|
+
const updatePosition = useCallback(() => {
|
|
2520
|
+
if (tooltipRef.current && triggerRef.current) {
|
|
2388
2521
|
const bubbleEl = tooltipRef.current;
|
|
2389
2522
|
const triggerEl = triggerRef.current;
|
|
2390
2523
|
const { width: bubbleWidth, height: bubbleHeight } = bubbleEl.getBoundingClientRect();
|
|
@@ -2417,7 +2550,24 @@ const Tooltip = ({
|
|
|
2417
2550
|
"--wz-tooltip-arrow-left": `${arrowLeft}px`
|
|
2418
2551
|
});
|
|
2419
2552
|
}
|
|
2420
|
-
}, [
|
|
2553
|
+
}, []);
|
|
2554
|
+
useLayoutEffect(() => {
|
|
2555
|
+
if (currentVisible) {
|
|
2556
|
+
updatePosition();
|
|
2557
|
+
}
|
|
2558
|
+
}, [currentVisible, updatePosition]);
|
|
2559
|
+
useEffect(() => {
|
|
2560
|
+
if (!currentVisible) return;
|
|
2561
|
+
const handleScroll = () => {
|
|
2562
|
+
updatePosition();
|
|
2563
|
+
};
|
|
2564
|
+
window.addEventListener("scroll", handleScroll, true);
|
|
2565
|
+
window.addEventListener("resize", handleScroll);
|
|
2566
|
+
return () => {
|
|
2567
|
+
window.removeEventListener("scroll", handleScroll, true);
|
|
2568
|
+
window.removeEventListener("resize", handleScroll);
|
|
2569
|
+
};
|
|
2570
|
+
}, [currentVisible, updatePosition]);
|
|
2421
2571
|
const handleWrapperClick = () => {
|
|
2422
2572
|
if (trigger === "click") {
|
|
2423
2573
|
handleVisibleChange(!currentVisible);
|
|
@@ -2439,17 +2589,17 @@ const Tooltip = ({
|
|
|
2439
2589
|
const renderBubble = () => {
|
|
2440
2590
|
if (!currentVisible) return null;
|
|
2441
2591
|
const renderAction = () => {
|
|
2442
|
-
if (!
|
|
2443
|
-
const
|
|
2444
|
-
|
|
2445
|
-
|
|
2592
|
+
if (!actionText) return null;
|
|
2593
|
+
const handleActionClick = (e) => {
|
|
2594
|
+
e.stopPropagation();
|
|
2595
|
+
onAction == null ? void 0 : onAction();
|
|
2446
2596
|
handleVisibleChange(false);
|
|
2447
2597
|
};
|
|
2448
|
-
return /* @__PURE__ */ jsx("div", { className: "wz-tooltip-bubble__action-slot", children:
|
|
2598
|
+
return /* @__PURE__ */ jsx("div", { className: "wz-tooltip-bubble__action-slot", children: /* @__PURE__ */ jsx("span", { className: "wz-tooltip-bubble__action-btn", onClick: handleActionClick, children: actionText }) });
|
|
2449
2599
|
};
|
|
2450
2600
|
const renderCloseIcon = () => {
|
|
2451
|
-
if (!
|
|
2452
|
-
return /* @__PURE__ */ jsx("div", { className: "wz-tooltip-bubble__close-slot", children:
|
|
2601
|
+
if (!closable) return null;
|
|
2602
|
+
return /* @__PURE__ */ jsx("div", { className: "wz-tooltip-bubble__close-slot", children: /* @__PURE__ */ jsx("span", { className: "wz-tooltip-bubble__close-btn", onClick: handleClose, children: /* @__PURE__ */ jsx(Icon, { name: "close", type: "yunying" }) }) });
|
|
2453
2603
|
};
|
|
2454
2604
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2455
2605
|
showMask && /* @__PURE__ */ jsx("div", { className: "wz-tooltip-mask", onClick: handleClose }),
|