antd-solid 0.0.12 → 0.0.14

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 +22 -21
  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
@@ -0,0 +1,44 @@
1
+ import { TinyColor } from '@ctrl/tinycolor';
2
+
3
+ function isStableColor(color) {
4
+ return color >= 0 && color <= 255;
5
+ }
6
+ function getAlphaColor(frontColor, backgroundColor) {
7
+ const {
8
+ r: fR,
9
+ g: fG,
10
+ b: fB,
11
+ a: originAlpha
12
+ } = new TinyColor(frontColor).toRgb();
13
+ if (originAlpha < 1) {
14
+ return frontColor;
15
+ }
16
+ const {
17
+ r: bR,
18
+ g: bG,
19
+ b: bB
20
+ } = new TinyColor(backgroundColor).toRgb();
21
+ for (let fA = 0.01; fA <= 1; fA += 0.01) {
22
+ const r = Math.round((fR - bR * (1 - fA)) / fA);
23
+ const g = Math.round((fG - bG * (1 - fA)) / fA);
24
+ const b = Math.round((fB - bB * (1 - fA)) / fA);
25
+ if (isStableColor(r) && isStableColor(g) && isStableColor(b)) {
26
+ return new TinyColor({
27
+ r,
28
+ g,
29
+ b,
30
+ a: Math.round(fA * 100) / 100
31
+ }).toRgbString();
32
+ }
33
+ }
34
+ // fallback
35
+ /* istanbul ignore next */
36
+ return new TinyColor({
37
+ r: fR,
38
+ g: fG,
39
+ b: fB,
40
+ a: 1
41
+ }).toRgbString();
42
+ }
43
+
44
+ export { getAlphaColor as default };
@@ -0,0 +1,3 @@
1
+ import { type SeedToken, type CssVariables } from '../types';
2
+ export declare function createCssVariables(token: SeedToken, theme?: 'light' | 'dark'): CssVariables;
3
+ export declare function getCssVariablesClass(): string;
@@ -0,0 +1,181 @@
1
+ import { nanoid } from 'nanoid';
2
+ import { TinyColor } from '@ctrl/tinycolor';
3
+ import genDarkColorMapToken from '../dark/index.js';
4
+ import genLightColorMapToken from '../light/index.js';
5
+ import getAlphaColor from './getAlphaColor.js';
6
+
7
+ function createCssVariables(token, theme = 'light') {
8
+ const mapToken = theme === 'dark' ? genDarkColorMapToken(token) : genLightColorMapToken(token);
9
+ const aliasToken = {
10
+ // ============== Background ============== //
11
+ colorFillContent: mapToken.colorFillSecondary,
12
+ colorFillContentHover: mapToken.colorFill,
13
+ colorFillAlter: mapToken.colorFillQuaternary,
14
+ colorBgContainerDisabled: mapToken.colorFillTertiary,
15
+ // ============== Split ============== //
16
+ colorBorderBg: mapToken.colorBgContainer,
17
+ colorSplit: getAlphaColor(mapToken.colorBorderSecondary, mapToken.colorBgContainer),
18
+ // ============== Text ============== //
19
+ colorTextPlaceholder: mapToken.colorTextQuaternary,
20
+ colorTextDisabled: mapToken.colorTextQuaternary,
21
+ colorTextHeading: mapToken.colorText,
22
+ colorTextLabel: mapToken.colorTextSecondary,
23
+ colorTextDescription: mapToken.colorTextTertiary,
24
+ colorTextLightSolid: mapToken.colorWhite,
25
+ colorHighlight: mapToken.colorError,
26
+ colorBgTextHover: mapToken.colorFillSecondary,
27
+ colorBgTextActive: mapToken.colorFill,
28
+ colorIcon: mapToken.colorTextTertiary,
29
+ colorIconHover: mapToken.colorText,
30
+ colorErrorOutline: getAlphaColor(mapToken.colorErrorBg, mapToken.colorBgContainer),
31
+ colorWarningOutline: getAlphaColor(mapToken.colorWarningBg, mapToken.colorBgContainer),
32
+ controlItemBgHover: mapToken.colorFillTertiary,
33
+ controlItemBgActive: mapToken.colorPrimaryBg,
34
+ controlItemBgActiveHover: mapToken.colorPrimaryBgHover,
35
+ controlItemBgActiveDisabled: mapToken.colorFill,
36
+ controlTmpOutline: mapToken.colorFillQuaternary,
37
+ controlOutline: getAlphaColor(mapToken.colorPrimaryBg, mapToken.colorBgContainer),
38
+ fontWeightStrong: 600,
39
+ opacityLoading: 0.65,
40
+ linkDecoration: 'none',
41
+ linkHoverDecoration: 'none',
42
+ linkFocusDecoration: 'none',
43
+ controlPaddingHorizontal: 12,
44
+ controlPaddingHorizontalSM: 8
45
+ };
46
+ const colorFillAlterSolid = new TinyColor(aliasToken.colorFillAlter).onBackground(mapToken.colorBgContainer).toHexShortString();
47
+ return {
48
+ '--ant-color-primary': mapToken.colorPrimary,
49
+ '--ant-color-primary-active': mapToken.colorPrimaryActive,
50
+ '--ant-color-primary-hover': mapToken.colorPrimaryHover,
51
+ '--ant-color-primary-border': mapToken.colorPrimaryBorder,
52
+ '--ant-color-primary-border-hover': mapToken.colorPrimaryBorderHover,
53
+ '--ant-color-success': mapToken.colorSuccess,
54
+ '--ant-color-success-border': mapToken.colorSuccessBorder,
55
+ '--ant-color-success-bg': mapToken.colorSuccessBg,
56
+ '--ant-color-error': mapToken.colorError,
57
+ '--ant-color-error-active': mapToken.colorErrorActive,
58
+ '--ant-color-error-bg': mapToken.colorErrorBg,
59
+ '--ant-color-error-bg-hover': mapToken.colorErrorBgHover,
60
+ '--ant-color-error-border': mapToken.colorErrorBorder,
61
+ '--ant-color-error-border-hover': mapToken.colorErrorBorderHover,
62
+ '--ant-color-warning': mapToken.colorWarning,
63
+ '--ant-color-warning-bg': mapToken.colorWarningBg,
64
+ '--ant-color-warning-bg-hover': mapToken.colorWarningBgHover,
65
+ '--ant-color-warning-border': mapToken.colorWarningBorder,
66
+ '--ant-color-warning-border-hover': mapToken.colorWarningBorderHover,
67
+ '--ant-color-info-bg': mapToken.colorInfoBg,
68
+ '--ant-color-info-border': mapToken.colorInfoBorder,
69
+ '--ant-color-border': mapToken.colorBorder,
70
+ '--ant-color-border-secondary': mapToken.colorBorderSecondary,
71
+ '--ant-color-split': aliasToken.colorSplit,
72
+ '--ant-color-icon': aliasToken.colorIcon,
73
+ '--ant-color-icon-hover': aliasToken.colorIconHover,
74
+ '--ant-color-text': mapToken.colorText,
75
+ '--ant-color-text-secondary': mapToken.colorTextSecondary,
76
+ '--ant-color-text-tertiary': mapToken.colorTextTertiary,
77
+ '--ant-color-text-quaternary': mapToken.colorTextQuaternary,
78
+ '--ant-color-text-disabled': aliasToken.colorTextDisabled,
79
+ '--ant-color-text-heading': aliasToken.colorTextHeading,
80
+ '--ant-color-text-label': aliasToken.colorTextLabel,
81
+ '--ant-color-text-description': aliasToken.colorTextDescription,
82
+ '--ant-color-text-placeholder': aliasToken.colorTextPlaceholder,
83
+ '--ant-color-text-light-solid': aliasToken.colorTextLightSolid,
84
+ '--ant-color-bg-text-hover': aliasToken.colorBgTextHover,
85
+ '--ant-color-bg-text-active': aliasToken.colorBgTextActive,
86
+ '--ant-color-bg-container': mapToken.colorBgContainer,
87
+ '--ant-color-bg-elevated': mapToken.colorBgElevated,
88
+ '--ant-color-bg-container-disabled': aliasToken.colorBgContainerDisabled,
89
+ '--ant-color-bg-container-secondary': mapToken.colorBgContainerSecondary,
90
+ '--ant-color-bg-container-tertiary': mapToken.colorBgContainerTertiary,
91
+ '--ant-color-bg-spotlight': mapToken.colorBgSpotlight,
92
+ '--ant-color-bg-layout': mapToken.colorBgLayout,
93
+ '--ant-color-white': mapToken.colorWhite,
94
+ '--ant-color-bg-mask': mapToken.colorBgMask,
95
+ '--ant-color-fill': mapToken.colorFill,
96
+ '--ant-color-fill-secondary': mapToken.colorFillSecondary,
97
+ '--ant-color-fill-tertiary': mapToken.colorFillTertiary,
98
+ '--ant-color-fill-quaternary': mapToken.colorFillQuaternary,
99
+ '--ant-control-outline': aliasToken.controlOutline,
100
+ '--ant-control-item-bg-active': aliasToken.controlItemBgActive,
101
+ '--ant-control-item-bg-hover': mapToken.colorFillTertiary,
102
+ '--ant-font-weight-strong': '600',
103
+ '--ant-font-size-sm': '12px',
104
+ '--ant-font-size': '14px',
105
+ '--ant-font-size-lg': '16px',
106
+ '--ant-font-size-xl': '20px',
107
+ '--ant-font-size-heading-1': '38px',
108
+ '--ant-font-size-heading-2': '30px',
109
+ '--ant-font-size-heading-3': '24px',
110
+ '--ant-font-size-heading-4': '20px',
111
+ '--ant-font-size-heading-5': '16px',
112
+ '--ant-line-height': '1.5714285714285714',
113
+ '--ant-line-height-lg': '1.5',
114
+ '--ant-line-width-bold': '2px',
115
+ '--ant-line-width': '1px',
116
+ '--ant-line-type': 'solid',
117
+ '--ant-margin-xxs': '4px',
118
+ '--ant-margin-xs': '8px',
119
+ '--ant-margin-sm': '12px',
120
+ '--ant-margin': '16px',
121
+ '--ant-margin-lg': '24px',
122
+ '--ant-margin-xl': '32px',
123
+ '--ant-padding-xxs': '4px',
124
+ '--ant-padding-xs': '8px',
125
+ '--ant-padding-sm': '12px',
126
+ '--ant-padding': '16px',
127
+ '--ant-padding-lg': '24px',
128
+ '--ant-padding-xl': '32px',
129
+ '--ant-box-shadow': `
130
+ 0 6px 16px 0 rgba(0, 0, 0, 0.08),
131
+ 0 3px 6px -4px rgba(0, 0, 0, 0.12),
132
+ 0 9px 28px 8px rgba(0, 0, 0, 0.05)
133
+ `,
134
+ '--ant-box-shadow-secondary': `
135
+ 0 6px 16px 0 rgba(0, 0, 0, 0.08),
136
+ 0 3px 6px -4px rgba(0, 0, 0, 0.12),
137
+ 0 9px 28px 8px rgba(0, 0, 0, 0.05)
138
+ `,
139
+ '--ant-box-shadow-tertiary': '0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.02)',
140
+ '--ant-border-radius-xs': '2px',
141
+ '--ant-border-radius-sm': '4px',
142
+ '--ant-border-radius': '6px',
143
+ '--ant-border-radius-lg': '8px',
144
+ '--ant-opacity-loading': '0.65',
145
+ '--ant-button-default-color': mapToken.colorText,
146
+ '--ant-button-border-color-disabled': mapToken.colorBorder,
147
+ '--ant-button-default-bg': mapToken.colorBgContainer,
148
+ '--ant-radio-dot-color-disabled': aliasToken.colorTextDisabled,
149
+ '--ant-radio-button-checked-bg-disabled': aliasToken.controlItemBgActiveDisabled,
150
+ '--ant-collapse-header-bg': aliasToken.colorFillAlter,
151
+ '--ant-select-option-selected-bg': aliasToken.controlItemBgActive,
152
+ '--ant-select-option-active-bg': aliasToken.controlItemBgHover,
153
+ '--ant-select-multiple-item-bg': mapToken.colorFillSecondary,
154
+ '--ant-tree-expand-icon-width': '24px',
155
+ '--ant-tree-node-wrapper-padding': '2px 0',
156
+ '--ant-tree-node-selected-bg': aliasToken.controlItemBgActive,
157
+ '--ant-tree-node-hover-bg': aliasToken.controlItemBgHover,
158
+ '--ant-alert-default-padding': '8px 12px',
159
+ '--ant-tabs-card-bg': aliasToken.colorFillAlter,
160
+ '--ant-progress-remaining-color': mapToken.colorFillSecondary,
161
+ '--ant-segmented-item-color': aliasToken.colorTextLabel,
162
+ '--ant-segmented-item-hover-color': mapToken.colorText,
163
+ '--ant-segmented-item-selected-color': mapToken.colorText,
164
+ '--ant-segmented-item-selected-bg': mapToken.colorBgContainerSecondary,
165
+ '--ant-segmented-item-hover-bg': mapToken.colorFillSecondary,
166
+ '--ant-segmented-item-active-bg': mapToken.colorFill,
167
+ '--ant-table-header-bg': colorFillAlterSolid,
168
+ '--ant-table-row-hover-bg': colorFillAlterSolid,
169
+ '--ant-table-border-color': mapToken.colorBorderSecondary,
170
+ '--ant-slider-handle-color': mapToken.colorPrimaryBorder,
171
+ '--ant-slider-handle-active-color': mapToken.colorPrimary,
172
+ '--ant-slider-handle-color-disabled': new TinyColor(aliasToken.colorTextDisabled).onBackground(mapToken.colorBgContainer).toHexShortString(),
173
+ '--ant-slider-track-bg-disabled': aliasToken.colorBgContainerDisabled,
174
+ '--ant-modal-title-color': aliasToken.colorTextHeading
175
+ };
176
+ }
177
+ function getCssVariablesClass() {
178
+ return `css-var-${nanoid(12)}`;
179
+ }
180
+
181
+ export { createCssVariables, getCssVariablesClass };
@@ -0,0 +1,8 @@
1
+ import { type MenuProps } from '../Menu';
2
+ declare const _default: {
3
+ trigger: (event: MouseEvent, options: MenuProps<any>) => void;
4
+ useContextMenu: () => {
5
+ trigger: (event: MouseEvent, options: MenuProps<any>) => void;
6
+ };
7
+ };
8
+ export default _default;
@@ -0,0 +1,99 @@
1
+ import { createComponent, mergeProps } from 'solid-js/web';
2
+ import { splitProps, createSignal, createEffect, onCleanup, getOwner, runWithOwner } from 'solid-js';
3
+ import Command from '../Command/index.js';
4
+ import { inRange } from '../utils/number.js';
5
+ import Menu from '../Menu/index.js';
6
+ import Element from '../Element/index.js';
7
+
8
+ const offsetY = 4;
9
+ const ContextMenuCommand = Command.createCommand(props => {
10
+ let ref;
11
+ const [, menuProps] = splitProps(props, ['x', 'y']);
12
+ const [reverse, setReverse] = createSignal(false);
13
+ createEffect(() => {
14
+ setReverse(props.y + (ref?.clientHeight ?? 0) + offsetY > window.innerHeight);
15
+ });
16
+ const {
17
+ dispose
18
+ } = Command.useCommandProps();
19
+ const abortController = new AbortController();
20
+ window.addEventListener('click', e => {
21
+ if (e.target instanceof Node && ref?.contains(e.target)) return;
22
+ dispose();
23
+ }, {
24
+ capture: true,
25
+ signal: abortController.signal
26
+ });
27
+ window.addEventListener('keyup', e => {
28
+ if (e.key === 'Escape') {
29
+ dispose();
30
+ }
31
+ }, {
32
+ signal: abortController.signal
33
+ });
34
+ onCleanup(() => {
35
+ abortController.abort();
36
+ });
37
+ return createComponent(Element, {
38
+ ref(r$) {
39
+ var _ref$ = ref;
40
+ typeof _ref$ === "function" ? _ref$(r$) : ref = r$;
41
+ },
42
+ "class": "z-1000 fixed left-0 top-0 [font-size:var(--ant-font-size)] text-[var(--ant-color-text)] leading-[var(--ant-line-height)] bg-[--ant-color-bg-container-tertiary] rounded-[var(--ant-border-radius)]",
43
+ get style() {
44
+ return {
45
+ top: `${props.y}px`,
46
+ left: `${props.x}px`,
47
+ transform: reverse() ? `translateY(calc(-100% - ${offsetY}px))` : `translateY(${offsetY}px)`
48
+ };
49
+ },
50
+ get children() {
51
+ return createComponent(Menu, mergeProps({
52
+ selectable: false,
53
+ style: {
54
+ '--ant-menu-item-height': '32px'
55
+ }
56
+ }, menuProps, {
57
+ onClick: info => {
58
+ dispose();
59
+ menuProps.onClick?.(info);
60
+ }
61
+ }));
62
+ }
63
+ });
64
+ });
65
+ let prevPosition;
66
+ // 用于范围检测
67
+ const padding = 2;
68
+ const trigger = (event, options) => {
69
+ event.preventDefault();
70
+ event.stopPropagation();
71
+ if (!options.items?.length || ContextMenuCommand.isOpen() && inRange(prevPosition?.x ?? 0, event.clientX - padding, event.clientX + padding, '[]') && inRange(prevPosition?.y ?? 0, event.clientY - padding, event.clientY + padding, '[]')) {
72
+ ContextMenuCommand.dispose();
73
+ return;
74
+ }
75
+ prevPosition = {
76
+ x: event.clientX,
77
+ y: event.clientY
78
+ };
79
+ ContextMenuCommand.show({
80
+ ...prevPosition,
81
+ ...options
82
+ });
83
+ };
84
+ const useContextMenu = () => {
85
+ const owner = getOwner();
86
+ return {
87
+ trigger: (event, options) => {
88
+ runWithOwner(owner, () => {
89
+ trigger(event, options);
90
+ });
91
+ }
92
+ };
93
+ };
94
+ var index = {
95
+ trigger,
96
+ useContextMenu
97
+ };
98
+
99
+ export { index as default };
@@ -0,0 +1,6 @@
1
+ import { type Component, type ParentProps, type JSX } from 'solid-js';
2
+ export interface CursorProps extends ParentProps {
3
+ cursor: JSX.Element;
4
+ }
5
+ declare const Cursor: Component<CursorProps>;
6
+ export default Cursor;
@@ -0,0 +1,71 @@
1
+ import { createComponent, Portal, insert, effect, template } from 'solid-js/web';
2
+ import { children, createSignal, createEffect, onCleanup, Show } from 'solid-js';
3
+
4
+ var _tmpl$ = /*#__PURE__*/template(`<span class="absolute pointer-events-none z-2000">`);
5
+ const Cursor = props => {
6
+ const resolvedChildren = children(() => props.children);
7
+ const [hover, setHover] = createSignal(false);
8
+ const [cursorPosition, setCursorPosition] = createSignal({
9
+ x: 0,
10
+ y: 0
11
+ });
12
+ let originalCursor;
13
+ createEffect(() => {
14
+ const _children = resolvedChildren();
15
+ if (!(_children instanceof HTMLElement || _children instanceof SVGElement)) return;
16
+ const abortController = new AbortController();
17
+ _children.addEventListener('mouseenter', () => {
18
+ setHover(true);
19
+ originalCursor = _children.style.cursor;
20
+ _children.style.cursor = 'none';
21
+ }, {
22
+ capture: true,
23
+ signal: abortController.signal
24
+ });
25
+ _children.addEventListener('mousemove', e => {
26
+ setCursorPosition({
27
+ x: e.clientX,
28
+ y: e.clientY
29
+ });
30
+ }, {
31
+ capture: true,
32
+ signal: abortController.signal
33
+ });
34
+ _children.addEventListener('mouseleave', () => {
35
+ setHover(false);
36
+ if (originalCursor) _children.style.cursor = originalCursor;
37
+ }, {
38
+ capture: true,
39
+ signal: abortController.signal
40
+ });
41
+ onCleanup(() => {
42
+ abortController.abort();
43
+ });
44
+ });
45
+ return [resolvedChildren, createComponent(Show, {
46
+ get when() {
47
+ return hover();
48
+ },
49
+ get children() {
50
+ return createComponent(Portal, {
51
+ get children() {
52
+ var _el$ = _tmpl$();
53
+ insert(_el$, () => props.cursor);
54
+ effect(_p$ => {
55
+ var _v$ = `${cursorPosition().y}px`,
56
+ _v$2 = `${cursorPosition().x}px`;
57
+ _v$ !== _p$.e && ((_p$.e = _v$) != null ? _el$.style.setProperty("top", _v$) : _el$.style.removeProperty("top"));
58
+ _v$2 !== _p$.t && ((_p$.t = _v$2) != null ? _el$.style.setProperty("left", _v$2) : _el$.style.removeProperty("left"));
59
+ return _p$;
60
+ }, {
61
+ e: undefined,
62
+ t: undefined
63
+ });
64
+ return _el$;
65
+ }
66
+ });
67
+ }
68
+ })];
69
+ };
70
+
71
+ export { Cursor as default };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 延迟创建组件
3
+ * 只有当 props.when 第一次为 true 时才初始化组件
4
+ */
5
+ import { type Component, type JSXElement } from 'solid-js';
6
+ export interface DelayShowProps {
7
+ when?: boolean;
8
+ /**
9
+ * 延迟显示的时间,只在第一次显示时有效
10
+ * 单位 ms
11
+ */
12
+ time?: number;
13
+ children: JSXElement;
14
+ }
15
+ declare const DelayShow: Component<DelayShowProps>;
16
+ export default DelayShow;
@@ -0,0 +1,27 @@
1
+ import { createComponent } from 'solid-js/web';
2
+ import { createSignal, untrack, createRenderEffect, on, Show } from 'solid-js';
3
+
4
+ const DelayShow = props => {
5
+ // 是否显示过一次
6
+ const [showed, setShowed] = createSignal(untrack(() => props.when ?? false));
7
+ createRenderEffect(on(() => props.when, () => {
8
+ if (!props.when && !showed()) return;
9
+ if (typeof props.time === 'number') {
10
+ setTimeout(() => {
11
+ setShowed(true);
12
+ }, props.time);
13
+ } else {
14
+ setShowed(true);
15
+ }
16
+ }));
17
+ return createComponent(Show, {
18
+ get when() {
19
+ return showed() || props.when;
20
+ },
21
+ get children() {
22
+ return props.children;
23
+ }
24
+ });
25
+ };
26
+
27
+ export { DelayShow as default };
@@ -0,0 +1,17 @@
1
+ import { type ParentProps, type Component } from 'solid-js';
2
+ import { type StyleProps } from '../types';
3
+ export interface DividerProps extends ParentProps, StyleProps {
4
+ dashed?: boolean;
5
+ /**
6
+ * 分割线标题的位置
7
+ * 默认 'center'
8
+ */
9
+ orientation?: 'left' | 'right' | 'center';
10
+ /**
11
+ * 水平还是垂直类型
12
+ * 默认 'horizontal'
13
+ */
14
+ type?: 'horizontal' | 'vertical';
15
+ }
16
+ declare const Divider: Component<DividerProps>;
17
+ export default Divider;
@@ -0,0 +1,71 @@
1
+ import { createComponent, use, insert, effect, template } from 'solid-js/web';
2
+ import { mergeProps, createMemo, children, Show } from 'solid-js';
3
+ import cs from 'classnames';
4
+ import 'lodash-es';
5
+ import useSize from '../hooks/useSize.js';
6
+ import Element from '../Element/index.js';
7
+
8
+ var _tmpl$ = /*#__PURE__*/template(`<span class="inline-block px-[var(--ant-divider-text-padding-inline)]">`);
9
+ const Divider = _props => {
10
+ const props = mergeProps({
11
+ orientation: 'center',
12
+ type: 'horizontal'
13
+ }, _props);
14
+ let container;
15
+ const containerSize = useSize(() => container);
16
+ const containerWidth = createMemo(() => containerSize()?.width ?? 0);
17
+ let childrenRef;
18
+ const childrenSize = useSize(() => childrenRef);
19
+ const childrenWidth = createMemo(() => childrenSize()?.width ?? 0);
20
+ const orientationMargin = 0.05;
21
+ const childrenStart = createMemo(() => ({
22
+ left: containerWidth() * orientationMargin,
23
+ center: containerWidth() / 2 - childrenWidth() / 2,
24
+ right: containerWidth() * (1 - orientationMargin) - childrenWidth()
25
+ })[props.orientation]);
26
+ const resolvedChildren = children(() => props.children);
27
+ return createComponent(Show, {
28
+ get when() {
29
+ return resolvedChildren() && props.type === 'horizontal';
30
+ },
31
+ get fallback() {
32
+ return createComponent(Element, {
33
+ get ["class"]() {
34
+ return cs(props.class, 'border-[--ant-color-split]', props.type === 'horizontal' ? 'my-[--ant-margin-lg] border-width-[1px_0_0]' : 'mx-[--ant-margin-xs] inline-block border-width-[0_1px_0_0] h-0.9em [vertical-align:middle]', props.dashed ? 'border-dashed' : 'border-solid');
35
+ },
36
+ get style() {
37
+ return props.style;
38
+ }
39
+ });
40
+ },
41
+ get children() {
42
+ return createComponent(Element, {
43
+ ref(r$) {
44
+ var _ref$ = container;
45
+ typeof _ref$ === "function" ? _ref$(r$) : container = r$;
46
+ },
47
+ get ["class"]() {
48
+ return cs(props.class, 'my-[var(--ant-margin)] flex items-center relative', ['before:content-empty before:block before:absolute before:left-0 before:w-[var(--ant-divider-children-start)] before:border-width-[1px_0_0] before:border-[var(--ant-color-split)]', props.dashed ? 'before:border-dashed' : 'before:border-solid'], ['after:content-empty after:block after:absolute after:left-[var(--ant-divider-children-end)] after:right-0 after:border-width-[1px_0_0] after:border-[var(--ant-color-split)]', props.dashed ? 'after:border-dashed' : 'after:border-solid']);
49
+ },
50
+ get style() {
51
+ return {
52
+ '--ant-divider-text-padding-inline': '1em',
53
+ '--ant-divider-children-start': `${childrenStart()}px`,
54
+ '--ant-divider-children-end': `${childrenStart() + childrenWidth()}px`,
55
+ ...props.style
56
+ };
57
+ },
58
+ get children() {
59
+ var _el$ = _tmpl$();
60
+ var _ref$2 = childrenRef;
61
+ typeof _ref$2 === "function" ? use(_ref$2, _el$) : childrenRef = _el$;
62
+ insert(_el$, resolvedChildren);
63
+ effect(() => `translateX(${childrenStart()}px)` != null ? _el$.style.setProperty("transform", `translateX(${childrenStart()}px)`) : _el$.style.removeProperty("transform"));
64
+ return _el$;
65
+ }
66
+ });
67
+ }
68
+ });
69
+ };
70
+
71
+ export { Divider as default };
@@ -1,25 +1,24 @@
1
- import { type Component, type JSXElement, type Ref } from 'solid-js';
1
+ import { type Component, type JSXElement } from 'solid-js';
2
2
  import './index.scss';
