@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
@@ -50,12 +50,12 @@
50
50
  overflow-wrap: break-word;
51
51
  background-color: inherit;
52
52
  box-sizing: border-box;
53
- text-align: left;
53
+ text-align: start;
54
54
  }
55
55
 
56
56
  // 对齐方式
57
57
  .#{$prefix}-align-left {
58
- text-align: left;
58
+ text-align: start;
59
59
  }
60
60
 
61
61
  .#{$prefix}-align-center {
@@ -63,7 +63,7 @@
63
63
  }
64
64
 
65
65
  .#{$prefix}-align-right {
66
- text-align: right;
66
+ text-align: end;
67
67
  }
68
68
 
69
69
  // 文本省略
@@ -76,25 +76,28 @@
76
76
  display: block;
77
77
  }
78
78
 
79
- // 当单元格启用省略�? &__cell--ellipsis {
80
- overflow: hidden;
81
- position: relative;
82
- max-width: 100%;
83
-
84
- // 确保内部内容不会超出
85
- & > div {
86
- width: 100%;
79
+ // 当单元格启用省略时
80
+ &__cell--ellipsis {
81
+ overflow: hidden;
82
+ position: relative;
87
83
  max-width: 100%;
88
- box-sizing: border-box;
84
+
85
+ // 确保内部内容不会超出
86
+ & > div {
87
+ width: 100%;
88
+ max-width: 100%;
89
+ box-sizing: border-box;
90
+ }
89
91
  }
92
+
90
93
  // 边框模式
91
94
  &--bordered {
92
95
  td,
93
96
  th {
94
- border-left: 1px solid $table-border-color;
97
+ border-inline-start: 1px solid $table-border-color;
95
98
 
96
99
  &:first-child {
97
- border-left-width: 0;
100
+ border-inline-start-width: 0;
98
101
  }
99
102
  }
100
103
 
@@ -104,9 +107,11 @@
104
107
  }
105
108
  }
106
109
 
107
- // 斑马�? &--stripe {
108
- tbody tr:nth-of-type(odd) {
109
- background-color: $table-highlight-bg-color;
110
+ // 斑马纹
111
+ &--stripe {
112
+ tbody tr:nth-of-type(odd) {
113
+ background-color: $table-highlight-bg-color;
114
+ }
110
115
  }
111
116
 
112
117
  // 悬浮效果
@@ -146,7 +151,8 @@
146
151
  &--layout-fixed {
147
152
  table-layout: fixed;
148
153
 
149
- // 固定布局下,省略文本需要特殊处�? td.#{$prefix}-table__cell--ellipsis,
154
+ // 固定布局下,省略文本需要特殊处理
155
+ td.#{$prefix}-table__cell--ellipsis,
150
156
  th.#{$prefix}-table__cell--ellipsis {
151
157
  overflow: hidden;
152
158
  position: relative;
@@ -170,17 +176,19 @@
170
176
  }
171
177
  }
172
178
 
173
- // 空数�? &__empty-row {
174
- td {
175
- padding: 0;
176
- border: 0;
177
- }
179
+ // 空行
180
+ &__empty-row {
181
+ td {
182
+ padding: 0;
183
+ border: 0;
184
+ }
178
185
 
179
- &__empty {
180
- display: flex;
181
- align-items: center;
182
- justify-content: center;
183
- min-height: $table-empty-min-height;
184
- color: $table-color-empty;
186
+ &__empty {
187
+ display: flex;
188
+ align-items: center;
189
+ justify-content: center;
190
+ min-height: $table-empty-min-height;
191
+ color: $table-color-empty;
192
+ }
185
193
  }
186
194
  }
@@ -1,5 +1,4 @@
1
1
  @use "../../_vars.scss" as *;
2
- @use "../../vars.scss" as *;
3
2
  @use "./vars.scss" as *;
4
3
  @use "./_mixins.scss" as *;
5
4
  @use "../../mixins/reset.scss" as *;
@@ -31,7 +30,7 @@
31
30
  position: relative;
32
31
 
33
32
  &.#{$prefix}-is-addable {
34
- margin-right: $tab-btn-width;
33
+ margin-inline-end: $tab-btn-width;
35
34
  }
