@ioca/react 1.3.2 → 1.3.4

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 (389) hide show
  1. package/lib/components/affix/affix.js +2 -0
  2. package/lib/components/affix/affix.js.map +1 -0
  3. package/lib/components/affix/index.js +2 -0
  4. package/lib/components/affix/index.js.map +1 -0
  5. package/lib/components/affix/totop.js +2 -0
  6. package/lib/components/affix/totop.js.map +1 -0
  7. package/lib/components/badge/badge.js +2 -0
  8. package/lib/components/badge/badge.js.map +1 -0
  9. package/lib/components/badge/index.js +2 -0
  10. package/lib/components/badge/index.js.map +1 -0
  11. package/lib/components/button/button.js +2 -0
  12. package/lib/components/button/button.js.map +1 -0
  13. package/lib/components/button/group.js +2 -0
  14. package/lib/components/button/group.js.map +1 -0
  15. package/lib/components/button/index.js +2 -0
  16. package/lib/components/button/index.js.map +1 -0
  17. package/lib/components/button/toggle.js +2 -0
  18. package/lib/components/button/toggle.js.map +1 -0
  19. package/lib/components/card/card.js +2 -0
  20. package/lib/components/card/card.js.map +1 -0
  21. package/lib/components/card/index.js +2 -0
  22. package/lib/components/card/index.js.map +1 -0
  23. package/lib/components/checkbox/checkbox.js +2 -0
  24. package/lib/components/checkbox/checkbox.js.map +1 -0
  25. package/lib/components/checkbox/index.js +2 -0
  26. package/lib/components/checkbox/index.js.map +1 -0
  27. package/lib/components/checkbox/item.js +2 -0
  28. package/lib/components/checkbox/item.js.map +1 -0
  29. package/lib/components/collapse/collapse.js +2 -0
  30. package/lib/components/collapse/collapse.js.map +1 -0
  31. package/lib/components/collapse/index.js +2 -0
  32. package/lib/components/collapse/index.js.map +1 -0
  33. package/lib/components/collapse/item.js +2 -0
  34. package/lib/components/collapse/item.js.map +1 -0
  35. package/lib/components/datagrid/cell.js +2 -0
  36. package/lib/components/datagrid/cell.js.map +1 -0
  37. package/lib/components/datagrid/datagrid.js +2 -0
  38. package/lib/components/datagrid/datagrid.js.map +1 -0
  39. package/lib/components/datagrid/index.js +2 -0
  40. package/lib/components/datagrid/index.js.map +1 -0
  41. package/lib/components/datagrid/resize.js +2 -0
  42. package/lib/components/datagrid/resize.js.map +1 -0
  43. package/lib/components/datagrid/row.js +2 -0
  44. package/lib/components/datagrid/row.js.map +1 -0
  45. package/lib/components/datagrid/sorter.js +2 -0
  46. package/lib/components/datagrid/sorter.js.map +1 -0
  47. package/lib/components/description/description.js +2 -0
  48. package/lib/components/description/description.js.map +1 -0
  49. package/lib/components/description/index.js +2 -0
  50. package/lib/components/description/index.js.map +1 -0
  51. package/lib/components/drawer/drawer.js +2 -0
  52. package/lib/components/drawer/drawer.js.map +1 -0
  53. package/lib/components/drawer/index.js +2 -0
  54. package/lib/components/drawer/index.js.map +1 -0
  55. package/lib/components/dropdown/dropdown.js +2 -0
  56. package/lib/components/dropdown/dropdown.js.map +1 -0
  57. package/lib/components/dropdown/index.js +2 -0
  58. package/lib/components/dropdown/index.js.map +1 -0
  59. package/lib/components/dropdown/item.js +2 -0
  60. package/lib/components/dropdown/item.js.map +1 -0
  61. package/lib/components/editor/controls.js +2 -0
  62. package/lib/components/editor/controls.js.map +1 -0
  63. package/lib/components/editor/editor.js +2 -0
  64. package/lib/components/editor/editor.js.map +1 -0
  65. package/lib/components/editor/index.js +2 -0
  66. package/lib/components/editor/index.js.map +1 -0
  67. package/lib/components/flex/flex.js +2 -0
  68. package/lib/components/flex/flex.js.map +1 -0
  69. package/lib/components/flex/index.js +2 -0
  70. package/lib/components/flex/index.js.map +1 -0
  71. package/lib/components/form/context.js +2 -0
  72. package/lib/components/form/context.js.map +1 -0
  73. package/lib/components/form/field.js +2 -0
  74. package/lib/components/form/field.js.map +1 -0
  75. package/lib/components/form/form.js +2 -0
  76. package/lib/components/form/form.js.map +1 -0
  77. package/lib/components/form/index.js +2 -0
  78. package/lib/components/form/index.js.map +1 -0
  79. package/lib/components/form/useForm.js +2 -0
  80. package/lib/components/form/useForm.js.map +1 -0
  81. package/lib/components/icon/icon.js +2 -0
  82. package/lib/components/icon/icon.js.map +1 -0
  83. package/lib/components/icon/index.js +2 -0
  84. package/lib/components/icon/index.js.map +1 -0
  85. package/lib/components/image/image.js +2 -0
  86. package/lib/components/image/image.js.map +1 -0
  87. package/lib/components/image/index.js +2 -0
  88. package/lib/components/image/index.js.map +1 -0
  89. package/lib/components/image/list.js +2 -0
  90. package/lib/components/image/list.js.map +1 -0
  91. package/lib/components/input/container.js +2 -0
  92. package/lib/components/input/container.js.map +1 -0
  93. package/lib/components/input/index.js +2 -0
  94. package/lib/components/input/index.js.map +1 -0
  95. package/lib/components/input/input.js +2 -0
  96. package/lib/components/input/input.js.map +1 -0
  97. package/lib/components/input/number.js +2 -0
  98. package/lib/components/input/number.js.map +1 -0
  99. package/lib/components/input/range.js +2 -0
  100. package/lib/components/input/range.js.map +1 -0
  101. package/lib/components/input/textarea.js +2 -0
  102. package/lib/components/input/textarea.js.map +1 -0
  103. package/lib/components/list/index.js +2 -0
  104. package/lib/components/list/index.js.map +1 -0
  105. package/lib/components/list/item.js +2 -0
  106. package/lib/components/list/item.js.map +1 -0
  107. package/lib/components/list/list.js +2 -0
  108. package/lib/components/list/list.js.map +1 -0
  109. package/lib/components/loading/index.js +2 -0
  110. package/lib/components/loading/index.js.map +1 -0
  111. package/lib/components/loading/loading.js +2 -0
  112. package/lib/components/loading/loading.js.map +1 -0
  113. package/lib/components/message/index.js +2 -0
  114. package/lib/components/message/index.js.map +1 -0
  115. package/lib/components/message/message.js +2 -0
  116. package/lib/components/message/message.js.map +1 -0
  117. package/lib/components/modal/hookModal.js +2 -0
  118. package/lib/components/modal/hookModal.js.map +1 -0
  119. package/lib/components/modal/index.js +2 -0
  120. package/lib/components/modal/index.js.map +1 -0
  121. package/lib/components/modal/modal.js +2 -0
  122. package/lib/components/modal/modal.js.map +1 -0
  123. package/lib/components/modal/useModal.js +2 -0
  124. package/lib/components/modal/useModal.js.map +1 -0
  125. package/lib/components/pagination/index.js +2 -0
  126. package/lib/components/pagination/index.js.map +1 -0
  127. package/lib/components/pagination/page.js +2 -0
  128. package/lib/components/pagination/page.js.map +1 -0
  129. package/lib/components/pagination/pagination.js +2 -0
  130. package/lib/components/pagination/pagination.js.map +1 -0
  131. package/lib/components/picker/colors/footer.js +2 -0
  132. package/lib/components/picker/colors/footer.js.map +1 -0
  133. package/lib/components/picker/colors/handle.js +2 -0
  134. package/lib/components/picker/colors/handle.js.map +1 -0
  135. package/lib/components/picker/colors/index.js +2 -0
  136. package/lib/components/picker/colors/index.js.map +1 -0
  137. package/lib/components/picker/dates/dates.js +2 -0
  138. package/lib/components/picker/dates/dates.js.map +1 -0
  139. package/lib/components/picker/dates/index.js +2 -0
  140. package/lib/components/picker/dates/index.js.map +1 -0
  141. package/lib/components/picker/dates/panel.js +2 -0
  142. package/lib/components/picker/dates/panel.js.map +1 -0
  143. package/lib/components/picker/time/index.js +2 -0
  144. package/lib/components/picker/time/index.js.map +1 -0
  145. package/lib/components/picker/time/item.js +2 -0
  146. package/lib/components/picker/time/item.js.map +1 -0
  147. package/lib/components/picker/time/panel.js +2 -0
  148. package/lib/components/picker/time/panel.js.map +1 -0
  149. package/lib/components/popconfirm/index.js +2 -0
  150. package/lib/components/popconfirm/index.js.map +1 -0
  151. package/lib/components/popconfirm/popconfirm.js +2 -0
  152. package/lib/components/popconfirm/popconfirm.js.map +1 -0
  153. package/lib/components/popup/content.js +2 -0
  154. package/lib/components/popup/content.js.map +1 -0
  155. package/lib/components/popup/index.js +2 -0
  156. package/lib/components/popup/index.js.map +1 -0
  157. package/lib/components/popup/popup.js +2 -0
  158. package/lib/components/popup/popup.js.map +1 -0
  159. package/lib/components/progress/circle.js +2 -0
  160. package/lib/components/progress/circle.js.map +1 -0
  161. package/lib/components/progress/index.js +2 -0
  162. package/lib/components/progress/index.js.map +1 -0
  163. package/lib/components/progress/line.js +2 -0
  164. package/lib/components/progress/line.js.map +1 -0
  165. package/lib/components/progress/progress.js +2 -0
  166. package/lib/components/progress/progress.js.map +1 -0
  167. package/lib/components/radio/index.js +2 -0
  168. package/lib/components/radio/index.js.map +1 -0
  169. package/lib/components/radio/item.js +2 -0
  170. package/lib/components/radio/item.js.map +1 -0
  171. package/lib/components/radio/radio.js +2 -0
  172. package/lib/components/radio/radio.js.map +1 -0
  173. package/lib/components/resizable/index.js +2 -0
  174. package/lib/components/resizable/index.js.map +1 -0
  175. package/lib/components/resizable/resizable.js +2 -0
  176. package/lib/components/resizable/resizable.js.map +1 -0
  177. package/lib/components/select/index.js +2 -0
  178. package/lib/components/select/index.js.map +1 -0
  179. package/lib/components/select/options.js +2 -0
  180. package/lib/components/select/options.js.map +1 -0
  181. package/lib/components/select/select.js +2 -0
  182. package/lib/components/select/select.js.map +1 -0
  183. package/lib/components/step/divider.js +2 -0
  184. package/lib/components/step/divider.js.map +1 -0
  185. package/lib/components/step/index.js +2 -0
  186. package/lib/components/step/index.js.map +1 -0
  187. package/lib/components/step/item.js +2 -0
  188. package/lib/components/step/item.js.map +1 -0
  189. package/lib/components/step/step.js +2 -0
  190. package/lib/components/step/step.js.map +1 -0
  191. package/lib/components/swiper/index.js +2 -0
  192. package/lib/components/swiper/index.js.map +1 -0
  193. package/lib/components/swiper/item.js +2 -0
  194. package/lib/components/swiper/item.js.map +1 -0
  195. package/lib/components/swiper/swiper.js +2 -0
  196. package/lib/components/swiper/swiper.js.map +1 -0
  197. package/lib/components/tabs/index.js +2 -0
  198. package/lib/components/tabs/index.js.map +1 -0
  199. package/lib/components/tabs/item.js +2 -0
  200. package/lib/components/tabs/item.js.map +1 -0
  201. package/lib/components/tabs/tabs.js +2 -0
  202. package/lib/components/tabs/tabs.js.map +1 -0
  203. package/lib/components/tag/index.js +2 -0
  204. package/lib/components/tag/index.js.map +1 -0
  205. package/lib/components/tag/tag.js +2 -0
  206. package/lib/components/tag/tag.js.map +1 -0
  207. package/lib/components/text/highlight.js +2 -0
  208. package/lib/components/text/highlight.js.map +1 -0
  209. package/lib/components/text/index.js +2 -0
  210. package/lib/components/text/index.js.map +1 -0
  211. package/lib/components/text/number.js +2 -0
  212. package/lib/components/text/number.js.map +1 -0
  213. package/lib/components/text/text.js +2 -0
  214. package/lib/components/text/text.js.map +1 -0
  215. package/lib/components/text/time.js +2 -0
  216. package/lib/components/text/time.js.map +1 -0
  217. package/lib/components/tree/index.js +2 -0
  218. package/lib/components/tree/index.js.map +1 -0
  219. package/lib/components/tree/item.js +2 -0
  220. package/lib/components/tree/item.js.map +1 -0
  221. package/lib/components/tree/tree.js +2 -0
  222. package/lib/components/tree/tree.js.map +1 -0
  223. package/lib/components/upload/index.js +2 -0
  224. package/lib/components/upload/index.js.map +1 -0
  225. package/lib/components/upload/renderFile.js +2 -0
  226. package/lib/components/upload/renderFile.js.map +1 -0
  227. package/lib/components/upload/upload.js +2 -0
  228. package/lib/components/upload/upload.js.map +1 -0
  229. package/lib/components/utils/empty/index.js +2 -0
  230. package/lib/components/utils/empty/index.js.map +1 -0
  231. package/lib/components/utils/helpericon/helpericon.js +2 -0
  232. package/lib/components/utils/helpericon/helpericon.js.map +1 -0
  233. package/lib/components/utils/helpericon/index.js +2 -0
  234. package/lib/components/utils/helpericon/index.js.map +1 -0
  235. package/lib/components/video/index.js +2 -0
  236. package/lib/components/video/index.js.map +1 -0
  237. package/lib/components/video/video.js +2 -0
  238. package/lib/components/video/video.js.map +1 -0
  239. package/lib/css/index.css +1 -1
  240. package/lib/css/index.css.map +1 -1
  241. package/lib/index.js +1 -1
  242. package/lib/index.js.map +1 -1
  243. package/lib/js/hooks.js +2 -0
  244. package/lib/js/hooks.js.map +1 -0
  245. package/lib/js/usePreview/content.js +2 -0
  246. package/lib/js/usePreview/content.js.map +1 -0
  247. package/lib/js/usePreview/index.js +2 -0
  248. package/lib/js/usePreview/index.js.map +1 -0
  249. package/lib/js/usePreview/renderFile.js +2 -0
  250. package/lib/js/usePreview/renderFile.js.map +1 -0
  251. package/lib/js/usePreview/type.js +2 -0
  252. package/lib/js/usePreview/type.js.map +1 -0
  253. package/lib/js/useRipple/index.js +2 -0
  254. package/lib/js/useRipple/index.js.map +1 -0
  255. package/lib/js/utils.js +2 -0
  256. package/lib/js/utils.js.map +1 -0
  257. package/lib/types/components/affix/affix.d.ts +12 -0
  258. package/lib/types/components/affix/index.d.ts +7 -0
  259. package/lib/types/components/affix/totop.d.ts +8 -0
  260. package/lib/types/components/affix/type.d.ts +15 -0
  261. package/lib/types/components/badge/badge.d.ts +8 -0
  262. package/lib/types/components/badge/index.d.ts +7 -0
  263. package/lib/types/components/badge/type.d.ts +17 -0
  264. package/lib/types/components/button/button.d.ts +7 -0
  265. package/lib/types/components/button/group.d.ts +8 -0
  266. package/lib/types/components/button/index.d.ts +7 -0
  267. package/lib/types/components/button/toggle.d.ts +8 -0
  268. package/lib/types/components/button/type.d.ts +46 -0
  269. package/lib/types/components/card/card.d.ts +8 -0
  270. package/lib/types/components/card/index.d.ts +7 -0
  271. package/lib/types/components/card/type.d.ts +15 -0
  272. package/lib/types/components/checkbox/checkbox.d.ts +12 -0
  273. package/lib/types/components/checkbox/index.d.ts +7 -0
  274. package/lib/types/components/checkbox/item.d.ts +8 -0
  275. package/lib/types/components/checkbox/type.d.ts +26 -0
  276. package/lib/types/components/collapse/collapse.d.ts +12 -0
  277. package/lib/types/components/collapse/index.d.ts +7 -0
  278. package/lib/types/components/collapse/item.d.ts +8 -0
  279. package/lib/types/components/collapse/type.d.ts +25 -0
  280. package/lib/types/components/datagrid/datagrid.d.ts +8 -0
  281. package/lib/types/components/datagrid/index.d.ts +7 -0
  282. package/lib/types/components/datagrid/type.d.ts +42 -0
  283. package/lib/types/components/description/description.d.ts +8 -0
  284. package/lib/types/components/description/index.d.ts +7 -0
  285. package/lib/types/components/description/type.d.ts +27 -0
  286. package/lib/types/components/drawer/drawer.d.ts +7 -0
  287. package/lib/types/components/drawer/index.d.ts +7 -0
  288. package/lib/types/components/drawer/type.d.ts +18 -0
  289. package/lib/types/components/dropdown/dropdown.d.ts +11 -0
  290. package/lib/types/components/dropdown/index.d.ts +7 -0
  291. package/lib/types/components/dropdown/type.d.ts +15 -0
  292. package/lib/types/components/editor/editor.d.ts +8 -0
  293. package/lib/types/components/editor/index.d.ts +7 -0
  294. package/lib/types/components/editor/type.d.ts +21 -0
  295. package/lib/types/components/flex/flex.d.ts +7 -0
  296. package/lib/types/components/flex/index.d.ts +7 -0
  297. package/lib/types/components/flex/type.d.ts +15 -0
  298. package/lib/types/components/form/field.d.ts +8 -0
  299. package/lib/types/components/form/form.d.ts +14 -0
  300. package/lib/types/components/form/index.d.ts +7 -0
  301. package/lib/types/components/form/type.d.ts +32 -0
  302. package/lib/types/components/form/useForm.d.ts +19 -0
  303. package/lib/types/components/icon/icon.d.ts +8 -0
  304. package/lib/types/components/icon/index.d.ts +7 -0
  305. package/lib/types/components/icon/type.d.ts +14 -0
  306. package/lib/types/components/image/image.d.ts +7 -0
  307. package/lib/types/components/image/index.d.ts +7 -0
  308. package/lib/types/components/image/list.d.ts +8 -0
  309. package/lib/types/components/image/type.d.ts +30 -0
  310. package/lib/types/components/input/index.d.ts +7 -0
  311. package/lib/types/components/input/input.d.ts +7 -0
  312. package/lib/types/components/input/number.d.ts +8 -0
  313. package/lib/types/components/input/range.d.ts +8 -0
  314. package/lib/types/components/input/textarea.d.ts +8 -0
  315. package/lib/types/components/input/type.d.ts +48 -0
  316. package/lib/types/components/list/index.d.ts +7 -0
  317. package/lib/types/components/list/list.d.ts +11 -0
  318. package/lib/types/components/list/type.d.ts +17 -0
  319. package/lib/types/components/loading/index.d.ts +7 -0
  320. package/lib/types/components/loading/loading.d.ts +8 -0
  321. package/lib/types/components/loading/type.d.ts +12 -0
  322. package/lib/types/components/message/index.d.ts +7 -0
  323. package/lib/types/components/message/message.d.ts +26 -0
  324. package/lib/types/components/message/type.d.ts +23 -0
  325. package/lib/types/components/modal/index.d.ts +7 -0
  326. package/lib/types/components/modal/modal.d.ts +7 -0
  327. package/lib/types/components/modal/type.d.ts +33 -0
  328. package/lib/types/components/modal/useModal.d.ts +11 -0
  329. package/lib/types/components/pagination/index.d.ts +7 -0
  330. package/lib/types/components/pagination/pagination.d.ts +8 -0
  331. package/lib/types/components/pagination/type.d.ts +20 -0
  332. package/lib/types/components/picker/colors/index.d.ts +8 -0
  333. package/lib/types/components/picker/dates/index.d.ts +8 -0
  334. package/lib/types/components/picker/time/index.d.ts +8 -0
  335. package/lib/types/components/picker/type.d.ts +43 -0
  336. package/lib/types/components/popconfirm/index.d.ts +7 -0
  337. package/lib/types/components/popconfirm/popconfirm.d.ts +8 -0
  338. package/lib/types/components/popconfirm/type.d.ts +16 -0
  339. package/lib/types/components/popup/index.d.ts +7 -0
  340. package/lib/types/components/popup/popup.d.ts +8 -0
  341. package/lib/types/components/popup/type.d.ts +31 -0
  342. package/lib/types/components/progress/index.d.ts +7 -0
  343. package/lib/types/components/progress/progress.d.ts +8 -0
  344. package/lib/types/components/progress/type.d.ts +25 -0
  345. package/lib/types/components/radio/index.d.ts +7 -0
  346. package/lib/types/components/radio/item.d.ts +8 -0
  347. package/lib/types/components/radio/radio.d.ts +12 -0
  348. package/lib/types/components/radio/type.d.ts +22 -0
  349. package/lib/types/components/resizable/index.d.ts +7 -0
  350. package/lib/types/components/resizable/resizable.d.ts +8 -0
  351. package/lib/types/components/resizable/type.d.ts +21 -0
  352. package/lib/types/components/select/index.d.ts +7 -0
  353. package/lib/types/components/select/select.d.ts +8 -0
  354. package/lib/types/components/select/type.d.ts +24 -0
  355. package/lib/types/components/step/index.d.ts +7 -0
  356. package/lib/types/components/step/item.d.ts +8 -0
  357. package/lib/types/components/step/step.d.ts +12 -0
  358. package/lib/types/components/step/type.d.ts +21 -0
  359. package/lib/types/components/swiper/index.d.ts +7 -0
  360. package/lib/types/components/swiper/item.d.ts +8 -0
  361. package/lib/types/components/swiper/swiper.d.ts +7 -0
  362. package/lib/types/components/swiper/type.d.ts +54 -0
  363. package/lib/types/components/tabs/index.d.ts +7 -0
  364. package/lib/types/components/tabs/item.d.ts +8 -0
  365. package/lib/types/components/tabs/tabs.d.ts +7 -0
  366. package/lib/types/components/tabs/type.d.ts +46 -0
  367. package/lib/types/components/tag/index.d.ts +7 -0
  368. package/lib/types/components/tag/tag.d.ts +8 -0
  369. package/lib/types/components/tag/type.d.ts +16 -0
  370. package/lib/types/components/text/highlight.d.ts +8 -0
  371. package/lib/types/components/text/index.d.ts +7 -0
  372. package/lib/types/components/text/number.d.ts +8 -0
  373. package/lib/types/components/text/text.d.ts +7 -0
  374. package/lib/types/components/text/time.d.ts +8 -0
  375. package/lib/types/components/text/type.d.ts +45 -0
  376. package/lib/types/components/tree/index.d.ts +7 -0
  377. package/lib/types/components/tree/tree.d.ts +8 -0
  378. package/lib/types/components/tree/type.d.ts +50 -0
  379. package/lib/types/components/upload/index.d.ts +7 -0
  380. package/lib/types/components/upload/type.d.ts +38 -0
  381. package/lib/types/components/upload/upload.d.ts +8 -0
  382. package/lib/types/components/video/index.d.ts +7 -0
  383. package/lib/types/components/video/type.d.ts +29 -0
  384. package/lib/types/components/video/video.d.ts +8 -0
  385. package/lib/types/index.d.ts +41 -1021
  386. package/lib/types/js/usePreview/index.d.ts +7 -0
  387. package/lib/types/js/usePreview/type.d.ts +32 -0
  388. package/lib/types/type/index.d.ts +30 -0
  389. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ import{useEffect as e}from"react";const n=new Set,t=new Set,o=new Set,s="ontouchend"in document,c={MOVE:s?"touchmove":"mousemove",UP:s?"touchend":"mouseup",KEYDOWN:"keydown"};function r(t,o){e((()=>(n.add(t),()=>{n.delete(t)})),[t])}function u(n,o){e((()=>(t.add(n),()=>{t.delete(n)})),[n])}function d(n,t){e((()=>{if(!t?.disabled)return o.add(n),()=>{o.delete(n)}}),[n])}function i(e){const n=new WeakMap,t=new IntersectionObserver((e=>{e.map((e=>{const t=n.get(e.target);t?.(e.target,e.isIntersecting)}))}),e);return{observe:function(e,o){n.get(e)||(n.set(e,o),e&&t.observe(e))},unobserve:function(e){e&&t.unobserve(e),n.delete(e)},disconnect:function(){t.disconnect()}}}function a(){const e=new WeakMap,n=new ResizeObserver((n=>{n.map((n=>{const t=e.get(n.target);t?.(n.target)}))}));return{observe:function(t,o){e.get(t)||(t&&n.observe(t),e.set(t,o))},unobserve:function(t){t&&n.unobserve(t),e.delete(t)},disconnect:function(){n.disconnect()}}}document.addEventListener(c.MOVE,(e=>{for(const t of n.values())t(e)}),{passive:!1}),document.addEventListener(c.UP,(e=>{for(const n of t.values())n(e)})),document.addEventListener(c.KEYDOWN,(e=>{for(const n of o.values())n(e)}));export{i as useIntersectionObserver,d as useKeydown,r as useMouseMove,u as useMouseUp,a as useResizeObserver};
