antd-solid 0.0.11 → 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 (347) hide show
  1. package/css/index.css +10 -73
  2. package/dist/index.esm.js +7802 -2378
  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 +32 -0
  7. package/es/Button/index.js +123 -0
  8. package/es/Button/index.scss.js +6 -0
  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 +14 -0
  48. package/es/Compact/index.js +32 -0
  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 -112
  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 +9 -3
  96. package/es/Empty/index.js +24 -9
  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 +6 -4
  140. package/es/Progress/index.js +75 -60
  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/index.d.ts +64 -0
  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 +53 -23
  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/Button.d.ts +0 -19
  246. package/es/Button.js +0 -73
  247. package/es/ColorPicker.d.ts +0 -8
  248. package/es/ColorPicker.js +0 -6
  249. package/es/Compact.d.ts +0 -12
  250. package/es/Compact.js +0 -17
  251. package/es/DatePicker.d.ts +0 -19
  252. package/es/DatePicker.js +0 -9
  253. package/es/Image.d.ts +0 -9
  254. package/es/Image.js +0 -22
  255. package/es/Input.d.ts +0 -29
  256. package/es/Input.js +0 -144
  257. package/es/InputNumber.d.ts +0 -11
  258. package/es/InputNumber.js +0 -92
  259. package/es/Modal.d.ts +0 -48
  260. package/es/Modal.js +0 -209
  261. package/es/Popconfirm.js +0 -64
  262. package/es/Radio.d.ts +0 -27
  263. package/es/Radio.js +0 -93
  264. package/es/Result.js +0 -29
  265. package/es/Select.d.ts +0 -16
  266. package/es/Select.js +0 -113
  267. package/es/Skeleton.d.ts +0 -9
  268. package/es/Skeleton.js +0 -9
  269. package/es/Spin.d.ts +0 -9
  270. package/es/Spin.js +0 -22
  271. package/es/Switch.js +0 -30
  272. package/es/Table.js +0 -57
  273. package/es/Tabs.d.ts +0 -17
  274. package/es/Tabs.js +0 -117
  275. package/es/Timeline.js +0 -30
  276. package/es/Tooltip.d.ts +0 -34
  277. package/es/Tooltip.js +0 -302
  278. package/es/Tree.d.ts +0 -28
  279. package/es/Tree.js +0 -198
  280. package/es/Upload.d.ts +0 -11
  281. package/es/Upload.js +0 -6
  282. package/es/hooks/createUpdateEffect.d.ts +0 -5
  283. package/es/hooks/createUpdateEffect.js +0 -12
  284. package/es/utils/EventEmitter.d.ts +0 -7
  285. package/es/utils/EventEmitter.js +0 -13
  286. package/es/utils/ReactToSolid.d.ts +0 -8
  287. package/es/utils/ReactToSolid.js +0 -30
  288. package/es/utils/SolidToReact.d.ts +0 -8
  289. package/es/utils/SolidToReact.js +0 -23
  290. package/es/utils/component.d.ts +0 -31
  291. package/es/utils/component.js +0 -68
  292. package/es/utils/zh_CN.d.ts +0 -2
  293. package/es/utils/zh_CN.js +0 -236
  294. package/src/Button.tsx +0 -128
  295. package/src/Collapse/index.tsx +0 -86
  296. package/src/ColorPicker.tsx +0 -11
  297. package/src/Compact.tsx +0 -15
  298. package/src/DatePicker.tsx +0 -30
  299. package/src/Drawer/index.scss +0 -53
  300. package/src/Drawer/index.tsx +0 -212
  301. package/src/Empty/PRESENTED_IMAGE_SIMPLE.tsx +0 -15
  302. package/src/Empty/assets/EmptySvg.tsx +0 -43
  303. package/src/Empty/assets/SimpleEmptySvg.tsx +0 -16
  304. package/src/Empty/index.tsx +0 -20
  305. package/src/Form/Form.tsx +0 -94
  306. package/src/Form/FormItem.tsx +0 -141
  307. package/src/Form/context.ts +0 -16
  308. package/src/Form/index.ts +0 -13
  309. package/src/Image.tsx +0 -29
  310. package/src/Input.tsx +0 -202
  311. package/src/InputNumber.test.tsx +0 -46
  312. package/src/InputNumber.tsx +0 -125
  313. package/src/Modal.tsx +0 -220
  314. package/src/Popconfirm.tsx +0 -75
  315. package/src/Popover.tsx +0 -30
  316. package/src/Progress/index.tsx +0 -73
  317. package/src/Radio.tsx +0 -142
  318. package/src/Result.tsx +0 -38
  319. package/src/Segmented/index.tsx +0 -95
  320. package/src/Select.tsx +0 -128
  321. package/src/Skeleton.tsx +0 -14
  322. package/src/Spin.tsx +0 -23
  323. package/src/Switch.tsx +0 -34
  324. package/src/Table.tsx +0 -53
  325. package/src/Tabs.tsx +0 -131
  326. package/src/Timeline.tsx +0 -33
  327. package/src/Tooltip.tsx +0 -340
  328. package/src/Tree.tsx +0 -246
  329. package/src/Upload.tsx +0 -10
  330. package/src/hooks/createControllableValue.ts +0 -68
  331. package/src/hooks/createTransition.ts +0 -52
  332. package/src/hooks/createUpdateEffect.ts +0 -16
  333. package/src/hooks/index.ts +0 -2
  334. package/src/hooks/useClickAway.ts +0 -18
  335. package/src/hooks/useSize.ts +0 -26
  336. package/src/index.ts +0 -47
  337. package/src/types/index.ts +0 -5
  338. package/src/utils/EventEmitter.ts +0 -15
  339. package/src/utils/ReactToSolid.tsx +0 -38
  340. package/src/utils/SolidToReact.tsx +0 -27
  341. package/src/utils/array.ts +0 -21
  342. package/src/utils/component.tsx +0 -85
  343. package/src/utils/solid.ts +0 -61
  344. package/src/utils/zh_CN.ts +0 -236
  345. /package/es/{InputNumber.test.d.ts → InputNumber/index.test.d.ts} +0 -0
  346. /package/es/{Result.d.ts → Result/index.d.ts} +0 -0
  347. /package/es/{Timeline.d.ts → Timeline/index.d.ts} +0 -0
