@shzlx/ui-default 4.58.2

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 (448) hide show
  1. package/README.md +5 -0
  2. package/api.ts +61 -0
  3. package/backendlib/builder.ts +182 -0
  4. package/backendlib/markdown-it-imsize.ts +235 -0
  5. package/backendlib/markdown-it-katex.ts +139 -0
  6. package/backendlib/markdown-it-media.ts +163 -0
  7. package/backendlib/markdown-it-xss.ts +200 -0
  8. package/backendlib/markdown.js +64 -0
  9. package/backendlib/misc.ts +54 -0
  10. package/backendlib/template.ts +279 -0
  11. package/breakpoints.json +5 -0
  12. package/components/DOMAttachedObject.ts +128 -0
  13. package/components/autocomplete/AssignSelectAutoComplete.tsx +22 -0
  14. package/components/autocomplete/CustomSelectAutoComplete.tsx +23 -0
  15. package/components/autocomplete/DomainSelectAutoComplete.tsx +18 -0
  16. package/components/autocomplete/FileSelectAutoComplete.tsx +26 -0
  17. package/components/autocomplete/LanguageSelectAutoComplete.tsx +24 -0
  18. package/components/autocomplete/ProblemSelectAutoComplete.tsx +18 -0
  19. package/components/autocomplete/UserSelectAutoComplete.tsx +23 -0
  20. package/components/autocomplete/components/AssignSelectAutoComplete.tsx +118 -0
  21. package/components/autocomplete/components/DomainSelectAutoComplete.tsx +53 -0
  22. package/components/autocomplete/components/FileSelectAutoComplete.tsx +50 -0
  23. package/components/autocomplete/components/LanguageSelectAutoComplete.tsx +48 -0
  24. package/components/autocomplete/components/ProblemSelectAutoComplete.tsx +54 -0
  25. package/components/autocomplete/components/UserSelectAutoComplete.tsx +54 -0
  26. package/components/autocomplete/domainselectautocomplete.page.styl +6 -0
  27. package/components/autocomplete/index.tsx +110 -0
  28. package/components/autocomplete/problemselectautocomplete.page.styl +6 -0
  29. package/components/autocomplete/userselectautocomplete.page.styl +6 -0
  30. package/components/browser-update.page.ts +27 -0
  31. package/components/calendar/calendar.page.styl +129 -0
  32. package/components/calendar/index.js +367 -0
  33. package/components/clipboard.page.ts +23 -0
  34. package/components/contest/contest.page.styl +119 -0
  35. package/components/contest/contest.page.ts +23 -0
  36. package/components/contest/contest_sidebar.page.styl +21 -0
  37. package/components/contest/problem-contest-bg.png +0 -0
  38. package/components/contest/problem-contest-bg@2x.png +0 -0
  39. package/components/customFont.page.tsx +90 -0
  40. package/components/datepicker/datepicker.page.tsx +94 -0
  41. package/components/dialog/DomDialog.ts +145 -0
  42. package/components/dialog/dialog.page.styl +40 -0
  43. package/components/dialog/index.tsx +285 -0
  44. package/components/discussion/CommentBox.js +103 -0
  45. package/components/discussion/collapsible.page.styl +40 -0
  46. package/components/discussion/collapsible.page.tsx +62 -0
  47. package/components/discussion/comments.page.styl +142 -0
  48. package/components/discussion/comments.page.tsx +192 -0
  49. package/components/discussion/discussion.page.styl +17 -0
  50. package/components/discussion/history.page.tsx +81 -0
  51. package/components/discussion/reaction.page.styl +30 -0
  52. package/components/discussion/reaction.page.tsx +103 -0
  53. package/components/drop/drop.page.styl +40 -0
  54. package/components/dropdown/Dropdown.js +50 -0
  55. package/components/dropdown/dropdown.page.styl +33 -0
  56. package/components/dropdown/dropdown.page.ts +8 -0
  57. package/components/editor/cmeditor.page.ts +23 -0
  58. package/components/editor/cmeditor.styl +10 -0
  59. package/components/editor/index.tsx +293 -0
  60. package/components/editor/mdeditor.ts +60 -0
  61. package/components/editor/textareaHandler.ts +29 -0
  62. package/components/footer/footer.page.styl +94 -0
  63. package/components/footer/footer.page.ts +26 -0
  64. package/components/form/button.page.default.styl +59 -0
  65. package/components/form/button.page.styl +36 -0
  66. package/components/form/checkbox.page.styl +89 -0
  67. package/components/form/form.page.styl +200 -0
  68. package/components/form/form.page.ts +20 -0
  69. package/components/form/multiSelectCheckbox.page.js +46 -0
  70. package/components/form/radiobox.page.styl +62 -0
  71. package/components/form/select.page.styl +29 -0
  72. package/components/form/textbox.page.styl +79 -0
  73. package/components/form/textbox.page.ts +21 -0
  74. package/components/form/var.inc.styl +14 -0
  75. package/components/header/header.page.styl +79 -0
  76. package/components/highlighter/code-example.js +111 -0
  77. package/components/highlighter/highlighter.page.styl +99 -0
  78. package/components/highlighter/highlighter.page.ts +72 -0
  79. package/components/highlighter/meta.js +15 -0
  80. package/components/highlighter/prismjs.js +122 -0
  81. package/components/hint.page.styl +9 -0
  82. package/components/hint.ts +19 -0
  83. package/components/hitokoto/index.page.js +21 -0
  84. package/components/hotkey/hotkey.page.js +83 -0
  85. package/components/katex/katex.page.js +26 -0
  86. package/components/katex/katex.page.styl +2 -0
  87. package/components/languageselect.tsx +94 -0
  88. package/components/loader/loader.page.styl +40 -0
  89. package/components/mantine.page.tsx +39 -0
  90. package/components/marker/Marker.js +192 -0
  91. package/components/marker/MarkerReactive.js +55 -0
  92. package/components/marker/marker.page.js +8 -0
  93. package/components/marker/marker.page.styl +57 -0
  94. package/components/media/media.page.js +46 -0
  95. package/components/menu/menu-heading.page.js +28 -0
  96. package/components/menu/menu.page.js +18 -0
  97. package/components/menu/menu.page.styl +68 -0
  98. package/components/message/index.page.ts +166 -0
  99. package/components/message/worker.ts +110 -0
  100. package/components/messagepad/DialogueListItem.page.styl +28 -0
  101. package/components/messagepad/DialogueListItemComponent.jsx +39 -0
  102. package/components/messagepad/Message.page.styl +64 -0
  103. package/components/messagepad/MessageComponent.jsx +33 -0
  104. package/components/messagepad/MessagePad.page.styl +99 -0
  105. package/components/messagepad/MessagePadDialogueContentContainer.jsx +104 -0
  106. package/components/messagepad/MessagePadDialogueListContainer.jsx +49 -0
  107. package/components/messagepad/MessagePadInputContainer.jsx +100 -0
  108. package/components/messagepad/index.jsx +49 -0
  109. package/components/messagepad/reducers/activeId.ts +36 -0
  110. package/components/messagepad/reducers/dialogues.js +53 -0
  111. package/components/messagepad/reducers/index.ts +14 -0
  112. package/components/messagepad/reducers/inputs.js +43 -0
  113. package/components/messagepad/reducers/isPosting.ts +49 -0
  114. package/components/monaco/index.ts +178 -0
  115. package/components/monaco/languages/markdown.ts +97 -0
  116. package/components/monaco/languages/typescript.ts +45 -0
  117. package/components/monaco/languages/yaml.ts +22 -0
  118. package/components/monaco/loader.ts +96 -0
  119. package/components/monaco/monaco.styl +30 -0
  120. package/components/monaco/nls.js +31 -0
  121. package/components/monaco/schema/problemconfig.ts +123 -0
  122. package/components/navigation/hamburgers.page.styl +87 -0
  123. package/components/navigation/nav-logo-small_dark.png +0 -0
  124. package/components/navigation/navigation.page.js +203 -0
  125. package/components/navigation/navigation.page.styl +211 -0
  126. package/components/notification/index.ts +105 -0
  127. package/components/notification/notification.page.js +14 -0
  128. package/components/notification/notification.page.styl +84 -0
  129. package/components/nprogress.page.styl +50 -0
  130. package/components/omnisearch/index.page.tsx +124 -0
  131. package/components/omnisearch/omnibar.page.styl +138 -0
  132. package/components/pager/pager.page.styl +57 -0
  133. package/components/preview/preview.page.ts +187 -0
  134. package/components/problem/create.page.js +12 -0
  135. package/components/problem/list.page.js +9 -0
  136. package/components/problem/rp.page.styl +4 -0
  137. package/components/problem/tag.page.styl +84 -0
  138. package/components/problemconfig/BasicForm.tsx +92 -0
  139. package/components/problemconfig/ProblemConfigEditor.tsx +170 -0
  140. package/components/problemconfig/ProblemConfigForm.tsx +140 -0
  141. package/components/problemconfig/ProblemConfigTree.tsx +163 -0
  142. package/components/problemconfig/ProblemType.tsx +165 -0
  143. package/components/problemconfig/index.tsx +91 -0
  144. package/components/problemconfig/reducer/config.ts +173 -0
  145. package/components/problemconfig/reducer/index.ts +11 -0
  146. package/components/problemconfig/reducer/testdata.ts +16 -0
  147. package/components/problemconfig/tree/AddTestcase.tsx +137 -0
  148. package/components/problemconfig/tree/SelectionManager.tsx +140 -0
  149. package/components/problemconfig/tree/SubtaskSettings.tsx +180 -0
  150. package/components/problemconfig/tree/Testcase.tsx +98 -0
  151. package/components/profile/backgrounds/1.jpg +0 -0
  152. package/components/profile/backgrounds/10.jpg +0 -0
  153. package/components/profile/backgrounds/11.jpg +0 -0
  154. package/components/profile/backgrounds/12.jpg +0 -0
  155. package/components/profile/backgrounds/13.jpg +0 -0
  156. package/components/profile/backgrounds/14.jpg +0 -0
  157. package/components/profile/backgrounds/15.jpg +0 -0
  158. package/components/profile/backgrounds/16.jpg +0 -0
  159. package/components/profile/backgrounds/17.jpg +0 -0
  160. package/components/profile/backgrounds/18.jpg +0 -0
  161. package/components/profile/backgrounds/19.jpg +0 -0
  162. package/components/profile/backgrounds/2.jpg +0 -0
  163. package/components/profile/backgrounds/20.jpg +0 -0
  164. package/components/profile/backgrounds/21.jpg +0 -0
  165. package/components/profile/backgrounds/3.jpg +0 -0
  166. package/components/profile/backgrounds/4.jpg +0 -0
  167. package/components/profile/backgrounds/5.jpg +0 -0
  168. package/components/profile/backgrounds/6.jpg +0 -0
  169. package/components/profile/backgrounds/7.jpg +0 -0
  170. package/components/profile/backgrounds/8.jpg +0 -0
  171. package/components/profile/backgrounds/9.jpg +0 -0
  172. package/components/profile/backgrounds/gen_thumbnails.sh +7 -0
  173. package/components/profile/backgrounds/thumbnail/1.jpg +0 -0
  174. package/components/profile/backgrounds/thumbnail/10.jpg +0 -0
  175. package/components/profile/backgrounds/thumbnail/11.jpg +0 -0
  176. package/components/profile/backgrounds/thumbnail/12.jpg +0 -0
  177. package/components/profile/backgrounds/thumbnail/13.jpg +0 -0
  178. package/components/profile/backgrounds/thumbnail/14.jpg +0 -0
  179. package/components/profile/backgrounds/thumbnail/15.jpg +0 -0
  180. package/components/profile/backgrounds/thumbnail/16.jpg +0 -0
  181. package/components/profile/backgrounds/thumbnail/17.jpg +0 -0
  182. package/components/profile/backgrounds/thumbnail/18.jpg +0 -0
  183. package/components/profile/backgrounds/thumbnail/19.jpg +0 -0
  184. package/components/profile/backgrounds/thumbnail/2.jpg +0 -0
  185. package/components/profile/backgrounds/thumbnail/20.jpg +0 -0
  186. package/components/profile/backgrounds/thumbnail/21.jpg +0 -0
  187. package/components/profile/backgrounds/thumbnail/3.jpg +0 -0
  188. package/components/profile/backgrounds/thumbnail/4.jpg +0 -0
  189. package/components/profile/backgrounds/thumbnail/5.jpg +0 -0
  190. package/components/profile/backgrounds/thumbnail/6.jpg +0 -0
  191. package/components/profile/backgrounds/thumbnail/7.jpg +0 -0
  192. package/components/profile/backgrounds/thumbnail/8.jpg +0 -0
  193. package/components/profile/backgrounds/thumbnail/9.jpg +0 -0
  194. package/components/profile/profile.page.styl +23 -0
  195. package/components/react/DomComponent.tsx +14 -0
  196. package/components/react/IconComponent.tsx +20 -0
  197. package/components/record/record.page.styl +26 -0
  198. package/components/rotator/index.js +75 -0
  199. package/components/rotator/rotator.page.styl +20 -0
  200. package/components/scratchpad/DataInput.page.styl +17 -0
  201. package/components/scratchpad/DataInputComponent.jsx +45 -0
  202. package/components/scratchpad/Editor.page.styl +13 -0
  203. package/components/scratchpad/Panel.page.styl +18 -0
  204. package/components/scratchpad/PanelButton.page.styl +15 -0
  205. package/components/scratchpad/PanelButtonComponent.jsx +19 -0
  206. package/components/scratchpad/PanelComponent.jsx +25 -0
  207. package/components/scratchpad/ScratchpadEditorContainer.tsx +137 -0
  208. package/components/scratchpad/ScratchpadPretestContainer.jsx +57 -0
  209. package/components/scratchpad/ScratchpadRecordsContainer.jsx +45 -0
  210. package/components/scratchpad/ScratchpadRecordsRowContainer.jsx +83 -0
  211. package/components/scratchpad/ScratchpadSettings.tsx +48 -0
  212. package/components/scratchpad/ScratchpadToolbarContainer.jsx +190 -0
  213. package/components/scratchpad/Tab.page.styl +24 -0
  214. package/components/scratchpad/Toolbar.page.styl +53 -0
  215. package/components/scratchpad/ToolbarComponent.jsx +85 -0
  216. package/components/scratchpad/index.tsx +132 -0
  217. package/components/scratchpad/reducers/editor.ts +24 -0
  218. package/components/scratchpad/reducers/index.ts +17 -0
  219. package/components/scratchpad/reducers/pretest.ts +34 -0
  220. package/components/scratchpad/reducers/records.ts +40 -0
  221. package/components/scratchpad/reducers/state.ts +10 -0
  222. package/components/scratchpad/reducers/ui.ts +152 -0
  223. package/components/scratchpad/scratchpad.page.styl +55 -0
  224. package/components/scratchpad/var.inc.styl +2 -0
  225. package/components/selectUser.tsx +16 -0
  226. package/components/signin/signInDialog.page.js +84 -0
  227. package/components/signin/signin_dialog.page.styl +57 -0
  228. package/components/smoothscroll/smoothscroll.page.js +44 -0
  229. package/components/socket/index.ts +68 -0
  230. package/components/star/star.page.styl +20 -0
  231. package/components/star/star.page.ts +58 -0
  232. package/components/sticky/sticky.page.js +66 -0
  233. package/components/tab/Tab.js +168 -0
  234. package/components/tab/tab.page.js +9 -0
  235. package/components/tab/tab.page.styl +105 -0
  236. package/components/tab/var.inc.styl +3 -0
  237. package/components/table/StyledTable.js +51 -0
  238. package/components/table/styledTable.page.js +8 -0
  239. package/components/table/table.page.styl +73 -0
  240. package/components/time/time.page.js +47 -0
  241. package/components/tooltip/Tooltip.js +49 -0
  242. package/components/tooltip/tooltip.page.js +29 -0
  243. package/components/tooltip/tooltip.page.styl +69 -0
  244. package/components/training/training.page.styl +25 -0
  245. package/components/upload.tsx +103 -0
  246. package/components/vote/vote.page.js +43 -0
  247. package/components/zipDownloader/index.ts +157 -0
  248. package/constant/domain.js +21 -0
  249. package/constant/message.js +5 -0
  250. package/constant/record.js +52 -0
  251. package/context.ts +11 -0
  252. package/entry.js +72 -0
  253. package/hydro.ts +112 -0
  254. package/index.ts +226 -0
  255. package/lazyload.ts +69 -0
  256. package/locales/en.yaml +71 -0
  257. package/locales/ko.yaml +823 -0
  258. package/locales/zh.yaml +1137 -0
  259. package/locales/zh_TW.yaml +1133 -0
  260. package/misc/Page.ts +49 -0
  261. package/misc/PageLoader.js +31 -0
  262. package/misc/float.styl +14 -0
  263. package/misc/grid.styl +1048 -0
  264. package/misc/immersive-background.jpg +0 -0
  265. package/misc/immersive-background@2x.jpg +0 -0
  266. package/misc/immersive.styl +23 -0
  267. package/misc/nothing.styl +13 -0
  268. package/misc/puzzled_twd2.svg +1 -0
  269. package/misc/section.styl +105 -0
  270. package/misc/slideout.styl +46 -0
  271. package/misc/structure.styl +158 -0
  272. package/misc/textalign.styl +11 -0
  273. package/misc/typography.styl +485 -0
  274. package/package.json +148 -0
  275. package/polyfill.ts +90 -0
  276. package/postcss.config.js +15 -0
  277. package/sentry.ts +26 -0
  278. package/service-worker.ts +265 -0
  279. package/setting.yaml +98 -0
  280. package/templates/about.html +14 -0
  281. package/templates/bsod.html +35 -0
  282. package/templates/components/comments_discussion.html +165 -0
  283. package/templates/components/comments_solution.html +171 -0
  284. package/templates/components/contest.html +12 -0
  285. package/templates/components/form.html +214 -0
  286. package/templates/components/home.html +20 -0
  287. package/templates/components/homework.html +8 -0
  288. package/templates/components/md_hint.html +39 -0
  289. package/templates/components/noscript_note.html +15 -0
  290. package/templates/components/nothing.html +6 -0
  291. package/templates/components/paginator.html +25 -0
  292. package/templates/components/problem.html +33 -0
  293. package/templates/components/record.html +21 -0
  294. package/templates/components/sidemenu.html +11 -0
  295. package/templates/components/user.html +49 -0
  296. package/templates/contest_balloon.html +48 -0
  297. package/templates/contest_clarification.html +103 -0
  298. package/templates/contest_detail.html +56 -0
  299. package/templates/contest_edit.html +259 -0
  300. package/templates/contest_main.html +146 -0
  301. package/templates/contest_manage.html +80 -0
  302. package/templates/contest_print.html +27 -0
  303. package/templates/contest_problemlist.html +231 -0
  304. package/templates/contest_scoreboard.html +46 -0
  305. package/templates/contest_scoreboard_download_html.html +71 -0
  306. package/templates/contest_user.html +47 -0
  307. package/templates/discussion_create.html +28 -0
  308. package/templates/discussion_detail.html +149 -0
  309. package/templates/discussion_edit.html +30 -0
  310. package/templates/discussion_main_or_node.html +47 -0
  311. package/templates/domain_base.html +26 -0
  312. package/templates/domain_create.html +55 -0
  313. package/templates/domain_dashboard.html +45 -0
  314. package/templates/domain_edit.html +6 -0
  315. package/templates/domain_group.html +51 -0
  316. package/templates/domain_join.html +47 -0
  317. package/templates/domain_join_applications.html +67 -0
  318. package/templates/domain_permission.html +66 -0
  319. package/templates/domain_role.html +71 -0
  320. package/templates/domain_user.html +86 -0
  321. package/templates/domain_user_raw.html +5 -0
  322. package/templates/error.html +25 -0
  323. package/templates/home_domain.html +64 -0
  324. package/templates/home_files.html +16 -0
  325. package/templates/home_messages.html +9 -0
  326. package/templates/home_security.html +224 -0
  327. package/templates/home_settings.html +21 -0
  328. package/templates/homework_detail.html +82 -0
  329. package/templates/homework_edit.html +138 -0
  330. package/templates/homework_files.html +24 -0
  331. package/templates/homework_main.html +76 -0
  332. package/templates/layout/basic.html +27 -0
  333. package/templates/layout/home_base.html +13 -0
  334. package/templates/layout/html5.html +74 -0
  335. package/templates/layout/immersive.html +22 -0
  336. package/templates/layout/mail.html +31 -0
  337. package/templates/layout/simple.html +4 -0
  338. package/templates/layout/wiki_base.html +16 -0
  339. package/templates/main.html +22 -0
  340. package/templates/manage_base.html +24 -0
  341. package/templates/manage_config.html +6 -0
  342. package/templates/manage_dashboard.html +27 -0
  343. package/templates/manage_script.html +56 -0
  344. package/templates/manage_setting.html +6 -0
  345. package/templates/manage_user_import.html +23 -0
  346. package/templates/manage_user_priv.html +76 -0
  347. package/templates/partials/category.html +19 -0
  348. package/templates/partials/contest.html +3 -0
  349. package/templates/partials/contest_balloon.html +37 -0
  350. package/templates/partials/contest_sidebar.html +150 -0
  351. package/templates/partials/contest_sidebar_management.html +56 -0
  352. package/templates/partials/contest_user.html +19 -0
  353. package/templates/partials/discussion_edit_form.html +45 -0
  354. package/templates/partials/discussion_list.html +50 -0
  355. package/templates/partials/discussion_nodes_widget.html +17 -0
  356. package/templates/partials/files.html +49 -0
  357. package/templates/partials/footer.html +108 -0
  358. package/templates/partials/hamburger.html +7 -0
  359. package/templates/partials/header_mobile.html +12 -0
  360. package/templates/partials/homepage/bulletin.html +7 -0
  361. package/templates/partials/homepage/contest.html +48 -0
  362. package/templates/partials/homepage/discussion.html +13 -0
  363. package/templates/partials/homepage/discussion_nodes.html +4 -0
  364. package/templates/partials/homepage/error.html +5 -0
  365. package/templates/partials/homepage/hitokoto.html +6 -0
  366. package/templates/partials/homepage/homework.html +45 -0
  367. package/templates/partials/homepage/problem_search.html +13 -0
  368. package/templates/partials/homepage/ranking.html +39 -0
  369. package/templates/partials/homepage/recent_problems.html +17 -0
  370. package/templates/partials/homepage/starred_problems.html +15 -0
  371. package/templates/partials/homepage/suggestion.html +34 -0
  372. package/templates/partials/homepage/training.html +50 -0
  373. package/templates/partials/homework.html +3 -0
  374. package/templates/partials/homework_default_penalty_rules.yaml +6 -0
  375. package/templates/partials/homework_sidebar.html +93 -0
  376. package/templates/partials/login_dialog.html +56 -0
  377. package/templates/partials/manage_user_priv.html +78 -0
  378. package/templates/partials/nav.html +138 -0
  379. package/templates/partials/problem-sidebar-information.html +25 -0
  380. package/templates/partials/problem.html +2 -0
  381. package/templates/partials/problem_category_dialog.html +43 -0
  382. package/templates/partials/problem_default.md +26 -0
  383. package/templates/partials/problem_description.html +33 -0
  384. package/templates/partials/problem_files.html +63 -0
  385. package/templates/partials/problem_list.html +68 -0
  386. package/templates/partials/problem_lucky.html +10 -0
  387. package/templates/partials/problem_sidebar.html +14 -0
  388. package/templates/partials/problem_sidebar_contest.html +43 -0
  389. package/templates/partials/problem_sidebar_homework.html +42 -0
  390. package/templates/partials/problem_sidebar_normal.html +152 -0
  391. package/templates/partials/problem_stat.html +3 -0
  392. package/templates/partials/scoreboard.html +79 -0
  393. package/templates/partials/setting.html +92 -0
  394. package/templates/partials/training_default.json +14 -0
  395. package/templates/partials/training_detail.html +153 -0
  396. package/templates/partials/user.html +2 -0
  397. package/templates/partials/user_detail/activity.html +18 -0
  398. package/templates/partials/user_detail/solution.html +29 -0
  399. package/templates/problem_config.html +39 -0
  400. package/templates/problem_detail.html +150 -0
  401. package/templates/problem_edit.html +111 -0
  402. package/templates/problem_files.html +91 -0
  403. package/templates/problem_hack.html +41 -0
  404. package/templates/problem_import.html +58 -0
  405. package/templates/problem_main.html +100 -0
  406. package/templates/problem_solution.html +55 -0
  407. package/templates/problem_statistics.html +96 -0
  408. package/templates/problem_submit.html +40 -0
  409. package/templates/ranking.html +81 -0
  410. package/templates/record_detail.html +134 -0
  411. package/templates/record_detail_status.html +93 -0
  412. package/templates/record_detail_summary.html +19 -0
  413. package/templates/record_main.html +142 -0
  414. package/templates/record_main_tr.html +35 -0
  415. package/templates/status.html +75 -0
  416. package/templates/training_detail.html +120 -0
  417. package/templates/training_edit.html +68 -0
  418. package/templates/training_files.html +64 -0
  419. package/templates/training_main.html +107 -0
  420. package/templates/user_changemail_mail.html +6 -0
  421. package/templates/user_changemail_mail_sent.html +9 -0
  422. package/templates/user_delete_pending.html +10 -0
  423. package/templates/user_detail.html +181 -0
  424. package/templates/user_login.html +46 -0
  425. package/templates/user_logout.html +13 -0
  426. package/templates/user_lostpass.html +27 -0
  427. package/templates/user_lostpass_mail.html +6 -0
  428. package/templates/user_lostpass_mail_sent.html +9 -0
  429. package/templates/user_lostpass_with_code.html +29 -0
  430. package/templates/user_register.html +22 -0
  431. package/templates/user_register_mail.html +6 -0
  432. package/templates/user_register_mail_sent.html +9 -0
  433. package/templates/user_register_with_code.html +35 -0
  434. package/templates/user_sudo.html +54 -0
  435. package/templates/user_sudo_redirect.html +18 -0
  436. package/templates/wiki_help.html +189 -0
  437. package/theme/bp6-compat.css +48 -0
  438. package/theme/dark.styl +397 -0
  439. package/theme/default.js +33 -0
  440. package/typed.d.ts +20 -0
  441. package/utils/base.ts +209 -0
  442. package/utils/base64.js +104 -0
  443. package/utils/db.ts +32 -0
  444. package/utils/index.ts +73 -0
  445. package/utils/loadReactRedux.ts +32 -0
  446. package/utils/mediaQuery.ts +13 -0
  447. package/utils/pjax.js +148 -0
  448. package/utils/slide.ts +57 -0