2
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sources":["../../packages/js/hooks.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\ntype TMouseEvent = (e: MouseEvent) => void;\ntype TKeyboardEvent = (e: KeyboardEvent) => void;\ntype TEventOption = {\n\tdisabled?: boolean;\n};\n\nconst ClickEvents = new Set<TMouseEvent>();\nconst MouseMoveEvents = new Set<TMouseEvent>();\nconst MouseUpEvents = new Set<TMouseEvent>();\nconst KeydownEvents = new Set<TKeyboardEvent>();\n\nconst touchable = \"ontouchend\" in document;\nconst EVENTS: any = {\n\tMOVE: touchable ? \"touchmove\" : \"mousemove\",\n\tUP: touchable ? \"touchend\" : \"mouseup\",\n\tKEYDOWN: \"keydown\",\n};\n\ndocument.addEventListener(\n\tEVENTS.MOVE,\n\t(e: MouseEvent) => {\n\t\tfor (const listener of MouseMoveEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t},\n\t{ passive: false }\n);\n\ndocument.addEventListener(EVENTS.UP, (e) => {\n\tfor (const listener of MouseUpEvents.values()) {\n\t\tlistener(e);\n\t}\n});\n\ndocument.addEventListener(EVENTS.KEYDOWN, (e) => {\n\tfor (const listener of KeydownEvents.values()) {\n\t\tlistener(e);\n\t}\n});\n\nexport function useMouseMove(listener: TMouseEvent, options?: TEventOption) {\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseMoveEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseMoveEvents.delete(listener);\n\t\t};\n\t}, [listener]);\n}\n\nexport function useMouseUp(listener: TMouseEvent, options?: TEventOption) {\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseUpEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseUpEvents.delete(listener);\n\t\t};\n\t}, [listener]);\n}\n\nexport function useKeydown(listener: TKeyboardEvent, options?: TEventOption) {\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tKeydownEvents.add(listener);\n\t\treturn () => {\n\t\t\tKeydownEvents.delete(listener);\n\t\t};\n\t}, [listener]);\n}\n\nexport function useIntersectionObserver(configs?: IntersectionObserverInit) {\n\tconst WM = new WeakMap();\n\tconst IO = new IntersectionObserver((entries) => {\n\t\tentries.map((entry) => {\n\t\t\tconst callback = WM.get(entry.target);\n\n\t\t\tcallback?.(entry.target, entry.isIntersecting);\n\t\t});\n\t}, configs);\n\n\tfunction observe(target: HTMLElement, callback: Function) {\n\t\tif (WM.get(target)) return;\n\n\t\tWM.set(target, callback);\n\t\ttarget && IO.observe(target);\n\t}\n\n\tfunction unobserve(target: HTMLElement) {\n\t\ttarget && IO.unobserve(target);\n\t\tWM.delete(target);\n\t}\n\n\tfunction disconnect() {\n\t\tIO.disconnect();\n\t}\n\n\treturn {\n\t\tobserve,\n\t\tunobserve,\n\t\tdisconnect,\n\t};\n}\n\nexport function useResizeObserver() {\n\tconst WM = new WeakMap();\n\tconst IO = new ResizeObserver((entries) => {\n\t\tentries.map((entry) => {\n\t\t\tconst callback = WM.get(entry.target);\n\n\t\t\tcallback?.(entry.target);\n\t\t});\n\t});\n\n\tfunction observe(target: HTMLElement, callback: Function) {\n\t\tif (WM.get(target)) return;\n\n\t\ttarget && IO.observe(target);\n\t\tWM.set(target, callback);\n\t}\n\n\tfunction unobserve(target: HTMLElement) {\n\t\ttarget && IO.unobserve(target);\n\t\tWM.delete(target);\n\t}\n\n\tfunction disconnect() {\n\t\tIO.disconnect();\n\t}\n\n\treturn {\n\t\tobserve,\n\t\tunobserve,\n\t\tdisconnect,\n\t};\n}\n"],"names":["MouseMoveEvents","Set","MouseUpEvents","KeydownEvents","touchable","document","EVENTS","MOVE","UP","KEYDOWN","useMouseMove","listener","options","useEffect","add","delete","useMouseUp","useKeydown","disabled","useIntersectionObserver","configs","WM","WeakMap","IO","IntersectionObserver","entries","map","entry","callback","get","target","isIntersecting","observe","set","unobserve","disconnect","useResizeObserver","ResizeObserver","addEventListener","e","values","passive"],"mappings":"kCASA,MAAMA,EAAkB,IAAIC,IACtBC,EAAgB,IAAID,IACpBE,EAAgB,IAAIF,IAEpBG,EAAY,eAAgBC,SAC5BC,EAAc,CACnBC,KAAMH,EAAY,YAAc,YAChCI,GAAIJ,EAAY,WAAa,UAC7BK,QAAS,WAyBM,SAAAC,EAAaC,EAAuBC,GACnDC,GAAU,KAGTb,EAAgBc,IAAIH,GACb,KACNX,EAAgBe,OAAOJ,EAAS,IAE/B,CAACA,GACL,CAEgB,SAAAK,EAAWL,EAAuBC,GACjDC,GAAU,KAGTX,EAAcY,IAAIH,GACX,KACNT,EAAca,OAAOJ,EAAS,IAE7B,CAACA,GACL,CAEgB,SAAAM,EAAWN,EAA0BC,GACpDC,GAAU,KACT,IAAID,GAASM,SAGb,OADAf,EAAcW,IAAIH,GACX,KACNR,EAAcY,OAAOJ,EAAS,CAC9B,GACC,CAACA,GACL,CAEM,SAAUQ,EAAwBC,GACvC,MAAMC,EAAK,IAAIC,QACTC,EAAK,IAAIC,sBAAsBC,IACpCA,EAAQC,KAAKC,IACZ,MAAMC,EAAWP,EAAGQ,IAAIF,EAAMG,QAE9BF,IAAWD,EAAMG,OAAQH,EAAMI,eAAe,GAC7C,GACAX,GAkBH,MAAO,CACNY,QAjBD,SAAiBF,EAAqBF,GACjCP,EAAGQ,IAAIC,KAEXT,EAAGY,IAAIH,EAAQF,GACfE,GAAUP,EAAGS,QAAQF,KAcrBI,UAXD,SAAmBJ,GAClBA,GAAUP,EAAGW,UAAUJ,GACvBT,EAAGN,OAAOe,IAUVK,WAPD,WACCZ,EAAGY,cAQL,UAEgBC,IACf,MAAMf,EAAK,IAAIC,QACTC,EAAK,IAAIc,gBAAgBZ,IAC9BA,EAAQC,KAAKC,IACZ,MAAMC,EAAWP,EAAGQ,IAAIF,EAAMG,QAE9BF,IAAWD,EAAMG,OAAO,GACvB,IAmBH,MAAO,CACNE,QAjBD,SAAiBF,EAAqBF,GACjCP,EAAGQ,IAAIC,KAEXA,GAAUP,EAAGS,QAAQF,GACrBT,EAAGY,IAAIH,EAAQF,KAcfM,UAXD,SAAmBJ,GAClBA,GAAUP,EAAGW,UAAUJ,GACvBT,EAAGN,OAAOe,IAUVK,WAPD,WACCZ,EAAGY,cAQL,CAvHA9B,SAASiC,iBACRhC,EAAOC,MACNgC,IACA,IAAK,MAAM5B,KAAYX,EAAgBwC,SACtC7B,EAAS4B,KAGX,CAAEE,SAAS,IAGZpC,SAASiC,iBAAiBhC,EAAOE,IAAK+B,IACrC,IAAK,MAAM5B,KAAYT,EAAcsC,SACpC7B,EAAS4B,MAIXlC,SAASiC,iBAAiBhC,EAAOG,SAAU8B,IAC1C,IAAK,MAAM5B,KAAYR,EAAcqC,SACpC7B,EAAS4B"}
@@ -0,0 +1,2 @@
1
+ import{jsxs as r,Fragment as t,jsx as e}from"react/jsx-runtime";import"../../components/button/index.js";import n from"../../components/icon/icon.js";import{CloseRound as o,AspectRatioRound as a,OpenInNewRound as i,FileDownloadOutlined as c,RotateRightRound as l,RotateLeftRound as s,KeyboardArrowLeftRound as d,KeyboardArrowRightRound as u}from"@ricons/material";import{useReactive as m}from"ahooks";import p from"classnames";import{throttle as f}from"radash";import{useRef as g,useMemo as h}from"react";import{useMouseMove as k,useMouseUp as j}from"../hooks.js";import{getSuffixByUrl as v,getFileType as C}from"../utils.js";import x from"./renderFile.js";import{TFileType as q}from"./type.js";import b from"../../components/button/button.js";function y(y){const{items:H=[],initial:w=0,renderFile:N=x,onRotate:$,onChange:D,onClose:F,onZoom:Y}=y,M=m({current:w,rotate:0,scale:1,translate:[0,0],start:[0,0],dragging:!1,controlHidden:!0}),T=g(null),X=g([0,0]),_=g(null),A=h((()=>H.map((r=>{const t={src:""};return"string"==typeof r?t.src=r:Object.assign(t,r),t.suffix=v(t.src)||"",t.type=C(t.suffix,r.type),t}))),[H]),{file:E,content:G}=h((()=>{const r=A[M.current];return{file:r,content:N(r)}}),[M.current,H]),I=E.type===q.IMAGE,O=r=>{const t=A.length,{current:e}=M;M.current=r>=t?0:r<0?t-1:r,D?.(M.current,e),M.rotate=A[M.current].rotate||0,1!==M.scale&&(M.scale=1,Y?.(1)),$?.(M.rotate),M.translate=X.current=[0,0]},P=r=>{M.rotate+=r,$?.(M.rotate)},R=f({interval:60},(r=>{if(!I)return;let t=M.scale+(r.deltaY<0?.05:-.05);t>2&&(t=2),t<.25&&(t=.25),Y?.(t),M.scale=t})),W=f({interval:300},(()=>{M.controlHidden&&(M.controlHidden=!1,_.current&&!M.controlHidden&&(clearTimeout(_.current),_.current=null),_.current=setTimeout((()=>{M.controlHidden=!0}),1e3))}));return k((r=>{if(W(),!M.dragging)return;r.preventDefault();const[t,e]=X.current,[n,o]=M.start,a=r.pageX-n,i=r.pageY-o;M.translate=[t+a,e+i]})),j((()=>{M.dragging&&(M.dragging=!1,X.current=M.translate)})),r(t,{children:[e("div",{ref:T,className:p("i-preview-content",{"no-transition":M.dragging}),style:{transform:`translate(${M.translate.map((r=>`${r}px`)).join(",")}) rotate(${M.rotate}deg) scale(${M.scale})`},onWheel:R,onMouseDown:r=>{I&&(r.preventDefault(),M.dragging=!0,M.start=[r.pageX,r.pageY])},onClick:r=>r.stopPropagation(),children:G}),r("div",{className:p("i-preview-controls",{"i-preview-controls-hidden":M.controlHidden}),children:[e(b,{square:!0,flat:!0,onClick:F,children:e(n,{icon:e(o,{})})}),A.length>1&&r("span",{className:"px-8",children:[M.current+1," / ",A.length]}),1!==M.scale&&r(b,{flat:!0,onClick:()=>M.scale=1,children:[e(n,{icon:e(a,{})}),r("span",{className:"mt-2",children:[(100*M.scale).toFixed(0),"%"]})]}),e(b,{square:!0,flat:!0,href:E.src,target:"_blank",children:e(n,{icon:e(i,{})})}),e(b,{square:!0,flat:!0,href:E.src,download:!0,target:"_blank",children:e(n,{icon:e(c,{})})}),e(b,{square:!0,flat:!0,onClick:()=>P(90),children:e(n,{icon:e(l,{})})}),e(b,{square:!0,flat:!0,onClick:()=>P(-90),children:e(n,{icon:e(s,{})})}),A.length>1&&r(t,{children:[e(b,{square:!0,flat:!0,onClick:()=>O(M.current-1),children:e(n,{icon:e(d,{})})}),e(b,{square:!0,flat:!0,onClick:()=>O(M.current+1),children:e(n,{icon:e(u,{})})})]})]})]})}export{y as default};
2
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sources":["../../../packages/js/usePreview/content.tsx"],"sourcesContent":["import Button from \"@p/components/button\";\nimport Icon from \"@p/components/icon\";\nimport {\n\tAspectRatioRound,\n\tCloseRound,\n\tFileDownloadOutlined,\n\tKeyboardArrowLeftRound,\n\tKeyboardArrowRightRound,\n\tOpenInNewRound,\n\tRotateLeftRound,\n\tRotateRightRound,\n} from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { throttle } from \"radash\";\nimport { useMemo, useRef } from \"react\";\nimport { useMouseMove, useMouseUp } from \"../hooks\";\nimport { getFileType, getSuffixByUrl } from \"../utils\";\nimport DefaultRenderFile from \"./renderFile\";\nimport { IPreview, TFileType, TPreviewItem } from \"./type\";\n\nexport default function Content(props: IPreview) {\n\tconst {\n\t\titems = [],\n\t\tinitial = 0,\n\t\trenderFile = DefaultRenderFile,\n\t\tonRotate,\n\t\tonChange,\n\t\tonClose,\n\t\tonZoom,\n\t} = props;\n\tconst state = useReactive({\n\t\tcurrent: initial,\n\t\trotate: 0,\n\t\tscale: 1,\n\t\ttranslate: [0, 0],\n\t\tstart: [0, 0],\n\t\tdragging: false,\n\t\tcontrolHidden: true,\n\t});\n\tconst box = useRef<HTMLDivElement>(null);\n\tconst translate = useRef<number[]>([0, 0]);\n\tconst hiddenTO = useRef<any>(null);\n\n\tconst files = useMemo(() => {\n\t\treturn items.map((item) => {\n\t\t\tconst o: TPreviewItem = {\n\t\t\t\tsrc: \"\",\n\t\t\t};\n\t\t\tif (typeof item === \"string\") {\n\t\t\t\to.src = item;\n\t\t\t} else {\n\t\t\t\tObject.assign(o, item);\n\t\t\t}\n\n\t\t\to.suffix = getSuffixByUrl(o.src) || \"\";\n\t\t\to.type = getFileType(o.suffix, item[\"type\"]);\n\n\t\t\treturn o;\n\t\t});\n\t}, [items]);\n\n\tconst { file, content } = useMemo(() => {\n\t\tconst file = files[state.current];\n\t\tconst content = renderFile(file);\n\n\t\treturn {\n\t\t\tfile,\n\t\t\tcontent,\n\t\t};\n\t}, [state.current, items]);\n\n\tconst isImage = file.type === TFileType.IMAGE;\n\n\tconst handleSwitch = (next: number) => {\n\t\tconst l = files.length;\n\t\tconst { current: before } = state;\n\t\tif (next >= l) {\n\t\t\tstate.current = 0;\n\t\t} else if (next < 0) {\n\t\t\tstate.current = l - 1;\n\t\t} else {\n\t\t\tstate.current = next;\n\t\t}\n\t\tonChange?.(state.current, before);\n\n\t\tstate.rotate = files[state.current].rotate || 0;\n\n\t\tif (state.scale !== 1) {\n\t\t\tstate.scale = 1;\n\t\t\tonZoom?.(1);\n\t\t}\n\t\tonRotate?.(state.rotate);\n\t\tstate.translate = translate.current = [0, 0];\n\t};\n\n\tconst handleRotate = (deg: number) => {\n\t\tstate.rotate += deg;\n\n\t\tonRotate?.(state.rotate);\n\t};\n\n\tconst handleMouseWheel = throttle({ interval: 60 }, (e) => {\n\t\tif (!isImage) return;\n\t\tlet after = state.scale + (e.deltaY < 0 ? 0.05 : -0.05);\n\t\tif (after > 2) after = 2;\n\t\tif (after < 0.25) after = 0.25;\n\n\t\tonZoom?.(after);\n\t\tstate.scale = after;\n\t});\n\n\tconst handleMouseDown = (e) => {\n\t\tif (!isImage) return;\n\t\te.preventDefault();\n\t\tstate.dragging = true;\n\t\tstate.start = [e.pageX, e.pageY];\n\t};\n\n\tconst clearHiddenTO = () => {\n\t\tif (!hiddenTO.current || state.controlHidden) return;\n\t\tclearTimeout(hiddenTO.current);\n\t\thiddenTO.current = null;\n\t};\n\n\tconst setHiddenFalse = () => {\n\t\tif (!state.controlHidden) return;\n\t\tstate.controlHidden = false;\n\n\t\tclearHiddenTO();\n\t\thiddenTO.current = setTimeout(() => {\n\t\t\tstate.controlHidden = true;\n\t\t}, 1000);\n\t};\n\n\tconst throttleMouseMove = throttle({ interval: 300 }, setHiddenFalse);\n\n\tconst handleMouseMove = (e) => {\n\t\tthrottleMouseMove();\n\t\tif (!state.dragging) return;\n\t\te.preventDefault();\n\n\t\tconst [x, y] = translate.current;\n\t\tconst [ox, oy] = state.start;\n\t\tconst offsetX = e.pageX - ox;\n\t\tconst offsetY = e.pageY - oy;\n\n\t\tstate.translate = [x + offsetX, y + offsetY];\n\t};\n\n\tconst handleMouseUp = () => {\n\t\tif (!state.dragging) return;\n\t\tstate.dragging = false;\n\t\ttranslate.current = state.translate;\n\t};\n\n\tuseMouseMove(handleMouseMove);\n\tuseMouseUp(handleMouseUp);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tref={box}\n\t\t\t\tclassName={classNames(\"i-preview-content\", {\n\t\t\t\t\t\"no-transition\": state.dragging,\n\t\t\t\t})}\n\t\t\t\tstyle={{\n\t\t\t\t\ttransform: `translate(${state.translate\n\t\t\t\t\t\t.map((n) => `${n}px`)\n\t\t\t\t\t\t.join(\",\")}) rotate(${state.rotate}deg) scale(${\n\t\t\t\t\t\tstate.scale\n\t\t\t\t\t})`,\n\t\t\t\t}}\n\t\t\t\tonWheel={handleMouseWheel}\n\t\t\t\tonMouseDown={handleMouseDown}\n\t\t\t\tonClick={(e) => e.stopPropagation()}\n\t\t\t>\n\t\t\t\t{content}\n\t\t\t</div>\n\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-preview-controls\", {\n\t\t\t\t\t\"i-preview-controls-hidden\": state.controlHidden,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t<Button square flat onClick={onClose}>\n\t\t\t\t\t<Icon icon={<CloseRound />} />\n\t\t\t\t</Button>\n\t\t\t\t{files.length > 1 && (\n\t\t\t\t\t<span className='px-8'>\n\t\t\t\t\t\t{state.current + 1} / {files.length}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{state.scale !== 1 && (\n\t\t\t\t\t<Button flat onClick={() => (state.scale = 1)}>\n\t\t\t\t\t\t<Icon icon={<AspectRatioRound />} />\n\t\t\t\t\t\t<span className='mt-2'>\n\t\t\t\t\t\t\t{(state.scale * 100).toFixed(0)}%\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Button>\n\t\t\t\t)}\n\t\t\t\t<Button square flat href={file.src} target='_blank'>\n\t\t\t\t\t<Icon icon={<OpenInNewRound />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat href={file.src} download target='_blank'>\n\t\t\t\t\t<Icon icon={<FileDownloadOutlined />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat onClick={() => handleRotate(90)}>\n\t\t\t\t\t<Icon icon={<RotateRightRound />} />\n\t\t\t\t</Button>\n\t\t\t\t<Button square flat onClick={() => handleRotate(-90)}>\n\t\t\t\t\t<Icon icon={<RotateLeftRound />} />\n\t\t\t\t</Button>\n\n\t\t\t\t{files.length > 1 && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsquare\n\t\t\t\t\t\t\tflat\n\t\t\t\t\t\t\tonClick={() => handleSwitch(state.current - 1)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={<KeyboardArrowLeftRound />} />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsquare\n\t\t\t\t\t\t\tflat\n\t\t\t\t\t\t\tonClick={() => handleSwitch(state.current + 1)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon icon={<KeyboardArrowRightRound />} />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"names":["Content","props","items","initial","renderFile","DefaultRenderFile","onRotate","onChange","onClose","onZoom","state","useReactive","current","rotate","scale","translate","start","dragging","controlHidden","box","useRef","hiddenTO","files","useMemo","map","item","o","src","Object","assign","suffix","getSuffixByUrl","type","getFileType","file","content","isImage","TFileType","IMAGE","handleSwitch","next","l","length","before","handleRotate","deg","handleMouseWheel","throttle","interval","e","after","deltaY","throttleMouseMove","clearTimeout","setTimeout","useMouseMove","preventDefault","x","y","ox","oy","offsetX","pageX","offsetY","pageY","useMouseUp","_jsxs","_Fragment","children","_jsx","ref","className","classNames","style","transform","n","join","onWheel","onMouseDown","onClick","stopPropagation","Button","square","flat","Icon","icon","CloseRound","AspectRatioRound","toFixed","href","target","OpenInNewRound","download","FileDownloadOutlined","RotateRightRound","RotateLeftRound","KeyboardArrowLeftRound","KeyboardArrowRightRound"],"mappings":"wuBAqBwB,SAAAA,EAAQC,GAC/B,MAAMC,MACLA,EAAQ,GAAEC,QACVA,EAAU,EACVC,WAAAA,EAAaC,EAAiBC,SAC9BA,EAAQC,SACRA,EAAQC,QACRA,EAAOC,OACPA,GACGR,EACES,EAAQC,EAAY,CACzBC,QAAST,EACTU,OAAQ,EACRC,MAAO,EACPC,UAAW,CAAC,EAAG,GACfC,MAAO,CAAC,EAAG,GACXC,UAAU,EACVC,eAAe,IAEVC,EAAMC,EAAuB,MAC7BL,EAAYK,EAAiB,CAAC,EAAG,IACjCC,EAAWD,EAAY,MAEvBE,EAAQC,GAAQ,IACdrB,EAAMsB,KAAKC,IACjB,MAAMC,EAAkB,CACvBC,IAAK,IAWN,MA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AAAC,KAAMhB,EAACkB,EAAmB,CAAA,KAChCrB,EAAA,OAAA,CAAMK,UAAU,OAAMH,SAAA,EACL,IAAd1D,EAAMI,OAAa0E,QAAQ,GACvB,UAGTnB,EAACY,EAAM,CAACC,QAAO,EAAAC,MAAK,EAAAM,KAAMvD,EAAKP,IAAK+D,OAAO,SAAQtB,SAClDC,EAACe,EAAI,CAACC,KAAMhB,EAACsB,EAAc,CAAA,OAE5BtB,EAACY,EAAM,CAACC,QAAO,EAAAC,MAAK,EAAAM,KAAMvD,EAAKP,IAAKiE,UAAS,EAAAF,OAAO,SACnDtB,SAAAC,EAACe,EAAI,CAACC,KAAMhB,EAACwB,EAAoB,CAAA,OAElCxB,EAACY,EAAO,CAAAC,QAAO,EAAAC,MAAK,EAAAJ,QAAS,IAAMnC,EAAa,IAC/CwB,SAAAC,EAACe,EAAI,CAACC,KAAMhB,EAACyB,EAAgB,CAAA,OAE9BzB,EAACY,EAAO,CAAAC,QAAO,EAAAC,MAAK,EAAAJ,QAAS,IAAMnC,GAAa,IAC/CwB,SAAAC,EAACe,EAAK,CAAAC,KAAMhB,EAAC0B,EAAkB,CAAA,OAG/BzE,EAAMoB,OAAS,GACfwB,EACCC,EAAA,CAAAC,SAAA,CAAAC,EAACY,EACA,CAAAC,QACA,EAAAC,MACA,EAAAJ,QAAS,IAAMxC,EAAa7B,EAAME,QAAU,GAE5CwD,SAAAC,EAACe,EAAI,CAACC,KAAMhB,EAAC2B,EAAsB,CAAA,OAEpC3B,EAACY,EACA,CAAAC,QACA,EAAAC,QACAJ,QAAS,IAAMxC,EAAa7B,EAAME,QAAU,GAAEwD,SAE9CC,EAACe,EAAK,CAAAC,KAAMhB,EAAC4B,EAA0B,CAAA,eAO9C"}
@@ -0,0 +1,2 @@
1
+ import{jsx as o}from"react/jsx-runtime";import{useRef as e}from"react";import t from"../../components/modal/hookModal.js";import{renderNode as r}from"../utils.js";import i from"./content.js";function s(){const s=e(null);return e=>{const{items:m,modalProps:n,onClose:l,...a}=e,c=r(o(t,{ref:s,visible:!0,className:"i-preview",customized:!0,hideShadow:!0,...n,children:o(i,{...a,items:m,onClose:()=>{s.current?.update({visible:!1})}}),fixed:!0,onClose:()=>{l?.(),c?.()}}))}}export{s as default};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../packages/js/usePreview/index.tsx"],"sourcesContent":["import { useRef } from \"react\";\nimport HookModal from \"../../components/modal/hookModal\";\nimport type { RefHookModal } from \"../../components/modal/type\";\nimport { renderNode } from \"../utils\";\nimport Content from \"./content\";\nimport \"./index.css\";\nimport type { IPreview } from \"./type\";\n\nexport default function usePreview() {\n\tconst ref = useRef<RefHookModal>(null);\n\n\tconst preview = (config: IPreview) => {\n\t\tconst { items, modalProps, onClose, ...restProps } = config;\n\n\t\tconst handleClose = () => {\n\t\t\tonClose?.();\n\t\t\tunMount?.();\n\t\t};\n\n\t\tconst unMount = renderNode(\n\t\t\t<HookModal\n\t\t\t\tref={ref}\n\t\t\t\tvisible\n\t\t\t\tclassName='i-preview'\n\t\t\t\tcustomized\n\t\t\t\thideShadow\n\t\t\t\t{...modalProps}\n\t\t\t\tchildren={\n\t\t\t\t\t<Content\n\t\t\t\t\t\t{...restProps}\n\t\t\t\t\t\titems={items}\n\t\t\t\t\t\tonClose={() => {\n\t\t\t\t\t\t\tref.current?.update({ visible: false });\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\tfixed\n\t\t\t\tonClose={handleClose}\n\t\t\t/>\n\t\t);\n\t};\n\n\treturn preview;\n}\n"],"names":["usePreview","ref","useRef","config","items","modalProps","onClose","restProps","unMount","renderNode","_jsx","HookModal","visible","className","customized","hideShadow","children","Content","current","update","fixed"],"mappings":"+LAQc,SAAUA,IACvB,MAAMC,EAAMC,EAAqB,MAiCjC,OA/BiBC,IAChB,MAAMC,MAAEA,EAAKC,WAAEA,EAAUC,QAAEA,KAAYC,GAAcJ,EAO/CK,EAAUC,EACfC,EAACC,EACA,CAAAV,IAAKA,EACLW,SAAO,EACPC,UAAU,YACVC,YACA,EAAAC,iBACIV,EACJW,SACCN,EAACO,EAAO,IACHV,EACJH,MAAOA,EACPE,QAAS,KACRL,EAAIiB,SAASC,OAAO,CAAEP,SAAS,GAAQ,IAI1CQ,OAAK,EACLd,QAvBkB,KACnBA,MACAE,KAAW,IAuBX,CAIH"}
@@ -0,0 +1,2 @@
1
+ import{jsxs as e,jsx as r}from"react/jsx-runtime";import o from"../../components/icon/icon.js";import i from"../../components/video/video.js";import{FeedOutlined as t}from"@ricons/material";import{TFileType as n}from"./type.js";function m(m){const{name:s,suffix:c,type:a}=m;switch(a){case n.IMAGE:return r("img",{src:m.src});case n.VIDEO:return r(i,{...m});default:return e("div",{className:"i-preview-unknown",children:[r(o,{icon:r(t,{}),size:"3em"}),r("h5",{className:"mt-4",children:s||c||"?"})]})}}export{m as default};
2
+ //# sourceMappingURL=renderFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderFile.js","sources":["../../../packages/js/usePreview/renderFile.tsx"],"sourcesContent":["import Icon from \"@p/components/icon\";\nimport Video from \"@p/components/video\";\nimport { FeedOutlined } from \"@ricons/material\";\nimport { TFileType, TPreviewItem } from \"./type\";\n\nexport default function renderFile(props: TPreviewItem) {\n\tconst { name, suffix, type } = props;\n\n\tswitch (type) {\n\t\tcase TFileType.IMAGE:\n\t\t\treturn <img src={props.src} />;\n\t\tcase TFileType.VIDEO:\n\t\t\treturn <Video {...props} />;\n\t\tdefault:\n\t\t\treturn (\n\t\t\t\t<div className='i-preview-unknown'>\n\t\t\t\t\t<Icon icon={<FeedOutlined />} size='3em' />\n\t\t\t\t\t<h5 className='mt-4'>{name || suffix || \"?\"}</h5>\n\t\t\t\t</div>\n\t\t\t);\n\t}\n}\n"],"names":["renderFile","props","name","suffix","type","TFileType","IMAGE","_jsx","src","VIDEO","Video","_jsxs","className","children","Icon","icon","FeedOutlined","size"],"mappings":"oOAKwB,SAAAA,EAAWC,GAClC,MAAMC,KAAEA,EAAIC,OAAEA,EAAMC,KAAEA,GAASH,EAE/B,OAAQG,GACP,KAAKC,EAAUC,MACd,OAAOC,SAAKC,IAAKP,EAAMO,MACxB,KAAKH,EAAUI,MACd,OAAOF,EAACG,EAAU,IAAAT,IACnB,QACC,OACCU,EAAA,MAAA,CAAKC,UAAU,oBACdC,SAAA,CAAAN,EAACO,EAAI,CAACC,KAAMR,EAACS,MAAiBC,KAAK,QACnCV,EAAI,KAAA,CAAAK,UAAU,OAAMC,SAAEX,GAAQC,GAAU,SAI7C"}
@@ -0,0 +1,2 @@
1
+ var E;!function(E){E.IMAGE="IMAGE",E.VIDEO="VIDEO",E.AUDIO="AUDIO",E.PDF="PDF",E.EXCEL="EXCEL",E.TXT="TXT",E.UNKNOWN="UNKNOWN"}(E||(E={}));export{E as TFileType};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sources":["../../../packages/js/usePreview/type.ts"],"sourcesContent":["import { CSSProperties, ReactNode } from \"react\";\nimport type { IModal } from \"../../components/modal/type\";\n\nexport type TPreviewItem = {\n\tsrc: string;\n\tname?: ReactNode;\n\tthumb?: string;\n\trotate?: number;\n\tzoom?: number;\n\tstyle?: CSSProperties;\n\ttype?: string;\n\tsuffix?: string;\n};\n\nexport enum TFileType {\n\tIMAGE = \"IMAGE\",\n\tVIDEO = \"VIDEO\",\n\tAUDIO = \"AUDIO\",\n\tPDF = \"PDF\",\n\tEXCEL = \"EXCEL\",\n\tTXT = \"TXT\",\n\tUNKNOWN = \"UNKNOWN\",\n}\n\nexport interface IPreview {\n\titems: (TPreviewItem | string)[];\n\tinitial?: number;\n\tcontrols?: boolean;\n\tloop?: boolean;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tmodalProps?: IModal;\n\trenderImage?: (file: TPreviewItem) => ReactNode;\n\trenderFile?: (file: TPreviewItem) => ReactNode;\n\tonClose?: () => void;\n\tonChange?: (after: number, before?: number) => void;\n\tonZoom?: (scale: number) => void;\n\tonRotate?: (deg: number) => void;\n}\n"],"names":["TFileType"],"mappings":"IAcYA,GAAZ,SAAYA,GACXA,EAAA,MAAA,QACAA,EAAA,MAAA,QACAA,EAAA,MAAA,QACAA,EAAA,IAAA,MACAA,EAAA,MAAA,QACAA,EAAA,IAAA,MACAA,EAAA,QAAA,SACA,CARD,CAAYA,IAAAA,EAQX,CAAA"}
@@ -0,0 +1,2 @@
1
+ const e=500,t=()=>{document.documentElement.dataset.useripple||(document.documentElement.dataset.useripple="enable",document.addEventListener("mousedown",n))};function n(t){const n=t.target,a=n.closest("[data-ripple]");n&&a&&function(t,n){const[a,i]=function(){const e=document.createElement("SPAN"),t=document.createElement("SPAN");return e.className="i-ripple-container",t.className="i-ripple",e.append(t),[e,t]}(),s=t.getBoundingClientRect(),o=2*Math.max(s.width,s.height);i.style.cssText=`\n left: ${n.pageX-s.left}px;\n top: ${n.pageY-s.top}px;\n width: ${o}px;\n height: ${o}px;\n transition: all 0.5s;\n `,t.insertAdjacentElement("afterbegin",a),t.offsetHeight,i.classList.add("i-ripple-active"),setTimeout((()=>{a.remove()}),e)}(a,t)}export{t as default};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../packages/js/useRipple/index.ts"],"sourcesContent":["import \"./ripple.css\";\n\nconst TIMEOUT = 500;\n\nconst useRipple = () => {\n\tif (document.documentElement.dataset[\"useripple\"]) return;\n\tdocument.documentElement.dataset[\"useripple\"] = \"enable\";\n\n\tdocument.addEventListener(\"mousedown\", listener);\n};\n\nfunction listener(e: MouseEvent) {\n\tconst target = e.target as HTMLElement;\n\tconst parent = target.closest(\"[data-ripple]\") as HTMLElement;\n\n\tif (!target || !parent) return;\n\n\ttriggerRipple(parent, e);\n}\n\nfunction triggerRipple(target: HTMLElement, e: MouseEvent) {\n\tconst [$box, $ripple] = createRipple();\n\tconst rect = target.getBoundingClientRect();\n\tconst size = Math.max(rect.width, rect.height) * 2;\n\n\t$ripple.style.cssText = `\n left: ${e.pageX - rect.left}px;\n top: ${e.pageY - rect.top}px;\n width: ${size}px;\n height: ${size}px;\n transition: all ${TIMEOUT / 1000}s;\n `;\n\ttarget.insertAdjacentElement(\"afterbegin\", $box);\n\ttarget.offsetHeight;\n\t$ripple.classList.add(\"i-ripple-active\");\n\n\tsetTimeout(() => {\n\t\t$box.remove();\n\t}, TIMEOUT);\n}\n\nfunction createRipple() {\n\tconst $box = document.createElement(\"SPAN\");\n\tconst $ripple = document.createElement(\"SPAN\");\n\n\t$box.className = \"i-ripple-container\";\n\t$ripple.className = \"i-ripple\";\n\n\t$box.append($ripple);\n\n\treturn [$box, $ripple];\n}\n\nexport default useRipple;\n"],"names":["TIMEOUT","useRipple","document","documentElement","dataset","addEventListener","listener","e","target","parent","closest","$box","$ripple","createElement","className","append","createRipple","rect","getBoundingClientRect","size","Math","max","width","height","style","cssText","pageX","left","pageY","top","insertAdjacentElement","offsetHeight","classList","add","setTimeout","remove","triggerRipple"],"mappings":"AAEA,MAAMA,EAAU,IAEVC,EAAY,KACbC,SAASC,gBAAgBC,QAAmB,YAChDF,SAASC,gBAAgBC,QAAmB,UAAI,SAEhDF,SAASG,iBAAiB,YAAaC,GAAS,EAGjD,SAASA,EAASC,GACjB,MAAMC,EAASD,EAAEC,OACXC,EAASD,EAAOE,QAAQ,iBAEzBF,GAAWC,GAKjB,SAAuBD,EAAqBD,GAC3C,MAAOI,EAAMC,GAoBd,WACC,MAAMD,EAAOT,SAASW,cAAc,QAC9BD,EAAUV,SAASW,cAAc,QAOvC,OALAF,EAAKG,UAAY,qBACjBF,EAAQE,UAAY,WAEpBH,EAAKI,OAAOH,GAEL,CAACD,EAAMC,EACf,CA9ByBI,GAClBC,EAAOT,EAAOU,wBACdC,EAA2C,EAApCC,KAAKC,IAAIJ,EAAKK,MAAOL,EAAKM,QAEvCX,EAAQY,MAAMC,QAAU,mBACTlB,EAAEmB,MAAQT,EAAKU,yBAChBpB,EAAEqB,MAAQX,EAAKY,0BACbV,yBACCA,4CAGjBX,EAAOsB,sBAAsB,aAAcnB,GAC3CH,EAAOuB,aACPnB,EAAQoB,UAAUC,IAAI,mBAEtBC,YAAW,KACVvB,EAAKwB,QAAQ,GACXnC,EACJ,CAtBCoC,CAAc3B,EAAQF,EACvB"}
@@ -0,0 +1,2 @@
1
+ import{createRoot as t}from"react-dom/client";function e(t,e,n={}){const{refWindow:i,gap:r=0,offset:c=0,position:s="top",align:a}=n;if(!t||!e)return[0,0,{arrowX:0,arrowY:0,arrowPos:"bottom"}];const u=t.getBoundingClientRect(),f=e.getBoundingClientRect();let l=window.innerWidth,g=window.innerHeight,{left:h,top:d,right:p,bottom:m,width:w,height:B}=u;const{height:b,width:z}=f;if(!i){const e=t.offsetParent?.getBoundingClientRect();l=e?.width||l,g=e?.height||g,h=t.offsetLeft,d=t.offsetTop,p=h+u.width,m=d+u.height}let M=0,S=0,$=0,F=0,v="bottom";switch(s){case"left":case"right":M=B!==b?o({containerSize:g,targetSize:B,targetOffset:d,contentSize:b,gap:r,align:a}):d,F=M<d?d-M+B/2:B/2;const t=h-c-z,e=p+c+z;if("left"===s){const n=t<0&&e<=l;S=n?p+c:t,$=n?0:z,v=n?"left":"right"}else{const n=l>e||t<0;S=n?p+c:t,$=n?0:z,v=n?"left":"right"}break;case"top":case"bottom":S=w!==z?o({containerSize:l,targetOffset:h,targetSize:w,contentSize:z,gap:r,align:a}):h,$=S>h?z/2:h-S+w/2;const n=d-c-b,i=m+c+b;if("top"===s){const t=n<0&&i<=g;M=t?m+c:n,F=t?0:b,v=t?"top":"bottom"}else{const t=g>i||n<0;M=t?m+c:n,F=t?0:b,v=t?"top":"bottom"}}return[S,M,{arrowX:$,arrowY:F,arrowPos:v}]}function n(t,e){const{width:n,height:o}=e.getBoundingClientRect(),i=e.offsetParent;let r,c,s=0,a=0;if(i){const{width:t,height:e,left:n,top:o}=i.getBoundingClientRect();r=t,c=e,a=o-(i.scrollTop??0),s=n}else r=window.innerWidth,c=window.innerHeight;const u=t.pageX-s,f=t.pageY-a;return[u+n>=r&&u-n>0?u-n:u,f+o>=c&&f-o>0?f-o:f]}function o({containerSize:t,targetSize:e,targetOffset:n,contentSize:o,gap:i,align:r="center"}){const c=n+e/2;switch(r){case"start":return n+o>t?t-o-i:n;case"center":return e>=o?c-o/2:c+o/2+i>t?n+e-o:c-o/2-i<0?i:c-o/2;case"end":const r=n+e-o;return r>0?r:i;default:return c-o/2}}function i(t){return t.map((t=>["string","number"].includes(typeof t)?{label:t,value:t}:t))}function r(t,e,n=1e3,o,i=t=>1-Math.pow(1-t,4)){const r=performance.now(),c=e-t;let s=requestAnimationFrame((function t(){s=requestAnimationFrame(t);let e=(performance.now()-r)/n;e>=1&&(e=1,cancelAnimationFrame(s));const a=c*i(e);o?.(a)}))}function c(t,e={}){const{precision:n,thousand:o}=e,i=t.toFixed(n);if(!o)return i;const r=i.split("."),c=r[0].replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g,`$&${o}`);return 1===r.length?c:`${c}.${r[1]}`}function s(e,n=document.body){const o=document.createElement("div");n.append(o);const i=t(o),r=setTimeout((()=>{i?.render(e)}),0);return()=>{o?.remove(),i?.unmount(),r&&clearTimeout(r)}}function a(t){return t.match(/\.([^\./\?]+)($|\?)/)?.[1]}function u(t,e){switch(!0){case["jpg","jpeg","png","webp","svg"].includes(t)||e?.startsWith("image/"):return"IMAGE";case["mp4","avi"].includes(t)||e?.startsWith("video/"):return"VIDEO";default:return"UNKNOWN"}}function f(t){t.requestFullscreen?.()}function l(){document.exitFullscreen?.()}function g(t,e){const n=[],{zero:o=!0,units:i=["",":",":"]}=e,r=i.length;let c=0;for(;c<r&&!(t<=0&&c>1);){const e=Math.round(t%60);t=Math.floor(t/60),n.unshift((o&&e<10?`0${e}`:e)+i[c++])}return n.join("")}function h(t,e,n){const o=["desc","asc"];if(t===n){const t=o.findIndex((t=>t===e))+1,i=o[t]||"";return[""===i?"":n,i]}return[n,"desc"]}function d(t,e=2){if(!+t)return"0 Bytes";const n=e<0?0:e,o=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/Math.pow(1024,o)).toFixed(n))} ${["B","KB","MB","GB","TB","PB","EB","ZB","YB"][o]}`}function p(t,e,n){return t<e?e:t>n?n:t}const m=(t,e,n)=>{if(n>=t.length){let e=n-t.length+1;for(;e--;)t.push(void 0)}return t.splice(n,0,t.splice(e,1)[0]),t};export{r as animate,m as arrayMove,p as clamp,l as exitFullScreen,d as formatBytes,c as formatNumber,i as formatOption,g as formatTime,f as fullScreen,u as getFileType,h as getNextSorter,n as getPointPosition,e as getPosition,a as getSuffixByUrl,s as renderNode};
2
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../packages/js/utils.ts"],"sourcesContent":["import type { MouseEvent } from \"react\";\nimport { ReactNode } from \"react\";\nimport { Root, createRoot } from \"react-dom/client\";\nimport type { TOption, TOptions, TRelativeOptions } from \"../type\";\n\ntype TComputePosition = {\n\tcontainerSize: number;\n\ttargetSize: number;\n\ttargetOffset: number;\n\tcontentSize: number;\n\tgap: number;\n\talign?: \"start\" | \"center\" | \"end\";\n};\n\nexport function getPosition(\n\t$source?: HTMLElement | null,\n\t$popup?: HTMLElement | null,\n\toptions: TRelativeOptions = {}\n): [\n\tx: number,\n\ty: number,\n\tz: {\n\t\tarrowX: number;\n\t\tarrowY: number;\n\t\tarrowPos: string;\n\t}\n] {\n\tconst { refWindow, gap = 0, offset = 0, position = \"top\", align } = options;\n\n\tif (!$source || !$popup)\n\t\treturn [\n\t\t\t0,\n\t\t\t0,\n\t\t\t{\n\t\t\t\tarrowX: 0,\n\t\t\t\tarrowY: 0,\n\t\t\t\tarrowPos: \"bottom\",\n\t\t\t},\n\t\t];\n\n\tconst rectT = $source.getBoundingClientRect();\n\tconst rectC = $popup.getBoundingClientRect();\n\n\tlet w = window.innerWidth;\n\tlet h = window.innerHeight;\n\tlet {\n\t\tleft: tl,\n\t\ttop: tt,\n\t\tright: tr,\n\t\tbottom: tb,\n\t\twidth: tw,\n\t\theight: th,\n\t} = rectT;\n\tconst { height: ch, width: cw } = rectC;\n\n\tif (!refWindow) {\n\t\tconst rectPa = $source.offsetParent?.getBoundingClientRect();\n\n\t\tw = rectPa?.width || w;\n\t\th = rectPa?.height || h;\n\t\ttl = $source.offsetLeft;\n\t\ttt = $source.offsetTop;\n\t\ttr = tl + rectT.width;\n\t\ttb = tt + rectT.height;\n\t}\n\n\tlet y = 0;\n\tlet x = 0;\n\tlet arrowX = 0;\n\tlet arrowY = 0;\n\tlet arrowPos = \"bottom\";\n\n\tswitch (position) {\n\t\tcase \"left\":\n\t\tcase \"right\":\n\t\t\ty =\n\t\t\t\tth !== ch\n\t\t\t\t\t? computePosition({\n\t\t\t\t\t\t\tcontainerSize: h,\n\t\t\t\t\t\t\ttargetSize: th,\n\t\t\t\t\t\t\ttargetOffset: tt,\n\t\t\t\t\t\t\tcontentSize: ch,\n\t\t\t\t\t\t\tgap,\n\t\t\t\t\t\t\talign,\n\t\t\t\t\t })\n\t\t\t\t\t: tt;\n\t\t\tarrowY = y < tt ? tt - y + th / 2 : th / 2;\n\n\t\t\tconst xl = tl - offset - cw;\n\t\t\tconst xr = tr + offset + cw;\n\n\t\t\tif (position === \"left\") {\n\t\t\t\tconst R = xl < 0 && xr <= w;\n\t\t\t\tx = R ? tr + offset : xl;\n\t\t\t\tarrowX = R ? 0 : cw;\n\t\t\t\tarrowPos = R ? \"left\" : \"right\";\n\t\t\t} else {\n\t\t\t\tconst R = w > xr || xl < 0;\n\t\t\t\tx = R ? tr + offset : xl;\n\t\t\t\tarrowX = R ? 0 : cw;\n\t\t\t\tarrowPos = R ? \"left\" : \"right\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\tcase \"top\":\n\t\tcase \"bottom\":\n\t\t\tx =\n\t\t\t\ttw !== cw\n\t\t\t\t\t? computePosition({\n\t\t\t\t\t\t\tcontainerSize: w,\n\t\t\t\t\t\t\ttargetOffset: tl,\n\t\t\t\t\t\t\ttargetSize: tw,\n\t\t\t\t\t\t\tcontentSize: cw,\n\t\t\t\t\t\t\tgap,\n\t\t\t\t\t\t\talign,\n\t\t\t\t\t })\n\t\t\t\t\t: tl;\n\t\t\tarrowX = x > tl ? cw / 2 : tl - x + tw / 2;\n\n\t\t\tconst yt = tt - offset - ch;\n\t\t\tconst yb = tb + offset + ch;\n\t\t\tif (position === \"top\") {\n\t\t\t\tconst T = yt < 0 && yb <= h;\n\t\t\t\ty = T ? tb + offset : yt;\n\t\t\t\tarrowY = T ? 0 : ch;\n\t\t\t\tarrowPos = T ? \"top\" : \"bottom\";\n\t\t\t} else {\n\t\t\t\tconst B = h > yb || yt < 0;\n\t\t\t\ty = B ? tb + offset : yt;\n\t\t\t\tarrowY = B ? 0 : ch;\n\t\t\t\tarrowPos = B ? \"top\" : \"bottom\";\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n\treturn [\n\t\tx,\n\t\ty,\n\t\t{\n\t\t\tarrowX,\n\t\t\tarrowY,\n\t\t\tarrowPos,\n\t\t},\n\t];\n}\n\nexport function getPointPosition(e: MouseEvent, content: HTMLElement) {\n\tconst { width: w, height: h } = content.getBoundingClientRect();\n\tconst parent = content.offsetParent;\n\tlet pw,\n\t\tph,\n\t\tpl = 0,\n\t\tpt = 0;\n\n\tif (parent) {\n\t\tconst {\n\t\t\twidth: ow,\n\t\t\theight: oh,\n\t\t\tleft: ol,\n\t\t\ttop: ot,\n\t\t} = parent.getBoundingClientRect();\n\t\tconst st = parent.scrollTop ?? 0;\n\n\t\tpw = ow;\n\t\tph = oh;\n\t\tpt = ot - st;\n\t\tpl = ol;\n\t} else {\n\t\tpw = window.innerWidth;\n\t\tph = window.innerHeight;\n\t}\n\tconst x = e.pageX - pl;\n\tconst y = e.pageY - pt;\n\n\tconst left = x + w >= pw ? (x - w > 0 ? x - w : x) : x;\n\tconst top = y + h >= ph ? (y - h > 0 ? y - h : y) : y;\n\n\treturn [left, top];\n}\n\nfunction computePosition({\n\tcontainerSize,\n\ttargetSize,\n\ttargetOffset,\n\tcontentSize,\n\tgap,\n\talign = \"center\",\n}: TComputePosition) {\n\tconst centerPoint = targetOffset + targetSize / 2;\n\n\tswitch (align) {\n\t\tcase \"start\":\n\t\t\treturn targetOffset + contentSize > containerSize\n\t\t\t\t? containerSize - contentSize - gap\n\t\t\t\t: targetOffset;\n\t\tcase \"center\":\n\t\t\tif (targetSize >= contentSize) {\n\t\t\t\treturn centerPoint - contentSize / 2;\n\t\t\t}\n\n\t\t\tif (centerPoint + contentSize / 2 + gap > containerSize) {\n\t\t\t\treturn targetOffset + targetSize - contentSize;\n\t\t\t}\n\n\t\t\tif (centerPoint - contentSize / 2 - gap < 0) {\n\t\t\t\treturn gap;\n\t\t\t}\n\n\t\t\treturn centerPoint - contentSize / 2;\n\t\tcase \"end\":\n\t\t\tconst result = targetOffset + targetSize - contentSize;\n\t\t\treturn result > 0 ? result : gap;\n\t\tdefault:\n\t\t\treturn centerPoint - contentSize / 2;\n\t}\n}\n\nexport function formatOption(options: TOptions): TOption[] {\n\treturn options.map((option) =>\n\t\t[\"string\", \"number\"].includes(typeof option)\n\t\t\t? { label: option, value: option }\n\t\t\t: option\n\t) as TOption[];\n}\n\nexport function animate(\n\tfrom: number,\n\tto: number,\n\tduration: number = 1000,\n\tcallback?: (v: number) => void,\n\teasing: (t: number) => number = (t) => 1 - Math.pow(1 - t, 4)\n) {\n\tconst start = performance.now();\n\tconst diff = to - from;\n\tlet raf = requestAnimationFrame(loop);\n\n\tfunction loop() {\n\t\traf = requestAnimationFrame(loop);\n\n\t\tconst past = performance.now() - start;\n\t\tlet percent = past / duration;\n\n\t\tif (percent >= 1) {\n\t\t\tpercent = 1;\n\t\t\tcancelAnimationFrame(raf);\n\t\t}\n\n\t\tconst pass = diff * easing(percent);\n\t\tcallback?.(pass);\n\t}\n}\n\nexport function formatNumber(\n\tvalue: number,\n\toptions: {\n\t\tprecision?: number;\n\t\tthousand?: string;\n\t} = {}\n) {\n\tconst { precision, thousand } = options;\n\n\tconst result = value.toFixed(precision);\n\n\tif (!thousand) return result;\n\n\tconst points = result.split(\".\");\n\tconst integer = points[0].replace(\n\t\t/\\d{1,3}(?=(\\d{3})+(\\.\\d*)?$)/g,\n\t\t`$&${thousand}`\n\t);\n\n\tif (points.length === 1) return integer;\n\n\treturn `${integer}.${points[1]}`;\n}\n\nexport function renderNode(node: ReactNode, container = document.body) {\n\tconst div: HTMLDivElement | null = document.createElement(\"div\");\n\tcontainer.append(div);\n\n\tconst root: Root | null = createRoot(div);\n\tconst sto = setTimeout(() => {\n\t\troot?.render(node);\n\t}, 0);\n\n\treturn () => {\n\t\tdiv?.remove();\n\t\troot?.unmount();\n\t\tsto && clearTimeout(sto);\n\t};\n}\n\nexport function getSuffixByUrl(url: string) {\n\treturn url.match(/\\.([^\\./\\?]+)($|\\?)/)?.[1];\n}\n\nexport function getFileType(suffix: string, type?: string) {\n\tswitch (true) {\n\t\tcase [\"jpg\", \"jpeg\", \"png\", \"webp\", \"svg\"].includes(suffix) ||\n\t\t\ttype?.startsWith(\"image/\"):\n\t\t\treturn \"IMAGE\";\n\t\tcase [\"mp4\", \"avi\"].includes(suffix) || type?.startsWith(\"video/\"):\n\t\t\treturn \"VIDEO\";\n\t\tdefault:\n\t\t\treturn \"UNKNOWN\";\n\t}\n}\n\nexport function fullScreen(el: HTMLElement) {\n\tel.requestFullscreen?.();\n}\n\nexport function exitFullScreen() {\n\tdocument.exitFullscreen?.();\n}\n\nexport function formatTime(\n\ttime: number,\n\toptions?: {\n\t\tzero?: boolean;\n\t\tunits?: string[];\n\t}\n) {\n\tconst result: string[] = [];\n\tconst { zero = true, units = [\"\", \":\", \":\"] } = options || {};\n\n\tconst l = units.length;\n\tlet i = 0;\n\n\twhile (i < l) {\n\t\tif (time <= 0 && i > 1) break;\n\n\t\tconst n = Math.round(time % 60);\n\n\t\ttime = Math.floor(time / 60);\n\n\t\tresult.unshift((zero && n < 10 ? `0${n}` : n) + units[i++]);\n\t}\n\n\treturn result.join(\"\");\n}\n\nexport function getNextSorter(\n\tprevSortBy: string,\n\tprevSortType: string,\n\tsortBy: string\n): [sortBy: string, sortType: string] {\n\tconst types = [\"desc\", \"asc\"];\n\n\tif (prevSortBy === sortBy) {\n\t\tconst i = types.findIndex((t) => t === prevSortType) + 1;\n\t\tconst type = types[i] || \"\";\n\t\tconst by = type === \"\" ? \"\" : sortBy;\n\n\t\treturn [by, type];\n\t}\n\n\treturn [sortBy, \"desc\"];\n}\n\nexport function formatBytes(bytes: number, decimals = 2) {\n\tif (!+bytes) return \"0 Bytes\";\n\n\tconst k = 1024;\n\tconst dm = decimals < 0 ? 0 : decimals;\n\tconst sizes = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"];\n\n\tconst i = Math.floor(Math.log(bytes) / Math.log(k));\n\n\treturn `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;\n}\n\nexport function clamp(value: number, min: number, max: number) {\n\treturn value < min ? min : value > max ? max : value;\n}\n\nexport const arrayMove = (array, fromIndex: number, toIndex: number) => {\n\tif (toIndex >= array.length) {\n\t\tlet k = toIndex - array.length + 1;\n\t\twhile (k--) {\n\t\t\tarray.push(undefined);\n\t\t}\n\t}\n\tarray.splice(toIndex, 0, array.splice(fromIndex, 1)[0]);\n\treturn array;\n};\n"],"names":["getPosition","$source","$popup","options","refWindow","gap","offset","position","align","arrowX","arrowY","arrowPos","rectT","getBoundingClientRect","rectC","w","window","innerWidth","h","innerHeight","left","tl","top","tt","right","tr","bottom","tb","width","tw","height","th","ch","cw","rectPa","offsetParent","offsetLeft","offsetTop","y","x","computePosition","containerSize","targetSize","targetOffset","contentSize","xl","xr","R","yt","yb","T","B","getPointPosition","e","content","parent","pw","ph","pl","pt","ow","oh","ol","ot","scrollTop","pageX","pageY","centerPoint","result","formatOption","map","option","includes","label","value","animate","from","to","duration","callback","easing","t","Math","pow","start","performance","now","diff","raf","requestAnimationFrame","loop","percent","cancelAnimationFrame","pass","formatNumber","precision","thousand","toFixed","points","split","integer","replace","length","renderNode","node","container","document","body","div","createElement","append","root","createRoot","sto","setTimeout","render","remove","unmount","clearTimeout","getSuffixByUrl","url","match","getFileType","suffix","type","startsWith","fullScreen","el","requestFullscreen","exitFullScreen","exitFullscreen","formatTime","time","zero","units","l","i","n","round","floor","unshift","join","getNextSorter","prevSortBy","prevSortType","sortBy","types","findIndex","formatBytes","bytes","decimals","dm","log","parseFloat","clamp","min","max","arrayMove","array","fromIndex","toIndex","k","push","undefined","splice"],"mappings":"8CAcM,SAAUA,EACfC,EACAC,EACAC,EAA4B,CAAA,GAU5B,MAAMC,UAAEA,EAASC,IAAEA,EAAM,EAACC,OAAEA,EAAS,EAACC,SAAEA,EAAW,MAAKC,MAAEA,GAAUL,EAEpE,IAAKF,IAAYC,EAChB,MAAO,CACN,EACA,EACA,CACCO,OAAQ,EACRC,OAAQ,EACRC,SAAU,WAIb,MAAMC,EAAQX,EAAQY,wBAChBC,EAAQZ,EAAOW,wBAErB,IAAIE,EAAIC,OAAOC,WACXC,EAAIF,OAAOG,aAEdC,KAAMC,EACNC,IAAKC,EACLC,MAAOC,EACPC,OAAQC,EACRC,MAAOC,EACPC,OAAQC,GACLnB,EACJ,MAAQkB,OAAQE,EAAIJ,MAAOK,GAAOnB,EAElC,IAAKV,EAAW,CACf,MAAM8B,EAASjC,EAAQkC,cAActB,wBAErCE,EAAImB,GAAQN,OAASb,EACrBG,EAAIgB,GAAQJ,QAAUZ,EACtBG,EAAKpB,EAAQmC,WACbb,EAAKtB,EAAQoC,UACbZ,EAAKJ,EAAKT,EAAMgB,MAChBD,EAAKJ,EAAKX,EAAMkB,OAGjB,IAAIQ,EAAI,EACJC,EAAI,EACJ9B,EAAS,EACTC,EAAS,EACTC,EAAW,SAEf,OAAQJ,GACP,IAAK,OACL,IAAK,Q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,CAC5B,IAAI2D,EAAID,EAAUF,EAAMxD,OAAS,EACjC,KAAO2D,KACNH,EAAMI,UAAKC,GAIb,OADAL,EAAMM,OAAOJ,EAAS,EAAGF,EAAMM,OAAOL,EAAW,GAAG,IAC7CD,CAAK"}
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import ToTop from './totop.js';
5
+ import { IAffix } from './type.js';
6
+
7
+ declare const Affix: {
8
+ (props: IAffix): react_jsx_runtime.JSX.Element;
9
+ ToTop: typeof ToTop;
10
+ };
11
+
12
+ export { Affix as default };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+
3
+ import Affix from './affix.js';
4
+
5
+
6
+
7
+ export { Affix as default };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { IAffix } from './type.js';
5
+
6
+ declare function ToTop(props: IAffix): react_jsx_runtime.JSX.Element;
7
+
8
+ export { ToTop as default };
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+
3
+ import { HTMLAttributes } from 'react';
4
+
5
+ interface IAffix extends HTMLAttributes<HTMLElement> {
6
+ position?: "fixed" | "absolute" | "sticky" | "static";
7
+ left?: string | number;
8
+ top?: string | number;
9
+ right?: string | number;
10
+ bottom?: string | number;
11
+ offset?: number;
12
+ getContainer?: () => HTMLElement | null;
13
+ }
14
+
15
+ export type { IAffix };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { IBadge } from './type.js';
5
+
6
+ declare const Badge: (props: IBadge) => react_jsx_runtime.JSX.Element;
7
+
8
+ export { Badge as default };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+
3
+ import Badge from './badge.js';
4
+
5
+
6
+
7
+ export { Badge as default };
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+
3
+ import { ReactNode, CSSProperties } from 'react';
4
+
5
+ interface IBadge {
6
+ content?: ReactNode;
7
+ contentClass?: string;
8
+ dot?: boolean;
9
+ dotSize?: string | number;
10
+ round?: boolean;
11
+ disabled?: boolean;
12
+ className?: string;
13
+ style?: CSSProperties;
14
+ children?: ReactNode;
15
+ }
16
+
17
+ export type { IBadge };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+
3
+ import { CompositionButton } from './type.js';
4
+
5
+ declare const _default: CompositionButton;
6
+
7
+ export { _default as default };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { IButtonGroup } from './type.js';
5
+
6
+ declare function Group(props: IButtonGroup): react_jsx_runtime.JSX.Element;
7
+
8
+ export { Group as default };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+
3
+ import _default from './button.js';
4
+
5
+
6
+
7
+ export { _default as default };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { IButtonToggle } from './type.js';
5
+
6
+ declare function Toggle(props: IButtonToggle): react_jsx_runtime.JSX.Element;
7
+
8
+ export { Toggle as default };
@@ -0,0 +1,46 @@
1
+ /// <reference types="react" />
2
+
3
+ import { ForwardRefExoticComponent, RefAttributes, ButtonHTMLAttributes, AnchorHTMLAttributes, ReactNode, CSSProperties, RefObject } from 'react';
4
+ import { LinkProps } from '/Users/iann/codes/ioca-react/node_modules/react-router/dist/development/index.d.ts';
5
+ import Group from './group.js';
6
+ import Toggle from './toggle.js';
7
+
8
+ interface BaseButtonProps {
9
+ as?: "a" | "button" | ForwardRefExoticComponent<LinkProps & RefAttributes<HTMLAnchorElement>>;
10
+ ref?: RefObject<HTMLElement | null>;
11
+ children?: ReactNode | string;
12
+ className?: string;
13
+ loading?: boolean;
14
+ flat?: boolean;
15
+ outline?: boolean;
16
+ square?: boolean;
17
+ size?: "mini" | "small" | "normal" | "large" | "extreme";
18
+ disabled?: boolean;
19
+ block?: boolean;
20
+ round?: boolean;
21
+ ripple?: boolean;
22
+ secondary?: boolean;
23
+ }
24
+ interface IButton extends BaseButtonProps, Omit<ButtonHTMLAttributes<HTMLElement>, "type" | "onToggle">, Omit<AnchorHTMLAttributes<HTMLElement>, "onToggle"> {
25
+ }
26
+ interface IButtonToggle extends IButton {
27
+ active?: boolean;
28
+ activeClass?: string;
29
+ after?: ReactNode;
30
+ disabled?: boolean;
31
+ toggable?: () => boolean | Promise<boolean>;
32
+ onToggle?: (active: boolean) => void;
33
+ }
34
+ interface IButtonGroup {
35
+ children?: ReactNode;
36
+ vertical?: boolean;
37
+ buttonProps?: IButton;
38
+ className?: string;
39
+ style?: CSSProperties;
40
+ }
41
+ interface CompositionButton extends ForwardRefExoticComponent<IButton & RefAttributes<HTMLElement>> {
42
+ Toggle: typeof Toggle;
43
+ Group: typeof Group;
44
+ }
45
+
46
+ export type { CompositionButton, IButton, IButtonGroup, IButtonToggle };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { ICard } from './type.js';
5
+
6
+ declare const Card: (props: ICard) => react_jsx_runtime.JSX.Element;
7
+
8
+ export { Card as default };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+
3
+ import Card from './card.js';
4
+
5
+
6
+
7
+ export { Card as default };
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+
3
+ import { HTMLAttributes, CSSProperties, ReactNode } from 'react';
4
+
5
+ interface ICard extends HTMLAttributes<HTMLDivElement> {
6
+ hideShadow?: boolean;
7
+ border?: boolean;
8
+ style?: CSSProperties;
9
+ className?: string;
10
+ children?: ReactNode;
11
+ header?: ReactNode;
12
+ footer?: ReactNode;
13
+ }
14
+
15
+ export type { ICard };
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import CheckboxItem from './item.js';
5
+ import { ICheckbox } from './type.js';
6
+
7
+ declare function Checkbox(props: ICheckbox): react_jsx_runtime.JSX.Element;
8
+ declare namespace Checkbox {
9
+ var Item: typeof CheckboxItem;
10
+ }
11
+
12
+ export { Checkbox as default };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+
3
+ import Checkbox from './checkbox.js';
4
+
5
+
6
+
7
+ export { Checkbox as default };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { ICheckboxItem } from './type.js';
5
+
6
+ declare function CheckboxItem(props: ICheckboxItem): react_jsx_runtime.JSX.Element;
7
+
8
+ export { CheckboxItem as default };
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+
3
+ import { InputHTMLAttributes, ReactNode, ChangeEvent } from 'react';
4
+ import { TValidate, TOption } from '../../type/index.js';
5
+
6
+ type TRenderCheckboxItem = (checked: boolean, value: any) => ReactNode;
7
+ interface ICheckbox extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange">, TValidate {
8
+ label?: ReactNode;
9
+ options: TOption[] | (string | number)[];
10
+ type?: "default" | "switch" | "button";
11
+ optionInline?: boolean;
12
+ labelInline?: boolean;
13
+ renderItem?: TRenderCheckboxItem;
14
+ onChange?: (value: any[], option: TOption, e: ChangeEvent<HTMLInputElement>) => void;
15
+ }
16
+ interface ICheckboxItem extends Omit<InputHTMLAttributes<HTMLElement>, "value" | "children" | "onChange">, TValidate {
17
+ type?: "default" | "switch" | "button";
18
+ label?: ReactNode;
19
+ value?: boolean;
20
+ optionValue?: any;
21
+ partof?: boolean;
22
+ children?: ReactNode | TRenderCheckboxItem;
23
+ onChange?: (value: boolean, e: ChangeEvent<HTMLInputElement>) => void;
24
+ }
25
+
26
+ export type { ICheckbox, ICheckboxItem };
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import Item from './item.js';
5
+ import { ICollapse } from './type.js';
6
+
7
+ declare const Collapse: {
8
+ (props: ICollapse): react_jsx_runtime.JSX.Element;
9
+ Item: typeof Item;
10
+ };
11
+
12
+ export { Collapse as default };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+
3
+ import Collapse from './collapse.js';
4
+
5
+
6
+
7
+ export { Collapse as default };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { ICollapseItem } from './type.js';
5
+
6
+ declare function Item(props: ICollapseItem): react_jsx_runtime.JSX.Element;
7
+
8
+ export { Item as default };
@@ -0,0 +1,25 @@
1
+ /// <reference types="react" />
2
+
3
+ import { HTMLAttributes, ReactNode, CSSProperties } from 'react';
4
+
5
+ type TKey = string | number;
6
+ interface ICollapse extends HTMLAttributes<HTMLDivElement> {
7
+ active?: TKey | TKey[];
8
+ items?: ICollapseItem[];
9
+ multiple?: boolean;
10
+ border?: boolean;
11
+ headerClickable?: boolean;
12
+ renderToggle?: (active: boolean) => ReactNode;
13
+ onCollapse?: (key: TKey, active: boolean) => void;
14
+ }
15
+ interface ICollapseItem {
16
+ key?: TKey;
17
+ title?: ReactNode;
18
+ content?: ReactNode;
19
+ disabled?: boolean;
20
+ children?: ReactNode;
21
+ className?: string;
22
+ style?: CSSProperties;
23
+ }
24
+
25
+ export type { ICollapse, ICollapseItem, TKey };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { IDatagrid } from './type.js';
5
+
6
+ declare const Datagrid: (props: IDatagrid) => react_jsx_runtime.JSX.Element;
7
+
8
+ export { Datagrid as default };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+
3
+ import Datagrid from './datagrid.js';
4
+
5
+
6
+
7
+ export { Datagrid as default };
@@ -0,0 +1,42 @@
1
+ /// <reference types="react" />
2
+
3
+ import { ReactNode, CSSProperties, MouseEvent } from 'react';
4
+
5
+ type IData = Record<string, any>;
6
+ interface IColumn {
7
+ id: string;
8
+ title?: ReactNode;
9
+ sorter?: boolean;
10
+ justify?: string;
11
+ rowSpan?: number;
12
+ colSpan?: number;
13
+ width?: string;
14
+ fixed?: "left" | "right";
15
+ render?: (value?: any, data?: IData, index?: number) => ReactNode;
16
+ renderHeader?: (column?: IColumn, index?: number) => ReactNode;
17
+ }
18
+ interface IDatagrid {
19
+ data: IData[];
20
+ columns?: IColumn[];
21
+ border?: boolean;
22
+ striped?: boolean;
23
+ header?: boolean;
24
+ resizable?: boolean;
25
+ loading?: boolean;
26
+ empty?: ReactNode;
27
+ cellPadding?: string | number;
28
+ cellEllipsis?: boolean;
29
+ height?: number | string;
30
+ style?: CSSProperties;
31
+ className?: string;
32
+ renderLoading?: () => ReactNode;
33
+ onRowClick?: (data?: IData, row?: number) => void;
34
+ onCellClick?: (data?: IData, column?: IColumn, row?: number, col?: number, e?: MouseEvent) => void;
35
+ onCellDoubleClick?: (data?: IData, column?: IColumn, row?: number, col?: number, e?: MouseEvent) => void;
36
+ onHeaderClick?: (column?: IColumn, e?: MouseEvent) => void;
37
+ onSort?: (sortBy: string, sortType: string) => void;
38
+ onScroll?: (e: MouseEvent) => void;
39
+ onResize?: (column?: IColumn, width?: number) => void;
40
+ }
41
+
42
+ export type { IColumn, IData, IDatagrid };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { IDescription } from './type.js';
5
+
6
+ declare const Description: (props: IDescription) => react_jsx_runtime.JSX.Element;
7
+
8
+ export { Description as default };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+
3
+ import Description from './description.js';
4
+
5
+
6
+
7
+ export { Description as default };
@@ -0,0 +1,27 @@
1
+ /// <reference types="react" />
2
+
3
+ import { ReactNode, CSSProperties } from 'react';
4
+
5
+ type IData = {
6
+ label: ReactNode;
7
+ value: ReactNode;
8
+ colSpan?: number;
9
+ rowSpan?: number;
10
+ hidden?: boolean;
11
+ style?: CSSProperties;
12
+ };
13
+ interface IDescription {
14
+ data: IData[];
15
+ align?: string;
16
+ colon?: ReactNode;
17
+ gap?: string | number;
18
+ equally?: boolean;
19
+ columns?: number;
20
+ vertical?: boolean;
21
+ labelWidth?: string | number;
22
+ labelAlign?: "left" | "right" | "center" | "justify";
23
+ style?: CSSProperties;
24
+ className?: string;
25
+ }
26
+
27
+ export type { IDescription };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+
3
+ import { IDrawer } from './type.js';
4
+
5
+ declare function Drawer(props: IDrawer): any;
6
+
7
+ export { Drawer as default };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+
3
+ import Drawer from './drawer.js';
4
+
5
+
6
+
7
+ export { Drawer as default };