@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
@@ -1,6 +1,6 @@
1
- import Color from './color';
2
- import { ALPHA_FORMAT_MAP, COLOR_FORMAT_INPUTS, FORMATS } from './constants';
3
- import type { AlphaConvertibleFormat, BasicColorFormat, ColorFormat } from './types';
1
+ import Color from "./color";
2
+ import { ALPHA_FORMAT_MAP, COLOR_FORMAT_INPUTS, FORMATS } from "./constants";
3
+ import type { AlphaConvertibleFormat, BasicColorFormat, ColorFormat } from "./types";
4
4
 
5
5
  /**
6
6
  * 兜底处理用户传入的格式,例如:
@@ -18,8 +18,8 @@ export const initColorFormat = (format: ColorFormat, enableAlpha: boolean) => {
18
18
  * - encode:将字符串转换为单独的颜色值,例如 `{r: 255, g: 255, b: 255}`
19
19
  * - decode:获取完整的颜色字符串,例如 `rgb(255, 255, 255)`
20
20
  */
21
- export const getColorFormatMap = (color: Color, type: 'encode' | 'decode') => {
22
- if (type === 'encode') {
21
+ export const getColorFormatMap = (color: Color, type: "encode" | "decode") => {
22
+ if (type === "encode") {
23
23
  return {
24
24
  HSV: color.getHsva(),
25
25
  HSVA: color.getHsva(),
@@ -29,14 +29,14 @@ export const getColorFormatMap = (color: Color, type: 'encode' | 'decode') => {
29
29
  RGBA: color.getRgba(),
30
30
  CMYK: color.getCmyk(),
31
31
  CSS: {
32
- css: color.css,
32
+ css: color.css
33
33
  },
34
34
  HEX: {
35
- hex: color.hex,
35
+ hex: color.hex
36
36
  },
37
37
  HEX8: {
38
- hex: color.hex8, // 为了减少转换 hex8 的 key 也对应 hex
39
- },
38
+ hex: color.hex8 // 为了减少转换 hex8 的 key 也对应 hex
39
+ }
40
40
  };
41
41
  }
42
42
 
@@ -47,47 +47,42 @@ export const getColorFormatMap = (color: Color, type: 'encode' | 'decode') => {
47
47
  /**
48
48
  * 获取下拉框的格式选项
49
49
  */
50
- export const getColorFormatOptions = (enableAlpha: boolean) => (
50
+ export const getColorFormatOptions = (enableAlpha: boolean) =>
51
51
  enableAlpha
52
52
  ? FORMATS.map((item) => (item in ALPHA_FORMAT_MAP ? ALPHA_FORMAT_MAP[item as AlphaConvertibleFormat] : item))
53
- : FORMATS
54
- );
53
+ : FORMATS;
55
54
 
56
55
  /**
57
56
  * 获取当前格式的输入框配置
58
57
  */
59
- export const getColorFormatInputs = (
60
- format: ColorFormat = 'RGB',
61
- enableAlpha: boolean
62
- ) => {
58
+ export const getColorFormatInputs = (format: ColorFormat = "RGB", enableAlpha: boolean) => {
63
59
  let finalFormat;
64
60
 
65
61
  /* 为了减少 `ALPHA_FORMAT_MAP` 中的重复代码
66
62
  `RGBA/HEX8/HSLA/HSVA` 会被转换为 `RGB/HEX/HSL/HSV` 后再匹配
67
63
  但在下一步会 push 一个代表透明度的输入框 */
68
64
  if (enableAlpha) {
69
- finalFormat = Object.keys(ALPHA_FORMAT_MAP).find(
70
- (key) => key in ALPHA_FORMAT_MAP && ALPHA_FORMAT_MAP[key as AlphaConvertibleFormat] === format
71
- ) || format;
65
+ finalFormat =
66
+ Object.keys(ALPHA_FORMAT_MAP).find(
67
+ (key) => key in ALPHA_FORMAT_MAP && ALPHA_FORMAT_MAP[key as AlphaConvertibleFormat] === format
68
+ ) || format;
72
69
  } else {
73
70
  finalFormat = format;
74
71
  }
75
72
 
76
73
  if (!COLOR_FORMAT_INPUTS[finalFormat as BasicColorFormat]) return [];
77
74
 
78
- const configs = [
79
- ...(COLOR_FORMAT_INPUTS[finalFormat as BasicColorFormat]),
80
- ];
75
+ const configs = [...COLOR_FORMAT_INPUTS[finalFormat as BasicColorFormat]];
81
76
 
82
77
  // CMYK 格式不支持透明度
83
- if (enableAlpha && format !== 'CMYK') {
78
+ if (enableAlpha && format !== "CMYK") {
84
79
  configs.push({
85
- type: 'inputNumber',
86
- key: 'a',
80
+ type: "inputNumber",
81
+ key: "a",
87
82
  min: 0,
88
83
  max: 100,
89
84
  format: (value: number) => `${value}%`,
90
- flex: 1.15,
85
+ flex: 1.15
91
86
  });
92
87
  }
93
88
 
@@ -1,10 +1,10 @@
1
- import { isString, isNull } from 'lodash-es';
2
- /* eslint-disable no-param-reassign */
1
+ import { isString, isNull } from "lodash-es";
2
+
3
3
  /**
4
4
  * 用于反解析渐变字符串为对象
5
5
  * https://stackoverflow.com/questions/20215440/parse-css-gradient-rule-with-javascript-regex
6
6
  */
7
- import tinyColor from 'tinycolor2';
7
+ import tinyColor from "tinycolor2";
8
8
 
9
9
  /**
10
10
  * Utility combine multiple regular expressions.
@@ -13,7 +13,7 @@ import tinyColor from 'tinycolor2';
13
13
  * @param {string} flags Normal RegExp flags.
14
14
  */
15
15
  const combineRegExp = (regexpList: (string | RegExp)[], flags: string): RegExp => {
16
- let source = '';
16
+ let source = "";
17
17
  for (let i = 0; i < regexpList.length; i++) {
18
18
  if (isString(regexpList[i])) {
19
19
  source += regexpList[i];
@@ -51,7 +51,7 @@ interface ParseGradientResult {
51
51
  */
52
52
  const generateRegExp = (): RegExpLib => {
53
53
  // Note any variables with "Capture" in name include capturing bracket set(s).
54
- const searchFlags = 'gi'; // ignore case for angles, "rgb" etc
54
+ const searchFlags = "gi"; // ignore case for angles, "rgb" etc
55
55
  const rAngle = /(?:[+-]?\d*\.?\d+)(?:deg|grad|rad|turn)/; // Angle +ive, -ive and angle types
56
56
  // optional 2nd part
57
57
  const rSideCornerCapture = /to\s+((?:(?:left|right|top|bottom)(?:\s+(?:top|bottom|left|right))?))/;
@@ -66,25 +66,25 @@ const generateRegExp = (): RegExpLib => {
66
66
  rKeyword = /[_a-z-][_a-z0-9-]*/;
67
67
  const // "red", "transparent".
68
68
  rColor = combineRegExp(
69
- ['(?:', rColorHex, '|', '(?:rgb|hsl)', rDigits3, '|', '(?:rgba|hsla)', rDigits4, '|', rKeyword, ')'],
70
- '',
69
+ ["(?:", rColorHex, "|", "(?:rgb|hsl)", rDigits3, "|", "(?:rgba|hsla)", rDigits4, "|", rKeyword, ")"],
70
+ ""
71
71
  );
72
- const rColorStop = combineRegExp([rColor, '(?:\\s+', rValue, '(?:\\s+', rValue, ')?)?'], '');
72
+ const rColorStop = combineRegExp([rColor, "(?:\\s+", rValue, "(?:\\s+", rValue, ")?)?"], "");
73
73
  const // Single Color Stop, optional %, optional length.
74
- rColorStopList = combineRegExp(['(?:', rColorStop, rComma, ')*', rColorStop], '');
74
+ rColorStopList = combineRegExp(["(?:", rColorStop, rComma, ")*", rColorStop], "");
75
75
  const // List of color stops min 1.
76
- rLineCapture = combineRegExp(['(?:(', rAngle, ')|', rSideCornerCapture, ')'], '');
76
+ rLineCapture = combineRegExp(["(?:(", rAngle, ")|", rSideCornerCapture, ")"], "");
77
77
  const // Angle or SideCorner
78
- rGradientSearch = combineRegExp(['(?:(', rLineCapture, ')', rComma, ')?(', rColorStopList, ')'], searchFlags);
78
+ rGradientSearch = combineRegExp(["(?:(", rLineCapture, ")", rComma, ")?(", rColorStopList, ")"], searchFlags);
79
79
  const // Capture 1:"line", 2:"angle" (optional), 3:"side corner" (optional) and 4:"stop list".
80
80
  rColorStopSearch = combineRegExp(
81
- ['\\s*(', rColor, ')', '(?:\\s+', '(', rValue, '))?', '(?:', rComma, '\\s*)?'],
82
- searchFlags,
81
+ ["\\s*(", rColor, ")", "(?:\\s+", "(", rValue, "))?", "(?:", rComma, "\\s*)?"],
82
+ searchFlags
83
83
  ); // Capture 1:"color" and 2:"position" (optional).
84
84
 
85
85
  return {
86
86
  gradientSearch: rGradientSearch,
87
- colorStopSearch: rColorStopSearch,
87
+ colorStopSearch: rColorStopSearch
88
88
  };
89
89
  };
90
90
 
@@ -111,22 +111,19 @@ const parseGradient = (regExpLib: RegExpLib, input: string) => {
111
111
  if (!isNull(matchGradient)) {
112
112
  result = {
113
113
  original: matchGradient[0],
114
- colorStopList: [],
114
+ colorStopList: []
115
115
  };
116
116
 
117
117
  // Line (Angle or Side-Corner).
118
118
  if (matchGradient[1]) {
119
- // eslint-disable-next-line prefer-destructuring
120
119
  result.line = matchGradient[1];
121
120
  }
122
121
  // Angle or undefined if side-corner.
123
122
  if (matchGradient[2]) {
124
- // eslint-disable-next-line prefer-destructuring
125
123
  result.angle = matchGradient[2];
126
124
  }
127
125
  // Side-corner or undefined if angle.
128
126
  if (matchGradient[3]) {
129
- // eslint-disable-next-line prefer-destructuring
130
127
  result.sideCorner = matchGradient[3];
131
128
  }
132
129
 
@@ -137,12 +134,11 @@ const parseGradient = (regExpLib: RegExpLib, input: string) => {
137
134
  matchColorStop = regExpLib.colorStopSearch.exec(matchGradient[4]);
138
135
  while (!isNull(matchColorStop)) {
139
136
  stopResult = {
140
- color: matchColorStop[1],
137
+ color: matchColorStop[1]
141
138
  };
142
139
 
143
140
  // Position (optional).
144
141
  if (matchColorStop[2]) {
145
- // eslint-disable-next-line prefer-destructuring
146
142
  stopResult.position = matchColorStop[2];
147
143
  }
148
144
  result.colorStopList.push(stopResult);
@@ -186,14 +182,14 @@ const sideCornerDegreeMap = {
186
182
  right: 90,
187
183
  bottom: 180,
188
184
  left: 270,
189
- 'top left': 315,
190
- 'left top': 315,
191
- 'top right': 45,
192
- 'right top': 45,
193
- 'bottom left': 225,
194
- 'left bottom': 225,
195
- 'bottom right': 135,
196
- 'right bottom': 135,
185
+ "top left": 315,
186
+ "left top": 315,
187
+ "top right": 45,
188
+ "right top": 45,
189
+ "bottom left": 225,
190
+ "left bottom": 225,
191
+ "bottom right": 135,
192
+ "right bottom": 135
197
193
  };
198
194
 
199
195
  /**
@@ -207,26 +203,24 @@ export const parseGradientString = (input: string): GradientColors | false => {
207
203
 
208
204
  const gradientColors: GradientColors = {
209
205
  points: [],
210
- degree: 0,
206
+ degree: 0
211
207
  };
212
208
 
213
209
  const result: ParseGradientResult = parseGradient(REGEXP_LIB, match[1]);
214
210
  if (result.original.trim() !== match[1].trim()) return false;
215
211
 
216
- const points: GradientColorPoint[] = result.colorStopList.map(
217
- ({ color, position }, index, array) => {
218
- const point = Object.create(null);
219
- point.color = tinyColor(color).toRgbString();
220
-
221
- let left = parseFloat(position);
222
- if (Number.isNaN(left)) {
223
- left = (index / (array.length - 1)) * 100;
224
- }
212
+ const points: GradientColorPoint[] = result.colorStopList.map(({ color, position }, index, array) => {
213
+ const point = Object.create(null);
214
+ point.color = tinyColor(color).toRgbString();
225
215
 
226
- point.left = left;
227
- return point;
216
+ let left = parseFloat(position);
217
+ if (Number.isNaN(left)) {
218
+ left = (index / (array.length - 1)) * 100;
228
219
  }
229
- );
220
+
221
+ point.left = left;
222
+ return point;
223
+ });
230
224
  gradientColors.points = points;
231
225
 
232
226
  let degree = parseInt(result.angle, 10);
@@ -1,9 +1,9 @@
1
- import { ALPHA_FORMAT_MAP, FORMATS } from './constants';
1
+ import { ALPHA_FORMAT_MAP, FORMATS } from "./constants";
2
2
 
3
3
  /**
4
4
  * 非透明色类型
5
5
  */
6
- export type BasicColorFormat = typeof FORMATS[number];
6
+ export type BasicColorFormat = (typeof FORMATS)[number];
7
7
 
8
8
  /**
9
9
  * 支持转为透明格式的非透明色类型
@@ -13,7 +13,7 @@ export type AlphaConvertibleFormat = keyof typeof ALPHA_FORMAT_MAP;
13
13
  /**
14
14
  * 透明色类型
15
15
  */
16
- export type AlphaColorFormat = typeof ALPHA_FORMAT_MAP[AlphaConvertibleFormat];
16
+ export type AlphaColorFormat = (typeof ALPHA_FORMAT_MAP)[AlphaConvertibleFormat];
17
17
 
18
18
  /**
19
19
  * 完整的颜色格式类型
@@ -27,7 +27,7 @@ export interface ColorInputProp {
27
27
  key: string;
28
28
  min?: number;
29
29
  max?: number;
30
- type: 'input' | 'inputNumber';
30
+ type: "input" | "inputNumber";
31
31
  flex?: number;
32
32
  format?: Function;
33
33
  }
@@ -6,6 +6,7 @@ import defaultLocale from "../locale/zh_CN";
6
6
 
7
7
  export const defaultGlobalConfig: GlobalConfigProvider = {
8
8
  classPrefix: defaultClassPrefix,
9
+ direction: "ltr",
9
10
  attach: null,
10
11
  form: {},
11
12
  icon: {} as Record<string, typeof Icon>,
@@ -36,6 +36,7 @@ export const setGlobalConfig = (configInfo?: GlobalConfigProvider) => {
36
36
  export default function ConfigProvider({ children, globalConfig, notSet }: ConfigProviderProps) {
37
37
  const defaultData = cloneDeep(defaultGlobalConfig);
38
38
  const mergedGlobalConfig = merge(defaultData, globalConfig);
39
+ const direction = mergedGlobalConfig.direction || "ltr";
39
40
 
40
41
  useEffect(() => {
41
42
  if (!notSet) {
@@ -44,7 +45,23 @@ export default function ConfigProvider({ children, globalConfig, notSet }: Confi
44
45
  }
45
46
  }, [mergedGlobalConfig, notSet]);
46
47
 
47
- return <ConfigContext.Provider value={{ globalConfig: mergedGlobalConfig }}>{children}</ConfigContext.Provider>;
48
+ useEffect(() => {
49
+ if (notSet || typeof document === "undefined") return;
50
+ document.documentElement.setAttribute("dir", direction);
51
+ document.body.setAttribute("dir", direction);
52
+ }, [direction, notSet]);
53
+
54
+ return (
55
+ <ConfigContext.Provider value={{ globalConfig: mergedGlobalConfig }}>
56
+ <div
57
+ className={`${mergedGlobalConfig.classPrefix}-config-provider`}
58
+ dir={direction}
59
+ style={{ display: "contents" }}
60
+ >
61
+ {children}
62
+ </div>
63
+ </ConfigContext.Provider>
64
+ );
48
65
  }
49
66
 
50
67
  ConfigProvider.getGlobalConfig = getGlobalConfig;
@@ -9,6 +9,11 @@ export interface TdConfigProviderProps {
9
9
  }
10
10
 
11
11
  export interface GlobalConfigProvider {
12
+ /**
13
+ * 文本方向,'rtl' 表示从右往左
14
+ * @default 'ltr'
15
+ */
16
+ direction?: "ltr" | "rtl";
12
17
  /**
13
18
  * 警告全局配置
14
19
  */
@@ -0,0 +1,27 @@
1
+ import React, { useState } from "react";
2
+ import { Button, Dialog } from "@tendaui/react";
3
+
4
+ export default function Base() {
5
+ const [visible, setVisible] = useState(false);
6
+
7
+ const onConfirm = (context) => {
8
+ console.log("点击了确认按钮", context);
9
+ setVisible(false);
10
+ };
11
+
12
+ const onClose = (context) => {
13
+ console.log("关闭弹窗", context);
14
+ setVisible(false);
15
+ };
16
+
17
+ return (
18
+ <>
19
+ <Button theme="primary" onClick={() => setVisible(true)}>
20
+ 打开对话框
21
+ </Button>
22
+ <Dialog header="基础对话框" visible={visible} onClose={onClose} onConfirm={onConfirm}>
23
+ <p>这是一个基础对话框示例。</p>
24
+ </Dialog>
25
+ </>
26
+ );
27
+ }
@@ -0,0 +1,32 @@
1
+ import React, { useState } from "react";
2
+ import { Button, Dialog } from "@tendaui/react";
3
+
4
+ export default function ConfirmLoading() {
5
+ const [visible, setVisible] = useState(false);
6
+ const [loading, setLoading] = useState(false);
7
+
8
+ const handleConfirm = () => {
9
+ setLoading(true);
10
+ setTimeout(() => {
11
+ setLoading(false);
12
+ setVisible(false);
13
+ }, 2000);
14
+ };
15
+
16
+ return (
17
+ <>
18
+ <Button theme="primary" onClick={() => setVisible(true)}>
19
+ 异步确认
20
+ </Button>
21
+ <Dialog
22
+ header="异步确认"
23
+ visible={visible}
24
+ confirmLoading={loading}
25
+ onClose={() => setVisible(false)}
26
+ onConfirm={handleConfirm}
27
+ >
28
+ <p>点击确认按钮后会显示加载状态,2秒后自动关闭。</p>
29
+ </Dialog>
30
+ </>
31
+ );
32
+ }
@@ -0,0 +1,24 @@
1
+ import React, { useState } from "react";
2
+ import { Button, Dialog } from "@tendaui/react";
3
+
4
+ export default function CustomButtons() {
5
+ const [visible, setVisible] = useState(false);
6
+
7
+ return (
8
+ <>
9
+ <Button theme="primary" onClick={() => setVisible(true)}>
10
+ 自定义按钮
11
+ </Button>
12
+ <Dialog
13
+ header="自定义按钮"
14
+ visible={visible}
15
+ confirmBtn={{ content: "我知道了", theme: "primary" }}
16
+ cancelBtn={{ content: "稍后再说", variant: "outline" }}
17
+ onClose={() => setVisible(false)}
18
+ onConfirm={() => setVisible(false)}
19
+ >
20
+ <p>这是一个带自定义按钮文字的对话框。</p>
21
+ </Dialog>
22
+ </>
23
+ );
24
+ }
@@ -0,0 +1,26 @@
1
+ import React, { useState } from "react";
2
+ import { Button, Dialog } from "@tendaui/react";
3
+
4
+ export default function FullScreen() {
5
+ const [visible, setVisible] = useState(false);
6
+
7
+ return (
8
+ <>
9
+ <Button theme="primary" onClick={() => setVisible(true)}>
10
+ 全屏对话框
11
+ </Button>
12
+ <Dialog
13
+ header="全屏对话框"
14
+ mode="full-screen"
15
+ visible={visible}
16
+ onClose={() => setVisible(false)}
17
+ onConfirm={() => setVisible(false)}
18
+ >
19
+ <div style={{ padding: "20px" }}>
20
+ <p>这是一个全屏对话框,适合展示大量内容。</p>
21
+ <p>可以在这里放置复杂的表单、数据展示等。</p>
22
+ </div>
23
+ </Dialog>
24
+ </>
25
+ );
26
+ }
@@ -0,0 +1,39 @@
1
+ import React, { useState } from "react";
2
+ import { Button, Dialog } from "@tendaui/react";
3
+
4
+ export default function HideButtons() {
5
+ const [noCancelVisible, setNoCancelVisible] = useState(false);
6
+ const [noFooterVisible, setNoFooterVisible] = useState(false);
7
+
8
+ return (
9
+ <>
10
+ <div style={{ display: "flex", gap: "12px" }}>
11
+ <Button theme="primary" onClick={() => setNoCancelVisible(true)}>
12
+ 无取消按钮
13
+ </Button>
14
+ <Button theme="primary" onClick={() => setNoFooterVisible(true)}>
15
+ 无底部操作栏
16
+ </Button>
17
+ </div>
18
+
19
+ <Dialog
20
+ header="无取消按钮"
21
+ visible={noCancelVisible}
22
+ cancelBtn={null}
23
+ onClose={() => setNoCancelVisible(false)}
24
+ onConfirm={() => setNoCancelVisible(false)}
25
+ >
26
+ <p>这是一个只有确认按钮的对话框。</p>
27
+ </Dialog>
28
+
29
+ <Dialog
30
+ header="无底部操作栏"
31
+ visible={noFooterVisible}
32
+ footer={false}
33
+ onClose={() => setNoFooterVisible(false)}
34
+ >
35
+ <p>这是一个没有底部操作栏的对话框,点击右上角关闭按钮关闭。</p>
36
+ </Dialog>
37
+ </>
38
+ );
39
+ }
@@ -0,0 +1,25 @@
1
+ import React, { useState } from "react";
2
+ import { Button, Dialog } from "@tendaui/react";
3
+
4
+ export default function Modeless() {
5
+ const [visible, setVisible] = useState(false);
6
+
7
+ return (
8
+ <>
9
+ <Button theme="primary" onClick={() => setVisible(true)}>
10
+ 非模态对话框
11
+ </Button>
12
+ <Dialog
13
+ header="非模态对话框"
14
+ mode="modeless"
15
+ draggable
16
+ visible={visible}
17
+ onClose={() => setVisible(false)}
18
+ onConfirm={() => setVisible(false)}
19
+ >
20
+ <p>这是一个非模态对话框,可以拖拽移动。</p>
21
+ <p>可以同时操作页面上的其他内容。</p>
22
+ </Dialog>
23
+ </>
24
+ );
25
+ }
@@ -0,0 +1,40 @@
1
+ import React, { useState } from "react";
2
+ import { Button, Dialog } from "@tendaui/react";
3
+
4
+ export default function Placement() {
5
+ const [topVisible, setTopVisible] = useState(false);
6
+ const [centerVisible, setCenterVisible] = useState(false);
7
+
8
+ return (
9
+ <>
10
+ <div style={{ display: "flex", gap: "12px" }}>
11
+ <Button theme="primary" onClick={() => setTopVisible(true)}>
12
+ 顶部对话框
13
+ </Button>
14
+ <Button theme="primary" onClick={() => setCenterVisible(true)}>
15
+ 居中对话框
16
+ </Button>
17
+ </div>
18
+
19
+ <Dialog
20
+ header="顶部对话框"
21
+ placement="top"
22
+ visible={topVisible}
23
+ onClose={() => setTopVisible(false)}
24
+ onConfirm={() => setTopVisible(false)}
25
+ >
26
+ <p>这是一个显示在顶部的对话框。</p>
27
+ </Dialog>
28
+
29
+ <Dialog
30
+ header="居中对话框"
31
+ placement="center"
32
+ visible={centerVisible}
33
+ onClose={() => setCenterVisible(false)}
34
+ onConfirm={() => setCenterVisible(false)}
35
+ >
36
+ <p>这是一个垂直居中的对话框。</p>
37
+ </Dialog>
38
+ </>
39
+ );
40
+ }
@@ -0,0 +1,69 @@
1
+ import React from "react";
2
+ import { Button, DialogPlugin } from "@tendaui/react";
3
+
4
+ export default function PluginExample() {
5
+ const buttonStyle = { marginRight: 16 };
6
+
7
+ const showDialog = () => {
8
+ const myDialog = DialogPlugin({
9
+ header: "DialogPlugin 调用",
10
+ body: "这是通过 DialogPlugin 函数调用的对话框",
11
+ onConfirm: ({ e }) => {
12
+ console.log("confirm clicked", e);
13
+ myDialog.hide();
14
+ },
15
+ onClose: ({ trigger }) => {
16
+ console.log("trigger:", trigger);
17
+ myDialog.hide();
18
+ }
19
+ });
20
+ };
21
+
22
+ const showConfirm = () => {
23
+ const confirmDialog = DialogPlugin.confirm({
24
+ header: "确认操作",
25
+ body: "确定要执行此操作吗?",
26
+ confirmBtn: "确定",
27
+ cancelBtn: "取消",
28
+ onConfirm: () => {
29
+ confirmDialog.hide();
30
+ },
31
+ onClose: () => {
32
+ confirmDialog.hide();
33
+ }
34
+ });
35
+ };
36
+
37
+ const showAlert = () => {
38
+ const alertDialog = DialogPlugin.alert({
39
+ header: "提示",
40
+ body: "这是一条重要提示信息。",
41
+ confirmBtn: { content: "我知道了", theme: "primary" },
42
+ onConfirm: () => {
43
+ alertDialog.hide();
44
+ },
45
+ onClose: () => {
46
+ alertDialog.hide();
47
+ }
48
+ });
49
+ };
50
+
51
+ return (
52
+ <div>
53
+ <p style={{ marginBottom: "16px", color: "#666" }}>
54
+ 函数调用方式:DialogPlugin(options) / DialogPlugin.confirm(options) / DialogPlugin.alert(options)
55
+ </p>
56
+ <div style={{ display: "flex", flexWrap: "wrap", gap: "12px" }}>
57
+ <Button theme="primary" onClick={showDialog} style={buttonStyle}>
58
+ DialogPlugin
59
+ </Button>
60
+ <Button theme="primary" onClick={showConfirm} style={buttonStyle}>
61
+ DialogPlugin.confirm
62
+ </Button>
63
+ <Button theme="primary" onClick={showAlert} style={buttonStyle}>
64
+ DialogPlugin.alert
65
+ </Button>
66
+ </div>
67
+ </div>
68
+ );
69
+ }