@@ -0,0 +1,91 @@
1
+ import { Button, Tabs } from '@mantine/core';
2
+ import { Allotment } from 'allotment';
3
+ import { ContextMenuProvider } from 'mantine-contextmenu';
4
+ import React from 'react';
5
+ import { useSelector, useStore } from 'react-redux';
6
+ import { confirm } from 'vj/components/dialog/index';
7
+ import { i18n } from 'vj/utils';
8
+ import ProblemConfigEditor from './ProblemConfigEditor';
9
+ import ProblemConfigForm from './ProblemConfigForm';
10
+ import { ProblemConfigTree } from './ProblemConfigTree';
11
+ import { RootState } from './reducer';
12
+
13
+ interface Props {
14
+ onSave: () => void;
15
+ }
16
+
17
+ export default function ProblemConfig(props: Props) {
18
+ const [selected, setSelected] = React.useState('basic');
19
+ const [container, setContainer] = React.useState<HTMLDivElement | null>(null);
20
+ const [tabs, setTabs] = React.useState<HTMLDivElement | null>(null);
21
+ const [editor, setEditor] = React.useState<any>(null);
22
+ const store = useStore<RootState>();
23
+ const valid = useSelector((state: RootState) => state.config.__valid);
24
+ const errors = useSelector((state: RootState) => state.config.__errors, (a, b) => JSON.stringify(a) === JSON.stringify(b));
25
+
26
+ const handleSave = React.useCallback(async () => {
27
+ if (valid) props.onSave();
28
+ else if (await confirm(i18n('Errors detected in the config. Confirm save?'))) props.onSave();
29
+ }, [valid, props.onSave]);
30
+
31
+ React.useEffect(() => {
32
+ if (!container) return () => { };
33
+ container.style.height ||= '600px';
34
+ const callback = () => {
35
+ setTimeout(() => {
36
+ const target = Math.max(container.clientHeight, tabs?.clientHeight || 0);
37
+ container.style.height = `${target}px`;
38
+ if (editor) editor.layout();
39
+ }, 50);
40
+ };
41
+ const dispose = store.subscribe(callback);
42
+ window.addEventListener('resize', callback);
43
+ return () => {
44
+ dispose();
45
+ window.removeEventListener('resize', callback);
46
+ };
47
+ }, [container, tabs, store]);
48
+
49
+ return <ContextMenuProvider>
50
+ <div ref={setContainer}>
51
+ <Allotment
52
+ defaultSizes={[2, 3]}
53
+ className="problem-config-allotment">
54
+ <Allotment.Pane>
55
+ <div style={{ height: '100%', overflow: 'auto' }}>
56
+ <ProblemConfigEditor ref={setEditor} />
57
+ </div>
58
+ </Allotment.Pane>
59
+ <Allotment.Pane>
60
+ <Tabs
61
+ ref={setTabs}
62
+ value={valid ? selected : 'errors'}
63
+ keepMounted={false}
64
+ style={{ paddingLeft: 20 }}
65
+ onChange={(t) => (t !== 'errors' && t && setSelected(t.toString()))}
66
+ >
67
+ <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
68
+ <Tabs.List>
69
+ <Tabs.Tab value="basic" disabled={!valid}>{i18n('Basic')}</Tabs.Tab>
70
+ <Tabs.Tab value="subtasks" disabled={!valid}>{i18n('Subtasks')}</Tabs.Tab>
71
+ <Tabs.Tab value="errors" disabled={valid}>{errors.length ? `Errors(${errors.length})` : 'No Errors'}</Tabs.Tab>
72
+ </Tabs.List>
73
+ <Button onClick={handleSave}>
74
+ {i18n('Save')}
75
+ </Button>
76
+ </div>
77
+ <Tabs.Panel value="basic">
78
+ <ProblemConfigForm />
79
+ </Tabs.Panel>
80
+ <Tabs.Panel value="subtasks">
81
+ <ProblemConfigTree />
82
+ </Tabs.Panel>
83
+ <Tabs.Panel value="errors">
84
+ <div>{errors.map((i) => (<pre key={i}>{i}</pre>))}</div>
85
+ </Tabs.Panel>
86
+ </Tabs>
87
+ </Allotment.Pane>
88
+ </Allotment>
89
+ </div>
90
+ </ContextMenuProvider>;
91
+ }
@@ -0,0 +1,173 @@
1
+ import { parseMemoryMB, parseTimeMS, sortFiles } from '@hydrooj/utils/lib/common';
2
+ import type { ProblemConfigFile, TestCaseConfig } from 'hydrooj/src/interface';
3
+ import Ajv from 'ajv';
4
+ import yaml from 'js-yaml';
5
+ import { cloneDeep } from 'lodash';
6
+ import schema from '../../monaco/schema/problemconfig';
7
+
8
+ type State = ProblemConfigFile & {
9
+ __loaded: boolean;
10
+ __valid: boolean;
11
+ __errors: string[];
12
+ __cases: TestCaseConfig[];
13
+ };
14
+ const ajv = new Ajv();
15
+ const validate = ajv.compile(schema);
16
+
17
+ export default function reducer(state = {
18
+ type: 'default', __loaded: false, __valid: false, __errors: [], __cases: [], subtasks: [],
19
+ } as State, action: any = {}): State {
20
+ switch (action.type) {
21
+ case 'CONFIG_LOAD_FULFILLED': {
22
+ const c = { ...state, __loaded: true };
23
+ try {
24
+ let data = yaml.load(action.payload.config) as any;
25
+ if (typeof data !== 'object') data = { subtasks: [] };
26
+ else data.subtasks ||= [];
27
+ if (!validate(data)) {
28
+ Object.assign(c, data);
29
+ c.__errors = validate.errors.map((i) => `${i.instancePath}: ${i.message}`);
30
+ return c;
31
+ }
32
+ const subtasks = (data as any).subtasks;
33
+ for (const subtask of subtasks) {
34
+ if (typeof subtask.id !== 'number') {
35
+ for (let i = 1; ; i++) {
36
+ if (!subtasks.find((s) => s.id === i)) {
37
+ subtask.id = i;
38
+ break;
39
+ }
40
+ }
41
+ }
42
+ }
43
+ Object.assign(c, data);
44
+ c.__valid = true;
45
+ } catch (e) {
46
+ c.__errors.push(e.message);
47
+ }
48
+ return c;
49
+ }
50
+ case 'CONFIG_FORM_UPDATE': {
51
+ const next = { ...state, [action.key]: action.value };
52
+ if (action.key === 'score' && action.value) next.score = +next.score;
53
+ if (action.key === 'checker_type' && action.value === 'other') next.checker_type = 'syzoj';
54
+ if (!action.value || (action.value instanceof Array && !action.value.join(''))) delete next[action.key];
55
+ return next;
56
+ }
57
+ case 'CONFIG_CODE_UPDATE': {
58
+ try {
59
+ const data = yaml.load(action.payload);
60
+ if (!validate(data)) {
61
+ return {
62
+ ...state,
63
+ __valid: false,
64
+ __errors: validate.errors.map((i) => `${i.instancePath}: ${i.message}`),
65
+ __loaded: true,
66
+ };
67
+ }
68
+ return {
69
+ ...state, ...data as object, __valid: true, __errors: [], __loaded: true,
70
+ };
71
+ } catch (e) {
72
+ return {
73
+ ...state, __valid: false, __errors: [e.message], __loaded: true,
74
+ };
75
+ }
76
+ }
77
+ case 'CONFIG_AUTOCASES_UPDATE': {
78
+ const next = { ...state };
79
+ const { subtasks } = action;
80
+ for (const subtask of subtasks) {
81
+ if (subtask.time === parseTimeMS(state.time || '1s')) delete subtask.time;
82
+ if (subtask.memory === parseMemoryMB(state.memory || '256m')) delete subtask.memory;
83
+ if (subtask.time) subtask.time += 'ms';
84
+ if (subtask.memory) subtask.memory += 'MB';
85
+ if (typeof subtask.id !== 'number') {
86
+ for (let i = 1; ; i++) {
87
+ if (!subtasks.find((s) => s.id === s)) {
88
+ subtask.id = i;
89
+ break;
90
+ }
91
+ }
92
+ }
93
+ }
94
+ if (subtasks.length === 0) next.subtasks = [];
95
+ else {
96
+ next.subtasks = subtasks.map((subtask) => (
97
+ { ...subtask, ...{ cases: subtask.cases.map((i) => ({ input: i.input, output: i.output })) } }));
98
+ }
99
+ return next;
100
+ }
101
+ case 'problemconfig/updateFileIO': {
102
+ const n = { ...state, filename: action.filename };
103
+ if (!n.filename) delete n.filename;
104
+ return n;
105
+ }
106
+ case 'problemconfig/updateGlobalConfig': {
107
+ const n = { ...state, time: action.time, memory: action.memory };
108
+ if (!n.time) delete n.time;
109
+ if (!n.memory) delete n.memory;
110
+ return n;
111
+ }
112
+ case 'problemconfig/addSubtask': {
113
+ const subtasks = cloneDeep(state.subtasks);
114
+ subtasks.push({
115
+ cases: [],
116
+ score: 0,
117
+ id: Object.keys(subtasks).map((i) => subtasks[i].id).reduce((a, b) => Math.max(+a, +b), 0) + 1,
118
+ });
119
+ return { ...state, subtasks };
120
+ }
121
+ case 'problemconfig/updateSubtaskConfig': {
122
+ if (!state.subtasks.find((i) => i.id === action.id)) return state;
123
+ const subtask = { ...state.subtasks.find((i) => i.id === action.id) };
124
+ const subtasks = [...state.subtasks];
125
+ subtasks.splice(state.subtasks.findIndex((i) => i.id === action.id), 1, subtask);
126
+ if (action.payload.time) subtask.time = action.payload.time;
127
+ if (action.payload.memory) subtask.memory = action.payload.memory;
128
+ if (action.payload.score) subtask.score = +action.payload.score || 0;
129
+ if (action.payload.if) subtask.if = action.payload.if;
130
+ if (action.payload.type) subtask.type = action.payload.type;
131
+ if (!subtask.time) delete subtask.time;
132
+ if (!subtask.memory) delete subtask.memory;
133
+ return { ...state, subtasks };
134
+ }
135
+ case 'problemconfig/addTestcases': {
136
+ return { ...state, __cases: sortFiles([...state.__cases, ...action.cases], 'input') };
137
+ }
138
+ case 'problemconfig/moveTestcases': {
139
+ const testcases = action.payload.cases;
140
+ const subtasks = cloneDeep(state.subtasks);
141
+ const targetCases = action.payload.target === -1
142
+ ? state.__cases
143
+ : (subtasks.find((s) => s.id === action.payload.target)?.cases || []);
144
+ const toAdd = testcases.filter((tc) => !targetCases.find((j) => j.input === tc.input && j.output === tc.output));
145
+ const __cases = action.payload.source === -1
146
+ ? state.__cases.filter((i) => !testcases.find((j) => i.input === j.input && i.output === j.output))
147
+ : action.payload.target === -1
148
+ ? sortFiles([...state.__cases, ...toAdd], 'input')
149
+ : state.__cases;
150
+ for (const key in subtasks) {
151
+ const subtask = subtasks[key];
152
+ if (subtask.id === action.payload.source) {
153
+ subtask.cases = subtask.cases.filter((i) => !testcases.find((j) => i.input === j.input && i.output === j.output));
154
+ } else if (subtask.id === action.payload.target) {
155
+ subtask.cases = sortFiles([...subtask.cases, ...toAdd], 'input');
156
+ }
157
+ }
158
+ return { ...state, subtasks, __cases };
159
+ }
160
+ case 'problemconfig/delTestcases': {
161
+ const testcases = action.cases;
162
+ return { ...state, __cases: state.__cases.filter((i) => !testcases.find((j) => i.input === j.input && i.output === j.output)) };
163
+ }
164
+ case 'problemconfig/deleteSubtask': {
165
+ const currentCases = state.subtasks.find((i) => i.id === action.id)?.cases || [];
166
+ const subtasks = state.subtasks.filter((i) => i.id !== action.id);
167
+ const add = currentCases.filter((i) => !subtasks.find((j) => j.cases.find((k) => k.input === i.input && k.output === i.output)));
168
+ return { ...state, subtasks, __cases: sortFiles([...state.__cases, ...add], 'input') };
169
+ }
170
+ default:
171
+ return state;
172
+ }
173
+ }
@@ -0,0 +1,11 @@
1
+ import { combineReducers } from 'redux';
2
+ import config from './config';
3
+ import testdata from './testdata';
4
+
5
+ const reducer = combineReducers({
6
+ config,
7
+ testdata,
8
+ });
9
+
10
+ export default reducer;
11
+ export type RootState = ReturnType<typeof reducer>;
@@ -0,0 +1,16 @@
1
+ export default function reducer(state = [], action: any = {}) {
2
+ switch (action.type) {
3
+ case 'CONFIG_LOAD_FULFILLED': {
4
+ return state.concat(action.payload.testdata);
5
+ }
6
+ case 'CONFIG_DELETE_TESTDATA': {
7
+ const next = state.filter((i) => i.name !== action.value[0]);
8
+ return next;
9
+ }
10
+ case 'CONFIG_ADD_TESTDATA': {
11
+ return state.concat([action.value]);
12
+ }
13
+ default:
14
+ return state;
15
+ }
16
+ }
@@ -0,0 +1,137 @@
1
+ import { readSubtasksFromFiles } from '@hydrooj/common';
2
+ import { Button, Modal, Text } from '@mantine/core';
3
+ import React, { useEffect, useRef } from 'react';
4
+ import { useSelector, useStore } from 'react-redux';
5
+ import { i18n } from 'vj/utils';
6
+ import FileSelectAutoComplete from '../../autocomplete/components/FileSelectAutoComplete';
7
+ import { RootState } from '../reducer';
8
+
9
+ export function AddTestcase() {
10
+ const [open, setOpen] = React.useState(false);
11
+ const [input, setInput] = React.useState('');
12
+ const [output, setOutput] = React.useState('');
13
+ const [valid, setValid] = React.useState(false);
14
+ const [autoInput, setAutoInput] = React.useState(true);
15
+ const [autoOutput, setAutoOutput] = React.useState(true);
16
+ const testdata = useSelector((state: RootState) => state.testdata);
17
+ const store = useStore<RootState>();
18
+ const refInput = useRef(null);
19
+ const refOutput = useRef(null);
20
+
21
+ useEffect(() => {
22
+ const inputValid = testdata.find((i) => i.name === input);
23
+ if (input) setAutoInput(false);
24
+ else setAutoInput(true);
25
+ setValid(inputValid);
26
+ if (inputValid && autoOutput) {
27
+ const filename = input.substring(0, input.lastIndexOf('.'));
28
+ let outputFile = '';
29
+ if (testdata.find((i) => i.name === `${filename}.out`)) outputFile = `${filename}.out`;
30
+ else if (testdata.find((i) => i.name === `${filename}.ans`)) outputFile = `${filename}.ans`;
31
+ if (outputFile) {
32
+ // @ts-ignore
33
+ refOutput.current!.setSelectedItems([outputFile]);
34
+ setOutput(outputFile);
35
+ setAutoOutput(true);
36
+ }
37
+ }
38
+ }, [input]);
39
+
40
+ useEffect(() => {
41
+ const outputValid = testdata.find((i) => i.name === output);
42
+ if (output) setAutoOutput(false);
43
+ else setAutoOutput(true);
44
+ setValid(outputValid);
45
+ if (outputValid && autoInput) {
46
+ const filename = output.substring(0, output.lastIndexOf('.'));
47
+ if (testdata.find((i) => i.name === `${filename}.in`)) {
48
+ // @ts-ignore
49
+ refInput.current!.setSelectedItems([`${filename}.in`]);
50
+ setInput(`${filename}.in`);
51
+ setAutoInput(true);
52
+ }
53
+ }
54
+ }, [output]);
55
+
56
+ function onConfirm() {
57
+ store.dispatch({
58
+ type: 'problemconfig/addTestcases',
59
+ cases: [{ input, output }],
60
+ });
61
+ setOpen(false);
62
+ }
63
+
64
+ function auto() {
65
+ const state = store.getState();
66
+ const subtasks = readSubtasksFromFiles(state.testdata.map((i) => i.name), {});
67
+ const current = state.config.subtasks.flatMap((i) => i.cases).concat(state.config.__cases);
68
+ const pending = [];
69
+ for (const c of subtasks.flatMap((s) => s.cases)) {
70
+ if (!current.find((i) => i.input === c.input && i.output === c.output)) {
71
+ pending.push({
72
+ input: c.input,
73
+ output: c.output,
74
+ });
75
+ }
76
+ }
77
+ store.dispatch({
78
+ type: 'problemconfig/addTestcases',
79
+ cases: pending,
80
+ });
81
+ }
82
+
83
+ return (<>
84
+ <div
85
+ style={{ cursor: 'pointer', padding: '6px 0' }}
86
+ onClick={auto}
87
+ >
88
+ <Text><i className="icon icon-wrench" /> {i18n('Auto detect')}</Text>
89
+ </div>
90
+ <div
91
+ style={{ cursor: 'pointer', padding: '6px 0' }}
92
+ onClick={() => {
93
+ setInput('');
94
+ setOutput('');
95
+ setAutoInput(true);
96
+ setAutoOutput(true);
97
+ setOpen(true);
98
+ }}
99
+ >
100
+ <Text><i className="icon icon-add" /> {i18n('Add testcase')}</Text>
101
+ </div>
102
+ <Modal
103
+ opened={open}
104
+ onClose={() => setOpen(false)}
105
+ title={i18n('Add testcase')}
106
+ styles={{ body: { overflow: 'visible' }, content: { overflow: 'visible' } }}
107
+ >
108
+ <div className="row" style={{ overflow: 'visible' }}>
109
+ <div className="columns medium-6" style={{ overflow: 'visible' }}>
110
+ <FileSelectAutoComplete
111
+ ref={refInput}
112
+ data={testdata}
113
+ label="Input"
114
+ width="100%"
115
+ onChange={(e) => setInput(e)}
116
+ placeholder={i18n('Input')}
117
+ value={input || ''}
118
+ />
119
+ </div>
120
+ <div className="columns medium-6" style={{ overflow: 'visible' }}>
121
+ <FileSelectAutoComplete
122
+ ref={refOutput}
123
+ data={testdata}
124
+ label="Output"
125
+ width="100%"
126
+ onChange={(e) => setOutput(e)}
127
+ placeholder={i18n('Output')}
128
+ value={output || ''}
129
+ />
130
+ </div>
131
+ </div>
132
+ <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: 12 }}>
133
+ <Button onClick={onConfirm} disabled={!valid}> {i18n('Save')}</Button>
134
+ </div>
135
+ </Modal>
136
+ </>);
137
+ }
@@ -0,0 +1,140 @@
1
+ import React from 'react';
2
+ import { useSelector } from 'react-redux';
3
+ import { RootState } from '../reducer';
4
+ import { TestcaseGroup } from './Testcase';
5
+
6
+ interface SelectionManagerProps {
7
+ subtaskId: number;
8
+ subtaskIds: number[];
9
+ }
10
+
11
+ function collide(rect1: any, rect2: any): boolean {
12
+ if ('getBoundingClientRect' in rect1) rect1 = rect1.getBoundingClientRect();
13
+ if ('getBoundingClientRect' in rect2) rect2 = rect2.getBoundingClientRect();
14
+ const maxX = Math.max(rect1.x + rect1.width, rect2.x + rect2.width);
15
+ const maxY = Math.max(rect1.y + rect1.height, rect2.y + rect2.height);
16
+ const minX = Math.min(rect1.x, rect2.x);
17
+ const minY = Math.min(rect1.y, rect2.y);
18
+ return maxX - minX <= rect1.width + rect2.width && maxY - minY <= rect1.height + rect2.height;
19
+ }
20
+
21
+ export function SelectionManager(props: SelectionManagerProps) {
22
+ const { subtaskIds, subtaskId } = props;
23
+ const cases = useSelector((state: RootState) => (subtaskId === -1
24
+ ? state.config.__cases || []
25
+ : state.config.subtasks.find((i) => i.id === subtaskId).cases || []));
26
+ // Don't need to trigger a re-render for this property change
27
+ const pos = React.useMemo(() => ({
28
+ x: 0, y: 0, endX: 0, endY: 0,
29
+ }), []);
30
+ const [start, setStart] = React.useState(0);
31
+ const [end, setEnd] = React.useState(0);
32
+ React.useEffect(() => {
33
+ setStart(0);
34
+ setEnd(0);
35
+ }, [JSON.stringify(cases)]);
36
+
37
+ const selecting = React.useRef(false);
38
+
39
+ const handleMouseDown = React.useCallback((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
40
+ pos.x = event.pageX;
41
+ pos.y = event.pageY;
42
+ // Check if clicking on a selected testcase (let drag handle it)
43
+ if ((event.target as HTMLElement).closest?.('[data-selected="true"]')) return;
44
+ selecting.current = true;
45
+ // eslint-disable-next-line ts/no-use-before-define
46
+ document.body.addEventListener('mousemove', handleMouseMove);
47
+ // eslint-disable-next-line ts/no-use-before-define
48
+ document.body.addEventListener('mouseup', handleMouseUp);
49
+ $('body').css('cursor', 'crosshair')
50
+ .append('<div id="divSelectArea" style="position:absolute;background-color:#e073d4;"></div>');
51
+ $('#divSelectArea').css({
52
+ top: event.pageY,
53
+ left: event.pageX,
54
+ zIndex: 9999999,
55
+ }).fadeTo(12, 0.2);
56
+ }, [JSON.stringify(cases)]);
57
+ const handleMouseMove = React.useCallback((event) => {
58
+ if (!selecting.current) return;
59
+ pos.endX = event.pageX;
60
+ pos.endY = event.pageY;
61
+ $('#divSelectArea').css({
62
+ top: Math.min(event.pageY, pos.y),
63
+ left: Math.min(event.pageX, pos.x),
64
+ height: Math.abs(event.pageY - pos.y),
65
+ width: Math.abs(event.pageX - pos.x),
66
+ });
67
+ }, [JSON.stringify(cases)]);
68
+ const cleanupSelection = React.useCallback(() => {
69
+ selecting.current = false;
70
+ document.body.removeEventListener('mousemove', handleMouseMove);
71
+ // eslint-disable-next-line ts/no-use-before-define
72
+ document.body.removeEventListener('mouseup', handleMouseUp);
73
+ $('#divSelectArea').remove();
74
+ $('body').css('cursor', 'default');
75
+ pos.x = pos.y = pos.endX = pos.endY = 0;
76
+ }, [JSON.stringify(cases)]);
77
+ const handleMouseUp = React.useCallback(() => {
78
+ if (!selecting.current) {
79
+ cleanupSelection();
80
+ return;
81
+ }
82
+ const caseEntries = Array.from($(`[data-subtaskid="${subtaskId}"]`));
83
+ const selected = [];
84
+ for (let i = 0; i < caseEntries.length; i += 1) {
85
+ if (collide(caseEntries[i], $('#divSelectArea')[0])) {
86
+ selected.push(cases.indexOf(cases.find((c) => c.input === caseEntries[i].dataset.index)));
87
+ }
88
+ }
89
+ const sorted = selected.sort((a, b) => a - b);
90
+ cleanupSelection();
91
+ if (!sorted.length) return;
92
+ setStart(sorted[0]);
93
+ setEnd(sorted[selected.length - 1] + 1);
94
+ }, [JSON.stringify(cases)]);
95
+
96
+ return (
97
+ <>
98
+ {end > start && cases.slice(0, start).map((c, id) => (
99
+ <TestcaseGroup
100
+ subtaskId={subtaskId}
101
+ cases={[c]}
102
+ key={`${c.input}@${id}`}
103
+ selected={false}
104
+ subtaskIds={subtaskIds}
105
+ index={id}
106
+ onMouseDown={handleMouseDown}
107
+ onClick={() => {
108
+ setStart(id);
109
+ setEnd(id + 1);
110
+ }}
111
+ />
112
+ ))}
113
+ {start <= end && (
114
+ <TestcaseGroup
115
+ cases={cases.slice(start, end)}
116
+ subtaskId={subtaskId}
117
+ subtaskIds={subtaskIds}
118
+ onMouseDown={handleMouseDown}
119
+ selected={true}
120
+ index={start}
121
+ />
122
+ )}
123
+ {end < cases.length && cases.slice(end).map((c, id) => (
124
+ <TestcaseGroup
125
+ subtaskId={subtaskId}
126
+ cases={[c]}
127
+ key={`${c.input}@${id}`}
128
+ subtaskIds={subtaskIds}
129
+ selected={false}
130
+ onMouseDown={handleMouseDown}
131
+ index={id + end}
132
+ onClick={() => {
133
+ setStart(id + end);
134
+ setEnd(id + end + 1);
135
+ }}
136
+ />
137
+ ))}
138
+ </>
139
+ );
140
+ }