wz-h5-design 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/README.md +51 -0
  2. package/dist/Button/index.js +84 -0
  3. package/dist/Button/index.umd.cjs +1 -0
  4. package/dist/Button/style/index.css +1 -0
  5. package/dist/Button/style/index.js +1 -0
  6. package/dist/Button/style.css +1 -0
  7. package/dist/Card/index.js +32 -0
  8. package/dist/Card/index.umd.cjs +1 -0
  9. package/dist/Card/style/index.css +1 -0
  10. package/dist/Card/style/index.js +1 -0
  11. package/dist/Card/style.css +1 -0
  12. package/dist/Cascader/index.js +94 -0
  13. package/dist/Cascader/index.umd.cjs +1 -0
  14. package/dist/Cascader/style/index.css +1 -0
  15. package/dist/Cascader/style/index.js +1 -0
  16. package/dist/Cascader/style.css +1 -0
  17. package/dist/Cell/index.js +135 -0
  18. package/dist/Cell/index.umd.cjs +6 -0
  19. package/dist/Cell/style/index.css +1 -0
  20. package/dist/Cell/style/index.js +1 -0
  21. package/dist/Cell/style.css +1 -0
  22. package/dist/CheckList/index.js +34 -0
  23. package/dist/CheckList/index.umd.cjs +1 -0
  24. package/dist/CheckList/style/index.css +1 -0
  25. package/dist/CheckList/style/index.js +1 -0
  26. package/dist/CheckList/style.css +1 -0
  27. package/dist/Checkbox/index.js +84 -0
  28. package/dist/Checkbox/index.umd.cjs +1 -0
  29. package/dist/Checkbox/style/index.css +1 -0
  30. package/dist/Checkbox/style/index.js +1 -0
  31. package/dist/Checkbox/style.css +1 -0
  32. package/dist/Collapse/index.js +72 -0
  33. package/dist/Collapse/index.umd.cjs +1 -0
  34. package/dist/Collapse/style/index.css +1 -0
  35. package/dist/Collapse/style/index.js +1 -0
  36. package/dist/Collapse/style.css +1 -0
  37. package/dist/DatePicker/index.js +154 -0
  38. package/dist/DatePicker/index.umd.cjs +1 -0
  39. package/dist/DatePicker/style/index.css +1 -0
  40. package/dist/DatePicker/style/index.js +1 -0
  41. package/dist/DatePicker/style.css +1 -0
  42. package/dist/DateRangePicker/index.js +220 -0
  43. package/dist/DateRangePicker/index.umd.cjs +1 -0
  44. package/dist/DateRangePicker/style/index.css +1 -0
  45. package/dist/DateRangePicker/style/index.js +1 -0
  46. package/dist/DateRangePicker/style.css +1 -0
  47. package/dist/Dialog/index.js +216 -0
  48. package/dist/Dialog/index.umd.cjs +6 -0
  49. package/dist/Dialog/style/index.css +1 -0
  50. package/dist/Dialog/style/index.js +1 -0
  51. package/dist/Dialog/style.css +1 -0
  52. package/dist/Divider/index.js +27 -0
  53. package/dist/Divider/index.umd.cjs +1 -0
  54. package/dist/Divider/style/index.css +1 -0
  55. package/dist/Divider/style/index.js +1 -0
  56. package/dist/Divider/style.css +1 -0
  57. package/dist/DropDownMenu/index.js +111 -0
  58. package/dist/DropDownMenu/index.umd.cjs +1 -0
  59. package/dist/DropDownMenu/style/index.css +1 -0
  60. package/dist/DropDownMenu/style/index.js +1 -0
  61. package/dist/DropDownMenu/style.css +1 -0
  62. package/dist/Flex/index.js +85 -0
  63. package/dist/Flex/index.umd.cjs +1 -0
  64. package/dist/Flex/style/index.css +1 -0
  65. package/dist/Flex/style/index.js +1 -0
  66. package/dist/Flex/style.css +1 -0
  67. package/dist/Grid/index.js +54 -0
  68. package/dist/Grid/index.umd.cjs +1 -0
  69. package/dist/Grid/style/index.css +1 -0
  70. package/dist/Grid/style/index.js +1 -0
  71. package/dist/Grid/style.css +1 -0
  72. package/dist/GridView/index.js +90 -0
  73. package/dist/GridView/index.umd.cjs +1 -0
  74. package/dist/GridView/style/index.css +1 -0
  75. package/dist/GridView/style/index.js +1 -0
  76. package/dist/GridView/style.css +1 -0
  77. package/dist/Icon/index.js +31 -0
  78. package/dist/Icon/index.umd.cjs +1 -0
  79. package/dist/Icon/style/index.css +1 -0
  80. package/dist/Icon/style/index.js +1 -0
  81. package/dist/Icon/style.css +1 -0
  82. package/dist/Input/index.js +148 -0
  83. package/dist/Input/index.umd.cjs +1 -0
  84. package/dist/Input/style/index.css +1 -0
  85. package/dist/Input/style/index.js +1 -0
  86. package/dist/Input/style.css +1 -0
  87. package/dist/NavBar/index.js +175 -0
  88. package/dist/NavBar/index.umd.cjs +6 -0
  89. package/dist/NavBar/style/index.css +1 -0
  90. package/dist/NavBar/style/index.js +1 -0
  91. package/dist/NavBar/style.css +1 -0
  92. package/dist/Popup/index.js +124 -0
  93. package/dist/Popup/index.umd.cjs +1 -0
  94. package/dist/Popup/style/index.css +1 -0
  95. package/dist/Popup/style/index.js +1 -0
  96. package/dist/Popup/style.css +1 -0
  97. package/dist/Radio/index.js +82 -0
  98. package/dist/Radio/index.umd.cjs +1 -0
  99. package/dist/Radio/style/index.css +1 -0
  100. package/dist/Radio/style/index.js +1 -0
  101. package/dist/Radio/style.css +1 -0
  102. package/dist/Search/index.js +158 -0
  103. package/dist/Search/index.umd.cjs +1 -0
  104. package/dist/Search/style/index.css +1 -0
  105. package/dist/Search/style/index.js +1 -0
  106. package/dist/Search/style.css +1 -0
  107. package/dist/Stepper/index.js +140 -0
  108. package/dist/Stepper/index.umd.cjs +1 -0
  109. package/dist/Stepper/style/index.css +1 -0
  110. package/dist/Stepper/style/index.js +1 -0
  111. package/dist/Stepper/style.css +1 -0
  112. package/dist/Switch/index.js +53 -0
  113. package/dist/Switch/index.umd.cjs +1 -0
  114. package/dist/Switch/style/index.css +1 -0
  115. package/dist/Switch/style/index.js +1 -0
  116. package/dist/Switch/style.css +1 -0
  117. package/dist/Tabbar/index.js +159 -0
  118. package/dist/Tabbar/index.umd.cjs +6 -0
  119. package/dist/Tabbar/style/index.css +1 -0
  120. package/dist/Tabbar/style/index.js +1 -0
  121. package/dist/Tabbar/style.css +1 -0
  122. package/dist/Tabs/index.js +50 -0
  123. package/dist/Tabs/index.umd.cjs +1 -0
  124. package/dist/Tabs/style/index.css +1 -0
  125. package/dist/Tabs/style/index.js +1 -0
  126. package/dist/Tabs/style.css +1 -0
  127. package/dist/Tag/index.js +96 -0
  128. package/dist/Tag/index.umd.cjs +6 -0
  129. package/dist/Tag/style/index.css +1 -0
  130. package/dist/Tag/style/index.js +1 -0
  131. package/dist/Tag/style.css +1 -0
  132. package/dist/TimePicker/index.js +201 -0
  133. package/dist/TimePicker/index.umd.cjs +1 -0
  134. package/dist/TimePicker/style/index.css +1 -0
  135. package/dist/TimePicker/style/index.js +1 -0
  136. package/dist/TimePicker/style.css +1 -0
  137. package/dist/Tip/index.js +104 -0
  138. package/dist/Tip/index.umd.cjs +6 -0
  139. package/dist/Tip/style/index.css +1 -0
  140. package/dist/Tip/style/index.js +1 -0
  141. package/dist/Tip/style.css +1 -0
  142. package/dist/Toast/index.js +183 -0
  143. package/dist/Toast/index.umd.cjs +6 -0
  144. package/dist/Toast/style/index.css +1 -0
  145. package/dist/Toast/style/index.js +1 -0
  146. package/dist/Toast/style.css +1 -0
  147. package/dist/Tooltip/index.js +172 -0
  148. package/dist/Tooltip/index.umd.cjs +6 -0
  149. package/dist/Tooltip/style/index.css +1 -0
  150. package/dist/Tooltip/style/index.js +1 -0
  151. package/dist/Tooltip/style.css +1 -0
  152. package/dist/assets/fonts/qitu/iconfont.css +140 -0
  153. package/dist/assets/fonts/qitu/iconfont.ttf +0 -0
  154. package/dist/assets/fonts/qitu/iconfont.woff +0 -0
  155. package/dist/assets/fonts/qitu/iconfont.woff2 +0 -0
  156. package/dist/assets/fonts/qituyonghu/iconfont.css +64 -0
  157. package/dist/assets/fonts/qituyonghu/iconfont.ttf +0 -0
  158. package/dist/assets/fonts/qituyonghu/iconfont.woff +0 -0
  159. package/dist/assets/fonts/qituyonghu/iconfont.woff2 +0 -0
  160. package/dist/assets/fonts/wzdaili/iconfont.css +71 -0
  161. package/dist/assets/fonts/wzdaili/iconfont.ttf +0 -0
  162. package/dist/assets/fonts/wzdaili/iconfont.woff +0 -0
  163. package/dist/assets/fonts/wzdaili/iconfont.woff2 +0 -0
  164. package/dist/assets/fonts/wzyonghu/iconfont.css +97 -0
  165. package/dist/assets/fonts/wzyonghu/iconfont.ttf +0 -0
  166. package/dist/assets/fonts/wzyonghu/iconfont.woff +0 -0
  167. package/dist/assets/fonts/wzyonghu/iconfont.woff2 +0 -0
  168. package/dist/assets/fonts/yunying/iconfont.css +303 -0
  169. package/dist/assets/fonts/yunying/iconfont.ttf +0 -0
  170. package/dist/assets/fonts/yunying/iconfont.woff +0 -0
  171. package/dist/assets/fonts/yunying/iconfont.woff2 +0 -0
  172. package/dist/style.css +1 -0
  173. package/dist/types/components/Button/Button.d.ts +16 -0
  174. package/dist/types/components/Button/index.d.ts +5 -0
  175. package/dist/types/components/Card/Card.d.ts +15 -0
  176. package/dist/types/components/Card/index.d.ts +3 -0
  177. package/dist/types/components/Cascader/Cascader.d.ts +14 -0
  178. package/dist/types/components/Cascader/index.d.ts +3 -0
  179. package/dist/types/components/Cell/Cell.d.ts +24 -0
  180. package/dist/types/components/Cell/CellGroup.d.ts +8 -0
  181. package/dist/types/components/Cell/index.d.ts +8 -0
  182. package/dist/types/components/CheckList/CheckList.d.ts +11 -0
  183. package/dist/types/components/CheckList/index.d.ts +3 -0
  184. package/dist/types/components/Checkbox/Checkbox.d.ts +62 -0
  185. package/dist/types/components/Checkbox/index.d.ts +3 -0
  186. package/dist/types/components/Collapse/Collapse.d.ts +17 -0
  187. package/dist/types/components/Collapse/index.d.ts +3 -0
  188. package/dist/types/components/DatePicker/DatePicker.d.ts +13 -0
  189. package/dist/types/components/DatePicker/index.d.ts +3 -0
  190. package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +13 -0
  191. package/dist/types/components/DateRangePicker/index.d.ts +3 -0
  192. package/dist/types/components/Dialog/Dialog.d.ts +16 -0
  193. package/dist/types/components/Dialog/imperative.d.ts +8 -0
  194. package/dist/types/components/Dialog/index.d.ts +8 -0
  195. package/dist/types/components/Divider/Divider.d.ts +11 -0
  196. package/dist/types/components/Divider/index.d.ts +3 -0
  197. package/dist/types/components/DropDownMenu/DropdownMenu.d.ts +19 -0
  198. package/dist/types/components/DropDownMenu/index.d.ts +2 -0
  199. package/dist/types/components/Flex/Flex.d.ts +25 -0
  200. package/dist/types/components/Flex/index.d.ts +3 -0
  201. package/dist/types/components/Grid/Grid.d.ts +22 -0
  202. package/dist/types/components/Grid/index.d.ts +3 -0
  203. package/dist/types/components/GridView/GridView.d.ts +59 -0
  204. package/dist/types/components/GridView/index.d.ts +2 -0
  205. package/dist/types/components/Icon/Icon.d.ts +12 -0
  206. package/dist/types/components/Icon/icon-data.d.ts +42 -0
  207. package/dist/types/components/Icon/index.d.ts +3 -0
  208. package/dist/types/components/Input/Input.d.ts +17 -0
  209. package/dist/types/components/Input/index.d.ts +3 -0
  210. package/dist/types/components/NavBar/NavBar.d.ts +20 -0
  211. package/dist/types/components/NavBar/index.d.ts +3 -0
  212. package/dist/types/components/Popup/Popup.d.ts +23 -0
  213. package/dist/types/components/Popup/index.d.ts +3 -0
  214. package/dist/types/components/Radio/Radio.d.ts +62 -0
  215. package/dist/types/components/Radio/index.d.ts +3 -0
  216. package/dist/types/components/Search/Search.d.ts +26 -0
  217. package/dist/types/components/Search/index.d.ts +3 -0
  218. package/dist/types/components/Stepper/Stepper.d.ts +22 -0
  219. package/dist/types/components/Stepper/index.d.ts +3 -0
  220. package/dist/types/components/Switch/Switch.d.ts +16 -0
  221. package/dist/types/components/Switch/index.d.ts +3 -0
  222. package/dist/types/components/Tabbar/Tabbar.d.ts +39 -0
  223. package/dist/types/components/Tabbar/index.d.ts +3 -0
  224. package/dist/types/components/Tabs/Tabs.d.ts +25 -0
  225. package/dist/types/components/Tabs/index.d.ts +3 -0
  226. package/dist/types/components/Tag/Tag.d.ts +39 -0
  227. package/dist/types/components/Tag/index.d.ts +3 -0
  228. package/dist/types/components/TimePicker/TimePicker.d.ts +12 -0
  229. package/dist/types/components/TimePicker/index.d.ts +3 -0
  230. package/dist/types/components/Tip/Tip.d.ts +32 -0
  231. package/dist/types/components/Tip/index.d.ts +3 -0
  232. package/dist/types/components/Toast/Toast.d.ts +11 -0
  233. package/dist/types/components/Toast/index.d.ts +15 -0
  234. package/dist/types/components/Tooltip/Tooltip.d.ts +17 -0
  235. package/dist/types/components/Tooltip/index.d.ts +3 -0
  236. package/dist/types/components/index.d.ts +31 -0
  237. package/dist/types/index.d.ts +7 -0
  238. package/dist/types/utils/color.d.ts +1 -0
  239. package/dist/wz-h5-design.es.js +2449 -0
  240. package/dist/wz-h5-design.umd.js +6 -0
  241. package/package.json +84 -0
