@ioca/react 1.3.4 → 1.3.5

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 (893) hide show
  1. package/lib/cjs/components/affix/affix.js +63 -0
  2. package/lib/cjs/components/affix/affix.js.map +1 -0
  3. package/lib/cjs/components/affix/index.js +10 -0
  4. package/lib/cjs/components/affix/index.js.map +1 -0
  5. package/lib/cjs/components/affix/totop.js +18 -0
  6. package/lib/cjs/components/affix/totop.js.map +1 -0
  7. package/lib/cjs/components/badge/badge.js +17 -0
  8. package/lib/cjs/components/badge/badge.js.map +1 -0
  9. package/lib/cjs/components/badge/index.js +10 -0
  10. package/lib/cjs/components/badge/index.js.map +1 -0
  11. package/lib/cjs/components/button/button.js +62 -0
  12. package/lib/cjs/components/button/button.js.map +1 -0
  13. package/lib/cjs/components/button/group.js +25 -0
  14. package/lib/cjs/components/button/group.js.map +1 -0
  15. package/lib/cjs/components/button/index.js +13 -0
  16. package/lib/cjs/components/button/index.js.map +1 -0
  17. package/lib/cjs/components/button/toggle.js +50 -0
  18. package/lib/cjs/components/button/toggle.js.map +1 -0
  19. package/lib/cjs/components/card/card.js +17 -0
  20. package/lib/cjs/components/card/card.js.map +1 -0
  21. package/lib/cjs/components/card/index.js +10 -0
  22. package/lib/cjs/components/card/index.js.map +1 -0
  23. package/lib/cjs/components/checkbox/checkbox.js +46 -0
  24. package/lib/cjs/components/checkbox/checkbox.js.map +1 -0
  25. package/lib/cjs/components/checkbox/index.js +10 -0
  26. package/lib/cjs/components/checkbox/index.js.map +1 -0
  27. package/lib/cjs/components/checkbox/item.js +40 -0
  28. package/lib/cjs/components/checkbox/item.js.map +1 -0
  29. package/lib/cjs/components/collapse/collapse.js +78 -0
  30. package/lib/cjs/components/collapse/collapse.js.map +1 -0
  31. package/lib/cjs/components/collapse/index.js +10 -0
  32. package/lib/cjs/components/collapse/index.js.map +1 -0
  33. package/lib/cjs/components/collapse/item.js +12 -0
  34. package/lib/cjs/components/collapse/item.js.map +1 -0
  35. package/lib/cjs/components/datagrid/cell.js +27 -0
  36. package/lib/cjs/components/datagrid/cell.js.map +1 -0
  37. package/lib/cjs/components/datagrid/datagrid.js +117 -0
  38. package/lib/cjs/components/datagrid/datagrid.js.map +1 -0
  39. package/lib/cjs/components/datagrid/index.js +10 -0
  40. package/lib/cjs/components/datagrid/index.js.map +1 -0
  41. package/lib/cjs/components/datagrid/resize.js +45 -0
  42. package/lib/cjs/components/datagrid/resize.js.map +1 -0
  43. package/lib/cjs/components/datagrid/row.js +37 -0
  44. package/lib/cjs/components/datagrid/row.js.map +1 -0
  45. package/lib/cjs/components/datagrid/sorter.js +17 -0
  46. package/lib/cjs/components/datagrid/sorter.js.map +1 -0
  47. package/lib/cjs/components/description/description.js +32 -0
  48. package/lib/cjs/components/description/description.js.map +1 -0
  49. package/lib/cjs/components/description/index.js +10 -0
  50. package/lib/cjs/components/description/index.js.map +1 -0
  51. package/lib/cjs/components/drawer/drawer.js +66 -0
  52. package/lib/cjs/components/drawer/drawer.js.map +1 -0
  53. package/lib/cjs/components/drawer/index.js +10 -0
  54. package/lib/cjs/components/drawer/index.js.map +1 -0
  55. package/lib/cjs/components/dropdown/dropdown.js +17 -0
  56. package/lib/cjs/components/dropdown/dropdown.js.map +1 -0
  57. package/lib/cjs/components/dropdown/index.js +10 -0
  58. package/lib/cjs/components/dropdown/index.js.map +1 -0
  59. package/lib/cjs/components/dropdown/item.js +22 -0
  60. package/lib/cjs/components/dropdown/item.js.map +1 -0
  61. package/lib/cjs/components/editor/controls.js +87 -0
  62. package/lib/cjs/components/editor/controls.js.map +1 -0
  63. package/lib/cjs/components/editor/editor.js +83 -0
  64. package/lib/cjs/components/editor/editor.js.map +1 -0
  65. package/lib/cjs/components/editor/index.js +10 -0
  66. package/lib/cjs/components/editor/index.js.map +1 -0
  67. package/lib/cjs/components/flex/flex.js +32 -0
  68. package/lib/cjs/components/flex/flex.js.map +1 -0
  69. package/lib/cjs/components/flex/index.js +10 -0
  70. package/lib/cjs/components/flex/index.js.map +1 -0
  71. package/lib/cjs/components/form/context.js +10 -0
  72. package/lib/cjs/components/form/context.js.map +1 -0
  73. package/lib/cjs/components/form/field.js +77 -0
  74. package/lib/cjs/components/form/field.js.map +1 -0
  75. package/lib/cjs/components/form/form.js +57 -0
  76. package/lib/cjs/components/form/form.js.map +1 -0
  77. package/lib/cjs/components/form/index.js +10 -0
  78. package/lib/cjs/components/form/index.js.map +1 -0
  79. package/lib/cjs/components/form/useForm.js +130 -0
  80. package/lib/cjs/components/form/useForm.js.map +1 -0
  81. package/lib/cjs/components/icon/icon.js +27 -0
  82. package/lib/cjs/components/icon/icon.js.map +1 -0
  83. package/lib/cjs/components/icon/index.js +10 -0
  84. package/lib/cjs/components/icon/index.js.map +1 -0
  85. package/lib/cjs/components/image/image.js +76 -0
  86. package/lib/cjs/components/image/image.js.map +1 -0
  87. package/lib/cjs/components/image/index.js +11 -0
  88. package/lib/cjs/components/image/index.js.map +1 -0
  89. package/lib/cjs/components/image/list.js +47 -0
  90. package/lib/cjs/components/image/list.js.map +1 -0
  91. package/lib/cjs/components/input/container.js +18 -0
  92. package/lib/cjs/components/input/container.js.map +1 -0
  93. package/lib/cjs/components/input/index.js +15 -0
  94. package/lib/cjs/components/input/index.js.map +1 -0
  95. package/lib/cjs/components/input/input.js +67 -0
  96. package/lib/cjs/components/input/input.js.map +1 -0
  97. package/lib/cjs/components/input/number.js +58 -0
  98. package/lib/cjs/components/input/number.js.map +1 -0
  99. package/lib/cjs/components/input/range.js +71 -0
  100. package/lib/cjs/components/input/range.js.map +1 -0
  101. package/lib/cjs/components/input/textarea.js +51 -0
  102. package/lib/cjs/components/input/textarea.js.map +1 -0
  103. package/lib/cjs/components/list/index.js +10 -0
  104. package/lib/cjs/components/list/index.js.map +1 -0
  105. package/lib/cjs/components/list/item.js +18 -0
  106. package/lib/cjs/components/list/item.js.map +1 -0
  107. package/lib/cjs/components/list/list.js +28 -0
  108. package/lib/cjs/components/list/list.js.map +1 -0
  109. package/lib/cjs/components/loading/index.js +10 -0
  110. package/lib/cjs/components/loading/index.js.map +1 -0
  111. package/lib/cjs/components/loading/loading.js +21 -0
  112. package/lib/cjs/components/loading/loading.js.map +1 -0
  113. package/lib/cjs/components/message/index.js +10 -0
  114. package/lib/cjs/components/message/index.js.map +1 -0
  115. package/lib/cjs/components/message/message.js +178 -0
  116. package/lib/cjs/components/message/message.js.map +1 -0
  117. package/lib/cjs/components/modal/hookModal.js +31 -0
  118. package/lib/cjs/components/modal/hookModal.js.map +1 -0
  119. package/lib/cjs/components/modal/index.js +11 -0
  120. package/lib/cjs/components/modal/index.js.map +1 -0
  121. package/lib/cjs/components/modal/modal.js +108 -0
  122. package/lib/cjs/components/modal/modal.js.map +1 -0
  123. package/lib/cjs/components/modal/useModal.js +38 -0
  124. package/lib/cjs/components/modal/useModal.js.map +1 -0
  125. package/lib/cjs/components/pagination/index.js +10 -0
  126. package/lib/cjs/components/pagination/index.js.map +1 -0
  127. package/lib/cjs/components/pagination/page.js +28 -0
  128. package/lib/cjs/components/pagination/page.js.map +1 -0
  129. package/lib/cjs/components/pagination/pagination.js +48 -0
  130. package/lib/cjs/components/pagination/pagination.js.map +1 -0
  131. package/lib/cjs/components/picker/colors/footer.js +44 -0
  132. package/lib/cjs/components/picker/colors/footer.js.map +1 -0
  133. package/lib/cjs/components/picker/colors/handle.js +14 -0
  134. package/lib/cjs/components/picker/colors/handle.js.map +1 -0
  135. package/lib/cjs/components/picker/colors/index.js +61 -0
  136. package/lib/cjs/components/picker/colors/index.js.map +1 -0
  137. package/lib/cjs/components/picker/dates/dates.js +50 -0
  138. package/lib/cjs/components/picker/dates/dates.js.map +1 -0
  139. package/lib/cjs/components/picker/dates/index.js +66 -0
  140. package/lib/cjs/components/picker/dates/index.js.map +1 -0
  141. package/lib/cjs/components/picker/dates/panel.js +81 -0
  142. package/lib/cjs/components/picker/dates/panel.js.map +1 -0
  143. package/lib/cjs/components/picker/time/index.js +50 -0
  144. package/lib/cjs/components/picker/time/index.js.map +1 -0
  145. package/lib/cjs/components/picker/time/item.js +19 -0
  146. package/lib/cjs/components/picker/time/item.js.map +1 -0
  147. package/lib/cjs/components/picker/time/panel.js +87 -0
  148. package/lib/cjs/components/picker/time/panel.js.map +1 -0
  149. package/lib/cjs/components/popconfirm/index.js +10 -0
  150. package/lib/cjs/components/popconfirm/index.js.map +1 -0
  151. package/lib/cjs/components/popconfirm/popconfirm.js +58 -0
  152. package/lib/cjs/components/popconfirm/popconfirm.js.map +1 -0
  153. package/lib/cjs/components/popup/content.js +44 -0
  154. package/lib/cjs/components/popup/content.js.map +1 -0
  155. package/lib/cjs/components/popup/index.js +10 -0
  156. package/lib/cjs/components/popup/index.js.map +1 -0
  157. package/lib/cjs/components/popup/popup.js +223 -0
  158. package/lib/cjs/components/popup/popup.js.map +1 -0
  159. package/lib/cjs/components/progress/circle.js +17 -0
  160. package/lib/cjs/components/progress/circle.js.map +1 -0
  161. package/lib/cjs/components/progress/index.js +10 -0
  162. package/lib/cjs/components/progress/index.js.map +1 -0
  163. package/lib/cjs/components/progress/line.js +18 -0
  164. package/lib/cjs/components/progress/line.js.map +1 -0
  165. package/lib/cjs/components/progress/progress.js +87 -0
  166. package/lib/cjs/components/progress/progress.js.map +1 -0
  167. package/lib/cjs/components/radio/index.js +10 -0
  168. package/lib/cjs/components/radio/index.js.map +1 -0
  169. package/lib/cjs/components/radio/item.js +21 -0
  170. package/lib/cjs/components/radio/item.js.map +1 -0
  171. package/lib/cjs/components/radio/radio.js +39 -0
  172. package/lib/cjs/components/radio/radio.js.map +1 -0
  173. package/lib/cjs/components/resizable/index.js +10 -0
  174. package/lib/cjs/components/resizable/index.js.map +1 -0
  175. package/lib/cjs/components/resizable/resizable.js +65 -0
  176. package/lib/cjs/components/resizable/resizable.js.map +1 -0
  177. package/lib/cjs/components/select/index.js +10 -0
  178. package/lib/cjs/components/select/index.js.map +1 -0
  179. package/lib/cjs/components/select/options.js +51 -0
  180. package/lib/cjs/components/select/options.js.map +1 -0
  181. package/lib/cjs/components/select/select.js +97 -0
  182. package/lib/cjs/components/select/select.js.map +1 -0
  183. package/lib/cjs/components/step/divider.js +12 -0
  184. package/lib/cjs/components/step/divider.js.map +1 -0
  185. package/lib/cjs/components/step/index.js +10 -0
  186. package/lib/cjs/components/step/index.js.map +1 -0
  187. package/lib/cjs/components/step/item.js +26 -0
  188. package/lib/cjs/components/step/item.js.map +1 -0
  189. package/lib/cjs/components/step/step.js +40 -0
  190. package/lib/cjs/components/step/step.js.map +1 -0
  191. package/lib/cjs/components/swiper/index.js +10 -0
  192. package/lib/cjs/components/swiper/index.js.map +1 -0
  193. package/lib/cjs/components/swiper/item.js +29 -0
  194. package/lib/cjs/components/swiper/item.js.map +1 -0
  195. package/lib/cjs/components/swiper/swiper.js +238 -0
  196. package/lib/cjs/components/swiper/swiper.js.map +1 -0
  197. package/lib/cjs/components/tabs/index.js +10 -0
  198. package/lib/cjs/components/tabs/index.js.map +1 -0
  199. package/lib/cjs/components/tabs/item.js +12 -0
  200. package/lib/cjs/components/tabs/item.js.map +1 -0
  201. package/lib/cjs/components/tabs/tabs.js +215 -0
  202. package/lib/cjs/components/tabs/tabs.js.map +1 -0
  203. package/lib/cjs/components/tag/index.js +10 -0
  204. package/lib/cjs/components/tag/index.js.map +1 -0
  205. package/lib/cjs/components/tag/tag.js +22 -0
  206. package/lib/cjs/components/tag/tag.js.map +1 -0
  207. package/lib/cjs/components/text/highlight.js +32 -0
  208. package/lib/cjs/components/text/highlight.js.map +1 -0
  209. package/lib/cjs/components/text/index.js +15 -0
  210. package/lib/cjs/components/text/index.js.map +1 -0
  211. package/lib/cjs/components/text/number.js +31 -0
  212. package/lib/cjs/components/text/number.js.map +1 -0
  213. package/lib/cjs/components/text/text.js +32 -0
  214. package/lib/cjs/components/text/text.js.map +1 -0
  215. package/lib/cjs/components/text/time.js +24 -0
  216. package/lib/cjs/components/text/time.js.map +1 -0
  217. package/lib/cjs/components/tree/index.js +10 -0
  218. package/lib/cjs/components/tree/index.js.map +1 -0
  219. package/lib/cjs/components/tree/item.js +76 -0
  220. package/lib/cjs/components/tree/item.js.map +1 -0
  221. package/lib/cjs/components/tree/tree.js +136 -0
  222. package/lib/cjs/components/tree/tree.js.map +1 -0
  223. package/lib/cjs/components/upload/index.js +10 -0
  224. package/lib/cjs/components/upload/index.js.map +1 -0
  225. package/lib/cjs/components/upload/renderFile.js +66 -0
  226. package/lib/cjs/components/upload/renderFile.js.map +1 -0
  227. package/lib/cjs/components/upload/upload.js +127 -0
  228. package/lib/cjs/components/upload/upload.js.map +1 -0
  229. package/lib/cjs/components/utils/empty/index.js +15 -0
  230. package/lib/cjs/components/utils/empty/index.js.map +1 -0
  231. package/lib/cjs/components/utils/helpericon/helpericon.js +28 -0
  232. package/lib/cjs/components/utils/helpericon/helpericon.js.map +1 -0
  233. package/lib/cjs/components/utils/helpericon/index.js +10 -0
  234. package/lib/cjs/components/utils/helpericon/index.js.map +1 -0
  235. package/lib/cjs/components/video/index.js +10 -0
  236. package/lib/cjs/components/video/index.js.map +1 -0
  237. package/lib/cjs/components/video/video.js +175 -0
  238. package/lib/cjs/components/video/video.js.map +1 -0
  239. package/lib/cjs/index.js +89 -0
  240. package/lib/cjs/index.js.map +1 -0
  241. package/lib/cjs/js/hooks.js +115 -0
  242. package/lib/cjs/js/hooks.js.map +1 -0
  243. package/lib/cjs/js/usePreview/content.js +148 -0
  244. package/lib/cjs/js/usePreview/content.js.map +1 -0
  245. package/lib/cjs/js/usePreview/index.js +27 -0
  246. package/lib/cjs/js/usePreview/index.js.map +1 -0
  247. package/lib/cjs/js/usePreview/renderFile.js +24 -0
  248. package/lib/cjs/js/usePreview/renderFile.js.map +1 -0
  249. package/lib/cjs/js/usePreview/type.js +13 -0
  250. package/lib/cjs/js/usePreview/type.js.map +1 -0
  251. package/lib/cjs/js/useRipple/index.js +47 -0
  252. package/lib/cjs/js/useRipple/index.js.map +1 -0
  253. package/lib/cjs/js/utils.js +281 -0
  254. package/lib/cjs/js/utils.js.map +1 -0
  255. package/lib/css/index.css +1 -1
  256. package/lib/css/index.css.map +1 -1
  257. package/lib/es/components/affix/affix.js +59 -0
  258. package/lib/es/components/affix/affix.js.map +1 -0
  259. package/lib/es/components/affix/index.js +6 -0
  260. package/lib/{components/badge → es/components/affix}/index.js.map +1 -1
  261. package/lib/es/components/affix/totop.js +14 -0
  262. package/lib/es/components/affix/totop.js.map +1 -0
  263. package/lib/es/components/badge/badge.js +13 -0
  264. package/lib/es/components/badge/badge.js.map +1 -0
  265. package/lib/es/components/badge/index.js +6 -0
  266. package/lib/{components/checkbox → es/components/badge}/index.js.map +1 -1
  267. package/lib/es/components/button/button.js +58 -0
  268. package/lib/es/components/button/button.js.map +1 -0
  269. package/lib/es/components/button/group.js +21 -0
  270. package/lib/es/components/button/group.js.map +1 -0
  271. package/lib/es/components/button/index.js +9 -0
  272. package/lib/es/components/button/index.js.map +1 -0
  273. package/lib/es/components/button/toggle.js +46 -0
  274. package/lib/es/components/button/toggle.js.map +1 -0
  275. package/lib/es/components/card/card.js +13 -0
  276. package/lib/es/components/card/card.js.map +1 -0
  277. package/lib/es/components/card/index.js +6 -0
  278. package/lib/{components → es/components}/card/index.js.map +1 -1
  279. package/lib/es/components/checkbox/checkbox.js +42 -0
  280. package/lib/es/components/checkbox/checkbox.js.map +1 -0
  281. package/lib/es/components/checkbox/index.js +6 -0
  282. package/lib/{components/affix → es/components/checkbox}/index.js.map +1 -1
  283. package/lib/es/components/checkbox/item.js +36 -0
  284. package/lib/es/components/checkbox/item.js.map +1 -0
  285. package/lib/es/components/collapse/collapse.js +74 -0
  286. package/lib/es/components/collapse/collapse.js.map +1 -0
  287. package/lib/es/components/collapse/index.js +6 -0
  288. package/lib/es/components/collapse/index.js.map +1 -0
  289. package/lib/es/components/collapse/item.js +8 -0
  290. package/lib/es/components/collapse/item.js.map +1 -0
  291. package/lib/es/components/datagrid/cell.js +24 -0
  292. package/lib/es/components/datagrid/cell.js.map +1 -0
  293. package/lib/es/components/datagrid/datagrid.js +113 -0
  294. package/lib/es/components/datagrid/datagrid.js.map +1 -0
  295. package/lib/es/components/datagrid/index.js +6 -0
  296. package/lib/es/components/datagrid/index.js.map +1 -0
  297. package/lib/es/components/datagrid/resize.js +41 -0
  298. package/lib/es/components/datagrid/resize.js.map +1 -0
  299. package/lib/es/components/datagrid/row.js +32 -0
  300. package/lib/es/components/datagrid/row.js.map +1 -0
  301. package/lib/es/components/datagrid/sorter.js +13 -0
  302. package/lib/es/components/datagrid/sorter.js.map +1 -0
  303. package/lib/es/components/description/description.js +28 -0
  304. package/lib/es/components/description/description.js.map +1 -0
  305. package/lib/es/components/description/index.js +6 -0
  306. package/lib/es/components/description/index.js.map +1 -0
  307. package/lib/es/components/drawer/drawer.js +62 -0
  308. package/lib/es/components/drawer/drawer.js.map +1 -0
  309. package/lib/es/components/drawer/index.js +6 -0
  310. package/lib/es/components/drawer/index.js.map +1 -0
  311. package/lib/es/components/dropdown/dropdown.js +13 -0
  312. package/lib/es/components/dropdown/dropdown.js.map +1 -0
  313. package/lib/es/components/dropdown/index.js +6 -0
  314. package/lib/es/components/dropdown/index.js.map +1 -0
  315. package/lib/es/components/dropdown/item.js +18 -0
  316. package/lib/es/components/dropdown/item.js.map +1 -0
  317. package/lib/es/components/editor/controls.js +81 -0
  318. package/lib/es/components/editor/controls.js.map +1 -0
  319. package/lib/es/components/editor/editor.js +79 -0
  320. package/lib/es/components/editor/editor.js.map +1 -0
  321. package/lib/es/components/editor/index.js +6 -0
  322. package/lib/es/components/editor/index.js.map +1 -0
  323. package/lib/es/components/flex/flex.js +28 -0
  324. package/lib/es/components/flex/flex.js.map +1 -0
  325. package/lib/es/components/flex/index.js +6 -0
  326. package/lib/es/components/flex/index.js.map +1 -0
  327. package/lib/es/components/form/context.js +6 -0
  328. package/lib/es/components/form/context.js.map +1 -0
  329. package/lib/es/components/form/field.js +73 -0
  330. package/lib/es/components/form/field.js.map +1 -0
  331. package/lib/es/components/form/form.js +53 -0
  332. package/lib/es/components/form/form.js.map +1 -0
  333. package/lib/es/components/form/index.js +6 -0
  334. package/lib/es/components/form/index.js.map +1 -0
  335. package/lib/es/components/form/useForm.js +125 -0
  336. package/lib/es/components/form/useForm.js.map +1 -0
  337. package/lib/es/components/icon/icon.js +23 -0
  338. package/lib/es/components/icon/icon.js.map +1 -0
  339. package/lib/es/components/icon/index.js +6 -0
  340. package/lib/es/components/icon/index.js.map +1 -0
  341. package/lib/es/components/image/image.js +72 -0
  342. package/lib/es/components/image/image.js.map +1 -0
  343. package/lib/es/components/image/index.js +7 -0
  344. package/lib/es/components/image/index.js.map +1 -0
  345. package/lib/es/components/image/list.js +43 -0
  346. package/lib/es/components/image/list.js.map +1 -0
  347. package/lib/es/components/input/container.js +14 -0
  348. package/lib/es/components/input/container.js.map +1 -0
  349. package/lib/es/components/input/index.js +11 -0
  350. package/lib/es/components/input/index.js.map +1 -0
  351. package/lib/es/components/input/input.js +63 -0
  352. package/lib/es/components/input/input.js.map +1 -0
  353. package/lib/es/components/input/number.js +54 -0
  354. package/lib/es/components/input/number.js.map +1 -0
  355. package/lib/es/components/input/range.js +67 -0
  356. package/lib/es/components/input/range.js.map +1 -0
  357. package/lib/es/components/input/textarea.js +47 -0
  358. package/lib/es/components/input/textarea.js.map +1 -0
  359. package/lib/es/components/list/index.js +6 -0
  360. package/lib/es/components/list/index.js.map +1 -0
  361. package/lib/es/components/list/item.js +14 -0
  362. package/lib/es/components/list/item.js.map +1 -0
  363. package/lib/es/components/list/list.js +24 -0
  364. package/lib/es/components/list/list.js.map +1 -0
  365. package/lib/es/components/loading/index.js +6 -0
  366. package/lib/es/components/loading/index.js.map +1 -0
  367. package/lib/es/components/loading/loading.js +17 -0
  368. package/lib/es/components/loading/loading.js.map +1 -0
  369. package/lib/es/components/message/index.js +6 -0
  370. package/lib/es/components/message/index.js.map +1 -0
  371. package/lib/es/components/message/message.js +174 -0
  372. package/lib/es/components/message/message.js.map +1 -0
  373. package/lib/es/components/modal/hookModal.js +27 -0
  374. package/lib/es/components/modal/hookModal.js.map +1 -0
  375. package/lib/es/components/modal/index.js +7 -0
  376. package/lib/es/components/modal/index.js.map +1 -0
  377. package/lib/es/components/modal/modal.js +104 -0
  378. package/lib/es/components/modal/modal.js.map +1 -0
  379. package/lib/es/components/modal/useModal.js +34 -0
  380. package/lib/es/components/modal/useModal.js.map +1 -0
  381. package/lib/es/components/pagination/index.js +6 -0
  382. package/lib/es/components/pagination/index.js.map +1 -0
  383. package/lib/es/components/pagination/page.js +24 -0
  384. package/lib/es/components/pagination/page.js.map +1 -0
  385. package/lib/es/components/pagination/pagination.js +44 -0
  386. package/lib/es/components/pagination/pagination.js.map +1 -0
  387. package/lib/es/components/picker/colors/footer.js +39 -0
  388. package/lib/es/components/picker/colors/footer.js.map +1 -0
  389. package/lib/es/components/picker/colors/handle.js +10 -0
  390. package/lib/es/components/picker/colors/handle.js.map +1 -0
  391. package/lib/es/components/picker/colors/index.js +57 -0
  392. package/lib/es/components/picker/colors/index.js.map +1 -0
  393. package/lib/es/components/picker/dates/dates.js +46 -0
  394. package/lib/es/components/picker/dates/dates.js.map +1 -0
  395. package/lib/es/components/picker/dates/index.js +62 -0
  396. package/lib/es/components/picker/dates/index.js.map +1 -0
  397. package/lib/es/components/picker/dates/panel.js +77 -0
  398. package/lib/es/components/picker/dates/panel.js.map +1 -0
  399. package/lib/es/components/picker/time/index.js +46 -0
  400. package/lib/es/components/picker/time/index.js.map +1 -0
  401. package/lib/es/components/picker/time/item.js +15 -0
  402. package/lib/es/components/picker/time/item.js.map +1 -0
  403. package/lib/es/components/picker/time/panel.js +83 -0
  404. package/lib/es/components/picker/time/panel.js.map +1 -0
  405. package/lib/es/components/popconfirm/index.js +6 -0
  406. package/lib/es/components/popconfirm/index.js.map +1 -0
  407. package/lib/es/components/popconfirm/popconfirm.js +54 -0
  408. package/lib/es/components/popconfirm/popconfirm.js.map +1 -0
  409. package/lib/es/components/popup/content.js +40 -0
  410. package/lib/es/components/popup/content.js.map +1 -0
  411. package/lib/es/components/popup/index.js +6 -0
  412. package/lib/es/components/popup/index.js.map +1 -0
  413. package/lib/es/components/popup/popup.js +219 -0
  414. package/lib/es/components/popup/popup.js.map +1 -0
  415. package/lib/es/components/progress/circle.js +13 -0
  416. package/lib/es/components/progress/circle.js.map +1 -0
  417. package/lib/es/components/progress/index.js +6 -0
  418. package/lib/es/components/progress/index.js.map +1 -0
  419. package/lib/es/components/progress/line.js +14 -0
  420. package/lib/es/components/progress/line.js.map +1 -0
  421. package/lib/es/components/progress/progress.js +83 -0
  422. package/lib/es/components/progress/progress.js.map +1 -0
  423. package/lib/es/components/radio/index.js +6 -0
  424. package/lib/es/components/radio/index.js.map +1 -0
  425. package/lib/es/components/radio/item.js +17 -0
  426. package/lib/es/components/radio/item.js.map +1 -0
  427. package/lib/es/components/radio/radio.js +35 -0
  428. package/lib/es/components/radio/radio.js.map +1 -0
  429. package/lib/es/components/resizable/index.js +6 -0
  430. package/lib/es/components/resizable/index.js.map +1 -0
  431. package/lib/es/components/resizable/resizable.js +61 -0
  432. package/lib/es/components/resizable/resizable.js.map +1 -0
  433. package/lib/es/components/select/index.js +6 -0
  434. package/lib/es/components/select/index.js.map +1 -0
  435. package/lib/es/components/select/options.js +47 -0
  436. package/lib/es/components/select/options.js.map +1 -0
  437. package/lib/es/components/select/select.js +93 -0
  438. package/lib/es/components/select/select.js.map +1 -0
  439. package/lib/es/components/step/divider.js +8 -0
  440. package/lib/es/components/step/divider.js.map +1 -0
  441. package/lib/es/components/step/index.js +6 -0
  442. package/lib/es/components/step/index.js.map +1 -0
  443. package/lib/es/components/step/item.js +22 -0
  444. package/lib/es/components/step/item.js.map +1 -0
  445. package/lib/es/components/step/step.js +36 -0
  446. package/lib/es/components/step/step.js.map +1 -0
  447. package/lib/es/components/swiper/index.js +6 -0
  448. package/lib/es/components/swiper/index.js.map +1 -0
  449. package/lib/es/components/swiper/item.js +25 -0
  450. package/lib/es/components/swiper/item.js.map +1 -0
  451. package/lib/es/components/swiper/swiper.js +234 -0
  452. package/lib/es/components/swiper/swiper.js.map +1 -0
  453. package/lib/es/components/tabs/index.js +6 -0
  454. package/lib/es/components/tabs/index.js.map +1 -0
  455. package/lib/es/components/tabs/item.js +8 -0
  456. package/lib/es/components/tabs/item.js.map +1 -0
  457. package/lib/es/components/tabs/tabs.js +211 -0
  458. package/lib/es/components/tabs/tabs.js.map +1 -0
  459. package/lib/es/components/tag/index.js +6 -0
  460. package/lib/es/components/tag/index.js.map +1 -0
  461. package/lib/es/components/tag/tag.js +18 -0
  462. package/lib/es/components/tag/tag.js.map +1 -0
  463. package/lib/es/components/text/highlight.js +28 -0
  464. package/lib/es/components/text/highlight.js.map +1 -0
  465. package/lib/es/components/text/index.js +11 -0
  466. package/lib/es/components/text/index.js.map +1 -0
  467. package/lib/es/components/text/number.js +27 -0
  468. package/lib/es/components/text/number.js.map +1 -0
  469. package/lib/es/components/text/text.js +28 -0
  470. package/lib/es/components/text/text.js.map +1 -0
  471. package/lib/es/components/text/time.js +20 -0
  472. package/lib/es/components/text/time.js.map +1 -0
  473. package/lib/es/components/tree/index.js +6 -0
  474. package/lib/es/components/tree/index.js.map +1 -0
  475. package/lib/es/components/tree/item.js +73 -0
  476. package/lib/es/components/tree/item.js.map +1 -0
  477. package/lib/es/components/tree/tree.js +132 -0
  478. package/lib/es/components/tree/tree.js.map +1 -0
  479. package/lib/es/components/upload/index.js +6 -0
  480. package/lib/es/components/upload/index.js.map +1 -0
  481. package/lib/es/components/upload/renderFile.js +61 -0
  482. package/lib/es/components/upload/renderFile.js.map +1 -0
  483. package/lib/es/components/upload/upload.js +123 -0
  484. package/lib/es/components/upload/upload.js.map +1 -0
  485. package/lib/es/components/utils/empty/index.js +11 -0
  486. package/lib/es/components/utils/empty/index.js.map +1 -0
  487. package/lib/es/components/utils/helpericon/helpericon.js +24 -0
  488. package/lib/es/components/utils/helpericon/helpericon.js.map +1 -0
  489. package/lib/es/components/utils/helpericon/index.js +6 -0
  490. package/lib/es/components/utils/helpericon/index.js.map +1 -0
  491. package/lib/es/components/video/index.js +6 -0
  492. package/lib/es/components/video/index.js.map +1 -0
  493. package/lib/es/components/video/video.js +171 -0
  494. package/lib/es/components/video/video.js.map +1 -0
  495. package/lib/es/index.js +45 -0
  496. package/lib/es/index.js.map +1 -0
  497. package/lib/es/js/hooks.js +109 -0
  498. package/lib/es/js/hooks.js.map +1 -0
  499. package/lib/es/js/usePreview/content.js +144 -0
  500. package/lib/es/js/usePreview/content.js.map +1 -0
  501. package/lib/es/js/usePreview/index.js +23 -0
  502. package/lib/es/js/usePreview/index.js.map +1 -0
  503. package/lib/es/js/usePreview/renderFile.js +20 -0
  504. package/lib/es/js/usePreview/renderFile.js.map +1 -0
  505. package/lib/es/js/usePreview/type.js +13 -0
  506. package/lib/es/js/usePreview/type.js.map +1 -0
  507. package/lib/es/js/useRipple/index.js +43 -0
  508. package/lib/es/js/useRipple/index.js.map +1 -0
  509. package/lib/es/js/utils.js +265 -0
  510. package/lib/es/js/utils.js.map +1 -0
  511. package/lib/index.js +4317 -2
  512. package/lib/types/components/affix/affix.d.ts +0 -2
  513. package/lib/types/components/affix/index.d.ts +0 -2
  514. package/lib/types/components/affix/totop.d.ts +0 -2
  515. package/lib/types/components/affix/type.d.ts +0 -2
  516. package/lib/types/components/badge/badge.d.ts +0 -2
  517. package/lib/types/components/badge/index.d.ts +0 -2
  518. package/lib/types/components/badge/type.d.ts +0 -2
  519. package/lib/types/components/button/button.d.ts +0 -2
  520. package/lib/types/components/button/group.d.ts +0 -2
  521. package/lib/types/components/button/index.d.ts +0 -2
  522. package/lib/types/components/button/toggle.d.ts +0 -2
  523. package/lib/types/components/button/type.d.ts +0 -2
  524. package/lib/types/components/card/card.d.ts +0 -2
  525. package/lib/types/components/card/index.d.ts +0 -2
  526. package/lib/types/components/card/type.d.ts +0 -2
  527. package/lib/types/components/checkbox/checkbox.d.ts +0 -2
  528. package/lib/types/components/checkbox/index.d.ts +0 -2
  529. package/lib/types/components/checkbox/item.d.ts +0 -2
  530. package/lib/types/components/checkbox/type.d.ts +0 -2
  531. package/lib/types/components/collapse/collapse.d.ts +0 -2
  532. package/lib/types/components/collapse/index.d.ts +0 -2
  533. package/lib/types/components/collapse/item.d.ts +0 -2
  534. package/lib/types/components/collapse/type.d.ts +0 -2
  535. package/lib/types/components/datagrid/datagrid.d.ts +0 -2
  536. package/lib/types/components/datagrid/index.d.ts +0 -2
  537. package/lib/types/components/datagrid/type.d.ts +0 -2
  538. package/lib/types/components/description/description.d.ts +0 -2
  539. package/lib/types/components/description/index.d.ts +0 -2
  540. package/lib/types/components/description/type.d.ts +0 -2
  541. package/lib/types/components/drawer/drawer.d.ts +0 -2
  542. package/lib/types/components/drawer/index.d.ts +0 -2
  543. package/lib/types/components/drawer/type.d.ts +0 -2
  544. package/lib/types/components/dropdown/dropdown.d.ts +0 -2
  545. package/lib/types/components/dropdown/index.d.ts +0 -2
  546. package/lib/types/components/dropdown/type.d.ts +0 -2
  547. package/lib/types/components/editor/editor.d.ts +0 -2
  548. package/lib/types/components/editor/index.d.ts +0 -2
  549. package/lib/types/components/editor/type.d.ts +0 -2
  550. package/lib/types/components/flex/flex.d.ts +0 -2
  551. package/lib/types/components/flex/index.d.ts +0 -2
  552. package/lib/types/components/flex/type.d.ts +0 -2
  553. package/lib/types/components/form/field.d.ts +0 -2
  554. package/lib/types/components/form/form.d.ts +0 -2
  555. package/lib/types/components/form/index.d.ts +0 -2
  556. package/lib/types/components/form/type.d.ts +0 -2
  557. package/lib/types/components/form/useForm.d.ts +0 -2
  558. package/lib/types/components/icon/icon.d.ts +0 -2
  559. package/lib/types/components/icon/index.d.ts +0 -2
  560. package/lib/types/components/icon/type.d.ts +0 -2
  561. package/lib/types/components/image/image.d.ts +0 -2
  562. package/lib/types/components/image/index.d.ts +0 -2
  563. package/lib/types/components/image/list.d.ts +0 -2
  564. package/lib/types/components/image/type.d.ts +0 -2
  565. package/lib/types/components/input/index.d.ts +0 -2
  566. package/lib/types/components/input/input.d.ts +0 -2
  567. package/lib/types/components/input/number.d.ts +0 -2
  568. package/lib/types/components/input/range.d.ts +0 -2
  569. package/lib/types/components/input/textarea.d.ts +0 -2
  570. package/lib/types/components/input/type.d.ts +0 -2
  571. package/lib/types/components/list/index.d.ts +0 -2
  572. package/lib/types/components/list/list.d.ts +0 -2
  573. package/lib/types/components/list/type.d.ts +0 -2
  574. package/lib/types/components/loading/index.d.ts +0 -2
  575. package/lib/types/components/loading/loading.d.ts +0 -2
  576. package/lib/types/components/loading/type.d.ts +0 -2
  577. package/lib/types/components/message/index.d.ts +0 -2
  578. package/lib/types/components/message/message.d.ts +0 -2
  579. package/lib/types/components/message/type.d.ts +0 -2
  580. package/lib/types/components/modal/index.d.ts +0 -2
  581. package/lib/types/components/modal/modal.d.ts +0 -2
  582. package/lib/types/components/modal/type.d.ts +0 -2
  583. package/lib/types/components/modal/useModal.d.ts +0 -2
  584. package/lib/types/components/pagination/index.d.ts +0 -2
  585. package/lib/types/components/pagination/pagination.d.ts +0 -2
  586. package/lib/types/components/pagination/type.d.ts +0 -2
  587. package/lib/types/components/picker/colors/index.d.ts +0 -2
  588. package/lib/types/components/picker/dates/index.d.ts +0 -2
  589. package/lib/types/components/picker/time/index.d.ts +0 -2
  590. package/lib/types/components/picker/type.d.ts +2 -4
  591. package/lib/types/components/popconfirm/index.d.ts +0 -2
  592. package/lib/types/components/popconfirm/popconfirm.d.ts +0 -2
  593. package/lib/types/components/popconfirm/type.d.ts +0 -2
  594. package/lib/types/components/popup/index.d.ts +0 -2
  595. package/lib/types/components/popup/popup.d.ts +0 -2
  596. package/lib/types/components/popup/type.d.ts +0 -2
  597. package/lib/types/components/progress/index.d.ts +0 -2
  598. package/lib/types/components/progress/progress.d.ts +0 -2
  599. package/lib/types/components/progress/type.d.ts +0 -2
  600. package/lib/types/components/radio/index.d.ts +0 -2
  601. package/lib/types/components/radio/item.d.ts +0 -2
  602. package/lib/types/components/radio/radio.d.ts +0 -2
  603. package/lib/types/components/radio/type.d.ts +0 -2
  604. package/lib/types/components/resizable/index.d.ts +0 -2
  605. package/lib/types/components/resizable/resizable.d.ts +0 -2
  606. package/lib/types/components/resizable/type.d.ts +0 -2
  607. package/lib/types/components/select/index.d.ts +0 -2
  608. package/lib/types/components/select/select.d.ts +0 -2
  609. package/lib/types/components/select/type.d.ts +0 -2
  610. package/lib/types/components/step/index.d.ts +0 -2
  611. package/lib/types/components/step/item.d.ts +0 -2
  612. package/lib/types/components/step/step.d.ts +0 -2
  613. package/lib/types/components/step/type.d.ts +0 -2
  614. package/lib/types/components/swiper/index.d.ts +0 -2
  615. package/lib/types/components/swiper/item.d.ts +0 -2
  616. package/lib/types/components/swiper/swiper.d.ts +0 -2
  617. package/lib/types/components/swiper/type.d.ts +0 -2
  618. package/lib/types/components/tabs/index.d.ts +0 -2
  619. package/lib/types/components/tabs/item.d.ts +0 -2
  620. package/lib/types/components/tabs/tabs.d.ts +0 -2
  621. package/lib/types/components/tabs/type.d.ts +0 -2
  622. package/lib/types/components/tag/index.d.ts +0 -2
  623. package/lib/types/components/tag/tag.d.ts +0 -2
  624. package/lib/types/components/tag/type.d.ts +0 -2
  625. package/lib/types/components/text/highlight.d.ts +0 -2
  626. package/lib/types/components/text/index.d.ts +0 -2
  627. package/lib/types/components/text/number.d.ts +0 -2
  628. package/lib/types/components/text/text.d.ts +0 -2
  629. package/lib/types/components/text/time.d.ts +0 -2
  630. package/lib/types/components/text/type.d.ts +0 -2
  631. package/lib/types/components/tree/index.d.ts +0 -2
  632. package/lib/types/components/tree/tree.d.ts +0 -2
  633. package/lib/types/components/tree/type.d.ts +0 -2
  634. package/lib/types/components/upload/index.d.ts +0 -2
  635. package/lib/types/components/upload/type.d.ts +0 -2
  636. package/lib/types/components/upload/upload.d.ts +0 -2
  637. package/lib/types/components/video/index.d.ts +0 -2
  638. package/lib/types/components/video/type.d.ts +0 -2
  639. package/lib/types/components/video/video.d.ts +0 -2
  640. package/lib/types/index.d.ts +0 -2
  641. package/lib/types/js/usePreview/index.d.ts +0 -2
  642. package/lib/types/js/usePreview/type.d.ts +0 -2
  643. package/lib/types/type/index.d.ts +0 -2
  644. package/package.json +20 -11
  645. package/lib/components/affix/affix.js +0 -2
  646. package/lib/components/affix/affix.js.map +0 -1
  647. package/lib/components/affix/index.js +0 -2
  648. package/lib/components/affix/totop.js +0 -2
  649. package/lib/components/affix/totop.js.map +0 -1
  650. package/lib/components/badge/badge.js +0 -2
  651. package/lib/components/badge/badge.js.map +0 -1
  652. package/lib/components/badge/index.js +0 -2
  653. package/lib/components/button/button.js +0 -2
  654. package/lib/components/button/button.js.map +0 -1
  655. package/lib/components/button/group.js +0 -2
  656. package/lib/components/button/group.js.map +0 -1
  657. package/lib/components/button/index.js +0 -2
  658. package/lib/components/button/index.js.map +0 -1
  659. package/lib/components/button/toggle.js +0 -2
  660. package/lib/components/button/toggle.js.map +0 -1
  661. package/lib/components/card/card.js +0 -2
  662. package/lib/components/card/card.js.map +0 -1
  663. package/lib/components/card/index.js +0 -2
  664. package/lib/components/checkbox/checkbox.js +0 -2
  665. package/lib/components/checkbox/checkbox.js.map +0 -1
  666. package/lib/components/checkbox/index.js +0 -2
  667. package/lib/components/checkbox/item.js +0 -2
  668. package/lib/components/checkbox/item.js.map +0 -1
  669. package/lib/components/collapse/collapse.js +0 -2
  670. package/lib/components/collapse/collapse.js.map +0 -1
  671. package/lib/components/collapse/index.js +0 -2
  672. package/lib/components/collapse/index.js.map +0 -1
  673. package/lib/components/collapse/item.js +0 -2
  674. package/lib/components/collapse/item.js.map +0 -1
  675. package/lib/components/datagrid/cell.js +0 -2
  676. package/lib/components/datagrid/cell.js.map +0 -1
  677. package/lib/components/datagrid/datagrid.js +0 -2
  678. package/lib/components/datagrid/datagrid.js.map +0 -1
  679. package/lib/components/datagrid/index.js +0 -2
  680. package/lib/components/datagrid/index.js.map +0 -1
  681. package/lib/components/datagrid/resize.js +0 -2
  682. package/lib/components/datagrid/resize.js.map +0 -1
  683. package/lib/components/datagrid/row.js +0 -2
  684. package/lib/components/datagrid/row.js.map +0 -1
  685. package/lib/components/datagrid/sorter.js +0 -2
  686. package/lib/components/datagrid/sorter.js.map +0 -1
  687. package/lib/components/description/description.js +0 -2
  688. package/lib/components/description/description.js.map +0 -1
  689. package/lib/components/description/index.js +0 -2
  690. package/lib/components/description/index.js.map +0 -1
  691. package/lib/components/drawer/drawer.js +0 -2
  692. package/lib/components/drawer/drawer.js.map +0 -1
  693. package/lib/components/drawer/index.js +0 -2
  694. package/lib/components/drawer/index.js.map +0 -1
  695. package/lib/components/dropdown/dropdown.js +0 -2
  696. package/lib/components/dropdown/dropdown.js.map +0 -1
  697. package/lib/components/dropdown/index.js +0 -2
  698. package/lib/components/dropdown/index.js.map +0 -1
  699. package/lib/components/dropdown/item.js +0 -2
  700. package/lib/components/dropdown/item.js.map +0 -1
  701. package/lib/components/editor/controls.js +0 -2
  702. package/lib/components/editor/controls.js.map +0 -1
  703. package/lib/components/editor/editor.js +0 -2
  704. package/lib/components/editor/editor.js.map +0 -1
  705. package/lib/components/editor/index.js +0 -2
  706. package/lib/components/editor/index.js.map +0 -1
  707. package/lib/components/flex/flex.js +0 -2
  708. package/lib/components/flex/flex.js.map +0 -1
  709. package/lib/components/flex/index.js +0 -2
  710. package/lib/components/flex/index.js.map +0 -1
  711. package/lib/components/form/context.js +0 -2
  712. package/lib/components/form/context.js.map +0 -1
  713. package/lib/components/form/field.js +0 -2
  714. package/lib/components/form/field.js.map +0 -1
  715. package/lib/components/form/form.js +0 -2
  716. package/lib/components/form/form.js.map +0 -1
  717. package/lib/components/form/index.js +0 -2
  718. package/lib/components/form/index.js.map +0 -1
  719. package/lib/components/form/useForm.js +0 -2
  720. package/lib/components/form/useForm.js.map +0 -1
  721. package/lib/components/icon/icon.js +0 -2
  722. package/lib/components/icon/icon.js.map +0 -1
  723. package/lib/components/icon/index.js +0 -2
  724. package/lib/components/icon/index.js.map +0 -1
  725. package/lib/components/image/image.js +0 -2
  726. package/lib/components/image/image.js.map +0 -1
  727. package/lib/components/image/index.js +0 -2
  728. package/lib/components/image/index.js.map +0 -1
  729. package/lib/components/image/list.js +0 -2
  730. package/lib/components/image/list.js.map +0 -1
  731. package/lib/components/input/container.js +0 -2
  732. package/lib/components/input/container.js.map +0 -1
  733. package/lib/components/input/index.js +0 -2
  734. package/lib/components/input/index.js.map +0 -1
  735. package/lib/components/input/input.js +0 -2
  736. package/lib/components/input/input.js.map +0 -1
  737. package/lib/components/input/number.js +0 -2
  738. package/lib/components/input/number.js.map +0 -1
  739. package/lib/components/input/range.js +0 -2
  740. package/lib/components/input/range.js.map +0 -1
  741. package/lib/components/input/textarea.js +0 -2
  742. package/lib/components/input/textarea.js.map +0 -1
  743. package/lib/components/list/index.js +0 -2
  744. package/lib/components/list/index.js.map +0 -1
  745. package/lib/components/list/item.js +0 -2
  746. package/lib/components/list/item.js.map +0 -1
  747. package/lib/components/list/list.js +0 -2
  748. package/lib/components/list/list.js.map +0 -1
  749. package/lib/components/loading/index.js +0 -2
  750. package/lib/components/loading/index.js.map +0 -1
  751. package/lib/components/loading/loading.js +0 -2
  752. package/lib/components/loading/loading.js.map +0 -1
  753. package/lib/components/message/index.js +0 -2
  754. package/lib/components/message/index.js.map +0 -1
  755. package/lib/components/message/message.js +0 -2
  756. package/lib/components/message/message.js.map +0 -1
  757. package/lib/components/modal/hookModal.js +0 -2
  758. package/lib/components/modal/hookModal.js.map +0 -1
  759. package/lib/components/modal/index.js +0 -2
  760. package/lib/components/modal/index.js.map +0 -1
  761. package/lib/components/modal/modal.js +0 -2
  762. package/lib/components/modal/modal.js.map +0 -1
  763. package/lib/components/modal/useModal.js +0 -2
  764. package/lib/components/modal/useModal.js.map +0 -1
  765. package/lib/components/pagination/index.js +0 -2
  766. package/lib/components/pagination/index.js.map +0 -1
  767. package/lib/components/pagination/page.js +0 -2
  768. package/lib/components/pagination/page.js.map +0 -1
  769. package/lib/components/pagination/pagination.js +0 -2
  770. package/lib/components/pagination/pagination.js.map +0 -1
  771. package/lib/components/picker/colors/footer.js +0 -2
  772. package/lib/components/picker/colors/footer.js.map +0 -1
  773. package/lib/components/picker/colors/handle.js +0 -2
  774. package/lib/components/picker/colors/handle.js.map +0 -1
  775. package/lib/components/picker/colors/index.js +0 -2
  776. package/lib/components/picker/colors/index.js.map +0 -1
  777. package/lib/components/picker/dates/dates.js +0 -2
  778. package/lib/components/picker/dates/dates.js.map +0 -1
  779. package/lib/components/picker/dates/index.js +0 -2
  780. package/lib/components/picker/dates/index.js.map +0 -1
  781. package/lib/components/picker/dates/panel.js +0 -2
  782. package/lib/components/picker/dates/panel.js.map +0 -1
  783. package/lib/components/picker/time/index.js +0 -2
  784. package/lib/components/picker/time/index.js.map +0 -1
  785. package/lib/components/picker/time/item.js +0 -2
  786. package/lib/components/picker/time/item.js.map +0 -1
  787. package/lib/components/picker/time/panel.js +0 -2
  788. package/lib/components/picker/time/panel.js.map +0 -1
  789. package/lib/components/popconfirm/index.js +0 -2
  790. package/lib/components/popconfirm/index.js.map +0 -1
  791. package/lib/components/popconfirm/popconfirm.js +0 -2
  792. package/lib/components/popconfirm/popconfirm.js.map +0 -1
  793. package/lib/components/popup/content.js +0 -2
  794. package/lib/components/popup/content.js.map +0 -1
  795. package/lib/components/popup/index.js +0 -2
  796. package/lib/components/popup/index.js.map +0 -1
  797. package/lib/components/popup/popup.js +0 -2
  798. package/lib/components/popup/popup.js.map +0 -1
  799. package/lib/components/progress/circle.js +0 -2
  800. package/lib/components/progress/circle.js.map +0 -1
  801. package/lib/components/progress/index.js +0 -2
  802. package/lib/components/progress/index.js.map +0 -1
  803. package/lib/components/progress/line.js +0 -2
  804. package/lib/components/progress/line.js.map +0 -1
  805. package/lib/components/progress/progress.js +0 -2
  806. package/lib/components/progress/progress.js.map +0 -1
  807. package/lib/components/radio/index.js +0 -2
  808. package/lib/components/radio/index.js.map +0 -1
  809. package/lib/components/radio/item.js +0 -2
  810. package/lib/components/radio/item.js.map +0 -1
  811. package/lib/components/radio/radio.js +0 -2
  812. package/lib/components/radio/radio.js.map +0 -1
  813. package/lib/components/resizable/index.js +0 -2
  814. package/lib/components/resizable/index.js.map +0 -1
  815. package/lib/components/resizable/resizable.js +0 -2
  816. package/lib/components/resizable/resizable.js.map +0 -1
  817. package/lib/components/select/index.js +0 -2
  818. package/lib/components/select/index.js.map +0 -1
  819. package/lib/components/select/options.js +0 -2
  820. package/lib/components/select/options.js.map +0 -1
  821. package/lib/components/select/select.js +0 -2
  822. package/lib/components/select/select.js.map +0 -1
  823. package/lib/components/step/divider.js +0 -2
  824. package/lib/components/step/divider.js.map +0 -1
  825. package/lib/components/step/index.js +0 -2
  826. package/lib/components/step/index.js.map +0 -1
  827. package/lib/components/step/item.js +0 -2
  828. package/lib/components/step/item.js.map +0 -1
  829. package/lib/components/step/step.js +0 -2
  830. package/lib/components/step/step.js.map +0 -1
  831. package/lib/components/swiper/index.js +0 -2
  832. package/lib/components/swiper/index.js.map +0 -1
  833. package/lib/components/swiper/item.js +0 -2
  834. package/lib/components/swiper/item.js.map +0 -1
  835. package/lib/components/swiper/swiper.js +0 -2
  836. package/lib/components/swiper/swiper.js.map +0 -1
  837. package/lib/components/tabs/index.js +0 -2
  838. package/lib/components/tabs/index.js.map +0 -1
  839. package/lib/components/tabs/item.js +0 -2
  840. package/lib/components/tabs/item.js.map +0 -1
  841. package/lib/components/tabs/tabs.js +0 -2
  842. package/lib/components/tabs/tabs.js.map +0 -1
  843. package/lib/components/tag/index.js +0 -2
  844. package/lib/components/tag/index.js.map +0 -1
  845. package/lib/components/tag/tag.js +0 -2
  846. package/lib/components/tag/tag.js.map +0 -1
  847. package/lib/components/text/highlight.js +0 -2
  848. package/lib/components/text/highlight.js.map +0 -1
  849. package/lib/components/text/index.js +0 -2
  850. package/lib/components/text/index.js.map +0 -1
  851. package/lib/components/text/number.js +0 -2
  852. package/lib/components/text/number.js.map +0 -1
  853. package/lib/components/text/text.js +0 -2
  854. package/lib/components/text/text.js.map +0 -1
  855. package/lib/components/text/time.js +0 -2
  856. package/lib/components/text/time.js.map +0 -1
  857. package/lib/components/tree/index.js +0 -2
  858. package/lib/components/tree/index.js.map +0 -1
  859. package/lib/components/tree/item.js +0 -2
  860. package/lib/components/tree/item.js.map +0 -1
  861. package/lib/components/tree/tree.js +0 -2
  862. package/lib/components/tree/tree.js.map +0 -1
  863. package/lib/components/upload/index.js +0 -2
  864. package/lib/components/upload/index.js.map +0 -1
  865. package/lib/components/upload/renderFile.js +0 -2
  866. package/lib/components/upload/renderFile.js.map +0 -1
  867. package/lib/components/upload/upload.js +0 -2
  868. package/lib/components/upload/upload.js.map +0 -1
  869. package/lib/components/utils/empty/index.js +0 -2
  870. package/lib/components/utils/empty/index.js.map +0 -1
  871. package/lib/components/utils/helpericon/helpericon.js +0 -2
  872. package/lib/components/utils/helpericon/helpericon.js.map +0 -1
  873. package/lib/components/utils/helpericon/index.js +0 -2
  874. package/lib/components/utils/helpericon/index.js.map +0 -1
  875. package/lib/components/video/index.js +0 -2
  876. package/lib/components/video/index.js.map +0 -1
  877. package/lib/components/video/video.js +0 -2
  878. package/lib/components/video/video.js.map +0 -1
  879. package/lib/index.js.map +0 -1
  880. package/lib/js/hooks.js +0 -2
  881. package/lib/js/hooks.js.map +0 -1
  882. package/lib/js/usePreview/content.js +0 -2
  883. package/lib/js/usePreview/content.js.map +0 -1
  884. package/lib/js/usePreview/index.js +0 -2
  885. package/lib/js/usePreview/index.js.map +0 -1
  886. package/lib/js/usePreview/renderFile.js +0 -2
  887. package/lib/js/usePreview/renderFile.js.map +0 -1
  888. package/lib/js/usePreview/type.js +0 -2
  889. package/lib/js/usePreview/type.js.map +0 -1
  890. package/lib/js/useRipple/index.js +0 -2
  891. package/lib/js/useRipple/index.js.map +0 -1
  892. package/lib/js/utils.js +0 -2
  893. package/lib/js/utils.js.map +0 -1