36
35
 
37
36
  &.#{$prefix}-tabs__nav--card {
@@ -61,8 +60,8 @@
61
60
  align-items: center;
62
61
  height: $tab-nav-item-wrapper-height;
63
62
  padding: $tab-nav-item-wrapper-padding;
64
- margin-left: $tab-nav-item-margin-left;
65
- margin-right: $tab-nav-item-margin-right;
63
+ margin-inline-start: $tab-nav-item-margin-left;
64
+ margin-inline-end: $tab-nav-item-margin-right;
66
65
  border-radius: $border-radius-default;
67
66
  transition: $tab-nav-item-transition;
68
67
 
@@ -117,7 +116,7 @@
117
116
  }
118
117
 
119
118
  & > .remove-btn {
120
- margin-left: $tab-btn-remove-btn-margin-left;
119
+ margin-inline-start: $tab-btn-remove-btn-margin-left;
121
120
  transition: $tab-btn-remove-btn-transition;
122
121
  display: flex;
123
122
  }
@@ -135,25 +134,25 @@
135
134
 
136
135
  &.#{$prefix}-is-top {
137
136
  bottom: 0;
138
- left: 0;
137
+ inset-inline-start: 0;
139
138
  height: $tab-default-stroke-size;
140
139
  }
141
140
 
142
141
  &.#{$prefix}-is-bottom {
143
142
  top: 0;
144
- left: 0;
143
+ inset-inline-start: 0;
145
144
  height: $tab-default-stroke-size;
146
145
  }
147
146
 
148
147
  &.#{$prefix}-is-left {
149
148
  top: 0;
150
- right: 0;
149
+ inset-inline-end: 0;
151
150
  width: $tab-default-stroke-size;
152
151
  }
153
152
 
154
153
  &.#{$prefix}-is-right {
155
154
  top: 0;
156
- left: 0;
155
+ inset-inline-start: 0;
157
156
  width: $tab-default-stroke-size;
158
157
  }
159
158
  }
