wz-h5-design 1.0.3 → 1.0.5

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 (90) hide show
  1. package/dist/Button/index.js +23 -7
  2. package/dist/Button/index.umd.cjs +1 -1
  3. package/dist/Button/style/index.css +1 -1
  4. package/dist/Button/style.css +1 -1
  5. package/dist/ButtonGroup/index.js +34 -0
  6. package/dist/ButtonGroup/index.umd.cjs +1 -0
  7. package/dist/ButtonGroup/style/index.css +1 -0
  8. package/dist/ButtonGroup/style/index.js +1 -0
  9. package/dist/ButtonGroup/style.css +1 -0
  10. package/dist/Cell/index.js +29 -2
  11. package/dist/Cell/index.umd.cjs +2 -2
  12. package/dist/Cell/style/index.css +1 -1
  13. package/dist/Cell/style.css +1 -1
  14. package/dist/CheckList/index.js +28 -1
  15. package/dist/CheckList/index.umd.cjs +1 -1
  16. package/dist/CheckList/style.css +1 -1
  17. package/dist/Checkbox/index.js +34 -2
  18. package/dist/Checkbox/index.umd.cjs +1 -1
  19. package/dist/Checkbox/style/index.css +1 -1
  20. package/dist/Checkbox/style.css +1 -1
  21. package/dist/DatePicker/style/index.css +1 -1
  22. package/dist/DatePicker/style.css +1 -1
  23. package/dist/DateRangePicker/index.js +65 -9
  24. package/dist/DateRangePicker/index.umd.cjs +1 -1
  25. package/dist/DateRangePicker/style/index.css +1 -1
  26. package/dist/DateRangePicker/style.css +1 -1
  27. package/dist/Dialog/index.js +23 -7
  28. package/dist/Dialog/index.umd.cjs +1 -1
  29. package/dist/Dialog/style.css +1 -1
  30. package/dist/Divider/index.js +13 -4
  31. package/dist/Divider/index.umd.cjs +1 -1
  32. package/dist/Divider/style/index.css +1 -1
  33. package/dist/Divider/style.css +1 -1
  34. package/dist/GridView/index.js +26 -2
  35. package/dist/GridView/index.umd.cjs +1 -1
  36. package/dist/GridView/style/index.css +1 -1
  37. package/dist/GridView/style.css +1 -1
  38. package/dist/Input/index.js +47 -5
  39. package/dist/Input/index.umd.cjs +1 -1
  40. package/dist/Input/style/index.css +1 -1
  41. package/dist/Input/style.css +1 -1
  42. package/dist/Popup/style/index.css +1 -1
  43. package/dist/Popup/style.css +1 -1
  44. package/dist/Radio/index.js +34 -2
  45. package/dist/Radio/index.umd.cjs +1 -1
  46. package/dist/Radio/style/index.css +1 -1
  47. package/dist/Radio/style.css +1 -1
  48. package/dist/Search/index.js +10 -2
  49. package/dist/Search/index.umd.cjs +1 -1
  50. package/dist/Search/style/index.css +1 -1
  51. package/dist/Search/style.css +1 -1
  52. package/dist/Switch/index.js +10 -3
  53. package/dist/Switch/index.umd.cjs +1 -1
  54. package/dist/Switch/style/index.css +1 -1
  55. package/dist/Switch/style.css +1 -1
  56. package/dist/Tabbar/index.js +6 -3
  57. package/dist/Tabbar/index.umd.cjs +1 -1
  58. package/dist/Tabbar/style/index.css +1 -1
  59. package/dist/Tabbar/style.css +1 -1
  60. package/dist/Tabs/index.js +57 -17
  61. package/dist/Tabs/index.umd.cjs +1 -1
  62. package/dist/Tabs/style/index.css +1 -1
  63. package/dist/Tabs/style.css +1 -1
  64. package/dist/TimePicker/style/index.css +1 -1
  65. package/dist/TimePicker/style.css +1 -1
  66. package/dist/Tip/index.js +28 -5
  67. package/dist/Tip/index.umd.cjs +2 -2
  68. package/dist/Tip/style/index.css +1 -1
  69. package/dist/Tip/style.css +1 -1
  70. package/dist/Tooltip/index.js +59 -14
  71. package/dist/Tooltip/index.umd.cjs +2 -2
  72. package/dist/Tooltip/style/index.css +1 -1
  73. package/dist/Tooltip/style.css +1 -1
  74. package/dist/style.css +1 -1
  75. package/dist/types/components/Button/Button.d.ts +3 -0
  76. package/dist/types/components/ButtonGroup/ButtonGroup.d.ts +20 -0
  77. package/dist/types/components/ButtonGroup/index.d.ts +5 -0
  78. package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +6 -0
  79. package/dist/types/components/Divider/Divider.d.ts +2 -0
  80. package/dist/types/components/GridView/GridView.d.ts +8 -0
  81. package/dist/types/components/Input/Input.d.ts +11 -1
  82. package/dist/types/components/Search/Search.d.ts +1 -0
  83. package/dist/types/components/Tabbar/Tabbar.d.ts +2 -0
  84. package/dist/types/components/Tabs/Tabs.d.ts +4 -1
  85. package/dist/types/components/Tip/Tip.d.ts +21 -2
  86. package/dist/types/components/Tooltip/Tooltip.d.ts +6 -2
  87. package/dist/types/components/index.d.ts +2 -1
  88. package/dist/wz-h5-design.es.js +357 -99
  89. package/dist/wz-h5-design.umd.js +2 -2
  90. package/package.json +1 -1