package/lib/index.js CHANGED
@@ -1,2 +1,4317 @@
1
- export{default as Affix}from"./components/affix/affix.js";export{default as Badge}from"./components/badge/badge.js";import"./components/button/index.js";export{default as Card}from"./components/card/card.js";export{default as Checkbox}from"./components/checkbox/checkbox.js";export{default as Collapse}from"./components/collapse/collapse.js";export{default as Datagrid}from"./components/datagrid/datagrid.js";export{default as Description}from"./components/description/description.js";export{default as Drawer}from"./components/drawer/drawer.js";export{default as Dropdown}from"./components/dropdown/dropdown.js";export{default as Editor}from"./components/editor/editor.js";export{default as Flex}from"./components/flex/flex.js";export{default as Form}from"./components/form/form.js";export{default as Icon}from"./components/icon/icon.js";import"./components/image/index.js";import"./components/input/index.js";export{default as List}from"./components/list/list.js";export{default as Loading}from"./components/loading/loading.js";export{default as Message}from"./components/message/message.js";import"./components/modal/index.js";export{default as Pagination}from"./components/pagination/pagination.js";export{default as ColorPicker}from"./components/picker/colors/index.js";export{default as DatePicker}from"./components/picker/dates/index.js";export{default as TimePicker}from"./components/picker/time/index.js";export{default as Popconfirm}from"./components/popconfirm/popconfirm.js";export{default as Popup}from"./components/popup/popup.js";export{default as Progress}from"./components/progress/progress.js";export{default as Radio}from"./components/radio/radio.js";export{default as Resizable}from"./components/resizable/resizable.js";export{default as Select}from"./components/select/select.js";export{default as Step}from"./components/step/step.js";export{default as Swiper}from"./components/swiper/swiper.js";export{default as Tabs}from"./components/tabs/tabs.js";export{default as Tag}from"./components/tag/tag.js";import"./components/text/index.js";export{default as Tree}from"./components/tree/tree.js";export{default as Upload}from"./components/upload/upload.js";export{default as Video}from"./components/video/video.js";export{default as usePreview}from"./js/usePreview/index.js";export{default as Button}from"./components/button/button.js";export{default as Image}from"./components/image/image.js";export{default as Modal}from"./components/modal/modal.js";export{default as Text}from"./components/text/text.js";export{default as Input}from"./components/input/input.js";
2
- //# sourceMappingURL=index.js.map
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import classNames from 'classnames';
3
+ import { debounce, uid, throttle, pick, title } from 'radash';
4
+ import { createElement, useEffect, useMemo, Children, cloneElement, isValidElement, useState, useRef, Fragment as Fragment$1, useLayoutEffect, useImperativeHandle, createContext, useContext } from 'react';
5
+ import { SkipPreviousRound, CloseRound, MinusRound, PlusRound, InboxTwotone, FormatBoldRound, FormatItalicRound, FormatUnderlinedRound, StrikethroughSRound, RedoRound, UndoRound, ClearAllRound, PauseRound, PlayArrowRound, StopRound, VolumeOffRound, VolumeDownRound, FullscreenExitRound, FullscreenRound, FeedOutlined, AspectRatioRound, OpenInNewRound, FileDownloadOutlined, RotateRightRound, RotateLeftRound, KeyboardArrowLeftRound, KeyboardArrowRightRound, HideImageTwotone, VisibilityRound, VisibilityOffRound, SyncAltRound, MoreHorizRound, SearchRound, CheckRound, UnfoldMoreRound, CalendarMonthTwotone, AccessTimeRound, InfoOutlined, KeyboardArrowDownRound, ListAltRound, PlusSharp } from '@ricons/material';
6
+ import { useReactive, useCreation, useSize } from 'ahooks';
7
+ import { createRoot } from 'react-dom/client';
8
+ import { createPortal } from 'react-dom';
9
+ import xss, { escapeAttrValue } from 'xss';
10
+ import PubSub from 'pubsub-js';
11
+ import { findAll } from 'highlight-words-core';
12
+ import ColorsPanel from '@rc-component/color-picker';
13
+ import dayjs from 'dayjs';
14
+ import customParseFormat from 'dayjs/plugin/customParseFormat.js';
15
+ import SortableContainer, { SortableItem } from 'react-easy-sort';
16
+
17
+ const TIMEOUT = 500;
18
+ const useRipple = () => {
19
+ if (document.documentElement.dataset["useripple"])
20
+ return;
21
+ document.documentElement.dataset["useripple"] = "enable";
22
+ document.addEventListener("mousedown", listener);
23
+ };
24
+ function listener(e) {
25
+ const target = e.target;
26
+ const parent = target.closest("[data-ripple]");
27
+ if (!target || !parent)
28
+ return;
29
+ triggerRipple(parent, e);
30
+ }
31
+ function triggerRipple(target, e) {
32
+ const [$box, $ripple] = createRipple();
33
+ const rect = target.getBoundingClientRect();
34
+ const size = Math.max(rect.width, rect.height) * 2;
35
+ $ripple.style.cssText = `
36
+ left: ${e.pageX - rect.left}px;
37
+ top: ${e.pageY - rect.top}px;
38
+ width: ${size}px;
39
+ height: ${size}px;
40
+ transition: all ${TIMEOUT / 1000}s;
41
+ `;
42
+ target.insertAdjacentElement("afterbegin", $box);
43
+ target.offsetHeight;
44
+ $ripple.classList.add("i-ripple-active");
45
+ setTimeout(() => {
46
+ $box.remove();
47
+ }, TIMEOUT);
48
+ }
49
+ function createRipple() {
50
+ const $box = document.createElement("SPAN");
51
+ const $ripple = document.createElement("SPAN");
52
+ $box.className = "i-ripple-container";
53
+ $ripple.className = "i-ripple";
54
+ $box.append($ripple);
55
+ return [$box, $ripple];
56
+ }
57
+
58
+ const Loading = (props) => {
59
+ const { icon, text, size, absolute, style, className, ...restProps } = props;
60
+ return (jsxs("div", { className: classNames("i-loading-container", {
61
+ absolute,
62
+ }, className), style: {
63
+ ...style,
64
+ inset: absolute ? 0 : "unset",
65
+ }, ...restProps, children: [icon ?? (jsx("svg", { width: '24', height: '24', stroke: '#000', viewBox: '0 0 24 24', xmlns: 'http://www.w3.org/2000/svg', className: 'i-loading-icon', style: {
66
+ fontSize: size,
67
+ }, children: jsx("circle", { cx: '12', cy: '12', r: '9.5', fill: 'none', strokeWidth: '3', strokeLinecap: 'round', strokeDasharray: 40, strokeDashoffset: 0 }) })), text] }));
68
+ };
69
+
70
+ const formatClass = ({ outline, flat, loading, disabled, size = "normal", block, round, square, secondary, className, }) => classNames("i-btn", className, {
71
+ "i-btn-outline": outline,
72
+ "i-btn-flat": flat,
73
+ "i-btn-block": block,
74
+ "i-btn-loading": loading,
75
+ "i-btn-square": square,
76
+ "i-btn-secondary": secondary,
77
+ [`i-btn-${size}`]: size !== "normal",
78
+ round,
79
+ disabled,
80
+ });
81
+ const Button = (props) => {
82
+ const { as: As = "a", ref, children, className, loading, flat, outline, square, secondary, size, round, href, ripple = true, onClick, ...restProps } = props;
83
+ const handleClick = (e) => {
84
+ if (loading || restProps.disabled) {
85
+ e.stopPropagation();
86
+ e.preventDefault();
87
+ return;
88
+ }
89
+ onClick?.(e);
90
+ };
91
+ if (!children)
92
+ return jsx(Fragment, {});
93
+ const childNodes = [
94
+ loading && jsx(Loading, {}, 'loading'),
95
+ createElement("span", { key: "content", className: "i-btn-content" }, children),
96
+ ];
97
+ const attrs = {
98
+ className: formatClass(props),
99
+ ["data-ripple"]: ripple && !loading && !restProps.disabled ? "" : undefined,
100
+ onClick: handleClick,
101
+ };
102
+ useEffect(() => {
103
+ ripple && useRipple();
104
+ }, [ripple]);
105
+ if (typeof As === "string") {
106
+ return createElement(As, {
107
+ ref,
108
+ href,
109
+ ...attrs,
110
+ ...restProps,
111
+ }, childNodes);
112
+ }
113
+ return createElement(As, {
114
+ to: href || "",
115
+ ...attrs,
116
+ ...restProps,
117
+ }, childNodes);
118
+ };
119
+
120
+ function Group(props) {
121
+ const { children, vertical, buttonProps, className, style } = props;
122
+ const nodes = useMemo(() => {
123
+ return Children.map(children, (node) => {
124
+ const { type } = node;
125
+ if (type === Button) {
126
+ return cloneElement(node, Object.assign({}, node.props, buttonProps));
127
+ }
128
+ return node;
129
+ });
130
+ }, [children]);
131
+ return (jsx("div", { className: classNames(className, vertical ? "i-btn-group-vertical" : "i-btn-group-horizonal"), style: style, children: nodes }));
132
+ }
133
+
134
+ function Toggle(props) {
135
+ const { ref, active, activeClass, after, disabled, children, className, toggable, onClick, onToggle, ...restProps } = props;
136
+ const state = useReactive({
137
+ active,
138
+ done: true,
139
+ });
140
+ const toggle = async () => {
141
+ const hasAfter = !!after;
142
+ const nextActive = !state.active;
143
+ const canToggle = toggable ? await toggable() : true;
144
+ if (!canToggle)
145
+ return;
146
+ Object.assign(state, {
147
+ active: nextActive,
148
+ done: !hasAfter,
149
+ });
150
+ onToggle?.(nextActive);
151
+ if (!hasAfter)
152
+ return;
153
+ setTimeout(() => {
154
+ state.done = true;
155
+ }, 16);
156
+ };
157
+ const handleClick = (e) => {
158
+ onClick?.(e);
159
+ !disabled && toggle();
160
+ };
161
+ useEffect(() => {
162
+ Object.assign(state, {
163
+ active,
164
+ done: true,
165
+ });
166
+ }, [active]);
167
+ return (jsx(Button, { ref: ref, className: classNames(className, { [activeClass || ""]: state.active }, "i-btn-toggle"), ...restProps, onClick: handleClick, children: jsx("div", { className: classNames("i-btn-toggle-content", {
168
+ "i-btn-toggle-active": state.done,
169
+ }), children: state.active ? after ?? children : children }) }));
170
+ }
171
+
172
+ Button.Toggle = Toggle;
173
+ Button.Group = Group;
174
+
175
+ const Icon = (props) => {
176
+ const { ref, icon, size = "1.425em", rotate, style, className, ...restProps } = props;
177
+ if (!isValidElement(icon))
178
+ return icon;
179
+ const iconProps = {
180
+ ref,
181
+ style: {
182
+ transform: rotate ? `rotate(${rotate}deg)` : undefined,
183
+ ...style,
184
+ width: size,
185
+ height: size,
186
+ },
187
+ className: classNames("i-icon", className),
188
+ ...restProps,
189
+ };
190
+ return cloneElement(icon, iconProps);
191
+ };
192
+
193
+ function ToTop(props) {
194
+ const { style, className, onClick } = props;
195
+ return (jsx(Button, { square: true, className: classNames("i-affix-totop", className), style: { ...style }, onClick: onClick, children: jsx(Icon, { icon: jsx(SkipPreviousRound, {}), rotate: 90 }) }));
196
+ }
197
+
198
+ const Affix = (props) => {
199
+ const { position = "fixed", left, top, right, bottom, offset, style, className, children, getContainer = () => document.body, } = props;
200
+ const [hidden, setHidden] = useState(false);
201
+ const hijackChildren = useMemo(() => {
202
+ return Children.map(children, (node) => {
203
+ if (node.type === ToTop) {
204
+ const { onClick } = node.props;
205
+ return cloneElement(node, {
206
+ key: node.key,
207
+ ...node.props,
208
+ onClick: (e) => {
209
+ const container = getContainer();
210
+ onClick?.(e);
211
+ container?.scrollTo({
212
+ top: 0,
213
+ left: 0,
214
+ behavior: "smooth",
215
+ });
216
+ },
217
+ });
218
+ }
219
+ return node;
220
+ });
221
+ }, [children, getContainer]);
222
+ useEffect(() => {
223
+ const container = getContainer();
224
+ if (!offset || !container)
225
+ return;
226
+ const listener = debounce({ delay: 160 }, () => {
227
+ const top = container.scrollTop;
228
+ setHidden(top < offset);
229
+ });
230
+ listener();
231
+ container.addEventListener("scroll", listener);
232
+ return () => {
233
+ container.removeEventListener("scroll", listener);
234
+ };
235
+ }, [offset, getContainer]);
236
+ return (jsx("div", { className: classNames("i-affix", className, {
237
+ "i-affix-hidden": hidden,
238
+ }), style: {
239
+ ...style,
240
+ position,
241
+ left,
242
+ top,
243
+ right,
244
+ bottom,
245
+ }, children: hijackChildren }));
246
+ };
247
+ Affix.ToTop = ToTop;
248
+
249
+ const Badge = (props) => {
250
+ const { content, contentClass, dot, dotSize, round, disabled, style, className, children, } = props;
251
+ return (jsxs("div", { style: style, className: classNames("i-badge", { rounded: round }, className), children: [children, jsx("div", { className: classNames("i-badge-content", contentClass, {
252
+ "i-badge-dot": dot,
253
+ "i-badge-hidden": disabled,
254
+ }), style: { fontSize: dotSize }, children: content })] }));
255
+ };
256
+
257
+ const Card = (props) => {
258
+ const { hideShadow, border, className, children, header, footer, ...restProps } = props;
259
+ return (jsxs("div", { className: classNames("i-card", className, {
260
+ shadow: !hideShadow,
261
+ "i-card-bordered": border,
262
+ }), ...restProps, children: [header && jsx("div", { className: 'i-card-header', children: header }), children && jsx("div", { className: 'i-card-content', children: children }), footer && jsx("div", { className: 'i-card-footer', children: footer })] }));
263
+ };
264
+
265
+ function getPosition($source, $popup, options = {}) {
266
+ const { refWindow, gap = 0, offset = 0, position = "top", align } = options;
267
+ if (!$source || !$popup)
268
+ return [
269
+ 0,
270
+ 0,
271
+ {
272
+ arrowX: 0,
273
+ arrowY: 0,
274
+ arrowPos: "bottom",
275
+ },
276
+ ];
277
+ const rectT = $source.getBoundingClientRect();
278
+ const rectC = $popup.getBoundingClientRect();
279
+ let w = window.innerWidth;
280
+ let h = window.innerHeight;
281
+ let { left: tl, top: tt, right: tr, bottom: tb, width: tw, height: th, } = rectT;
282
+ const { height: ch, width: cw } = rectC;
283
+ if (!refWindow) {
284
+ const rectPa = $source.offsetParent?.getBoundingClientRect();
285
+ w = rectPa?.width || w;
286
+ h = rectPa?.height || h;
287
+ tl = $source.offsetLeft;
288
+ tt = $source.offsetTop;
289
+ tr = tl + rectT.width;
290
+ tb = tt + rectT.height;
291
+ }
292
+ let y = 0;
293
+ let x = 0;
294
+ let arrowX = 0;
295
+ let arrowY = 0;
296
+ let arrowPos = "bottom";
297
+ switch (position) {
298
+ case "left":
299
+ case "right":
300
+ y =
301
+ th !== ch
302
+ ? computePosition({
303
+ containerSize: h,
304
+ targetSize: th,
305
+ targetOffset: tt,
306
+ contentSize: ch,
307
+ gap,
308
+ align,
309
+ })
310
+ : tt;
311
+ arrowY = y < tt ? tt - y + th / 2 : th / 2;
312
+ const xl = tl - offset - cw;
313
+ const xr = tr + offset + cw;
314
+ if (position === "left") {
315
+ const R = xl < 0 && xr <= w;
316
+ x = R ? tr + offset : xl;
317
+ arrowX = R ? 0 : cw;
318
+ arrowPos = R ? "left" : "right";
319
+ }
320
+ else {
321
+ const R = w > xr || xl < 0;
322
+ x = R ? tr + offset : xl;
323
+ arrowX = R ? 0 : cw;
324
+ arrowPos = R ? "left" : "right";
325
+ }
326
+ break;
327
+ case "top":
328
+ case "bottom":
329
+ x =
330
+ tw !== cw
331
+ ? computePosition({
332
+ containerSize: w,
333
+ targetOffset: tl,
334
+ targetSize: tw,
335
+ contentSize: cw,
336
+ gap,
337
+ align,
338
+ })
339
+ : tl;
340
+ arrowX = x > tl ? cw / 2 : tl - x + tw / 2;
341
+ const yt = tt - offset - ch;
342
+ const yb = tb + offset + ch;
343
+ if (position === "top") {
344
+ const T = yt < 0 && yb <= h;
345
+ y = T ? tb + offset : yt;
346
+ arrowY = T ? 0 : ch;
347
+ arrowPos = T ? "top" : "bottom";
348
+ }
349
+ else {
350
+ const B = h > yb || yt < 0;
351
+ y = B ? tb + offset : yt;
352
+ arrowY = B ? 0 : ch;
353
+ arrowPos = B ? "top" : "bottom";
354
+ }
355
+ break;
356
+ }
357
+ return [
358
+ x,
359
+ y,
360
+ {
361
+ arrowX,
362
+ arrowY,
363
+ arrowPos,
364
+ },
365
+ ];
366
+ }
367
+ function getPointPosition(e, content) {
368
+ const { width: w, height: h } = content.getBoundingClientRect();
369
+ const parent = content.offsetParent;
370
+ let pw, ph, pl = 0, pt = 0;
371
+ if (parent) {
372
+ const { width: ow, height: oh, left: ol, top: ot, } = parent.getBoundingClientRect();
373
+ const st = parent.scrollTop ?? 0;
374
+ pw = ow;
375
+ ph = oh;
376
+ pt = ot - st;
377
+ pl = ol;
378
+ }
379
+ else {
380
+ pw = window.innerWidth;
381
+ ph = window.innerHeight;
382
+ }
383
+ const x = e.pageX - pl;
384
+ const y = e.pageY - pt;
385
+ const left = x + w >= pw ? (x - w > 0 ? x - w : x) : x;
386
+ const top = y + h >= ph ? (y - h > 0 ? y - h : y) : y;
387
+ return [left, top];
388
+ }
389
+ function computePosition({ containerSize, targetSize, targetOffset, contentSize, gap, align = "center", }) {
390
+ const centerPoint = targetOffset + targetSize / 2;
391
+ switch (align) {
392
+ case "start":
393
+ return targetOffset + contentSize > containerSize
394
+ ? containerSize - contentSize - gap
395
+ : targetOffset;
396
+ case "center":
397
+ if (targetSize >= contentSize) {
398
+ return centerPoint - contentSize / 2;
399
+ }
400
+ if (centerPoint + contentSize / 2 + gap > containerSize) {
401
+ return targetOffset + targetSize - contentSize;
402
+ }
403
+ if (centerPoint - contentSize / 2 - gap < 0) {
404
+ return gap;
405
+ }
406
+ return centerPoint - contentSize / 2;
407
+ case "end":
408
+ const result = targetOffset + targetSize - contentSize;
409
+ return result > 0 ? result : gap;
410
+ default:
411
+ return centerPoint - contentSize / 2;
412
+ }
413
+ }
414
+ function formatOption(options) {
415
+ return options.map((option) => ["string", "number"].includes(typeof option)
416
+ ? { label: option, value: option }
417
+ : option);
418
+ }
419
+ function animate(from, to, duration = 1000, callback, easing = (t) => 1 - Math.pow(1 - t, 4)) {
420
+ const start = performance.now();
421
+ const diff = to - from;
422
+ let raf = requestAnimationFrame(loop);
423
+ function loop() {
424
+ raf = requestAnimationFrame(loop);
425
+ const past = performance.now() - start;
426
+ let percent = past / duration;
427
+ if (percent >= 1) {
428
+ percent = 1;
429
+ cancelAnimationFrame(raf);
430
+ }
431
+ const pass = diff * easing(percent);
432
+ callback?.(pass);
433
+ }
434
+ }
435
+ function formatNumber(value, options = {}) {
436
+ const { precision, thousand } = options;
437
+ const result = value.toFixed(precision);
438
+ if (!thousand)
439
+ return result;
440
+ const points = result.split(".");
441
+ const integer = points[0].replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, `$&${thousand}`);
442
+ if (points.length === 1)
443
+ return integer;
444
+ return `${integer}.${points[1]}`;
445
+ }
446
+ function renderNode(node, container = document.body) {
447
+ const div = document.createElement("div");
448
+ container.append(div);
449
+ const root = createRoot(div);
450
+ const sto = setTimeout(() => {
451
+ root?.render(node);
452
+ }, 0);
453
+ return () => {
454
+ div?.remove();
455
+ root?.unmount();
456
+ sto && clearTimeout(sto);
457
+ };
458
+ }
459
+ function getSuffixByUrl(url) {
460
+ return url.match(/\.([^\./\?]+)($|\?)/)?.[1];
461
+ }
462
+ function getFileType(suffix, type) {
463
+ switch (true) {
464
+ case ["jpg", "jpeg", "png", "webp", "svg"].includes(suffix) ||
465
+ type?.startsWith("image/"):
466
+ return "IMAGE";
467
+ case ["mp4", "avi"].includes(suffix) || type?.startsWith("video/"):
468
+ return "VIDEO";
469
+ default:
470
+ return "UNKNOWN";
471
+ }
472
+ }
473
+ function fullScreen(el) {
474
+ el.requestFullscreen?.();
475
+ }
476
+ function exitFullScreen() {
477
+ document.exitFullscreen?.();
478
+ }
479
+ function formatTime(time, options) {
480
+ const result = [];
481
+ const { zero = true, units = ["", ":", ":"] } = options;
482
+ const l = units.length;
483
+ let i = 0;
484
+ while (i < l) {
485
+ if (time <= 0 && i > 1)
486
+ break;
487
+ const n = Math.round(time % 60);
488
+ time = Math.floor(time / 60);
489
+ result.unshift((zero && n < 10 ? `0${n}` : n) + units[i++]);
490
+ }
491
+ return result.join("");
492
+ }
493
+ function getNextSorter(prevSortBy, prevSortType, sortBy) {
494
+ const types = ["desc", "asc"];
495
+ if (prevSortBy === sortBy) {
496
+ const i = types.findIndex((t) => t === prevSortType) + 1;
497
+ const type = types[i] || "";
498
+ const by = type === "" ? "" : sortBy;
499
+ return [by, type];
500
+ }
501
+ return [sortBy, "desc"];
502
+ }
503
+ function formatBytes(bytes, decimals = 2) {
504
+ if (!+bytes)
505
+ return "0 Bytes";
506
+ const k = 1024;
507
+ const dm = decimals < 0 ? 0 : decimals;
508
+ const sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
509
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
510
+ return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
511
+ }
512
+ function clamp(value, min, max) {
513
+ return value < min ? min : value > max ? max : value;
514
+ }
515
+ const arrayMove = (array, fromIndex, toIndex) => {
516
+ if (toIndex >= array.length) {
517
+ let k = toIndex - array.length + 1;
518
+ while (k--) {
519
+ array.push(undefined);
520
+ }
521
+ }
522
+ array.splice(toIndex, 0, array.splice(fromIndex, 1)[0]);
523
+ return array;
524
+ };
525
+
526
+ function CheckboxItem(props) {
527
+ const { type = "default", label, name, value = false, className, status = "normal", message, disabled, partof, optionValue, children, onChange, ...restProps } = props;
528
+ const state = useReactive({
529
+ value,
530
+ status,
531
+ message,
532
+ });
533
+ const isChildrenFn = typeof children === "function";
534
+ const handleChange = (e) => {
535
+ const checked = e.target.checked;
536
+ Object.assign(state, {
537
+ value: checked,
538
+ status,
539
+ message,
540
+ });
541
+ onChange?.(checked, e);
542
+ };
543
+ useEffect(() => {
544
+ state.value = value;
545
+ }, [value]);
546
+ return (jsxs("label", { className: classNames("i-checkbox-item", {
547
+ [`i-checkbox-${state.status}`]: state.status !== "normal",
548
+ disabled,
549
+ }, className), ...restProps, children: [jsx("input", { type: 'checkbox', name: name, className: classNames("i-checkbox-input", {
550
+ [`i-checkbox-${type}`]: !partof,
551
+ "i-checkbox-partof": partof,
552
+ }), checked: state.value, disabled: disabled, onChange: handleChange }), isChildrenFn ? (children(state.value, optionValue)) : (jsx("span", { className: 'i-checkbox-text', children: children || label })), state.message && (jsxs("span", { className: 'i-checkbox-message', children: ["*", state.message] }))] }));
553
+ }
554
+
555
+ function Checkbox(props) {
556
+ const { label, name, options = [], value = "", type = "default", optionInline = true, labelInline, disabled, status = "normal", message, required, className, renderItem, onChange, ...restProps } = props;
557
+ const state = useReactive({
558
+ value,
559
+ });
560
+ const formattedOptions = useMemo(() => formatOption(options), [options]);
561
+ const handleChange = (checked, opt, e) => {
562
+ const group = [...state.value];
563
+ const i = group.findIndex((item) => item === opt.value);
564
+ if (checked && i < 0) {
565
+ group.push(opt.value);
566
+ }
567
+ else if (!checked && i > -1) {
568
+ group.splice(i, 1);
569
+ }
570
+ state.value = group;
571
+ onChange?.(group, opt, e);
572
+ };
573
+ useEffect(() => {
574
+ state.value = value;
575
+ }, [value]);
576
+ return (jsxs("div", { className: classNames("i-checkbox i-input-label", {
577
+ [`i-checkbox-${status}`]: status !== "normal",
578
+ "i-input-inline": labelInline,
579
+ }, className), ...restProps, children: [label && (jsxs("span", { className: 'i-input-label-text', children: [required && jsx("span", { className: 'error', children: "*" }), label, message && jsx("p", { className: 'i-checkbox-message', children: message })] })), jsx("div", { className: classNames("i-checkbox-options", {
580
+ "i-options-block": !optionInline,
581
+ "i-checkbox-options-button": type === "button",
582
+ }), children: formattedOptions.map((option) => {
583
+ return (jsx(CheckboxItem, { name: name, value: state.value.includes(option.value), optionValue: option.value, type: type, disabled: disabled || option.disabled, onChange: (checked, e) => handleChange(checked, option, e), children: renderItem ?? option.label }, option.value));
584
+ }) })] }));
585
+ }
586
+ Checkbox.Item = CheckboxItem;
587
+
588
+ const Helpericon = (props) => {
589
+ const { as = "a", active, className, icon = jsx(CloseRound, {}), ...restProps } = props;
590
+ if (!active)
591
+ return jsx(Fragment, {});
592
+ return createElement(as, {
593
+ className: classNames("i-helpericon", className),
594
+ ...restProps,
595
+ }, [
596
+ createElement(Icon, {
597
+ key: uid(3),
598
+ icon,
599
+ }),
600
+ ]);
601
+ };
602
+
603
+ function Item$5(props) {
604
+ return jsx(Fragment, {});
605
+ }
606
+
607
+ const Collapse = (props) => {
608
+ const { active, items, multiple, border, headerClickable, className, children, renderToggle = (active) => active ? jsx(MinusRound, {}) : jsx(PlusRound, {}), onCollapse, ...restProps } = props;
609
+ const state = useReactive({
610
+ active,
611
+ });
612
+ const collapses = useMemo(() => {
613
+ if (!items) {
614
+ if (!children)
615
+ return [];
616
+ return (Children.map(children, (node, i) => {
617
+ const { key, props: nodeProps } = node;
618
+ const { title, children, content, disabled, ...restProps } = nodeProps;
619
+ return {
620
+ ...restProps,
621
+ key: key || i,
622
+ title,
623
+ content: children || content,
624
+ disabled,
625
+ };
626
+ }) || []);
627
+ }
628
+ return items;
629
+ }, [children]);
630
+ const handleHeaderClick = (item) => {
631
+ if (!headerClickable)
632
+ return;
633
+ handleToggle(item);
634
+ };
635
+ const handleToggle = (item, e) => {
636
+ const { key, disabled } = item;
637
+ e?.stopPropagation();
638
+ if (disabled)
639
+ return;
640
+ if (!multiple) {
641
+ state.active = state.active === key ? undefined : key;
642
+ onCollapse?.(key, state.active !== undefined);
643
+ return;
644
+ }
645
+ if (!Array.isArray(state.active))
646
+ state.active = [];
647
+ const i = state.active.findIndex((k) => k === key);
648
+ if (i > -1) {
649
+ state.active.splice(i, 1);
650
+ }
651
+ else {
652
+ key !== undefined && state.active.push(key);
653
+ }
654
+ onCollapse?.(key, i < 0);
655
+ };
656
+ return (jsx("div", { className: classNames("i-collapse", {
657
+ "i-collapse-bordered": border,
658
+ }, className), ...restProps, children: collapses.map((item) => {
659
+ const { key, title, content, disabled, className, ...restProps } = item;
660
+ const isActive = multiple
661
+ ? (state.active || []).includes(key)
662
+ : state.active === key;
663
+ return (jsxs("div", { className: classNames("i-collapse-item", className, {
664
+ "i-collapse-active": isActive,
665
+ "i-collapse-disabled": disabled,
666
+ }), ...restProps, children: [jsxs("div", { className: 'i-collapse-header', onClick: () => handleHeaderClick(item), children: [title, jsx(Helpericon, { active: true, className: 'i-collapse-toggle', icon: renderToggle(isActive), onClick: (e) => handleToggle(item, e) })] }), jsx("div", { className: 'i-collapse-content', children: content })] }, key));
667
+ }) }));
668
+ };
669
+ Collapse.Item = Item$5;
670
+
671
+ function Empty(props) {
672
+ const { className, ...restProps } = props;
673
+ return (jsx(InboxTwotone, { className: classNames("i-empty", className), ...restProps }));
674
+ }
675
+
676
+ function getCellStyle({ justify, col, row, colSpan = 1, rowSpan = 1, }) {
677
+ const style = {
678
+ "--datagrid-justify": justify,
679
+ gridArea: `${row + 1} / ${col + 1} / ${row + 1 + rowSpan} / ${col + 1 + colSpan}`,
680
+ insetInline: `var(--datagrid-cell-inset-${col})`,
681
+ };
682
+ return style;
683
+ }
684
+ function Cell(props) {
685
+ const { column, row, col, data, cellEllipsis, onCellClick, onCellDoubleClick, } = props;
686
+ const { id, fixed, justify, rowSpan, render } = column;
687
+ const style = getCellStyle({ justify, fixed, col, row, rowSpan });
688
+ return (jsx("div", { className: classNames("i-datagrid-cell", {
689
+ [`i-datagrid-cell-fixed-${fixed}`]: fixed,
690
+ }), "data-col": id, style: style, onClick: (e) => onCellClick?.(data, column, row, col, e), onDoubleClick: (e) => onCellDoubleClick?.(data, column, row, col, e), children: render?.(data[id], data, col) ?? (jsx("div", { className: classNames("i-datagrid-cell-content", {
691
+ "i-datagrid-cell-content-ellipsis": cellEllipsis,
692
+ }), children: data[id] })) }));
693
+ }
694
+
695
+ const MouseMoveEvents = new Set();
696
+ const MouseUpEvents = new Set();
697
+ const KeydownEvents = new Set();
698
+ const touchable = "ontouchend" in document;
699
+ const EVENTS = {
700
+ MOVE: touchable ? "touchmove" : "mousemove",
701
+ UP: touchable ? "touchend" : "mouseup",
702
+ KEYDOWN: "keydown",
703
+ };
704
+ document.addEventListener(EVENTS.MOVE, (e) => {
705
+ for (const listener of MouseMoveEvents.values()) {
706
+ listener(e);
707
+ }
708
+ }, { passive: false });
709
+ document.addEventListener(EVENTS.UP, (e) => {
710
+ for (const listener of MouseUpEvents.values()) {
711
+ listener(e);
712
+ }
713
+ });
714
+ document.addEventListener(EVENTS.KEYDOWN, (e) => {
715
+ for (const listener of KeydownEvents.values()) {
716
+ listener(e);
717
+ }
718
+ });
719
+ function useMouseMove(listener, options) {
720
+ useEffect(() => {
721
+ MouseMoveEvents.add(listener);
722
+ return () => {
723
+ MouseMoveEvents.delete(listener);
724
+ };
725
+ }, [listener]);
726
+ }
727
+ function useMouseUp(listener, options) {
728
+ useEffect(() => {
729
+ MouseUpEvents.add(listener);
730
+ return () => {
731
+ MouseUpEvents.delete(listener);
732
+ };
733
+ }, [listener]);
734
+ }
735
+ function useKeydown(listener, options) {
736
+ useEffect(() => {
737
+ if (options?.disabled)
738
+ return;
739
+ KeydownEvents.add(listener);
740
+ return () => {
741
+ KeydownEvents.delete(listener);
742
+ };
743
+ }, [listener]);
744
+ }
745
+ function useIntersectionObserver(configs) {
746
+ const WM = new WeakMap();
747
+ const IO = new IntersectionObserver((entries) => {
748
+ entries.map((entry) => {
749
+ const callback = WM.get(entry.target);
750
+ callback?.(entry.target, entry.isIntersecting);
751
+ });
752
+ }, configs);
753
+ function observe(target, callback) {
754
+ if (WM.get(target))
755
+ return;
756
+ WM.set(target, callback);
757
+ target && IO.observe(target);
758
+ }
759
+ function unobserve(target) {
760
+ target && IO.unobserve(target);
761
+ WM.delete(target);
762
+ }
763
+ function disconnect() {
764
+ IO.disconnect();
765
+ }
766
+ return {
767
+ observe,
768
+ unobserve,
769
+ disconnect,
770
+ };
771
+ }
772
+ function useResizeObserver() {
773
+ const WM = new WeakMap();
774
+ const IO = new ResizeObserver((entries) => {
775
+ entries.map((entry) => {
776
+ const callback = WM.get(entry.target);
777
+ callback?.(entry.target);
778
+ });
779
+ });
780
+ function observe(target, callback) {
781
+ if (WM.get(target))
782
+ return;
783
+ target && IO.observe(target);
784
+ WM.set(target, callback);
785
+ }
786
+ function unobserve(target) {
787
+ target && IO.unobserve(target);
788
+ WM.delete(target);
789
+ }
790
+ function disconnect() {
791
+ IO.disconnect();
792
+ }
793
+ return {
794
+ observe,
795
+ unobserve,
796
+ disconnect,
797
+ };
798
+ }
799
+
800
+ function Resize(props) {
801
+ const { index, onWidthChange } = props;
802
+ const state = useReactive({
803
+ resizing: false,
804
+ x: 0,
805
+ width: 0,
806
+ });
807
+ const handleMouseDown = (e) => {
808
+ const tar = e.target;
809
+ const width = tar.offsetParent.offsetWidth;
810
+ Object.assign(state, {
811
+ x: e.pageX,
812
+ resizing: true,
813
+ width,
814
+ });
815
+ };
816
+ const handleMouseMove = (e) => {
817
+ if (!state.resizing)
818
+ return;
819
+ e.preventDefault();
820
+ const after = state.width + e.pageX - state.x;
821
+ if (after <= 24)
822
+ return;
823
+ onWidthChange(index, after);
824
+ };
825
+ const handleMouseUp = () => {
826
+ if (!state.resizing)
827
+ return;
828
+ state.resizing = false;
829
+ };
830
+ useMouseMove(handleMouseMove);
831
+ useMouseUp(handleMouseUp);
832
+ return (jsx("i", { className: 'i-datagrid-resizor', onMouseDown: handleMouseDown, onClick: (e) => e.stopPropagation() }));
833
+ }
834
+
835
+ const Arrow = (props) => (jsx("svg", { xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 24 24', ...props, children: jsx("g", { fill: 'none', children: jsx("path", { d: 'M9 17.898c0 1.074 1.265 1.648 2.073.941l6.31-5.522a1.75 1.75 0 0 0 0-2.634l-6.31-5.522C10.265 4.454 9 5.028 9 6.102v11.796z', fill: 'currentColor' }) }) }));
836
+ function Sorter(props) {
837
+ const { type } = props;
838
+ return (jsxs("a", { className: classNames("i-datagrid-sorter", {
839
+ [`i-datagrid-sorter-${type}`]: type,
840
+ }), children: [jsx(Arrow, { className: 'i-datagrid-sorter-caret' }), jsx(Arrow, { className: 'i-datagrid-sorter-caret' })] }));
841
+ }
842
+
843
+ function Row(props) {
844
+ const { row, data, columns, cellEllipsis, onRowClick, onCellClick, onCellDoubleClick, } = props;
845
+ return (jsx("div", { className: 'i-datagrid-row', onClick: () => onRowClick?.(data, row), children: columns.map((col, i) => (jsx(Cell, { column: col, col: i, row: row, data: data, cellEllipsis: cellEllipsis, onCellClick: onCellClick, onCellDoubleClick: onCellDoubleClick }, i))) }));
846
+ }
847
+ function Header$1(props) {
848
+ const { columns, resizable, cellEllipsis, sortBy, sortType, onWidthChange, onHeaderClick, } = props;
849
+ return (jsx("div", { className: 'i-datagrid-header i-datagrid-row', children: columns.map((column, col) => {
850
+ const { id, title, fixed, colSpan, sorter, justify, renderHeader, } = column;
851
+ const style = getCellStyle({
852
+ justify,
853
+ row: 0,
854
+ col,
855
+ colSpan,
856
+ });
857
+ const order = sortBy === id ? sortType : "";
858
+ return (jsxs("div", { "data-col": id, className: classNames("i-datagrid-cell", {
859
+ "i-datagrid-has-sorter": sorter,
860
+ "i-datagrid-cell-fixed": fixed,
861
+ }), style: { ...style, insetBlockStart: 0 }, onClick: (e) => onHeaderClick?.(column, e), children: [renderHeader?.(column, col) ?? (jsx("div", { className: classNames("i-datagrid-cell-content", {
862
+ "i-datagrid-cell-content-ellipsis": cellEllipsis,
863
+ }), children: title || id })), sorter && jsx(Sorter, { type: order }), resizable && (jsx(Resize, { index: col, onWidthChange: onWidthChange }))] }, col));
864
+ }) }));
865
+ }
866
+
867
+ const Datagrid = (props) => {
868
+ const { data = [], columns = [], border, striped, header = true, resizable, cellPadding = ".5em", cellEllipsis, empty = jsx(Empty, {}), loading, height = "unset", style, className, renderLoading = () => jsx(Loading, { size: '1.5em', className: 'color-3' }), onCellClick, onRowClick, onHeaderClick, onSort, onScroll, onResize, } = props;
869
+ const container = useRef(null);
870
+ const state = useReactive({
871
+ rows: data,
872
+ widths: columns.map((col) => col.width ?? "min-content"),
873
+ sortBy: "",
874
+ sortType: "",
875
+ });
876
+ const styles = useMemo(() => {
877
+ const { widths } = state;
878
+ const o = {
879
+ ...style,
880
+ "--grid-template-columns": widths
881
+ .map((w) => {
882
+ return typeof w === "number" ? `${w}px` : w;
883
+ })
884
+ .join(" "),
885
+ };
886
+ if (!resizable)
887
+ return o;
888
+ const fws = columns.map((col, i) => {
889
+ const { fixed } = col;
890
+ if (!fixed)
891
+ return 0;
892
+ return widths[i];
893
+ });
894
+ columns.map((col, i) => {
895
+ const { fixed } = col;
896
+ if (!fixed)
897
+ return;
898
+ if (i === 0) {
899
+ o[`--datagrid-cell-inset-0`] = 0;
900
+ }
901
+ else if (i === fws.length - 1) {
902
+ o[`--datagrid-cell-inset-${fws.length - 1}`] = "auto 0";
903
+ }
904
+ else {
905
+ const isLeft = fixed === "left";
906
+ const before = isLeft ? fws.slice(0, i) : fws.slice(i + 1);
907
+ const sum = before.reduce((pre, cur) => pre + cur) + "px";
908
+ const result = isLeft ? `${sum} auto` : `auto ${sum}`;
909
+ o[`--datagrid-cell-inset-${i}`] = result;
910
+ }
911
+ });
912
+ return o;
913
+ }, [state.widths, resizable]);
914
+ const handleWidthChange = (i, w) => {
915
+ if (!resizable)
916
+ return;
917
+ const [...ws] = state.widths;
918
+ ws[i] = w;
919
+ state.widths = ws;
920
+ onResize?.(columns[i], w);
921
+ };
922
+ const handleHeaderClick = (column, e) => {
923
+ if (column?.sorter) {
924
+ const [sortBy, sortType] = getNextSorter(state.sortBy, state.sortType, column.id);
925
+ Object.assign(state, {
926
+ sortBy,
927
+ sortType,
928
+ });
929
+ onSort?.(sortBy, sortType);
930
+ }
931
+ onHeaderClick?.(column, e);
932
+ };
933
+ const rows = useMemo(() => {
934
+ const { sortBy, sortType } = state;
935
+ if (sortBy && !onSort) {
936
+ const sorter = columns.find((col) => col.id === sortBy)?.sorter;
937
+ const sortFn = typeof sorter === "function"
938
+ ? sorter
939
+ : (a, b) => b[sortBy] - a[sortBy];
940
+ const sorted = [...data].sort(sortFn);
941
+ return sortType === "desc" ? sorted : sorted.reverse();
942
+ }
943
+ return data;
944
+ }, [data, columns, state.sortBy, state.sortType]);
945
+ useEffect(() => {
946
+ if (!container.current)
947
+ return;
948
+ const { current: div } = container;
949
+ const tds = div.querySelector(".i-datagrid-row")?.children;
950
+ if (!tds?.length)
951
+ return;
952
+ state.widths = Array.from(tds).map((node) => node.offsetWidth);
953
+ }, [columns, resizable]);
954
+ useEffect(() => {
955
+ loading && container.current?.scrollTo({ top: 0, left: 0 });
956
+ }, [loading]);
957
+ const mergedStyle = {
958
+ "--cell-padding": cellPadding,
959
+ ...styles,
960
+ };
961
+ return (jsxs("div", { style: { maxHeight: height, ...mergedStyle }, className: classNames("i-datagrid-container", className, {
962
+ "i-datagrid-bordered": border,
963
+ "i-datagrid-striped": striped,
964
+ }), children: [jsxs("div", { ref: container, className: classNames("i-datagrid", {
965
+ "i-datagrid-loading": loading,
966
+ }), onWheel: onScroll, children: [header && (jsx(Header$1, { columns: columns, resizable: resizable, sortType: state.sortType, sortBy: state.sortBy, cellEllipsis: cellEllipsis, onWidthChange: handleWidthChange, onHeaderClick: handleHeaderClick })), rows.map((row, i) => (jsx(Row, { row: i + (header ? 1 : 0), data: row, cellEllipsis: cellEllipsis, columns: columns, onCellClick: onCellClick, onRowClick: onRowClick }, i))), rows.length < 1 && empty] }), loading && renderLoading()] }));
967
+ };
968
+
969
+ const Description = (props) => {
970
+ const { data, colon, columns = 1, gap = ".5em", align, labelWidth, labelAlign, vertical, equally, style, className, } = props;
971
+ return (jsx("div", { className: classNames("i-description", className), style: {
972
+ ["--description-label-width"]: labelWidth,
973
+ gridTemplateColumns: `repeat(${columns}, ${equally ? "1fr" : "auto"})`,
974
+ gap,
975
+ textAlign: align,
976
+ ...style,
977
+ }, children: data.map((item, i) => {
978
+ const { label, value, style, hidden, rowSpan = 1, colSpan = 1, } = item;
979
+ if (hidden)
980
+ return jsx(Fragment$1, {}, i);
981
+ return (jsxs("div", { className: classNames("i-description-item", {
982
+ "i-description-item-vertical": vertical,
983
+ }), style: {
984
+ gridColumn: `span ${colSpan}`,
985
+ gridRow: `span ${rowSpan}`,
986
+ ...style,
987
+ }, children: [label && (jsxs("div", { className: 'i-description-label', style: { textAlign: labelAlign }, children: [label, colon] })), jsx("div", { className: 'i-description-value', children: value })] }, i));
988
+ }) }));
989
+ };
990
+
991
+ function Drawer(props) {
992
+ const { visible, position = "left", header, footer, backdropClosable = true, hideCloseButton, keepDOM, className, disabledEsc, children, onVisibleChange, onClose, ...restProps } = props;
993
+ const toggable = useRef(true);
994
+ const state = useReactive({
995
+ show: visible,
996
+ active: visible,
997
+ init: false,
998
+ });
999
+ useEffect(() => {
1000
+ visible ? handleShow() : handleHide();
1001
+ }, [visible]);
1002
+ const handleShow = () => {
1003
+ if (!toggable.current)
1004
+ return;
1005
+ state.show = true;
1006
+ onVisibleChange?.(true);
1007
+ toggable.current = false;
1008
+ setTimeout(() => {
1009
+ state.active = true;
1010
+ toggable.current = true;
1011
+ state.init = true;
1012
+ }, 24);
1013
+ };
1014
+ const handleHide = () => {
1015
+ if (!toggable.current)
1016
+ return;
1017
+ toggable.current = false;
1018
+ state.active = false;
1019
+ setTimeout(() => {
1020
+ if (!keepDOM) {
1021
+ state.show = false;
1022
+ }
1023
+ onVisibleChange?.(false);
1024
+ toggable.current = true;
1025
+ onClose?.();
1026
+ }, 240);
1027
+ };
1028
+ const handleBackdropClick = function () {
1029
+ backdropClosable && handleHide();
1030
+ };
1031
+ useKeydown((e) => {
1032
+ if (e.code !== "Escape" || !visible)
1033
+ return;
1034
+ handleHide();
1035
+ }, {
1036
+ disabled: disabledEsc,
1037
+ });
1038
+ return createPortal(state.show && (jsx("div", { className: classNames("i-backdrop-drawer", className, {
1039
+ "i-active": state.active,
1040
+ }), onClick: handleBackdropClick, ...restProps, children: jsxs("div", { className: classNames("i-drawer", `i-drawer-${position}`), onClick: (e) => e.stopPropagation(), children: [jsxs("header", { className: 'i-drawer-header', children: [header, jsx(Helpericon, { active: !hideCloseButton, className: 'i-drawer-close', onClick: handleHide })] }), jsx("div", { className: 'i-drawer-content', children: children }), jsx("div", { className: 'i-drawer-footer', children: footer })] }) })), document.body);
1041
+ }
1042
+
1043
+ const Item$4 = (props) => {
1044
+ const { ref, active, type, align, disabled, label, style, className, children, ...restProps } = props;
1045
+ return (jsxs("li", { ref: ref, className: classNames("i-list-item", className, {
1046
+ "i-list-item-active": active,
1047
+ "i-list-option": type === "option",
1048
+ disabled,
1049
+ }), style: { alignItems: align, ...style }, ...restProps, children: [label !== undefined && (jsx("span", { className: 'i-list-item-label', children: label })), children] }));
1050
+ };
1051
+
1052
+ const List$1 = (props) => {
1053
+ const { label, type, className, children, ...restProps } = props;
1054
+ return (jsx("ul", { className: classNames("i-list", className), ...restProps, children: Children.map(children, (node, i) => {
1055
+ const renderLabel = typeof label === "function" ? label(i) : label;
1056
+ const { type, props: nodeProps } = node;
1057
+ if (type === Item$4) {
1058
+ return cloneElement(node, {
1059
+ label: renderLabel,
1060
+ ...nodeProps,
1061
+ type,
1062
+ });
1063
+ }
1064
+ return node;
1065
+ }) }));
1066
+ };
1067
+ List$1.Item = Item$4;
1068
+
1069
+ const Content$1 = (props) => {
1070
+ const { ref, getContainer = (trigger) => trigger?.offsetParent ?? document.body, trigger, arrow, arrowProps = {}, className, children, ...restProps } = props;
1071
+ const arrowCSS = useMemo(() => {
1072
+ let { left, top, pos } = arrowProps;
1073
+ let transform = "";
1074
+ switch (pos) {
1075
+ case "left":
1076
+ left += 2;
1077
+ transform = `translate(-100%, -50%) rotate(180deg)`;
1078
+ break;
1079
+ case "right":
1080
+ left -= 2;
1081
+ transform = `translate(0, -50%)`;
1082
+ break;
1083
+ case "top":
1084
+ top -= 2;
1085
+ transform = `translate(-50%, -50%) rotate(-90deg)`;
1086
+ break;
1087
+ case "bottom":
1088
+ top += 2;
1089
+ transform = `translate(-50%, -50%) rotate(90deg)`;
1090
+ break;
1091
+ }
1092
+ return {
1093
+ left,
1094
+ top,
1095
+ transform,
1096
+ };
1097
+ }, [arrowProps]);
1098
+ const content = (jsxs("div", { ref: ref, className: classNames("i-popup", className), ...restProps, children: [arrow && (jsx("svg", { xmlns: 'http://www.w3.org/2000/svg', className: 'i-popup-arrow', style: arrowCSS, children: jsx("path", { d: 'M0.5 0L1.5 0C1.5 4, 3 5.5, 5 7.5S8,10 8,12S7 14.5, 5 16.5S1.5,20 1.5,24L0.5 24L0.5 0z' }) })), children] }));
1099
+ return createPortal(content, getContainer(trigger));
1100
+ };
1101
+
1102
+ function Popup(props) {
1103
+ const { visible = false, content, trigger = "hover", gap = 12, offset = 8, fixed, position = "top", showDelay = 16, hideDelay = 12, touchable, arrow = true, align, fitSize, watchResize, clickOutside = true, disabled, referToWindow, style, className, getContainer, children, onVisibleChange, } = props;
1104
+ const triggerRef = useRef(null);
1105
+ const contentRef = useRef(null);
1106
+ const timerRef = useRef(null);
1107
+ const statusRef = useRef("");
1108
+ const state = useReactive({
1109
+ show: false,
1110
+ style: { position: fixed ? "fixed" : "absolute" },
1111
+ arrowProps: {},
1112
+ });
1113
+ useMouseUp((e) => {
1114
+ if (!triggerRef.current || !contentRef.current || !clickOutside)
1115
+ return;
1116
+ const tar = e.target;
1117
+ const isContain = triggerRef.current.contains(tar) ||
1118
+ contentRef.current.contains(tar);
1119
+ if (!state.show || isContain)
1120
+ return;
1121
+ handleToggle(false);
1122
+ });
1123
+ const clearTimer = () => {
1124
+ if (!timerRef.current)
1125
+ return;
1126
+ clearTimeout(timerRef.current);
1127
+ timerRef.current = null;
1128
+ };
1129
+ const handleShow = () => {
1130
+ if (disabled)
1131
+ return;
1132
+ if (state.show &&
1133
+ (trigger !== "hover" || (trigger === "hover" && !touchable))) {
1134
+ return;
1135
+ }
1136
+ state.show = true;
1137
+ statusRef.current = "showing";
1138
+ timerRef.current = setTimeout(() => {
1139
+ if (statusRef.current !== "showing") {
1140
+ return;
1141
+ }
1142
+ const [left, top, { arrowX, arrowY, arrowPos }] = getPosition(triggerRef.current, contentRef.current, {
1143
+ position,
1144
+ gap,
1145
+ offset,
1146
+ align,
1147
+ refWindow: referToWindow,
1148
+ });
1149
+ state.style = {
1150
+ ...state.style,
1151
+ opacity: 1,
1152
+ transform: "none",
1153
+ left,
1154
+ top,
1155
+ };
1156
+ state.arrowProps = {
1157
+ left: arrowX,
1158
+ top: arrowY,
1159
+ pos: arrowPos,
1160
+ };
1161
+ onVisibleChange?.(true);
1162
+ clearTimer();
1163
+ statusRef.current = "";
1164
+ }, showDelay);
1165
+ };
1166
+ const handleHide = () => {
1167
+ if (!state.show)
1168
+ return;
1169
+ statusRef.current = "hiding";
1170
+ timerRef.current = setTimeout(() => {
1171
+ if (statusRef.current !== "hiding") {
1172
+ clearTimer();
1173
+ return;
1174
+ }
1175
+ state.style = {
1176
+ ...state.style,
1177
+ opacity: 0,
1178
+ transform: "translate(0, 2px)",
1179
+ };
1180
+ setTimeout(() => {
1181
+ state.show = false;
1182
+ clearTimer();
1183
+ onVisibleChange?.(false);
1184
+ statusRef.current = "";
1185
+ }, 160);
1186
+ }, hideDelay);
1187
+ };
1188
+ const handleToggle = (action) => {
1189
+ if (action !== undefined) {
1190
+ action ? handleShow() : handleHide();
1191
+ return;
1192
+ }
1193
+ state.show ? handleHide() : handleShow();
1194
+ };
1195
+ const eventMaps = useCreation(() => ({
1196
+ click: {
1197
+ onClick: () => handleToggle(true),
1198
+ },
1199
+ hover: {
1200
+ onMouseEnter: () => handleToggle(true),
1201
+ onMouseLeave: () => handleToggle(false),
1202
+ },
1203
+ focus: {
1204
+ onFocus: () => handleToggle(true),
1205
+ onBlur: () => handleToggle(false),
1206
+ },
1207
+ contextmenu: {
1208
+ onContextMenu: (e) => {
1209
+ e.preventDefault();
1210
+ e.stopPropagation();
1211
+ if (state.show) {
1212
+ const [left, top] = getPointPosition(e, contentRef.current);
1213
+ state.style = {
1214
+ ...state.style,
1215
+ left,
1216
+ top,
1217
+ };
1218
+ return;
1219
+ }
1220
+ state.show = true;
1221
+ timerRef.current = setTimeout(() => {
1222
+ const [left, top] = getPointPosition(e, contentRef.current);
1223
+ state.style = {
1224
+ ...state.style,
1225
+ opacity: 1,
1226
+ transform: "none",
1227
+ left,
1228
+ top,
1229
+ };
1230
+ clearTimer();
1231
+ onVisibleChange?.(true);
1232
+ }, showDelay);
1233
+ },
1234
+ },
1235
+ none: {},
1236
+ }), []);
1237
+ const contentTouch = useMemo(() => {
1238
+ if (!touchable)
1239
+ return {};
1240
+ const events = {};
1241
+ if (trigger === "hover") {
1242
+ events["onMouseEnter"] = () => {
1243
+ clearTimer();
1244
+ };
1245
+ events["onMouseLeave"] = () => handleToggle(false);
1246
+ }
1247
+ return events;
1248
+ }, [touchable, trigger]);
1249
+ const computePosition = () => {
1250
+ if (!state.show)
1251
+ return;
1252
+ const [left, top, { arrowX, arrowY, arrowPos }] = getPosition(triggerRef.current, contentRef.current, {
1253
+ position,
1254
+ gap,
1255
+ offset,
1256
+ align,
1257
+ refWindow: referToWindow,
1258
+ });
1259
+ Object.assign(state, {
1260
+ style: { ...state.style, left, top },
1261
+ arrowProps: { left: arrowX, top: arrowY, pos: arrowPos },
1262
+ });
1263
+ };
1264
+ useEffect(() => {
1265
+ if (trigger === "contextmenu")
1266
+ return;
1267
+ const { observe, unobserve, disconnect } = useResizeObserver();
1268
+ triggerRef.current && observe(triggerRef.current, computePosition);
1269
+ if (!watchResize || !contentRef.current)
1270
+ return;
1271
+ observe(contentRef.current, computePosition);
1272
+ return () => {
1273
+ if (!watchResize || !contentRef.current)
1274
+ return;
1275
+ unobserve(contentRef.current);
1276
+ triggerRef.current && unobserve(triggerRef.current);
1277
+ disconnect();
1278
+ };
1279
+ }, [watchResize, contentRef.current, triggerRef.current]);
1280
+ useLayoutEffect(() => {
1281
+ if (!fitSize || !state.show)
1282
+ return;
1283
+ const vertical = ["top", "bottom"].includes(position);
1284
+ const size = triggerRef.current?.[vertical ? "offsetWidth" : "offsetHeight"];
1285
+ state.style = { ...state.style, [vertical ? "width" : "height"]: size };
1286
+ }, [state.show, fitSize]);
1287
+ useLayoutEffect(() => {
1288
+ handleToggle(visible);
1289
+ }, [visible]);
1290
+ return (jsxs(Fragment, { children: [Children.map(children, (child) => {
1291
+ if (!isValidElement(child))
1292
+ return;
1293
+ const { className, ...restProps } = child.props;
1294
+ Object.keys(eventMaps[trigger]).map((evt) => {
1295
+ if (!restProps[evt])
1296
+ return;
1297
+ const fn = eventMaps[trigger][evt];
1298
+ eventMaps[trigger][evt] = (e) => {
1299
+ fn();
1300
+ restProps[evt](e);
1301
+ };
1302
+ });
1303
+ return cloneElement(child, {
1304
+ ref: triggerRef,
1305
+ className,
1306
+ ...restProps,
1307
+ ...eventMaps[trigger],
1308
+ });
1309
+ }), state.show && (jsx(Content$1, { ref: contentRef, arrow: arrow && trigger !== "contextmenu", style: { ...style, ...state.style }, arrowProps: state.arrowProps, className: className, ...contentTouch, trigger: triggerRef.current, getContainer: getContainer, children: content }))] }));
1310
+ }
1311
+
1312
+ const { Item: ListItem } = List$1;
1313
+ const Item$3 = (props) => {
1314
+ const { more, moreProps, onClick, ...restProps } = props;
1315
+ const Li = (jsx(ListItem, { onClick: (e) => {
1316
+ e.stopPropagation();
1317
+ onClick?.(e);
1318
+ }, ...restProps }));
1319
+ if (!more)
1320
+ return Li;
1321
+ return (jsx(Popup, { position: 'right', touchable: true, arrow: false, align: 'start', offset: 10, hideDelay: 240, ...moreProps, content: jsx(List$1, { className: 'i-dropdown-content', onClick: (e) => e.stopPropagation(), children: more }), children: Li }));
1322
+ };
1323
+
1324
+ const Dropdown = (props) => {
1325
+ const { width, content, children, ...restProps } = props;
1326
+ return (jsx(Popup, { trigger: 'click', position: 'bottom', touchable: true, content: jsx(List$1, { className: 'i-dropdown-content', style: { minWidth: width }, children: content }), ...restProps, children: children }));
1327
+ };
1328
+ Dropdown.Item = Item$3;
1329
+
1330
+ const exec = (a, b, c) => document.execCommand(a, b, c);
1331
+ const xssOptions = {
1332
+ onIgnoreTagAttr: function (tag, name, value) {
1333
+ if (["data-", "style"].includes(name.substr(0, 5))) {
1334
+ return name + '="' + escapeAttrValue(value) + '"';
1335
+ }
1336
+ },
1337
+ };
1338
+ const fnMap = {
1339
+ bold: {
1340
+ icon: jsx(FormatBoldRound, {}),
1341
+ onClick: () => exec("bold"),
1342
+ tip: "粗体",
1343
+ },
1344
+ italic: {
1345
+ icon: jsx(FormatItalicRound, {}),
1346
+ onClick: () => exec("italic"),
1347
+ tip: "斜体",
1348
+ },
1349
+ underline: {
1350
+ icon: jsx(FormatUnderlinedRound, {}),
1351
+ onClick: () => exec("underline"),
1352
+ tip: "下划线",
1353
+ },
1354
+ strike: {
1355
+ icon: jsx(StrikethroughSRound, {}),
1356
+ onClick: () => exec("strikeThrough"),
1357
+ tip: "删除线",
1358
+ },
1359
+ redo: {
1360
+ icon: jsx(RedoRound, {}),
1361
+ onClick: () => exec("redo"),
1362
+ tip: "重做",
1363
+ },
1364
+ undo: {
1365
+ icon: jsx(UndoRound, {}),
1366
+ onClick: () => exec("undo"),
1367
+ tip: "撤销",
1368
+ },
1369
+ // color: {
1370
+ // icon: <FormatColorTextRound />,
1371
+ // onClick: () => exec("foreColor", false, ""),
1372
+ // },
1373
+ // backColor: {
1374
+ // icon: <FormatColorFillRound />,
1375
+ // onClick: () => exec("backColor", false, ""),
1376
+ // },
1377
+ clear: {
1378
+ icon: jsx(ClearAllRound, {}),
1379
+ onClick: () => exec("removeFormat"),
1380
+ tip: "清除格式",
1381
+ },
1382
+ };
1383
+ const aliasMap = {
1384
+ simple: ["undo", "redo", "bold", "italic", "underline", "strike", "clear"],
1385
+ all: Object.keys(fnMap),
1386
+ };
1387
+ function getControls(fns, options) {
1388
+ const { controlBtnProps } = options;
1389
+ const keys = typeof fns === "string" ? aliasMap[fns] : fns;
1390
+ return keys.map((k) => {
1391
+ if (fnMap[k]) {
1392
+ const { icon, render, tip, onClick } = fnMap[k];
1393
+ if (render) {
1394
+ return render(options);
1395
+ }
1396
+ return (jsxs(Button, { ...controlBtnProps, onClick: onClick, children: [jsx(Icon, { icon: icon }), tip && jsx("span", { className: 'i-editor-control-tip', children: tip })] }, k));
1397
+ }
1398
+ return jsx(Fragment, {}, k);
1399
+ });
1400
+ }
1401
+
1402
+ const Editor = (props) => {
1403
+ const { ref, width, height = "10em", placeholder, autosize, border = true, richPaste, controls = "simple", className, style, onInput, onPaste, onKeyDown, ...restProps } = props;
1404
+ const editorRef = useRef(null);
1405
+ const controlBtnProps = {
1406
+ square: true,
1407
+ flat: true,
1408
+ size: "small",
1409
+ };
1410
+ const handlePaste = async (e) => {
1411
+ onPaste?.(e);
1412
+ if (richPaste)
1413
+ return;
1414
+ e.preventDefault();
1415
+ const text = e.clipboardData.getData("text/plain");
1416
+ exec("insertText", false, text);
1417
+ };
1418
+ const handleKeyDown = (e) => {
1419
+ onKeyDown?.(e);
1420
+ switch (e.key) {
1421
+ case "Tab":
1422
+ e.preventDefault();
1423
+ exec("insertHTML", false, "&#09;");
1424
+ break;
1425
+ case "Enter":
1426
+ e.preventDefault();
1427
+ exec("insertLineBreak");
1428
+ if (!editorRef.current)
1429
+ return;
1430
+ editorRef.current.scrollBy({
1431
+ top: 20,
1432
+ left: -1e3,
1433
+ });
1434
+ if (!autosize)
1435
+ return;
1436
+ editorRef.current.style.height = `${editorRef.current.scrollHeight}px`;
1437
+ break;
1438
+ }
1439
+ };
1440
+ useImperativeHandle(ref, () => {
1441
+ return {
1442
+ setValue(html) {
1443
+ if (!editorRef.current)
1444
+ return;
1445
+ const safeHtml = xss(html, xssOptions);
1446
+ editorRef.current.innerHTML = safeHtml;
1447
+ },
1448
+ getSafeValue() {
1449
+ const html = editorRef.current?.innerHTML ?? "";
1450
+ return xss(html, xssOptions);
1451
+ },
1452
+ };
1453
+ });
1454
+ const handleInput = (e) => {
1455
+ let html = editorRef.current?.innerHTML ?? "";
1456
+ if (["<br>", "\n"].includes(html) && editorRef.current) {
1457
+ html = "";
1458
+ editorRef.current.innerHTML = html;
1459
+ }
1460
+ onInput?.(html, e);
1461
+ };
1462
+ return (jsxs("div", { className: classNames("i-editor", className, {
1463
+ "i-editor-borderless": !border,
1464
+ }), style: {
1465
+ ...style,
1466
+ [autosize ? "minHeight" : "height"]: height,
1467
+ width,
1468
+ }, children: [controls !== "none" && (jsx("div", { className: 'i-editor-controls', children: getControls(controls, {
1469
+ controlBtnProps,
1470
+ }) })), jsx("div", { ref: editorRef, className: 'i-editor-content', "data-placeholder": placeholder, contentEditable: true, onPaste: handlePaste, onInput: handleInput, onKeyDown: handleKeyDown, ...restProps })] }));
1471
+ };
1472
+
1473
+ const Flex = (props) => {
1474
+ const { as: Component = "div", align, justify, direction, wrap, gap, columns, className, style, ...restProps } = props;
1475
+ const gridColumns = useMemo(() => {
1476
+ if (!columns)
1477
+ return;
1478
+ if (typeof columns === "number")
1479
+ return `repeat(${columns}, 1fr)`;
1480
+ return columns;
1481
+ }, [columns]);
1482
+ return (jsx(Component, { ...restProps, style: {
1483
+ alignItems: align,
1484
+ justifyContent: justify,
1485
+ gap,
1486
+ flexDirection: direction,
1487
+ flexWrap: wrap === true ? "wrap" : wrap,
1488
+ gridTemplateColumns: gridColumns,
1489
+ ...style,
1490
+ }, className: classNames(className, {
1491
+ [columns ? "grid" : "flex"]: true,
1492
+ }) }));
1493
+ };
1494
+
1495
+ const Context = createContext({});
1496
+
1497
+ function Field(props) {
1498
+ const { name, required, children } = props;
1499
+ const state = useReactive({
1500
+ value: undefined,
1501
+ status: "normal",
1502
+ message: undefined,
1503
+ update: 0,
1504
+ });
1505
+ const form = useContext(Context);
1506
+ const { id } = form;
1507
+ const handleChange = (v) => {
1508
+ if (!name)
1509
+ return;
1510
+ form.set(name, v);
1511
+ PubSub.publish(`${id}:change`, {
1512
+ name,
1513
+ value: v,
1514
+ });
1515
+ };
1516
+ const hijackChildren = useMemo(() => {
1517
+ return Children.map(children, (node) => {
1518
+ if (!isValidElement(node))
1519
+ return null;
1520
+ const { onChange } = node.props;
1521
+ const { value, status, message } = state;
1522
+ return cloneElement(node, {
1523
+ value,
1524
+ status,
1525
+ message,
1526
+ required,
1527
+ onChange: (...args) => {
1528
+ handleChange(args[0]);
1529
+ onChange?.(...args);
1530
+ Object.assign(state, {
1531
+ status: "normal",
1532
+ message: undefined,
1533
+ });
1534
+ },
1535
+ });
1536
+ });
1537
+ }, [children, state.update]);
1538
+ useEffect(() => {
1539
+ if (!name)
1540
+ return;
1541
+ PubSub.subscribe(`${id}:set:${name}`, (evt, v) => {
1542
+ state.value = v;
1543
+ state.update += 1;
1544
+ });
1545
+ PubSub.subscribe(`${id}:invalid:${name}`, (evt, v) => {
1546
+ Object.assign(state, v);
1547
+ state.update += 1;
1548
+ });
1549
+ Promise.resolve().then(() => {
1550
+ form.set(name, form.cacheData[name] ?? undefined);
1551
+ });
1552
+ return () => {
1553
+ PubSub.unsubscribe(`${id}:set:${name}`);
1554
+ PubSub.unsubscribe(`${id}:invalid:${name}`);
1555
+ form.delete(name);
1556
+ };
1557
+ }, [name, children]);
1558
+ if (!name)
1559
+ return children;
1560
+ return hijackChildren;
1561
+ }
1562
+
1563
+ class IFormInstance {
1564
+ id;
1565
+ data = {};
1566
+ cacheData = {};
1567
+ rules = {};
1568
+ constructor() {
1569
+ this.id = uid(8);
1570
+ this.data = {};
1571
+ }
1572
+ get(field) {
1573
+ return field ? this.data[field] : this.data;
1574
+ }
1575
+ set(field, value) {
1576
+ const id = this.id;
1577
+ if (!this.data)
1578
+ return;
1579
+ if (typeof field === "string") {
1580
+ this.data[field] = value;
1581
+ this.cacheData[field] = value;
1582
+ PubSub.publish(`${id}:set:${field}`, value);
1583
+ return;
1584
+ }
1585
+ Object.keys(field).map((name) => {
1586
+ this.data[name] = field[name];
1587
+ this.cacheData[name] = field[name];
1588
+ PubSub.publish(`${id}:set:${name}`, field[name]);
1589
+ });
1590
+ }
1591
+ delete(field) {
1592
+ delete this.data[field];
1593
+ }
1594
+ clear() {
1595
+ if (!this.data)
1596
+ return;
1597
+ this.cacheData = {};
1598
+ Object.keys(this.data).map((name) => {
1599
+ PubSub.publish(`${this.id}:set:${name}`, undefined);
1600
+ this.data[name] = undefined;
1601
+ });
1602
+ }
1603
+ async validate(field) {
1604
+ const { id, rules, data } = this;
1605
+ if (!rules)
1606
+ return data;
1607
+ if (field) {
1608
+ const o = rules[field];
1609
+ const rule = {
1610
+ validator: (v) => Array.isArray(v)
1611
+ ? v.length > 0
1612
+ : ![undefined, null, ""].includes(v),
1613
+ message: undefined,
1614
+ };
1615
+ if (typeof o === "function") {
1616
+ rule.validator = o;
1617
+ }
1618
+ else if (o === true) {
1619
+ rule.message = "required";
1620
+ }
1621
+ else {
1622
+ Object.assign(rule, o);
1623
+ }
1624
+ const isValid = rule.validator?.(data[field], this);
1625
+ if (!isValid) {
1626
+ PubSub.publish(`${id}:invalid:${field}`, {
1627
+ message: rule.message,
1628
+ status: "error",
1629
+ });
1630
+ return false;
1631
+ }
1632
+ PubSub.publish(`${id}:invalid:${name}`, {
1633
+ message: null,
1634
+ status: "normal",
1635
+ });
1636
+ return true;
1637
+ }
1638
+ let isAllValid = true;
1639
+ Object.keys(data).map((name) => {
1640
+ const o = rules[name];
1641
+ if (o === undefined)
1642
+ return;
1643
+ const rule = {
1644
+ validator: (v) => (Array.isArray(v) ? v.length > 0 : !!v),
1645
+ message: undefined,
1646
+ };
1647
+ if (typeof o === "function") {
1648
+ rule.validator = o;
1649
+ }
1650
+ else if (o === true) {
1651
+ rule.message = "required";
1652
+ }
1653
+ else {
1654
+ Object.assign(rule, o);
1655
+ }
1656
+ const isValid = rule.validator?.(data[name], this);
1657
+ if (!isValid) {
1658
+ PubSub.publish(`${id}:invalid:${name}`, {
1659
+ message: rule.message,
1660
+ status: "error",
1661
+ });
1662
+ isAllValid = false;
1663
+ }
1664
+ else {
1665
+ PubSub.publish(`${id}:invalid:${name}`, {
1666
+ message: null,
1667
+ status: "normal",
1668
+ });
1669
+ }
1670
+ });
1671
+ return isAllValid ? Promise.resolve(data) : false;
1672
+ }
1673
+ }
1674
+ function useForm(form) {
1675
+ const formRef = useRef(null);
1676
+ if (!formRef.current) {
1677
+ formRef.current = form ?? new IFormInstance();
1678
+ }
1679
+ return formRef.current;
1680
+ }
1681
+
1682
+ const Form = (props) => {
1683
+ const { form = {}, rules, initialValues, style, className, width, columns = 1, gap = "1em", labelInline, labelWidth, labelRight, children, onKeyDown, onEnter, onChange, ...restProps } = props;
1684
+ const handleKeyDown = (e) => {
1685
+ onKeyDown?.(e);
1686
+ if (e.keyCode !== 13)
1687
+ return;
1688
+ onEnter?.(form.data, form);
1689
+ };
1690
+ const gridColumns = useMemo(() => {
1691
+ if (!columns)
1692
+ return;
1693
+ if (typeof columns === "number")
1694
+ return `minmax(0, 1fr) `.repeat(columns);
1695
+ return columns;
1696
+ }, [columns]);
1697
+ useEffect(() => {
1698
+ Object.assign(form, {
1699
+ data: { ...initialValues },
1700
+ rules,
1701
+ });
1702
+ }, [form]);
1703
+ useEffect(() => {
1704
+ PubSub.subscribe(`${form.id}:change`, (evt, v) => {
1705
+ onChange?.(v.name, v.value);
1706
+ });
1707
+ return () => {
1708
+ PubSub.unsubscribe(`${form.id}:change`);
1709
+ };
1710
+ }, []);
1711
+ return (jsx(Context, { value: form, children: jsx("form", { style: {
1712
+ ...style,
1713
+ width,
1714
+ gap,
1715
+ gridTemplateColumns: gridColumns,
1716
+ "--label-width": labelWidth,
1717
+ "--label-align": labelRight ? "right" : undefined,
1718
+ }, className: classNames("i-form", className, {
1719
+ "i-form-inline": labelInline,
1720
+ }), onKeyDown: handleKeyDown, ...restProps, children: children }) }));
1721
+ };
1722
+ Form.useForm = useForm;
1723
+ Form.Field = Field;
1724
+
1725
+ function DefaultContent(props) {
1726
+ const { title, footer, hideCloseButton, footerLeft, okButtonProps, cancelButtonProps, children, onOk, onClose, } = props;
1727
+ const showHeader = title || !hideCloseButton;
1728
+ const handleOk = async () => {
1729
+ const ret = await onOk?.();
1730
+ if (ret)
1731
+ return;
1732
+ onClose?.();
1733
+ };
1734
+ const renderFooter = useMemo(() => {
1735
+ if (footer || footer === null)
1736
+ return footer;
1737
+ const propsOk = Object.assign({
1738
+ children: "确定",
1739
+ onClick: handleOk,
1740
+ }, okButtonProps);
1741
+ const propsCancel = Object.assign({
1742
+ secondary: true,
1743
+ children: "关闭",
1744
+ onClick: onClose,
1745
+ }, cancelButtonProps);
1746
+ return (jsxs(Fragment, { children: [footerLeft, jsx(Button, { ...propsOk }), jsx(Button, { ...propsCancel })] }));
1747
+ }, [footer, okButtonProps, cancelButtonProps]);
1748
+ return (jsxs(Fragment, { children: [showHeader && (jsxs("header", { className: 'i-modal-header', children: [title && jsx("b", { children: title }), jsx(Helpericon, { active: !hideCloseButton, className: 'i-modal-close', onClick: onClose })] })), jsx("div", { className: 'i-modal-content', children: children }), jsx("footer", { className: 'i-modal-footer', children: renderFooter })] }));
1749
+ }
1750
+ function Modal(props) {
1751
+ const { visible, title, footer, okButtonProps, cancelButtonProps, closable = true, hideBackdrop, backdropClosable = true, hideCloseButton, disableEsc, width, height, customized, fixed, hideShadow, children, style, className, keepDOM, footerLeft, onClick, onVisibleChange, onClose, onOk, ...restProps } = props;
1752
+ const [show, setShow] = useState(visible);
1753
+ const [active, setActive] = useState(false);
1754
+ const [bounced, setBounced] = useState(false);
1755
+ const toggable = useRef(true);
1756
+ const handleShow = () => {
1757
+ if (!toggable.current)
1758
+ return;
1759
+ (!keepDOM || !show) && setShow(true);
1760
+ toggable.current = false;
1761
+ setTimeout(() => {
1762
+ setActive(true);
1763
+ onVisibleChange?.(true);
1764
+ toggable.current = true;
1765
+ }, 24);
1766
+ };
1767
+ const handleHide = () => {
1768
+ if (!toggable.current)
1769
+ return;
1770
+ toggable.current = false;
1771
+ if (!closable) {
1772
+ setBounced(true);
1773
+ setTimeout(() => {
1774
+ setBounced(false);
1775
+ toggable.current = true;
1776
+ }, 400);
1777
+ return;
1778
+ }
1779
+ setActive(false);
1780
+ setTimeout(() => {
1781
+ !keepDOM && setShow(false);
1782
+ toggable.current = true;
1783
+ onVisibleChange?.(false);
1784
+ onClose?.();
1785
+ }, 240);
1786
+ };
1787
+ const handleBackdropClick = function () {
1788
+ backdropClosable && handleHide();
1789
+ };
1790
+ useKeydown((e) => {
1791
+ if (e.code !== "Escape" || !visible)
1792
+ return;
1793
+ handleHide();
1794
+ }, { disabled: disableEsc });
1795
+ useEffect(() => {
1796
+ visible ? handleShow() : handleHide();
1797
+ }, [visible]);
1798
+ if (!show)
1799
+ return null;
1800
+ return createPortal(jsx("div", { className: classNames("i-modal-container", {
1801
+ "i-modal-backdrop": !hideBackdrop,
1802
+ "i-modal-customized": customized,
1803
+ "i-modal-active": active,
1804
+ fixed,
1805
+ }, className), style: style, onClick: handleBackdropClick, children: jsxs("div", { className: classNames("i-modal", {
1806
+ bounced,
1807
+ shadow: !hideShadow,
1808
+ }), style: {
1809
+ width,
1810
+ height,
1811
+ }, onClick: (e) => {
1812
+ e.stopPropagation();
1813
+ document.documentElement.click();
1814
+ onClick?.(e);
1815
+ }, ...restProps, children: [customized && children, !customized && (jsx(DefaultContent, { title: title, hideCloseButton: hideCloseButton, footer: footer, okButtonProps: okButtonProps, cancelButtonProps: cancelButtonProps, children: children, footerLeft: footerLeft, onOk: onOk, onClose: handleHide }))] }) }), document.body);
1816
+ }
1817
+
1818
+ const HookModal = (props) => {
1819
+ const { ref } = props;
1820
+ const state = useReactive({});
1821
+ const mergedProps = Object.assign({}, props, state);
1822
+ useImperativeHandle(ref, () => ({
1823
+ update: (config = {}) => {
1824
+ Object.assign(state, config);
1825
+ },
1826
+ close: () => {
1827
+ state.visible = false;
1828
+ if (mergedProps.closable)
1829
+ return;
1830
+ Promise.resolve().then(() => {
1831
+ state.visible = true;
1832
+ });
1833
+ },
1834
+ }));
1835
+ return jsx(Modal, { ...mergedProps });
1836
+ };
1837
+
1838
+ const Text = (props) => {
1839
+ const { as: Tag = "span", size, weight, decoration, gradient, wave, style, className, children, } = props;
1840
+ const gradients = useMemo(() => {
1841
+ if (!gradient || !Array.isArray(gradient))
1842
+ return {};
1843
+ return {
1844
+ backgroundImage: `-webkit-linear-gradient(${gradient.join(",")})`,
1845
+ backgroundClip: "text",
1846
+ };
1847
+ }, [gradient]);
1848
+ return (jsx(Tag, { style: {
1849
+ fontSize: size,
1850
+ fontWeight: weight,
1851
+ textDecoration: decoration,
1852
+ ...gradients,
1853
+ ...style,
1854
+ }, className: classNames(className, {
1855
+ "i-text-gradient": gradient,
1856
+ "i-text-gradient-wave": wave,
1857
+ }), children: children }));
1858
+ };
1859
+
1860
+ function HighLight(props) {
1861
+ const { keyword, text, escape, caseSensitive, renderWord = (word) => jsx("mark", { children: word }), ...restProps } = props;
1862
+ const content = useMemo(() => {
1863
+ const source = text;
1864
+ const searchWords = typeof keyword === "string" ? [keyword] : keyword;
1865
+ const chunks = findAll({
1866
+ searchWords,
1867
+ textToHighlight: text,
1868
+ caseSensitive,
1869
+ autoEscape: escape,
1870
+ });
1871
+ const result = chunks.map((chunk, i) => {
1872
+ const { end, highlight, start } = chunk;
1873
+ const word = source.slice(start, end);
1874
+ return highlight ? (jsx(Fragment$1, { children: renderWord(word) }, i)) : (word);
1875
+ });
1876
+ return result;
1877
+ }, [keyword, text, escape, caseSensitive]);
1878
+ return jsx(Text, { ...restProps, children: content });
1879
+ }
1880
+
1881
+ function Number$2(props) {
1882
+ const { count, to, decimal, thousand = ",", duration = 2400, easing, ...restProps } = props;
1883
+ const [n, setN] = useState(count);
1884
+ const number = useMemo(() => {
1885
+ if (n === undefined)
1886
+ return;
1887
+ const z = n.toFixed(decimal);
1888
+ if (!thousand)
1889
+ return z;
1890
+ return formatNumber(n, { precision: decimal, thousand });
1891
+ }, [n, thousand]);
1892
+ useEffect(() => {
1893
+ if (count === undefined || to === undefined)
1894
+ return;
1895
+ animate(count, to, duration, (v) => setN(count + v), easing);
1896
+ }, [to]);
1897
+ useEffect(() => setN(count), [count]);
1898
+ return jsx(Text, { ...restProps, children: number });
1899
+ }
1900
+
1901
+ function Number$1(props) {
1902
+ const { seconds, zero, units, ...restProps } = props;
1903
+ const text = useMemo(() => {
1904
+ if (seconds === undefined)
1905
+ return "";
1906
+ return formatTime(seconds, {
1907
+ zero,
1908
+ units,
1909
+ });
1910
+ }, [seconds]);
1911
+ return jsx(Text, { ...restProps, children: text });
1912
+ }
1913
+
1914
+ Text.Number = Number$2;
1915
+ Text.Time = Number$1;
1916
+ Text.HighLight = HighLight;
1917
+
1918
+ function Circle(props) {
1919
+ const { value, circleSize = 40, lineWidth = 8 } = props;
1920
+ return (jsxs("div", { className: 'i-progress-circle', children: [jsxs("svg", { width: circleSize, height: circleSize, children: [jsx("circle", { cx: circleSize / 2, cy: circleSize / 2, r: circleSize / 2 - lineWidth / 2, fill: 'none', stroke: 'var(--background-opacity-2)', strokeWidth: lineWidth }), jsx("circle", { cx: circleSize / 2, cy: circleSize / 2, r: circleSize / 2 - lineWidth / 2, fill: 'none', stroke: 'var(--color-main)', strokeWidth: lineWidth, strokeDasharray: 100, pathLength: 100, className: 'i-progress-circle-path', strokeLinecap: 'round', style: {
1921
+ strokeDashoffset: `calc(100 - ${value})`,
1922
+ } })] }), jsxs("span", { className: 'i-progress-circle-value', children: [jsx("span", { children: value }), jsx(Text, { size: '.81em', className: 'color-7', children: "%" })] })] }));
1923
+ }
1924
+
1925
+ const Line = (props) => {
1926
+ const { ref, value, lineWidth, vertical, barClass, dragging, renderCursor, onMouseDown, onTouchStart, } = props;
1927
+ return (jsx("div", { ref: ref, className: classNames("i-progress", {
1928
+ "i-progress-vertical": vertical,
1929
+ }), style: { [vertical ? "width" : "height"]: lineWidth }, onMouseDown: onMouseDown, onTouchStart: onTouchStart, children: jsx("div", { className: classNames("i-progress-bar", barClass, {
1930
+ "no-transition": dragging,
1931
+ }), style: { [vertical ? "height" : "width"]: `${value}%` }, children: renderCursor && (jsx("a", { className: 'i-progress-cursor', children: renderCursor(value ?? 0) })) }) }));
1932
+ };
1933
+
1934
+ const Progress = (props) => {
1935
+ const { value = 0, lineWidth = 8, circleSize = 40, precision = 0, style, draggable = true, type = "line", barClass, vertical, label, labelInline, className, renderCursor, onChange, onDraggingChange, } = props;
1936
+ const ref = useRef(null);
1937
+ const state = useReactive({
1938
+ value,
1939
+ dragging: false,
1940
+ size: 0,
1941
+ start: 0,
1942
+ });
1943
+ const pageXY = vertical ? "pageY" : "pageX";
1944
+ const rectTL = vertical ? "top" : "left";
1945
+ const rectWH = vertical ? "height" : "width";
1946
+ const toFixedValue = useMemo(() => {
1947
+ let value = +state.value.toFixed(precision);
1948
+ value = Math.min(100, value);
1949
+ value = Math.max(0, value);
1950
+ return value;
1951
+ }, [state.value, precision]);
1952
+ const handleMouseDown = (e) => {
1953
+ if (!ref.current || !draggable)
1954
+ return;
1955
+ if (e.touches) {
1956
+ e = e.touches[0];
1957
+ }
1958
+ const rect = ref.current.getBoundingClientRect();
1959
+ const value = ((e[pageXY] - rect[rectTL]) * 100) / rect[rectWH];
1960
+ Object.assign(state, {
1961
+ value: vertical ? 100 - value : value,
1962
+ size: rect[rectWH],
1963
+ start: rect[rectTL],
1964
+ dragging: true,
1965
+ });
1966
+ onDraggingChange?.(true);
1967
+ };
1968
+ const handleMouseMove = (e) => {
1969
+ if (!state.dragging || !draggable)
1970
+ return;
1971
+ e.preventDefault();
1972
+ if (e.touches) {
1973
+ e = e.touches[0];
1974
+ }
1975
+ const { start, size } = state;
1976
+ const offset = e[pageXY] - start;
1977
+ if (offset < 0 || offset > size)
1978
+ return;
1979
+ const value = ((e[pageXY] - start) * 100) / size;
1980
+ state.value = vertical ? 100 - value : value;
1981
+ };
1982
+ const handleMouseUp = () => {
1983
+ if (!state.dragging || !draggable)
1984
+ return;
1985
+ onChange?.(toFixedValue);
1986
+ state.dragging = false;
1987
+ onDraggingChange?.(false);
1988
+ };
1989
+ useMouseMove(handleMouseMove);
1990
+ useMouseUp(handleMouseUp);
1991
+ useEffect(() => {
1992
+ if (value > 100) {
1993
+ state.value = 100;
1994
+ return;
1995
+ }
1996
+ if (value < 0) {
1997
+ state.value = 0;
1998
+ return;
1999
+ }
2000
+ state.value = value;
2001
+ }, [value]);
2002
+ return (jsxs("div", { className: classNames("i-input-label", className, {
2003
+ "i-input-inline": labelInline,
2004
+ }), style: style, children: [label && jsx("span", { className: 'i-input-label-text', children: label }), type === "line" && (jsx(Line, { ref: ref, vertical: vertical, lineWidth: lineWidth, barClass: barClass, dragging: state.dragging, value: state.value, renderCursor: renderCursor, onMouseDown: handleMouseDown, onTouchStart: handleMouseDown })), type === "circle" && (jsx(Circle, { value: state.value, circleSize: circleSize, lineWidth: lineWidth }))] }));
2005
+ };
2006
+
2007
+ const Video = (props) => {
2008
+ const { ref, style, hideControls, autoplay, muted, volume = 50, height, width, useOriginControls, timeProgressProps = {
2009
+ barClass: "bg-blue",
2010
+ }, volumeProgressProps = {
2011
+ barClass: "bg-blue",
2012
+ }, className, onFullScreenChange, ...restProps } = props;
2013
+ const state = useReactive({
2014
+ playing: autoplay,
2015
+ volume: muted ? 0 : volume,
2016
+ volumeCache: 0,
2017
+ muted,
2018
+ current: 0,
2019
+ duration: 0,
2020
+ isFullscreen: false,
2021
+ controlHidden: true,
2022
+ draggingProgress: false,
2023
+ });
2024
+ const videoRef = useRef(null);
2025
+ const hiddenTO = useRef(null);
2026
+ const timeUpdateListener = (e) => {
2027
+ const tar = e.target;
2028
+ if (tar.paused || state.draggingProgress)
2029
+ return;
2030
+ Object.assign(state, {
2031
+ current: tar.currentTime,
2032
+ });
2033
+ };
2034
+ const playChangeListener = (e) => {
2035
+ state.playing = !e.target.paused;
2036
+ };
2037
+ const fsChangeListener = () => {
2038
+ const tar = videoRef.current?.parentElement;
2039
+ if (!tar)
2040
+ return;
2041
+ state.isFullscreen = document.fullscreenElement === tar;
2042
+ };
2043
+ const volumeChangeListener = (e) => {
2044
+ const tar = e.target;
2045
+ Object.assign(state, {
2046
+ volume: tar.volume * 100,
2047
+ muted: tar.volume === 0,
2048
+ });
2049
+ };
2050
+ const handlePlay = () => {
2051
+ const v = videoRef.current;
2052
+ if (!v)
2053
+ return;
2054
+ v.paused ? v.play() : v.pause();
2055
+ };
2056
+ const handleReady = (e) => {
2057
+ const tar = e.target;
2058
+ Object.assign(state, {
2059
+ duration: tar.duration,
2060
+ current: tar.currentTime,
2061
+ });
2062
+ tar.volume = state.volume / 100;
2063
+ };
2064
+ const handleMuted = () => {
2065
+ const v = videoRef.current;
2066
+ if (!v)
2067
+ return;
2068
+ if (v.volume > 0) {
2069
+ state.volumeCache = v.volume;
2070
+ v.volume = 0;
2071
+ return;
2072
+ }
2073
+ v.volume = state.volumeCache === 0 ? 0.5 : state.volumeCache;
2074
+ };
2075
+ const handleStop = () => {
2076
+ const v = videoRef.current;
2077
+ if (!v)
2078
+ return;
2079
+ v.currentTime = 0;
2080
+ v.pause();
2081
+ };
2082
+ const handleFullscreen = () => {
2083
+ const tar = videoRef.current?.parentElement;
2084
+ if (!tar)
2085
+ return;
2086
+ state.isFullscreen ? exitFullScreen() : fullScreen(tar);
2087
+ onFullScreenChange?.(!state.isFullscreen);
2088
+ };
2089
+ const handleUpdateTime = (t) => {
2090
+ const v = videoRef.current;
2091
+ if (!v)
2092
+ return;
2093
+ v.currentTime = (state.duration * t) / 100;
2094
+ };
2095
+ const handleUpdateVolume = (t) => {
2096
+ const v = videoRef.current;
2097
+ if (!v)
2098
+ return;
2099
+ v.volume = t / 100;
2100
+ };
2101
+ const showControls = !hideControls && !useOriginControls;
2102
+ const clearHiddenTO = () => {
2103
+ if (!hiddenTO.current)
2104
+ return;
2105
+ clearTimeout(hiddenTO.current);
2106
+ hiddenTO.current = null;
2107
+ };
2108
+ const setHiddenFalse = () => {
2109
+ if (!showControls || !state.controlHidden)
2110
+ return;
2111
+ state.controlHidden = false;
2112
+ clearHiddenTO();
2113
+ hiddenTO.current = setTimeout(() => {
2114
+ state.controlHidden = true;
2115
+ }, 1000);
2116
+ };
2117
+ const handleDraggingProgress = (dragging) => {
2118
+ state.draggingProgress = dragging;
2119
+ };
2120
+ const handleMouseMove = throttle({ interval: 900 }, setHiddenFalse);
2121
+ useImperativeHandle(ref, () => ({
2122
+ play: () => {
2123
+ const v = videoRef.current;
2124
+ if (!v)
2125
+ return;
2126
+ v.play();
2127
+ },
2128
+ pause: () => {
2129
+ const v = videoRef.current;
2130
+ if (!v)
2131
+ return;
2132
+ v.pause();
2133
+ },
2134
+ stop: handleStop,
2135
+ fullscreen: handleFullscreen,
2136
+ getVideo: () => videoRef.current,
2137
+ }));
2138
+ useEffect(() => {
2139
+ const v = videoRef.current;
2140
+ if (!v)
2141
+ return;
2142
+ v.addEventListener("timeupdate", timeUpdateListener);
2143
+ v.addEventListener("play", playChangeListener);
2144
+ v.addEventListener("pause", playChangeListener);
2145
+ v.addEventListener("volumechange", volumeChangeListener);
2146
+ document.addEventListener("fullscreenchange", fsChangeListener);
2147
+ return () => {
2148
+ clearHiddenTO();
2149
+ v.removeEventListener("timeupdate", timeUpdateListener);
2150
+ v.removeEventListener("play", playChangeListener);
2151
+ v.removeEventListener("pause", playChangeListener);
2152
+ v.removeEventListener("volumechange", volumeChangeListener);
2153
+ document.removeEventListener("fullscreenchange", fsChangeListener);
2154
+ };
2155
+ }, []);
2156
+ const currentValue = (state.current / state.duration) * 100;
2157
+ return (jsxs("div", { className: classNames("i-video", className), style: { height, width, ...style }, onClick: handlePlay, onDoubleClick: () => handleFullscreen(), onMouseMove: handleMouseMove, children: [jsx("video", { ref: videoRef, onCanPlay: handleReady, ...restProps, controls: useOriginControls }), showControls && (jsxs("div", { className: classNames("i-video-controls", {
2158
+ "i-video-controls-hidden": state.controlHidden,
2159
+ }), onClick: (e) => e.stopPropagation(), children: [jsx(Button.Toggle, { className: 'i-video-btn', flat: true, square: true, after: jsx(Icon, { icon: jsx(PauseRound, {}) }), active: state.playing, onClick: handlePlay, children: jsx(Icon, { icon: jsx(PlayArrowRound, {}) }) }), jsx(Button, { className: 'i-video-btn', flat: true, square: true, onClick: handleStop, children: jsx(Icon, { icon: jsx(StopRound, {}) }) }), jsxs("span", { className: 'i-video-times font-sm', children: [jsx(Text.Time, { seconds: state.current }), " /", jsx(Text.Time, { seconds: state.duration })] }), jsx(Progress, { ...timeProgressProps, value: currentValue, onChange: handleUpdateTime, onDraggingChange: handleDraggingProgress }), jsxs("div", { className: 'i-video-control-volume', children: [jsx(Button.Toggle, { className: 'i-video-btn', flat: true, square: true, active: state.volume <= 0, after: jsx(Icon, { icon: jsx(VolumeOffRound, {}), style: { padding: ".125em" } }), onClick: handleMuted, children: jsx(Icon, { icon: jsx(VolumeDownRound, {}) }) }), jsx("div", { className: 'i-video-volume', children: jsx(Progress, { style: { height: 100 }, vertical: true, ...volumeProgressProps, value: state.volume, onChange: handleUpdateVolume }) })] }), jsx(Button.Toggle, { className: 'i-video-btn', flat: true, square: true, after: jsx(Icon, { icon: jsx(FullscreenExitRound, {}) }), active: state.isFullscreen, onClick: () => handleFullscreen(), children: jsx(Icon, { icon: jsx(FullscreenRound, {}) }) })] }))] }));
2160
+ };
2161
+
2162
+ var TFileType;
2163
+ (function (TFileType) {
2164
+ TFileType["IMAGE"] = "IMAGE";
2165
+ TFileType["VIDEO"] = "VIDEO";
2166
+ TFileType["AUDIO"] = "AUDIO";
2167
+ TFileType["PDF"] = "PDF";
2168
+ TFileType["EXCEL"] = "EXCEL";
2169
+ TFileType["TXT"] = "TXT";
2170
+ TFileType["UNKNOWN"] = "UNKNOWN";
2171
+ })(TFileType || (TFileType = {}));
2172
+
2173
+ function renderFile(props) {
2174
+ const { name, suffix, type } = props;
2175
+ switch (type) {
2176
+ case TFileType.IMAGE:
2177
+ return jsx("img", { src: props.src });
2178
+ case TFileType.VIDEO:
2179
+ return jsx(Video, { ...props });
2180
+ default:
2181
+ return (jsxs("div", { className: 'i-preview-unknown', children: [jsx(Icon, { icon: jsx(FeedOutlined, {}), size: '3em' }), jsx("h5", { className: 'mt-4', children: name || suffix || "?" })] }));
2182
+ }
2183
+ }
2184
+
2185
+ function Content(props) {
2186
+ const { items = [], initial = 0, renderFile: renderFile$1 = renderFile, onRotate, onChange, onClose, onZoom, } = props;
2187
+ const state = useReactive({
2188
+ current: initial,
2189
+ rotate: 0,
2190
+ scale: 1,
2191
+ translate: [0, 0],
2192
+ start: [0, 0],
2193
+ dragging: false,
2194
+ controlHidden: true,
2195
+ });
2196
+ const box = useRef(null);
2197
+ const translate = useRef([0, 0]);
2198
+ const hiddenTO = useRef(null);
2199
+ const files = useMemo(() => {
2200
+ return items.map((item) => {
2201
+ const o = {
2202
+ src: "",
2203
+ };
2204
+ if (typeof item === "string") {
2205
+ o.src = item;
2206
+ }
2207
+ else {
2208
+ Object.assign(o, item);
2209
+ }
2210
+ o.suffix = getSuffixByUrl(o.src) || "";
2211
+ o.type = getFileType(o.suffix, item["type"]);
2212
+ return o;
2213
+ });
2214
+ }, [items]);
2215
+ const { file, content } = useMemo(() => {
2216
+ const file = files[state.current];
2217
+ const content = renderFile$1(file);
2218
+ return {
2219
+ file,
2220
+ content,
2221
+ };
2222
+ }, [state.current, items]);
2223
+ const isImage = file.type === TFileType.IMAGE;
2224
+ const handleSwitch = (next) => {
2225
+ const l = files.length;
2226
+ const { current: before } = state;
2227
+ if (next >= l) {
2228
+ state.current = 0;
2229
+ }
2230
+ else if (next < 0) {
2231
+ state.current = l - 1;
2232
+ }
2233
+ else {
2234
+ state.current = next;
2235
+ }
2236
+ onChange?.(state.current, before);
2237
+ state.rotate = files[state.current].rotate || 0;
2238
+ if (state.scale !== 1) {
2239
+ state.scale = 1;
2240
+ onZoom?.(1);
2241
+ }
2242
+ onRotate?.(state.rotate);
2243
+ state.translate = translate.current = [0, 0];
2244
+ };
2245
+ const handleRotate = (deg) => {
2246
+ state.rotate += deg;
2247
+ onRotate?.(state.rotate);
2248
+ };
2249
+ const handleMouseWheel = throttle({ interval: 60 }, (e) => {
2250
+ if (!isImage)
2251
+ return;
2252
+ let after = state.scale + (e.deltaY < 0 ? 0.05 : -0.05);
2253
+ if (after > 2)
2254
+ after = 2;
2255
+ if (after < 0.25)
2256
+ after = 0.25;
2257
+ onZoom?.(after);
2258
+ state.scale = after;
2259
+ });
2260
+ const handleMouseDown = (e) => {
2261
+ if (!isImage)
2262
+ return;
2263
+ e.preventDefault();
2264
+ state.dragging = true;
2265
+ state.start = [e.pageX, e.pageY];
2266
+ };
2267
+ const clearHiddenTO = () => {
2268
+ if (!hiddenTO.current || state.controlHidden)
2269
+ return;
2270
+ clearTimeout(hiddenTO.current);
2271
+ hiddenTO.current = null;
2272
+ };
2273
+ const setHiddenFalse = () => {
2274
+ if (!state.controlHidden)
2275
+ return;
2276
+ state.controlHidden = false;
2277
+ clearHiddenTO();
2278
+ hiddenTO.current = setTimeout(() => {
2279
+ state.controlHidden = true;
2280
+ }, 1000);
2281
+ };
2282
+ const throttleMouseMove = throttle({ interval: 300 }, setHiddenFalse);
2283
+ const handleMouseMove = (e) => {
2284
+ throttleMouseMove();
2285
+ if (!state.dragging)
2286
+ return;
2287
+ e.preventDefault();
2288
+ const [x, y] = translate.current;
2289
+ const [ox, oy] = state.start;
2290
+ const offsetX = e.pageX - ox;
2291
+ const offsetY = e.pageY - oy;
2292
+ state.translate = [x + offsetX, y + offsetY];
2293
+ };
2294
+ const handleMouseUp = () => {
2295
+ if (!state.dragging)
2296
+ return;
2297
+ state.dragging = false;
2298
+ translate.current = state.translate;
2299
+ };
2300
+ useMouseMove(handleMouseMove);
2301
+ useMouseUp(handleMouseUp);
2302
+ return (jsxs(Fragment, { children: [jsx("div", { ref: box, className: classNames("i-preview-content", {
2303
+ "no-transition": state.dragging,
2304
+ }), style: {
2305
+ transform: `translate(${state.translate
2306
+ .map((n) => `${n}px`)
2307
+ .join(",")}) rotate(${state.rotate}deg) scale(${state.scale})`,
2308
+ }, onWheel: handleMouseWheel, onMouseDown: handleMouseDown, onClick: (e) => e.stopPropagation(), children: content }), jsxs("div", { className: classNames("i-preview-controls", {
2309
+ "i-preview-controls-hidden": state.controlHidden,
2310
+ }), children: [jsx(Button, { square: true, flat: true, onClick: onClose, children: jsx(Icon, { icon: jsx(CloseRound, {}) }) }), files.length > 1 && (jsxs("span", { className: 'px-8', children: [state.current + 1, " / ", files.length] })), state.scale !== 1 && (jsxs(Button, { flat: true, onClick: () => (state.scale = 1), children: [jsx(Icon, { icon: jsx(AspectRatioRound, {}) }), jsxs("span", { className: 'mt-2', children: [(state.scale * 100).toFixed(0), "%"] })] })), jsx(Button, { square: true, flat: true, href: file.src, target: '_blank', children: jsx(Icon, { icon: jsx(OpenInNewRound, {}) }) }), jsx(Button, { square: true, flat: true, href: file.src, download: true, target: '_blank', children: jsx(Icon, { icon: jsx(FileDownloadOutlined, {}) }) }), jsx(Button, { square: true, flat: true, onClick: () => handleRotate(90), children: jsx(Icon, { icon: jsx(RotateRightRound, {}) }) }), jsx(Button, { square: true, flat: true, onClick: () => handleRotate(-90), children: jsx(Icon, { icon: jsx(RotateLeftRound, {}) }) }), files.length > 1 && (jsxs(Fragment, { children: [jsx(Button, { square: true, flat: true, onClick: () => handleSwitch(state.current - 1), children: jsx(Icon, { icon: jsx(KeyboardArrowLeftRound, {}) }) }), jsx(Button, { square: true, flat: true, onClick: () => handleSwitch(state.current + 1), children: jsx(Icon, { icon: jsx(KeyboardArrowRightRound, {}) }) })] }))] })] }));
2311
+ }
2312
+
2313
+ function usePreview() {
2314
+ const ref = useRef(null);
2315
+ const preview = (config) => {
2316
+ const { items, modalProps, onClose, ...restProps } = config;
2317
+ const handleClose = () => {
2318
+ onClose?.();
2319
+ unMount?.();
2320
+ };
2321
+ const unMount = renderNode(jsx(HookModal, { ref: ref, visible: true, className: 'i-preview', customized: true, hideShadow: true, ...modalProps, children: jsx(Content, { ...restProps, items: items, onClose: () => {
2322
+ ref.current?.update({ visible: false });
2323
+ } }), fixed: true, onClose: handleClose }));
2324
+ };
2325
+ return preview;
2326
+ }
2327
+
2328
+ const Image = (props) => {
2329
+ const { src, round, size, initSize, lazyload, fallback = (jsx(Icon, { icon: jsx(HideImageTwotone, {}), size: '2em', className: 'color-5' })), fit, style, className, cover, coverClass, usePreview: previewable, onLoad, onError, onClick, ...restProps } = props;
2330
+ const state = useReactive({
2331
+ status: "loading",
2332
+ });
2333
+ const ref = useRef(null);
2334
+ const wh = fit ? "100%" : undefined;
2335
+ const { observe, unobserve } = useIntersectionObserver();
2336
+ const preview = usePreview();
2337
+ const handleError = (err) => {
2338
+ onError?.(err);
2339
+ state.status = "error";
2340
+ };
2341
+ const handleLoad = (e) => {
2342
+ onLoad?.(e);
2343
+ state.status = undefined;
2344
+ };
2345
+ const handleClick = (e) => {
2346
+ onClick?.(e);
2347
+ previewable &&
2348
+ src &&
2349
+ preview({
2350
+ items: [
2351
+ {
2352
+ src,
2353
+ type: "IMAGE",
2354
+ },
2355
+ ],
2356
+ });
2357
+ };
2358
+ useEffect(() => {
2359
+ if (!src)
2360
+ return;
2361
+ if (!ref.current?.complete) {
2362
+ state.status = "loading";
2363
+ }
2364
+ if (!lazyload || !ref.current)
2365
+ return;
2366
+ observe(ref.current, (tar, visible) => {
2367
+ if (!visible)
2368
+ return;
2369
+ tar.setAttribute("src", tar.dataset.src || "");
2370
+ unobserve(tar);
2371
+ });
2372
+ return () => {
2373
+ ref.current && unobserve(ref.current);
2374
+ };
2375
+ }, [src]);
2376
+ restProps[lazyload ? "data-src" : "src"] = src;
2377
+ const iSize = state.status === "loading" ? initSize : undefined;
2378
+ return (jsx("div", { style: {
2379
+ width: size ?? iSize,
2380
+ height: size ?? iSize,
2381
+ ...style,
2382
+ }, className: classNames("i-image", className, {
2383
+ rounded: round,
2384
+ [`i-image-${state.status}`]: state.status,
2385
+ }), children: state.status === "error" ? (fallback) : (jsxs(Fragment, { children: [src && (jsx("img", { ref: ref, style: { objectFit: fit, width: wh, height: wh }, ...restProps, onLoad: handleLoad, onError: handleError, onClick: handleClick })), src && state.status === "loading" && jsx(Loading, { absolute: true }), cover && (jsx("div", { className: classNames("i-image-cover", coverClass), onClick: handleClick, children: cover }))] })) }));
2386
+ };
2387
+
2388
+ function List(props) {
2389
+ const { items = [], gap = 8, columns, wrap, direction, usePreview: previewable, onClick, ...restProps } = props;
2390
+ const preview = usePreview();
2391
+ const files = useMemo(() => {
2392
+ return items.map((item) => {
2393
+ const o = {
2394
+ src: "",
2395
+ };
2396
+ if (typeof item === "string") {
2397
+ o.src = item;
2398
+ }
2399
+ else {
2400
+ Object.assign(o, item);
2401
+ }
2402
+ o.suffix = getSuffixByUrl(o.src) || "";
2403
+ o.type = getFileType(o.suffix, item["type"]);
2404
+ return o;
2405
+ });
2406
+ }, [items]);
2407
+ const handleClick = (e, i) => {
2408
+ onClick?.(e);
2409
+ previewable &&
2410
+ preview({
2411
+ items: files,
2412
+ initial: i,
2413
+ });
2414
+ };
2415
+ if (!files.length)
2416
+ return "";
2417
+ return (jsx(Flex, { className: 'i-image-list', gap: gap, columns: columns, wrap: wrap, direction: direction, children: files.map((img, i) => {
2418
+ return (jsx(Image, { src: img.src, size: 60, usePreview: false, onClick: (e) => handleClick(e, i), ...restProps }, i));
2419
+ }) }));
2420
+ }
2421
+
2422
+ Image.List = List;
2423
+
2424
+ function InputContainer(props) {
2425
+ const { as: As = "label", label, className, labelInline, style, children, status, tip, required, } = props;
2426
+ return (jsxs(As, { className: classNames("i-input-label", className, {
2427
+ "i-input-inline": labelInline,
2428
+ }), style: style, children: [label && (jsxs("span", { className: 'i-input-label-text', children: [required && jsx("span", { className: 'error', children: "*" }), label] })), children, tip && (jsx("span", { className: classNames("i-input-message", {
2429
+ [`i-input-${status}`]: status !== "normal",
2430
+ }), children: tip }))] }));
2431
+ }
2432
+
2433
+ const Input = ((props) => {
2434
+ const { ref, type = "text", label, name, value = props.initValue ?? "", initValue = "", prepend, append, labelInline, className, status = "normal", message, tip, clear, hideVisible, border, required, onChange, onEnter, style, ...restProps } = props;
2435
+ const state = useReactive({
2436
+ value,
2437
+ type,
2438
+ visible: false,
2439
+ });
2440
+ const handleChange = (e) => {
2441
+ const v = e.target.value;
2442
+ state.value = v;
2443
+ onChange?.(v, e);
2444
+ };
2445
+ const handleKeydown = (e) => {
2446
+ e.code === "Enter" && onEnter?.(e);
2447
+ };
2448
+ const handleHelperClick = () => {
2449
+ if (type === "password" && !hideVisible) {
2450
+ Object.assign(state, {
2451
+ visible: !state.visible,
2452
+ type: !state.visible ? "text" : "password",
2453
+ });
2454
+ return;
2455
+ }
2456
+ const v = "";
2457
+ onChange?.(v);
2458
+ };
2459
+ const HelperIcon = useMemo(() => {
2460
+ if (type === "password") {
2461
+ return state.visible ? jsx(VisibilityRound, {}) : jsx(VisibilityOffRound, {});
2462
+ }
2463
+ return undefined;
2464
+ }, [state.visible]);
2465
+ useEffect(() => {
2466
+ state.value = value;
2467
+ }, [value]);
2468
+ const inputProps = {
2469
+ ref,
2470
+ type: state.type,
2471
+ name,
2472
+ value: state.value,
2473
+ className: classNames("i-input", `i-input-${type}`),
2474
+ onChange: handleChange,
2475
+ onKeyDown: handleKeydown,
2476
+ ...restProps,
2477
+ };
2478
+ const clearable = clear && state.value;
2479
+ const showHelper = type === "password" && !!state.value;
2480
+ return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, required: required, children: jsxs("div", { className: classNames("i-input-item", {
2481
+ [`i-input-${status}`]: status !== "normal",
2482
+ "i-input-borderless": !border,
2483
+ }), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), jsx("input", { ...inputProps }), jsx(Helpericon, { active: !!clearable || showHelper, icon: HelperIcon, onClick: handleHelperClick }), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
2484
+ });
2485
+
2486
+ const Number = (props) => {
2487
+ const { ref, label, name, value = props.initValue ?? "", initValue, labelInline, step = 1, min = -Infinity, max = Infinity, thousand, precision, type, className, status = "normal", append, border, prepend, message, tip, hideControl, style, onChange, onEnter, onInput, onBlur, ...restProps } = props;
2488
+ const state = useReactive({
2489
+ value,
2490
+ });
2491
+ const getRangeNumber = (v) => clamp(v, min, max);
2492
+ const getFormatNumber = (v) => formatNumber(v, { precision, thousand });
2493
+ const formatInputValue = (v) => {
2494
+ if (!v)
2495
+ return "";
2496
+ if (typeof v === "number" || !thousand)
2497
+ return v;
2498
+ return v.replaceAll(thousand, "");
2499
+ };
2500
+ const handleChange = (e) => {
2501
+ const { value } = e.target;
2502
+ const v = formatInputValue(value.replace(/[^\d\.-]/g, ""));
2503
+ state.value = v;
2504
+ onChange?.(+v, e);
2505
+ };
2506
+ const handleOperate = (param) => {
2507
+ const value = formatInputValue(state.value) ?? 0;
2508
+ const result = getRangeNumber(+value + param);
2509
+ state.value = getFormatNumber(result);
2510
+ onChange?.(result);
2511
+ };
2512
+ useEffect(() => {
2513
+ state.value = value;
2514
+ }, [value]);
2515
+ const inputProps = {
2516
+ ref,
2517
+ name,
2518
+ value: state.value,
2519
+ className: "i-input i-input-number",
2520
+ onChange: handleChange,
2521
+ ...restProps,
2522
+ };
2523
+ return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsxs("div", { className: classNames("i-input-item", {
2524
+ [`i-input-${status}`]: status !== "normal",
2525
+ "i-input-borderless": !border,
2526
+ }), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(MinusRound, {}), onClick: () => handleOperate(-step) })), jsx("input", { ...inputProps }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(PlusRound, {}), onClick: () => handleOperate(step) })), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
2527
+ };
2528
+
2529
+ const Range = (props) => {
2530
+ const { label, name, value = props.initValue ?? "", initValue, labelInline, min = -Infinity, max = Infinity, type, className, status = "normal", message, tip, append, prepend, step = 1, thousand, precision, hideControl, placeholder, border, onChange, onBlur, style, ...restProps } = props;
2531
+ const state = useReactive({
2532
+ value,
2533
+ });
2534
+ const getRangeNumber = (v) => clamp(v, min, max);
2535
+ const getFormatNumber = (v) => formatNumber(v, { precision, thousand });
2536
+ const formatInputValue = (v) => {
2537
+ if (!v)
2538
+ return "";
2539
+ if (typeof v === "number" || !thousand)
2540
+ return v;
2541
+ return v.replaceAll(thousand, "");
2542
+ };
2543
+ const handleChange = (e, i) => {
2544
+ const { value } = e.target;
2545
+ const v = formatInputValue(value.replace(/[^\d\.-]/g, ""));
2546
+ const range = Array.isArray(state.value) ? state.value : [];
2547
+ range[i] = +v;
2548
+ state.value = range;
2549
+ onChange?.(range, e);
2550
+ };
2551
+ const handleOperate = (e, param, i) => {
2552
+ e.preventDefault();
2553
+ e.stopPropagation();
2554
+ const range = Array.isArray(state.value) ? state.value : [];
2555
+ const value = formatInputValue(range[i]) ?? 0;
2556
+ const result = getRangeNumber(+value + param);
2557
+ range[i] = getFormatNumber(result);
2558
+ state.value = range;
2559
+ onChange?.(range, e);
2560
+ };
2561
+ const handleSwitch = (e) => {
2562
+ e.preventDefault();
2563
+ e.stopPropagation();
2564
+ const range = state.value ? state.value : [];
2565
+ const v = range[0];
2566
+ range[0] = range[1];
2567
+ range[1] = v;
2568
+ state.value = range;
2569
+ onChange?.(range);
2570
+ };
2571
+ useEffect(() => {
2572
+ state.value = value;
2573
+ }, [value]);
2574
+ const inputProps = {
2575
+ name,
2576
+ className: "i-input i-input-number",
2577
+ ...restProps,
2578
+ };
2579
+ return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsxs("div", { className: classNames("i-input-item", {
2580
+ [`i-input-${status}`]: status !== "normal",
2581
+ "i-input-borderless": !border,
2582
+ }), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(MinusRound, {}), onClick: (e) => handleOperate(e, -step, 0) })), jsx("input", { value: state.value?.[0] || "", placeholder: placeholder?.[0], ...inputProps, onChange: (e) => handleChange(e, 0) }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(PlusRound, {}), onClick: (e) => handleOperate(e, step, 0) })), jsx(Helpericon, { active: true, icon: jsx(SyncAltRound, {}), style: { margin: 0 }, onClick: handleSwitch }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(MinusRound, {}), onClick: (e) => handleOperate(e, -step, 1) })), jsx("input", { value: state.value?.[1] || "", placeholder: placeholder?.[1], ...inputProps, onChange: (e) => handleChange(e, 1) }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(PlusRound, {}), onClick: (e) => handleOperate(e, step, 1) })), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
2583
+ };
2584
+
2585
+ const Textarea = (props) => {
2586
+ const { ref, label, name, value = props.initValue, initValue, labelInline, className, status = "normal", message, tip, autoSize, border, style, onChange, onEnter, ...restProps } = props;
2587
+ const state = useReactive({
2588
+ value,
2589
+ });
2590
+ const refTextarea = useRef(null);
2591
+ const handleChange = (e) => {
2592
+ const v = e.target.value;
2593
+ state.value = v;
2594
+ const ta = refTextarea.current?.firstChild;
2595
+ if (autoSize && ta) {
2596
+ ta.style.height = `${ta.scrollHeight}px`;
2597
+ }
2598
+ onChange?.(v, e);
2599
+ };
2600
+ const handleKeydown = (e) => {
2601
+ if (e.code !== "Enter")
2602
+ return;
2603
+ e.stopPropagation();
2604
+ onEnter?.(e);
2605
+ };
2606
+ useEffect(() => {
2607
+ state.value = value;
2608
+ }, [value]);
2609
+ const inputProps = {
2610
+ ref,
2611
+ name,
2612
+ value: state.value,
2613
+ className: "i-input i-textarea",
2614
+ onChange: handleChange,
2615
+ onKeyDown: handleKeydown,
2616
+ ...restProps,
2617
+ };
2618
+ return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsx("div", { ref: refTextarea, className: classNames("i-input-item", {
2619
+ [`i-input-${status}`]: status !== "normal",
2620
+ "i-input-borderless": !border,
2621
+ }), children: jsx("textarea", { ...inputProps }) }) }));
2622
+ };
2623
+
2624
+ Input.Textarea = Textarea;
2625
+ Input.Number = Number;
2626
+ Input.Range = Range;
2627
+
2628
+ const AlignMap = {
2629
+ left: "flex-start",
2630
+ center: "center",
2631
+ right: "flex-end",
2632
+ };
2633
+ const GlobalConfig = {
2634
+ align: "center",
2635
+ offset: "12px",
2636
+ gap: 12,
2637
+ };
2638
+ const ItemDefaultConfig = {
2639
+ duration: 3000,
2640
+ closable: true,
2641
+ active: false,
2642
+ };
2643
+ const container = createContainer();
2644
+ const handler = {
2645
+ oneInstance: null,
2646
+ callout(item) { },
2647
+ close() { },
2648
+ };
2649
+ const queue = {
2650
+ left: [],
2651
+ center: [],
2652
+ right: [],
2653
+ };
2654
+ const heights = {
2655
+ left: [],
2656
+ center: [],
2657
+ right: [],
2658
+ };
2659
+ createRoot(container).render(jsx(Messages, {}));
2660
+ const MessageItem = function ({ ref, active, content, top, className, style, onClick, }) {
2661
+ return (jsx("div", { ref: ref, className: classNames("i-message", className, {
2662
+ "i-message-active": active,
2663
+ }), style: {
2664
+ ...style,
2665
+ top,
2666
+ }, onClick: onClick, children: content }));
2667
+ };
2668
+ function Messages() {
2669
+ const ref = useRef(null);
2670
+ const state = useReactive({
2671
+ items: {
2672
+ left: [],
2673
+ center: [],
2674
+ right: [],
2675
+ },
2676
+ tops: {
2677
+ left: [],
2678
+ center: [],
2679
+ right: [],
2680
+ },
2681
+ });
2682
+ const offsetTop = {
2683
+ left: 0,
2684
+ center: 0,
2685
+ right: 0,
2686
+ };
2687
+ useEffect(() => {
2688
+ Object.assign(handler, {
2689
+ callout: function (item) {
2690
+ const { align = "center", unshift, onShow } = item;
2691
+ const size = queue[align][unshift ? "unshift" : "push"](item);
2692
+ state.items[align] = [...queue[align]];
2693
+ item.close = this.close.bind(item);
2694
+ setTimeout(() => {
2695
+ const h = ref.current?.offsetHeight || 0;
2696
+ queue[align][unshift ? 0 : size - 1].active = true;
2697
+ state.items[align] = [...queue[align]];
2698
+ heights[align][unshift ? "unshift" : "push"](h);
2699
+ state.tops[align] = [...heights[align]];
2700
+ onShow?.();
2701
+ }, 12);
2702
+ if (item.duration !== 0) {
2703
+ item.timer = setTimeout(() => {
2704
+ this.close.call(item);
2705
+ }, item.duration);
2706
+ }
2707
+ },
2708
+ close: function () {
2709
+ const item = this;
2710
+ const { align = "center", onHide } = item;
2711
+ const index = queue[align].findIndex((i) => i.id === item.id);
2712
+ if (index < 0)
2713
+ return;
2714
+ queue[align][index].active = false;
2715
+ state.items[align] = [...queue[align]];
2716
+ item.timer = setTimeout(() => {
2717
+ const index = queue[align].findIndex((i) => i.id === item.id);
2718
+ queue[align].splice(index, 1);
2719
+ heights[align].splice(index, 1);
2720
+ state.tops[align] = [...heights[align]];
2721
+ state.items[align] = [...queue[align]];
2722
+ item.timer && clearTimeout(item.timer);
2723
+ onHide?.();
2724
+ }, 240);
2725
+ },
2726
+ });
2727
+ }, []);
2728
+ const renderItems = (item, i) => {
2729
+ if (!item)
2730
+ return jsx(Fragment, {});
2731
+ const { id, active, content, align = "center", className } = item;
2732
+ offsetTop[align] += state.tops[align][i - 1] || 0;
2733
+ const top = GlobalConfig.gap * i + offsetTop[align];
2734
+ return (jsx(MessageItem, { ref: ref, active: active, content: content, top: top, className: className, style: { alignSelf: AlignMap[align] }, onClick: handler.close.bind(item) }, id));
2735
+ };
2736
+ return (jsxs("div", { className: 'i-messages', children: [state.items.left.map(renderItems), state.items.center.map(renderItems), state.items.right.map(renderItems)] }));
2737
+ }
2738
+ function message(config) {
2739
+ if (["string", "number"].includes(typeof config) ||
2740
+ isValidElement(config)) {
2741
+ config = { content: config };
2742
+ }
2743
+ config = Object.assign({ id: uid(7) }, ItemDefaultConfig, config);
2744
+ handler.callout(config);
2745
+ return {
2746
+ instance: config,
2747
+ close: handler.close.bind(config),
2748
+ };
2749
+ }
2750
+ function createContainer() {
2751
+ const container = document.createElement("div");
2752
+ container.dataset.id = "messages";
2753
+ document.body.append(container);
2754
+ return container;
2755
+ }
2756
+ message.error = (content) => {
2757
+ return message({
2758
+ content,
2759
+ className: "bg-error",
2760
+ });
2761
+ };
2762
+ message.success = (content) => {
2763
+ return message({
2764
+ content,
2765
+ className: "bg-success",
2766
+ });
2767
+ };
2768
+ message.warning = (content) => {
2769
+ return message({
2770
+ content,
2771
+ className: "bg-warning",
2772
+ });
2773
+ };
2774
+ message.one = (config) => {
2775
+ const o = handler.oneInstance;
2776
+ if (o) {
2777
+ if (o.active && o.duration !== 0) {
2778
+ clearTimeout(o.timer);
2779
+ o.timer = setTimeout(() => {
2780
+ o.close?.();
2781
+ }, o.duration);
2782
+ }
2783
+ else {
2784
+ handler.callout(o);
2785
+ }
2786
+ }
2787
+ else {
2788
+ const { instance } = message(config);
2789
+ handler.oneInstance = instance;
2790
+ }
2791
+ };
2792
+
2793
+ function useModal() {
2794
+ const ref = useRef(null);
2795
+ const handleOpen = (props) => {
2796
+ const unMount = renderNode(jsx(HookModal, { ref: ref, visible: true, ...props, onClose: () => {
2797
+ props.onClose?.();
2798
+ unMount?.();
2799
+ } }));
2800
+ };
2801
+ const handleUpdate = (props) => {
2802
+ if (!ref.current)
2803
+ return;
2804
+ const { update } = ref.current;
2805
+ update(props);
2806
+ };
2807
+ const handleClose = () => {
2808
+ if (!ref.current)
2809
+ return;
2810
+ const { close } = ref.current;
2811
+ close();
2812
+ };
2813
+ return {
2814
+ open: handleOpen,
2815
+ update: handleUpdate,
2816
+ close: handleClose,
2817
+ };
2818
+ }
2819
+
2820
+ Modal.useModal = useModal;
2821
+
2822
+ const Page = (props) => {
2823
+ const { page, active, children, onChange } = props;
2824
+ const [loading, setLoading] = useState(false);
2825
+ const handleClick = async () => {
2826
+ if (active || loading)
2827
+ return;
2828
+ setLoading(true);
2829
+ await onChange?.(page);
2830
+ setLoading(false);
2831
+ };
2832
+ return (jsxs("a", { className: classNames("i-page", {
2833
+ "i-page-active": active,
2834
+ "i-page-loading": loading,
2835
+ "i-page-disabled": false,
2836
+ }), "data-page": page, onClick: handleClick, children: [loading && jsx(Loading, {}), children] }));
2837
+ };
2838
+
2839
+ const Pagination = (props) => {
2840
+ const { page: defaultPage = 1, size = 10, total = 0, sibling = 2, prev = jsx(Icon, { icon: jsx(KeyboardArrowLeftRound, {}) }), next = jsx(Icon, { icon: jsx(KeyboardArrowRightRound, {}) }), simple, jumper, className, renderEllipsis = () => (jsx(Icon, { icon: jsx(MoreHorizRound, {}), className: 'color-7' })), renderPage = (i) => i, onChange, ...restProps } = props;
2841
+ const [page, setPage] = useState(defaultPage);
2842
+ const [loading, setLoading] = useState(false);
2843
+ const totalPage = useMemo(() => Math.ceil(total / size), [size, total]);
2844
+ const [start, end, loop] = useMemo(() => {
2845
+ const start = Math.max(1, page - sibling);
2846
+ const end = Math.min(totalPage, page + sibling);
2847
+ return [
2848
+ start,
2849
+ end,
2850
+ Array.from({ length: end - start + 1 }).map((n, i) => start + i),
2851
+ ];
2852
+ }, [page, totalPage, sibling]);
2853
+ if (totalPage <= page && page === 1)
2854
+ return jsx(Fragment, {});
2855
+ const handlePageChange = async (p) => {
2856
+ if (!onChange || loading)
2857
+ return;
2858
+ setLoading(true);
2859
+ return new Promise(async (resolve) => {
2860
+ if (p === undefined)
2861
+ return;
2862
+ await onChange(p);
2863
+ setPage(p);
2864
+ setLoading(false);
2865
+ resolve();
2866
+ });
2867
+ };
2868
+ useEffect(() => setPage(defaultPage), [defaultPage]);
2869
+ return (jsxs("div", { className: classNames("i-pagination", className), ...restProps, children: [prev && (jsx(Page, { page: page - 1 || 1, onChange: handlePageChange, children: prev })), start > 1 && (jsx(Page, { page: 1, onChange: handlePageChange, children: renderPage(1) })), start > 2 && renderEllipsis(), loop.map((p) => {
2870
+ return (jsx(Page, { page: p, active: p === page, onChange: handlePageChange, children: renderPage(p) }, p));
2871
+ }), end < totalPage - 1 && renderEllipsis(), end < totalPage && (jsx(Page, { page: totalPage, onChange: handlePageChange, children: renderPage(totalPage) })), next && (jsx(Page, { page: page + 1, onChange: handlePageChange, children: next }))] }));
2872
+ };
2873
+
2874
+ const Tag = (props) => {
2875
+ const { dot, dotClass, outline, round, size = "normal", hoverShowClose, className, children, onClose, onClick, ...restProps } = props;
2876
+ return (jsxs("span", { className: classNames("i-tag", {
2877
+ "i-tag-outline": outline,
2878
+ "i-tag-clickable": onClick,
2879
+ [`i-tag-${size}`]: size !== "normal",
2880
+ round,
2881
+ }, className), onClick: onClick, ...restProps, children: [dot && jsx("span", { className: classNames("i-tag-dot", dotClass) }), children, onClose && (jsx(Helpericon, { active: true, className: classNames("i-tag-close", {
2882
+ "i-tag-hover-close": hoverShowClose,
2883
+ }), onClick: onClose }))] }));
2884
+ };
2885
+
2886
+ const Options = (props) => {
2887
+ const { value: val, options, filter, filterPlaceholder, multiple, empty = jsx(Empty, {}), onSelect, onFilter, } = props;
2888
+ return (jsxs("div", { className: classNames("i-select-options", {
2889
+ "i-select-options-multiple": multiple,
2890
+ }), children: [filter && multiple && (jsxs("div", { className: 'i-select-filter', children: [jsx(Icon, { icon: jsx(SearchRound, {}), className: 'color-8 ml-8 my-auto', size: '1.2em' }), jsx("input", { type: 'text', className: 'i-input', placeholder: filterPlaceholder, onChange: onFilter })] })), options.length === 0 && empty, options.map((option, i) => {
2891
+ const { label, value, disabled } = option;
2892
+ const isActive = multiple
2893
+ ? val?.includes(value)
2894
+ : val === value;
2895
+ return (jsxs(List$1.Item, { active: isActive, type: 'option', onClick: () => onSelect?.(value, option), disabled: disabled, children: [multiple && (jsx(Icon, { icon: jsx(CheckRound, {}), className: 'i-select-option-check', size: '1em' })), label] }, value || i));
2896
+ })] }));
2897
+ };
2898
+ const activeOptions = (options = [], value = [], max = 3) => {
2899
+ const total = options.flatMap((opt) => value.includes(opt.value) ? [opt] : []);
2900
+ if (max >= total.length)
2901
+ return total;
2902
+ const rest = total.length - max;
2903
+ const after = total.slice(0, max);
2904
+ after.push(rest);
2905
+ return after;
2906
+ };
2907
+ const displayValue = (config) => {
2908
+ const { options, value, maxDisplay, multiple, onSelect } = config;
2909
+ if (multiple) {
2910
+ return activeOptions(options, value, maxDisplay).map((opt, i) => {
2911
+ if (typeof opt === "number")
2912
+ return jsxs(Tag, { children: ["+", opt] }, i);
2913
+ const { label, value } = opt;
2914
+ return (jsx(Tag, { hoverShowClose: true, onClose: (e) => {
2915
+ e?.stopPropagation();
2916
+ onSelect?.(value, opt);
2917
+ }, children: label }, value));
2918
+ });
2919
+ }
2920
+ return options.find((opt) => opt.value === value)?.label;
2921
+ };
2922
+
2923
+ const Select = (props) => {
2924
+ const { ref, type = "text", name, label, value = "", placeholder, options = [], multiple, prepend, append, labelInline, style, className, message, status = "normal", hideClear, hideArrow, maxDisplay, border, filter, tip, filterPlaceholder = "...", popupProps, onSelect, onChange, ...restProps } = props;
2925
+ const state = useReactive({
2926
+ inputValue: "",
2927
+ filterValue: "",
2928
+ value,
2929
+ loading: false,
2930
+ });
2931
+ const [active, setActive] = useState(false);
2932
+ const formattedOptions = useMemo(() => formatOption(options), [options]);
2933
+ const filterOptions = useMemo(() => {
2934
+ const { filterValue: fv } = state;
2935
+ if (!fv || !filter)
2936
+ return formattedOptions;
2937
+ const filterFn = typeof filter === "function"
2938
+ ? filter
2939
+ : (opt) => opt.value.includes(fv) || opt.label.includes(fv);
2940
+ return formattedOptions.filter(filterFn);
2941
+ }, [formattedOptions, filter, state.filterValue]);
2942
+ const changeValue = (v) => {
2943
+ state.value = v;
2944
+ onChange?.(v);
2945
+ };
2946
+ const handleSelect = (value, option) => {
2947
+ onSelect?.(value, option);
2948
+ if (multiple) {
2949
+ const values = [...state.value];
2950
+ const i = values.findIndex((v) => v === value);
2951
+ i > -1 ? values.splice(i, 1) : values.push(value);
2952
+ changeValue(values);
2953
+ return;
2954
+ }
2955
+ setActive(false);
2956
+ changeValue(value);
2957
+ };
2958
+ const handleVisibleChange = (visible) => {
2959
+ setActive(visible);
2960
+ if (!filter)
2961
+ return;
2962
+ state.filterValue = "";
2963
+ };
2964
+ const handleHelperClick = (e) => {
2965
+ e.stopPropagation();
2966
+ setActive(true);
2967
+ if (!active)
2968
+ return;
2969
+ changeValue(multiple ? [] : "");
2970
+ };
2971
+ const handleFilterChange = debounce({ delay: 400 }, (e) => {
2972
+ const v = e.target.value;
2973
+ state.filterValue = v;
2974
+ });
2975
+ const handleInputChange = (e) => {
2976
+ state.filterValue = e.target.value;
2977
+ };
2978
+ useEffect(() => {
2979
+ state.value = value;
2980
+ }, [value]);
2981
+ const hasValue = multiple
2982
+ ? state.value.length > 0
2983
+ : !!state.value;
2984
+ const clearable = !hideClear && active && hasValue;
2985
+ const text = message ?? tip;
2986
+ return (jsxs("label", { className: classNames("i-input-label", className, {
2987
+ "i-input-inline": labelInline,
2988
+ }), style: style, children: [label && jsx("span", { className: 'i-input-label-text', children: label }), jsx(Popup, { position: 'bottom', arrow: false, fitSize: true, ...popupProps, visible: active, trigger: 'none', onVisibleChange: handleVisibleChange, content: jsx(Options, { options: filterOptions, value: state.value, multiple: multiple, filter: !!filter, filterPlaceholder: filterPlaceholder, onSelect: handleSelect, onFilter: handleFilterChange }), children: jsxs("div", { className: classNames("i-input-item", {
2989
+ [`i-input-${status}`]: status !== "normal",
2990
+ "i-input-borderless": !border,
2991
+ "i-input-focus": active,
2992
+ }), onClick: () => setActive(true), children: [prepend, jsx("input", { ref: ref, type: 'hidden', value: state.value, ...restProps }), multiple ? (hasValue ? (jsx("div", { className: classNames("i-input i-select", {
2993
+ "i-select-multiple": multiple,
2994
+ }), children: displayValue({
2995
+ options: formattedOptions,
2996
+ value: state.value,
2997
+ multiple,
2998
+ maxDisplay,
2999
+ onSelect: handleSelect,
3000
+ }) })) : (jsx("input", { className: 'i-input i-select', placeholder: placeholder, readOnly: true }))) : null, !multiple && (jsx("input", { value: active ? state.filterValue : state.value, className: 'i-input i-select', placeholder: state.value || placeholder, onChange: handleInputChange, readOnly: !filter })), jsx(Helpericon, { active: !hideArrow, icon: clearable ? undefined : jsx(UnfoldMoreRound, {}), onClick: handleHelperClick }), append] }) }), text && jsx("span", { className: 'i-input-message', children: text })] }));
3001
+ };
3002
+
3003
+ const ColorMethods = {
3004
+ HEX: "toHexString",
3005
+ RGB: "toRgbString",
3006
+ HSB: "toHsbString",
3007
+ };
3008
+ function Footer(props) {
3009
+ const { value, type, onTypeChange, onChange, onOk } = props;
3010
+ const state = useReactive({
3011
+ value,
3012
+ type,
3013
+ });
3014
+ const handleChange = (v) => {
3015
+ state.value = v;
3016
+ onChange(v);
3017
+ };
3018
+ const handleTypeChange = (t) => {
3019
+ state.type = t;
3020
+ onTypeChange(t);
3021
+ };
3022
+ useEffect(() => {
3023
+ state.value = value;
3024
+ state.type = type;
3025
+ }, [value, type]);
3026
+ return (jsxs("div", { className: 'i-colorpicker-footer', children: [jsx(Select, { readOnly: true, hideClear: true, hideArrow: true, style: { width: "5.6em" }, options: ["RGB", "HEX", "HSB"], value: state.type, onChange: handleTypeChange }), jsx(Input, { placeholder: 'color', value: state.value, onChange: handleChange }), jsx(Button, { square: true, onClick: onOk, children: jsx(Icon, { icon: jsx(CheckRound, {}) }) })] }));
3027
+ }
3028
+
3029
+ const Handle = (props) => {
3030
+ const { ref, color, handle, placeholder, className, ...restProps } = props;
3031
+ return (jsxs("div", { ref: ref, className: classNames("i-colorpicker-handle", className), ...restProps, children: [handle !== "text" && (jsx("i", { className: 'i-colorpicker-square', style: { background: color } })), handle !== "square" && (jsx("span", { className: 'i-colorpicker-text', style: { color }, children: color ?? placeholder }))] }));
3032
+ };
3033
+
3034
+ function ColorPicker(props) {
3035
+ const { value, type = "HEX", disabledAlpha, children, usePanel, handle = "both", placeholder = "Colors", popupProps, onChange, } = props;
3036
+ const state = useReactive({
3037
+ type,
3038
+ value,
3039
+ syncValue: value,
3040
+ visible: popupProps?.visible,
3041
+ });
3042
+ const handleChange = (target) => {
3043
+ state.syncValue = target;
3044
+ };
3045
+ const handleComplete = (target) => {
3046
+ const method = ColorMethods[state.type];
3047
+ if (target.a !== 1) {
3048
+ target.a = parseFloat(target.a.toFixed(3));
3049
+ }
3050
+ state.value = target[method]?.();
3051
+ };
3052
+ const handleVisibleChange = (v) => {
3053
+ state.visible = v;
3054
+ popupProps?.onVisibleChange?.(v);
3055
+ };
3056
+ const handleTypeChange = (t) => {
3057
+ const method = ColorMethods[t];
3058
+ state.type = t;
3059
+ state.value = state.syncValue[method]?.();
3060
+ };
3061
+ const handleValueChange = (v) => {
3062
+ state.value = v;
3063
+ state.syncValue = v;
3064
+ };
3065
+ const handleOk = () => {
3066
+ onChange?.(state.value);
3067
+ state.visible = false;
3068
+ };
3069
+ useEffect(() => {
3070
+ state.syncValue = value;
3071
+ state.value = value;
3072
+ }, [value]);
3073
+ if (usePanel) {
3074
+ return jsx(ColorsPanel, { ...props });
3075
+ }
3076
+ return (jsx(Popup, { trigger: 'click', touchable: true, position: 'bottom', ...popupProps, visible: state.visible, content: jsx(ColorsPanel, { value: state.syncValue, disabledAlpha: disabledAlpha, panelRender: (panel) => {
3077
+ return (jsxs(Fragment, { children: [panel, jsx(Footer, { value: state.value, type: state.type, onTypeChange: handleTypeChange, onChange: handleValueChange, onOk: handleOk })] }));
3078
+ }, onChange: handleChange, onChangeComplete: handleComplete }), onVisibleChange: handleVisibleChange, children: children ?? (jsx(Handle, { color: value, handle: handle, placeholder: placeholder })) }));
3079
+ }
3080
+
3081
+ const Dates = (props) => {
3082
+ const { value, month, weeks = ["一", "二", "三", "四", "五", "六", "日"], renderDate = (date) => date.date(), disabledDate, onDateClick, } = props;
3083
+ const today = dayjs();
3084
+ const dates = useMemo(() => {
3085
+ const dates = [];
3086
+ const lastDateOfLastMonth = month.add(-1, "month").endOf("month");
3087
+ let { $W, $D } = lastDateOfLastMonth;
3088
+ if ($W !== 0) {
3089
+ const lastMonthDates = Array.from({ length: $W }).map((whatever, i) => lastDateOfLastMonth.add(i + 1 - $W, "day"));
3090
+ dates.push(...lastMonthDates);
3091
+ }
3092
+ const lastDate = month.endOf("month");
3093
+ $D = lastDate.$D;
3094
+ $W = lastDate.$W;
3095
+ dates.push(...Array.from({ length: $D }).map((whatever, i) => lastDate.add(i + 1 - $D, "day")));
3096
+ if ($W !== 0) {
3097
+ dates.push(...Array.from({ length: 7 - $W }).map((whatever, i) => lastDate.add(i + 1, "day")));
3098
+ }
3099
+ return dates;
3100
+ }, [month]);
3101
+ const handleDateClick = (date) => {
3102
+ if (disabledDate?.(date))
3103
+ return;
3104
+ onDateClick?.(date);
3105
+ };
3106
+ return (jsxs(Fragment, { children: [jsx("div", { className: 'i-datepicker-weeks', children: weeks.map((week, i) => (jsx("span", { className: 'i-datepicker-week', children: week }, i))) }), jsx("div", { className: 'i-datepicker-dates', children: dates.map((date, i) => {
3107
+ const active = date.isSame(value, "day");
3108
+ const isSameMonth = date.isSame(month, "month");
3109
+ const isToday = date.isSame(today, "day");
3110
+ const disabled = disabledDate?.(date);
3111
+ return (jsx("div", { className: classNames("i-datepicker-item", {
3112
+ "i-datepicker-active": active,
3113
+ "i-datepicker-same-month": isSameMonth,
3114
+ "i-datepicker-today": isToday,
3115
+ "i-datepicker-disabled": disabled,
3116
+ }), onClick: () => handleDateClick(date), children: renderDate(date) }, i));
3117
+ }) })] }));
3118
+ };
3119
+
3120
+ const MONTHS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
3121
+ const YearMonth = (props) => {
3122
+ const { value, unitMonth = "月", unitYear = "年", renderYear, renderMonth, onClick, } = props;
3123
+ return (jsxs("a", { className: 'i-datepicker-action', "data-ripple": true, onClick: onClick, children: [jsx("span", { children: renderYear?.(value.year()) }), unitYear, jsx("span", { children: renderMonth?.(value.month() + 1) }), unitMonth] }));
3124
+ };
3125
+ const Panel$1 = (props) => {
3126
+ const { value, unitYear, unitMonth, renderDate, renderMonth = (m) => m, renderYear = (y) => y, disabledDate, onDateClick, } = props;
3127
+ const state = useReactive({
3128
+ today: value,
3129
+ month: value || dayjs(),
3130
+ selectedYear: dayjs(),
3131
+ years: [],
3132
+ selectable: false,
3133
+ });
3134
+ const $years = useRef(null);
3135
+ const handleOperateMonth = (next) => {
3136
+ state.month = state.month[next ? "add" : "subtract"](1, "month");
3137
+ };
3138
+ const handleChangeDate = (date) => {
3139
+ if (date.isSame(state.today, "day"))
3140
+ return;
3141
+ if (!date.isSame(state.month, "month")) {
3142
+ state.month = date;
3143
+ }
3144
+ state.today = date;
3145
+ onDateClick?.(date);
3146
+ };
3147
+ const handleChangeMonth = (month) => {
3148
+ state.month = state.month
3149
+ .year(state.selectedYear.year())
3150
+ .month(month - 1);
3151
+ state.selectable = false;
3152
+ };
3153
+ const getMoreYears = throttle({ interval: 100 }, (e) => {
3154
+ const isUp = e.deltaY < 0;
3155
+ state.years = state.years.map((y) => (y += isUp ? -1 : 1));
3156
+ });
3157
+ useEffect(() => {
3158
+ if (!state.selectable)
3159
+ return;
3160
+ state.selectedYear = state.month;
3161
+ const y = state.selectedYear.year();
3162
+ const years = Array.from({ length: 7 }).map((_, i) => y - 3 + i);
3163
+ state.years = [...years];
3164
+ }, [state.selectable]);
3165
+ useEffect(() => {
3166
+ state.today = value;
3167
+ state.month = value || dayjs();
3168
+ }, [value]);
3169
+ return (jsxs("div", { className: 'i-datepicker', children: [jsxs("div", { className: 'i-datepicker-units', children: [jsx(YearMonth, { value: state.month, unitYear: unitYear, unitMonth: unitMonth, renderMonth: renderMonth, renderYear: renderYear, onClick: () => (state.selectable = true) }), jsx("a", { className: 'ml-auto i-datepicker-action', "data-ripple": true, onClick: () => handleOperateMonth(false), children: jsx(Icon, { icon: jsx(KeyboardArrowLeftRound, {}) }) }), jsx("a", { className: 'i-datepicker-action', "data-ripple": true, onClick: () => handleOperateMonth(true), children: jsx(Icon, { icon: jsx(KeyboardArrowRightRound, {}) }) })] }), jsxs("div", { className: classNames("i-datepicker-ym", {
3170
+ "i-datepicker-active": state.selectable,
3171
+ }), children: [jsx(Helpericon, { active: true, className: 'i-datepicker-close', onClick: (e) => {
3172
+ e.stopPropagation();
3173
+ state.selectable = false;
3174
+ } }), jsx("div", { ref: $years, className: 'i-datepicker-years', onWheel: getMoreYears, children: state.years.map((y) => (jsx("a", { className: classNames("i-datepicker-year", {
3175
+ "i-datepicker-active": y === state.selectedYear.year(),
3176
+ }), onClick: () => (state.selectedYear =
3177
+ state.selectedYear.year(y)), children: renderYear(y) }, y))) }), jsx("div", { className: 'i-datepicker-months', children: MONTHS.map((m) => {
3178
+ return (jsx("a", { className: classNames("i-datepicker-month", {
3179
+ "i-datepicker-active": m === state.month.month() + 1,
3180
+ }), onClick: () => handleChangeMonth(m), children: renderMonth(m) }, m));
3181
+ }) })] }), jsx(Dates, { value: state.today, month: state.month, disabledDate: disabledDate, onDateClick: handleChangeDate, renderDate: renderDate })] }));
3182
+ };
3183
+
3184
+ dayjs.extend(customParseFormat);
3185
+ const FORMATTYPES = ["YYYY-MM-DD", "YYYY-M-D", "YYYY/MM/DD", "YYYY/M/D"];
3186
+ const FORMAT$1 = "YYYY-MM-DD";
3187
+ const Datepicker = (props) => {
3188
+ const { name, value, weeks, format = FORMAT$1, placeholder = props.format ?? FORMAT$1, renderDate, renderMonth, renderYear, popupProps, disabledDate, onDateClick, onChange, onBlur, ...restProps } = props;
3189
+ const state = useReactive({
3190
+ value,
3191
+ });
3192
+ const [active, setActive] = useState(false);
3193
+ const dayJsValue = useMemo(() => {
3194
+ if (!state.value)
3195
+ return null;
3196
+ const date = dayjs(state.value, format, true);
3197
+ if (date.isValid())
3198
+ return date;
3199
+ return null;
3200
+ }, [state.value]);
3201
+ const handleDateClick = (date) => {
3202
+ handleChange(date.format(format));
3203
+ };
3204
+ const handleChange = (v) => {
3205
+ state.value = v;
3206
+ onChange?.(v);
3207
+ };
3208
+ const handleSetDate = () => {
3209
+ if (!state.value)
3210
+ return;
3211
+ const date = dayjs(state.value, FORMATTYPES, true);
3212
+ if (date.isValid()) {
3213
+ handleChange(date.format(format));
3214
+ return;
3215
+ }
3216
+ handleChange("");
3217
+ };
3218
+ const handleBlur = (e) => {
3219
+ onBlur?.(e);
3220
+ handleSetDate();
3221
+ };
3222
+ const handleVisibleChange = (v) => {
3223
+ popupProps?.onVisibleChange?.(v);
3224
+ setActive(v);
3225
+ };
3226
+ useEffect(() => {
3227
+ state.value = value;
3228
+ }, [value]);
3229
+ return (jsx(Popup, { visible: active, trigger: 'click', position: 'bottom', arrow: false, align: 'start', onVisibleChange: handleVisibleChange, watchResize: true, content: jsx(Panel$1, { value: dayJsValue, weeks: weeks, renderDate: renderDate, renderMonth: renderMonth, renderYear: renderYear, disabledDate: disabledDate, onDateClick: handleDateClick }), ...popupProps, children: jsx(Input, { value: state.value, append: jsx(Icon, { icon: jsx(CalendarMonthTwotone, {}), className: 'i-datepicker-icon', size: '1em' }), placeholder: placeholder, onChange: handleChange, onBlur: handleBlur, onEnter: handleSetDate, ...restProps }) }));
3230
+ };
3231
+
3232
+ function Items(props) {
3233
+ const { items = [], active, renderItem, unit, onClick } = props;
3234
+ return items.map((n) => {
3235
+ const isActive = n === active;
3236
+ return (jsx("a", { className: classNames("i-timepicker-item", {
3237
+ "i-timepicker-item-active": isActive,
3238
+ }), onClick: () => onClick(n), children: renderItem?.(n, isActive, unit) ?? (n < 10 ? `0${n}` : n) }, n));
3239
+ });
3240
+ }
3241
+
3242
+ const UnitMaps = {
3243
+ h: "hour",
3244
+ hh: "hour",
3245
+ m: "minute",
3246
+ mm: "minute",
3247
+ s: "second",
3248
+ ss: "second",
3249
+ };
3250
+ function Panel(props) {
3251
+ const { value, stepH = 1, stepM = 1, stepS = 1, format, periods, renderItem, onChange, onFallback, } = props;
3252
+ const state = useReactive({
3253
+ period: undefined,
3254
+ hour: undefined,
3255
+ minute: undefined,
3256
+ second: undefined,
3257
+ });
3258
+ const [hours, minutes, seconds] = useMemo(() => {
3259
+ const hasH = format.includes("h");
3260
+ const hasM = format.includes("m");
3261
+ const hasS = format.includes("s");
3262
+ const hours = hasH
3263
+ ? Array.from({ length: (periods ? 12 : 24) / stepH }, (_, i) => i * stepH)
3264
+ : [];
3265
+ const minutes = hasM
3266
+ ? Array.from({ length: 60 / stepM }, (_, i) => i * stepM)
3267
+ : [];
3268
+ const seconds = hasS
3269
+ ? Array.from({ length: 60 / stepS }, (_, i) => i * stepS)
3270
+ : [];
3271
+ return [hours, minutes, seconds];
3272
+ }, [stepH, stepM, stepS, format, periods]);
3273
+ const updateValue = () => {
3274
+ const reg = /(hh|h){1}|(mm|m){1}|(ss|s){1}/gi;
3275
+ let result = format.replace(reg, (pattern) => {
3276
+ const p = pattern.toLowerCase();
3277
+ const u = UnitMaps[p];
3278
+ const n = state[u] ?? 0;
3279
+ return p.length > 1 && n < 10 ? `0${n ?? 0}` : n ?? 0;
3280
+ });
3281
+ if (periods && hours.length > 0) {
3282
+ result = `${state.period ?? periods[0]} ${result}`;
3283
+ }
3284
+ onChange(result);
3285
+ };
3286
+ const handleSetTime = (v, unit) => {
3287
+ state[unit] = v;
3288
+ updateValue();
3289
+ };
3290
+ useEffect(() => {
3291
+ let time = value ?? "";
3292
+ if (periods && hours.length > 0 && value) {
3293
+ const [p, t] = value.split(" ");
3294
+ time = t ?? "";
3295
+ state.period = periods.includes(p) ? p : undefined;
3296
+ }
3297
+ const nums = time.match(/\d+/g) ?? [];
3298
+ if (!nums.length) {
3299
+ onFallback("");
3300
+ return;
3301
+ }
3302
+ let i = 0;
3303
+ const r = format.replace(/(hh|h)+|(mm|m)+|(ss|s)+/gi, (p) => {
3304
+ const n = nums[i++] ?? 0;
3305
+ let o = p;
3306
+ if (UnitMaps[p] === "hour") {
3307
+ o = Math.min(periods ? 11 : 23, n);
3308
+ }
3309
+ o = Math.min(59, n);
3310
+ state[UnitMaps[p]] = o;
3311
+ return p.length > 1 && o < 10 ? `0${o}` : o;
3312
+ });
3313
+ onFallback(r);
3314
+ }, [value]);
3315
+ return (jsxs("div", { className: 'i-timepicker', children: [hours.length > 0 && (jsxs(Fragment, { children: [periods && (jsx("div", { className: 'i-timepicker-list', children: jsx(Items, { items: periods, active: state.period, onClick: (p) => handleSetTime(p, "period") }) })), jsx("div", { className: 'i-timepicker-list', children: jsx(Items, { items: hours, active: state.hour, unit: 'hour', renderItem: renderItem, onClick: (h) => handleSetTime(h, "hour") }) })] })), minutes.length > 0 && (jsx("div", { className: 'i-timepicker-list', children: jsx(Items, { items: minutes, active: state.minute, unit: 'minute', renderItem: renderItem, onClick: (m) => handleSetTime(m, "minute") }) })), seconds.length > 0 && (jsx("div", { className: 'i-timepicker-list', children: jsx(Items, { items: seconds, active: state.second, unit: 'second', renderItem: renderItem, onClick: (s) => handleSetTime(s, "second") }) }))] }));
3316
+ }
3317
+
3318
+ const FORMAT = "hh:mm:ss";
3319
+ function TimePicker(props) {
3320
+ const { name, value, format = FORMAT, periods, placeholder = props.format ?? FORMAT, renderItem, onChange, onBlur, popupProps, ...restProps } = props;
3321
+ const state = useReactive({
3322
+ value,
3323
+ safeValue: undefined,
3324
+ });
3325
+ const [active, setActive] = useState(false);
3326
+ const handleChange = (v) => {
3327
+ state.value = v;
3328
+ };
3329
+ const handleFallback = (v) => {
3330
+ state.safeValue = v;
3331
+ };
3332
+ const handleValidTime = () => {
3333
+ if (!state.value)
3334
+ return;
3335
+ state.value = state.safeValue;
3336
+ handleChange(state.safeValue);
3337
+ };
3338
+ const handleBlur = (e) => {
3339
+ onBlur?.(e);
3340
+ handleValidTime();
3341
+ };
3342
+ const handleVisibleChange = (v) => {
3343
+ popupProps?.onVisibleChange?.(v);
3344
+ setActive(v);
3345
+ };
3346
+ useEffect(() => {
3347
+ state.value = value;
3348
+ }, [value]);
3349
+ return (jsx(Popup, { visible: active, trigger: 'click', position: 'bottom', arrow: false, align: 'start', watchResize: true, ...popupProps, onVisibleChange: handleVisibleChange, content: jsx(Panel, { value: state.value, format: format, periods: periods, renderItem: renderItem, onChange: handleChange, onFallback: handleFallback }), children: jsx(Input, { value: state.value, placeholder: placeholder, append: jsx(Icon, { icon: jsx(AccessTimeRound, {}), className: 'i-timepicker-icon', size: '1em' }), onChange: handleChange, onBlur: handleBlur, ...restProps }) }));
3350
+ }
3351
+
3352
+ const defaultOk = {
3353
+ children: "确定",
3354
+ };
3355
+ const defaultCancel = {
3356
+ children: "取消",
3357
+ secondary: true,
3358
+ };
3359
+ const Popconfirm = (props) => {
3360
+ const { trigger = "click", visible, icon = jsx(Icon, { icon: jsx(InfoOutlined, {}), className: 'error' }), content, okButtonProps, cancelButtonProps, children, align = "end", position = "top", offset = 12, extra, onOk, onClose, ...restProps } = props;
3361
+ const state = useReactive({
3362
+ loading: false,
3363
+ visible,
3364
+ });
3365
+ const ok = okButtonProps
3366
+ ? Object.assign({}, defaultOk, okButtonProps)
3367
+ : defaultOk;
3368
+ const cancel = cancelButtonProps
3369
+ ? Object.assign({}, defaultCancel, cancelButtonProps)
3370
+ : defaultCancel;
3371
+ const handleVisibleChange = (v) => {
3372
+ state.visible = v;
3373
+ restProps.onVisibleChange?.(v);
3374
+ };
3375
+ const handleOk = async (e) => {
3376
+ state.loading = true;
3377
+ ok.onClick?.(e);
3378
+ onOk?.()
3379
+ ?.then(() => {
3380
+ state.visible = false;
3381
+ })
3382
+ .finally(() => {
3383
+ state.loading = false;
3384
+ });
3385
+ };
3386
+ const handleCancel = async (e) => {
3387
+ cancel.onClick?.(e);
3388
+ await onClose?.();
3389
+ state.visible = false;
3390
+ };
3391
+ const popconfirmContent = (jsxs("div", { className: 'i-popconfirm', children: [jsxs(Flex, { gap: 12, children: [icon, jsx("div", { className: 'i-popconfirm-content', children: content })] }), jsxs(Flex, { gap: 12, justify: 'flex-end', className: 'mt-8 i-popconfirm-footer', children: [cancelButtonProps !== null && (jsx(Button, { ...cancel, onClick: handleCancel })), extra, okButtonProps !== null && (jsx(Button, { loading: state.loading, ...ok, onClick: handleOk }))] })] }));
3392
+ return (jsx(Popup, { content: popconfirmContent, ...restProps, trigger: trigger, visible: state.visible, align: align, offset: offset, position: position, onVisibleChange: handleVisibleChange, children: children }));
3393
+ };
3394
+
3395
+ function RadioItem(props) {
3396
+ const { type = "default", name, value, checked, disabled, children, onChange, } = props;
3397
+ const isChildrenFn = typeof children === "function";
3398
+ const handleChange = (e) => {
3399
+ onChange?.(value, e);
3400
+ };
3401
+ return (jsxs("label", { className: classNames("i-radio-item", {
3402
+ disabled,
3403
+ "i-radio-item-custom": isChildrenFn,
3404
+ }), children: [jsx("input", { type: 'radio', name: name, checked: checked, className: classNames("i-radio-input", `i-radio-${type}`), disabled: disabled, hidden: isChildrenFn, onChange: handleChange }), isChildrenFn ? (children(!!checked, value)) : (jsx("span", { className: 'i-radio-text', children: children }))] }));
3405
+ }
3406
+
3407
+ function Radio(props) {
3408
+ const { label, name, options, value, type = "default", status = "normal", message, optionInline = true, labelInline, disabled, required, className, renderItem, onChange, } = props;
3409
+ const state = useReactive({
3410
+ value,
3411
+ });
3412
+ const formattedOptions = useMemo(() => formatOption(options), [options]);
3413
+ const handleChange = (value, e) => {
3414
+ state.value = value;
3415
+ onChange?.(value, e);
3416
+ };
3417
+ useEffect(() => {
3418
+ state.value = value;
3419
+ }, [value]);
3420
+ return (jsxs("div", { className: classNames("i-radio i-input-label", {
3421
+ [`i-radio-${status}`]: status !== "normal",
3422
+ "i-input-inline": labelInline,
3423
+ }, className), children: [label && (jsxs("span", { className: 'i-input-label-text', children: [required && jsx("span", { className: 'error', children: "*" }), label, message && jsx("p", { className: 'i-radio-message', children: message })] })), jsx("div", { className: classNames("i-radio-options", {
3424
+ "i-options-block": !optionInline,
3425
+ "i-radio-options-button": type === "button",
3426
+ }), children: formattedOptions.map((option) => {
3427
+ const checked = state.value === option.value;
3428
+ return (jsx(RadioItem, { name: name, value: option.value, checked: checked, type: type, disabled: disabled || option.disabled, onChange: handleChange, children: renderItem ?? option.label }, option.value));
3429
+ }) })] }));
3430
+ }
3431
+ Radio.Item = RadioItem;
3432
+
3433
+ const Resizable = (props) => {
3434
+ const { other, children, vertical, height, size = "auto", minSize = 0, maxSize = "100%", style, line, className, asPercent, onResize, onResizeComplete, } = props;
3435
+ const state = useReactive({
3436
+ size,
3437
+ resizing: false,
3438
+ start: 0,
3439
+ total: 0,
3440
+ });
3441
+ const ref = useRef(null);
3442
+ const handleMouseDown = () => {
3443
+ const rect = ref.current?.getBoundingClientRect();
3444
+ if (!rect)
3445
+ return;
3446
+ state.resizing = true;
3447
+ if (vertical) {
3448
+ state.total = rect.height;
3449
+ state.start = rect.top;
3450
+ return;
3451
+ }
3452
+ state.total = rect.width;
3453
+ state.start = rect.left;
3454
+ };
3455
+ const handleMouseMove = (e) => {
3456
+ if (!state.resizing)
3457
+ return;
3458
+ e.preventDefault();
3459
+ if (e.touches) {
3460
+ e = e.touches[0];
3461
+ }
3462
+ const d = e[vertical ? "pageY" : "pageX"];
3463
+ const offset = d - state.start;
3464
+ state.size = asPercent ? `${(offset / state.total) * 100}%` : offset;
3465
+ onResize?.(state.size);
3466
+ };
3467
+ const handleMouseUp = () => {
3468
+ if (!state.resizing)
3469
+ return;
3470
+ state.resizing = false;
3471
+ onResizeComplete?.(state.size);
3472
+ };
3473
+ useMouseUp(handleMouseUp);
3474
+ useMouseMove(handleMouseMove);
3475
+ return (jsxs("div", { ref: ref, className: classNames("i-resizable", className, {
3476
+ [`i-resizable-vertical`]: vertical,
3477
+ }), style: { ...style, height }, children: [jsx("div", { className: 'i-resizable-a', style: {
3478
+ [vertical ? "height" : "width"]: state.size,
3479
+ [vertical ? "minHeight" : "minWidth"]: minSize,
3480
+ [vertical ? "maxHeight" : "maxWidth"]: maxSize,
3481
+ }, children: other }), jsx("div", { className: classNames("i-resizable-line", {
3482
+ [`i-resizable-resizing`]: state.resizing,
3483
+ }), onMouseDown: handleMouseDown, onTouchStart: handleMouseDown, onContextMenu: (e) => e.preventDefault(), children: jsx("div", { className: 'i-resizable-line-node', children: line }) }), jsx("div", { className: 'i-resizable-b', children: children })] }));
3484
+ };
3485
+
3486
+ function Divider() {
3487
+ return jsx("i", { className: 'i-step-divider' });
3488
+ }
3489
+
3490
+ const STATUS = ["finished", "active", "pending"];
3491
+ function defaultRenderIcon(i, status) {
3492
+ return (jsx("span", { className: 'i-step-item-index', children: status === "finished" ? (jsx(CheckRound, { style: { width: "1em", height: "1.5em" } })) : (i + 1) }));
3493
+ }
3494
+ function Item$2(props) {
3495
+ const { index = 0, active = 0, renderIcon = defaultRenderIcon, title, vertical, line = jsx(Divider, {}), asList, style, className, children, onClick, } = props;
3496
+ const status = STATUS[index === active ? 1 : index < active ? 0 : 2];
3497
+ const handleClick = () => {
3498
+ onClick?.(index);
3499
+ };
3500
+ return (jsx("div", { style: style, className: classNames("i-step-item", {
3501
+ [`i-step-item-${status}`]: !asList,
3502
+ }, className), onClick: handleClick, children: vertical ? (jsxs(Fragment, { children: [jsxs("div", { className: 'i-step-item-left', children: [renderIcon?.(index, status), line] }), jsxs("div", { className: 'i-step-item-right', children: [jsx("div", { className: 'i-step-item-title', children: title }), children && (jsx("div", { className: 'i-step-item-content', children: children }))] })] })) : (jsxs(Fragment, { children: [jsxs("div", { className: 'i-step-item-title', children: [renderIcon?.(index, status), jsx("span", { children: title }), line] }), children && (jsx("div", { className: 'i-step-item-content', children: children }))] })) }));
3503
+ }
3504
+
3505
+ const Step = (props) => {
3506
+ const { active = 0, vertical, renderIcon, line, style, asList, className, children, onClick, } = props;
3507
+ const steps = useMemo(() => {
3508
+ const nodes = [];
3509
+ let index = 0;
3510
+ Children.map(children, (el) => {
3511
+ if (!el || el.type !== Item$2)
3512
+ return;
3513
+ const { props: elProps } = el;
3514
+ nodes.push({
3515
+ ...el,
3516
+ props: {
3517
+ renderIcon,
3518
+ line,
3519
+ onClick,
3520
+ ...elProps,
3521
+ vertical,
3522
+ active,
3523
+ asList,
3524
+ index: index++,
3525
+ },
3526
+ });
3527
+ });
3528
+ return nodes;
3529
+ }, [active, children]);
3530
+ return (jsx("div", { className: classNames("i-step", { "i-step-vertical": vertical }, className), style: style, children: steps }));
3531
+ };
3532
+ Step.Item = Item$2;
3533
+
3534
+ function Item$1(props) {
3535
+ const { index = 0, itemIndex = 0, active, type, transition, gap = 0, itemHeight, vertical, style, className, children, onItemClick, } = props;
3536
+ const selfStyle = useMemo(() => {
3537
+ if (type === "normal") {
3538
+ return {
3539
+ [vertical ? "paddingBlock" : "paddingInline"]: gap / 2,
3540
+ height: itemHeight,
3541
+ };
3542
+ }
3543
+ return {
3544
+ transform: `translate(-${index * 100}%, 0)`,
3545
+ transition,
3546
+ };
3547
+ }, [index, gap, itemHeight, vertical, type]);
3548
+ return (jsx("div", { style: { ...style, ...selfStyle }, className: classNames("i-swiper-item", className, {
3549
+ "i-swiper-active": active,
3550
+ }), "data-index": itemIndex, onClick: (e) => onItemClick?.(itemIndex, e), children: children }));
3551
+ }
3552
+
3553
+ const Swiper = ((props) => {
3554
+ const { ref, type = "normal", initial = 0, display = 1, scroll = 1, loop = true, vertical, prev = jsx(Icon, { icon: jsx(KeyboardArrowLeftRound, {}), size: '2em' }), next = jsx(Icon, { icon: jsx(KeyboardArrowRightRound, {}), size: '2em' }), duration = 600, interval = 3000, autoplay, pauseOnHover, arrow = true, reverse, draggable, dragOffset = 40, gap = 0, itemHeight, indicator, fixedIndicator, style, className, children, renderIndicator, onBeforeSwipe, onAfterSwipe, onItemClick, } = props;
3555
+ const listRef = useRef(null);
3556
+ const timerRef = useRef(null);
3557
+ const transition = `all ${duration / 1000}s`;
3558
+ const state = useReactive({
3559
+ current: initial,
3560
+ swipable: true,
3561
+ transition: type === "fade" ? "none" : transition,
3562
+ dragStart: 0,
3563
+ dragging: false,
3564
+ initialized: false,
3565
+ });
3566
+ const items = useMemo(() => {
3567
+ return Children.map(children, (node) => {
3568
+ if (node.type !== Item$1)
3569
+ return;
3570
+ return node;
3571
+ });
3572
+ }, [children]);
3573
+ const [displayItems, extra, size, total, listSize] = useMemo(() => {
3574
+ const extra = type === "normal" && loop && items.length > display
3575
+ ? display + 1
3576
+ : 0;
3577
+ let list = [];
3578
+ if (extra <= 0) {
3579
+ list = [...items];
3580
+ }
3581
+ else {
3582
+ const head = items.slice(0, extra);
3583
+ const tail = items.slice(-extra);
3584
+ list = [...tail, ...items, ...head];
3585
+ }
3586
+ const listSize = `${(list.length / display) * 100}%`;
3587
+ return [list, extra, items.length, list.length, listSize];
3588
+ }, [display, loop, type, items]);
3589
+ const offsetPercent = useMemo(() => (-100 * (state.current + extra)) / total, [state.current, total]);
3590
+ const position = useMemo(() => {
3591
+ if (size <= display || type === "fade")
3592
+ return;
3593
+ const offset = vertical
3594
+ ? `0, ${offsetPercent}%`
3595
+ : `${offsetPercent}%, 0`;
3596
+ return `translate3d(${offset}, 0)`;
3597
+ }, [offsetPercent, vertical, display, size, type]);
3598
+ const trackStyle = useMemo(() => {
3599
+ if (!vertical || !itemHeight)
3600
+ return;
3601
+ return {
3602
+ height: itemHeight * display,
3603
+ };
3604
+ }, [vertical, itemHeight, display]);
3605
+ const indicatorsLoop = useMemo(() => {
3606
+ return Array.from({
3607
+ length: Math.ceil((size - display) / scroll) + 1,
3608
+ });
3609
+ }, [loop, indicator]);
3610
+ const clearTimer = () => {
3611
+ clearTimeout(timerRef.current);
3612
+ timerRef.current = null;
3613
+ };
3614
+ const swipeTo = (i) => {
3615
+ if (!state.swipable || i === state.current)
3616
+ return;
3617
+ state.swipable = false;
3618
+ onBeforeSwipe?.(state.current);
3619
+ let reset = false;
3620
+ let next = i;
3621
+ const lastDisplay = size - display;
3622
+ if (loop) {
3623
+ if (i > lastDisplay) {
3624
+ reset = true;
3625
+ i = size;
3626
+ next = 0;
3627
+ }
3628
+ else if (i < 0) {
3629
+ reset = true;
3630
+ i = -display;
3631
+ next = lastDisplay;
3632
+ }
3633
+ }
3634
+ else {
3635
+ next = clamp(next, 0, lastDisplay);
3636
+ i = next;
3637
+ }
3638
+ setTimeout(() => {
3639
+ state.swipable = true;
3640
+ }, duration + 32);
3641
+ if (type === "fade") {
3642
+ state.current = next;
3643
+ onAfterSwipe?.(next);
3644
+ return;
3645
+ }
3646
+ state.current = i;
3647
+ if (!reset) {
3648
+ if (autoplay) {
3649
+ timerRef.current = setTimeout(swipeNext, interval);
3650
+ }
3651
+ setTimeout(() => {
3652
+ onAfterSwipe?.(next);
3653
+ }, duration + 12);
3654
+ return;
3655
+ }
3656
+ setTimeout(() => {
3657
+ state.transition = "none";
3658
+ state.current = next;
3659
+ onAfterSwipe?.(next);
3660
+ if (autoplay) {
3661
+ timerRef.current = setTimeout(swipeNext, interval);
3662
+ }
3663
+ setTimeout(() => {
3664
+ state.transition = transition;
3665
+ }, 60);
3666
+ }, duration + 20);
3667
+ };
3668
+ const swipeNext = () => {
3669
+ swipeTo(reverse ? state.current - scroll : state.current + scroll);
3670
+ };
3671
+ const swipePrev = () => {
3672
+ swipeTo(reverse ? state.current + scroll : state.current - scroll);
3673
+ };
3674
+ const handleMouseDown = (e) => {
3675
+ if (!draggable || !state.swipable || type === "fade")
3676
+ return;
3677
+ e.stopPropagation();
3678
+ e.preventDefault();
3679
+ if (e.touches) {
3680
+ e = e.touches[0];
3681
+ }
3682
+ Object.assign(state, {
3683
+ dragStart: vertical ? e.clientY : e.clientX,
3684
+ dragging: true,
3685
+ transition: "none",
3686
+ });
3687
+ };
3688
+ const handleMouseMove = (e) => {
3689
+ if (!state.dragging || !listRef.current)
3690
+ return;
3691
+ e.preventDefault();
3692
+ if (e.touches) {
3693
+ e = e.touches[0];
3694
+ }
3695
+ const dragEnd = vertical ? e.clientY : e.clientX;
3696
+ const offset = ((dragEnd - state.dragStart) * 61.8) /
3697
+ listRef.current[vertical ? "offsetHeight" : "offsetWidth"] +
3698
+ offsetPercent;
3699
+ listRef.current.style.transform = `translate3d(${vertical ? `0, ${offset}%` : `${offset}%, 0`}, 0)`;
3700
+ };
3701
+ const handleMouseUp = (e) => {
3702
+ if (!state.dragging || !listRef.current)
3703
+ return;
3704
+ if (e.changedTouches) {
3705
+ e = e.changedTouches[0];
3706
+ }
3707
+ const dragEnd = vertical ? e.clientY : e.clientX;
3708
+ const part = listRef.current[vertical ? "offsetHeight" : "offsetWidth"] / total;
3709
+ const offset = (dragEnd - state.dragStart) * 0.618;
3710
+ const absOffset = Math.abs(offset);
3711
+ if (absOffset > dragOffset) {
3712
+ const base = Math.floor(absOffset / part);
3713
+ const mod = (absOffset % part) - dragOffset > 0 ? 1 : 0;
3714
+ const p = base + mod;
3715
+ let to = state.current + (offset > 0 ? -p : p);
3716
+ swipeTo(to);
3717
+ }
3718
+ listRef.current.style.transform = position || "";
3719
+ Object.assign(state, {
3720
+ dragging: false,
3721
+ transition,
3722
+ });
3723
+ };
3724
+ const handleMouseOver = () => {
3725
+ if (!pauseOnHover)
3726
+ return;
3727
+ clearTimer();
3728
+ };
3729
+ const handleMouseLeave = () => {
3730
+ if (!pauseOnHover)
3731
+ return;
3732
+ clearTimer();
3733
+ timerRef.current = setTimeout(swipeNext, interval);
3734
+ };
3735
+ useMouseMove(handleMouseMove);
3736
+ useMouseUp(handleMouseUp);
3737
+ useImperativeHandle(ref, () => ({
3738
+ swipeTo,
3739
+ swipeNext,
3740
+ swipePrev,
3741
+ }));
3742
+ useEffect(() => {
3743
+ if (!autoplay)
3744
+ return;
3745
+ timerRef.current = setTimeout(swipeNext, interval);
3746
+ return () => {
3747
+ clearTimeout(timerRef.current);
3748
+ timerRef.current = null;
3749
+ };
3750
+ }, [autoplay, interval]);
3751
+ return (jsxs("div", { style: style, className: classNames("i-swiper", {
3752
+ "i-swiper-vertical": vertical,
3753
+ "i-swiper-initialized": state.initialized,
3754
+ }, className), children: [jsxs("div", { className: 'i-swiper-track', style: trackStyle, onMouseOver: handleMouseOver, onMouseLeave: handleMouseLeave, children: [jsx("div", { ref: listRef, className: classNames("i-swiper-list", {
3755
+ "i-swiper-fade": type === "fade",
3756
+ }), style: {
3757
+ [vertical ? "height" : "width"]: listSize,
3758
+ transform: position,
3759
+ transition: state.transition,
3760
+ }, onMouseDown: handleMouseDown, onTouchStart: handleMouseDown, children: displayItems.map((item, i) => {
3761
+ const { props: itemProps } = item;
3762
+ return (jsx(Item$1, { index: i, itemIndex: (i - extra + size) % size, active: i - extra === state.current, type: type, gap: gap, transition: transition, itemHeight: itemHeight, vertical: vertical, onItemClick: onItemClick, ...itemProps }, i));
3763
+ }) }), arrow && (jsxs(Fragment, { children: [(loop || state.current !== 0) && (jsx("a", { className: 'i-swiper-arrow i-swiper-prev', onClick: swipePrev, children: prev })), (loop || state.current < size - display) && (jsx("a", { className: 'i-swiper-arrow i-swiper-next', onClick: swipeNext, children: next }))] }))] }), indicator && (jsx("div", { className: classNames("i-swiper-indicators", {
3764
+ "i-swiper-indicators-fixed": fixedIndicator,
3765
+ }), children: indicatorsLoop.map((_, i) => {
3766
+ return (jsx("a", { className: classNames("i-swiper-indicator", {
3767
+ "i-indicator-active": i ===
3768
+ Math[loop ? "floor" : "ceil"](((state.current + size) % size) /
3769
+ scroll),
3770
+ }), onClick: () => swipeTo(i * scroll), children: renderIndicator?.(i) }, i));
3771
+ }) }))] }));
3772
+ });
3773
+ Swiper.Item = Item$1;
3774
+
3775
+ const Item = (props) => {
3776
+ return jsx(Fragment, {});
3777
+ };
3778
+
3779
+ const Tabs = ((props) => {
3780
+ const { ref, active, tabs: items, type = "default", prepend, append, children, className, vertical, toggable, navsJustify = "start", bar = true, hideMore, barClass, renderMore = () => (jsx(Button, { flat: true, square: true, size: 'small', children: jsx(Icon, { icon: jsx(MoreHorizRound, {}) }) })), onTabChange, ...rest } = props;
3781
+ const navRefs = useRef([]);
3782
+ const barRef = useRef(null);
3783
+ const navsRef = useRef(null);
3784
+ const state = useReactive({
3785
+ active,
3786
+ prevActive: undefined,
3787
+ barStyle: {},
3788
+ cachedTabs: [],
3789
+ overflow: false,
3790
+ more: [],
3791
+ tabs: [],
3792
+ });
3793
+ const { observe, unobserve } = useIntersectionObserver();
3794
+ const size = useSize(navsRef);
3795
+ useEffect(() => {
3796
+ if (!items) {
3797
+ if (!children) {
3798
+ state.tabs = [];
3799
+ return;
3800
+ }
3801
+ state.tabs = Children.map(children, (node, i) => {
3802
+ const { key, props: nodeProps } = node;
3803
+ const { title, children, content, keepDOM } = nodeProps;
3804
+ const cloned = children
3805
+ ? typeof children === "string"
3806
+ ? children
3807
+ : pick(children, ["props", "type", "$$typeof", "ref"])
3808
+ : content;
3809
+ return {
3810
+ key: key || String(i),
3811
+ title,
3812
+ content: cloned,
3813
+ keepDOM,
3814
+ };
3815
+ });
3816
+ return;
3817
+ }
3818
+ state.tabs = items.map((item, i) => {
3819
+ if (["string", "number"].includes(typeof item)) {
3820
+ return { key: item, title: item };
3821
+ }
3822
+ if (item.key === undefined) {
3823
+ item.key = i;
3824
+ }
3825
+ return item;
3826
+ });
3827
+ }, [children, items]);
3828
+ const add = (tab) => {
3829
+ const { key } = tab;
3830
+ const i = state.tabs.findIndex((t) => t.key === key);
3831
+ if (i > -1) {
3832
+ open(state.tabs[i].key ?? i);
3833
+ return;
3834
+ }
3835
+ const l = state.tabs.length;
3836
+ const tkey = tab.key ?? l;
3837
+ state.tabs.push({ ...tab, key: tkey });
3838
+ open(tkey);
3839
+ };
3840
+ const close = (key) => {
3841
+ const i = state.tabs.findIndex((t) => t.key === key);
3842
+ if (i < 0)
3843
+ return;
3844
+ state.tabs.splice(i, 1);
3845
+ if (state.active !== key)
3846
+ return;
3847
+ const next = state.tabs[i] || state.tabs[i - 1];
3848
+ open(state.prevActive ?? next?.key ?? "");
3849
+ };
3850
+ const open = (key) => {
3851
+ if (key === state.active) {
3852
+ if (!toggable)
3853
+ return;
3854
+ onTabChange?.(undefined, key);
3855
+ state.active = undefined;
3856
+ state.barStyle = {
3857
+ height: 0,
3858
+ width: 0,
3859
+ };
3860
+ return;
3861
+ }
3862
+ state.prevActive = state.active;
3863
+ onTabChange?.(key, state.active);
3864
+ state.active = key;
3865
+ };
3866
+ useEffect(() => {
3867
+ if (!size || hideMore)
3868
+ return;
3869
+ const { scrollHeight, scrollWidth } = navsRef.current;
3870
+ const { width, height } = size;
3871
+ state.overflow = scrollHeight > height || scrollWidth > width;
3872
+ if (!state.overflow)
3873
+ return;
3874
+ navRefs.current.map((nav, i) => {
3875
+ if (!nav)
3876
+ return;
3877
+ observe(nav, (tar, visible) => {
3878
+ if (!state.tabs[i])
3879
+ return;
3880
+ state.tabs[i].intersecting = visible;
3881
+ state.more = state.tabs.filter((tab) => !tab.intersecting);
3882
+ });
3883
+ });
3884
+ }, [size, hideMore, state.tabs.length]);
3885
+ useEffect(() => {
3886
+ if (!bar || type === "pane" || state.active === undefined) {
3887
+ return;
3888
+ }
3889
+ const index = state.tabs.findIndex((tab) => tab.key === state.active);
3890
+ setTimeout(() => {
3891
+ const nav = navRefs.current[index];
3892
+ if (!nav)
3893
+ return;
3894
+ if (state.tabs[index].keepDOM && state.active) {
3895
+ const i = state.cachedTabs.findIndex((k) => k === state.active);
3896
+ i < 0 && state.cachedTabs.unshift(state.active);
3897
+ }
3898
+ const { offsetHeight, offsetLeft, offsetTop, offsetWidth } = nav;
3899
+ const isLine = type === "line";
3900
+ state.barStyle = {
3901
+ height: !vertical && isLine ? ".25em" : offsetHeight,
3902
+ width: vertical && isLine ? ".25em" : offsetWidth,
3903
+ transform: `translate(${offsetLeft}px, ${offsetTop}px)`,
3904
+ };
3905
+ }, 16);
3906
+ }, [state.active, bar, size]);
3907
+ useEffect(() => {
3908
+ if (active === undefined || state.active === active)
3909
+ return;
3910
+ open(active);
3911
+ }, [active]);
3912
+ useEffect(() => {
3913
+ if (hideMore)
3914
+ return;
3915
+ return () => {
3916
+ navRefs.current?.map(unobserve);
3917
+ };
3918
+ }, [state.tabs.length]);
3919
+ useEffect(() => {
3920
+ if (!navsRef.current || vertical)
3921
+ return;
3922
+ const handleMouseWheel = (e) => {
3923
+ e.stopPropagation();
3924
+ e.preventDefault();
3925
+ if (vertical)
3926
+ return;
3927
+ navsRef.current?.scrollBy({
3928
+ left: e.deltaY + e.deltaX,
3929
+ });
3930
+ };
3931
+ navsRef.current.addEventListener("wheel", handleMouseWheel, {
3932
+ passive: false,
3933
+ });
3934
+ return () => {
3935
+ if (!navsRef.current)
3936
+ return;
3937
+ navsRef.current.removeEventListener("wheel", handleMouseWheel);
3938
+ };
3939
+ }, [navsRef.current]);
3940
+ useImperativeHandle(ref, () => ({
3941
+ open,
3942
+ close,
3943
+ add,
3944
+ navs: navsRef,
3945
+ }));
3946
+ return (jsxs("div", { className: classNames("i-tabs", { flex: vertical, [`i-tabs-${type}`]: type !== "default" }, className), ...rest, children: [jsxs("div", { className: classNames("i-tab-navs-container", {
3947
+ "i-tab-navs-vertical": vertical,
3948
+ }), children: [prepend, jsxs("div", { ref: navsRef, className: classNames("i-tab-navs", `justify-${navsJustify}`), children: [state.tabs.map((tab, i) => {
3949
+ const { title, key = i, closable } = tab;
3950
+ return (jsxs("a", { ref: (ref) => (navRefs.current[i] = ref), className: classNames("i-tab-nav", {
3951
+ "i-tab-active": state.active === key,
3952
+ }), onClick: () => open(key), children: [title, closable && (jsx(Helpericon, { as: 'i', active: true, className: 'i-tab-nav-close', onClick: (e) => {
3953
+ e.stopPropagation();
3954
+ close(key);
3955
+ } }))] }, key));
3956
+ }), bar && (jsx("span", { ref: barRef, className: classNames("i-tab-navs-bar", barClass), style: state.barStyle }))] }), !hideMore && state.overflow && state.more.length > 0 && (jsx(Popup, { arrow: false, position: vertical ? "right" : "bottom", align: 'end', touchable: true, hideDelay: 500, content: jsx("div", { className: 'i-tabs-morelist pd-4', children: state.more.map((tab, i) => {
3957
+ const { key = i, title } = tab;
3958
+ const isActive = state.active === key;
3959
+ return (jsx("a", { className: classNames("i-tab-nav", {
3960
+ "i-tab-active": isActive,
3961
+ }), onClick: () => open(key), children: title }, key));
3962
+ }) }), children: renderMore(state.more) })), append] }), jsx("div", { className: 'i-tab-contents', children: state.tabs.map((tab, i) => {
3963
+ const { key = i, content } = tab;
3964
+ const isActive = state.active === key;
3965
+ const show = isActive ||
3966
+ (key !== undefined && state.cachedTabs.includes(key));
3967
+ return (show && (jsx("div", { className: classNames("i-tab-content", {
3968
+ "i-tab-active": isActive,
3969
+ }), children: content }, key)));
3970
+ }) })] }));
3971
+ });
3972
+ Tabs.Item = Item;
3973
+
3974
+ function TreeList(props) {
3975
+ const { data = [], depth = 0, round, style, className, parent, nodeProps, ...restProps } = props;
3976
+ const contents = data.map((item, i) => {
3977
+ const { type } = item;
3978
+ const title = item[nodeProps.title];
3979
+ const itemKey = item[nodeProps.key] ||
3980
+ (parent?.key !== undefined ? `${parent.key}-${i}` : `${i}`);
3981
+ item.key = itemKey;
3982
+ item.parent = parent;
3983
+ if (type === "title") {
3984
+ return (jsx("div", { className: 'i-tree-group-title', children: title }, i));
3985
+ }
3986
+ if (type && type !== "item") {
3987
+ return (jsx("div", { className: `i-tree-type-${type}`, children: title }, i));
3988
+ }
3989
+ return (jsx(TreeItem, { index: i, item: item, depth: depth, nodeProps: nodeProps, ...restProps }, itemKey));
3990
+ });
3991
+ if (depth > 0)
3992
+ return jsx(Fragment, { children: contents });
3993
+ return (jsx("div", { className: classNames("i-tree", className, {
3994
+ "i-tree-round": round,
3995
+ }), style: style, children: contents }));
3996
+ }
3997
+ const Header = (props) => {
3998
+ const { as: Tag = "a", href, selected, children, ...restProps } = props;
3999
+ const className = classNames("i-tree-item-header", {
4000
+ "i-tree-item-selected": selected,
4001
+ });
4002
+ if (typeof Tag === "string") {
4003
+ return (jsx(Tag, { href: href, className: className, ...restProps, children: children }));
4004
+ }
4005
+ return (jsx(Tag, { to: href || "", className: className, ...restProps, children: children }));
4006
+ };
4007
+ const TreeItem = (props) => {
4008
+ const { item, depth = 0, index, selected, checked = [], partofs = {}, checkable, nodeProps, renderExtra, onItemClick, onItemSelect, onItemCheck, ...restProps } = props;
4009
+ const { as, key = "", href, icon, title, expanded, disabled } = item;
4010
+ const children = item[nodeProps.children];
4011
+ const [expand, setExpand] = useState(expanded);
4012
+ const handleExpand = (e, fromToggle) => {
4013
+ if (fromToggle) {
4014
+ e.preventDefault();
4015
+ e.stopPropagation();
4016
+ }
4017
+ if (disabled || !children?.length)
4018
+ return;
4019
+ setExpand((v) => !v);
4020
+ };
4021
+ const handleItemClick = (e) => {
4022
+ if (disabled) {
4023
+ e.preventDefault();
4024
+ e.stopPropagation();
4025
+ return;
4026
+ }
4027
+ handleExpand(e);
4028
+ onItemClick?.(item, e);
4029
+ onItemSelect?.(key, item);
4030
+ };
4031
+ const handleItemCheck = (checked) => onItemCheck?.(item, checked, []);
4032
+ const itemChecked = checked.includes(key);
4033
+ return (jsxs("div", { className: classNames("i-tree-item", {
4034
+ "i-tree-expand": expand,
4035
+ }), children: [jsxs(Header, { as: as, href: href, style: { paddingLeft: `${depth * 1.5 + 0.5}em` }, selected: selected === key, onClick: handleItemClick, children: [checkable && (jsx(Checkbox.Item, { value: itemChecked, partof: !itemChecked && partofs[key], className: 'i-tree-checkbox', onChange: handleItemCheck, onClick: (e) => e.stopPropagation() })), icon && jsx("span", { className: 'i-tree-item-icon', children: icon }), jsx("span", { className: 'i-tree-item-title', children: title }), renderExtra?.(item), children && (jsx(Icon, { icon: jsx(KeyboardArrowDownRound, {}), className: 'i-tree-toggle', onClick: (e) => handleExpand(e, true) }))] }), children?.length && (jsx("div", { className: 'i-tree-item-content', children: jsx(TreeList, { data: children, depth: depth + 1, selected: selected, checkable: checkable, parent: item, partofs: partofs, checked: checked, nodeProps: nodeProps, renderExtra: renderExtra, onItemClick: onItemClick, onItemSelect: onItemSelect, onItemCheck: onItemCheck, ...restProps }) }))] }));
4036
+ };
4037
+
4038
+ const defaultNodeProps = {
4039
+ key: "key",
4040
+ title: "title",
4041
+ children: "children",
4042
+ };
4043
+ const Tree = (props) => {
4044
+ const { data = [], ref, selected, checked = [], disabledRelated, nodeProps, onItemSelect, onItemCheck, ...restProps } = props;
4045
+ const state = useReactive({
4046
+ selected,
4047
+ checked,
4048
+ partofs: {},
4049
+ nodeMaps: new Map(),
4050
+ });
4051
+ const oNodeProps = Object.assign({}, defaultNodeProps, nodeProps);
4052
+ const isChecked = (key) => state.checked.includes(key || "");
4053
+ const checkItem = (item, checked, direction) => {
4054
+ const { key = "", parent, children } = item;
4055
+ const shouldChanged = { [key]: checked };
4056
+ const partofs = { [key]: false };
4057
+ if (disabledRelated)
4058
+ return [shouldChanged];
4059
+ if (checked) {
4060
+ if (parent && direction !== "leaf") {
4061
+ const hasUnchecked = parent.children?.some((o) => o.key !== key && !isChecked(o.key));
4062
+ const [changes, parts] = checkItem(parent, true, "root");
4063
+ if (!hasUnchecked) {
4064
+ Object.assign(shouldChanged, changes);
4065
+ }
4066
+ Object.assign(partofs, hasUnchecked ? parts : {}, {
4067
+ [parent.key]: true,
4068
+ });
4069
+ }
4070
+ if (children?.length && direction !== "root") {
4071
+ children.map((o) => {
4072
+ if (isChecked(o.key))
4073
+ return;
4074
+ const [changes] = checkItem(o, true, "leaf");
4075
+ Object.assign(shouldChanged, changes);
4076
+ partofs[o.key] = false;
4077
+ });
4078
+ }
4079
+ return [shouldChanged, partofs];
4080
+ }
4081
+ if (parent && direction !== "leaf") {
4082
+ const [changes, parts] = checkItem(parent, false, "root");
4083
+ Object.assign(shouldChanged, changes);
4084
+ const hasChecked = parent.children?.some((o) => isChecked(o.key) && o.key !== key);
4085
+ Object.assign(partofs, hasChecked ? {} : parts, {
4086
+ [parent.key]: hasChecked,
4087
+ [key]: false,
4088
+ });
4089
+ }
4090
+ if (children?.length && direction !== "root") {
4091
+ children.map((o) => {
4092
+ const [changes] = checkItem(o, false, "leaf");
4093
+ if (!isChecked(o.key))
4094
+ return;
4095
+ Object.assign(shouldChanged, changes);
4096
+ partofs[o.key] = false;
4097
+ });
4098
+ }
4099
+ return [shouldChanged, partofs];
4100
+ };
4101
+ const handleCheck = (item, checked) => {
4102
+ const [shouldChanged, partofs] = checkItem(item, checked);
4103
+ const changedKeys = Object.keys(shouldChanged);
4104
+ state.checked = checked
4105
+ ? Array.from(new Set([...state.checked, ...changedKeys]))
4106
+ : state.checked.filter((k) => !changedKeys.includes(k));
4107
+ Object.assign(state.partofs, partofs);
4108
+ onItemCheck?.(item, checked, state.checked);
4109
+ };
4110
+ const handleSelect = (key, item) => {
4111
+ if (!props.selectable)
4112
+ return;
4113
+ state.selected = key;
4114
+ onItemSelect?.(key, item);
4115
+ };
4116
+ useEffect(() => {
4117
+ if (selected === undefined)
4118
+ return;
4119
+ state.selected = selected;
4120
+ }, [selected]);
4121
+ useEffect(() => {
4122
+ state.nodeMaps.clear();
4123
+ const { key, children } = oNodeProps;
4124
+ const recursive = (nodes) => {
4125
+ nodes.map((o) => {
4126
+ state.nodeMaps.set(o[key], o);
4127
+ o[children]?.length > 0 && recursive(o[children]);
4128
+ });
4129
+ };
4130
+ recursive(data);
4131
+ }, [data]);
4132
+ useImperativeHandle(ref, () => {
4133
+ return {
4134
+ getChecked: () => {
4135
+ const items = [];
4136
+ state.checked.map((k) => {
4137
+ const item = state.nodeMaps.get(k);
4138
+ items.push(item);
4139
+ });
4140
+ return [state.checked, items];
4141
+ },
4142
+ getSelected: () => {
4143
+ const item = state.nodeMaps.get(state.selected);
4144
+ return [state.selected, item];
4145
+ },
4146
+ getPartofs: () => {
4147
+ const items = [];
4148
+ const keys = Object.keys(state.partofs).filter((k) => {
4149
+ const indeterminate = state.partofs[k];
4150
+ if (indeterminate) {
4151
+ const item = state.nodeMaps.get(k);
4152
+ items.push(item);
4153
+ }
4154
+ return indeterminate;
4155
+ });
4156
+ return [keys, items];
4157
+ },
4158
+ };
4159
+ });
4160
+ return (jsx(TreeList, { data: data, selected: state.selected, checked: state.checked, partofs: state.partofs, nodeProps: oNodeProps, onItemCheck: handleCheck, onItemSelect: handleSelect, ...restProps }));
4161
+ };
4162
+
4163
+ const ListContainer = (props) => {
4164
+ const { sortable, onSortEnd, itemProps, ...restProps } = props;
4165
+ const customProps = {
4166
+ className: "i-upload-list",
4167
+ onClick: (e) => {
4168
+ e.stopPropagation();
4169
+ e.preventDefault();
4170
+ },
4171
+ };
4172
+ if (!sortable) {
4173
+ return jsx("div", { ...customProps, ...restProps });
4174
+ }
4175
+ return (jsx(SortableContainer, { draggedItemClassName: 'i-upload-item-dragged', onSortEnd: onSortEnd, ...customProps, ...restProps }));
4176
+ };
4177
+ const FileListItem = (props) => {
4178
+ const { ref, mode, index, file, renderItem, onRemove, onPreview } = props;
4179
+ if (!file)
4180
+ return "";
4181
+ const { id, name, size, url, src } = file;
4182
+ const type = getFileType(name, file.type);
4183
+ if (renderItem) {
4184
+ return renderItem(file, index);
4185
+ }
4186
+ const CloseBtn = (jsx(Helpericon, { active: true, className: 'i-upload-delete', onClick: (e) => {
4187
+ e.stopPropagation();
4188
+ e.preventDefault();
4189
+ onRemove(index);
4190
+ } }));
4191
+ switch (mode) {
4192
+ case "card":
4193
+ let node = jsx(Fragment, {});
4194
+ switch (type) {
4195
+ case TFileType.IMAGE:
4196
+ node = (jsx(Image, { lazyload: true, src: url || src, fit: 'cover', onMouseDown: (e) => e.preventDefault() }));
4197
+ break;
4198
+ case TFileType.VIDEO:
4199
+ node = jsx("video", { src: url || src, preload: 'none' });
4200
+ break;
4201
+ default:
4202
+ node = (jsxs(Fragment, { children: [jsx(Icon, { icon: jsx(ListAltRound, {}) }), jsx("span", { className: 'i-upload-file-name', children: title(name) })] }));
4203
+ break;
4204
+ }
4205
+ return (jsxs("div", { ref: ref, title: name, className: 'i-upload-item-card', onClick: () => onPreview?.(index), children: [node, CloseBtn] }));
4206
+ default:
4207
+ return (jsxs("div", { ref: ref, className: 'i-upload-item', onClick: () => onPreview?.(index), children: [jsx("span", { children: name }), jsx("i", { className: 'i-upload-size', children: formatBytes(size ?? 0) }), CloseBtn] }, id));
4208
+ }
4209
+ };
4210
+
4211
+ const Upload = (props) => {
4212
+ const { ref, label, labelInline, value, files = [], initialFiles, placeholder, status = "normal", message, className, style, children, defaultText = "Upload", mode = "default", cardSize = "4em", disabled, sortable, limit = props.multiple ? Infinity : 1, multiple, renderItem, shouldUpload = () => true, uploader, onChange, onFilesChange, onUpload, ...restProps } = props;
4213
+ const state = useReactive({
4214
+ files,
4215
+ value,
4216
+ status,
4217
+ message,
4218
+ });
4219
+ const inputRef = useRef(null);
4220
+ const preview = usePreview();
4221
+ const trigger = useMemo(() => {
4222
+ if (children)
4223
+ return children;
4224
+ switch (mode) {
4225
+ case "card":
4226
+ return (jsx(Button, { className: 'i-upload-card-btn color-5', square: true, flat: true, outline: true, disabled: disabled, children: jsx(Icon, { icon: jsx(PlusSharp, {}) }) }));
4227
+ default:
4228
+ return (jsx(Button, { className: 'i-upload-btn', disabled: disabled, children: defaultText }));
4229
+ }
4230
+ }, [mode, children]);
4231
+ const handleChange = (e) => {
4232
+ const files = Array.from(e.target.files || []);
4233
+ const { files: before } = state;
4234
+ const changed = [];
4235
+ files.map((f) => {
4236
+ const { id, name, size, type } = f;
4237
+ const same = before.find((pf) => {
4238
+ const { name: n, size: s, type: t } = pf;
4239
+ return n === name && s === size && t === type;
4240
+ });
4241
+ const src = URL.createObjectURL(f);
4242
+ Object.assign(f, {
4243
+ id: id ?? uid(7),
4244
+ src: src ?? f.name,
4245
+ url: src ?? f.name,
4246
+ });
4247
+ !same && changed.push(f);
4248
+ });
4249
+ const after = [...before, ...changed];
4250
+ Object.assign(state, {
4251
+ files: multiple ? after.slice(0, limit) : [after.at(-1)],
4252
+ status,
4253
+ message,
4254
+ });
4255
+ onFilesChange?.(state.files, changed, e);
4256
+ onChange?.(state.files, e);
4257
+ handleUpload(changed);
4258
+ inputRef.current && (inputRef.current.value = "");
4259
+ };
4260
+ const handleRemove = (i) => {
4261
+ const [...files] = state.files;
4262
+ const changed = files.splice(i, 1);
4263
+ URL.revokeObjectURL(changed[0]?.src || "");
4264
+ state.files = files;
4265
+ onFilesChange?.(files, changed);
4266
+ onChange?.(files);
4267
+ inputRef.current && (inputRef.current.value = "");
4268
+ };
4269
+ const handleUpload = async (files) => {
4270
+ if (!uploader)
4271
+ return;
4272
+ const shouldUploadFiles = files.filter(shouldUpload);
4273
+ const result = Promise.all(shouldUploadFiles.map(uploader));
4274
+ return onUpload?.(result);
4275
+ };
4276
+ const handlePreview = (i) => {
4277
+ preview({ items: state.files, initial: i });
4278
+ };
4279
+ const setFileList = (files) => {
4280
+ if (!files)
4281
+ return;
4282
+ state.files = files.map((f) => {
4283
+ return { ...f, id: f.id ?? uid(7) };
4284
+ });
4285
+ };
4286
+ const handleSortEnd = (before, after) => {
4287
+ const [...files] = state.files;
4288
+ state.files = arrayMove(files, before, after);
4289
+ onChange?.(state.files);
4290
+ };
4291
+ useEffect(() => {
4292
+ Object.assign(state, {
4293
+ status,
4294
+ message,
4295
+ });
4296
+ }, [status, message]);
4297
+ useEffect(() => {
4298
+ state.files = value?.filter?.((file) => !!file.id) ?? [];
4299
+ }, [value]);
4300
+ useEffect(() => {
4301
+ setFileList(initialFiles);
4302
+ }, []);
4303
+ useImperativeHandle(ref, () => ({
4304
+ getFileList: () => state.files,
4305
+ setFileList,
4306
+ }), []);
4307
+ return (jsx(InputContainer, { as: 'div', label: label, labelInline: labelInline, className: classNames("i-input-label-file", className), style: style, children: jsxs("div", { className: classNames("i-upload-inner", {
4308
+ [`i-upload-${mode}`]: mode !== "default",
4309
+ }), style: { ["--upload-card-size"]: cardSize }, children: [jsx(ListContainer, { sortable: sortable, onSortEnd: handleSortEnd, children: state.files.map((file, i) => {
4310
+ const node = (jsx(FileListItem, { index: i, file: file, mode: mode, renderItem: renderItem, onRemove: handleRemove, onPreview: handlePreview }, i));
4311
+ if (!sortable)
4312
+ return node;
4313
+ return jsx(SortableItem, { children: node }, i);
4314
+ }) }), state.message && (jsx("span", { className: 'i-upload-message', children: state.message })), state.files.length < limit && (jsxs("label", { children: [jsx("input", { ...restProps, disabled: disabled, ref: inputRef, type: 'file', className: 'i-input-file-hidden', multiple: multiple, onChange: handleChange }), trigger] }))] }) }));
4315
+ };
4316
+
4317
+ export { Affix, Badge, Button, Card, Checkbox, Collapse, ColorPicker, Datagrid, Datepicker as DatePicker, Description, Drawer, Dropdown, Editor, Flex, Form, Icon, Image, Input, List$1 as List, Loading, message as Message, Modal, Pagination, Popconfirm, Popup, Progress, Radio, Resizable, Select, Step, Swiper, Tabs, Tag, Text, TimePicker, Tree, Upload, Video, usePreview };