@tendaui/components 1.2.4 → 1.3.1

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 (309) hide show
  1. package/_util/scroll.ts +9 -0
  2. package/alert/_example/base.tsx +13 -0
  3. package/alert/_example/collapse.tsx +15 -0
  4. package/badge/_example/base.tsx +10 -0
  5. package/badge/_example/count.tsx +29 -0
  6. package/badge/_example/custom-color.tsx +32 -0
  7. package/badge/_example/dot.tsx +26 -0
  8. package/badge/_example/max-count.tsx +26 -0
  9. package/badge/_example/offset.tsx +29 -0
  10. package/badge/_example/shape.tsx +32 -0
  11. package/badge/_example/show-zero.tsx +23 -0
  12. package/badge/_example/size.tsx +35 -0
  13. package/badge/_example/standalone.tsx +14 -0
  14. package/badge/_example/text-count.tsx +26 -0
  15. package/badge/_example/with-button.tsx +23 -0
  16. package/button/_example/block.tsx +18 -0
  17. package/button/_example/disabled.tsx +22 -0
  18. package/button/_example/ghost.tsx +21 -0
  19. package/button/_example/link.tsx +15 -0
  20. package/button/_example/loading.tsx +19 -0
  21. package/button/_example/shape.tsx +18 -0
  22. package/button/_example/size.tsx +18 -0
  23. package/button/_example/suffix.tsx +16 -0
  24. package/button/_example/theme.tsx +14 -0
  25. package/button/_example/variant-base.tsx +24 -0
  26. package/button/_example/variant-dashed.tsx +24 -0
  27. package/button/_example/variant-outline.tsx +24 -0
  28. package/button/_example/variant-text.tsx +24 -0
  29. package/checkbox/_example/base.tsx +8 -0
  30. package/checkbox/_example/controlled.tsx +11 -0
  31. package/checkbox/_example/group-disabled.tsx +13 -0
  32. package/checkbox/_example/group-with-check-all.tsx +22 -0
  33. package/checkbox/_example/group-with-max.tsx +17 -0
  34. package/checkbox/_example/group-with-options.tsx +18 -0
  35. package/checkbox/_example/group.tsx +17 -0
  36. package/checkbox/_example/states.tsx +19 -0
  37. package/color-picker/ColorPicker.tsx +16 -2
  38. package/color-picker/_example/base.tsx +12 -0
  39. package/color-picker/_example/borderless.tsx +17 -0
  40. package/color-picker/_example/clearable.tsx +12 -0
  41. package/color-picker/_example/disabled.tsx +17 -0
  42. package/color-picker/_example/formats.tsx +30 -0
  43. package/color-picker/_example/manual-input.tsx +39 -0
  44. package/color-picker/_example/recent-colors.tsx +19 -0
  45. package/color-picker/_example/swatch-colors.tsx +28 -0
  46. package/color-picker/_example/with-alpha.tsx +21 -0
  47. package/color-picker/components/panel/format/inputs.tsx +1 -1
  48. package/color-picker/components/panel/index.tsx +13 -0
  49. package/color-picker/components/trigger.tsx +64 -13
  50. package/color-picker/defaultProps.ts +4 -1
  51. package/color-picker/utils/color-picker/cmyk.ts +5 -5
  52. package/color-picker/utils/color-picker/draggable.ts +14 -15
  53. package/color-picker/utils/color-picker/format.ts +21 -26
  54. package/color-picker/utils/color-picker/gradient.ts +35 -41
  55. package/color-picker/utils/color-picker/types.ts +4 -4
  56. package/config-provider/ConfigContext.tsx +1 -0
  57. package/config-provider/ConfigProvider.tsx +18 -1
  58. package/config-provider/type.ts +5 -0
  59. package/dialog/_example/base.tsx +27 -0
  60. package/dialog/_example/confirm-loading.tsx +32 -0
  61. package/dialog/_example/custom-buttons.tsx +24 -0
  62. package/dialog/_example/full-screen.tsx +26 -0
  63. package/dialog/_example/hide-buttons.tsx +39 -0
  64. package/dialog/_example/modeless.tsx +25 -0
  65. package/dialog/_example/placement.tsx +40 -0
  66. package/dialog/_example/plugin-example.tsx +69 -0
  67. package/dialog/_example/themes.tsx +41 -0
  68. package/drawer/Drawer.tsx +17 -9
  69. package/drawer/_example/custom-header-footer.tsx +29 -0
  70. package/drawer/_example/default.tsx +20 -0
  71. package/drawer/_example/events.tsx +53 -0
  72. package/drawer/_example/no-footer.tsx +20 -0
  73. package/drawer/_example/no-overlay.tsx +20 -0
  74. package/drawer/_example/placement.tsx +43 -0
  75. package/drawer/_example/size-draggable.tsx +26 -0
  76. package/drawer/_example/size.tsx +40 -0
  77. package/drawer/defaultProps.ts +1 -1
  78. package/fireworks/Fireworks.tsx +1 -10
  79. package/fireworks/index.ts +0 -1
  80. package/fireworks/type.ts +0 -1
  81. package/form/_example/complex.tsx +76 -0
  82. package/form/_example/default.tsx +58 -0
  83. package/form/_example/disabled.tsx +26 -0
  84. package/form/_example/form-list.tsx +74 -0
  85. package/form/_example/inline-layout.tsx +20 -0
  86. package/form/_example/label-align.tsx +46 -0
  87. package/form/_example/methods.tsx +66 -0
  88. package/form/_example/validation.tsx +71 -0
  89. package/form/hooks/useFormItemStyle.tsx +19 -7
  90. package/form/index.ts +20 -2
  91. package/global-config/default-config.ts +28 -28
  92. package/global-config/locale/ar_KW.ts +176 -187
  93. package/global-config/locale/en_US.ts +180 -195
  94. package/global-config/locale/it_IT.ts +174 -197
  95. package/global-config/locale/ja_JP.ts +178 -193
  96. package/global-config/locale/ko_KR.ts +178 -193
  97. package/global-config/locale/ru_RU.ts +189 -200
  98. package/global-config/locale/zh_CN.ts +179 -193
  99. package/global-config/locale/zh_TW.ts +178 -192
  100. package/global-config/mobile/default-config.ts +3 -3
  101. package/global-config/mobile/locale/ar_KW.ts +76 -77
  102. package/global-config/mobile/locale/en_US.ts +76 -77
  103. package/global-config/mobile/locale/it_IT.ts +76 -77
  104. package/global-config/mobile/locale/ja_JP.ts +64 -65
  105. package/global-config/mobile/locale/ko_KR.ts +64 -65
  106. package/global-config/mobile/locale/ru_RU.ts +76 -77
  107. package/global-config/mobile/locale/zh_CN.ts +64 -65
  108. package/global-config/mobile/locale/zh_TW.ts +64 -65
  109. package/global-config/t.ts +12 -12
  110. package/hooks/useDebounce.ts +27 -0
  111. package/hooks/useLastest.ts +6 -2
  112. package/hooks/useResizeObserve.ts +0 -1
  113. package/index.ts +1 -1
  114. package/input/Input.tsx +53 -10
  115. package/input/_example/auto-width.tsx +14 -0
  116. package/input/_example/borderless.tsx +17 -0
  117. package/input/_example/clearable.tsx +14 -0
  118. package/input/_example/default.tsx +10 -0
  119. package/input/_example/disabled-readonly.tsx +12 -0
  120. package/input/_example/events.tsx +42 -0
  121. package/input/_example/group.tsx +14 -0
  122. package/input/_example/label-suffix.tsx +12 -0
  123. package/input/_example/max-length.tsx +11 -0
  124. package/input/_example/password.tsx +14 -0
  125. package/input/_example/sizes.tsx +12 -0
  126. package/input/_example/status.tsx +13 -0
  127. package/input/_example/text-align.tsx +12 -0
  128. package/input/_example/with-icon.tsx +13 -0
  129. package/input/type.ts +3 -0
  130. package/input/useLengthLimit.ts +122 -0
  131. package/input-number/_example/align.tsx +23 -0
  132. package/input-number/_example/auto-width.tsx +8 -0
  133. package/input-number/_example/default.tsx +8 -0
  134. package/input-number/_example/events.tsx +45 -0
  135. package/input-number/_example/format.tsx +27 -0
  136. package/input-number/_example/large-number.tsx +17 -0
  137. package/input-number/_example/min-max.tsx +14 -0
  138. package/input-number/_example/sizes.tsx +35 -0
  139. package/input-number/_example/status.tsx +65 -0
  140. package/input-number/_example/step-and-decimal.tsx +14 -0
  141. package/input-number/_example/themes.tsx +21 -0
  142. package/input-number/_example/with-suffix.tsx +12 -0
  143. package/ip-input/_example/controlled.tsx +26 -0
  144. package/ip-input/_example/default.tsx +12 -0
  145. package/ip-input/_example/full-featured.tsx +32 -0
  146. package/ip-input/_example/ipv6.tsx +23 -0
  147. package/ip-input/_example/keyboard-navigation.tsx +19 -0
  148. package/ip-input/_example/paste-demo.tsx +23 -0
  149. package/ip-input/_example/states.tsx +21 -0
  150. package/ip-input/_example/with-cidr.tsx +23 -0
  151. package/layout/_example/combine-left.tsx +54 -0
  152. package/layout/_example/combine-right.tsx +54 -0
  153. package/layout/_example/custom-aside-width.tsx +56 -0
  154. package/layout/_example/custom-height.tsx +45 -0
  155. package/layout/_example/double-sidebar.tsx +57 -0
  156. package/layout/_example/side-navigation-right.tsx +51 -0
  157. package/layout/_example/side-navigation.tsx +51 -0
  158. package/layout/_example/top-navigation.tsx +41 -0
  159. package/list/_example/async-loading.tsx +46 -0
  160. package/list/_example/default.tsx +23 -0
  161. package/list/_example/header-footer.tsx +40 -0
  162. package/list/_example/multiline.tsx +24 -0
  163. package/list/_example/scroll-loading.tsx +69 -0
  164. package/list/_example/sizes.tsx +45 -0
  165. package/list/_example/split.tsx +36 -0
  166. package/list/_example/stripe.tsx +24 -0
  167. package/list/_example/virtual-scroll.tsx +51 -0
  168. package/list/_example/with-image.tsx +26 -0
  169. package/loading/_example/default.tsx +6 -0
  170. package/loading/_example/delay.tsx +53 -0
  171. package/loading/_example/fullscreen.tsx +29 -0
  172. package/loading/_example/inherit-color.tsx +24 -0
  173. package/loading/_example/no-overlay.tsx +15 -0
  174. package/loading/_example/sizes.tsx +25 -0
  175. package/loading/_example/with-text.tsx +12 -0
  176. package/loading/_example/wrapper.tsx +30 -0
  177. package/notification/_example/default.tsx +31 -0
  178. package/notification/_example/long-content.tsx +37 -0
  179. package/notification/_example/stacking.tsx +40 -0
  180. package/notification/_example/types.tsx +78 -0
  181. package/notification/_example/usage-example.tsx +62 -0
  182. package/package.json +4 -3
  183. package/popup/Popup.tsx +17 -5
  184. package/popup/_example/controlled.tsx +32 -0
  185. package/popup/_example/custom-content.tsx +64 -0
  186. package/popup/_example/default.tsx +19 -0
  187. package/popup/_example/delay.tsx +35 -0
  188. package/popup/_example/disabled.tsx +17 -0
  189. package/popup/_example/no-arrow.tsx +17 -0
  190. package/popup/_example/placements.tsx +61 -0
  191. package/popup/_example/triggers.tsx +26 -0
  192. package/radio/_example/allow-uncheck.tsx +19 -0
  193. package/radio/_example/button-style.tsx +40 -0
  194. package/radio/_example/controlled.tsx +13 -0
  195. package/radio/_example/default.tsx +13 -0
  196. package/radio/_example/group-disabled.tsx +22 -0
  197. package/radio/_example/group-with-options.tsx +20 -0
  198. package/radio/_example/group.tsx +19 -0
  199. package/radio/_example/sizes.tsx +37 -0
  200. package/radio/_example/states.tsx +20 -0
  201. package/select/_example/collapsed.tsx +30 -0
  202. package/select/_example/creatable.tsx +36 -0
  203. package/select/_example/custom-content.tsx +26 -0
  204. package/select/_example/default.tsx +29 -0
  205. package/select/_example/disabled.tsx +20 -0
  206. package/select/_example/filterable.tsx +27 -0
  207. package/select/_example/group-options.tsx +44 -0
  208. package/select/_example/label-suffix.tsx +24 -0
  209. package/select/_example/loading.tsx +19 -0
  210. package/select/_example/multiple.tsx +31 -0
  211. package/select/_example/sizes.tsx +20 -0
  212. package/select/_example/status.tsx +27 -0
  213. package/slider/Slider.tsx +13 -5
  214. package/slider/_example/custom-label.tsx +19 -0
  215. package/slider/_example/default.tsx +14 -0
  216. package/slider/_example/disabled.tsx +17 -0
  217. package/slider/_example/marks.tsx +31 -0
  218. package/slider/_example/range.tsx +16 -0
  219. package/slider/_example/step.tsx +14 -0
  220. package/slider/_example/vertical.tsx +26 -0
  221. package/slider/_example/with-input-number.tsx +21 -0
  222. package/slider/type.ts +1 -1
  223. package/styles/_vars.scss +16 -0
  224. package/styles/components/button/_index.scss +3 -3
  225. package/styles/components/dialog/_index.scss +18 -20
  226. package/styles/components/drawer/_index.scss +4 -3
  227. package/styles/components/drawer/_var.scss +1 -1
  228. package/styles/components/form/_index.scss +7 -6
  229. package/styles/components/input/_mixins.scss +7 -5
  230. package/styles/components/input-number/_index.scss +13 -12
  231. package/styles/components/list/_index.scss +5 -5
  232. package/styles/components/notification/_index.scss +4 -4
  233. package/styles/components/slider/_index.scss +8 -8
  234. package/styles/components/switch/_index.scss +98 -15
  235. package/styles/components/table/_index.scss +37 -29
  236. package/styles/components/tabs/_index.scss +8 -9
  237. package/styles/components/tooltip/_index.scss +104 -0
  238. package/styles/components/tooltip/_vars.scss +23 -0
  239. package/switch/_example/async-change.tsx +25 -0
  240. package/switch/_example/before-change.tsx +22 -0
  241. package/switch/_example/controlled.tsx +14 -0
  242. package/switch/_example/custom-value.tsx +21 -0
  243. package/switch/_example/default.tsx +6 -0
  244. package/switch/_example/disabled.tsx +25 -0
  245. package/switch/_example/loading.tsx +17 -0
  246. package/switch/_example/sizes.tsx +21 -0
  247. package/switch/_example/with-label.tsx +21 -0
  248. package/tab/TabPanel.tsx +9 -6
  249. package/tab/_example/addable.tsx +45 -0
  250. package/tab/_example/card-theme.tsx +22 -0
  251. package/tab/_example/default.tsx +22 -0
  252. package/tab/_example/disabled.tsx +38 -0
  253. package/tab/_example/lazy.tsx +25 -0
  254. package/tab/_example/placement.tsx +36 -0
  255. package/tab/_example/removable.tsx +31 -0
  256. package/tab/_example/sizes.tsx +31 -0
  257. package/tab/_example/with-action.tsx +26 -0
  258. package/table/Cell.tsx +3 -6
  259. package/table/Ellipsis.tsx +73 -0
  260. package/table/_example/alignment.tsx +46 -0
  261. package/table/_example/auto-width.tsx +47 -0
  262. package/table/_example/bordered-stripe-hover.tsx +42 -0
  263. package/table/_example/bordered.tsx +42 -0
  264. package/table/_example/cell-click.tsx +52 -0
  265. package/table/_example/complex.tsx +82 -0
  266. package/table/_example/custom-cell.tsx +68 -0
  267. package/table/_example/custom-empty.tsx +37 -0
  268. package/table/_example/custom-row-class-name.tsx +57 -0
  269. package/table/_example/default.tsx +42 -0
  270. package/table/_example/ellipsis.tsx +56 -0
  271. package/table/_example/empty.tsx +28 -0
  272. package/table/_example/fixed-width.tsx +48 -0
  273. package/table/_example/hover.tsx +42 -0
  274. package/table/_example/row-click.tsx +52 -0
  275. package/table/_example/sizes.tsx +57 -0
  276. package/table/_example/stripe.tsx +42 -0
  277. package/table/_example/vertical-align.tsx +110 -0
  278. package/table/hooks/useTableClassName.ts +3 -3
  279. package/table/index.ts +2 -0
  280. package/table/type.ts +1 -0
  281. package/tag/Tag.tsx +1 -1
  282. package/tag/_example/closable.tsx +44 -0
  283. package/tag/_example/default.tsx +17 -0
  284. package/tag/_example/disabled.tsx +19 -0
  285. package/tag/_example/sizes.tsx +18 -0
  286. package/tag/_example/variants.tsx +37 -0
  287. package/tag-input/_example/collapsed.tsx +27 -0
  288. package/tag-input/_example/controlled-uncontrolled.tsx +26 -0
  289. package/tag-input/_example/default.tsx +15 -0
  290. package/tag-input/_example/disabled-readonly.tsx +21 -0
  291. package/tag-input/_example/events.tsx +64 -0
  292. package/tag-input/_example/excess-display.tsx +27 -0
  293. package/tag-input/_example/max-tags.tsx +22 -0
  294. package/tag-input/_example/sizes.tsx +21 -0
  295. package/tag-input/_example/status.tsx +37 -0
  296. package/tag-input/_example/with-label.tsx +23 -0
  297. package/tag-input/hooks/useTagList.tsx +1 -1
  298. package/tooltip/Tooltip.tsx +76 -0
  299. package/tooltip/_example/base.tsx +26 -0
  300. package/tooltip/_example/custom-content.tsx +47 -0
  301. package/tooltip/_example/placement.tsx +33 -0
  302. package/tooltip/_example/theme.tsx +34 -0
  303. package/tooltip/defaultProps.ts +14 -0
  304. package/tooltip/index.ts +7 -0
  305. package/tooltip/style/index.js +1 -0
  306. package/tooltip/type.ts +99 -0
  307. package/utils/log/index.ts +1 -1
  308. package/utils/log/log.ts +2 -3
  309. package/utils/log/types.ts +1 -4