@@ -0,0 +1,104 @@
1
+ @use "../../_vars.scss" as *;
2
+ @use "./_vars.scss" as *;
3
+
4
+ // Tooltip 组件样式
5
+ .#{$prefix}-tooltip {
6
+ .#{$prefix}-popup__content {
7
+ display: inline-block;
8
+ border: 0;
9
+ z-index: $z-index-Tooltip;
10
+ margin-bottom: 1px;
11
+ max-width: $tooltip-max-width;
12
+ word-break: break-word;
13
+ box-sizing: border-box;
14
+ border-radius: $border-radius-medium;
15
+ color: $tooltip-light-text-color;
16
+ }
17
+
18
+ &--dark {
19
+ .#{$prefix}-popup__content {
20
+ color: $tooltip-text-color;
21
+ background: $tooltip-bg;
22
+ box-shadow:
23
+ inset 0 0.5px 0 $gray-color-9,
24
+ inset 0.5px 0 0 $gray-color-9,
25
+ inset 0 -0.5px 0 $gray-color-9,
26
+ inset -0.5px 0 0 $gray-color-9;
27
+ }
28
+
29
+ &[data-popper-placement^="left"] .#{$prefix}-popup__arrow:before {
30
+ box-shadow:
31
+ inset -0.5px 0 0 $gray-color-9,
32
+ inset 0 0.5px 0 $gray-color-9;
33
+ }
34
+
35
+ &[data-popper-placement^="right"] .#{$prefix}-popup__arrow:before {
36
+ box-shadow:
37
+ inset 0.5px 0 0 $gray-color-9,
38
+ inset 0 -0.5px 0 $gray-color-9;
39
+ }
40
+
41
+ &[data-popper-placement^="top"] .#{$prefix}-popup__arrow:before {
42
+ box-shadow:
43
+ inset 0 -0.5px 0 $gray-color-9,
44
+ inset -0.5px 0 0 $gray-color-9;
45
+ }
46
+
47
+ &[data-popper-placement^="bottom"] .#{$prefix}-popup__arrow:before {
48
+ box-shadow:
49
+ inset 0.5px 0 0 $gray-color-9,
50
+ inset 0 0.5px 0 $gray-color-9;
51
+ }
52
+ }
53
+
54
+ &--light {
55
+ .#{$prefix}-popup__content {
56
+ color: $tooltip-light-text-color;
57
+ background: $bg-color-container;
58
+ box-shadow: $shadow-2;
59
+ }
60
+ }
61
+
62
+ &--primary {
63
+ .#{$prefix}-popup__content {
64
+ color: $tooltip-color-primary;
65
+ background: $tooltip-bg-primary;
66
+ }
67
+ }
68
+
69
+ &--success {
70
+ .#{$prefix}-popup__content {
71
+ color: $tooltip-color-success;
72
+ background: $tooltip-bg-success;
73
+ }
74
+ }
75
+
76
+ &--error {
77
+ .#{$prefix}-popup__content {
78
+ color: $tooltip-color-danger;
79
+ background: $tooltip-bg-danger;
80
+ }
81
+ }
82
+
83
+ &--warning {
84
+ .#{$prefix}-popup__content {
85
+ color: $tooltip-color-warning;
86
+ background: $tooltip-bg-warning;
87
+ }
88
+ }
89
+
90
+ .#{$prefix}-popup__arrow {
91
+ background: inherit;
92
+ height: auto;
93
+ &::before {
94
+ background: inherit;
95
+ }
96
+ }
97
+
98
+ &--noshadow {
99
+ .#{$prefix}-popup__content,
100
+ &[data-popper-placement] .#{$prefix}-popup__arrow:before {
101
+ box-shadow: none;
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,23 @@
1
+ @use "../../_vars.scss" as *;
2
+ // Tooltip 组件变量
3
+ // 宽度
4
+ $tooltip-max-width: 480px;
5
+
6
+ // 颜色
7
+ $tooltip-bg: $gray-color-9; // tooltip 背景色
8
+ $tooltip-color-primary: $brand-color;
9
+ $tooltip-bg-primary: $brand-color-light;
10
+ $tooltip-color-success: $success-color;
11
+ $tooltip-bg-success: $success-color-light;
12
+ $tooltip-color-danger: $error-color;
13
+ $tooltip-bg-danger: $error-color-light;
14
+ $tooltip-color-warning: $warning-color;
15
+ $tooltip-bg-warning: $warning-color-light;
16
+ $tooltip-text-color: $text-color-anti;
17
+ $tooltip-light-text-color: $text-color-primary;
18
+
19
+ // 间距
20
+ $tooltip-default-margin: $comp-margin-s;
21
+
22
+ // tooltip箭头位移量
23
+ $tooltip-arrow-position: $comp-margin-xs;
@@ -0,0 +1,25 @@
1
+ import React, { useState } from "react";
2
+ import { Switch } from "@tendaui/react";
3
+
4
+ const AsyncExample = () => {
5
+ const [checked, setChecked] = useState(false);
6
+ const [loading, setLoading] = useState(false);
7
+
8
+ const handleChange = (val: boolean) => {
9
+ setLoading(true);
10
+ // 模拟异步请求
11
+ setTimeout(() => {
12
+ setChecked(val);
13
+ setLoading(false);
14
+ }, 1000);
15
+ };
16
+
17
+ return (
18
+ <div>
19
+ <Switch value={checked} loading={loading} onChange={(val) => handleChange(val as boolean)} />
20
+ <div style={{ color: "#666", fontSize: "12px" }}>点击切换,模拟 1 秒异步请求</div>
21
+ </div>
22
+ );
23
+ };
24
+
25
+ export default AsyncExample;
@@ -0,0 +1,22 @@
1
+ import React, { useState } from "react";
2
+ import { Switch } from "@tendaui/react";
3
+
4
+ const BeforeChangeExample = () => {
5
+ const [checked, setChecked] = useState(false);
6
+
7
+ const beforeChange = () => {
8
+ return new Promise<boolean>((resolve) => {
9
+ const confirmed = window.confirm("确定要切换状态吗?");
10
+ resolve(confirmed);
11
+ });
12
+ };
13
+
14
+ return (
15
+ <div>
16
+ <Switch value={checked} beforeChange={beforeChange} onChange={(val) => setChecked(val as boolean)} />
17
+ <div style={{ color: "#666", fontSize: "12px" }}>切换前会弹出确认框,确认后才会切换</div>
18
+ </div>
19
+ );
20
+ };
21
+
22
+ export default BeforeChangeExample;
@@ -0,0 +1,14 @@
1
+ import React, { useState } from "react";
2
+ import { Switch } from "@tendaui/react";
3
+
4
+ const ControlledExample = () => {
5
+ const [checked, setChecked] = useState(true);
6
+ return (
7
+ <div>
8
+ <Switch value={checked} onChange={(val) => setChecked(val as boolean)} />
9
+ <div style={{ color: "#666" }}>当前状态:{checked ? "开启" : "关闭"}</div>
10
+ </div>
11
+ );
12
+ };
13
+
14
+ export default ControlledExample;
@@ -0,0 +1,21 @@
1
+ import React, { useState } from "react";
2
+ import { Switch } from "@tendaui/react";
3
+
4
+ const CustomValueExample = () => {
5
+ const [value1, setValue1] = useState<string | number | boolean>(1);
6
+ const [value2, setValue2] = useState<string | number | boolean>("open");
7
+ return (
8
+ <div>
9
+ <div style={{ display: "flex", alignItems: "center", gap: "16px" }}>
10
+ <Switch customValue={[1, 0]} value={value1} onChange={(val) => setValue1(val)} />
11
+ <span style={{ color: "#666" }}>数字值: {String(value1)}</span>
12
+ </div>
13
+ <div style={{ display: "flex", alignItems: "center", gap: "16px" }}>
14
+ <Switch customValue={["open", "close"]} value={value2} onChange={(val) => setValue2(val)} />
15
+ <span style={{ color: "#666" }}>字符串值: {String(value2)}</span>
16
+ </div>
17
+ </div>
18
+ );
19
+ };
20
+
21
+ export default CustomValueExample;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ import { Switch } from "@tendaui/react";
3
+
4
+ const DefaultExample = () => <Switch defaultValue={true} />;
5
+
6
+ export default DefaultExample;
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ import { Switch } from "@tendaui/react";
3
+
4
+ const DisabledExample = () => (
5
+ <div style={{ display: "flex", gap: "24px" }}>
6
+ <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: "8px" }}>
7
+ <Switch defaultValue={false} />
8
+ <span style={{ color: "#666", fontSize: "12px" }}>正常关闭</span>
9
+ </div>
10
+ <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: "8px" }}>
11
+ <Switch defaultValue={true} />
12
+ <span style={{ color: "#666", fontSize: "12px" }}>正常开启</span>
13
+ </div>
14
+ <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: "8px" }}>
15
+ <Switch disabled defaultValue={false} />
16
+ <span style={{ color: "#666", fontSize: "12px" }}>禁用关闭</span>
17
+ </div>
18
+ <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: "8px" }}>
19
+ <Switch disabled defaultValue={true} />
20
+ <span style={{ color: "#666", fontSize: "12px" }}>禁用开启</span>
21
+ </div>
22
+ </div>
23
+ );
24
+
25
+ export default DisabledExample;
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import { Switch } from "@tendaui/react";
3
+
4
+ const LoadingExample = () => (
5
+ <div style={{ display: "flex", gap: "24px" }}>
6
+ <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: "8px" }}>
7
+ <Switch loading defaultValue={false} />
8
+ <span style={{ color: "#666", fontSize: "12px" }}>加载中(关)</span>
9
+ </div>
10
+ <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: "8px" }}>
11
+ <Switch loading defaultValue={true} />
12
+ <span style={{ color: "#666", fontSize: "12px" }}>加载中(开)</span>
13
+ </div>
14
+ </div>
15
+ );
16
+
17
+ export default LoadingExample;
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { Switch } from "@tendaui/react";
3
+
4
+ const SizesExample = () => (
5
+ <div style={{ display: "flex", gap: "24px", alignItems: "center" }}>
6
+ <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: "8px" }}>
7
+ <Switch size="small" defaultValue={true} />
8
+ <span style={{ color: "#666", fontSize: "12px" }}>小</span>
9
+ </div>
10
+ <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: "8px" }}>
11
+ <Switch size="medium" defaultValue={true} />
12
+ <span style={{ color: "#666", fontSize: "12px" }}>中(默认)</span>
13
+ </div>
14
+ <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: "8px" }}>
15
+ <Switch size="large" defaultValue={true} />
16
+ <span style={{ color: "#666", fontSize: "12px" }}>大</span>
17
+ </div>
18
+ </div>
19
+ );
20
+
21
+ export default SizesExample;
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { Switch } from "@tendaui/react";
3
+
4
+ const WithLabelExample = () => (
5
+ <div style={{ display: "flex", flexDirection: "column", gap: "12px" }}>
6
+ <div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
7
+ <Switch label={["开", "关"]} defaultValue={true} />
8
+ <span style={{ color: "#666" }}>数组形式</span>
9
+ </div>
10
+ <div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
11
+ <Switch label={["ON", "OFF"]} defaultValue={false} />
12
+ <span style={{ color: "#666" }}>英文标签</span>
13
+ </div>
14
+ <div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
15
+ <Switch label={["1", "0"]} defaultValue={true} />
16
+ <span style={{ color: "#666" }}>数字标签</span>
17
+ </div>
18
+ </div>
19
+ );
20
+
21
+ export default WithLabelExample;
package/tab/TabPanel.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useRef } from "react";
1
+ import React, { useState, useEffect } from "react";
2
2
  import classNames from "classnames";