@@ -0,0 +1,2449 @@
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";
3
+ import { createRoot } from "react-dom/client";
4
+ const Button = forwardRef(({
5
+ type = "primary",
6
+ size = "medium",
7
+ block = false,
8
+ disabled = false,
9
+ color = "",
10
+ textColor = "",
11
+ borderColor = "",
12
+ className = "",
13
+ style = {},
14
+ children,
15
+ onClick
16
+ }, ref) => {
17
+ const [isActive, setIsActive] = useState(false);
18
+ const timerRef = useRef(null);
19
+ const buttonStyle = useMemo(() => {
20
+ if (type === "cancel") return style;
21
+ if (type === "outline") {
22
+ return {
23
+ color: textColor || "var(--wz-primary-color)",
24
+ borderColor: borderColor || "var(--wz-primary-color)",
25
+ background: "transparent",
26
+ ...style
27
+ };
28
+ }
29
+ if (type === "text") {
30
+ return {
31
+ color: textColor || style.color || "var(--wz-primary-color, #22C94D)",
32
+ background: "transparent",
33
+ border: "none",
34
+ boxShadow: "none",
35
+ ...style
36
+ };
37
+ }
38
+ if (type === "primary") {
39
+ let s = { ...style };
40
+ s.background = color || "var(--wz-primary-gradient, var(--wz-primary-color))";
41
+ s.color = textColor || "#fff";
42
+ return s;
43
+ }
44
+ return style;
45
+ }, [type, color, textColor, borderColor, style]);
46
+ const handleClick = (e) => {
47
+ if (disabled) return;
48
+ setIsActive(true);
49
+ if (timerRef.current) window.clearTimeout(timerRef.current);
50
+ timerRef.current = window.setTimeout(() => setIsActive(false), 100);
51
+ onClick == null ? void 0 : onClick(e);
52
+ };
53
+ const btnClass = [
54
+ "wz-button",
55
+ `wz-button--${type}`,
56
+ `wz-button--${size}`,
57
+ block ? "wz-button--block" : "",
58
+ disabled ? "wz-button--disabled" : "",
59
+ isActive && !disabled ? "wz-button--active" : "",
60
+ className
61
+ ].filter(Boolean).join(" ");
62
+ return /* @__PURE__ */ jsxs(
63
+ "button",
64
+ {
65
+ ref,
66
+ type: "button",
67
+ className: btnClass,
68
+ style: buttonStyle,
69
+ disabled,
70
+ onClick: handleClick,
71
+ children: [
72
+ children,
73
+ type === "primary" && isActive && /* @__PURE__ */ jsx("span", { className: "wz-button__mask" }),
74
+ type === "outline" && isActive && /* @__PURE__ */ jsx("span", { className: "wz-button__mask" }),
75
+ type === "outline" && disabled && /* @__PURE__ */ jsx("span", { className: "wz-button__mask--disabled" }),
76
+ type === "cancel" && isActive && /* @__PURE__ */ jsx("span", { className: "wz-button__mask--cancel" })
77
+ ]
78
+ }
79
+ );
80
+ });
81
+ Button.displayName = "Button";
82
+ const RadioGroupContext = createContext({});
83
+ const Radio = ({
84
+ size,
85
+ checked,
86
+ disabled,
87
+ onChange,
88
+ children,
89
+ value,
90
+ className = "",
91
+ style,
92
+ ...rest
93
+ }) => {
94
+ const groupContext = useContext(RadioGroupContext);
95
+ const isInGroup = !!groupContext.value;
96
+ const handleChange = (e) => {
97
+ var _a;
98
+ if (!disabled && !groupContext.disabled) {
99
+ if (isInGroup) {
100
+ (_a = groupContext.onChange) == null ? void 0 : _a.call(groupContext, value);
101
+ } else {
102
+ onChange == null ? void 0 : onChange(e.target.checked);
103
+ }
104
+ }
105
+ };
106
+ const isChecked = isInGroup ? groupContext.value === value : checked;
107
+ const isDisabled = disabled || groupContext.disabled;
108
+ const radioSize = size || groupContext.size || "medium";
109
+ return /* @__PURE__ */ jsxs(
110
+ "label",
111
+ {
112
+ className: `wz-radio-wrapper ${isDisabled ? "wz-radio--disabled" : ""} wz-radio--${radioSize} ${className}`,
113
+ style,
114
+ children: [
115
+ /* @__PURE__ */ jsx(
116
+ "input",
117
+ {
118
+ type: "radio",
119
+ className: "wz-radio-input",
120
+ checked: isChecked,
121
+ disabled: isDisabled,
122
+ onChange: handleChange,
123
+ value,
124
+ ...rest
125
+ }
126
+ ),
127
+ /* @__PURE__ */ jsx("span", { className: "wz-radio-inner" }),
128
+ children && /* @__PURE__ */ jsx("span", { className: "wz-radio-label", children })
129
+ ]
130
+ }
131
+ );
132
+ };
133
+ const RadioGroup = ({
134
+ value,
135
+ defaultValue,
136
+ onChange,
137
+ disabled,
138
+ size,
139
+ children,
140
+ className = "",
141
+ style
142
+ }) => {
143
+ const [innerValue, setInnerValue] = React.useState(defaultValue);
144
+ const handleChange = (newValue) => {
145
+ setInnerValue(newValue);
146
+ onChange == null ? void 0 : onChange(newValue);
147
+ };
148
+ const contextValue = {
149
+ value: value !== void 0 ? value : innerValue,
150
+ onChange: handleChange,
151
+ disabled,
152
+ size
153
+ };
154
+ return /* @__PURE__ */ jsx(RadioGroupContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { className: `wz-radio-group ${className}`, style, children }) });
155
+ };
156
+ Radio.Group = RadioGroup;
157
+ Radio.displayName = "Radio";
158
+ RadioGroup.displayName = "Radio.Group";
159
+ const CheckboxContext = createContext({});
160
+ const Checkbox = ({
161
+ size,
162
+ checked,
163
+ disabled,
164
+ onChange,
165
+ children,
166
+ value,
167
+ className = "",
168
+ style,
169
+ ...rest
170
+ }) => {
171
+ var _a;
172
+ const groupContext = useContext(CheckboxContext);
173
+ const isInGroup = !!groupContext.value;
174
+ const handleChange = (e) => {
175
+ var _a2;
176
+ if (!disabled && !groupContext.disabled) {
177
+ if (isInGroup) {
178
+ const newValue = e.target.checked ? [...groupContext.value || [], value] : (groupContext.value || []).filter((v) => v !== value);
179
+ (_a2 = groupContext.onChange) == null ? void 0 : _a2.call(groupContext, newValue);
180
+ } else {
181
+ onChange == null ? void 0 : onChange(e.target.checked);
182
+ }
183
+ }
184
+ };
185
+ const isChecked = isInGroup ? (_a = groupContext.value) == null ? void 0 : _a.includes(value) : checked;
186
+ const isDisabled = disabled || groupContext.disabled;
187
+ const checkboxSize = size || groupContext.size || "medium";
188
+ return /* @__PURE__ */ jsxs(
189
+ "label",
190
+ {
191
+ className: `wz-checkbox-wrapper ${isDisabled ? "wz-checkbox--disabled" : ""} wz-checkbox--${checkboxSize} ${className}`,
192
+ style,
193
+ children: [
194
+ /* @__PURE__ */ jsx(
195
+ "input",
196
+ {
197
+ type: "checkbox",
198
+ className: "wz-checkbox-input",
199
+ checked: isChecked,
200
+ disabled: isDisabled,
201
+ onChange: handleChange,
202
+ value,
203
+ ...rest
204
+ }
205
+ ),
206
+ /* @__PURE__ */ jsx("span", { className: "wz-checkbox-inner" }),
207
+ children && /* @__PURE__ */ jsx("span", { className: "wz-checkbox-label", children })
208
+ ]
209
+ }
210
+ );
211
+ };
212
+ const CheckboxGroup = ({
213
+ value,
214
+ defaultValue,
215
+ onChange,
216
+ disabled,
217
+ size,
218
+ children,
219
+ className = "",
220
+ style
221
+ }) => {
222
+ const [innerValue, setInnerValue] = React.useState(defaultValue || []);
223
+ const handleChange = (newValue) => {
224
+ setInnerValue(newValue);
225
+ onChange == null ? void 0 : onChange(newValue);
226
+ };
227
+ const contextValue = {
228
+ value: value !== void 0 ? value : innerValue,
229
+ onChange: handleChange,
230
+ disabled,
231
+ size
232
+ };
233
+ return /* @__PURE__ */ jsx(CheckboxContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { className: `wz-checkbox-group ${className}`, style, children }) });
234
+ };
235
+ Checkbox.Group = CheckboxGroup;
236
+ Checkbox.displayName = "Checkbox";
237
+ CheckboxGroup.displayName = "Checkbox.Group";
238
+ const DEFAULT_ACTIVE_TEXT = "开启";
239
+ const DEFAULT_INACTIVE_TEXT = "关闭";
240
+ const Switch = ({
241
+ value,
242
+ defaultValue = false,
243
+ onChange,
244
+ disabled = false,
245
+ showText = true,
246
+ activeText = "",
247
+ inactiveText = "",
248
+ style,
249
+ className = "",
250
+ size = "default",
251
+ activeColor
252
+ }) => {
253
+ const [innerValue, setInnerValue] = useState(defaultValue);
254
+ const isControlled = value !== void 0;
255
+ const checked = isControlled ? value : innerValue;
256
+ const text = checked ? activeText || DEFAULT_ACTIVE_TEXT : inactiveText || DEFAULT_INACTIVE_TEXT;
257
+ const textWidth = showText ? `${text.length * 12 + 8}px` : "0px";
258
+ const baseWidth = size === "large" ? 62 : 60;
259
+ const switchWidthNum = showText ? text.length * 12 + 40 : baseWidth;
260
+ const switchWidth = `${switchWidthNum}px`;
261
+ const onBg = activeColor ? activeColor.includes("gradient") ? activeColor : activeColor : void 0;
262
+ const handleClick = () => {
263
+ if (disabled) return;
264
+ if (!isControlled) setInnerValue(!checked);
265
+ onChange == null ? void 0 : onChange(!checked);
266
+ };
267
+ const bgStyle = checked ? activeColor ? { background: onBg } : {} : {};
268
+ return /* @__PURE__ */ jsxs(
269
+ "div",
270
+ {
271
+ className: `wz-switch-bg ${checked ? "wz-switch-on" : "wz-switch-off"}${disabled ? " wz-switch-disabled" : ""}${className ? " " + className : ""} wz-switch-${size}`,
272
+ style: { width: switchWidth, minWidth: `${baseWidth}px`, ...style, ...bgStyle },
273
+ onClick: handleClick,
274
+ children: [
275
+ showText && /* @__PURE__ */ jsx("span", { className: "wz-switch-text", style: { width: textWidth }, children: text }),
276
+ /* @__PURE__ */ jsx(
277
+ "div",
278
+ {
279
+ className: `wz-switch-slider ${checked ? "wz-switch-slider-on" : "wz-switch-slider-off"}`
280
+ }
281
+ )
282
+ ]
283
+ }
284
+ );
285
+ };
286
+ function getDefaultExportFromCjs(x) {
287
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
288
+ }
289
+ var classnames = { exports: {} };
290
+ /*!
291
+ Copyright (c) 2018 Jed Watson.
292
+ Licensed under the MIT License (MIT), see
293
+ http://jedwatson.github.io/classnames
294
+ */
295
+ (function(module) {
296
+ (function() {
297
+ var hasOwn = {}.hasOwnProperty;
298
+ function classNames2() {
299
+ var classes = [];
300
+ for (var i = 0; i < arguments.length; i++) {
301
+ var arg = arguments[i];
302
+ if (!arg) continue;
303
+ var argType = typeof arg;
304
+ if (argType === "string" || argType === "number") {
305
+ classes.push(arg);
306
+ } else if (Array.isArray(arg)) {
307
+ if (arg.length) {
308
+ var inner = classNames2.apply(null, arg);
309
+ if (inner) {
310
+ classes.push(inner);
311
+ }
312
+ }
313
+ } else if (argType === "object") {
314
+ if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
315
+ classes.push(arg.toString());
316
+ continue;
317
+ }
318
+ for (var key in arg) {
319
+ if (hasOwn.call(arg, key) && arg[key]) {
320
+ classes.push(key);
321
+ }
322
+ }
323
+ }
324
+ }
325
+ return classes.join(" ");
326
+ }
327
+ if (module.exports) {
328
+ classNames2.default = classNames2;
329
+ module.exports = classNames2;
330
+ } else {
331
+ window.classNames = classNames2;
332
+ }
333
+ })();
334
+ })(classnames);
335
+ var classnamesExports = classnames.exports;
336
+ const classNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
337
+ const Icon = ({
338
+ name,
339
+ size = 24,
340
+ color = "currentColor",
341
+ className = "",
342
+ style,
343
+ onClick,
344
+ type = "yunying"
345
+ // 默认使用yunying图标库
346
+ }) => {
347
+ const iconStyle = {
348
+ fontSize: typeof size === "number" ? `${size}px` : size,
349
+ color,
350
+ ...style
351
+ };
352
+ const iconFontClass = `iconfont-${type}`;
353
+ const iconPrefix = "icon-";
354
+ const iconClass = `${iconPrefix}${name}`;
355
+ return /* @__PURE__ */ jsx(
356
+ "i",
357
+ {
358
+ className: `wz-icon ${iconFontClass} ${iconClass} ${className}`,
359
+ style: iconStyle,
360
+ onClick
361
+ }
362
+ );
363
+ };
364
+ const TabbarItem = (props) => {
365
+ const { title, icon, activeIcon, badge, badgeAsBubble, hump, active, onItemClick, onClick, activeColor } = props;
366
+ const renderIcon = (iconSource) => {
367
+ if (typeof iconSource === "string") {
368
+ return /* @__PURE__ */ jsx(Icon, { name: iconSource });
369
+ }
370
+ return iconSource;
371
+ };
372
+ const renderBadge = () => {
373
+ if (!badge) return null;
374
+ if (badgeAsBubble) {
375
+ return /* @__PURE__ */ jsx("div", { className: "wz-tabbar-item-badge-custom", children: /* @__PURE__ */ jsxs("div", { className: "wz-tabbar-item-badge-bubble", children: [
376
+ badge,
377
+ /* @__PURE__ */ jsx("div", { className: "wz-tabbar-item-badge-bubble-arrow" })
378
+ ] }) });
379
+ }
380
+ if (React.isValidElement(badge)) {
381
+ return /* @__PURE__ */ jsx("div", { className: "wz-tabbar-item-badge-custom", children: badge });
382
+ }
383
+ return /* @__PURE__ */ jsx("div", { className: "wz-tabbar-item-badge", children: badge });
384
+ };
385
+ const itemCls = classNames("wz-tabbar-item", {
386
+ "wz-tabbar-item-active": !hump && active,
387
+ "wz-tabbar-item-hump": hump
388
+ });
389
+ const itemStyle = useMemo(() => {
390
+ const style = {};
391
+ if (active && activeColor) {
392
+ style.color = activeColor;
393
+ }
394
+ return style;
395
+ }, [active, activeColor]);
396
+ return /* @__PURE__ */ jsxs("div", { className: itemCls, style: itemStyle, onClick: hump ? onClick : onItemClick, children: [
397
+ /* @__PURE__ */ jsxs("div", { className: "wz-tabbar-item-icon", children: [
398
+ active ? renderIcon(activeIcon || icon) : renderIcon(icon),
399
+ renderBadge()
400
+ ] }),
401
+ /* @__PURE__ */ jsx("div", { className: "wz-tabbar-item-title", children: title })
402
+ ] });
403
+ };
404
+ const Tabbar = (props) => {
405
+ var _a;
406
+ const {
407
+ activeKey,
408
+ defaultActiveKey,
409
+ onChange,
410
+ items,
411
+ fixed = true,
412
+ className,
413
+ style
414
+ } = props;
415
+ const [currentKey, setCurrentKey] = React.useState(
416
+ activeKey ?? defaultActiveKey ?? ((_a = items == null ? void 0 : items[0]) == null ? void 0 : _a.key)
417
+ );
418
+ React.useEffect(() => {
419
+ if (activeKey !== void 0) {
420
+ setCurrentKey(activeKey);
421
+ }
422
+ }, [activeKey]);
423
+ const handleItemClick = (key) => {
424
+ if (activeKey === void 0) {
425
+ setCurrentKey(key);
426
+ }
427
+ onChange == null ? void 0 : onChange(key);
428
+ };
429
+ const containerCls = classNames("wz-tabbar", { "wz-tabbar-fixed": fixed }, className);
430
+ return /* @__PURE__ */ jsx("div", { className: containerCls, style, children: items.map((item) => /* @__PURE__ */ createElement(
431
+ TabbarItem,
432
+ {
433
+ ...item,
434
+ key: item.key,
435
+ active: !item.hump && currentKey === item.key,
436
+ onItemClick: () => handleItemClick(item.key)
437
+ }
438
+ )) });
439
+ };
440
+ const Card = ({
441
+ title,
442
+ extra,
443
+ cover,
444
+ actions,
445
+ bordered,
446
+ noDivider = false,
447
+ className = "",
448
+ style,
449
+ children,
450
+ onClick
451
+ }) => {
452
+ const cardClassName = [
453
+ "wz-card",
454
+ bordered !== void 0 ? "wz-card-bordered" : "",
455
+ noDivider ? "wz-card-no-divider" : "",
456
+ className
457
+ ].filter(Boolean).join(" ");
458
+ return /* @__PURE__ */ jsxs("div", { className: cardClassName, style, onClick, children: [
459
+ cover && /* @__PURE__ */ jsx("div", { className: "wz-card-cover", children: cover }),
460
+ (title || extra) && /* @__PURE__ */ jsxs("div", { className: "wz-card-header", children: [
461
+ title && /* @__PURE__ */ jsx("div", { className: "wz-card-title", children: title }),
462
+ extra && /* @__PURE__ */ jsx("div", { className: "wz-card-extra", children: extra })
463
+ ] }),
464
+ /* @__PURE__ */ jsx("div", { className: "wz-card-body", children }),
465
+ actions && actions.length > 0 && /* @__PURE__ */ jsx("div", { className: "wz-card-actions", children: actions.map((action, index) => /* @__PURE__ */ jsx("div", { className: "wz-card-action", children: action }, index)) })
466
+ ] });
467
+ };
468
+ const Cell$1 = (props) => {
469
+ const {
470
+ title,
471
+ label,
472
+ value,
473
+ icon,
474
+ arrow = false,
475
+ border = true,
476
+ center = false,
477
+ disabled = false,
478
+ required = false,
479
+ className,
480
+ style,
481
+ titleStyle,
482
+ titleClassName,
483
+ labelStyle,
484
+ labelClassName,
485
+ valueStyle,
486
+ valueClassName,
487
+ onClick,
488
+ children
489
+ } = props;
490
+ const cellClassName = classNames(
491
+ "wz-cell",
492
+ {
493
+ "wz-cell-border": border,
494
+ "wz-cell-center": center,
495
+ "wz-cell-disabled": disabled
496
+ },
497
+ className
498
+ );
499
+ const renderTitle = () => {
500
+ if (title) {
501
+ return /* @__PURE__ */ jsxs("div", { className: classNames("wz-cell-title", titleClassName), style: titleStyle, children: [
502
+ required && /* @__PURE__ */ jsx("span", { className: "wz-cell-required", children: "*" }),
503
+ title,
504
+ value && /* @__PURE__ */ jsx("span", { className: classNames("wz-cell-value", valueClassName), style: valueStyle, children: value })
505
+ ] });
506
+ }
507
+ return null;
508
+ };
509
+ const renderValue = () => {
510
+ return null;
511
+ };
512
+ const renderLabel = () => {
513
+ if (label) {
514
+ return /* @__PURE__ */ jsx("div", { className: classNames("wz-cell-label", labelClassName), style: labelStyle, children: label });
515
+ }
516
+ return null;
517
+ };
518
+ const renderLeftIcon = () => {
519
+ if (icon) {
520
+ return /* @__PURE__ */ jsx("div", { className: "wz-cell-icon", children: icon });
521
+ }
522
+ return null;
523
+ };
524
+ const renderRightIcon = () => {
525
+ if (arrow) {
526
+ return /* @__PURE__ */ jsx("div", { className: "wz-cell-arrow" });
527
+ }
528
+ return null;
529
+ };
530
+ return /* @__PURE__ */ jsxs("div", { className: cellClassName, style, onClick: disabled ? void 0 : onClick, children: [
531
+ renderLeftIcon(),
532
+ /* @__PURE__ */ jsxs("div", { className: "wz-cell-content", children: [
533
+ renderTitle(),
534
+ renderLabel()
535
+ ] }),
536
+ renderValue(),
537
+ children && /* @__PURE__ */ jsx("div", { className: "wz-cell-extra", children }),
538
+ renderRightIcon()
539
+ ] });
540
+ };
541
+ const CellGroup = (props) => {
542
+ const { className, style, children } = props;
543
+ return /* @__PURE__ */ jsx("div", { className: classNames("wz-cell-group", className), style, children });
544
+ };
545
+ const Cell = Cell$1;
546
+ Cell.Group = CellGroup;
547
+ const TabPane = ({ children }) => {
548
+ return /* @__PURE__ */ jsx(Fragment, { children });
549
+ };
550
+ const Tabs = ({
551
+ type = "line",
552
+ value,
553
+ defaultValue = 0,
554
+ onChange,
555
+ className = "",
556
+ style,
557
+ headerClassName = "",
558
+ headerStyle,
559
+ contentClassName = "",
560
+ contentStyle,
561
+ children
562
+ }) => {
563
+ const isControlled = value !== void 0;
564
+ const [innerValue, setInnerValue] = useState(defaultValue);
565
+ const activeIndex = isControlled ? value : innerValue;
566
+ const panes = Children.toArray(children).filter(Boolean);
567
+ const handleTabClick = (idx, disabled) => {
568
+ if (disabled) return;
569
+ if (!isControlled) setInnerValue(idx);
570
+ onChange == null ? void 0 : onChange(idx);
571
+ };
572
+ return /* @__PURE__ */ jsxs("div", { className: `wz-tabs wz-tabs-${type} ${className}`, style, children: [
573
+ /* @__PURE__ */ jsx("div", { className: `wz-tabs-header ${headerClassName}`, style: headerStyle, children: panes.map((pane, idx) => /* @__PURE__ */ jsxs(
574
+ "div",
575
+ {
576
+ className: `wz-tabs-tab${idx === activeIndex ? " wz-tabs-tab-active" : ""}${pane.props.disabled ? " wz-tabs-tab-disabled" : ""}`,
577
+ onClick: () => handleTabClick(idx, pane.props.disabled),
578
+ children: [
579
+ /* @__PURE__ */ jsxs("div", { className: "wz-tabs-tab-text", children: [
580
+ pane.props.title,
581
+ pane.props.badge && /* @__PURE__ */ jsx("div", { className: "wz-tabs-badge", children: pane.props.badge })
582
+ ] }),
583
+ idx === activeIndex && type === "line" && /* @__PURE__ */ jsx("div", { className: "wz-tabs-underline" })
584
+ ]
585
+ },
586
+ idx
587
+ )) }),
588
+ /* @__PURE__ */ jsx("div", { className: `wz-tabs-content ${contentClassName}`, style: contentStyle, children: panes[activeIndex] })
589
+ ] });
590
+ };
591
+ Tabs.TabPane = TabPane;
592
+ const Collapse = ({
593
+ title,
594
+ extra,
595
+ children,
596
+ defaultExpanded = false,
597
+ expanded,
598
+ onChange,
599
+ style,
600
+ className = "",
601
+ headerStyle,
602
+ headerClassName = "",
603
+ contentStyle,
604
+ contentClassName = ""
605
+ }) => {
606
+ const [innerExpanded, setInnerExpanded] = useState(defaultExpanded);
607
+ const isControlled = expanded !== void 0;
608
+ const isExpanded = isControlled ? expanded : innerExpanded;
609
+ const handleToggle = () => {
610
+ if (!isControlled) {
611
+ setInnerExpanded(!isExpanded);
612
+ }
613
+ onChange == null ? void 0 : onChange(!isExpanded);
614
+ };
615
+ return /* @__PURE__ */ jsxs("div", { className: `wz-collapse${className ? " " + className : ""}`, style, children: [
616
+ /* @__PURE__ */ jsxs(
617
+ "div",
618
+ {
619
+ className: `wz-collapse-header ${headerClassName}`,
620
+ onClick: handleToggle,
621
+ style: headerStyle,
622
+ children: [
623
+ /* @__PURE__ */ jsx("div", { className: "wz-collapse-title", children: title }),
624
+ /* @__PURE__ */ jsx("div", { className: "wz-collapse-extra", onClick: (e) => e.stopPropagation(), children: extra }),
625
+ /* @__PURE__ */ jsx(
626
+ "svg",
627
+ {
628
+ className: `wz-collapse-arrow${isExpanded ? " expanded" : ""}`,
629
+ width: "20",
630
+ height: "20",
631
+ viewBox: "0 0 20 20",
632
+ style: { transition: "transform 0.2s", transform: isExpanded ? "rotate(90deg)" : "rotate(0deg)" },
633
+ children: /* @__PURE__ */ jsx(
634
+ "polyline",
635
+ {
636
+ points: "7,5 13,10 7,15",
637
+ fill: "none",
638
+ stroke: "#888",
639
+ strokeWidth: "2",
640
+ strokeLinecap: "round",
641
+ strokeLinejoin: "round"
642
+ }
643
+ )
644
+ }
645
+ )
646
+ ]
647
+ }
648
+ ),
649
+ /* @__PURE__ */ jsx(
650
+ "div",
651
+ {
652
+ className: `wz-collapse-content${isExpanded ? " expanded" : ""} ${contentClassName}`,
653
+ style: contentStyle,
654
+ children
655
+ }
656
+ )
657
+ ] });
658
+ };
659
+ const Stepper = ({
660
+ value,
661
+ min = -Infinity,
662
+ max = Infinity,
663
+ step = 1,
664
+ onChange,
665
+ disabled = false,
666
+ prefix,
667
+ suffix,
668
+ showMinus = true,
669
+ // 默认显示减号按钮
670
+ showPlus = true,
671
+ // 默认显示加号按钮
672
+ precision,
673
+ className = "",
674
+ style,
675
+ inputStyle,
676
+ inputClassName = "",
677
+ buttonStyle,
678
+ buttonClassName = ""
679
+ }) => {
680
+ const [inputValue, setInputValue] = useState(String(value));
681
+ const [isFocused, setIsFocused] = useState(false);
682
+ useEffect(() => {
683
+ if (!isFocused) {
684
+ setInputValue(String(value));
685
+ }
686
+ }, [value, isFocused]);
687
+ const handleAdd = () => {
688
+ if (disabled) return;
689
+ let num = Number(value) + step;
690
+ if (num > max) num = max;
691
+ num = precision !== void 0 ? parseFloat(num.toFixed(precision)) : num;
692
+ onChange(num);
693
+ setInputValue(String(num));
694
+ };
695
+ const handleMinus = () => {
696
+ if (disabled) return;
697
+ let num = Number(value) - step;
698
+ if (num < min) num = min;
699
+ num = precision !== void 0 ? parseFloat(num.toFixed(precision)) : num;
700
+ onChange(num);
701
+ setInputValue(String(num));
702
+ };
703
+ const handleInputFocus = (e) => {
704
+ setIsFocused(true);
705
+ e.target.select();
706
+ };
707
+ const handleInputChange = (e) => {
708
+ setInputValue(e.target.value);
709
+ };
710
+ const handleInputBlur = () => {
711
+ setIsFocused(false);
712
+ let num = Number(inputValue);
713
+ if (isNaN(num)) {
714
+ setInputValue(String(value));
715
+ return;
716
+ }
717
+ if (num > max) num = max;
718
+ if (num < min) num = min;
719
+ num = precision !== void 0 ? parseFloat(num.toFixed(precision)) : num;
720
+ onChange(num);
721
+ setInputValue(String(num));
722
+ };
723
+ const minusDisabled = disabled || Number(value) <= min;
724
+ const addDisabled = disabled || Number(value) >= max;
725
+ return /* @__PURE__ */ jsxs("div", { className: `wz-stepper ${className}`, style, children: [
726
+ showMinus && /* @__PURE__ */ jsx(
727
+ "button",
728
+ {
729
+ className: `wz-stepper-btn wz-stepper-btn-minus ${buttonClassName}`,
730
+ onClick: handleMinus,
731
+ disabled: minusDisabled,
732
+ type: "button",
733
+ style: buttonStyle,
734
+ children: /* @__PURE__ */ jsx(Icon, { name: "jian", type: "yunying", size: 21 })
735
+ }
736
+ ),
737
+ /* @__PURE__ */ jsxs("div", { className: "wz-stepper-input-wrapper", children: [
738
+ prefix && /* @__PURE__ */ jsx("span", { className: "wz-stepper-prefix", children: prefix }),
739
+ /* @__PURE__ */ jsx(
740
+ "input",
741
+ {
742
+ className: `wz-stepper-input ${inputClassName}`,
743
+ type: "text",
744
+ value: inputValue,
745
+ onChange: handleInputChange,
746
+ onFocus: handleInputFocus,
747
+ onBlur: handleInputBlur,
748
+ disabled,
749
+ style: inputStyle
750
+ }
751
+ ),
752
+ suffix && /* @__PURE__ */ jsx("span", { className: "wz-stepper-suffix", children: suffix })
753
+ ] }),
754
+ showPlus && /* @__PURE__ */ jsx(
755
+ "button",
756
+ {
757
+ className: `wz-stepper-btn wz-stepper-btn-plus ${buttonClassName}`,
758
+ onClick: handleAdd,
759
+ disabled: addDisabled,
760
+ type: "button",
761
+ style: buttonStyle,
762
+ children: /* @__PURE__ */ jsx(Icon, { name: "jia", type: "yunying", size: 21 })
763
+ }
764
+ )
765
+ ] });
766
+ };
767
+ const Popup = ({
768
+ visible = false,
769
+ position = "bottom",
770
+ mask = true,
771
+ maskClosable = true,
772
+ round = false,
773
+ duration = 300,
774
+ zIndex = 1e3,
775
+ destroyOnClose = false,
776
+ className = "",
777
+ style = {},
778
+ maskStyle = {},
779
+ children,
780
+ onClose,
781
+ onClosed,
782
+ afterShow,
783
+ closeable = false,
784
+ title
785
+ }) => {
786
+ const [display, setDisplay] = useState(visible);
787
+ const [animating, setAnimating] = useState(false);
788
+ const [active, setActive] = useState(visible);
789
+ useEffect(() => {
790
+ if (visible) {
791
+ open();
792
+ } else {
793
+ close();
794
+ }
795
+ }, [visible]);
796
+ const open = () => {
797
+ if (display) return;
798
+ setDisplay(true);
799
+ setAnimating(true);
800
+ requestAnimationFrame(() => {
801
+ requestAnimationFrame(() => {
802
+ setActive(true);
803
+ setTimeout(() => {
804
+ setAnimating(false);
805
+ afterShow == null ? void 0 : afterShow();
806
+ }, duration);
807
+ });
808
+ });
809
+ };
810
+ const close = () => {
811
+ if (!display) return;
812
+ setActive(false);
813
+ setAnimating(true);
814
+ setTimeout(() => {
815
+ setAnimating(false);
816
+ setDisplay(false);
817
+ onClosed == null ? void 0 : onClosed();
818
+ }, duration);
819
+ };
820
+ const handleMaskClick = () => {
821
+ if (maskClosable && !animating) {
822
+ onClose == null ? void 0 : onClose();
823
+ }
824
+ };
825
+ const handleCloseClick = () => {
826
+ if (!animating) {
827
+ onClose == null ? void 0 : onClose();
828
+ }
829
+ };
830
+ const popupStyle = {
831
+ ...style,
832
+ zIndex,
833
+ transitionDuration: `${duration}ms`
834
+ };
835
+ const maskBaseStyle = {
836
+ ...maskStyle,
837
+ zIndex,
838
+ transitionDuration: `${duration}ms`
839
+ };
840
+ if (!display && destroyOnClose) {
841
+ return null;
842
+ }
843
+ return /* @__PURE__ */ jsxs(
844
+ "div",
845
+ {
846
+ className: `wz-popup-container ${display ? "wz-popup--display" : ""}`,
847
+ style: { zIndex },
848
+ children: [
849
+ mask && /* @__PURE__ */ jsx(
850
+ "div",
851
+ {
852
+ className: `wz-popup-mask ${active ? "wz-popup-mask--active" : ""}`,
853
+ style: maskBaseStyle,
854
+ onClick: handleMaskClick
855
+ }
856
+ ),
857
+ /* @__PURE__ */ jsxs(
858
+ "div",
859
+ {
860
+ className: `
861
+ wz-popup
862
+ wz-popup--${position}
863
+ ${active ? "wz-popup--active" : ""}
864
+ ${round ? "wz-popup--round" : ""}
865
+ ${className}
866
+ `,
867
+ style: popupStyle,
868
+ children: [
869
+ closeable && /* @__PURE__ */ jsx(
870
+ "div",
871
+ {
872
+ className: "wz-popup-close",
873
+ onClick: handleCloseClick,
874
+ children: /* @__PURE__ */ jsx("span", { className: "wz-popup-close-icon", children: "×" })
875
+ }
876
+ ),
877
+ title && /* @__PURE__ */ jsx("div", { className: "wz-popup-title", children: title }),
878
+ children
879
+ ]
880
+ }
881
+ )
882
+ ]
883
+ }
884
+ );
885
+ };
886
+ const Cascader = ({
887
+ value,
888
+ onChange,
889
+ data
890
+ }) => {
891
+ const [selectedValues, setSelectedValues] = useState(value || []);
892
+ const [activeLevel, setActiveLevel] = useState(Math.min((value || []).length, 2));
893
+ useEffect(() => {
894
+ if (value !== void 0) {
895
+ setSelectedValues(value);
896
+ setActiveLevel(Math.min(value.length, 2));
897
+ }
898
+ }, [value]);
899
+ const currentLevelData = useMemo(() => {
900
+ if (activeLevel === 0) {
901
+ return data;
902
+ }
903
+ let currentData = data;
904
+ for (let i = 0; i < activeLevel; i++) {
905
+ const selectedItem = currentData.find((item) => item.value === selectedValues[i]);
906
+ currentData = (selectedItem == null ? void 0 : selectedItem.children) || [];
907
+ }
908
+ return currentData;
909
+ }, [data, activeLevel, selectedValues]);
910
+ const selectedLabels = useMemo(() => {
911
+ let currentData = data;
912
+ const defaultLabels = ["请选择", "请选择", "请选择"];
913
+ return selectedValues.map((value2, index) => {
914
+ const selectedItem = currentData.find((item) => item.value === value2);
915
+ currentData = (selectedItem == null ? void 0 : selectedItem.children) || [];
916
+ return (selectedItem == null ? void 0 : selectedItem.label) || defaultLabels[index];
917
+ });
918
+ }, [data, selectedValues]);
919
+ const handleSelect = (item) => {
920
+ if (item.disabled) return;
921
+ const newSelectedValues = [...selectedValues];
922
+ newSelectedValues[activeLevel] = item.value;
923
+ newSelectedValues.length = activeLevel + 1;
924
+ setSelectedValues(newSelectedValues);
925
+ if (activeLevel === 0 && item.children) {
926
+ setActiveLevel(1);
927
+ } else if (activeLevel === 1 && item.children) {
928
+ setActiveLevel(2);
929
+ } else if (activeLevel === 2) {
930
+ onChange == null ? void 0 : onChange(newSelectedValues);
931
+ }
932
+ };
933
+ const handleLevelChange = (level) => {
934
+ if (level <= selectedValues.length) {
935
+ setActiveLevel(level);
936
+ }
937
+ };
938
+ return /* @__PURE__ */ jsxs("div", { className: "wz-cascader", children: [
939
+ /* @__PURE__ */ jsx("div", { className: "wz-cascader-levels", children: ["省", "市", "区"].map((label, index) => {
940
+ if (index > 0 && selectedValues.length < index) {
941
+ return null;
942
+ }
943
+ return /* @__PURE__ */ jsx(
944
+ "div",
945
+ {
946
+ className: `
947
+ wz-cascader-level
948
+ ${activeLevel === index ? "active" : ""}
949
+ ${selectedValues[index] ? "selected" : ""}
950
+ `,
951
+ onClick: () => handleLevelChange(index),
952
+ children: selectedValues[index] ? selectedLabels[index] : "请选择"
953
+ },
954
+ label
955
+ );
956
+ }) }),
957
+ /* @__PURE__ */ jsx("div", { className: "wz-cascader-content", children: /* @__PURE__ */ jsx("div", { className: "wz-cascader-options", children: currentLevelData.map((item) => /* @__PURE__ */ jsxs(
958
+ "div",
959
+ {
960
+ className: `
961
+ wz-cascader-option
962
+ ${selectedValues.includes(item.value) ? "selected" : ""}
963
+ ${item.disabled ? "disabled" : ""}
964
+ `,
965
+ onClick: () => handleSelect(item),
966
+ children: [
967
+ item.label,
968
+ item.disabled && /* @__PURE__ */ jsx("span", { className: "wz-cascader-option-tip", children: "不可选" })
969
+ ]
970
+ },
971
+ item.value
972
+ )) }) })
973
+ ] });
974
+ };
975
+ const Input = forwardRef(
976
+ ({
977
+ clearable = false,
978
+ align = "center",
979
+ value,
980
+ defaultValue,
981
+ onChange,
982
+ style,
983
+ className = "",
984
+ type = "text",
985
+ showCount = false,
986
+ rows = 3,
987
+ maxLength,
988
+ countStyle,
989
+ suffix,
990
+ borderRadius,
991
+ backgroundColor,
992
+ bordered,
993
+ ...props
994
+ }, ref) => {
995
+ const isControlled = value !== void 0;
996
+ const [innerValue, setInnerValue] = useState(defaultValue || "");
997
+ const showClear = clearable && !!(isControlled ? value : innerValue);
998
+ const [passwordVisible, setPasswordVisible] = useState(false);
999
+ const handleChange = (e) => {
1000
+ if (!isControlled) setInnerValue(e.target.value);
1001
+ onChange == null ? void 0 : onChange(e);
1002
+ };
1003
+ const handleClear = () => {
1004
+ if (!isControlled) setInnerValue("");
1005
+ const event = {
1006
+ ...props,
1007
+ target: { value: "" }
1008
+ };
1009
+ onChange == null ? void 0 : onChange(event);
1010
+ };
1011
+ const handlePasswordVisible = () => {
1012
+ setPasswordVisible(!passwordVisible);
1013
+ };
1014
+ const wrapperStyle = {
1015
+ position: "relative",
1016
+ width: style == null ? void 0 : style.width,
1017
+ ...style
1018
+ };
1019
+ const inputStyle = {
1020
+ textAlign: align,
1021
+ borderRadius,
1022
+ backgroundColor,
1023
+ border: bordered !== void 0 ? void 0 : "none"
1024
+ };
1025
+ const currentValue = isControlled ? value : innerValue;
1026
+ const count = (currentValue == null ? void 0 : currentValue.toString().length) || 0;
1027
+ const isExceeded = maxLength && count > maxLength;
1028
+ const renderInput = () => {
1029
+ if (type === "textarea") {
1030
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1031
+ /* @__PURE__ */ jsx(
1032
+ "textarea",
1033
+ {
1034
+ ref,
1035
+ className: `wz-input ${className}`,
1036
+ value: currentValue,
1037
+ onChange: handleChange,
1038
+ style: { ...inputStyle, resize: "none" },
1039
+ rows,
1040
+ maxLength,
1041
+ ...props
1042
+ }
1043
+ ),
1044
+ showCount && maxLength && /* @__PURE__ */ jsxs(
1045
+ "div",
1046
+ {
1047
+ className: `wz-input-count ${isExceeded ? "wz-input-count-exceeded" : ""}`,
1048
+ style: countStyle,
1049
+ children: [
1050
+ count,
1051
+ "/",
1052
+ maxLength
1053
+ ]
1054
+ }
1055
+ )
1056
+ ] });
1057
+ }
1058
+ return /* @__PURE__ */ jsx(
1059
+ "input",
1060
+ {
1061
+ ref,
1062
+ className: `wz-input ${className}`,
1063
+ value: currentValue,
1064
+ onChange: handleChange,
1065
+ style: inputStyle,
1066
+ type: type === "password" && passwordVisible ? "text" : type,
1067
+ maxLength,
1068
+ ...props
1069
+ }
1070
+ );
1071
+ };
1072
+ return /* @__PURE__ */ jsxs(
1073
+ "div",
1074
+ {
1075
+ className: `wz-input-affix-wrapper ${type === "textarea" ? "wz-input-affix-wrapper-textarea" : ""} ${suffix ? "wz-input-has-suffix" : ""} ${bordered === void 0 ? "wz-input-no-border" : ""}`,
1076
+ style: wrapperStyle,
1077
+ children: [
1078
+ renderInput(),
1079
+ showClear && !props.disabled && type !== "textarea" && !suffix && /* @__PURE__ */ jsx("span", { className: "wz-input-clear", onClick: handleClear, children: /* @__PURE__ */ jsx(Icon, { name: "close", size: 22 }) }),
1080
+ type === "password" && !suffix && /* @__PURE__ */ jsx("span", { className: "wz-input-password", onClick: handlePasswordVisible, children: /* @__PURE__ */ jsx(Icon, { name: passwordVisible ? "eyes-close" : "eyes-open", size: 22 }) }),
1081
+ suffix && /* @__PURE__ */ jsxs("div", { className: "wz-input-suffix", children: [
1082
+ /* @__PURE__ */ jsx("span", { className: "wz-input-suffix-divider" }),
1083
+ suffix
1084
+ ] })
1085
+ ]
1086
+ }
1087
+ );
1088
+ }
1089
+ );
1090
+ Input.displayName = "Input";
1091
+ const Divider = ({
1092
+ direction = "horizontal",
1093
+ color = "#eee",
1094
+ length,
1095
+ margin,
1096
+ style,
1097
+ className = ""
1098
+ }) => {
1099
+ const isVertical = direction === "vertical";
1100
+ return /* @__PURE__ */ jsx(
1101
+ "div",
1102
+ {
1103
+ className: `wz-divider wz-divider--${direction} ${className}`,
1104
+ style: {
1105
+ background: color,
1106
+ width: isVertical ? 1 : length || "100%",
1107
+ height: isVertical ? length || 24 : 1,
1108
+ margin,
1109
+ ...style
1110
+ }
1111
+ }
1112
+ );
1113
+ };
1114
+ const CheckList = ({ options, value, onChange, multiple = false, style, className = "" }) => {
1115
+ const isChecked = (item) => {
1116
+ if (multiple && Array.isArray(value)) return value.includes(item);
1117
+ return value === item;
1118
+ };
1119
+ const handleClick = (item) => {
1120
+ if (multiple) {
1121
+ if (!Array.isArray(value)) return;
1122
+ if (value.includes(item)) {
1123
+ onChange(value.filter((v) => v !== item));
1124
+ } else {
1125
+ onChange([...value, item]);
1126
+ }
1127
+ } else {
1128
+ onChange(item);
1129
+ }
1130
+ };
1131
+ return /* @__PURE__ */ jsx("div", { className: `wz-check-list ${className}`, style, children: options.map((item) => /* @__PURE__ */ jsxs(
1132
+ "div",
1133
+ {
1134
+ className: "wz-check-list__item" + (isChecked(item) ? " wz-check-list__item--active" : ""),
1135
+ onClick: () => handleClick(item),
1136
+ children: [
1137
+ /* @__PURE__ */ jsx("span", { className: "wz-check-list__label", children: item }),
1138
+ isChecked(item) && /* @__PURE__ */ jsx("span", { className: "wz-check-list__icon", children: "✔" })
1139
+ ]
1140
+ },
1141
+ item
1142
+ )) });
1143
+ };
1144
+ const Search = forwardRef(
1145
+ ({
1146
+ value,
1147
+ defaultValue,
1148
+ placeholder = "输入关键词搜索",
1149
+ shape = "round",
1150
+ clearable = true,
1151
+ disabled = false,
1152
+ prefix,
1153
+ suffix,
1154
+ leftIcon = /* @__PURE__ */ jsx(Icon, { name: "search", size: 16 }),
1155
+ actionText = "搜索",
1156
+ showCancel = false,
1157
+ cancelText = "返回",
1158
+ background,
1159
+ style,
1160
+ className = "",
1161
+ onSearch,
1162
+ onClear,
1163
+ onChange,
1164
+ onFocus,
1165
+ onBlur,
1166
+ onCancel,
1167
+ ...props
1168
+ }, ref) => {
1169
+ const isControlled = value !== void 0;
1170
+ const [innerValue, setInnerValue] = useState(defaultValue || "");
1171
+ const [isFocused, setIsFocused] = useState(false);
1172
+ const inputRef = useRef(null);
1173
+ useImperativeHandle(ref, () => inputRef.current);
1174
+ const inputValue = isControlled ? value : innerValue;
1175
+ const showClear = clearable && inputValue && isFocused && !disabled;
1176
+ const handleChange = (e) => {
1177
+ const newValue = e.target.value;
1178
+ if (!isControlled) setInnerValue(newValue);
1179
+ onChange == null ? void 0 : onChange(newValue);
1180
+ };
1181
+ const handleFocus = (e) => {
1182
+ setIsFocused(true);
1183
+ onFocus == null ? void 0 : onFocus(e);
1184
+ };
1185
+ const handleBlur = (e) => {
1186
+ setIsFocused(false);
1187
+ onBlur == null ? void 0 : onBlur(e);
1188
+ };
1189
+ const handleSearch = () => {
1190
+ var _a;
1191
+ if (disabled) return;
1192
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
1193
+ onSearch == null ? void 0 : onSearch(inputValue);
1194
+ };
1195
+ const handleClear = (e) => {
1196
+ var _a;
1197
+ e.preventDefault();
1198
+ if (!isControlled) setInnerValue("");
1199
+ onChange == null ? void 0 : onChange("");
1200
+ onClear == null ? void 0 : onClear();
1201
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
1202
+ };
1203
+ const handleKeyDown = (e) => {
1204
+ if (e.key === "Enter" && !disabled) handleSearch();
1205
+ };
1206
+ const handleCancel = () => {
1207
+ setIsFocused(false);
1208
+ onCancel == null ? void 0 : onCancel();
1209
+ };
1210
+ const renderCancel = () => {
1211
+ if (prefix || !showCancel || !isFocused) return null;
1212
+ return /* @__PURE__ */ jsx("div", { className: "wz-search-cancel", onClick: handleCancel, children: cancelText });
1213
+ };
1214
+ const combinedStyle = {
1215
+ ...style,
1216
+ backgroundColor: background
1217
+ };
1218
+ return /* @__PURE__ */ jsxs(
1219
+ "div",
1220
+ {
1221
+ className: `wz-search ${isFocused ? "wz-search-focused" : ""} ${className}`,
1222
+ style: combinedStyle,
1223
+ children: [
1224
+ prefix && /* @__PURE__ */ jsx("div", { className: "wz-search-prefix", children: prefix }),
1225
+ renderCancel(),
1226
+ /* @__PURE__ */ jsxs(
1227
+ "div",
1228
+ {
1229
+ className: `wz-search-content wz-search-shape-${shape} ${disabled ? "wz-search-disabled" : ""}`,
1230
+ children: [
1231
+ /* @__PURE__ */ jsxs(
1232
+ "div",
1233
+ {
1234
+ className: `wz-search-input-wrapper ${showClear ? "wz-search-input-wrapper--with-clear" : ""}`,
1235
+ children: [
1236
+ leftIcon && /* @__PURE__ */ jsx("div", { className: "wz-search-left-icon", children: leftIcon }),
1237
+ /* @__PURE__ */ jsx(
1238
+ "input",
1239
+ {
1240
+ ref: inputRef,
1241
+ className: "wz-search-input",
1242
+ value: inputValue,
1243
+ onChange: handleChange,
1244
+ onFocus: handleFocus,
1245
+ onBlur: handleBlur,
1246
+ onKeyDown: handleKeyDown,
1247
+ placeholder,
1248
+ disabled,
1249
+ ...props
1250
+ }
1251
+ ),
1252
+ showClear && /* @__PURE__ */ jsx("div", { className: "wz-search-clear", onMouseDown: handleClear, children: /* @__PURE__ */ jsx(Icon, { name: "close", size: 16, color: "#BDBDBD" }) })
1253
+ ]
1254
+ }
1255
+ ),
1256
+ actionText && /* @__PURE__ */ jsxs("div", { className: "wz-search-action", onClick: handleSearch, children: [
1257
+ /* @__PURE__ */ jsx("div", { className: "wz-search-divider" }),
1258
+ /* @__PURE__ */ jsx("div", { className: "wz-search-action-text", children: actionText })
1259
+ ] })
1260
+ ]
1261
+ }
1262
+ ),
1263
+ suffix && /* @__PURE__ */ jsx("div", { className: "wz-search-suffix", children: suffix })
1264
+ ]
1265
+ }
1266
+ );
1267
+ }
1268
+ );
1269
+ Search.displayName = "Search";
1270
+ const defaultSingleOptions = Array.from({ length: 24 }, (_, i) => `${i + 1}小时`);
1271
+ const hourOptions = Array.from({ length: 24 }, (_, i) => i.toString().padStart(2, "0"));
1272
+ const minuteOptions = Array.from({ length: 60 }, (_, i) => i.toString().padStart(2, "0"));
1273
+ const TimePicker = ({
1274
+ type = "single",
1275
+ options,
1276
+ value,
1277
+ onChange,
1278
+ className = "",
1279
+ style,
1280
+ itemHeight = 48
1281
+ }) => {
1282
+ if (type === "single") {
1283
+ const pickerOptions = options && options.length > 0 ? options : defaultSingleOptions;
1284
+ const [current, setCurrent] = useState(() => {
1285
+ const idx = value ? pickerOptions.indexOf(value) : 0;
1286
+ return idx >= 0 ? idx : 0;
1287
+ });
1288
+ const wrapperRef = useRef(null);
1289
+ const startY2 = useRef(0);
1290
+ const startScroll2 = useRef(0);
1291
+ const isDragging2 = useRef(false);
1292
+ useEffect(() => {
1293
+ if (value && pickerOptions.includes(value)) {
1294
+ setCurrent(pickerOptions.indexOf(value));
1295
+ }
1296
+ }, [value, pickerOptions]);
1297
+ useEffect(() => {
1298
+ if (wrapperRef.current) {
1299
+ wrapperRef.current.scrollTo({
1300
+ top: current * itemHeight,
1301
+ behavior: "smooth"
1302
+ });
1303
+ }
1304
+ }, [current, itemHeight]);
1305
+ const handleTouchStart2 = (e) => {
1306
+ var _a;
1307
+ isDragging2.current = true;
1308
+ startY2.current = e.touches[0].clientY;
1309
+ startScroll2.current = ((_a = wrapperRef.current) == null ? void 0 : _a.scrollTop) || 0;
1310
+ };
1311
+ const handleTouchMove2 = (e) => {
1312
+ if (!isDragging2.current) return;
1313
+ const deltaY = e.touches[0].clientY - startY2.current;
1314
+ if (wrapperRef.current) {
1315
+ wrapperRef.current.scrollTop = startScroll2.current - deltaY;
1316
+ }
1317
+ };
1318
+ const handleTouchEnd2 = () => {
1319
+ isDragging2.current = false;
1320
+ if (!wrapperRef.current) return;
1321
+ const idx = Math.round(wrapperRef.current.scrollTop / itemHeight);
1322
+ setCurrent(idx);
1323
+ onChange == null ? void 0 : onChange(pickerOptions[idx]);
1324
+ };
1325
+ const handleScroll2 = () => {
1326
+ if (!isDragging2.current && wrapperRef.current) {
1327
+ const idx = Math.round(wrapperRef.current.scrollTop / itemHeight);
1328
+ setCurrent(idx);
1329
+ onChange == null ? void 0 : onChange(pickerOptions[idx]);
1330
+ }
1331
+ };
1332
+ const isItemActive = (index) => index === current;
1333
+ return /* @__PURE__ */ jsxs("div", { className: `wz-time-picker ${className}`, style, children: [
1334
+ /* @__PURE__ */ jsx("div", { className: "wz-time-picker-mask wz-time-picker-mask-top", style: { height: itemHeight } }),
1335
+ /* @__PURE__ */ jsx("div", { className: "wz-time-picker-indicator", style: { height: itemHeight } }),
1336
+ /* @__PURE__ */ jsxs(
1337
+ "div",
1338
+ {
1339
+ className: "wz-time-picker-list",
1340
+ ref: wrapperRef,
1341
+ style: { height: itemHeight * 3 },
1342
+ onTouchStart: handleTouchStart2,
1343
+ onTouchMove: handleTouchMove2,
1344
+ onTouchEnd: handleTouchEnd2,
1345
+ onScroll: handleScroll2,
1346
+ children: [
1347
+ /* @__PURE__ */ jsx("div", { style: { height: itemHeight } }),
1348
+ pickerOptions.map((opt, idx) => /* @__PURE__ */ jsx(
1349
+ "div",
1350
+ {
1351
+ className: `wz-time-picker-item${isItemActive(idx) ? " active" : ""}`,
1352
+ style: { height: itemHeight },
1353
+ children: opt
1354
+ },
1355
+ opt
1356
+ )),
1357
+ /* @__PURE__ */ jsx("div", { style: { height: itemHeight } })
1358
+ ]
1359
+ }
1360
+ ),
1361
+ /* @__PURE__ */ jsx("div", { className: "wz-time-picker-mask wz-time-picker-mask-bottom", style: { height: itemHeight } })
1362
+ ] });
1363
+ }
1364
+ const [hour, minute] = value ? value.split(":") : [hourOptions[0], minuteOptions[0]];
1365
+ const [currentHour, setCurrentHour] = useState(hourOptions.indexOf(hour));
1366
+ const [currentMinute, setCurrentMinute] = useState(minuteOptions.indexOf(minute));
1367
+ const hourRef = useRef(null);
1368
+ const minuteRef = useRef(null);
1369
+ const startY = useRef(0);
1370
+ const startScroll = useRef(0);
1371
+ const isDragging = useRef(false);
1372
+ const dragType = useRef(null);
1373
+ useEffect(() => {
1374
+ if (hourRef.current) {
1375
+ hourRef.current.scrollTo({
1376
+ top: currentHour * itemHeight,
1377
+ behavior: "smooth"
1378
+ });
1379
+ }
1380
+ }, [currentHour, itemHeight]);
1381
+ useEffect(() => {
1382
+ if (minuteRef.current) {
1383
+ minuteRef.current.scrollTo({
1384
+ top: currentMinute * itemHeight,
1385
+ behavior: "smooth"
1386
+ });
1387
+ }
1388
+ }, [currentMinute, itemHeight]);
1389
+ const handleTouchStart = (type2) => (e) => {
1390
+ var _a, _b;
1391
+ isDragging.current = true;
1392
+ dragType.current = type2;
1393
+ startY.current = e.touches[0].clientY;
1394
+ startScroll.current = (type2 === "hour" ? (_a = hourRef.current) == null ? void 0 : _a.scrollTop : (_b = minuteRef.current) == null ? void 0 : _b.scrollTop) || 0;
1395
+ };
1396
+ const handleTouchMove = (e) => {
1397
+ if (!isDragging.current || !dragType.current) return;
1398
+ const deltaY = e.touches[0].clientY - startY.current;
1399
+ if (dragType.current === "hour" && hourRef.current) {
1400
+ hourRef.current.scrollTop = startScroll.current - deltaY;
1401
+ } else if (dragType.current === "minute" && minuteRef.current) {
1402
+ minuteRef.current.scrollTop = startScroll.current - deltaY;
1403
+ }
1404
+ };
1405
+ const handleTouchEnd = () => {
1406
+ if (!isDragging.current || !dragType.current) return;
1407
+ if (dragType.current === "hour" && hourRef.current) {
1408
+ const idx = Math.round(hourRef.current.scrollTop / itemHeight);
1409
+ setCurrentHour(idx);
1410
+ onChange == null ? void 0 : onChange(`${hourOptions[idx]}:${minuteOptions[currentMinute]}`);
1411
+ } else if (dragType.current === "minute" && minuteRef.current) {
1412
+ const idx = Math.round(minuteRef.current.scrollTop / itemHeight);
1413
+ setCurrentMinute(idx);
1414
+ onChange == null ? void 0 : onChange(`${hourOptions[currentHour]}:${minuteOptions[idx]}`);
1415
+ }
1416
+ isDragging.current = false;
1417
+ dragType.current = null;
1418
+ };
1419
+ const handleScroll = (type2) => () => {
1420
+ if (isDragging.current) return;
1421
+ if (type2 === "hour" && hourRef.current) {
1422
+ const idx = Math.round(hourRef.current.scrollTop / itemHeight);
1423
+ setCurrentHour(idx);
1424
+ onChange == null ? void 0 : onChange(`${hourOptions[idx]}:${minuteOptions[currentMinute]}`);
1425
+ } else if (type2 === "minute" && minuteRef.current) {
1426
+ const idx = Math.round(minuteRef.current.scrollTop / itemHeight);
1427
+ setCurrentMinute(idx);
1428
+ onChange == null ? void 0 : onChange(`${hourOptions[currentHour]}:${minuteOptions[idx]}`);
1429
+ }
1430
+ };
1431
+ const renderColumn = (options2, current, ref, type2) => /* @__PURE__ */ jsxs(
1432
+ "div",
1433
+ {
1434
+ className: "wz-time-picker-list",
1435
+ ref,
1436
+ style: { height: itemHeight * 3 },
1437
+ onTouchStart: handleTouchStart(type2),
1438
+ onTouchMove: handleTouchMove,
1439
+ onTouchEnd: handleTouchEnd,
1440
+ onScroll: handleScroll(type2),
1441
+ children: [
1442
+ /* @__PURE__ */ jsx("div", { style: { height: itemHeight } }),
1443
+ options2.map((opt, idx) => /* @__PURE__ */ jsx(
1444
+ "div",
1445
+ {
1446
+ className: `wz-time-picker-item${idx === current ? " active" : ""}`,
1447
+ style: { height: itemHeight },
1448
+ children: opt
1449
+ },
1450
+ opt
1451
+ )),
1452
+ /* @__PURE__ */ jsx("div", { style: { height: itemHeight } })
1453
+ ]
1454
+ }
1455
+ );
1456
+ return /* @__PURE__ */ jsxs("div", { className: `wz-time-picker wz-time-picker-double ${className}`, style, children: [
1457
+ /* @__PURE__ */ jsx("div", { className: "wz-time-picker-mask wz-time-picker-mask-top", style: { height: itemHeight } }),
1458
+ /* @__PURE__ */ jsx("div", { className: "wz-time-picker-indicator", style: { height: itemHeight } }),
1459
+ /* @__PURE__ */ jsxs("div", { className: "wz-time-picker-double-columns", children: [
1460
+ renderColumn(hourOptions, currentHour, hourRef, "hour"),
1461
+ renderColumn(minuteOptions, currentMinute, minuteRef, "minute")
1462
+ ] }),
1463
+ /* @__PURE__ */ jsx("div", { className: "wz-time-picker-mask wz-time-picker-mask-bottom", style: { height: itemHeight } })
1464
+ ] });
1465
+ };
1466
+ const getYearList = (min, max) => {
1467
+ const arr = [];
1468
+ for (let i = min; i <= max; i++) arr.push(i.toString());
1469
+ return arr;
1470
+ };
1471
+ const getMonthList = () => Array.from({ length: 12 }, (_, i) => (i + 1).toString().padStart(2, "0"));
1472
+ const getDayList = (year, month) => {
1473
+ const days = new Date(year, month, 0).getDate();
1474
+ return Array.from({ length: days }, (_, i) => (i + 1).toString().padStart(2, "0"));
1475
+ };
1476
+ const DatePicker = ({
1477
+ value,
1478
+ onChange,
1479
+ min = "1970-01-01",
1480
+ max = "2100-12-31",
1481
+ columns = ["year", "month", "day"],
1482
+ itemHeight = 48,
1483
+ className = "",
1484
+ style
1485
+ }) => {
1486
+ const today = /* @__PURE__ */ new Date();
1487
+ const [initYear, initMonth, initDay] = value ? value.split("-").map(Number) : [today.getFullYear(), today.getMonth() + 1, today.getDate()];
1488
+ const minYear = Number(min.split("-")[0]);
1489
+ const maxYear = Number(max.split("-")[0]);
1490
+ const yearList = useMemo(() => getYearList(minYear, maxYear), [minYear, maxYear]);
1491
+ const [year, setYear] = useState(initYear);
1492
+ const [month, setMonth] = useState(initMonth);
1493
+ const [day, setDay] = useState(initDay);
1494
+ const monthList = getMonthList();
1495
+ const dayList = getDayList(year, month);
1496
+ const yearRef = useRef(null);
1497
+ const monthRef = useRef(null);
1498
+ const dayRef = useRef(null);
1499
+ const startY = useRef(0);
1500
+ const startScroll = useRef(0);
1501
+ const isDragging = useRef(false);
1502
+ const dragType = useRef(null);
1503
+ useLayoutEffect(() => {
1504
+ if (yearRef.current) yearRef.current.scrollTo({ top: (year - minYear) * itemHeight, behavior: "auto" });
1505
+ }, [year, itemHeight, minYear]);
1506
+ useLayoutEffect(() => {
1507
+ if (monthRef.current) monthRef.current.scrollTo({ top: (month - 1) * itemHeight, behavior: "auto" });
1508
+ }, [month, itemHeight]);
1509
+ useLayoutEffect(() => {
1510
+ if (dayRef.current) dayRef.current.scrollTo({ top: (day - 1) * itemHeight, behavior: "auto" });
1511
+ }, [day, itemHeight]);
1512
+ const handleTouchStart = (type) => (e) => {
1513
+ var _a, _b, _c;
1514
+ isDragging.current = true;
1515
+ dragType.current = type;
1516
+ startY.current = e.touches[0].clientY;
1517
+ let scrollTop = 0;
1518
+ if (type === "year") scrollTop = ((_a = yearRef.current) == null ? void 0 : _a.scrollTop) || 0;
1519
+ if (type === "month") scrollTop = ((_b = monthRef.current) == null ? void 0 : _b.scrollTop) || 0;
1520
+ if (type === "day") scrollTop = ((_c = dayRef.current) == null ? void 0 : _c.scrollTop) || 0;
1521
+ startScroll.current = scrollTop;
1522
+ };
1523
+ const handleTouchMove = (e) => {
1524
+ if (!isDragging.current || !dragType.current) return;
1525
+ const deltaY = e.touches[0].clientY - startY.current;
1526
+ if (dragType.current === "year" && yearRef.current) yearRef.current.scrollTop = startScroll.current - deltaY;
1527
+ if (dragType.current === "month" && monthRef.current) monthRef.current.scrollTop = startScroll.current - deltaY;
1528
+ if (dragType.current === "day" && dayRef.current) dayRef.current.scrollTop = startScroll.current - deltaY;
1529
+ };
1530
+ const handleTouchEnd = () => {
1531
+ if (!isDragging.current || !dragType.current) return;
1532
+ if (dragType.current === "year" && yearRef.current) {
1533
+ const idx = Math.round(yearRef.current.scrollTop / itemHeight);
1534
+ setYear(Number(yearList[idx]));
1535
+ onChange == null ? void 0 : onChange(`${yearList[idx]}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}`);
1536
+ }
1537
+ if (dragType.current === "month" && monthRef.current) {
1538
+ const idx = Math.round(monthRef.current.scrollTop / itemHeight);
1539
+ setMonth(Number(monthList[idx]));
1540
+ onChange == null ? void 0 : onChange(`${year}-${monthList[idx]}-${day.toString().padStart(2, "0")}`);
1541
+ }
1542
+ if (dragType.current === "day" && dayRef.current) {
1543
+ const idx = Math.round(dayRef.current.scrollTop / itemHeight);
1544
+ setDay(Number(dayList[idx]));
1545
+ onChange == null ? void 0 : onChange(`${year}-${month.toString().padStart(2, "0")}-${dayList[idx]}`);
1546
+ }
1547
+ isDragging.current = false;
1548
+ dragType.current = null;
1549
+ };
1550
+ const handleScroll = (type) => () => {
1551
+ if (isDragging.current) return;
1552
+ if (type === "year" && yearRef.current) {
1553
+ const idx = Math.round(yearRef.current.scrollTop / itemHeight);
1554
+ setYear(Number(yearList[idx]));
1555
+ onChange == null ? void 0 : onChange(`${yearList[idx]}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}`);
1556
+ }
1557
+ if (type === "month" && monthRef.current) {
1558
+ const idx = Math.round(monthRef.current.scrollTop / itemHeight);
1559
+ setMonth(Number(monthList[idx]));
1560
+ onChange == null ? void 0 : onChange(`${year}-${monthList[idx]}-${day.toString().padStart(2, "0")}`);
1561
+ }
1562
+ if (type === "day" && dayRef.current) {
1563
+ const idx = Math.round(dayRef.current.scrollTop / itemHeight);
1564
+ setDay(Number(dayList[idx]));
1565
+ onChange == null ? void 0 : onChange(`${year}-${month.toString().padStart(2, "0")}-${dayList[idx]}`);
1566
+ }
1567
+ };
1568
+ React.useEffect(() => {
1569
+ if (value) {
1570
+ const [y, m, d] = value.split("-").map(Number);
1571
+ setYear(y);
1572
+ setMonth(m);
1573
+ setDay(d);
1574
+ if (yearRef.current) yearRef.current.scrollTo({ top: (y - minYear) * itemHeight, behavior: "auto" });
1575
+ if (monthRef.current) monthRef.current.scrollTo({ top: (m - 1) * itemHeight, behavior: "auto" });
1576
+ if (dayRef.current) dayRef.current.scrollTo({ top: (d - 1) * itemHeight, behavior: "auto" });
1577
+ }
1578
+ }, [value]);
1579
+ const renderColumn = (options, current, ref, type) => /* @__PURE__ */ jsxs(
1580
+ "div",
1581
+ {
1582
+ className: "wz-date-picker-list",
1583
+ ref,
1584
+ style: { height: itemHeight * 3 },
1585
+ onTouchStart: handleTouchStart(type),
1586
+ onTouchMove: handleTouchMove,
1587
+ onTouchEnd: handleTouchEnd,
1588
+ onScroll: handleScroll(type),
1589
+ children: [
1590
+ /* @__PURE__ */ jsx("div", { style: { height: itemHeight } }),
1591
+ options.map((opt, idx) => /* @__PURE__ */ jsx(
1592
+ "div",
1593
+ {
1594
+ className: `wz-date-picker-item${idx === current ? " active" : ""}`,
1595
+ style: { height: itemHeight },
1596
+ children: type === "year" ? `${opt}年` : type === "month" ? `${opt}月` : `${opt}日`
1597
+ },
1598
+ opt
1599
+ )),
1600
+ /* @__PURE__ */ jsx("div", { style: { height: itemHeight } })
1601
+ ]
1602
+ }
1603
+ );
1604
+ return /* @__PURE__ */ jsxs("div", { className: `wz-date-picker ${className}`, style, children: [
1605
+ /* @__PURE__ */ jsx("div", { className: "wz-date-picker-mask wz-date-picker-mask-top", style: { height: itemHeight } }),
1606
+ /* @__PURE__ */ jsx("div", { className: "wz-date-picker-indicator", style: { height: itemHeight } }),
1607
+ /* @__PURE__ */ jsxs("div", { className: "wz-date-picker-columns", children: [
1608
+ columns.includes("year") && renderColumn(yearList, year - minYear, yearRef, "year"),
1609
+ columns.includes("month") && renderColumn(monthList, month - 1, monthRef, "month"),
1610
+ columns.includes("day") && renderColumn(dayList, day - 1, dayRef, "day")
1611
+ ] }),
1612
+ /* @__PURE__ */ jsx("div", { className: "wz-date-picker-mask wz-date-picker-mask-bottom", style: { height: itemHeight } })
1613
+ ] });
1614
+ };
1615
+ const DateRangePicker = ({
1616
+ value,
1617
+ onChange,
1618
+ min = "1970-01-01",
1619
+ max = "2100-12-31",
1620
+ startLabel = "开始时间",
1621
+ endLabel = "结束时间",
1622
+ className = "",
1623
+ style
1624
+ }) => {
1625
+ const todayStr = React.useMemo(() => {
1626
+ const today = /* @__PURE__ */ new Date();
1627
+ const y = today.getFullYear();
1628
+ const m = (today.getMonth() + 1).toString().padStart(2, "0");
1629
+ const d = today.getDate().toString().padStart(2, "0");
1630
+ return `${y}-${m}-${d}`;
1631
+ }, []);
1632
+ const [innerValue, setInnerValue] = useState(value || [todayStr, todayStr]);
1633
+ const range = value || innerValue;
1634
+ const [active, setActive] = useState("start");
1635
+ const handleSelect = (val) => {
1636
+ if (active === "start") {
1637
+ const newRange = [val, range[1] && range[1] >= val ? range[1] : val];
1638
+ setInnerValue(newRange);
1639
+ onChange == null ? void 0 : onChange(newRange);
1640
+ } else {
1641
+ const newRange = [range[0], val && val >= range[0] ? val : range[0]];
1642
+ setInnerValue(newRange);
1643
+ onChange == null ? void 0 : onChange(newRange);
1644
+ }
1645
+ };
1646
+ return /* @__PURE__ */ jsxs("div", { className: `wz-date-range-picker ${className}`, style, children: [
1647
+ /* @__PURE__ */ jsxs("div", { className: "wz-date-range-picker-label-row", children: [
1648
+ /* @__PURE__ */ jsx("div", { className: "wz-date-range-picker-label", children: startLabel }),
1649
+ /* @__PURE__ */ jsx("div", { className: "wz-date-range-picker-label", children: endLabel })
1650
+ ] }),
1651
+ /* @__PURE__ */ jsxs("div", { className: "wz-date-range-picker-row", children: [
1652
+ /* @__PURE__ */ jsx("div", { className: "wz-date-range-picker-col", children: /* @__PURE__ */ jsx(
1653
+ "div",
1654
+ {
1655
+ className: `wz-date-range-picker-value${active === "start" ? " active" : ""}`,
1656
+ onClick: () => setActive("start"),
1657
+ children: range[0] || "请选择"
1658
+ }
1659
+ ) }),
1660
+ /* @__PURE__ */ jsx("div", { className: "wz-date-range-picker-sep", children: "至" }),
1661
+ /* @__PURE__ */ jsx("div", { className: "wz-date-range-picker-col", children: /* @__PURE__ */ jsx(
1662
+ "div",
1663
+ {
1664
+ className: `wz-date-range-picker-value${active === "end" ? " active" : ""}`,
1665
+ onClick: () => setActive("end"),
1666
+ children: range[1] || "请选择"
1667
+ }
1668
+ ) })
1669
+ ] }),
1670
+ /* @__PURE__ */ jsx("div", { className: "wz-date-range-picker-picker", children: /* @__PURE__ */ jsx(
1671
+ DatePicker,
1672
+ {
1673
+ value: active === "start" ? range[0] : range[1],
1674
+ onChange: handleSelect,
1675
+ min,
1676
+ max
1677
+ }
1678
+ ) })
1679
+ ] });
1680
+ };
1681
+ const alignMap = {
1682
+ start: "flex-start",
1683
+ center: "center",
1684
+ end: "flex-end",
1685
+ stretch: "stretch",
1686
+ baseline: "baseline"
1687
+ };
1688
+ const justifyMap = {
1689
+ start: "flex-start",
1690
+ center: "center",
1691
+ end: "flex-end",
1692
+ between: "space-between",
1693
+ around: "space-around",
1694
+ evenly: "space-evenly"
1695
+ };
1696
+ const FlexItem = ({
1697
+ span,
1698
+ order,
1699
+ offset,
1700
+ className = "",
1701
+ style = {},
1702
+ children
1703
+ }) => {
1704
+ if (process.env.NODE_ENV !== "production") {
1705
+ if (span !== void 0 && (span < 0 || span > 1)) {
1706
+ console.warn(
1707
+ `[Flex.Item] span 应该在 0-1 之间,当前值为 ${span}。例如:0.5 表示 50%`
1708
+ );
1709
+ }
1710
+ if (offset !== void 0 && (offset < 0 || offset > 1)) {
1711
+ console.warn(
1712
+ `[Flex.Item] offset 应该在 0-1 之间,当前值为 ${offset}。例如:0.25 表示 25%`
1713
+ );
1714
+ }
1715
+ }
1716
+ const itemStyle = {
1717
+ flexBasis: span !== void 0 ? `${span * 100}%` : void 0,
1718
+ flexGrow: span !== void 0 ? 0 : void 0,
1719
+ flexShrink: span !== void 0 ? 0 : void 0,
1720
+ order,
1721
+ marginLeft: offset !== void 0 ? `${offset * 100}%` : void 0,
1722
+ ...style
1723
+ };
1724
+ return /* @__PURE__ */ jsx(
1725
+ "div",
1726
+ {
1727
+ className: `wz-flex-item${className ? " " + className : ""}`,
1728
+ style: itemStyle,
1729
+ children
1730
+ }
1731
+ );
1732
+ };
1733
+ const Flex = ({
1734
+ direction = "row",
1735
+ align = "stretch",
1736
+ justify = "start",
1737
+ wrap = "nowrap",
1738
+ gap = 0,
1739
+ className = "",
1740
+ style = {},
1741
+ children
1742
+ }) => {
1743
+ const flexStyle = {
1744
+ display: "flex",
1745
+ flexDirection: direction,
1746
+ alignItems: alignMap[align],
1747
+ justifyContent: justifyMap[justify],
1748
+ flexWrap: wrap,
1749
+ gap: typeof gap === "number" ? `${gap}px` : gap,
1750
+ ...style
1751
+ };
1752
+ return /* @__PURE__ */ jsx(
1753
+ "div",
1754
+ {
1755
+ className: `wz-flex${className ? " " + className : ""}`,
1756
+ style: flexStyle,
1757
+ children
1758
+ }
1759
+ );
1760
+ };
1761
+ Flex.Item = FlexItem;
1762
+ const GridContext = createContext(24);
1763
+ const GridItem = ({
1764
+ span = 1,
1765
+ offset = 0,
1766
+ order,
1767
+ className = "",
1768
+ style = {},
1769
+ children
1770
+ }) => {
1771
+ const cols = useContext(GridContext);
1772
+ if (process.env.NODE_ENV !== "production") {
1773
+ if (span < 1 || span > cols) {
1774
+ console.warn(
1775
+ `[Grid.Item] span 应该在 1-${cols} 之间,当前值为 ${span}`
1776
+ );
1777
+ }
1778
+ if (offset < 0 || offset > cols) {
1779
+ console.warn(
1780
+ `[Grid.Item] offset 应该在 0-${cols} 之间,当前值为 ${offset}`
1781
+ );
1782
+ }
1783
+ }
1784
+ const width = `${span / cols * 100}%`;
1785
+ const marginLeft = offset ? `${offset / cols * 100}%` : void 0;
1786
+ return /* @__PURE__ */ jsx(
1787
+ "div",
1788
+ {
1789
+ className: `wz-grid-item${className ? " " + className : ""}`,
1790
+ style: { width, marginLeft, order, ...style },
1791
+ children
1792
+ }
1793
+ );
1794
+ };
1795
+ const Grid = ({
1796
+ cols = 24,
1797
+ gap = 0,
1798
+ className = "",
1799
+ style = {},
1800
+ children
1801
+ }) => {
1802
+ const gridStyle = {
1803
+ display: "flex",
1804
+ flexWrap: "wrap",
1805
+ gap: typeof gap === "number" ? `${gap}px` : gap,
1806
+ ...style
1807
+ };
1808
+ return /* @__PURE__ */ jsx(GridContext.Provider, { value: cols, children: /* @__PURE__ */ jsx("div", { className: `wz-grid${className ? " " + className : ""}`, style: gridStyle, children }) });
1809
+ };
1810
+ Grid.Item = GridItem;
1811
+ const GridViewItem = ({
1812
+ icon,
1813
+ text,
1814
+ description,
1815
+ badge,
1816
+ corner,
1817
+ onClick,
1818
+ className = "",
1819
+ style = {},
1820
+ disabled = false,
1821
+ children,
1822
+ horizontal = false,
1823
+ compact = false,
1824
+ backgroundImage,
1825
+ backgroundStyle = {}
1826
+ }) => {
1827
+ const handleClick = () => {
1828
+ if (!disabled && onClick) {
1829
+ onClick();
1830
+ }
1831
+ };
1832
+ const itemClass = [
1833
+ "wz-grid-view-item",
1834
+ disabled ? "wz-grid-view-item--disabled" : "",
1835
+ onClick ? "wz-grid-view-item--clickable" : "",
1836
+ horizontal ? "wz-grid-view-item--horizontal" : "",
1837
+ compact ? "wz-grid-view-item--compact" : "",
1838
+ backgroundImage ? "wz-grid-view-item--with-bg" : "",
1839
+ className
1840
+ ].filter(Boolean).join(" ");
1841
+ const itemStyle = backgroundImage ? {
1842
+ backgroundImage: `url(${backgroundImage})`,
1843
+ backgroundSize: "cover",
1844
+ backgroundPosition: "center",
1845
+ backgroundRepeat: "no-repeat",
1846
+ ...backgroundStyle,
1847
+ ...style
1848
+ } : style;
1849
+ if (children) {
1850
+ return /* @__PURE__ */ jsxs("div", { className: itemClass, style: itemStyle, onClick: handleClick, children: [
1851
+ corner && /* @__PURE__ */ jsx("div", { className: "wz-grid-view-item__corner", children: corner }),
1852
+ children,
1853
+ badge && /* @__PURE__ */ jsx("div", { className: "wz-grid-view-item__badge", children: badge })
1854
+ ] });
1855
+ }
1856
+ return /* @__PURE__ */ jsxs("div", { className: itemClass, style: itemStyle, onClick: handleClick, children: [
1857
+ corner && /* @__PURE__ */ jsx("div", { className: "wz-grid-view-item__corner", children: corner }),
1858
+ /* @__PURE__ */ jsxs("div", { className: "wz-grid-view-item__content", children: [
1859
+ icon && /* @__PURE__ */ jsx("div", { className: "wz-grid-view-item__icon", children: icon }),
1860
+ /* @__PURE__ */ jsxs("div", { className: "wz-grid-view-item__text", children: [
1861
+ text && /* @__PURE__ */ jsx("div", { className: "wz-grid-view-item__title", children: text }),
1862
+ description && /* @__PURE__ */ jsx("div", { className: "wz-grid-view-item__desc", children: description })
1863
+ ] })
1864
+ ] }),
1865
+ badge && /* @__PURE__ */ jsx("div", { className: "wz-grid-view-item__badge", children: badge })
1866
+ ] });
1867
+ };
1868
+ const GridView = ({
1869
+ columns = 4,
1870
+ gap = 0,
1871
+ square = true,
1872
+ className = "",
1873
+ style = {},
1874
+ children,
1875
+ noBg = false,
1876
+ rounded = false,
1877
+ shadow = false,
1878
+ horizontal = false
1879
+ }) => {
1880
+ const gridStyle = {
1881
+ gridTemplateColumns: `repeat(${columns}, 1fr)`,
1882
+ gap: typeof gap === "number" ? `${gap}px` : gap,
1883
+ ...style
1884
+ };
1885
+ const gridClass = [
1886
+ "wz-grid-view",
1887
+ square ? "wz-grid-view--square" : "",
1888
+ noBg ? "wz-grid-view--no-bg" : "",
1889
+ rounded ? "wz-grid-view--rounded" : "",
1890
+ shadow ? "wz-grid-view--shadow" : "",
1891
+ horizontal ? "wz-grid-view--horizontal" : "",
1892
+ className
1893
+ ].filter(Boolean).join(" ");
1894
+ return /* @__PURE__ */ jsx("div", { className: gridClass, style: gridStyle, children });
1895
+ };
1896
+ GridView.Item = GridViewItem;
1897
+ function hexToRgba(hex, opacity) {
1898
+ let newHex = hex.replace("#", "");
1899
+ if (newHex.length === 3) {
1900
+ newHex = newHex.split("").map((char) => char + char).join("");
1901
+ }
1902
+ const r = parseInt(newHex.substring(0, 2), 16);
1903
+ const g = parseInt(newHex.substring(2, 4), 16);
1904
+ const b = parseInt(newHex.substring(4, 6), 16);
1905
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
1906
+ }
1907
+ const Tag = (props) => {
1908
+ const {
1909
+ type = "solid",
1910
+ size = "large",
1911
+ color,
1912
+ bgColor,
1913
+ fontWeight,
1914
+ className,
1915
+ style,
1916
+ children
1917
+ } = props;
1918
+ const classes = classNames("wz-tag", `wz-tag-${type}`, `wz-tag-${size}`, className);
1919
+ const tagStyle = useMemo(() => {
1920
+ const newStyle = { ...style };
1921
+ if (color) {
1922
+ newStyle.color = color;
1923
+ if (type === "line") {
1924
+ newStyle.borderColor = hexToRgba(color, 0.5);
1925
+ }
1926
+ }
1927
+ if (bgColor && type === "solid") {
1928
+ newStyle.backgroundColor = bgColor;
1929
+ }
1930
+ if (fontWeight) {
1931
+ newStyle.fontWeight = fontWeight;
1932
+ }
1933
+ return newStyle;
1934
+ }, [type, color, bgColor, fontWeight, style]);
1935
+ return /* @__PURE__ */ jsx("div", { className: classes, style: tagStyle, children });
1936
+ };
1937
+ const Tip = ({
1938
+ content,
1939
+ className,
1940
+ visible = true,
1941
+ onClose,
1942
+ action,
1943
+ marquee = false
1944
+ }) => {
1945
+ if (!visible) {
1946
+ return null;
1947
+ }
1948
+ const baseClass = "wz-tip";
1949
+ const tipClass = classNames(baseClass, className, {
1950
+ [`${baseClass}--marquee`]: marquee
1951
+ });
1952
+ const contentNode = marquee ? /* @__PURE__ */ jsx("div", { className: `${baseClass}-marquee-box`, children: /* @__PURE__ */ jsx("span", { children: content }) }) : content;
1953
+ return /* @__PURE__ */ jsxs("div", { className: tipClass, children: [
1954
+ /* @__PURE__ */ jsx("div", { className: `${baseClass}-content`, children: contentNode }),
1955
+ action && /* @__PURE__ */ jsx("div", { className: `${baseClass}-action`, children: action }),
1956
+ onClose && /* @__PURE__ */ jsx("div", { className: `${baseClass}-close`, onClick: onClose, children: /* @__PURE__ */ jsx(Icon, { name: "close", size: 16 }) })
1957
+ ] });
1958
+ };
1959
+ const NavBar = ({
1960
+ title,
1961
+ leftArrow = true,
1962
+ leftText,
1963
+ rightText,
1964
+ onLeftClick,
1965
+ onRightClick,
1966
+ leftSlot,
1967
+ rightSlot,
1968
+ titleSlot,
1969
+ className,
1970
+ style,
1971
+ fixed = false,
1972
+ scrollFixed = false
1973
+ }) => {
1974
+ const [isFixed, setIsFixed] = useState(fixed);
1975
+ const navbarRef = useRef(null);
1976
+ const placeholderRef = useRef(null);
1977
+ useEffect(() => {
1978
+ if (scrollFixed === false) {
1979
+ setIsFixed(fixed);
1980
+ return;
1981
+ }
1982
+ const threshold = typeof scrollFixed === "number" ? scrollFixed : 0;
1983
+ const handleScroll = () => {
1984
+ const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
1985
+ setIsFixed(scrollTop > threshold);
1986
+ };
1987
+ window.addEventListener("scroll", handleScroll);
1988
+ handleScroll();
1989
+ return () => {
1990
+ window.removeEventListener("scroll", handleScroll);
1991
+ };
1992
+ }, [scrollFixed, fixed]);
1993
+ const handleLeftClick = () => {
1994
+ if (onLeftClick) {
1995
+ onLeftClick();
1996
+ }
1997
+ };
1998
+ const handleRightClick = () => {
1999
+ if (onRightClick) {
2000
+ onRightClick();
2001
+ }
2002
+ };
2003
+ const renderLeft = () => {
2004
+ if (leftSlot) {
2005
+ return /* @__PURE__ */ jsx("div", { className: "wz-navbar-left", children: leftSlot });
2006
+ }
2007
+ return /* @__PURE__ */ jsxs("div", { className: "wz-navbar-left", onClick: handleLeftClick, children: [
2008
+ leftArrow && /* @__PURE__ */ jsx(
2009
+ Icon,
2010
+ {
2011
+ name: "right-arrow",
2012
+ size: 20,
2013
+ style: { transform: "scaleX(-1)" },
2014
+ className: "wz-navbar-icon"
2015
+ }
2016
+ ),
2017
+ leftText && /* @__PURE__ */ jsx("span", { className: "wz-navbar-text", children: leftText })
2018
+ ] });
2019
+ };
2020
+ const renderRight = () => {
2021
+ if (rightSlot) {
2022
+ return /* @__PURE__ */ jsx("div", { className: "wz-navbar-right", children: rightSlot });
2023
+ }
2024
+ return /* @__PURE__ */ jsxs("div", { className: "wz-navbar-right", onClick: handleRightClick, children: [
2025
+ rightText && /* @__PURE__ */ jsx("span", { className: "wz-navbar-text", children: rightText }),
2026
+ !rightText && /* @__PURE__ */ jsx(Icon, { name: "more-h", className: "wz-navbar-icon" })
2027
+ ] });
2028
+ };
2029
+ const renderTitle = () => {
2030
+ if (titleSlot) {
2031
+ return /* @__PURE__ */ jsx("div", { className: "wz-navbar-title", children: titleSlot });
2032
+ }
2033
+ return /* @__PURE__ */ jsx("div", { className: "wz-navbar-title", children: title });
2034
+ };
2035
+ const navbarClass = classNames(
2036
+ "wz-navbar",
2037
+ {
2038
+ "wz-navbar-fixed": isFixed
2039
+ },
2040
+ className
2041
+ );
2042
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2043
+ isFixed && /* @__PURE__ */ jsx("div", { ref: placeholderRef, style: { height: "44px" } }),
2044
+ /* @__PURE__ */ jsxs("div", { ref: navbarRef, className: navbarClass, style, children: [
2045
+ renderLeft(),
2046
+ renderTitle(),
2047
+ renderRight()
2048
+ ] })
2049
+ ] });
2050
+ };
2051
+ const DropdownMenu = ({
2052
+ items,
2053
+ extension,
2054
+ onChange,
2055
+ value,
2056
+ defaultValue = {}
2057
+ }) => {
2058
+ const [activeItem, setActiveItem] = useState(null);
2059
+ const [selectedValues, setSelectedValues] = useState(defaultValue);
2060
+ useEffect(() => {
2061
+ if (value !== void 0) {
2062
+ setSelectedValues(value);
2063
+ }
2064
+ }, [value]);
2065
+ const isControlled = value !== void 0;
2066
+ const getCurrentValues = () => isControlled ? value : selectedValues;
2067
+ const handleItemClick = (index) => {
2068
+ setActiveItem(activeItem === index ? null : index);
2069
+ };
2070
+ const handleOptionClick = (itemIndex, optionValue) => {
2071
+ const newValues = { ...getCurrentValues(), [itemIndex]: optionValue };
2072
+ if (!isControlled) {
2073
+ setSelectedValues(newValues);
2074
+ }
2075
+ setActiveItem(null);
2076
+ if (onChange) {
2077
+ onChange(itemIndex, optionValue, newValues);
2078
+ }
2079
+ };
2080
+ const handleMaskClick = () => {
2081
+ setActiveItem(null);
2082
+ };
2083
+ const getSelectedItemText = (itemIndex) => {
2084
+ const currentValues = getCurrentValues();
2085
+ const selectedValue = currentValues[itemIndex];
2086
+ if (selectedValue === void 0) {
2087
+ return items[itemIndex].title;
2088
+ }
2089
+ const selectedOption = items[itemIndex].options.find(
2090
+ (option) => option.value === selectedValue
2091
+ );
2092
+ return selectedOption ? selectedOption.text : items[itemIndex].title;
2093
+ };
2094
+ return /* @__PURE__ */ jsxs("div", { className: "wz-dropdown-menu-wrapper", children: [
2095
+ /* @__PURE__ */ jsxs("div", { className: "wz-dropdown-menu", children: [
2096
+ items.map((item, index) => /* @__PURE__ */ jsxs(
2097
+ "div",
2098
+ {
2099
+ className: `wz-dropdown-item ${activeItem === index ? "active" : ""}`,
2100
+ onClick: () => handleItemClick(index),
2101
+ children: [
2102
+ /* @__PURE__ */ jsx("span", { children: getSelectedItemText(index) }),
2103
+ item.icon || /* @__PURE__ */ jsx(
2104
+ Icon,
2105
+ {
2106
+ name: "dropdown",
2107
+ size: 12
2108
+ }
2109
+ )
2110
+ ]
2111
+ },
2112
+ index
2113
+ )),
2114
+ extension && /* @__PURE__ */ jsx("div", { className: "wz-dropdown-extension", children: extension })
2115
+ ] }),
2116
+ activeItem !== null && /* @__PURE__ */ jsxs(Fragment, { children: [
2117
+ /* @__PURE__ */ jsx("div", { className: "wz-dropdown-mask", onClick: handleMaskClick }),
2118
+ /* @__PURE__ */ jsx("div", { className: "wz-dropdown-popup", children: items[activeItem].options.map((option) => /* @__PURE__ */ jsx(
2119
+ "div",
2120
+ {
2121
+ className: `wz-dropdown-option ${getCurrentValues()[activeItem] === option.value ? "selected" : ""}`,
2122
+ onClick: () => handleOptionClick(activeItem, option.value),
2123
+ children: option.text
2124
+ },
2125
+ option.value
2126
+ )) })
2127
+ ] })
2128
+ ] });
2129
+ };
2130
+ const Toast$1 = ({
2131
+ content,
2132
+ duration = 2e3,
2133
+ icon,
2134
+ visible = false,
2135
+ onClose
2136
+ }) => {
2137
+ const [show2, setShow] = useState(visible);
2138
+ useEffect(() => {
2139
+ setShow(visible);
2140
+ let timer;
2141
+ if (visible && duration > 0) {
2142
+ timer = setTimeout(() => {
2143
+ setShow(false);
2144
+ onClose == null ? void 0 : onClose();
2145
+ }, duration);
2146
+ }
2147
+ return () => {
2148
+ clearTimeout(timer);
2149
+ };
2150
+ }, [visible, duration, onClose]);
2151
+ const toastClass = classNames("wz-toast", { "wz-toast-visible": show2 });
2152
+ const iconClass = classNames("wz-toast-icon");
2153
+ return /* @__PURE__ */ jsx("div", { className: toastClass, children: /* @__PURE__ */ jsxs("div", { className: "wz-toast-content", children: [
2154
+ icon && /* @__PURE__ */ jsx("div", { className: iconClass, children: icon }),
2155
+ /* @__PURE__ */ jsx("div", { className: "wz-toast-text", children: content })
2156
+ ] }) });
2157
+ };
2158
+ let root = null;
2159
+ let container = null;
2160
+ const destroy = () => {
2161
+ if (root) {
2162
+ root.unmount();
2163
+ root = null;
2164
+ }
2165
+ if (container && container.parentNode) {
2166
+ container.parentNode.removeChild(container);
2167
+ container = null;
2168
+ }
2169
+ };
2170
+ const renderToast = (props) => {
2171
+ if (!container) {
2172
+ container = document.createElement("div");
2173
+ document.body.appendChild(container);
2174
+ root = createRoot(container);
2175
+ }
2176
+ root.render(/* @__PURE__ */ jsx(Toast$1, { ...props }));
2177
+ };
2178
+ const show = (props) => {
2179
+ const toastProps = typeof props === "string" ? { content: props } : props;
2180
+ renderToast({ ...toastProps, visible: true, onClose: destroy });
2181
+ };
2182
+ const success = (content, duration) => {
2183
+ renderToast({
2184
+ content,
2185
+ duration,
2186
+ icon: /* @__PURE__ */ jsx(Icon, { name: "check-round", size: 37.14 }),
2187
+ visible: true,
2188
+ onClose: destroy
2189
+ });
2190
+ };
2191
+ const fail = (content, duration) => {
2192
+ renderToast({
2193
+ content,
2194
+ duration,
2195
+ icon: /* @__PURE__ */ jsx(Icon, { name: "close", size: 37.14 }),
2196
+ visible: true,
2197
+ onClose: destroy
2198
+ });
2199
+ };
2200
+ const loading = (content, duration) => {
2201
+ renderToast({
2202
+ content,
2203
+ duration,
2204
+ icon: /* @__PURE__ */ jsx(Icon, { name: "loading", size: 37.14 }),
2205
+ visible: true,
2206
+ onClose: destroy
2207
+ });
2208
+ };
2209
+ const warn = (content, duration) => {
2210
+ renderToast({
2211
+ content,
2212
+ duration,
2213
+ icon: /* @__PURE__ */ jsx(Icon, { name: "info", size: 37.14 }),
2214
+ visible: true,
2215
+ onClose: destroy
2216
+ });
2217
+ };
2218
+ const hide = () => {
2219
+ renderToast({ content: "", visible: false });
2220
+ destroy();
2221
+ };
2222
+ const Toast = { show, success, fail, loading, warn, hide };
2223
+ const Tooltip = ({
2224
+ content,
2225
+ children,
2226
+ className,
2227
+ style,
2228
+ color,
2229
+ textColor,
2230
+ trigger = "click",
2231
+ visible,
2232
+ onVisibleChange,
2233
+ showMask = false,
2234
+ action,
2235
+ closeIcon
2236
+ }) => {
2237
+ const [internalVisible, setInternalVisible] = useState(false);
2238
+ const [computedStyle, setComputedStyle] = useState({});
2239
+ const [currentPlacement, setCurrentPlacement] = useState("bottom");
2240
+ const tooltipRef = useRef(null);
2241
+ const triggerRef = useRef(null);
2242
+ const isControlled = visible !== void 0;
2243
+ const currentVisible = isControlled ? visible : internalVisible;
2244
+ const handleVisibleChange = (newVisible) => {
2245
+ if (!isControlled) {
2246
+ setInternalVisible(newVisible);
2247
+ }
2248
+ onVisibleChange == null ? void 0 : onVisibleChange(newVisible);
2249
+ };
2250
+ useLayoutEffect(() => {
2251
+ if (currentVisible && tooltipRef.current && triggerRef.current) {
2252
+ const bubbleEl = tooltipRef.current;
2253
+ const triggerEl = triggerRef.current;
2254
+ const { width: bubbleWidth, height: bubbleHeight } = bubbleEl.getBoundingClientRect();
2255
+ const { top: triggerTop, left: triggerLeft, width: triggerWidth, height: triggerHeight } = triggerEl.getBoundingClientRect();
2256
+ const { innerWidth, innerHeight } = window;
2257
+ const margin = 8;
2258
+ let finalTop;
2259
+ let finalLeft = triggerLeft + triggerWidth / 2 - bubbleWidth / 2;
2260
+ let finalPlacement = "bottom";
2261
+ if (finalLeft < margin) {
2262
+ finalLeft = margin;
2263
+ }
2264
+ if (finalLeft + bubbleWidth > innerWidth - margin) {
2265
+ finalLeft = innerWidth - bubbleWidth - margin;
2266
+ }
2267
+ finalTop = triggerTop + triggerHeight + margin;
2268
+ if (finalTop + bubbleHeight > innerHeight - margin) {
2269
+ finalPlacement = "top";
2270
+ finalTop = triggerTop - bubbleHeight - margin;
2271
+ }
2272
+ if (finalTop < margin) {
2273
+ finalPlacement = "bottom";
2274
+ finalTop = triggerTop + triggerHeight + margin;
2275
+ }
2276
+ const arrowLeft = triggerLeft + triggerWidth / 2 - finalLeft;
2277
+ setCurrentPlacement(finalPlacement);
2278
+ setComputedStyle({
2279
+ top: `${finalTop}px`,
2280
+ left: `${finalLeft}px`,
2281
+ "--wz-tooltip-arrow-left": `${arrowLeft}px`
2282
+ });
2283
+ }
2284
+ }, [currentVisible]);
2285
+ const handleWrapperClick = () => {
2286
+ if (trigger === "click") {
2287
+ handleVisibleChange(!currentVisible);
2288
+ }
2289
+ };
2290
+ const handleClose = (e) => {
2291
+ e.stopPropagation();
2292
+ handleVisibleChange(false);
2293
+ };
2294
+ const classes = classNames("wz-tooltip-bubble", `wz-tooltip-bubble--placement-${currentPlacement}`, className);
2295
+ const bubbleStyle = {
2296
+ ...style,
2297
+ ...computedStyle,
2298
+ opacity: computedStyle.top ? 1 : 0,
2299
+ transition: "opacity 150ms ease-in",
2300
+ "--wz-tooltip-bubble-bg": color,
2301
+ color: textColor
2302
+ };
2303
+ const renderBubble = () => {
2304
+ if (!currentVisible) return null;
2305
+ const renderAction = () => {
2306
+ if (!action) return null;
2307
+ const originalOnClick = action.props.onClick;
2308
+ const newOnClick = (e) => {
2309
+ originalOnClick == null ? void 0 : originalOnClick(e);
2310
+ handleVisibleChange(false);
2311
+ };
2312
+ return /* @__PURE__ */ jsx("div", { className: "wz-tooltip-bubble__action-slot", children: React.cloneElement(action, { onClick: newOnClick }) });
2313
+ };
2314
+ const renderCloseIcon = () => {
2315
+ if (!closeIcon) return null;
2316
+ return /* @__PURE__ */ jsx("div", { className: "wz-tooltip-bubble__close-slot", children: React.cloneElement(closeIcon, { onClick: handleClose }) });
2317
+ };
2318
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2319
+ showMask && /* @__PURE__ */ jsx("div", { className: "wz-tooltip-mask", onClick: handleClose }),
2320
+ /* @__PURE__ */ jsxs("div", { className: classes, style: bubbleStyle, ref: tooltipRef, children: [
2321
+ /* @__PURE__ */ jsx("div", { className: "wz-tooltip-bubble__arrow" }),
2322
+ /* @__PURE__ */ jsxs("div", { className: "wz-tooltip-bubble__inner", children: [
2323
+ /* @__PURE__ */ jsx("div", { className: "wz-tooltip-bubble__body", children: content }),
2324
+ renderAction(),
2325
+ renderCloseIcon()
2326
+ ] })
2327
+ ] })
2328
+ ] });
2329
+ };
2330
+ const triggerProps = {
2331
+ onClick: handleWrapperClick,
2332
+ ref: triggerRef
2333
+ };
2334
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2335
+ React.cloneElement(children, triggerProps),
2336
+ renderBubble()
2337
+ ] });
2338
+ };
2339
+ const Dialog$1 = ({
2340
+ visible,
2341
+ title,
2342
+ content,
2343
+ onClose,
2344
+ actions,
2345
+ closeOnAction,
2346
+ closeOnMaskClick
2347
+ }) => {
2348
+ const onMaskClick = () => {
2349
+ if (closeOnMaskClick) {
2350
+ onClose == null ? void 0 : onClose();
2351
+ }
2352
+ };
2353
+ const onActionClick = (onClick) => {
2354
+ onClick == null ? void 0 : onClick();
2355
+ if (closeOnAction) {
2356
+ onClose == null ? void 0 : onClose();
2357
+ }
2358
+ };
2359
+ return /* @__PURE__ */ jsxs("div", { className: classNames("wz-dialog-root", { visible }), children: [
2360
+ /* @__PURE__ */ jsx("div", { className: "wz-dialog-mask", onClick: onMaskClick }),
2361
+ /* @__PURE__ */ jsxs("div", { className: "wz-dialog-wrap", children: [
2362
+ title && /* @__PURE__ */ jsx("div", { className: "wz-dialog-header", children: /* @__PURE__ */ jsx("div", { className: "wz-dialog-title", children: title }) }),
2363
+ /* @__PURE__ */ jsx("div", { className: "wz-dialog-content", children: content }),
2364
+ /* @__PURE__ */ jsx("div", { className: "wz-dialog-footer", children: actions == null ? void 0 : actions.map((action) => /* @__PURE__ */ jsx(
2365
+ Button,
2366
+ {
2367
+ className: "wz-dialog-button",
2368
+ onClick: () => onActionClick(action.onClick),
2369
+ children: action.text
2370
+ },
2371
+ action.key
2372
+ )) })
2373
+ ] })
2374
+ ] });
2375
+ };
2376
+ const renderDialog = (props) => {
2377
+ const container2 = document.createElement("div");
2378
+ document.body.appendChild(container2);
2379
+ const root2 = createRoot(container2);
2380
+ const unmount = () => {
2381
+ root2.unmount();
2382
+ document.body.removeChild(container2);
2383
+ };
2384
+ root2.render(/* @__PURE__ */ jsx(Dialog$1, { ...props, visible: true, onClose: unmount }));
2385
+ };
2386
+ const alert = (props) => {
2387
+ renderDialog({
2388
+ ...props,
2389
+ closeOnAction: true,
2390
+ actions: [
2391
+ {
2392
+ key: "confirm",
2393
+ text: "确定",
2394
+ onClick: props.onConfirm
2395
+ }
2396
+ ]
2397
+ });
2398
+ };
2399
+ const confirm = (props) => {
2400
+ renderDialog({
2401
+ ...props,
2402
+ closeOnAction: true,
2403
+ actions: [
2404
+ {
2405
+ key: "cancel",
2406
+ text: "取消",
2407
+ onClick: props.onCancel
2408
+ },
2409
+ {
2410
+ key: "confirm",
2411
+ text: "确定",
2412
+ onClick: props.onConfirm
2413
+ }
2414
+ ]
2415
+ });
2416
+ };
2417
+ const Dialog = Object.assign(Dialog$1, { alert, confirm });
2418
+ export {
2419
+ Button,
2420
+ Card,
2421
+ Cascader,
2422
+ Cell,
2423
+ CheckList,
2424
+ Checkbox,
2425
+ Collapse,
2426
+ DatePicker,
2427
+ DateRangePicker,
2428
+ Dialog,
2429
+ Divider,
2430
+ DropdownMenu,
2431
+ Flex,
2432
+ Grid,
2433
+ GridView,
2434
+ Icon,
2435
+ Input,
2436
+ NavBar,
2437
+ Popup,
2438
+ Radio,
2439
+ Search,
2440
+ Stepper,
2441
+ Switch,
2442
+ Tabbar,
2443
+ Tabs,
2444
+ Tag,
2445
+ TimePicker,
2446
+ Tip,
2447
+ Toast,
2448
+ Tooltip
2449
+ };