antd-solid 0.0.12 → 0.0.13

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 (343) hide show
  1. package/css/index.css +10 -77
  2. package/dist/index.esm.js +7819 -2492
  3. package/dist/index.umd.js +1 -1
  4. package/es/Alert/index.d.ts +10 -0
  5. package/es/Alert/index.js +26 -0
  6. package/es/Button/index.d.ts +16 -4
  7. package/es/Button/index.js +107 -59
  8. package/es/Button/index.scss.js +1 -1
  9. package/es/Checkbox/Group.d.ts +19 -0
  10. package/es/Checkbox/Group.js +49 -0
  11. package/es/Checkbox/index.d.ts +15 -0
  12. package/es/Checkbox/index.js +60 -0
  13. package/es/CodeInput/index.d.ts +18 -0
  14. package/es/CodeInput/index.js +72 -0
  15. package/es/Collapse/Item.d.ts +46 -0
  16. package/es/Collapse/Item.js +130 -0
  17. package/es/Collapse/context.d.ts +5 -0
  18. package/es/Collapse/context.js +8 -0
  19. package/es/Collapse/index.d.ts +25 -10
  20. package/es/Collapse/index.js +95 -74
  21. package/es/Collapse/utils.d.ts +8 -0
  22. package/es/Collapse/utils.js +35 -0
  23. package/es/ColorPicker/ColorPickerInput.d.ts +3 -0
  24. package/es/ColorPicker/ColorPickerInput.js +250 -0
  25. package/es/ColorPicker/ColorPickerSelect.d.ts +3 -0
  26. package/es/ColorPicker/ColorPickerSelect.js +71 -0
  27. package/es/ColorPicker/ColorPickerSlider.d.ts +3 -0
  28. package/es/ColorPicker/ColorPickerSlider.js +115 -0
  29. package/es/ColorPicker/color.d.ts +24 -0
  30. package/es/ColorPicker/color.js +63 -0
  31. package/es/ColorPicker/context.d.ts +9 -0
  32. package/es/ColorPicker/context.js +5 -0
  33. package/es/ColorPicker/index.d.ts +31 -0
  34. package/es/ColorPicker/index.js +139 -0
  35. package/es/Command/context.d.ts +9 -0
  36. package/es/Command/context.js +11 -0
  37. package/es/Command/createCommand.d.ts +17 -0
  38. package/es/Command/createCommand.js +112 -0
  39. package/es/Command/index.d.ts +7 -0
  40. package/es/Command/index.js +9 -0
  41. package/es/Command/useCommandProps.d.ts +13 -0
  42. package/es/Command/useCommandProps.js +28 -0
  43. package/es/Compact/CompactContextIsolator.d.ts +3 -0
  44. package/es/Compact/CompactContextIsolator.js +15 -0
  45. package/es/Compact/context.d.ts +4 -0
  46. package/es/Compact/context.js +7 -0
  47. package/es/Compact/index.d.ts +11 -9
  48. package/es/Compact/index.js +28 -13
  49. package/es/Compact/index.scss.js +6 -0
  50. package/es/ConfigProvider/context.d.ts +11 -0
  51. package/es/ConfigProvider/context.js +15 -0
  52. package/es/ConfigProvider/dark/colorAlgorithm.d.ts +2 -0
  53. package/es/ConfigProvider/dark/colorAlgorithm.js +9 -0
  54. package/es/ConfigProvider/dark/colors.d.ts +3 -0
  55. package/es/ConfigProvider/dark/colors.js +47 -0
  56. package/es/ConfigProvider/dark/index.d.ts +2 -0
  57. package/es/ConfigProvider/dark/index.js +11 -0
  58. package/es/ConfigProvider/index.d.ts +32 -0
  59. package/es/ConfigProvider/index.js +44 -0
  60. package/es/ConfigProvider/light/colorAlgorithm.d.ts +2 -0
  61. package/es/ConfigProvider/light/colorAlgorithm.js +9 -0
  62. package/es/ConfigProvider/light/colors.d.ts +3 -0
  63. package/es/ConfigProvider/light/colors.js +45 -0
  64. package/es/ConfigProvider/light/index.d.ts +2 -0
  65. package/es/ConfigProvider/light/index.js +11 -0
  66. package/es/ConfigProvider/seed.d.ts +3 -0
  67. package/es/ConfigProvider/seed.js +22 -0
  68. package/es/ConfigProvider/types/index.d.ts +594 -0
  69. package/es/ConfigProvider/types/index.js +1 -0
  70. package/es/ConfigProvider/utils/genColorMapToken.d.ts +7 -0
  71. package/es/ConfigProvider/utils/genColorMapToken.js +85 -0
  72. package/es/ConfigProvider/utils/getAlphaColor.d.ts +2 -0
  73. package/es/ConfigProvider/utils/getAlphaColor.js +44 -0
  74. package/es/ConfigProvider/utils/index.d.ts +3 -0
  75. package/es/ConfigProvider/utils/index.js +181 -0
  76. package/es/ContextMenu/index.d.ts +8 -0
  77. package/es/ContextMenu/index.js +99 -0
  78. package/es/Cursor/index.d.ts +6 -0
  79. package/es/Cursor/index.js +71 -0
  80. package/es/DelayShow/index.d.ts +16 -0
  81. package/es/DelayShow/index.js +27 -0
  82. package/es/Divider/index.d.ts +17 -0
  83. package/es/Divider/index.js +71 -0
  84. package/es/Drawer/index.d.ts +20 -16
  85. package/es/Drawer/index.js +162 -111
  86. package/es/Drawer/index.scss.js +1 -1
  87. package/es/Dropdown/index.d.ts +16 -0
  88. package/es/Dropdown/index.js +47 -0
  89. package/es/Element/index.d.ts +10 -0
  90. package/es/Element/index.js +42 -0
  91. package/es/Empty/PRESENTED_IMAGE_SIMPLE.d.ts +2 -1
  92. package/es/Empty/PRESENTED_IMAGE_SIMPLE.js +25 -9
  93. package/es/Empty/assets/EmptySvg.js +1 -1
  94. package/es/Empty/assets/SimpleEmptySvg.js +1 -1
  95. package/es/Empty/index.d.ts +4 -2
  96. package/es/Empty/index.js +23 -13
  97. package/es/Form/Form.d.ts +8 -5
  98. package/es/Form/Form.js +50 -34
  99. package/es/Form/FormItem.d.ts +10 -5
  100. package/es/Form/FormItem.js +121 -104
  101. package/es/Form/context.d.ts +9 -9
  102. package/es/Form/context.js +4 -2
  103. package/es/Fragment/index.d.ts +4 -0
  104. package/es/Fragment/index.js +7 -0
  105. package/es/Image/index.d.ts +10 -0
  106. package/es/Image/index.js +37 -0
  107. package/es/Input/TextArea.d.ts +23 -0
  108. package/es/Input/TextArea.js +84 -0
  109. package/es/Input/index.d.ts +44 -0
  110. package/es/Input/index.js +213 -0
  111. package/es/Input/index.scss.js +6 -0
  112. package/es/InputNumber/index.d.ts +30 -0
  113. package/es/InputNumber/index.js +122 -0
  114. package/es/{InputNumber.test.js → InputNumber/index.test.js} +2 -1
  115. package/es/Menu/InternalMenu.d.ts +22 -0
  116. package/es/Menu/InternalMenu.js +196 -0
  117. package/es/Menu/index.d.ts +75 -0
  118. package/es/Menu/index.js +64 -0
  119. package/es/Message/Message.d.ts +9 -0
  120. package/es/Message/Message.js +34 -0
  121. package/es/Message/index.d.ts +12 -0
  122. package/es/Message/index.js +80 -0
  123. package/es/Message/index.scss.js +6 -0
  124. package/es/Message/useMessage.d.ts +6 -0
  125. package/es/Message/useMessage.js +54 -0
  126. package/es/Modal/index.d.ts +73 -0
  127. package/es/Modal/index.js +237 -0
  128. package/es/Modal/index.scss.js +6 -0
  129. package/es/Modal/useModal.d.ts +5 -0
  130. package/es/Modal/useModal.js +51 -0
  131. package/es/Modal/warning.d.ts +5 -0
  132. package/es/Modal/warning.js +43 -0
  133. package/es/{Popconfirm.d.ts → Popconfirm/index.d.ts} +2 -2
  134. package/es/Popconfirm/index.js +62 -0
  135. package/es/{Popover.d.ts → Popover/index.d.ts} +2 -2
  136. package/es/{Popover.js → Popover/index.js} +7 -12
  137. package/es/Progress/Circle.d.ts +16 -0
  138. package/es/Progress/Circle.js +122 -0
  139. package/es/Progress/index.d.ts +5 -2
  140. package/es/Progress/index.js +70 -65
  141. package/es/Radio/Button.d.ts +7 -0
  142. package/es/Radio/Button.js +72 -0
  143. package/es/Radio/Group.d.ts +18 -0
  144. package/es/Radio/Group.js +57 -0
  145. package/es/Radio/index.d.ts +14 -0
  146. package/es/Radio/index.js +68 -0
  147. package/es/RangeInput/index.d.ts +23 -0
  148. package/es/RangeInput/index.js +208 -0
  149. package/es/Result/index.js +49 -0
  150. package/es/Segmented/index.d.ts +10 -7
  151. package/es/Segmented/index.js +54 -53
  152. package/es/Select/index.d.ts +17 -0
  153. package/es/Select/index.js +75 -0
  154. package/es/SelectInput/index.d.ts +39 -0
  155. package/es/SelectInput/index.js +245 -0
  156. package/es/Slider/index.d.ts +47 -0
  157. package/es/Slider/index.js +177 -0
  158. package/es/Space/index.d.ts +13 -0
  159. package/es/Space/index.js +16 -0
  160. package/es/Spin/index.d.ts +19 -0
  161. package/es/Spin/index.js +82 -0
  162. package/es/{Switch.d.ts → Switch/index.d.ts} +9 -0
  163. package/es/Switch/index.js +41 -0
  164. package/es/{Table.d.ts → Table/index.d.ts} +6 -2
  165. package/es/Table/index.js +71 -0
  166. package/es/Tabs/index.d.ts +49 -0
  167. package/es/Tabs/index.js +256 -0
  168. package/es/Timeline/index.js +31 -0
  169. package/es/Tooltip/context.d.ts +5 -0
  170. package/es/Tooltip/context.js +5 -0
  171. package/es/Tooltip/index.d.ts +64 -0
  172. package/es/Tooltip/index.js +499 -0
  173. package/es/Transformer/index.d.ts +88 -0
  174. package/es/Transformer/index.js +882 -0
  175. package/es/Tree/SingleLevelTree.d.ts +28 -0
  176. package/es/Tree/SingleLevelTree.js +299 -0
  177. package/es/Tree/index.d.ts +83 -0
  178. package/es/Tree/index.js +197 -0
  179. package/es/TreeFor/index.d.ts +31 -0
  180. package/es/TreeFor/index.js +80 -0
  181. package/es/TreeSelect/index.d.ts +26 -0
  182. package/es/TreeSelect/index.js +98 -0
  183. package/es/{Upload.d.ts → Upload/index.d.ts} +8 -1
  184. package/es/Upload/index.js +112 -0
  185. package/es/assets/svg/ColorPickUp.d.ts +4 -0
  186. package/es/assets/svg/ColorPickUp.js +25 -0
  187. package/es/assets/svg/Crosshair.d.ts +7 -0
  188. package/es/assets/svg/Crosshair.js +51 -0
  189. package/es/assets/svg/Resize.d.ts +4 -0
  190. package/es/assets/svg/Resize.js +25 -0
  191. package/es/assets/svg/Rotate.d.ts +4 -0
  192. package/es/assets/svg/Rotate.js +20 -0
  193. package/es/assets/svg/RotateArrow.d.ts +4 -0
  194. package/es/assets/svg/RotateArrow.js +21 -0
  195. package/es/assets/svg/common.d.ts +2 -0
  196. package/es/assets/svg/common.js +9 -0
  197. package/es/hooks/createControllableValue.d.ts +1 -1
  198. package/es/hooks/createControllableValue.js +16 -17
  199. package/es/hooks/createTransition.d.ts +6 -2
  200. package/es/hooks/createTransition.js +12 -8
  201. package/es/hooks/useClickAway.d.ts +1 -1
  202. package/es/hooks/useClickAway.js +4 -3
  203. package/es/hooks/useComponentSize.d.ts +3 -0
  204. package/es/hooks/useComponentSize.js +12 -0
  205. package/es/hooks/useCounter.d.ts +12 -0
  206. package/es/hooks/useCounter.js +30 -0
  207. package/es/hooks/useFocus.d.ts +2 -0
  208. package/es/hooks/useFocus.js +24 -0
  209. package/es/hooks/useHover.d.ts +2 -0
  210. package/es/hooks/useHover.js +33 -0
  211. package/es/hooks/useLocale.d.ts +1 -0
  212. package/es/hooks/useLocale.js +11 -0
  213. package/es/hooks/useMouse.d.ts +1 -0
  214. package/es/hooks/useMouse.js +18 -0
  215. package/es/hooks/useScroll.d.ts +2 -0
  216. package/es/hooks/useScroll.js +29 -0
  217. package/es/hooks/useSize.d.ts +8 -2
  218. package/es/hooks/useSize.js +25 -13
  219. package/es/hooks/useVirtualList.d.ts +14 -0
  220. package/es/hooks/useVirtualList.js +45 -0
  221. package/es/index.d.ts +59 -8
  222. package/es/index.js +51 -21
  223. package/es/locale/en_US.d.ts +3 -0
  224. package/es/locale/en_US.js +9 -0
  225. package/es/locale/index.d.ts +5 -0
  226. package/es/locale/index.js +1 -0
  227. package/es/locale/zh_CN.d.ts +3 -0
  228. package/es/locale/zh_CN.js +9 -0
  229. package/es/types/index.d.ts +11 -2
  230. package/es/utils/animation.d.ts +6 -0
  231. package/es/utils/animation.js +20 -0
  232. package/es/utils/array.d.ts +2 -1
  233. package/es/utils/array.js +5 -1
  234. package/es/utils/domPoint.d.ts +7 -0
  235. package/es/utils/domPoint.js +11 -0
  236. package/es/utils/math.d.ts +17 -0
  237. package/es/utils/math.js +25 -0
  238. package/es/utils/number.d.ts +1 -0
  239. package/es/utils/number.js +14 -0
  240. package/es/utils/setupGlobalDrag.d.ts +10 -0
  241. package/es/utils/setupGlobalDrag.js +38 -0
  242. package/es/utils/solid.d.ts +2 -2
  243. package/es/utils/solid.js +7 -8
  244. package/package.json +10 -11
  245. package/es/ColorPicker.d.ts +0 -8
  246. package/es/ColorPicker.js +0 -6
  247. package/es/DatePicker.d.ts +0 -19
  248. package/es/DatePicker.js +0 -9
  249. package/es/Image.d.ts +0 -9
  250. package/es/Image.js +0 -22
  251. package/es/Input.d.ts +0 -29
  252. package/es/Input.js +0 -144
  253. package/es/InputNumber.d.ts +0 -11
  254. package/es/InputNumber.js +0 -92
  255. package/es/Modal.d.ts +0 -47
  256. package/es/Modal.js +0 -210
  257. package/es/Popconfirm.js +0 -64
  258. package/es/Radio.d.ts +0 -27
  259. package/es/Radio.js +0 -93
  260. package/es/Result.js +0 -29
  261. package/es/Select.d.ts +0 -16
  262. package/es/Select.js +0 -113
  263. package/es/Skeleton.d.ts +0 -9
  264. package/es/Skeleton.js +0 -9
  265. package/es/Spin.d.ts +0 -10
  266. package/es/Spin.js +0 -28
  267. package/es/Switch.js +0 -30
  268. package/es/Table.js +0 -57
  269. package/es/Tabs.d.ts +0 -17
  270. package/es/Tabs.js +0 -117
  271. package/es/Timeline.js +0 -30
  272. package/es/Tooltip.d.ts +0 -34
  273. package/es/Tooltip.js +0 -302
  274. package/es/Tree.d.ts +0 -28
  275. package/es/Tree.js +0 -198
  276. package/es/Upload.js +0 -96
  277. package/es/hooks/createUpdateEffect.d.ts +0 -5
  278. package/es/hooks/createUpdateEffect.js +0 -12
  279. package/es/utils/EventEmitter.d.ts +0 -7
  280. package/es/utils/EventEmitter.js +0 -13
  281. package/es/utils/ReactToSolid.d.ts +0 -8
  282. package/es/utils/ReactToSolid.js +0 -30
  283. package/es/utils/SolidToReact.d.ts +0 -8
  284. package/es/utils/SolidToReact.js +0 -23
  285. package/es/utils/component.d.ts +0 -31
  286. package/es/utils/component.js +0 -68
  287. package/es/utils/zh_CN.d.ts +0 -2
  288. package/es/utils/zh_CN.js +0 -236
  289. package/src/Button/index.scss +0 -9
  290. package/src/Button/index.tsx +0 -137
  291. package/src/Collapse/index.tsx +0 -86
  292. package/src/ColorPicker.tsx +0 -11
  293. package/src/Compact/index.tsx +0 -20
  294. package/src/DatePicker.tsx +0 -30
  295. package/src/Drawer/index.scss +0 -53
  296. package/src/Drawer/index.tsx +0 -211
  297. package/src/Empty/PRESENTED_IMAGE_SIMPLE.tsx +0 -15
  298. package/src/Empty/assets/EmptySvg.tsx +0 -43
  299. package/src/Empty/assets/SimpleEmptySvg.tsx +0 -16
  300. package/src/Empty/index.tsx +0 -25
  301. package/src/Form/Form.tsx +0 -94
  302. package/src/Form/FormItem.tsx +0 -141
  303. package/src/Form/context.ts +0 -16
  304. package/src/Form/index.ts +0 -13
  305. package/src/Image.tsx +0 -29
  306. package/src/Input.tsx +0 -202
  307. package/src/InputNumber.test.tsx +0 -46
  308. package/src/InputNumber.tsx +0 -139
  309. package/src/Modal.tsx +0 -221
  310. package/src/Popconfirm.tsx +0 -75
  311. package/src/Popover.tsx +0 -30
  312. package/src/Progress/index.tsx +0 -81
  313. package/src/Radio.tsx +0 -142
  314. package/src/Result.tsx +0 -38
  315. package/src/Segmented/index.tsx +0 -95
  316. package/src/Select.tsx +0 -138
  317. package/src/Skeleton.tsx +0 -14
  318. package/src/Spin.tsx +0 -34
  319. package/src/Switch.tsx +0 -34
  320. package/src/Table.tsx +0 -53
  321. package/src/Tabs.tsx +0 -131
  322. package/src/Timeline.tsx +0 -33
  323. package/src/Tooltip.tsx +0 -340
  324. package/src/Tree.tsx +0 -247
  325. package/src/Upload.tsx +0 -143
  326. package/src/hooks/createControllableValue.ts +0 -68
  327. package/src/hooks/createTransition.ts +0 -52
  328. package/src/hooks/createUpdateEffect.ts +0 -16
  329. package/src/hooks/index.ts +0 -2
  330. package/src/hooks/useClickAway.ts +0 -18
  331. package/src/hooks/useSize.ts +0 -26
  332. package/src/index.ts +0 -47
  333. package/src/types/index.ts +0 -5
  334. package/src/utils/EventEmitter.ts +0 -15
  335. package/src/utils/ReactToSolid.tsx +0 -38
  336. package/src/utils/SolidToReact.tsx +0 -27
  337. package/src/utils/array.ts +0 -21
  338. package/src/utils/component.tsx +0 -85
  339. package/src/utils/solid.ts +0 -61
  340. package/src/utils/zh_CN.ts +0 -236
  341. /package/es/{InputNumber.test.d.ts → InputNumber/index.test.d.ts} +0 -0
  342. /package/es/{Result.d.ts → Result/index.d.ts} +0 -0
  343. /package/es/{Timeline.d.ts → Timeline/index.d.ts} +0 -0