3
- export interface DrawerInstance {
4
- open: () => void;
5
- close: () => void;
6
- }
7
- export interface DrawerProps {
8
- ref?: Ref<DrawerInstance>;
9
- title?: JSXElement;
10
- extra?: JSXElement;
3
+ import { type StyleProps, type StringOrJSXElement } from '../types';
4
+ export interface DrawerProps extends StyleProps {
5
+ defaultOpen?: boolean;
6
+ open?: boolean;
7
+ onClose?: () => void;
8
+ title?: StringOrJSXElement;
9
+ extra?: StringOrJSXElement;
11
10
  children?: JSXElement;
12
11
  /**
13
- * 宽度
12
+ * 预设抽屉宽度(或高度)
14
13
  * 默认 378px
15
14
  */
16
- width?: string;
15
+ size?: string;
16
+ closeIcon?: boolean;
17
17
  /**
18
- * 高度,在 placement 为 top 或 bottom 时使用
19
- * 默认 378px
18
+ * 是否展示遮罩
19
+ * 默认 true
20
20
  */
21
- height?: string;
22
- closeIcon?: boolean;
21
+ mask?: boolean;
23
22
  /**
24
23
  * 点击蒙层是否允许关闭
25
24
  * 默认 true
@@ -29,6 +28,11 @@ export interface DrawerProps {
29
28
  * 关闭时销毁 Modal 里的子元素
30
29
  */
31
30
  destroyOnClose?: boolean;
31
+ /**
32
+ * 是否在摁下 Esc 键的时候关闭 Modal
33
+ * 默认 true
34
+ */
35
+ closeOnEsc?: boolean;
32
36
  /**
33
37
  * 抽屉的方向
34
38
  * 默认 right
@@ -38,7 +42,7 @@ export interface DrawerProps {
38
42
  * 指定 Drawer 挂载的节点,并在容器内展现,false 为挂载在当前位置
39
43
  * 默认 body
40
44
  */
41
- getContainer?: HTMLElement | (() => HTMLElement) | false;
45
+ getContainer?: HTMLElement | (() => HTMLElement | undefined) | false;
42
46
  }
43
47
  declare const Drawer: Component<DrawerProps>;
44
48
  export default Drawer;