3
3
  import type { TdTabPanelProps } from "./type";
4
4
  import { StyledProps } from "../common";
@@ -17,13 +17,16 @@ const TabPanel: React.FC<TabPanelProps> = (props) => {
17
17
  tabPanelDefaultProps
18
18
  );
19
19
  const { tdTabPanelClassPrefix } = useTabClass();
20
- const lazyRenderRef = useRef(lazy);
20
+ const [shouldRender, setShouldRender] = useState(!lazy);
21
21
 
22
- if (lazy && isActive && lazyRenderRef.current) {
23
- lazyRenderRef.current = false;
24
- }
22
+ // 当标签激活且是延迟渲染时,设置为应该渲染
23
+ useEffect(() => {
24
+ if (lazy && isActive) {
25
+ setShouldRender(true);
26
+ }
27
+ }, [lazy, isActive]);
25
28
 
26
- if ((!isActive && destroyOnHide) || lazyRenderRef.current) {
29
+ if ((!isActive && destroyOnHide) || !shouldRender) {
27
30
  return null;
28
31
  }
29
32
 
@@ -0,0 +1,45 @@
1
+ import React, { useState } from "react";
2
+ import { Tabs, TabPanel } from "../index";
3
+
4
+ const AddableExample = () => {
5
+ const [activeTab, setActiveTab] = useState("tab1");
6
+ const [tabs, setTabs] = useState([
7
+ { label: "选项卡一", value: "tab1" },
8
+ { label: "选项卡二", value: "tab2" }
9
+ ]);
10
+ const [tabCount, setTabCount] = useState(2);
11
+
12
+ const handleAdd = () => {
13
+ const newTabValue = `tab${tabCount + 1}`;
14
+ const newTab = { label: `选项卡${tabCount + 1}`, value: newTabValue };
15
+ setTabs([...tabs, newTab]);
16
+ setTabCount(tabCount + 1);
17
+ setActiveTab(newTabValue);
18
+ };
19
+
20
+ const handleRemove = (options: { value: string | number; index: number }) => {
21
+ const newTabs = tabs.filter((tab) => tab.value !== options.value);
22
+ setTabs(newTabs);
23
+ if (activeTab === options.value && newTabs.length > 0) {
24
+ setActiveTab(newTabs[0].value);
25
+ }
26
+ };
27
+
28
+ return (
29
+ <Tabs
30
+ value={activeTab}
31
+ onChange={(val) => setActiveTab(val as string)}
32
+ addable
33
+ onAdd={handleAdd}
34
+ onRemove={handleRemove}
35
+ >
36
+ {tabs.map((tab) => (
37
+ <TabPanel key={tab.value} label={tab.label} value={tab.value} removable>
38
+ <div style={{ padding: "16px" }}>{tab.label} 的内容</div>
39
+ </TabPanel>
40
+ ))}
41
+ </Tabs>
42
+ );
43
+ };
44
+
45
+ export default AddableExample;
@@ -0,0 +1,22 @@
1
+ import React, { useState } from "react";
2
+ import { Tabs, TabPanel } from "../index";
3
+
4
+ const CardThemeExample = () => {
5
+ const [activeTab, setActiveTab] = useState("tab1");
6
+
7
+ return (
8
+ <Tabs value={activeTab} onChange={(val) => setActiveTab(val as string)} theme="card">
9
+ <TabPanel label="选项卡一" value="tab1">
10
+ <div style={{ padding: "16px" }}>卡片风格 - 选项卡一的内容</div>
11
+ </TabPanel>
12
+ <TabPanel label="选项卡二" value="tab2">
13
+ <div style={{ padding: "16px" }}>卡片风格 - 选项卡二的内容</div>
14
+ </TabPanel>
15
+ <TabPanel label="选项卡三" value="tab3">
16
+ <div style={{ padding: "16px" }}>卡片风格 - 选项卡三的内容</div>
17
+ </TabPanel>
18
+ </Tabs>
19
+ );
20
+ };
21
+
22
+ export default CardThemeExample;
@@ -0,0 +1,22 @@
1
+ import React, { useState } from "react";
2
+ import { Tabs, TabPanel } from "../index";
3
+
4
+ const DefaultExample = () => {
5
+ const [activeTab, setActiveTab] = useState("tab1");
6
+
7
+ return (
8
+ <Tabs value={activeTab} onChange={(val) => setActiveTab(val as string)}>
9
+ <TabPanel label="选项卡一" value="tab1">
10
+ <div style={{ padding: "16px" }}>选项卡一的内容</div>
11
+ </TabPanel>
12
+ <TabPanel label="选项卡二" value="tab2">
13
+ <div style={{ padding: "16px" }}>选项卡二的内容</div>
14
+ </TabPanel>
15
+ <TabPanel label="选项卡三" value="tab3">
16
+ <div style={{ padding: "16px" }}>选项卡三的内容</div>
17
+ </TabPanel>
18
+ </Tabs>
19
+ );
20
+ };
21
+
22
+ export default DefaultExample;
@@ -0,0 +1,38 @@
1
+ import React, { useState } from "react";
2
+ import { Tabs, TabPanel } from "../index";
3
+
4
+ const DisabledExample = () => {
5
+ const [activeTab, setActiveTab] = useState("tab1");
6
+
7
+ return (
8
+ <div style={{ display: "flex", flexDirection: "column", gap: "24px" }}>
9
+ <div>
10
+ <div style={{ marginBottom: "8px", color: "#666" }}>部分禁用</div>
11
+ <Tabs value={activeTab} onChange={(val) => setActiveTab(val as string)}>
12
+ <TabPanel label="选项卡一" value="tab1">
13
+ <div style={{ padding: "16px" }}>选项卡一的内容</div>
14
+ </TabPanel>
15
+ <TabPanel label="选项卡二(禁用)" value="tab2" disabled>
16
+ <div style={{ padding: "16px" }}>选项卡二的内容</div>
17
+ </TabPanel>
18
+ <TabPanel label="选项卡三" value="tab3">
19
+ <div style={{ padding: "16px" }}>选项卡三的内容</div>
20
+ </TabPanel>
21
+ </Tabs>
22
+ </div>
23
+ <div>
24
+ <div style={{ marginBottom: "8px", color: "#666" }}>全部禁用</div>
25
+ <Tabs value="tab1" disabled>
26
+ <TabPanel label="选项卡一" value="tab1">
27
+ <div style={{ padding: "16px" }}>选项卡一的内容</div>
28
+ </TabPanel>
29
+ <TabPanel label="选项卡二" value="tab2">
30
+ <div style={{ padding: "16px" }}>选项卡二的内容</div>
31
+ </TabPanel>
32
+ </Tabs>
33
+ </div>
34
+ </div>
35
+ );
36
+ };
37
+
38
+ export default DisabledExample;