package/src/Input.tsx DELETED
@@ -1,202 +0,0 @@
1
- import { isNil, omit } from 'lodash-es'
2
- import { Show, createMemo, splitProps } from 'solid-js'
3
- import type { JSX, JSXElement, Component } from 'solid-js'
4
- import cs from 'classnames'
5
- import createControllableValue from './hooks/createControllableValue'
6
- import { Dynamic } from 'solid-js/web'
7
- import Compact from './Compact'
8
-
9
- type CommonInputProps<T extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement> =
10
- JSX.CustomAttributes<T> & {
11
- textarea?: boolean
12
- defaultValue?: string | undefined
13
- value?: string | undefined
14
- addonBefore?: JSXElement
15
- addonAfter?: JSXElement
16
- prefix?: JSXElement
17
- suffix?: JSXElement
18
- placeholder?: string
19
- /**
20
- * 仅供 InputNumber 使用
21
- */
22
- actions?: JSXElement
23
- /**
24
- * 设置校验状态
25
- */
26
- status?: 'error' | 'warning'
27
- onChange?: JSX.InputEventHandler<T, InputEvent>
28
- onPressEnter?: JSX.EventHandler<T, KeyboardEvent>
29
- onKeyDown?: JSX.EventHandler<T, KeyboardEvent>
30
- }
31
-
32
- const statusClassDict = {
33
- default: (disabled: boolean) =>
34
- cs(
35
- 'ant-[border:1px_solid_var(--ant-color-border)]',
36
- !disabled &&
37
- 'hover:ant-border-[var(--ant-color-primary)] focus-within:ant-border-[var(--ant-color-primary)] focus-within:ant-[box-shadow:0_0_0_2px_rgba(5,145,255,0.1)]',
38
- ),
39
- error: (disabled: boolean) =>
40
- cs(
41
- 'ant-[border:1px_solid_var(--ant-color-error)]',
42
- !disabled &&
43
- 'hover:ant-border-[var(--light-error-color)] focus-within:ant-[box-shadow:0_0_0_2px_rgba(255,38,5,.06)]',
44
- ),
45
- warning: (disabled: boolean) =>
46
- cs(
47
- 'ant-[border:1px_solid_var(--warning-color)]',
48
- !disabled &&
49
- 'hover:ant-border-[var(--color-warning-border-hover)] focus-within:ant-[box-shadow:0_0_0_2px_rgba(255,215,5,.1)]',
50
- ),
51
- }
52
-
53
- export function CommonInput<T extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement>(
54
- props: CommonInputProps<T> &
55
- Omit<JSX.InputHTMLAttributes<T>, 'onChange' | 'onInput' | 'onKeyDown'>,
56
- ) {
57
- const [{ style, onChange, onPressEnter, onKeyDown }, inputProps] = splitProps(props, [
58
- 'defaultValue',
59
- 'value',
60
- 'class',
61
- 'addonBefore',
62
- 'addonAfter',
63
- 'suffix',
64
- 'onChange',
65
- 'onPressEnter',
66
- 'onKeyDown',
67
- 'actions',
68
- 'style',
69
- ])
70
-
71
- const [_, controllableProps] = splitProps(props, ['onChange'])
72
- const [value, setValue] = createControllableValue(controllableProps)
73
-
74
- const inputWrapClass = createMemo(() =>
75
- cs(
76
- 'ant-px-11px ant-py-4px ant-rounded-6px',
77
- !props.textarea && 'ant-h-32px',
78
- props.addonBefore ? 'ant-rounded-l-0' : Compact.compactItemRoundedLeftClass,
79
- props.addonAfter ? 'ant-rounded-r-0' : Compact.compactItemRoundedRightClass,
80
- statusClassDict[props.status ?? 'default'](!!inputProps.disabled),
81
- Compact.compactItemRounded0Class,
82
- Compact.compactItemZIndexClass,
83
- ),
84
- )
85
- const hasPrefixOrSuffix = createMemo(
86
- () => !isNil(props.prefix) || !isNil(props.suffix) || !isNil(props.actions),
87
- )
88
- const inputJSX = (
89
- <Dynamic<Component<JSX.InputHTMLAttributes<HTMLInputElement>>>
90
- component={
91
- (props.textarea ? 'textarea' : 'input') as unknown as Component<
92
- JSX.InputHTMLAttributes<HTMLInputElement>
93
- >
94
- }
95
- {...(inputProps as JSX.InputHTMLAttributes<HTMLInputElement>)}
96
- class={cs(
97
- 'ant-w-full ant-[outline:none] ant-text-14px',
98
- !hasPrefixOrSuffix() && inputWrapClass(),
99
- inputProps.disabled &&
100
- 'ant-bg-[var(--ant-color-bg-container-disabled)] ant-cursor-not-allowed',
101
- )}
102
- value={value() ?? ''}
103
- onInput={e => {
104
- setValue(e.target.value)
105
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
106
- onChange?.(e as any)
107
-
108
- if (Object.keys(props).includes('value')) {
109
- e.target.value = value()
110
- }
111
- }}
112
- onKeyDown={e => {
113
- if (e.key === 'Enter') {
114
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
115
- onPressEnter?.(e as any)
116
- }
117
-
118
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
119
- onKeyDown?.(e as any)
120
- }}
121
- />
122
- )
123
-
124
- return (
125
- <div class={cs('ant-flex ant-w-full', Compact.compactItemClass)} style={style}>
126
- <Show when={props.addonBefore}>
127
- <div
128
- class={cs(
129
- 'ant-shrink-0 ant-flex ant-justify-center ant-items-center ant-px-11px ant-bg-[rgba(0,0,0,.02)] ant-[border:1px_solid_var(--ant-color-border)] ant-border-r-0 ant-rounded-l-6px ant-text-14px',
130
- Compact.compactItemRounded0Class,
131
- Compact.compactItemRoundedLeftClass,
132
- )}
133
- >
134
- {props.addonBefore}
135
- </div>
136
- </Show>
137
-
138
- <Show when={hasPrefixOrSuffix()} fallback={inputJSX}>
139
- <div
140
- class={cs(
141
- 'ant-flex ant-items-center ant-w-full ant-relative ant-[--input-after-display:none] hover:ant-[--input-after-display:block] p:hover-child[input]:ant-border-[var(--ant-color-primary)]',
142
- inputWrapClass(),
143
- )}
144
- >
145
- <Show when={props.prefix}>
146
- <div class="ant-mr-4px">{props.prefix}</div>
147
- </Show>
148
-
149
- {inputJSX}
150
-
151
- <Show when={props.suffix}>
152
- <div class="ant-ml-4px">{props.suffix}</div>
153
- </Show>
154
-
155
- <Show when={props.actions}>
156
- <div class="ant-[display:var(--input-after-display)] ant-absolute ant-top-0 ant-bottom-0 ant-right-0 ant-h-[calc(100%-2px)] ant-translate-y-1px -ant-translate-x-1px">
157
- {props.actions}
158
- </div>
159
- </Show>
160
- </div>
161
- </Show>
162
-
163
- <Show when={props.addonAfter}>
164
- <div
165
- class={cs(
166
- 'ant-shrink-0 ant-flex ant-justify-center ant-items-center ant-px-11px ant-bg-[rgba(0,0,0,.02)] ant-[border:1px_solid_var(--ant-color-border)] ant-border-l-0 ant-rounded-r-6px ant-text-14px',
167
- Compact.compactItemRounded0Class,
168
- Compact.compactItemRoundedRightClass,
169
- )}
170
- >
171
- {props.addonAfter}
172
- </div>
173
- </Show>
174
- </div>
175
- )
176
- }
177
-
178
- export type InputProps = Omit<CommonInputProps, 'actions' | 'textarea'> &
179
- Omit<JSX.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'onInput' | 'onKeyDown'>
180
-
181
- export type TextAreaProps = Omit<
182
- CommonInputProps<HTMLTextAreaElement>,
183
- 'prefix' | 'suffix' | 'textarea'
184
- > &
185
- Omit<
186
- JSX.TextareaHTMLAttributes<HTMLTextAreaElement>,
187
- 'actions' | 'onChange' | 'onInput' | 'onKeyDown'
188
- >
189
-
190
- const Input: Component<InputProps> & {
191
- TextArea: Component<TextAreaProps>
192
- } = props => {
193
- return <CommonInput {...omit(props, ['actions'])} />
194
- }
195
-
196
- Input.TextArea = props => {
197
- return (
198
- <CommonInput<HTMLTextAreaElement> textarea {...omit(props, ['prefix', 'suffix', 'actions'])} />
199
- )
200
- }
201
-
202
- export default Input
@@ -1,46 +0,0 @@
1
- import { describe, expect, it, vi } from 'vitest'
2
- import { fireEvent, render } from '@solidjs/testing-library'
3
- import InputNumber from './InputNumber'
4
- import '@testing-library/jest-dom'
5
-
6
- describe('InputNumber component', () => {
7
- it('onChange', () => {
8
- const onChange = vi.fn()
9
- const { getByPlaceholderText } = render(() => (
10
- <InputNumber placeholder="input-number" onChange={onChange} />
11
- ))
12
-
13
- const input: HTMLInputElement = getByPlaceholderText('input-number')
14
- input.value = '123'
15
- fireEvent.input(input)
16
- expect(onChange).toHaveBeenLastCalledWith(123)
17
-
18
- input.value = '1234'
19
- fireEvent.input(input)
20
- expect(onChange).toBeCalledTimes(2)
21
- expect(onChange).toHaveBeenLastCalledWith(1234)
22
-
23
- input.value = '1234'
24
- fireEvent.input(input)
25
- expect(onChange).toBeCalledTimes(2)
26
-
27
- input.value = '1234.'
28
- fireEvent.input(input)
29
- expect(onChange).toBeCalledTimes(2)
30
-
31
- input.value = '1234.0'
32
- fireEvent.input(input)
33
- expect(onChange).toBeCalledTimes(2)
34
-
35
- input.value = '1234.01'
36
- fireEvent.input(input)
37
- expect(onChange).toBeCalledTimes(3)
38
-
39
- input.value = '123x'
40
- fireEvent.input(input)
41
- expect(onChange).toBeCalledTimes(3)
42
-
43
- fireEvent.blur(input)
44
- expect(onChange).toBeCalledTimes(3)
45
- })
46
- })
@@ -1,139 +0,0 @@
1
- import {
2
- type Component,
3
- createEffect,
4
- on,
5
- splitProps,
6
- untrack,
7
- createSignal,
8
- mergeProps,
9
- } from 'solid-js'
10
- import { CommonInput, type InputProps } from './Input'
11
- import { clamp, isNil } from 'lodash-es'
12
- import { dispatchEventHandlerUnion } from './utils/solid'
13
-
14
- export interface InputNumberProps
15
- extends Omit<
16
- InputProps,
17
- 'defaultValue' | 'value' | 'onChange' | 'inputAfter' | 'onKeyDown' | 'min' | 'max' | 'suffix'
18
- > {
19
- defaultValue?: number | null | undefined
20
- value?: number | null | undefined
21
- onChange?: (value: number | null) => void
22
- min?: number
23
- max?: number
24
- }
25
-
26
- const isEmptyValue = (value: number | string | null | undefined) => isNil(value) || value === ''
27
-
28
- const actionBtnClass =
29
- 'ant-text-12px ant-flex ant-justify-center ant-items-center ant-h-1/2 ant-cursor-pointer ant-opacity-70 hover:ant-h-100% hover:ant-text-[var(--ant-color-primary)] ant-transition-color ant-transition-height ant-transition-duration-500'
30
-
31
- const InputNumber: Component<InputNumberProps> = _props => {
32
- const props = mergeProps(
33
- {
34
- min: -Infinity,
35
- max: Infinity,
36
- },
37
- _props,
38
- )
39
- const [_, inputProps] = splitProps(props, ['defaultValue', 'value', 'onChange', 'onBlur'])
40
-
41
- const clampValue = (v: number) => untrack(() => clamp(v, props.min, props.max))
42
-
43
- let prev: number | null = null
44
- const updatePrev = (v: number | null) => {
45
- if (prev === v) return
46
-
47
- prev = v
48
- props.onChange?.(prev)
49
- }
50
-
51
- const [value, setValue] = createSignal<number | string | null | undefined>(
52
- untrack(() => props.value ?? props.defaultValue),
53
- )
54
- createEffect(
55
- on(
56
- () => props.value,
57
- () => {
58
- setValue(props.value)
59
- },
60
- {
61
- defer: true,
62
- },
63
- ),
64
- )
65
-
66
- const add = (addon: number) => {
67
- let newValue: number | null
68
- if (isEmptyValue(value())) {
69
- newValue = clampValue(addon)
70
- } else {
71
- const num = Number(value())
72
- newValue = Number.isNaN(num) ? null : clampValue(num + addon)
73
- }
74
-
75
- if (!Object.keys(props).includes('value')) {
76
- setValue(newValue)
77
- }
78
- updatePrev(newValue)
79
- }
80
- const up = () => {
81
- add(1)
82
- }
83
- const down = () => {
84
- add(-1)
85
- }
86
-
87
- return (
88
- <CommonInput
89
- {...inputProps}
90
- actions={
91
- <div class="ant-flex ant-flex-col ant-h-full ant-w-24px ant-[border-left:1px_solid_var(--ant-color-border)]">
92
- <div class={actionBtnClass} onClick={up}>
93
- <div class="i-ant-design:up-outlined" />
94
- </div>
95
- <div
96
- class={`ant-[border-top:1px_solid_var(--ant-color-border)] ${actionBtnClass}`}
97
- onClick={down}
98
- >
99
- <div class="i-ant-design:down-outlined" />
100
- </div>
101
- </div>
102
- }
103
- value={`${value() ?? ''}`}
104
- onKeyDown={e => {
105
- switch (e.key) {
106
- case 'ArrowUp':
107
- up()
108
- e.preventDefault()
109
- return
110
- case 'ArrowDown':
111
- down()
112
- e.preventDefault()
113
- }
114
- }}
115
- onChange={e => {
116
- const newValue = e.target.value
117
- setValue(newValue)
118
-
119
- let newValueNum: number | null = Number(newValue)
120
- if (Number.isNaN(newValueNum)) return
121
-
122
- if (isEmptyValue(newValue)) {
123
- newValueNum = null
124
- } else {
125
- newValueNum = clampValue(newValueNum)
126
- }
127
-
128
- updatePrev(newValueNum)
129
- }}
130
- onBlur={e => {
131
- setValue(props.value ?? prev)
132
-
133
- dispatchEventHandlerUnion(props.onBlur, e)
134
- }}
135
- />
136
- )
137
- }
138
-
139
- export default InputNumber
package/src/Modal.tsx DELETED
@@ -1,221 +0,0 @@
1
- import { type JSXElement, Show, createSignal, untrack, type Ref, mergeProps } from 'solid-js'
2
- import { Portal, render } from 'solid-js/web'
3
- import Button from './Button'
4
- import cs from 'classnames'
5
-
6
- export interface ModalInstance {
7
- open: () => void
8
- close: () => void
9
- }
10
-
11
- export interface ModalProps {
12
- ref?: Ref<ModalInstance>
13
- title?: JSXElement
14
- defaultOpen?: boolean
15
- width?: string
16
- height?: string
17
- children?: JSXElement
18
- /**
19
- * 垂直居中展示 Modal
20
- */
21
- centered?: boolean
22
- /**
23
- * 点击蒙层是否允许关闭
24
- * 默认 true
25
- */
26
- maskClosable?: boolean
27
- /**
28
- * 设置为 false 时隐藏关闭按钮
29
- */
30
- closeIcon?: boolean
31
- footer?: boolean | ((modal: ModalInstance) => JSXElement)
32
- /**
33
- * 关闭时销毁 Modal 里的子元素
34
- */
35
- destroyOnClose?: boolean
36
- /**
37
- * 返回 true,会自动关闭 modal
38
- */
39
- onOk?: () => boolean | Promise<boolean>
40
- afterClose?: () => void
41
- /**
42
- * 自定义渲染对话框
43
- */
44
- modalRender?: () => JSXElement
45
- }
46
-
47
- export interface MethodProps
48
- extends Pick<ModalProps, 'title' | 'children' | 'onOk' | 'afterClose'> {}
49
-
50
- function Modal(_props: ModalProps) {
51
- const props = mergeProps({ footer: true }, _props)
52
- const [open, setOpen] = createSignal(props.defaultOpen ?? false)
53
- const [hide, setHide] = createSignal(false)
54
- let cleanup: () => void
55
-
56
- const instance: ModalInstance = {
57
- open() {
58
- setOpen(true)
59
- setHide(false)
60
-
61
- const originOverflow = document.body.style.overflow
62
- document.body.style.overflow = 'hidden'
63
-
64
- const onKeyup = (e: KeyboardEvent) => {
65
- if (e.key === 'Escape') {
66
- instance.close()
67
- }
68
- }
69
- document.addEventListener('keyup', onKeyup)
70
-
71
- cleanup = () => {
72
- document.body.style.overflow = originOverflow
73
- document.removeEventListener('keyup', onKeyup)
74
- }
75
- },
76
- close() {
77
- untrack(() => {
78
- if (props.destroyOnClose) {
79
- setOpen(false)
80
- } else {
81
- setHide(true)
82
- }
83
-
84
- cleanup()
85
- props.afterClose?.()
86
- })
87
- },
88
- }
89
- untrack(() => {
90
- if (typeof props.ref === 'function') {
91
- props.ref?.(instance)
92
- }
93
- })
94
-
95
- const [confirmLoading, setConfirmLoading] = createSignal(false)
96
-
97
- return (
98
- <Show when={open()}>
99
- <Portal>
100
- <div
101
- class={cs(
102
- 'ant-fixed ant-justify-center ant-inset-0 ant-bg-[rgba(0,0,0,.45)] ant-flex ant-z-1000',
103
- props.centered && 'ant-items-center',
104
- )}
105
- onClick={() => {
106
- if (props.maskClosable ?? true) {
107
- instance.close()
108
- }
109
- }}
110
- style={{ display: hide() ? 'none' : undefined }}
111
- >
112
- <Show when={typeof props.modalRender !== 'function'} fallback={props.modalRender!()}>
113
- <div
114
- class={cs(
115
- 'ant-absolute ant-px-24px ant-py-20px ant-rounded-8px ant-overflow-hidden ant-bg-white ant-flex ant-flex-col',
116
- // '!ant-[animation-duration:.5s]',
117
- !props.centered && 'ant-top-100px',
118
- )}
119
- onClick={e => {
120
- e.stopPropagation()
121
- }}
122
- style={{
123
- width: props.width ?? '520px',
124
- height: props.height,
125
- }}
126
- >
127
- {/* 关闭按钮 */}
128
- <Show when={props.closeIcon !== false}>
129
- <Button
130
- type="text"
131
- class={cs(
132
- 'ant-rm-size-btn !ant-w-22px !ant-h-22px !ant-flex !ant-justify-center !ant-items-center ant-text-center ant-text-18px !ant-absolute !ant-top-16px !ant-right-16px ant-z-1000 ant-text-[rgba(0,0,0,.45)] hover:!ant-text-[rgba(0,0,0,.88)]',
133
- )}
134
- onClick={() => {
135
- instance.close()
136
- }}
137
- >
138
- <span class="i-ant-design:close-outlined" />
139
- </Button>
140
- </Show>
141
-
142
- <div class="ant-text-[rgba(0,0,0,.88)] ant-text-16px ant-font-600 ant-mb-8px">
143
- {props.title}
144
- </div>
145
- <div class="ant-grow">{props.children}</div>
146
-
147
- <Show when={props.footer !== false}>
148
- <div class="ant-mt-12px">
149
- <Show
150
- when={typeof props.footer !== 'function'}
151
- fallback={typeof props.footer === 'function' && props.footer(instance)}
152
- >
153
- <div class="ant-flex ant-gap-8px ant-justify-end">
154
- <Button
155
- onClick={() => {
156
- instance.close()
157
- }}
158
- >
159
- 取消
160
- </Button>
161
- <Button
162
- type="primary"
163
- loading={confirmLoading()}
164
- // eslint-disable-next-line solid/reactivity, @typescript-eslint/no-misused-promises
165
- onClick={async () => {
166
- if (!props.onOk) return
167
-
168
- let res = props.onOk?.()
169
- if (res instanceof Promise) {
170
- setConfirmLoading(true)
171
- res = await res.finally(() => setConfirmLoading(false))
172
- }
173
- if (res) {
174
- instance.close()
175
- }
176
- }}
177
- >
178
- 确定
179
- </Button>
180
- </div>
181
- </Show>
182
- </div>
183
- </Show>
184
- </div>
185
- </Show>
186
- </div>
187
- </Portal>
188
- </Show>
189
- )
190
- }
191
-
192
- Modal.warning = (props: MethodProps) => {
193
- const div = document.createElement('div')
194
- document.body.appendChild(div)
195
- const dispose = render(
196
- () => (
197
- <Modal
198
- width="416px"
199
- maskClosable={false}
200
- closeIcon={false}
201
- {...props}
202
- title={
203
- <>
204
- <span class="i-ant-design:exclamation-circle ant-text-22px ant-mr-12px ant-text-[var(--warning-color)]" />
205
- {props.title}
206
- </>
207
- }
208
- children={<div class="ant-ml-34px">{props.children}</div>}
209
- defaultOpen
210
- afterClose={() => {
211
- document.body.removeChild(div)
212
- dispose()
213
- props.afterClose?.()
214
- }}
215
- />
216
- ),
217
- div,
218
- )
219
- }
220
-
221
- export default Modal
@@ -1,75 +0,0 @@
1
- import { type Component, type JSXElement, createSignal, mergeProps, untrack, splitProps } from 'solid-js'
2
- import Button from './Button'
3
- import Tooltip, { type TooltipProps } from './Tooltip'
4
-
5
- interface PopconfirmProps extends Pick<TooltipProps, 'placement' | 'arrow'> {
6
- title?: JSXElement
7
- content?: JSXElement
8
- children: JSXElement
9
- onCancel?: () => void
10
- onConfirm?: () => void
11
- /**
12
- * 确认按钮文字
13
- * 默认:确定
14
- */
15
- okText?: string
16
- /**
17
- * 取消按钮文字
18
- * 默认:取消
19
- */
20
- cancelText?: string
21
- }
22
-
23
- const Popconfirm: Component<PopconfirmProps> = props => {
24
- const mergedProps = mergeProps({ okText: '确定', cancelText: '取消' }, props)
25
- const [tooltipProps] = splitProps(props, ['placement', 'arrow'])
26
- const [open, setOpen] = createSignal(false)
27
-
28
- return (
29
- <Tooltip
30
- mode="light"
31
- trigger="click"
32
- open={open()}
33
- onOpenChange={setOpen}
34
- content={
35
- <div>
36
- <div class="ant-mb-8px ant-flex ant-items-center">
37
- <span class="i-ant-design:exclamation-circle-fill ant-text-#faad14" />
38
- <span class="ant-ml-8px ant-text-[rgba(0,0,0,0.88)] ant-font-600">{mergedProps.title}</span>
39
- </div>
40
-
41
- <div class="ant-ml-22px ant-mb-8px ant-text-[rgba(0,0,0,0.88)]">{mergedProps.content}</div>
42
-
43
- <div class="ant-text-right">
44
- <Button
45
- class="ant-ml-8px"
46
- size="small"
47
- onClick={() => {
48
- setOpen(false)
49
- untrack(() => mergedProps.onCancel?.())
50
- }}
51
- >
52
- {mergedProps.cancelText}
53
- </Button>
54
- <Button
55
- class="ant-ml-8px"
56
- type="primary"
57
- size="small"
58
- onClick={() => {
59
- setOpen(false)
60
- untrack(() => mergedProps.onConfirm?.())
61
- }}
62
- >
63
- {mergedProps.okText}
64
- </Button>
65
- </div>
66
- </div>
67
- }
68
- {...tooltipProps}
69
- >
70
- {mergedProps.children}
71
- </Tooltip>
72
- )
73
- }
74
-
75
- export default Popconfirm