@@ -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",
@@ -9,6 +9,9 @@ const Button = forwardRef(({
9
9
  color = "",
10
10
  textColor = "",
11
11
  borderColor = "",
12
+ width,
13
+ height,
14
+ fontSize,
12
15
  className = "",
13
16
  style = {},
14
17
  children,
@@ -18,12 +21,22 @@ const Button = forwardRef(({
18
21
  }, ref) => {
19
22
  const [isActive, setIsActive] = useState(false);
20
23
  const timerRef = useRef(null);
24
+ const formatSize = (value) => {
25
+ if (value === void 0) return void 0;
26
+ return typeof value === "number" ? `${value}px` : value;
27
+ };
21
28
  const buttonStyle = useMemo(() => {
29
+ const customStyle = {
30
+ width: formatSize(width),
31
+ height: formatSize(height),
32
+ fontSize: formatSize(fontSize)
33
+ };
22
34
  if (type === "cancel") {
23
35
  return {
24
36
  background: "#D6D6D6",
25
37
  color: textColor || "#fff",
26
- ...style
38
+ ...style,
39
+ ...customStyle
27
40
  };
28
41
  }
29
42
  if (type === "outline") {
@@ -31,7 +44,8 @@ const Button = forwardRef(({
31
44
  color: textColor || "var(--wz-primary-color)",
32
45
  borderColor: borderColor || "var(--wz-primary-color)",
33
46
  background: "transparent",
34
- ...style
47
+ ...style,
48
+ ...customStyle
35
49
  };
36
50
  }
37
51
  if (type === "text") {
@@ -40,7 +54,8 @@ const Button = forwardRef(({
40
54
  background: "transparent",
41
55
  border: "none",
42
56
  boxShadow: "none",
43
- ...style
57
+ ...style,
58
+ ...customStyle
44
59
  };
45
60
  }
46
61
  if (type === "plain") {
@@ -48,7 +63,8 @@ const Button = forwardRef(({
48
63
  color: textColor || "#666666",
49
64
  borderColor: borderColor || "#666666",
50
65
  background: "transparent",
51
- ...style
66
+ ...style,
67
+ ...customStyle
52
68
  };
53
69
  }
54
70
  if (type === "primary") {
@@ -57,10 +73,10 @@ const Button = forwardRef(({
57
73
  s.background = color || "var(--wz-primary-gradient, var(--wz-primary-color))";
58
74
  }
59
75
  s.color = textColor || "#fff";
60
- return s;
76
+ return { ...s, ...customStyle };
61
77
  }
62
- return style;
63
- }, [type, color, textColor, borderColor, style]);
78
+ return { ...style, ...customStyle };
79
+ }, [type, color, textColor, borderColor, width, height, fontSize, style]);
64
80
  const handleClick = (e) => {
65
81
  if (disabled) return;
66
82
  setIsActive(true);
@@ -100,6 +116,62 @@ const Button = forwardRef(({
100
116
  );
101
117
  });
102
118
  Button.displayName = "Button";
119
+ const ButtonGroup = ({
120
+ bgColor = "#fff",
121
+ height,
122
+ padding = "2px 10px",
123
+ fixed = false,
124
+ gap = 9,
125
+ className = "",
126
+ style = {},
127
+ children
128
+ }) => {
129
+ const formatSize = (value) => {
130
+ if (value === void 0) return void 0;
131
+ return typeof value === "number" ? `${value}px` : value;
132
+ };
133
+ const containerStyle = {
134
+ backgroundColor: bgColor,
135
+ height: formatSize(height),
136
+ padding: formatSize(padding),
137
+ gap: formatSize(gap),
138
+ ...style
139
+ };
140
+ const classNames2 = [
141
+ "wz-button-group",
142
+ fixed ? "wz-button-group--fixed" : "",
143
+ className
144
+ ].filter(Boolean).join(" ");
145
+ return /* @__PURE__ */ jsx("div", { className: classNames2, style: containerStyle, children });
146
+ };
147
+ ButtonGroup.displayName = "ButtonGroup";
148
+ const Icon = ({
149
+ name,
150
+ size = 24,
151
+ color = "currentColor",
152
+ className = "",
153
+ style,
154
+ onClick,
155
+ type = "yunying"
156
+ // 默认使用yunying图标库
157
+ }) => {
158
+ const iconStyle = {
159
+ fontSize: typeof size === "number" ? `${size}px` : size,
160
+ color,
161
+ ...style
162
+ };
163
+ const iconFontClass = `iconfont-${type}`;
164
+ const iconPrefix = "icon-";
165
+ const iconClass = `${iconPrefix}${name}`;
166
+ return /* @__PURE__ */ jsx(
167
+ "i",
168
+ {
169
+ className: `wz-icon ${iconFontClass} ${iconClass} ${className}`,
170
+ style: iconStyle,
171
+ onClick
172
+ }
173
+ );
174
+ };
103
175
  const RadioGroupContext = createContext({});
104
176
  const Radio = ({
105
177
  size,
@@ -127,6 +199,11 @@ const Radio = ({
127
199
  const isChecked = isInGroup ? groupContext.value === value : checked;
128
200
  const isDisabled = disabled || groupContext.disabled;
129
201
  const radioSize = size || groupContext.size || "medium";
202
+ const iconSizeMap = {
203
+ small: 16,
204
+ medium: 18,
205
+ large: 20
206
+ };
130
207
  return /* @__PURE__ */ jsxs(
131
208
  "label",
132
209
  {
@@ -145,7 +222,7 @@ const Radio = ({
145
222
  ...rest
146
223
  }
147
224
  ),
148
- /* @__PURE__ */ jsx("span", { className: "wz-radio-inner" }),
225
+ /* @__PURE__ */ jsx("span", { className: "wz-radio-inner", children: /* @__PURE__ */ jsx(Icon, { name: isChecked ? "radio-sel" : "radio-nor", type: "yunying", size: iconSizeMap[radioSize] }) }),
149
226
  children && /* @__PURE__ */ jsx("span", { className: "wz-radio-label", children })
150
227
  ]
151
228
  }
@@ -206,6 +283,11 @@ const Checkbox = ({
206
283
  const isChecked = isInGroup ? (_a = groupContext.value) == null ? void 0 : _a.includes(value) : checked;
207
284
  const isDisabled = disabled || groupContext.disabled;
208
285
  const checkboxSize = size || groupContext.size || "medium";
286
+ const iconSizeMap = {
287
+ small: 16,
288
+ medium: 18,
289
+ large: 20
290
+ };
209
291
  return /* @__PURE__ */ jsxs(
210
292
  "label",
211
293
  {
@@ -224,7 +306,7 @@ const Checkbox = ({
224
306
  ...rest
225
307
  }
226
308
  ),
227
- /* @__PURE__ */ jsx("span", { className: "wz-checkbox-inner" }),
309
+ /* @__PURE__ */ jsx("span", { className: "wz-checkbox-inner", children: /* @__PURE__ */ jsx(Icon, { name: isChecked ? "checkbox-checked" : "checkbox", type: "yunying", size: iconSizeMap[checkboxSize] }) }),
228
310
  children && /* @__PURE__ */ jsx("span", { className: "wz-checkbox-label", children })
229
311
  ]
230
312
  }
@@ -274,11 +356,17 @@ const Switch = ({
274
356
  const [innerValue, setInnerValue] = useState(defaultValue);
275
357
  const isControlled = value !== void 0;
276
358
  const checked = isControlled ? value : innerValue;
277
- const text = checked ? activeText || DEFAULT_ACTIVE_TEXT : inactiveText || DEFAULT_INACTIVE_TEXT;
359
+ const activeTextDisplay = activeText || DEFAULT_ACTIVE_TEXT;
360
+ const inactiveTextDisplay = inactiveText || DEFAULT_INACTIVE_TEXT;
361
+ const text = checked ? activeTextDisplay : inactiveTextDisplay;
278
362
  const textWidth = showText ? `${text.length * 12 + 8}px` : "0px";
363
+ const maxTextLen = Math.max(activeTextDisplay.length, inactiveTextDisplay.length);
279
364
  const baseWidth = size === "large" ? 62 : 60;
280
- const switchWidthNum = showText ? text.length * 12 + 40 : baseWidth;
365
+ const calculatedWidth = showText ? maxTextLen * 12 + 40 : baseWidth;
366
+ const switchWidthNum = Math.max(calculatedWidth, baseWidth);
281
367
  const switchWidth = `${switchWidthNum}px`;
368
+ const sliderSize = size === "large" ? 24 : 22;
369
+ const sliderTranslateX = checked ? switchWidthNum - sliderSize - 4 : 0;
282
370
  const onBg = activeColor ? activeColor.includes("gradient") ? activeColor : activeColor : void 0;
283
371
  const handleClick = () => {
284
372
  if (disabled) return;
@@ -297,7 +385,8 @@ const Switch = ({
297
385
  /* @__PURE__ */ jsx(
298
386
  "div",
299
387
  {
300
- className: `wz-switch-slider ${checked ? "wz-switch-slider-on" : "wz-switch-slider-off"}`
388
+ className: `wz-switch-slider ${checked ? "wz-switch-slider-on" : "wz-switch-slider-off"}`,
389
+ style: { transform: `translateX(${sliderTranslateX}px)` }
301
390
  }
302
391
  )
303
392
  ]
@@ -355,42 +444,18 @@ var classnames = { exports: {} };
355
444
  })(classnames);
356
445
  var classnamesExports = classnames.exports;
357
446
  const classNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
358
- const Icon = ({
359
- name,
360
- size = 24,
361
- color = "currentColor",
362
- className = "",
363
- style,
364
- onClick,
365
- type = "yunying"
366
- // 默认使用yunying图标库
367
- }) => {
368
- const iconStyle = {
369
- fontSize: typeof size === "number" ? `${size}px` : size,
370
- color,
371
- ...style
372
- };
373
- const iconFontClass = `iconfont-${type}`;
374
- const iconPrefix = "icon-";
375
- const iconClass = `${iconPrefix}${name}`;
376
- return /* @__PURE__ */ jsx(
377
- "i",
378
- {
379
- className: `wz-icon ${iconFontClass} ${iconClass} ${className}`,
380
- style: iconStyle,
381
- onClick
382
- }
383
- );
384
- };
385
447
  const TabbarItem = (props) => {
386
- const { title, icon, activeIcon, badge, badgeAsBubble, hump, active, onItemClick, onClick, activeColor } = props;
448
+ const { title, icon, activeIcon, badge, badgeAsBubble, dot, hump, active, onItemClick, onClick, activeColor } = props;
387
449
  const renderIcon = (iconSource) => {
388
450
  if (typeof iconSource === "string") {
389
- return /* @__PURE__ */ jsx(Icon, { name: iconSource });
451
+ return /* @__PURE__ */ jsx(Icon, { size: 22, name: iconSource });
390
452
  }
391
453
  return iconSource;
392
454
  };
393
455
  const renderBadge = () => {
456
+ if (dot) {
457
+ return /* @__PURE__ */ jsx("div", { className: "wz-tabbar-item-dot" });
458
+ }
394
459
  if (!badge) return null;
395
460
  if (badgeAsBubble) {
396
461
  return /* @__PURE__ */ jsx("div", { className: "wz-tabbar-item-badge-custom", children: /* @__PURE__ */ jsxs("div", { className: "wz-tabbar-item-badge-bubble", children: [
@@ -419,7 +484,7 @@ const TabbarItem = (props) => {
419
484
  active ? renderIcon(activeIcon || icon) : renderIcon(icon),
420
485
  renderBadge()
421
486
  ] }),
422
- /* @__PURE__ */ jsx("div", { className: "wz-tabbar-item-title", children: title })
487
+ !hump && /* @__PURE__ */ jsx("div", { className: "wz-tabbar-item-title", children: title })
423
488
  ] });
424
489
  };
425
490
  const Tabbar = (props) => {
@@ -544,7 +609,7 @@ const Cell$1 = (props) => {
544
609
  };
545
610
  const renderRightIcon = () => {
546
611
  if (arrow) {
547
- return /* @__PURE__ */ jsx("div", { className: "wz-cell-arrow" });
612
+ return /* @__PURE__ */ jsx("div", { className: "wz-cell-arrow", children: /* @__PURE__ */ jsx(Icon, { name: "right-arrow", size: 16 }) });
548
613
  }
549
614
  return null;
550
615
  };
@@ -570,6 +635,7 @@ const TabPane = ({ children }) => {
570
635
  };
571
636
  const Tabs = ({
572
637
  type = "line",
638
+ align = "center",
573
639
  value,
574
640
  defaultValue = 0,
575
641
  onChange,
@@ -579,33 +645,72 @@ const Tabs = ({
579
645
  headerStyle,
580
646
  contentClassName = "",
581
647
  contentStyle,
582
- children
648
+ children,
649
+ maxTabs = 5
583
650
  }) => {
584
651
  const isControlled = value !== void 0;
585
652
  const [innerValue, setInnerValue] = useState(defaultValue);
586
653
  const activeIndex = isControlled ? value : innerValue;
587
- const panes = Children.toArray(children).filter(Boolean);
654
+ const headerRef = useRef(null);
655
+ const isDragging = useRef(false);
656
+ const startX = useRef(0);
657
+ const scrollLeft = useRef(0);
658
+ const handleMouseDown = useCallback((e) => {
659
+ if (align !== "left" || !headerRef.current) return;
660
+ isDragging.current = true;
661
+ startX.current = e.pageX - headerRef.current.offsetLeft;
662
+ scrollLeft.current = headerRef.current.scrollLeft;
663
+ }, [align]);
664
+ const handleMouseMove = useCallback((e) => {
665
+ if (!isDragging.current || !headerRef.current) return;
666
+ e.preventDefault();
667
+ const x = e.pageX - headerRef.current.offsetLeft;
668
+ const walk = (x - startX.current) * 1.5;
669
+ headerRef.current.scrollLeft = scrollLeft.current - walk;
670
+ }, []);
671
+ const handleMouseUp = useCallback(() => {
672
+ isDragging.current = false;
673
+ }, []);
674
+ const handleMouseLeave = useCallback(() => {
675
+ isDragging.current = false;
676
+ }, []);
677
+ const allPanes = Children.toArray(children).filter(Boolean);
678
+ const panes = allPanes.slice(0, maxTabs);
588
679
  const handleTabClick = (idx, disabled) => {
589
680
  if (disabled) return;
590
681
  if (!isControlled) setInnerValue(idx);
591
682
  onChange == null ? void 0 : onChange(idx);
592
683
  };
593
- return /* @__PURE__ */ jsxs("div", { className: `wz-tabs wz-tabs-${type} ${className}`, style, children: [
594
- /* @__PURE__ */ jsx("div", { className: `wz-tabs-header ${headerClassName}`, style: headerStyle, children: panes.map((pane, idx) => /* @__PURE__ */ jsxs(
684
+ const cardTabStyle = type === "card" ? {
685
+ flex: panes.length > 3 ? "0 0 calc((100% - 28px) / 3)" : "1"
686
+ } : void 0;
687
+ return /* @__PURE__ */ jsxs("div", { className: `wz-tabs wz-tabs-${type}${align === "left" ? " wz-tabs-align-left" : ""} ${className}`, style, children: [
688
+ /* @__PURE__ */ jsx(
595
689
  "div",
596
690
  {
597
- className: `wz-tabs-tab${idx === activeIndex ? " wz-tabs-tab-active" : ""}${pane.props.disabled ? " wz-tabs-tab-disabled" : ""}`,
598
- onClick: () => handleTabClick(idx, pane.props.disabled),
599
- children: [
600
- /* @__PURE__ */ jsxs("div", { className: "wz-tabs-tab-text", children: [
601
- pane.props.title,
602
- pane.props.badge && /* @__PURE__ */ jsx("div", { className: "wz-tabs-badge", children: pane.props.badge })
603
- ] }),
604
- idx === activeIndex && type === "line" && /* @__PURE__ */ jsx("div", { className: "wz-tabs-underline" })
605
- ]
606
- },
607
- idx
608
- )) }),
691
+ ref: headerRef,
692
+ className: `wz-tabs-header ${headerClassName}`,
693
+ style: headerStyle,
694
+ onMouseDown: handleMouseDown,
695
+ onMouseMove: handleMouseMove,
696
+ onMouseUp: handleMouseUp,
697
+ onMouseLeave: handleMouseLeave,
698
+ children: panes.map((pane, idx) => /* @__PURE__ */ jsx(
699
+ "div",
700
+ {
701
+ className: `wz-tabs-tab${idx === activeIndex ? " wz-tabs-tab-active" : ""}${pane.props.disabled ? " wz-tabs-tab-disabled" : ""}`,
702
+ style: cardTabStyle,
703
+ onClick: () => handleTabClick(idx, pane.props.disabled),
704
+ children: /* @__PURE__ */ jsxs("div", { className: "wz-tabs-tab-text", children: [
705
+ pane.props.title,
706
+ pane.props.badge && /* @__PURE__ */ jsx("div", { className: "wz-tabs-badge", children: pane.props.badge }),
707
+ idx === activeIndex && type === "line" && /* @__PURE__ */ jsx("div", { className: "wz-tabs-underline" })
708
+ ] })
709
+ },
710
+ idx
711
+ ))
712
+ }
713
+ ),
609
714
  /* @__PURE__ */ jsx("div", { className: `wz-tabs-content ${contentClassName}`, style: contentStyle, children: panes[activeIndex] })
610
715
  ] });
611
716
  };
@@ -996,7 +1101,7 @@ const Cascader = ({
996
1101
  const Input = forwardRef(
997
1102
  ({
998
1103
  clearable = false,
999
- align = "center",
1104
+ align = "left",
1000
1105
  value,
1001
1106
  defaultValue,
1002
1107
  onChange,
@@ -1011,12 +1116,49 @@ const Input = forwardRef(
1011
1116
  borderRadius,
1012
1117
  backgroundColor,
1013
1118
  bordered,
1119
+ codeCountdown = 60,
1120
+ onGetCode,
1121
+ codeText = "获取验证码",
1122
+ codeCountingText = "{s}s后重新获取",
1123
+ codeResendText = "重新获取验证码",
1014
1124
  ...props
1015
1125
  }, ref) => {
1016
1126
  const isControlled = value !== void 0;
1017
1127
  const [innerValue, setInnerValue] = useState(defaultValue || "");
1018
1128
  const showClear = clearable && !!(isControlled ? value : innerValue);
1019
1129
  const [passwordVisible, setPasswordVisible] = useState(false);
1130
+ const [counting, setCounting] = useState(false);
1131
+ const [countdown, setCountdown] = useState(codeCountdown);
1132
+ const [hasSent, setHasSent] = useState(false);
1133
+ const [suffixWidth, setSuffixWidth] = useState(0);
1134
+ const suffixRef = useRef(null);
1135
+ useEffect(() => {
1136
+ if (suffixRef.current) {
1137
+ const width = suffixRef.current.offsetWidth;
1138
+ setSuffixWidth(width);
1139
+ }
1140
+ }, [counting, countdown, hasSent, suffix, codeText, codeCountingText, codeResendText]);
1141
+ useEffect(() => {
1142
+ let timer;
1143
+ if (counting && countdown > 0) {
1144
+ timer = setInterval(() => {
1145
+ setCountdown((prev) => prev - 1);
1146
+ }, 1e3);
1147
+ } else if (countdown === 0) {
1148
+ setCounting(false);
1149
+ setCountdown(codeCountdown);
1150
+ }
1151
+ return () => clearInterval(timer);
1152
+ }, [counting, countdown, codeCountdown]);
1153
+ const handleGetCode = useCallback(async () => {
1154
+ if (counting) return;
1155
+ try {
1156
+ await (onGetCode == null ? void 0 : onGetCode());
1157
+ setCounting(true);
1158
+ setHasSent(true);
1159
+ } catch {
1160
+ }
1161
+ }, [counting, onGetCode]);
1020
1162
  const handleChange = (e) => {
1021
1163
  if (!isControlled) setInnerValue(e.target.value);
1022
1164
  onChange == null ? void 0 : onChange(e);
@@ -1041,7 +1183,8 @@ const Input = forwardRef(
1041
1183
  textAlign: align,
1042
1184
  borderRadius,
1043
1185
  backgroundColor,
1044
- border: bordered !== void 0 ? void 0 : "none"
1186
+ border: bordered !== void 0 ? void 0 : "none",
1187
+ ...suffixWidth > 0 && (suffix || type === "code") ? { paddingRight: suffixWidth + 22 + 12 } : {}
1045
1188
  };
1046
1189
  const currentValue = isControlled ? value : innerValue;
1047
1190
  const count = (currentValue == null ? void 0 : currentValue.toString().length) || 0;
@@ -1093,15 +1236,19 @@ const Input = forwardRef(
1093
1236
  return /* @__PURE__ */ jsxs(
1094
1237
  "div",
1095
1238
  {
1096
- className: `wz-input-affix-wrapper ${type === "textarea" ? "wz-input-affix-wrapper-textarea" : ""} ${suffix ? "wz-input-has-suffix" : ""} ${bordered === void 0 ? "wz-input-no-border" : ""}`,
1239
+ 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" : ""}`,
1097
1240
  style: wrapperStyle,
1098
1241
  children: [
1099
1242
  renderInput(),
1100
1243
  showClear && !props.disabled && type !== "textarea" && !suffix && /* @__PURE__ */ jsx("span", { className: "wz-input-clear", onClick: handleClear, children: /* @__PURE__ */ jsx(Icon, { name: "close", size: 22 }) }),
1101
1244
  type === "password" && !suffix && /* @__PURE__ */ jsx("span", { className: "wz-input-password", onClick: handlePasswordVisible, children: /* @__PURE__ */ jsx(Icon, { name: passwordVisible ? "eyes-close" : "eyes-open", size: 22 }) }),
1102
- suffix && /* @__PURE__ */ jsxs("div", { className: "wz-input-suffix", children: [
1245
+ suffix && /* @__PURE__ */ jsxs("div", { className: "wz-input-suffix", ref: suffixRef, children: [
1103
1246
  /* @__PURE__ */ jsx("span", { className: "wz-input-suffix-divider" }),
1104
1247
  suffix
1248
+ ] }),
1249
+ type === "code" && /* @__PURE__ */ jsxs("div", { className: "wz-input-suffix", ref: !suffix ? suffixRef : void 0, children: [
1250
+ /* @__PURE__ */ jsx("span", { className: "wz-input-suffix-divider" }),
1251
+ 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 })
1105
1252
  ] })
1106
1253
  ]
1107
1254
  }
@@ -1109,23 +1256,32 @@ const Input = forwardRef(
1109
1256
  }
1110
1257
  );
1111
1258
  Input.displayName = "Input";
1259
+ const COLOR_MAP = {
1260
+ horizontal: {
1261
+ default: "#f7f7f7",
1262
+ emphasis: "#eeeeee"
1263
+ },
1264
+ vertical: "rgba(0, 0, 0, 0.1)"
1265
+ };
1112
1266
  const Divider = ({
1113
1267
  direction = "horizontal",
1114
- color = "#eee",
1268
+ type = "default",
1269
+ color,
1115
1270
  length,
1116
1271
  margin,
1117
1272
  style,
1118
1273
  className = ""
1119
1274
  }) => {
1120
1275
  const isVertical = direction === "vertical";
1276
+ const defaultColor = isVertical ? COLOR_MAP.vertical : COLOR_MAP.horizontal[type];
1121
1277
  return /* @__PURE__ */ jsx(
1122
1278
  "div",
1123
1279
  {
1124
1280
  className: `wz-divider wz-divider--${direction} ${className}`,
1125
1281
  style: {
1126
- background: color,
1127
- width: isVertical ? 1 : length || "100%",
1128
- height: isVertical ? length || 24 : 1,
1282
+ background: color || defaultColor,
1283
+ width: isVertical ? 2 : length || "100%",
1284
+ height: isVertical ? length || 24 : 2,
1129
1285
  margin,
1130
1286
  ...style
1131
1287
  }
@@ -1156,7 +1312,7 @@ const CheckList = ({ options, value, onChange, multiple = false, style, classNam
1156
1312
  onClick: () => handleClick(item),
1157
1313
  children: [
1158
1314
  /* @__PURE__ */ jsx("span", { className: "wz-check-list__label", children: item }),
1159
- isChecked(item) && /* @__PURE__ */ jsx("span", { className: "wz-check-list__icon", children: "" })
1315
+ isChecked(item) && /* @__PURE__ */ jsx("span", { className: "wz-check-list__icon", children: /* @__PURE__ */ jsx(Icon, { name: "check", size: 18, type: "yunying" }) })
1160
1316
  ]
1161
1317
  },
1162
1318
  item
@@ -1174,6 +1330,7 @@ const Search = forwardRef(
1174
1330
  suffix,
1175
1331
  leftIcon = /* @__PURE__ */ jsx(Icon, { name: "search", size: 16 }),
1176
1332
  actionText = "搜索",
1333
+ actionColor,
1177
1334
  showCancel = false,
1178
1335
  cancelText = "返回",
1179
1336
  background,
@@ -1270,13 +1427,20 @@ const Search = forwardRef(
1270
1427
  ...props
1271
1428
  }
1272
1429
  ),
1273
- showClear && /* @__PURE__ */ jsx("div", { className: "wz-search-clear", onMouseDown: handleClear, children: /* @__PURE__ */ jsx(Icon, { name: "close", size: 16, color: "#BDBDBD" }) })
1430
+ showClear && /* @__PURE__ */ jsx("div", { className: "wz-search-clear", onMouseDown: handleClear, children: /* @__PURE__ */ jsx(Icon, { name: "close", size: 16, color: "#CCCCCC" }) })
1274
1431
  ]
1275
1432
  }
1276
1433
  ),
1277
1434
  actionText && /* @__PURE__ */ jsxs("div", { className: "wz-search-action", onClick: handleSearch, children: [
1278
1435
  /* @__PURE__ */ jsx("div", { className: "wz-search-divider" }),
1279
- /* @__PURE__ */ jsx("div", { className: "wz-search-action-text", children: actionText })
1436
+ /* @__PURE__ */ jsx(
1437
+ "div",
1438
+ {
1439
+ className: "wz-search-action-text",
1440
+ style: actionColor ? { color: actionColor } : void 0,
1441
+ children: actionText
1442
+ }
1443
+ )
1280
1444
  ] })
1281
1445
  ]
1282
1446
  }
@@ -1641,7 +1805,10 @@ const DateRangePicker = ({
1641
1805
  startLabel = "开始时间",
1642
1806
  endLabel = "结束时间",
1643
1807
  className = "",
1644
- style
1808
+ style,
1809
+ showLongTerm = false,
1810
+ longTermLabel = "长期有效",
1811
+ longTermValue = "9999-12-31"
1645
1812
  }) => {
1646
1813
  const todayStr = React.useMemo(() => {
1647
1814
  const today = /* @__PURE__ */ new Date();
@@ -1653,6 +1820,7 @@ const DateRangePicker = ({
1653
1820
  const [innerValue, setInnerValue] = useState(value || [todayStr, todayStr]);
1654
1821
  const range = value || innerValue;
1655
1822
  const [active, setActive] = useState("start");
1823
+ const isLongTerm = range[1] === longTermValue;
1656
1824
  const handleSelect = (val) => {
1657
1825
  if (active === "start") {
1658
1826
  const newRange = [val, range[1] && range[1] >= val ? range[1] : val];
@@ -1664,6 +1832,17 @@ const DateRangePicker = ({
1664
1832
  onChange == null ? void 0 : onChange(newRange);
1665
1833
  }
1666
1834
  };
1835
+ const handleLongTermToggle = () => {
1836
+ if (isLongTerm) {
1837
+ const newRange = [range[0], range[0]];
1838
+ setInnerValue(newRange);
1839
+ onChange == null ? void 0 : onChange(newRange);
1840
+ } else {
1841
+ const newRange = [range[0], longTermValue];
1842
+ setInnerValue(newRange);
1843
+ onChange == null ? void 0 : onChange(newRange);
1844
+ }
1845
+ };
1667
1846
  return /* @__PURE__ */ jsxs("div", { className: `wz-date-range-picker ${className}`, style, children: [
1668
1847
  /* @__PURE__ */ jsxs("div", { className: "wz-date-range-picker-label-row", children: [
1669
1848
  /* @__PURE__ */ jsx("div", { className: "wz-date-range-picker-label", children: startLabel }),
@@ -1679,14 +1858,28 @@ const DateRangePicker = ({
1679
1858
  }
1680
1859
  ) }),
1681
1860
  /* @__PURE__ */ jsx("div", { className: "wz-date-range-picker-sep", children: "至" }),
1682
- /* @__PURE__ */ jsx("div", { className: "wz-date-range-picker-col", children: /* @__PURE__ */ jsx(
1683
- "div",
1684
- {
1685
- className: `wz-date-range-picker-value${active === "end" ? " active" : ""}`,
1686
- onClick: () => setActive("end"),
1687
- children: range[1] || "请选择"
1688
- }
1689
- ) })
1861
+ /* @__PURE__ */ jsxs("div", { className: "wz-date-range-picker-col", children: [
1862
+ /* @__PURE__ */ jsx(
1863
+ "div",
1864
+ {
1865
+ className: `wz-date-range-picker-value${active === "end" ? " active" : ""}${isLongTerm ? " disabled" : ""}`,
1866
+ onClick: () => !isLongTerm && setActive("end"),
1867
+ children: isLongTerm ? longTermLabel : range[1] || "请选择"
1868
+ }
1869
+ ),
1870
+ showLongTerm && /* @__PURE__ */ jsxs("div", { className: "wz-date-range-picker-long-term", onClick: handleLongTermToggle, children: [
1871
+ /* @__PURE__ */ jsx(
1872
+ Icon,
1873
+ {
1874
+ name: isLongTerm ? "radio-sel" : "radio-nor",
1875
+ type: "yunying",
1876
+ size: 20,
1877
+ color: isLongTerm ? "var(--active-color)" : "#ccc"
1878
+ }
1879
+ ),
1880
+ /* @__PURE__ */ jsx("span", { className: "wz-date-range-picker-long-term-text", children: longTermLabel })
1881
+ ] })
1882
+ ] })
1690
1883
  ] }),
1691
1884
  /* @__PURE__ */ jsx("div", { className: "wz-date-range-picker-picker", children: /* @__PURE__ */ jsx(
1692
1885
  DatePicker,
@@ -1832,7 +2025,11 @@ Grid.Item = GridItem;
1832
2025
  const GridViewItem = ({
1833
2026
  icon,
1834
2027
  text,
2028
+ textColor,
2029
+ textSize,
1835
2030
  description,
2031
+ descriptionColor,
2032
+ descriptionSize,
1836
2033
  badge,
1837
2034
  corner,
1838
2035
  onClick,
@@ -1879,8 +2076,28 @@ const GridViewItem = ({
1879
2076
  /* @__PURE__ */ jsxs("div", { className: "wz-grid-view-item__content", children: [
1880
2077
  icon && /* @__PURE__ */ jsx("div", { className: "wz-grid-view-item__icon", children: icon }),
1881
2078
  /* @__PURE__ */ jsxs("div", { className: "wz-grid-view-item__text", children: [
1882
- text && /* @__PURE__ */ jsx("div", { className: "wz-grid-view-item__title", children: text }),
1883
- description && /* @__PURE__ */ jsx("div", { className: "wz-grid-view-item__desc", children: description })
2079
+ text && /* @__PURE__ */ jsx(
2080
+ "div",
2081
+ {
2082
+ className: "wz-grid-view-item__title",
2083
+ style: {
2084
+ ...textColor ? { color: textColor } : {},
2085
+ ...textSize ? { fontSize: typeof textSize === "number" ? `${textSize}px` : textSize } : {}
2086
+ },
2087
+ children: text
2088
+ }
2089
+ ),
2090
+ description && /* @__PURE__ */ jsx(
2091
+ "div",
2092
+ {
2093
+ className: "wz-grid-view-item__desc",
2094
+ style: {
2095
+ ...descriptionColor ? { color: descriptionColor } : {},
2096
+ ...descriptionSize ? { fontSize: typeof descriptionSize === "number" ? `${descriptionSize}px` : descriptionSize } : {}
2097
+ },
2098
+ children: description
2099
+ }
2100
+ )
1884
2101
  ] })
1885
2102
  ] }),
1886
2103
  badge && /* @__PURE__ */ jsx("div", { className: "wz-grid-view-item__badge", children: badge })
@@ -1960,20 +2177,42 @@ const Tip = ({
1960
2177
  className,
1961
2178
  visible = true,
1962
2179
  onClose,
1963
- action,
1964
- marquee = false
2180
+ marquee = false,
2181
+ bold = false,
2182
+ icon,
2183
+ showAction = false,
2184
+ actionText = "查看",
2185
+ onAction
1965
2186
  }) => {
2187
+ const contentRef = useRef(null);
2188
+ const [isMultiLine, setIsMultiLine] = useState(false);
2189
+ useEffect(() => {
2190
+ if (contentRef.current && !marquee) {
2191
+ const el = contentRef.current;
2192
+ const lineHeight = parseFloat(getComputedStyle(el).lineHeight) || 20;
2193
+ setIsMultiLine(el.scrollHeight > lineHeight * 1.5);
2194
+ }
2195
+ }, [content, marquee]);
1966
2196
  if (!visible) {
1967
2197
  return null;
1968
2198
  }
1969
2199
  const baseClass = "wz-tip";
2200
+ const hasRightArea = showAction || onClose;
1970
2201
  const tipClass = classNames(baseClass, className, {
1971
- [`${baseClass}--marquee`]: marquee
2202
+ [`${baseClass}--marquee`]: marquee,
2203
+ [`${baseClass}--bold`]: bold,
2204
+ [`${baseClass}--center`]: !marquee && !isMultiLine,
2205
+ [`${baseClass}--left`]: !marquee && isMultiLine,
2206
+ [`${baseClass}--has-icon`]: !!icon,
2207
+ [`${baseClass}--has-right`]: hasRightArea
1972
2208
  });
1973
2209
  const contentNode = marquee ? /* @__PURE__ */ jsx("div", { className: `${baseClass}-marquee-box`, children: /* @__PURE__ */ jsx("span", { children: content }) }) : content;
1974
2210
  return /* @__PURE__ */ jsxs("div", { className: tipClass, children: [
1975
- /* @__PURE__ */ jsx("div", { className: `${baseClass}-content`, children: contentNode }),
1976
- action && /* @__PURE__ */ jsx("div", { className: `${baseClass}-action`, children: action }),
2211
+ /* @__PURE__ */ jsxs("div", { className: `${baseClass}-content`, ref: contentRef, children: [
2212
+ icon && /* @__PURE__ */ jsx("span", { className: `${baseClass}-icon`, children: /* @__PURE__ */ jsx(Icon, { name: icon, size: 16 }) }),
2213
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}-text`, children: contentNode })
2214
+ ] }),
2215
+ showAction && /* @__PURE__ */ jsx("div", { className: `${baseClass}-action`, onClick: onAction, children: actionText }),
1977
2216
  onClose && /* @__PURE__ */ jsx("div", { className: `${baseClass}-close`, onClick: onClose, children: /* @__PURE__ */ jsx(Icon, { name: "close", size: 16 }) })
1978
2217
  ] });
1979
2218
  };
@@ -2252,8 +2491,9 @@ const Tooltip = ({
2252
2491
  visible,
2253
2492
  onVisibleChange,
2254
2493
  showMask = false,
2255
- action,
2256
- closeIcon
2494
+ actionText,
2495
+ onAction,
2496
+ closable = false
2257
2497
  }) => {
2258
2498
  const [internalVisible, setInternalVisible] = useState(false);
2259
2499
  const [computedStyle, setComputedStyle] = useState({});
@@ -2268,8 +2508,8 @@ const Tooltip = ({
2268
2508
  }
2269
2509
  onVisibleChange == null ? void 0 : onVisibleChange(newVisible);
2270
2510
  };
2271
- useLayoutEffect(() => {
2272
- if (currentVisible && tooltipRef.current && triggerRef.current) {
2511
+ const updatePosition = useCallback(() => {
2512
+ if (tooltipRef.current && triggerRef.current) {
2273
2513
  const bubbleEl = tooltipRef.current;
2274
2514
  const triggerEl = triggerRef.current;
2275
2515
  const { width: bubbleWidth, height: bubbleHeight } = bubbleEl.getBoundingClientRect();
@@ -2302,7 +2542,24 @@ const Tooltip = ({
2302
2542
  "--wz-tooltip-arrow-left": `${arrowLeft}px`
2303
2543
  });
2304
2544
  }
2305
- }, [currentVisible]);
2545
+ }, []);
2546
+ useLayoutEffect(() => {
2547
+ if (currentVisible) {
2548
+ updatePosition();
2549
+ }
2550
+ }, [currentVisible, updatePosition]);
2551
+ useEffect(() => {
2552
+ if (!currentVisible) return;
2553
+ const handleScroll = () => {
2554
+ updatePosition();
2555
+ };
2556
+ window.addEventListener("scroll", handleScroll, true);
2557
+ window.addEventListener("resize", handleScroll);
2558
+ return () => {
2559
+ window.removeEventListener("scroll", handleScroll, true);
2560
+ window.removeEventListener("resize", handleScroll);
2561
+ };
2562
+ }, [currentVisible, updatePosition]);
2306
2563
  const handleWrapperClick = () => {
2307
2564
  if (trigger === "click") {
2308
2565
  handleVisibleChange(!currentVisible);
@@ -2324,17 +2581,17 @@ const Tooltip = ({
2324
2581
  const renderBubble = () => {
2325
2582
  if (!currentVisible) return null;
2326
2583
  const renderAction = () => {
2327
- if (!action) return null;
2328
- const originalOnClick = action.props.onClick;
2329
- const newOnClick = (e) => {
2330
- originalOnClick == null ? void 0 : originalOnClick(e);
2584
+ if (!actionText) return null;
2585
+ const handleActionClick = (e) => {
2586
+ e.stopPropagation();
2587
+ onAction == null ? void 0 : onAction();
2331
2588
  handleVisibleChange(false);
2332
2589
  };
2333
- return /* @__PURE__ */ jsx("div", { className: "wz-tooltip-bubble__action-slot", children: React.cloneElement(action, { onClick: newOnClick }) });
2590
+ return /* @__PURE__ */ jsx("div", { className: "wz-tooltip-bubble__action-slot", children: /* @__PURE__ */ jsx("span", { className: "wz-tooltip-bubble__action-btn", onClick: handleActionClick, children: actionText }) });
2334
2591
  };
2335
2592
  const renderCloseIcon = () => {
2336
- if (!closeIcon) return null;
2337
- return /* @__PURE__ */ jsx("div", { className: "wz-tooltip-bubble__close-slot", children: React.cloneElement(closeIcon, { onClick: handleClose }) });
2593
+ if (!closable) return null;
2594
+ 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" }) }) });
2338
2595
  };
2339
2596
  return /* @__PURE__ */ jsxs(Fragment, { children: [
2340
2597
  showMask && /* @__PURE__ */ jsx("div", { className: "wz-tooltip-mask", onClick: handleClose }),
@@ -2499,6 +2756,7 @@ const ConfigProvider = ({
2499
2756
  };
2500
2757
  export {
2501
2758
  Button,
2759
+ ButtonGroup,
2502
2760
  Card,
2503
2761
  Cascader,
2504
2762
  Cell,