@@ -1,212 +0,0 @@
1
- import {
2
- mergeProps,
3
- type Component,
4
- Show,
5
- type JSXElement,
6
- type Ref,
7
- createSignal,
8
- untrack,
9
- createMemo,
10
- } from 'solid-js'
11
- import cs from 'classnames'
12
- import Button from '../Button'
13
- import { setRef } from '../utils/solid'
14
- import { Portal } from 'solid-js/web'
15
- import { Transition } from 'solid-transition-group'
16
- import './index.scss'
17
- import createTransition from '../hooks/createTransition'
18
-
19
- export interface DrawerInstance {
20
- open: () => void
21
- close: () => void
22
- }
23
-
24
- export interface DrawerProps {
25
- ref?: Ref<DrawerInstance>
26
- title?: JSXElement
27
- extra?: JSXElement
28
- children?: JSXElement
29
- /**
30
- * 宽度
31
- * 默认 378px
32
- */
33
- width?: string
34
- /**
35
- * 高度,在 placement 为 top 或 bottom 时使用
36
- * 默认 378px
37
- */
38
- height?: string
39
- closeIcon?: boolean
40
- /**
41
- * 点击蒙层是否允许关闭
42
- * 默认 true
43
- */
44
- maskClosable?: boolean
45
- /**
46
- * 关闭时销毁 Modal 里的子元素
47
- */
48
- destroyOnClose?: boolean
49
- /**
50
- * 抽屉的方向
51
- * 默认 right
52
- */
53
- placement?: 'top' | 'right' | 'bottom' | 'left'
54
- /**
55
- * 指定 Drawer 挂载的节点,并在容器内展现,false 为挂载在当前位置
56
- * 默认 body
57
- */
58
- getContainer?: HTMLElement | (() => HTMLElement) | false
59
- }
60
-
61
- const Drawer: Component<DrawerProps> = _props => {
62
- const props = mergeProps(
63
- {
64
- width: '378px',
65
- height: '378px',
66
- maskClosable: true,
67
- placement: 'right',
68
- getContainer: document.body,
69
- },
70
- _props,
71
- )
72
-
73
- /**
74
- * 控制是否打开/销毁
75
- */
76
- const [open, setOpen] = createSignal(false)
77
- /**
78
- * 控制显隐
79
- */
80
- const [hide, setHide] = createSignal(false)
81
- let cleanup: (() => void) | undefined
82
-
83
- const container = createMemo(() => {
84
- if (typeof props.getContainer === 'function') {
85
- return props.getContainer()
86
- }
87
- if (props.getContainer instanceof HTMLElement) {
88
- return props.getContainer
89
- }
90
- return undefined
91
- })
92
- const isBody = createMemo(() => container() === document.body)
93
-
94
- const instance: DrawerInstance = {
95
- open() {
96
- setOpen(true)
97
- setHide(false)
98
-
99
- untrack(() => {
100
- if (!isBody()) return
101
-
102
- const originOverflow = document.body.style.overflow
103
- document.body.style.overflow = 'hidden'
104
-
105
- const onKeyup = (e: KeyboardEvent) => {
106
- if (e.key === 'Escape') {
107
- instance.close()
108
- }
109
- }
110
- document.addEventListener('keyup', onKeyup)
111
-
112
- cleanup = () => {
113
- document.body.style.overflow = originOverflow
114
- document.removeEventListener('keyup', onKeyup)
115
- }
116
- })
117
- },
118
- close() {
119
- untrack(() => {
120
- if (props.destroyOnClose) {
121
- setOpen(false)
122
- } else {
123
- setHide(true)
124
- }
125
-
126
- cleanup?.()
127
- })
128
- },
129
- }
130
- setRef(props, instance)
131
-
132
- let drawer: HTMLDivElement | undefined
133
- createTransition(
134
- () => drawer,
135
- () => !hide(),
136
- 'ant-drawer-fade',
137
- )
138
-
139
- const direction = createMemo(() =>
140
- ['top', 'bottom'].includes(props.placement) ? 'vertical' : 'horizontal',
141
- )
142
-
143
- const children = (
144
- <Transition name="ant-drawer-fade">
145
- <Show when={open()}>
146
- <div
147
- ref={drawer}
148
- class={cs(
149
- 'ant-inset-0 ant-bg-[rgba(0,0,0,.45)] ant-z-1000',
150
- isBody() ? 'ant-fixed' : 'ant-absolute',
151
- )}
152
- onClick={() => {
153
- if (props.maskClosable) {
154
- instance.close()
155
- }
156
- }}
157
- >
158
- <div
159
- class={cs(
160
- 'ant-drawer-content',
161
- {
162
- left: 'ant-drawer-content-left',
163
- right: 'ant-drawer-content-right',
164
- top: 'ant-drawer-content-top',
165
- bottom: 'ant-drawer-content-bottom',
166
- }[props.placement],
167
- 'ant-absolute ant-bg-white ant-grid ant-[grid-template-rows:auto_1fr]',
168
- )}
169
- style={{
170
- width: direction() === 'horizontal' ? props.width : undefined,
171
- height: direction() === 'vertical' ? props.height : undefined,
172
- }}
173
- onClick={e => {
174
- e.stopPropagation()
175
- }}
176
- >
177
- <div class="ant-px-[var(--ant-padding-lg)] ant-py-[var(--ant-padding)] ant-flex ant-justify-between ant-items-center ant-[border-bottom:var(--ant-line-width)_solid_var(--ant-color-split)]">
178
- <div class="ant-flex ant-items-center">
179
- <Show when={props.closeIcon !== false}>
180
- <Button
181
- type="text"
182
- size="plain"
183
- class="ant-mr-[var(--ant-margin-sm)] ant-text-size-[var(--ant-font-size-lg)] ant-h-[var(--ant-font-size-lg)] ant-leading-[var(--ant-font-size-lg)] hover:!ant-bg-transparent !ant-text-[var(--ant-color-icon)] hover:!ant-text-[var(--ant-color-icon-hover)]"
184
- onClick={() => {
185
- instance?.close()
186
- }}
187
- >
188
- <span class="i-ant-design:close-outlined" />
189
- </Button>
190
- </Show>
191
- <span class="ant-text-[var(--ant-color-text)] ant-text-size-[var(--ant-font-size-lg)] ant-[font-weight:var(--ant-font-weight-strong)] ant-leading-[var(--ant-line-height-lg)]">
192
- {props.title}
193
- </span>
194
- </div>
195
-
196
- <div>{props.extra}</div>
197
- </div>
198
- <div class="ant-p-[var(--ant-padding-lg)] ant-overflow-auto">{props.children}</div>
199
- </div>
200
- </div>
201
- </Show>
202
- </Transition>
203
- )
204
-
205
- return (
206
- <Show when={props.getContainer !== false} fallback={children}>
207
- <Portal mount={container()}>{children}</Portal>
208
- </Show>
209
- )
210
- }
211
-
212
- export default Drawer
@@ -1,15 +0,0 @@
1
- import { type Component } from 'solid-js'
2
- import SimpleEmptySvg from './assets/SimpleEmptySvg'
3
-
4
- const PRESENTED_IMAGE_SIMPLE: Component = () => {
5
- return (
6
- <div class='ant-my-[var(--ant-margin-xl)] ant-mx-[var(--ant-margin-xs)]'>
7
- <div class="ant-mb-[var(--ant-margin-xs)] ant-flex ant-justify-center">
8
- <SimpleEmptySvg />
9
- </div>
10
- <div class="ant-text-[var(--ant-color-text-disabled)] ant-text-center">暂无数据</div>
11
- </div>
12
- )
13
- }
14
-
15
- export default PRESENTED_IMAGE_SIMPLE
@@ -1,43 +0,0 @@
1
- const EmptySvg = () => (
2
- <svg width="184" height="100" viewBox="0 0 184 152" xmlns="http://www.w3.org/2000/svg">
3
- <g fill="none" fill-rule="evenodd">
4
- <g transform="translate(24 31.67)">
5
- <ellipse
6
- fill-opacity=".8"
7
- fill="#F5F5F7"
8
- cx="67.797"
9
- cy="106.89"
10
- rx="67.797"
11
- ry="12.668"
12
- />
13
- <path
14
- d="M122.034 69.674L98.109 40.229c-1.148-1.386-2.826-2.225-4.593-2.225h-51.44c-1.766 0-3.444.839-4.592 2.225L13.56 69.674v15.383h108.475V69.674z"
15
- fill="#AEB8C2"
16
- />
17
- <path
18
- d="M101.537 86.214L80.63 61.102c-1.001-1.207-2.507-1.867-4.048-1.867H31.724c-1.54 0-3.047.66-4.048 1.867L6.769 86.214v13.792h94.768V86.214z"
19
- fill="url(#linearGradient-1)"
20
- transform="translate(13.56)"
21
- />
22
- <path
23
- d="M33.83 0h67.933a4 4 0 0 1 4 4v93.344a4 4 0 0 1-4 4H33.83a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4z"
24
- fill="#F5F5F7"
25
- />
26
- <path
27
- d="M42.678 9.953h50.237a2 2 0 0 1 2 2V36.91a2 2 0 0 1-2 2H42.678a2 2 0 0 1-2-2V11.953a2 2 0 0 1 2-2zM42.94 49.767h49.713a2.262 2.262 0 1 1 0 4.524H42.94a2.262 2.262 0 0 1 0-4.524zM42.94 61.53h49.713a2.262 2.262 0 1 1 0 4.525H42.94a2.262 2.262 0 0 1 0-4.525zM121.813 105.032c-.775 3.071-3.497 5.36-6.735 5.36H20.515c-3.238 0-5.96-2.29-6.734-5.36a7.309 7.309 0 0 1-.222-1.79V69.675h26.318c2.907 0 5.25 2.448 5.25 5.42v.04c0 2.971 2.37 5.37 5.277 5.37h34.785c2.907 0 5.277-2.421 5.277-5.393V75.1c0-2.972 2.343-5.426 5.25-5.426h26.318v33.569c0 .617-.077 1.216-.221 1.789z"
28
- fill="#DCE0E6"
29
- />
30
- </g>
31
- <path
32
- d="M149.121 33.292l-6.83 2.65a1 1 0 0 1-1.317-1.23l1.937-6.207c-2.589-2.944-4.109-6.534-4.109-10.408C138.802 8.102 148.92 0 161.402 0 173.881 0 184 8.102 184 18.097c0 9.995-10.118 18.097-22.599 18.097-4.528 0-8.744-1.066-12.28-2.902z"
33
- fill="#DCE0E6"
34
- />
35
- <g transform="translate(149.65 15.383)" fill="#FFF">
36
- <ellipse cx="20.654" cy="3.167" rx="2.849" ry="2.815" />
37
- <path d="M5.698 5.63H0L2.898.704zM9.259.704h4.985V5.63H9.259z" />
38
- </g>
39
- </g>
40
- </svg>
41
- )
42
-
43
- export default EmptySvg
@@ -1,16 +0,0 @@
1
- const EmptySvg = () => (
2
- <svg width="64" height="41" viewBox="0 0 64 41" xmlns="http://www.w3.org/2000/svg">
3
- <g transform="translate(0 1)" fill="none" fill-rule="evenodd">
4
- <ellipse fill="#f5f5f5" cx="32" cy="33" rx="32" ry="7" />
5
- <g fill-rule="nonzero" stroke="#d9d9d9">
6
- <path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z" />
7
- <path
8
- d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"
9
- fill="#fafafa"
10
- />
11
- </g>
12
- </g>
13
- </svg>
14
- )
15
-
16
- export default EmptySvg
@@ -1,20 +0,0 @@
1
- import { type Component } from 'solid-js'
2
- import PRESENTED_IMAGE_SIMPLE from './PRESENTED_IMAGE_SIMPLE'
3
- import EmptySvg from './assets/EmptySvg'
4
-
5
- const Empty: Component & {
6
- PRESENTED_IMAGE_SIMPLE: Component
7
- } = () => {
8
- return (
9
- <div>
10
- <div class='ant-mb-[var(--ant-margin-xs)] ant-flex ant-justify-center'>
11
- <EmptySvg />
12
- </div>
13
- <div class='ant-text-[var(--ant-color-text)] ant-text-center'>暂无数据</div>
14
- </div>
15
- )
16
- }
17
-
18
- Empty.PRESENTED_IMAGE_SIMPLE = PRESENTED_IMAGE_SIMPLE
19
-
20
- export default Empty
package/src/Form/Form.tsx DELETED
@@ -1,94 +0,0 @@
1
- import {
2
- type JSXElement,
3
- type Ref,
4
- mergeProps,
5
- type Setter,
6
- onMount,
7
- createSignal,
8
- createMemo,
9
- } from 'solid-js'
10
- import { get, max, set } from 'lodash-es'
11
- import Context from './context'
12
- import { type Schema } from 'yup'
13
-
14
- export interface FormInstance<T extends {} = {}> {
15
- validateFields: () => Promise<T>
16
- setFieldValue: (name: Parameters<typeof set>[1], value: any) => void
17
- }
18
-
19
- export interface FormProps<T extends {} = {}> {
20
- ref?: Ref<FormInstance<T>>
21
- /**
22
- * 表单布局
23
- * 默认: horizontal
24
- */
25
- layout?: 'horizontal' | 'vertical' | 'inline'
26
- children: JSXElement
27
- initialValues?: T
28
- }
29
-
30
- function Form<T extends {} = {}>(_props: FormProps<T>) {
31
- const props = mergeProps({ layout: 'horizontal' } as FormProps, _props)
32
- const rulesDict: Record<string, Schema[]> = {}
33
- const setErrMsgDict: Record<string, Setter<string>> = {}
34
-
35
- const values = props.initialValues ? { ...props.initialValues } : ({} as T)
36
- const formInstance: FormInstance<T> = {
37
- async validateFields() {
38
- const promises = Object.entries(rulesDict).flatMap(([name, rules]) => {
39
- return rules.map(
40
- async rule =>
41
- await rule.validate(get(values, name)).catch(err => {
42
- setErrMsgDict[name](err.message)
43
- throw err
44
- }),
45
- )
46
- })
47
- const results = await Promise.allSettled(promises)
48
- if (results.some(result => result.status === 'rejected')) {
49
- // eslint-disable-next-line @typescript-eslint/no-throw-literal
50
- throw {
51
- errorFields: results.filter(res => res.status === 'rejected'),
52
- values,
53
- }
54
- }
55
- return values as T
56
- },
57
- setFieldValue(name, value) {
58
- set(values, name, value)
59
- },
60
- }
61
-
62
- onMount(() => {
63
- if (typeof _props.ref === 'function') {
64
- _props.ref?.(formInstance)
65
- }
66
- })
67
-
68
- // 存储 form item 的 dom 节点宽度
69
- const [itemWidthDict, setItemWidthDict] = createSignal<Record<string, number>>({})
70
- const maxItemWidth = createMemo(() => max(Object.values(itemWidthDict())))
71
-
72
- return (
73
- <form
74
- onSubmit={e => {
75
- e.preventDefault()
76
- }}
77
- >
78
- <Context.Provider
79
- value={{
80
- formInstance,
81
- rulesDict,
82
- setErrMsgDict,
83
- initialValues: props.initialValues as {},
84
- setItemWidthDict,
85
- maxItemWidth,
86
- }}
87
- >
88
- {props.children}
89
- </Context.Provider>
90
- </form>
91
- )
92
- }
93
-
94
- export default Form
@@ -1,141 +0,0 @@
1
- import {
2
- type JSXElement,
3
- type Component,
4
- type JSX,
5
- Show,
6
- useContext,
7
- createSignal,
8
- onMount,
9
- onCleanup,
10
- } from 'solid-js'
11
- import { get, isNil } from 'lodash-es'
12
- import { Dynamic } from 'solid-js/web'
13
- import { nanoid } from 'nanoid'
14
- import cs from 'classnames'
15
- import { type Schema } from 'yup'
16
- import Context from './context'
17
-
18
- export interface FormItemComponentProps<T = any> {
19
- defaultValue?: T
20
- status?: 'error' | 'warning'
21
- onChange?: (value: T) => void
22
- }
23
-
24
- export interface FormItemProps {
25
- class?: string
26
- style?: JSX.CSSProperties
27
- required?: boolean
28
- label?: JSXElement
29
- name?: string
30
- initialValue?: any
31
- rules?: Schema[]
32
- component: Component<FormItemComponentProps>
33
- }
34
-
35
- const FormItem: Component<FormItemProps> = props => {
36
- const { formInstance, rulesDict, setErrMsgDict, initialValues, setItemWidthDict, maxItemWidth } =
37
- useContext(Context)
38
- const [errMsg, setErrMsg] = createSignal('')
39
- const id = nanoid()
40
-
41
- onMount(() => {
42
- if (isNil(props.name)) return
43
-
44
- if (!isNil(props.initialValue)) {
45
- formInstance.setFieldValue(props.name, props.initialValue)
46
- }
47
-
48
- if (!isNil(props.rules)) {
49
- rulesDict[props.name] = props.rules
50
- }
51
-
52
- setErrMsgDict[props.name] = setErrMsg
53
- })
54
-
55
- let label: HTMLLabelElement
56
- onMount(() => {
57
- const resizeObserver = new ResizeObserver(entries => {
58
- const [entry] = entries
59
- // Firefox implements `borderBoxSize` as a single content rect, rather than an array
60
- const borderBoxSize: ResizeObserverSize = Array.isArray(entry.borderBoxSize)
61
- ? entry.borderBoxSize[0]
62
- : entry.borderBoxSize
63
- setItemWidthDict(dict => ({
64
- ...dict,
65
- [id]: borderBoxSize.inlineSize,
66
- }))
67
- })
68
-
69
- resizeObserver.observe(label)
70
-
71
- onCleanup(() => {
72
- setItemWidthDict(dict => {
73
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
74
- delete dict[id]
75
- return { ...dict }
76
- })
77
- resizeObserver.disconnect()
78
- })
79
- })
80
-
81
- const getLabel = (hidden?: boolean) => (
82
- <label
83
- class={cs(
84
- 'ant-shrink-0 ant-h-32px ant-leading-32px not[:empty]:ant-pr-8px ant-text-right ant-[white-space:nowrap]',
85
- hidden && 'ant-absolute ant-opacity-0',
86
- )}
87
- {...(hidden
88
- ? {
89
- ref: el => {
90
- label = el
91
- },
92
- }
93
- : {
94
- style: { width: `${maxItemWidth() ?? 0}px` },
95
- })}
96
- >
97
- <Show when={!isNil(props.required)}>
98
- <span class="ant-mr-4px ant-text-[var(--ant-color-error)]">*</span>
99
- </Show>
100
- <Show when={!isNil(props.label)}>
101
- <label>{props.label}</label>
102
- </Show>
103
- </label>
104
- )
105
-
106
- return (
107
- <div class={cs(props.class, 'ant-flex ant-items-center ant-mb-16px')} style={props.style}>
108
- {/* 第一个 label 仅用于计算实际宽度 */}
109
- {getLabel(true)}
110
- {getLabel()}
111
-
112
- <div class="ant-w-full">
113
- <Dynamic
114
- component={props.component}
115
- defaultValue={props.initialValue ?? get(initialValues, props.name!)}
116
- status={errMsg() ? 'error' : undefined}
117
- onChange={(value: any) => {
118
- if (!isNil(props.name)) formInstance.setFieldValue(props.name, value)
119
-
120
- props.rules?.forEach(rule => {
121
- rule
122
- .validate(value)
123
- .then(() => {
124
- setErrMsg('')
125
- })
126
- .catch(err => {
127
- setErrMsg(err.message)
128
- })
129
- })
130
- }}
131
- />
132
-
133
- <Show when={errMsg()}>
134
- <div class="ant-text-[var(--ant-color-error)]">{errMsg()}</div>
135
- </Show>
136
- </div>
137
- </div>
138
- )
139
- }
140
-
141
- export default FormItem
@@ -1,16 +0,0 @@
1
- import { type Setter, createContext, type Accessor } from 'solid-js'
2
- import { type FormInstance } from './Form'
3
- import { type Schema } from 'yup'
4
-
5
- const Context = createContext(
6
- {} as {
7
- formInstance: FormInstance
8
- rulesDict: Record<string, Schema[]>
9
- setErrMsgDict: Record<string, Setter<string>>
10
- initialValues: {}
11
- setItemWidthDict: Setter<Record<string, number>>
12
- maxItemWidth: Accessor<number | undefined>
13
- },
14
- )
15
-
16
- export default Context
package/src/Form/index.ts DELETED
@@ -1,13 +0,0 @@
1
- import InternalForm from './Form'
2
- import FormItem from './FormItem'
3
-
4
- export type { FormInstance, FormProps } from './Form'
5
- export type { FormItemProps, FormItemComponentProps } from './FormItem'
6
-
7
- const Form = InternalForm as typeof InternalForm & {
8
- Item: typeof FormItem
9
- }
10
-
11
- Form.Item = FormItem
12
-
13
- export default Form
package/src/Image.tsx DELETED
@@ -1,29 +0,0 @@
1
- import { Image as ImageAntd } from 'antd'
2
- import { configProvider, reactToSolidComponent, replaceClassName } from './utils/component'
3
- import { solidToReact } from './utils/solid'
4
- import { type JSXElement, createMemo } from 'solid-js'
5
- import { mapValues } from 'lodash-es'
6
-
7
- const _Image = replaceClassName(
8
- reactToSolidComponent(configProvider(ImageAntd), () => (<div class="ant-inline-flex" />) as any),
9
- )
10
-
11
- type ImageProps = Omit<Parameters<typeof _Image>[0], 'placeholder'> & {
12
- placeholder?: JSXElement
13
- }
14
-
15
- function Image(_props: ImageProps) {
16
- const props = createMemo(() =>
17
- mapValues(_props, (value, key) => {
18
- switch (key) {
19
- case 'placeholder':
20
- return solidToReact(value)
21
- default:
22
- return value
23
- }
24
- }),
25
- )
26
- return <_Image {...(props() as any)} />
27
- }
28
-
29
- export default Image