@@ -0,0 +1,41 @@
1
+ import React, { useState } from "react";
2
+ import { Button, Dialog } from "@tendaui/react";
3
+
4
+ export default function Themes() {
5
+ const [visible, setVisible] = useState(false);
6
+ const [theme, setTheme] = useState("default");
7
+
8
+ const openDialog = (t) => {
9
+ setTheme(t);
10
+ setVisible(true);
11
+ };
12
+
13
+ return (
14
+ <>
15
+ <div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
16
+ <Button onClick={() => openDialog("default")}>默认</Button>
17
+ <Button theme="primary" onClick={() => openDialog("info")}>
18
+ 信息
19
+ </Button>
20
+ <Button theme="success" onClick={() => openDialog("success")}>
21
+ 成功
22
+ </Button>
23
+ <Button theme="warning" onClick={() => openDialog("warning")}>
24
+ 警告
25
+ </Button>
26
+ <Button theme="danger" onClick={() => openDialog("danger")}>
27
+ 危险
28
+ </Button>
29
+ </div>
30
+ <Dialog
31
+ header={`${theme} 主题对话框`}
32
+ theme={theme}
33
+ visible={visible}
34
+ onClose={() => setVisible(false)}
35
+ onConfirm={() => setVisible(false)}
36
+ >
37
+ <p>这是 {theme} 主题的对话框。</p>
38
+ </Dialog>
39
+ </>
40
+ );
41
+ }
package/drawer/Drawer.tsx CHANGED
@@ -73,7 +73,7 @@ const Drawer = forwardRef<DrawerInstance, DrawerProps>((originalProps, ref) => {
73
73
  } = state;
74
74
 
75
75
  const size = propsSize;
76
- const { classPrefix } = useConfig();
76
+ const { classPrefix, direction } = useConfig();
77
77
  const drawerAttach = useAttach("drawer", attach);
78
78
  const maskRef = useRef<HTMLDivElement>(null);
79
79
  const containerRef = useRef<HTMLDivElement>(null);
@@ -81,8 +81,16 @@ const Drawer = forwardRef<DrawerInstance, DrawerProps>((originalProps, ref) => {
81
81
  const prefixCls = `${classPrefix}-drawer`;
82
82
 
83
83
  const closeIcon = isValidElement(closeBtn) ? closeBtn : <CloseIcon />;
84
+ const isRtl = direction === "rtl";
85
+ const actualPlacement = useMemo(() => {
86
+ if (!isRtl) return placement;
87
+ if (placement === "left") return "right";
88
+ if (placement === "right") return "left";
89
+ return placement;
90
+ }, [isRtl, placement]);
91
+
84
92
  const { dragSizeValue, enableDrag, draggableLineStyles, draggingStyles } = useDrag(
85
- placement,
93
+ actualPlacement,
86
94
  sizeDraggable,
87
95
  onSizeDragEnd
88
96
  );
@@ -147,10 +155,10 @@ const Drawer = forwardRef<DrawerInstance, DrawerProps>((originalProps, ref) => {
147
155
  const contentWrapperStyle = useMemo(
148
156
  () => ({
149
157
  transform: visible && animationStart ? "translateX(0)" : undefined,
150
- width: ["left", "right"].includes(placement) ? sizeValue : "",
151
- height: ["top", "bottom"].includes(placement) ? sizeValue : ""
158
+ width: ["left", "right"].includes(actualPlacement) ? sizeValue : "",
159
+ height: ["top", "bottom"].includes(actualPlacement) ? sizeValue : ""
152
160
  }),
153
- [visible, placement, sizeValue, animationStart]
161
+ [visible, actualPlacement, sizeValue, animationStart]
154
162
  );
155
163
 
156
164
  const renderDrawerButton = (btn: DrawerProps["cancelBtn"], defaultProps: ButtonProps) => {
@@ -184,12 +192,12 @@ const Drawer = forwardRef<DrawerInstance, DrawerProps>((originalProps, ref) => {
184
192
 
185
193
  const footerStyle = {
186
194
  display: "flex",
187
- justifyContent: placement === "right" ? "flex-start" : "flex-end"
195
+ justifyContent: actualPlacement === "right" ? "flex-start" : "flex-end"
188
196
  };
189
197
 
190
198
  return (
191
199
  <div style={footerStyle}>
192
- {placement === "right" ? (
200
+ {actualPlacement === "right" ? (
193
201
  <>
194
202
  {renderConfirmBtn} {renderCancelBtn}
195
203
  </>
@@ -233,7 +241,7 @@ const Drawer = forwardRef<DrawerInstance, DrawerProps>((originalProps, ref) => {
233
241
  <Portal attach={drawerAttach} ref={drawerWrapperRef}>
234
242
  <div
235
243
  ref={containerRef}
236
- className={classnames(prefixCls, className, `${prefixCls}--${placement}`, {
244
+ className={classnames(prefixCls, className, `${prefixCls}--${actualPlacement}`, {
237
245
  [`${prefixCls}--open`]: visible,
238
246
  [`${prefixCls}--attach`]: showInAttachedElement,
239
247
  [`${prefixCls}--without-mask`]: !showOverlay
@@ -244,7 +252,7 @@ const Drawer = forwardRef<DrawerInstance, DrawerProps>((originalProps, ref) => {
244
252
  >
245
253
  {renderOverlay}
246
254
  <div
247
- className={classnames(`${prefixCls}__content-wrapper`, `${prefixCls}__content-wrapper--${placement}`)}
255
+ className={classnames(`${prefixCls}__content-wrapper`, `${prefixCls}__content-wrapper--${actualPlacement}`)}
248
256
  style={{ ...contentWrapperStyle, ...draggingStyles }}
249
257
  >
250
258
  {renderCloseBtn}
@@ -0,0 +1,29 @@
1
+ import React, { useState } from "react";
2
+ import Drawer from "../index";
3
+ import { Button } from "../../button";
4
+
5
+ const CustomDrawer = () => {
6
+ const [visible, setVisible] = useState(false);
7
+ return (
8
+ <>
9
+ <Button theme="primary" onClick={() => setVisible(true)}>
10
+ 自定义头部和底部
11
+ </Button>
12
+ <Drawer
13
+ header={<h3 style={{ color: "var(--td-brand-color)", margin: 0 }}>自定义标题</h3>}
14
+ visible={visible}
15
+ onClose={() => setVisible(false)}
16
+ confirmBtn={{ content: "保存", theme: "primary" }}
17
+ cancelBtn={{ content: "取消", variant: "outline" }}
18
+ onConfirm={() => {
19
+ console.log("保存");
20
+ setVisible(false);
21
+ }}
22
+ >
23
+ <p>抽屉内容区域</p>
24
+ </Drawer>
25
+ </>
26
+ );
27
+ };
28
+
29
+ export default CustomDrawer;
@@ -0,0 +1,20 @@
1
+ import React, { useState } from "react";
2
+ import Drawer from "../index";
3
+ import { Button } from "../../button";
4
+
5
+ const BaseDrawer = () => {
6
+ const [visible, setVisible] = useState(false);
7
+ return (
8
+ <>
9
+ <Button theme="primary" onClick={() => setVisible(true)}>
10
+ 打开抽屉
11
+ </Button>
12
+ <Drawer header="基础抽屉" visible={visible} onClose={() => setVisible(false)}>
13
+ <p>这是抽屉内容。</p>
14
+ <p>点击遮罩层或右上角关闭按钮可关闭抽屉。</p>
15
+ </Drawer>
16
+ </>
17
+ );
18
+ };
19
+
20
+ export default BaseDrawer;
@@ -0,0 +1,53 @@
1
+ import React, { useState } from "react";
2
+ import Drawer from "../index";
3
+ import { Button } from "../../button";
4
+ import type { TdDrawerProps } from "../type";
5
+
6
+ const EventsDrawer = () => {
7
+ const [visible, setVisible] = useState(false);
8
+
9
+ const handleBeforeOpen = () => {
10
+ console.log("抽屉打开前");
11
+ };
12
+
13
+ const handleBeforeClose = () => {
14
+ console.log("抽屉关闭前");
15
+ };
16
+
17
+ const handleClose: TdDrawerProps["onClose"] = (context) => {
18
+ console.log("抽屉关闭,触发来源:", context.trigger);
19
+ setVisible(false);
20
+ };
21
+
22
+ const handleConfirm = () => {
23
+ console.log("点击确认按钮");
24
+ setVisible(false);
25
+ };
26
+
27
+ const handleCancel = () => {
28
+ console.log("点击取消按钮");
29
+ setVisible(false);
30
+ };
31
+
32
+ return (
33
+ <>
34
+ <Button theme="primary" onClick={() => setVisible(true)}>
35
+ 打开抽屉(查看控制台)
36
+ </Button>
37
+ <Drawer
38
+ header="事件回调"
39
+ visible={visible}
40
+ onBeforeOpen={handleBeforeOpen}
41
+ onBeforeClose={handleBeforeClose}
42
+ onClose={handleClose}
43
+ onConfirm={handleConfirm}
44
+ onCancel={handleCancel}
45
+ >
46
+ <p>打开控制台查看各种事件的回调日志。</p>
47
+ <p>支持的事件:onBeforeOpen、onBeforeClose、onClose、onConfirm、onCancel 等</p>
48
+ </Drawer>
49
+ </>
50
+ );
51
+ };
52
+
53
+ export default EventsDrawer;
@@ -0,0 +1,20 @@
1
+ import React, { useState } from "react";
2
+ import Drawer from "../index";
3
+ import { Button } from "../../button";
4
+
5
+ const NoFooterDrawer = () => {
6
+ const [visible, setVisible] = useState(false);
7
+ return (
8
+ <>
9
+ <Button theme="primary" onClick={() => setVisible(true)}>
10
+ 无底部操作栏
11
+ </Button>
12
+ <Drawer header="无底部操作栏" footer={false} visible={visible} onClose={() => setVisible(false)}>
13
+ <p>这是一个没有底部操作栏的抽屉。</p>
14
+ <p>适合只展示内容的场景。</p>
15
+ </Drawer>
16
+ </>
17
+ );
18
+ };
19
+
20
+ export default NoFooterDrawer;
@@ -0,0 +1,20 @@
1
+ import React, { useState } from "react";
2
+ import Drawer from "../index";
3
+ import { Button } from "../../button";
4
+
5
+ const NoOverlayDrawer = () => {
6
+ const [visible, setVisible] = useState(false);
7
+ return (
8
+ <>
9
+ <Button theme="primary" onClick={() => setVisible(true)}>
10
+ 无遮罩层抽屉
11
+ </Button>
12
+ <Drawer header="无遮罩层" showOverlay={false} visible={visible} onClose={() => setVisible(false)}>
13
+ <p>这是一个没有遮罩层的抽屉。</p>
14
+ <p>可以与页面其他内容进行交互。</p>
15
+ </Drawer>
16
+ </>
17
+ );
18
+ };
19
+
20
+ export default NoOverlayDrawer;
@@ -0,0 +1,43 @@
1
+ import React, { useState } from "react";
2
+ import Drawer from "../index";
3
+ import { Button } from "../../button";
4
+ import type { TdDrawerProps } from "../type";
5
+
6
+ const PlacementDrawer = () => {
7
+ const [visible, setVisible] = useState(false);
8
+ const [placement, setPlacement] = useState<TdDrawerProps["placement"]>("right");
9
+
10
+ const openDrawer = (p: TdDrawerProps["placement"]) => {
11
+ setPlacement(p);
12
+ setVisible(true);
13
+ };
14
+
15
+ return (
16
+ <>
17
+ <div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
18
+ <Button theme="primary" onClick={() => openDrawer("left")}>
19
+ 从左侧打开
20
+ </Button>
21
+ <Button theme="primary" onClick={() => openDrawer("right")}>
22
+ 从右侧打开
23
+ </Button>
24
+ <Button theme="primary" onClick={() => openDrawer("top")}>
25
+ 从顶部打开
26
+ </Button>
27
+ <Button theme="primary" onClick={() => openDrawer("bottom")}>
28
+ 从底部打开
29
+ </Button>
30
+ </div>
31
+ <Drawer
32
+ header={`${placement} 方向抽屉`}
33
+ placement={placement}
34
+ visible={visible}
35
+ onClose={() => setVisible(false)}
36
+ >
37
+ <p>这是从 {placement} 方向滑出的抽屉。</p>
38
+ </Drawer>
39
+ </>
40
+ );
41
+ };
42
+
43
+ export default PlacementDrawer;
@@ -0,0 +1,26 @@
1
+ import React, { useState } from "react";
2
+ import Drawer from "../index";
3
+ import { Button } from "../../button";
4
+
5
+ const DraggableDrawer = () => {
6
+ const [visible, setVisible] = useState(false);
7
+ return (
8
+ <>
9
+ <Button theme="primary" onClick={() => setVisible(true)}>
10
+ 可拖拽大小的抽屉
11
+ </Button>
12
+ <Drawer
13
+ header="可拖拽调整大小"
14
+ visible={visible}
15
+ sizeDraggable={{ min: 200, max: 800 }}
16
+ onClose={() => setVisible(false)}
17
+ >
18
+ <p>拖动抽屉边缘可以调整宽度。</p>
19
+ <p>最小宽度: 200px</p>
20
+ <p>最大宽度: 800px</p>
21
+ </Drawer>
22
+ </>
23
+ );
24
+ };
25
+
26
+ export default DraggableDrawer;
@@ -0,0 +1,40 @@
1
+ import React, { useState } from "react";
2
+ import Drawer from "../index";
3
+ import { Button } from "../../button";
4
+
5
+ const SizeDrawer = () => {
6
+ const [visible, setVisible] = useState(false);
7
+ const [size, setSize] = useState("small");
8
+
9
+ const openDrawer = (s: string) => {
10
+ setSize(s);
11
+ setVisible(true);
12
+ };
13
+
14
+ return (
15
+ <>
16
+ <div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
17
+ <Button theme="primary" onClick={() => openDrawer("small")}>
18
+ 小尺寸
19
+ </Button>
20
+ <Button theme="primary" onClick={() => openDrawer("medium")}>
21
+ 中尺寸
22
+ </Button>
23
+ <Button theme="primary" onClick={() => openDrawer("large")}>
24
+ 大尺寸
25
+ </Button>
26
+ <Button theme="primary" onClick={() => openDrawer("60%")}>
27
+ 60% 宽度
28
+ </Button>
29
+ <Button theme="primary" onClick={() => openDrawer("500px")}>
30
+ 500px 宽度
31
+ </Button>
32
+ </div>
33
+ <Drawer header={`尺寸: ${size}`} size={size} visible={visible} onClose={() => setVisible(false)}>
34
+ <p>当前抽屉尺寸: {size}</p>
35
+ </Drawer>
36
+ </>
37
+ );
38
+ };
39
+
40
+ export default SizeDrawer;
@@ -13,7 +13,7 @@ export const drawerDefaultProps: TdDrawerProps = {
13
13
  preventScrollThrough: true,
14
14
  showInAttachedElement: false,
15
15
  showOverlay: true,
16
- size: undefined,
16
+ size: "medium",
17
17
  sizeDraggable: false,
18
18
  visible: false
19
19
  };
@@ -1,12 +1,4 @@
1
- import React, {
2
- CSSProperties,
3
- forwardRef,
4
- useCallback,
5
- useEffect,
6
- useMemo,
7
- useRef,
8
- useState
9
- } from "react";
1
+ import React, { CSSProperties, forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
10
2
  import classNames from "classnames";
11
3
 
12
4
  import useConfig from "../hooks/useConfig";
@@ -135,4 +127,3 @@ const Fireworks = forwardRef<HTMLDivElement, FireworksProps>((props, ref) => {
135
127
  Fireworks.displayName = "Fireworks";
136
128
 
137
129
  export default Fireworks;
138
-
@@ -7,4 +7,3 @@ export * from "./type";
7
7
 
8
8
  export const Fireworks = _Fireworks;
9
9
  export default Fireworks;
10
-
package/fireworks/type.ts CHANGED
@@ -69,4 +69,3 @@ export interface TdFireworksProps {
69
69
  */
70
70
  onLaunch?: (context: FireworksLaunchContext) => void;
71
71
  }
72
-
@@ -0,0 +1,76 @@
1
+ import React from "react";
2
+ import { Form, Input, Switch, Checkbox, Button, Select, Radio, FormItem } from "@tendaui/react";
3
+ import { NotificationProvider, useNotification } from "@tendaui/react/notification";
4
+
5
+ const { useForm } = Form;
6
+ const {} = Form;
7
+ const ComplexFormExample = () => {
8
+ const [form] = useForm();
9
+ const { success } = useNotification();
10
+
11
+ const onSubmit = (e: any) => {
12
+ if (e.validateResult === true) {
13
+ success({ title: "成功", message: "表单提交成功" });
14
+ console.log("表单数据:", e.fields);
15
+ }
16
+ };
17
+
18
+ return (
19
+ <div style={{ width: 500 }}>
20
+ <Form form={form} onSubmit={onSubmit} labelWidth={100}>
21
+ <FormItem label="姓名" name="name" requiredMark rules={[{ required: true, message: "请输入姓名" }]}>
22
+ <Input placeholder="请输入姓名" />
23
+ </FormItem>
24
+
25
+ <FormItem label="性别" name="gender">
26
+ <Radio.Group>
27
+ <Radio value="male">男</Radio>
28
+ <Radio value="female">女</Radio>
29
+ </Radio.Group>
30
+ </FormItem>
31
+
32
+ <FormItem label="城市" name="city">
33
+ <Select
34
+ placeholder="请选择城市"
35
+ options={[
36
+ { label: "北京", value: "beijing" },
37
+ { label: "上海", value: "shanghai" },
38
+ { label: "广州", value: "guangzhou" },
39
+ { label: "深圳", value: "shenzhen" }
40
+ ]}
41
+ />
42
+ </FormItem>
43
+
44
+ <FormItem label="爱好" name="hobbies">
45
+ <Checkbox.Group>
46
+ <Checkbox value="reading">阅读</Checkbox>
47
+ <Checkbox value="music">音乐</Checkbox>
48
+ <Checkbox value="sports">运动</Checkbox>
49
+ <Checkbox value="travel">旅游</Checkbox>
50
+ </Checkbox.Group>
51
+ </FormItem>
52
+
53
+ <FormItem label="订阅通知" name="subscribe">
54
+ <Switch />
55
+ </FormItem>
56
+
57
+ <FormItem style={{ marginInlineStart: 100 }}>
58
+ <div style={{ display: "flex", gap: "8px" }}>
59
+ <Button type="submit" theme="primary">
60
+ 提交
61
+ </Button>
62
+ <Button type="reset">重置</Button>
63
+ </div>
64
+ </FormItem>
65
+ </Form>
66
+ </div>
67
+ );
68
+ };
69
+
70
+ const FormExample = () => (
71
+ <NotificationProvider>
72
+ <ComplexFormExample />
73
+ </NotificationProvider>
74
+ );
75
+
76
+ export default FormExample;
@@ -0,0 +1,58 @@
1
+ import React from "react";
2
+ import { Form, Input, Switch, InputNumber, Button, FormItem } from "@tendaui/react";
3
+ import { NotificationProvider, useNotification } from "@tendaui/react/notification";
4
+
5
+ const BaseForm = () => {
6
+ const [form] = Form.useForm();
7
+ const { success } = useNotification();
8
+
9
+ const onSubmit = (e: any) => {
10
+ if (e.validateResult === true) {
11
+ success({ title: "成功提示", message: "提交成功" });
12
+ console.log("表单数据:", e.fields);
13
+ }
14
+ };
15
+
16
+ const onReset = () => {
17
+ success({ title: "成功提示", message: "重置成功" });
18
+ };
19
+
20
+ return (
21
+ <div style={{ width: 500 }}>
22
+ <Form form={form} onSubmit={onSubmit} onReset={onReset} colon labelWidth={100}>
23
+ <FormItem label="姓名" name="name" requiredMark rules={[{ required: true, message: "请输入姓名" }]}>
24
+ <Input placeholder="请输入姓名" />
25
+ </FormItem>
26
+
27
+ <FormItem label="邮箱" name="email" rules={[{ email: true, message: "请输入正确的邮箱" }]}>
28
+ <Input placeholder="请输入邮箱" />
29
+ </FormItem>
30
+
31
+ <FormItem label="年龄" name="age">
32
+ <InputNumber placeholder="请输入年龄" min={1} max={120} />
33
+ </FormItem>
34
+
35
+ <FormItem label="是否启用" name="enabled">
36
+ <Switch />
37
+ </FormItem>
38
+
39
+ <FormItem style={{ marginInlineStart: 100 }}>
40
+ <div style={{ display: "flex", gap: "8px" }}>
41
+ <Button type="submit" theme="primary">
42
+ 提交
43
+ </Button>
44
+ <Button type="reset">重置</Button>
45
+ </div>
46
+ </FormItem>
47
+ </Form>
48
+ </div>
49
+ );
50
+ };
51
+
52
+ const FormExample = () => (
53
+ <NotificationProvider>
54
+ <BaseForm />
55
+ </NotificationProvider>
56
+ );
57
+
58
+ export default FormExample;
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import { Form, Input, Switch, Select, FormItem } from "@tendaui/react";
3
+
4
+ const DisabledForm = () => (
5
+ <div style={{ width: 500 }}>
6
+ <Form disabled labelWidth={100} colon>
7
+ <FormItem label="用户名" name="username">
8
+ <Input placeholder="请输入用户名" defaultValue="admin" />
9
+ </FormItem>
10
+ <FormItem label="角色" name="role">
11
+ <Select
12
+ defaultValue="admin"
13
+ options={[
14
+ { label: "管理员", value: "admin" },
15
+ { label: "用户", value: "user" }
16
+ ]}
17
+ />
18
+ </FormItem>
19
+ <FormItem label="启用" name="enabled">
20
+ <Switch defaultValue={true} />
21
+ </FormItem>
22
+ </Form>
23
+ </div>
24
+ );
25
+
26
+ export default DisabledForm;
@@ -0,0 +1,74 @@
1
+ import React from "react";
2
+ import { Form, Input, Button, Select, FormItem, FormList } from "@tendaui/react";
3
+
4
+ const FormListExample = () => {
5
+ const [form] = Form.useForm();
6
+
7
+ const onSubmit = () => {
8
+ const allFields = form.getFieldsValue(true);
9
+ console.log("表单数据:", allFields);
10
+ };
11
+
12
+ const cityOptions = [
13
+ { label: "北京", value: "bj" },
14
+ { label: "上海", value: "sh" },
15
+ { label: "广州", value: "gz" },
16
+ { label: "深圳", value: "sz" }
17
+ ];
18
+
19
+ return (
20
+ <Form
21
+ form={form}
22
+ colon
23
+ onSubmit={onSubmit}
24
+ labelWidth={100}
25
+ initialData={{
26
+ address: [
27
+ { city: "bj", area: "海淀" },
28
+ { city: "sh", area: "浦东" }
29
+ ]
30
+ }}
31
+ >
32
+ <FormList name="address">
33
+ {(fields, { add, remove }) => (
34
+ <>
35
+ {fields.map(({ key, name, ...restField }, index) => (
36
+ <FormItem key={key} label={`地址 ${index + 1}`}>
37
+ <div style={{ display: "flex", gap: "8px", alignItems: "center" }}>
38
+ <FormItem
39
+ name={[name, "city"]}
40
+ rules={[{ required: true, message: "请选择城市" }]}
41
+ {...restField}
42
+ style={{ marginBottom: 0 }}
43
+ >
44
+ <Select options={cityOptions} placeholder="选择城市" style={{ width: "120px" }} />
45
+ </FormItem>
46
+ <FormItem name={[name, "area"]} {...restField} style={{ marginBottom: 0 }}>
47
+ <Input placeholder="详细地址" style={{ width: "200px" }} />
48
+ </FormItem>
49
+ {fields.length > 1 && (
50
+ <Button variant="text" theme="danger" onClick={() => remove(index)}>
51
+ 删除
52
+ </Button>
53
+ )}
54
+ </div>
55
+ </FormItem>
56
+ ))}
57
+ <FormItem style={{ marginLeft: 100 }}>
58
+ <Button variant="dashed" onClick={() => add({ city: "", area: "" })}>
59
+ + 添加地址
60
+ </Button>
61
+ </FormItem>
62
+ </>
63
+ )}
64
+ </FormList>
65
+ <FormItem style={{ marginLeft: 100 }}>
66
+ <Button type="submit" theme="primary">
67
+ 提交
68
+ </Button>
69
+ </FormItem>
70
+ </Form>
71
+ );
72
+ };
73
+
74
+ export default FormListExample;
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import { Form, Input, Button, FormItem } from "@tendaui/react";
3
+
4
+ const InlineLayoutForm = () => (
5
+ <Form layout="inline" labelWidth={60}>
6
+ <FormItem label="用户名" name="username">
7
+ <Input placeholder="用户名" style={{ width: "150px" }} />
8
+ </FormItem>
9
+ <FormItem label="密码" name="password">
10
+ <Input type="password" placeholder="密码" style={{ width: "150px" }} />
11
+ </FormItem>
12
+ <FormItem>
13
+ <Button theme="primary" type="submit">
14
+ 登录
15
+ </Button>
16
+ </FormItem>
17
+ </Form>
18
+ );
19
+
20
+ export default InlineLayoutForm;