@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.
- package/README.md +5 -0
- package/api.ts +61 -0
- package/backendlib/builder.ts +182 -0
- package/backendlib/markdown-it-imsize.ts +235 -0
- package/backendlib/markdown-it-katex.ts +139 -0
- package/backendlib/markdown-it-media.ts +163 -0
- package/backendlib/markdown-it-xss.ts +200 -0
- package/backendlib/markdown.js +64 -0
- package/backendlib/misc.ts +54 -0
- package/backendlib/template.ts +279 -0
- package/breakpoints.json +5 -0
- package/components/DOMAttachedObject.ts +128 -0
- package/components/autocomplete/AssignSelectAutoComplete.tsx +22 -0
- package/components/autocomplete/CustomSelectAutoComplete.tsx +23 -0
- package/components/autocomplete/DomainSelectAutoComplete.tsx +18 -0
- package/components/autocomplete/FileSelectAutoComplete.tsx +26 -0
- package/components/autocomplete/LanguageSelectAutoComplete.tsx +24 -0
- package/components/autocomplete/ProblemSelectAutoComplete.tsx +18 -0
- package/components/autocomplete/UserSelectAutoComplete.tsx +23 -0
- package/components/autocomplete/components/AssignSelectAutoComplete.tsx +118 -0
- package/components/autocomplete/components/DomainSelectAutoComplete.tsx +53 -0
- package/components/autocomplete/components/FileSelectAutoComplete.tsx +50 -0
- package/components/autocomplete/components/LanguageSelectAutoComplete.tsx +48 -0
- package/components/autocomplete/components/ProblemSelectAutoComplete.tsx +54 -0
- package/components/autocomplete/components/UserSelectAutoComplete.tsx +54 -0
- package/components/autocomplete/domainselectautocomplete.page.styl +6 -0
- package/components/autocomplete/index.tsx +110 -0
- package/components/autocomplete/problemselectautocomplete.page.styl +6 -0
- package/components/autocomplete/userselectautocomplete.page.styl +6 -0
- package/components/browser-update.page.ts +27 -0
- package/components/calendar/calendar.page.styl +129 -0
- package/components/calendar/index.js +367 -0
- package/components/clipboard.page.ts +23 -0
- package/components/contest/contest.page.styl +119 -0
- package/components/contest/contest.page.ts +23 -0
- package/components/contest/contest_sidebar.page.styl +21 -0
- package/components/contest/problem-contest-bg.png +0 -0
- package/components/contest/problem-contest-bg@2x.png +0 -0
- package/components/customFont.page.tsx +90 -0
- package/components/datepicker/datepicker.page.tsx +94 -0
- package/components/dialog/DomDialog.ts +145 -0
- package/components/dialog/dialog.page.styl +40 -0
- package/components/dialog/index.tsx +285 -0
- package/components/discussion/CommentBox.js +103 -0
- package/components/discussion/collapsible.page.styl +40 -0
- package/components/discussion/collapsible.page.tsx +62 -0
- package/components/discussion/comments.page.styl +142 -0
- package/components/discussion/comments.page.tsx +192 -0
- package/components/discussion/discussion.page.styl +17 -0
- package/components/discussion/history.page.tsx +81 -0
- package/components/discussion/reaction.page.styl +30 -0
- package/components/discussion/reaction.page.tsx +103 -0
- package/components/drop/drop.page.styl +40 -0
- package/components/dropdown/Dropdown.js +50 -0
- package/components/dropdown/dropdown.page.styl +33 -0
- package/components/dropdown/dropdown.page.ts +8 -0
- package/components/editor/cmeditor.page.ts +23 -0
- package/components/editor/cmeditor.styl +10 -0
- package/components/editor/index.tsx +293 -0
- package/components/editor/mdeditor.ts +60 -0
- package/components/editor/textareaHandler.ts +29 -0
- package/components/footer/footer.page.styl +94 -0
- package/components/footer/footer.page.ts +26 -0
- package/components/form/button.page.default.styl +59 -0
- package/components/form/button.page.styl +36 -0
- package/components/form/checkbox.page.styl +89 -0
- package/components/form/form.page.styl +200 -0
- package/components/form/form.page.ts +20 -0
- package/components/form/multiSelectCheckbox.page.js +46 -0
- package/components/form/radiobox.page.styl +62 -0
- package/components/form/select.page.styl +29 -0
- package/components/form/textbox.page.styl +79 -0
- package/components/form/textbox.page.ts +21 -0
- package/components/form/var.inc.styl +14 -0
- package/components/header/header.page.styl +79 -0
- package/components/highlighter/code-example.js +111 -0
- package/components/highlighter/highlighter.page.styl +99 -0
- package/components/highlighter/highlighter.page.ts +72 -0
- package/components/highlighter/meta.js +15 -0
- package/components/highlighter/prismjs.js +122 -0
- package/components/hint.page.styl +9 -0
- package/components/hint.ts +19 -0
- package/components/hitokoto/index.page.js +21 -0
- package/components/hotkey/hotkey.page.js +83 -0
- package/components/katex/katex.page.js +26 -0
- package/components/katex/katex.page.styl +2 -0
- package/components/languageselect.tsx +94 -0
- package/components/loader/loader.page.styl +40 -0
- package/components/mantine.page.tsx +39 -0
- package/components/marker/Marker.js +192 -0
- package/components/marker/MarkerReactive.js +55 -0
- package/components/marker/marker.page.js +8 -0
- package/components/marker/marker.page.styl +57 -0
- package/components/media/media.page.js +46 -0
- package/components/menu/menu-heading.page.js +28 -0
- package/components/menu/menu.page.js +18 -0
- package/components/menu/menu.page.styl +68 -0
- package/components/message/index.page.ts +166 -0
- package/components/message/worker.ts +110 -0
- package/components/messagepad/DialogueListItem.page.styl +28 -0
- package/components/messagepad/DialogueListItemComponent.jsx +39 -0
- package/components/messagepad/Message.page.styl +64 -0
- package/components/messagepad/MessageComponent.jsx +33 -0
- package/components/messagepad/MessagePad.page.styl +99 -0
- package/components/messagepad/MessagePadDialogueContentContainer.jsx +104 -0
- package/components/messagepad/MessagePadDialogueListContainer.jsx +49 -0
- package/components/messagepad/MessagePadInputContainer.jsx +100 -0
- package/components/messagepad/index.jsx +49 -0
- package/components/messagepad/reducers/activeId.ts +36 -0
- package/components/messagepad/reducers/dialogues.js +53 -0
- package/components/messagepad/reducers/index.ts +14 -0
- package/components/messagepad/reducers/inputs.js +43 -0
- package/components/messagepad/reducers/isPosting.ts +49 -0
- package/components/monaco/index.ts +178 -0
- package/components/monaco/languages/markdown.ts +97 -0
- package/components/monaco/languages/typescript.ts +45 -0
- package/components/monaco/languages/yaml.ts +22 -0
- package/components/monaco/loader.ts +96 -0
- package/components/monaco/monaco.styl +30 -0
- package/components/monaco/nls.js +31 -0
- package/components/monaco/schema/problemconfig.ts +123 -0
- package/components/navigation/hamburgers.page.styl +87 -0
- package/components/navigation/nav-logo-small_dark.png +0 -0
- package/components/navigation/navigation.page.js +203 -0
- package/components/navigation/navigation.page.styl +211 -0
- package/components/notification/index.ts +105 -0
- package/components/notification/notification.page.js +14 -0
- package/components/notification/notification.page.styl +84 -0
- package/components/nprogress.page.styl +50 -0
- package/components/omnisearch/index.page.tsx +124 -0
- package/components/omnisearch/omnibar.page.styl +138 -0
- package/components/pager/pager.page.styl +57 -0
- package/components/preview/preview.page.ts +187 -0
- package/components/problem/create.page.js +12 -0
- package/components/problem/list.page.js +9 -0
- package/components/problem/rp.page.styl +4 -0
- package/components/problem/tag.page.styl +84 -0
- package/components/problemconfig/BasicForm.tsx +92 -0
- package/components/problemconfig/ProblemConfigEditor.tsx +170 -0
- package/components/problemconfig/ProblemConfigForm.tsx +140 -0
- package/components/problemconfig/ProblemConfigTree.tsx +163 -0
- package/components/problemconfig/ProblemType.tsx +165 -0
- package/components/problemconfig/index.tsx +91 -0
- package/components/problemconfig/reducer/config.ts +173 -0
- package/components/problemconfig/reducer/index.ts +11 -0
- package/components/problemconfig/reducer/testdata.ts +16 -0
- package/components/problemconfig/tree/AddTestcase.tsx +137 -0
- package/components/problemconfig/tree/SelectionManager.tsx +140 -0
- package/components/problemconfig/tree/SubtaskSettings.tsx +180 -0
- package/components/problemconfig/tree/Testcase.tsx +98 -0
- package/components/profile/backgrounds/1.jpg +0 -0
- package/components/profile/backgrounds/10.jpg +0 -0
- package/components/profile/backgrounds/11.jpg +0 -0
- package/components/profile/backgrounds/12.jpg +0 -0
- package/components/profile/backgrounds/13.jpg +0 -0
- package/components/profile/backgrounds/14.jpg +0 -0
- package/components/profile/backgrounds/15.jpg +0 -0
- package/components/profile/backgrounds/16.jpg +0 -0
- package/components/profile/backgrounds/17.jpg +0 -0
- package/components/profile/backgrounds/18.jpg +0 -0
- package/components/profile/backgrounds/19.jpg +0 -0
- package/components/profile/backgrounds/2.jpg +0 -0
- package/components/profile/backgrounds/20.jpg +0 -0
- package/components/profile/backgrounds/21.jpg +0 -0
- package/components/profile/backgrounds/3.jpg +0 -0
- package/components/profile/backgrounds/4.jpg +0 -0
- package/components/profile/backgrounds/5.jpg +0 -0
- package/components/profile/backgrounds/6.jpg +0 -0
- package/components/profile/backgrounds/7.jpg +0 -0
- package/components/profile/backgrounds/8.jpg +0 -0
- package/components/profile/backgrounds/9.jpg +0 -0
- package/components/profile/backgrounds/gen_thumbnails.sh +7 -0
- package/components/profile/backgrounds/thumbnail/1.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/10.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/11.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/12.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/13.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/14.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/15.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/16.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/17.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/18.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/19.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/2.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/20.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/21.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/3.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/4.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/5.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/6.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/7.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/8.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/9.jpg +0 -0
- package/components/profile/profile.page.styl +23 -0
- package/components/react/DomComponent.tsx +14 -0
- package/components/react/IconComponent.tsx +20 -0
- package/components/record/record.page.styl +26 -0
- package/components/rotator/index.js +75 -0
- package/components/rotator/rotator.page.styl +20 -0
- package/components/scratchpad/DataInput.page.styl +17 -0
- package/components/scratchpad/DataInputComponent.jsx +45 -0
- package/components/scratchpad/Editor.page.styl +13 -0
- package/components/scratchpad/Panel.page.styl +18 -0
- package/components/scratchpad/PanelButton.page.styl +15 -0
- package/components/scratchpad/PanelButtonComponent.jsx +19 -0
- package/components/scratchpad/PanelComponent.jsx +25 -0
- package/components/scratchpad/ScratchpadEditorContainer.tsx +137 -0
- package/components/scratchpad/ScratchpadPretestContainer.jsx +57 -0
- package/components/scratchpad/ScratchpadRecordsContainer.jsx +45 -0
- package/components/scratchpad/ScratchpadRecordsRowContainer.jsx +83 -0
- package/components/scratchpad/ScratchpadSettings.tsx +48 -0
- package/components/scratchpad/ScratchpadToolbarContainer.jsx +190 -0
- package/components/scratchpad/Tab.page.styl +24 -0
- package/components/scratchpad/Toolbar.page.styl +53 -0
- package/components/scratchpad/ToolbarComponent.jsx +85 -0
- package/components/scratchpad/index.tsx +132 -0
- package/components/scratchpad/reducers/editor.ts +24 -0
- package/components/scratchpad/reducers/index.ts +17 -0
- package/components/scratchpad/reducers/pretest.ts +34 -0
- package/components/scratchpad/reducers/records.ts +40 -0
- package/components/scratchpad/reducers/state.ts +10 -0
- package/components/scratchpad/reducers/ui.ts +152 -0
- package/components/scratchpad/scratchpad.page.styl +55 -0
- package/components/scratchpad/var.inc.styl +2 -0
- package/components/selectUser.tsx +16 -0
- package/components/signin/signInDialog.page.js +84 -0
- package/components/signin/signin_dialog.page.styl +57 -0
- package/components/smoothscroll/smoothscroll.page.js +44 -0
- package/components/socket/index.ts +68 -0
- package/components/star/star.page.styl +20 -0
- package/components/star/star.page.ts +58 -0
- package/components/sticky/sticky.page.js +66 -0
- package/components/tab/Tab.js +168 -0
- package/components/tab/tab.page.js +9 -0
- package/components/tab/tab.page.styl +105 -0
- package/components/tab/var.inc.styl +3 -0
- package/components/table/StyledTable.js +51 -0
- package/components/table/styledTable.page.js +8 -0
- package/components/table/table.page.styl +73 -0
- package/components/time/time.page.js +47 -0
- package/components/tooltip/Tooltip.js +49 -0
- package/components/tooltip/tooltip.page.js +29 -0
- package/components/tooltip/tooltip.page.styl +69 -0
- package/components/training/training.page.styl +25 -0
- package/components/upload.tsx +103 -0
- package/components/vote/vote.page.js +43 -0
- package/components/zipDownloader/index.ts +157 -0
- package/constant/domain.js +21 -0
- package/constant/message.js +5 -0
- package/constant/record.js +52 -0
- package/context.ts +11 -0
- package/entry.js +72 -0
- package/hydro.ts +112 -0
- package/index.ts +226 -0
- package/lazyload.ts +69 -0
- package/locales/en.yaml +71 -0
- package/locales/ko.yaml +823 -0
- package/locales/zh.yaml +1137 -0
- package/locales/zh_TW.yaml +1133 -0
- package/misc/Page.ts +49 -0
- package/misc/PageLoader.js +31 -0
- package/misc/float.styl +14 -0
- package/misc/grid.styl +1048 -0
- package/misc/immersive-background.jpg +0 -0
- package/misc/immersive-background@2x.jpg +0 -0
- package/misc/immersive.styl +23 -0
- package/misc/nothing.styl +13 -0
- package/misc/puzzled_twd2.svg +1 -0
- package/misc/section.styl +105 -0
- package/misc/slideout.styl +46 -0
- package/misc/structure.styl +158 -0
- package/misc/textalign.styl +11 -0
- package/misc/typography.styl +485 -0
- package/package.json +148 -0
- package/polyfill.ts +90 -0
- package/postcss.config.js +15 -0
- package/sentry.ts +26 -0
- package/service-worker.ts +265 -0
- package/setting.yaml +98 -0
- package/templates/about.html +14 -0
- package/templates/bsod.html +35 -0
- package/templates/components/comments_discussion.html +165 -0
- package/templates/components/comments_solution.html +171 -0
- package/templates/components/contest.html +12 -0
- package/templates/components/form.html +214 -0
- package/templates/components/home.html +20 -0
- package/templates/components/homework.html +8 -0
- package/templates/components/md_hint.html +39 -0
- package/templates/components/noscript_note.html +15 -0
- package/templates/components/nothing.html +6 -0
- package/templates/components/paginator.html +25 -0
- package/templates/components/problem.html +33 -0
- package/templates/components/record.html +21 -0
- package/templates/components/sidemenu.html +11 -0
- package/templates/components/user.html +49 -0
- package/templates/contest_balloon.html +48 -0
- package/templates/contest_clarification.html +103 -0
- package/templates/contest_detail.html +56 -0
- package/templates/contest_edit.html +259 -0
- package/templates/contest_main.html +146 -0
- package/templates/contest_manage.html +80 -0
- package/templates/contest_print.html +27 -0
- package/templates/contest_problemlist.html +231 -0
- package/templates/contest_scoreboard.html +46 -0
- package/templates/contest_scoreboard_download_html.html +71 -0
- package/templates/contest_user.html +47 -0
- package/templates/discussion_create.html +28 -0
- package/templates/discussion_detail.html +149 -0
- package/templates/discussion_edit.html +30 -0
- package/templates/discussion_main_or_node.html +47 -0
- package/templates/domain_base.html +26 -0
- package/templates/domain_create.html +55 -0
- package/templates/domain_dashboard.html +45 -0
- package/templates/domain_edit.html +6 -0
- package/templates/domain_group.html +51 -0
- package/templates/domain_join.html +47 -0
- package/templates/domain_join_applications.html +67 -0
- package/templates/domain_permission.html +66 -0
- package/templates/domain_role.html +71 -0
- package/templates/domain_user.html +86 -0
- package/templates/domain_user_raw.html +5 -0
- package/templates/error.html +25 -0
- package/templates/home_domain.html +64 -0
- package/templates/home_files.html +16 -0
- package/templates/home_messages.html +9 -0
- package/templates/home_security.html +224 -0
- package/templates/home_settings.html +21 -0
- package/templates/homework_detail.html +82 -0
- package/templates/homework_edit.html +138 -0
- package/templates/homework_files.html +24 -0
- package/templates/homework_main.html +76 -0
- package/templates/layout/basic.html +27 -0
- package/templates/layout/home_base.html +13 -0
- package/templates/layout/html5.html +74 -0
- package/templates/layout/immersive.html +22 -0
- package/templates/layout/mail.html +31 -0
- package/templates/layout/simple.html +4 -0
- package/templates/layout/wiki_base.html +16 -0
- package/templates/main.html +22 -0
- package/templates/manage_base.html +24 -0
- package/templates/manage_config.html +6 -0
- package/templates/manage_dashboard.html +27 -0
- package/templates/manage_script.html +56 -0
- package/templates/manage_setting.html +6 -0
- package/templates/manage_user_import.html +23 -0
- package/templates/manage_user_priv.html +76 -0
- package/templates/partials/category.html +19 -0
- package/templates/partials/contest.html +3 -0
- package/templates/partials/contest_balloon.html +37 -0
- package/templates/partials/contest_sidebar.html +150 -0
- package/templates/partials/contest_sidebar_management.html +56 -0
- package/templates/partials/contest_user.html +19 -0
- package/templates/partials/discussion_edit_form.html +45 -0
- package/templates/partials/discussion_list.html +50 -0
- package/templates/partials/discussion_nodes_widget.html +17 -0
- package/templates/partials/files.html +49 -0
- package/templates/partials/footer.html +108 -0
- package/templates/partials/hamburger.html +7 -0
- package/templates/partials/header_mobile.html +12 -0
- package/templates/partials/homepage/bulletin.html +7 -0
- package/templates/partials/homepage/contest.html +48 -0
- package/templates/partials/homepage/discussion.html +13 -0
- package/templates/partials/homepage/discussion_nodes.html +4 -0
- package/templates/partials/homepage/error.html +5 -0
- package/templates/partials/homepage/hitokoto.html +6 -0
- package/templates/partials/homepage/homework.html +45 -0
- package/templates/partials/homepage/problem_search.html +13 -0
- package/templates/partials/homepage/ranking.html +39 -0
- package/templates/partials/homepage/recent_problems.html +17 -0
- package/templates/partials/homepage/starred_problems.html +15 -0
- package/templates/partials/homepage/suggestion.html +34 -0
- package/templates/partials/homepage/training.html +50 -0
- package/templates/partials/homework.html +3 -0
- package/templates/partials/homework_default_penalty_rules.yaml +6 -0
- package/templates/partials/homework_sidebar.html +93 -0
- package/templates/partials/login_dialog.html +56 -0
- package/templates/partials/manage_user_priv.html +78 -0
- package/templates/partials/nav.html +138 -0
- package/templates/partials/problem-sidebar-information.html +25 -0
- package/templates/partials/problem.html +2 -0
- package/templates/partials/problem_category_dialog.html +43 -0
- package/templates/partials/problem_default.md +26 -0
- package/templates/partials/problem_description.html +33 -0
- package/templates/partials/problem_files.html +63 -0
- package/templates/partials/problem_list.html +68 -0
- package/templates/partials/problem_lucky.html +10 -0
- package/templates/partials/problem_sidebar.html +14 -0
- package/templates/partials/problem_sidebar_contest.html +43 -0
- package/templates/partials/problem_sidebar_homework.html +42 -0
- package/templates/partials/problem_sidebar_normal.html +152 -0
- package/templates/partials/problem_stat.html +3 -0
- package/templates/partials/scoreboard.html +79 -0
- package/templates/partials/setting.html +92 -0
- package/templates/partials/training_default.json +14 -0
- package/templates/partials/training_detail.html +153 -0
- package/templates/partials/user.html +2 -0
- package/templates/partials/user_detail/activity.html +18 -0
- package/templates/partials/user_detail/solution.html +29 -0
- package/templates/problem_config.html +39 -0
- package/templates/problem_detail.html +150 -0
- package/templates/problem_edit.html +111 -0
- package/templates/problem_files.html +91 -0
- package/templates/problem_hack.html +41 -0
- package/templates/problem_import.html +58 -0
- package/templates/problem_main.html +100 -0
- package/templates/problem_solution.html +55 -0
- package/templates/problem_statistics.html +96 -0
- package/templates/problem_submit.html +40 -0
- package/templates/ranking.html +81 -0
- package/templates/record_detail.html +134 -0
- package/templates/record_detail_status.html +93 -0
- package/templates/record_detail_summary.html +19 -0
- package/templates/record_main.html +142 -0
- package/templates/record_main_tr.html +35 -0
- package/templates/status.html +75 -0
- package/templates/training_detail.html +120 -0
- package/templates/training_edit.html +68 -0
- package/templates/training_files.html +64 -0
- package/templates/training_main.html +107 -0
- package/templates/user_changemail_mail.html +6 -0
- package/templates/user_changemail_mail_sent.html +9 -0
- package/templates/user_delete_pending.html +10 -0
- package/templates/user_detail.html +181 -0
- package/templates/user_login.html +46 -0
- package/templates/user_logout.html +13 -0
- package/templates/user_lostpass.html +27 -0
- package/templates/user_lostpass_mail.html +6 -0
- package/templates/user_lostpass_mail_sent.html +9 -0
- package/templates/user_lostpass_with_code.html +29 -0
- package/templates/user_register.html +22 -0
- package/templates/user_register_mail.html +6 -0
- package/templates/user_register_mail_sent.html +9 -0
- package/templates/user_register_with_code.html +35 -0
- package/templates/user_sudo.html +54 -0
- package/templates/user_sudo_redirect.html +18 -0
- package/templates/wiki_help.html +189 -0
- package/theme/bp6-compat.css +48 -0
- package/theme/dark.styl +397 -0
- package/theme/default.js +33 -0
- package/typed.d.ts +20 -0
- package/utils/base.ts +209 -0
- package/utils/base64.js +104 -0
- package/utils/db.ts +32 -0
- package/utils/index.ts +73 -0
- package/utils/loadReactRedux.ts +32 -0
- package/utils/mediaQuery.ts +13 -0
- package/utils/pjax.js +148 -0
- package/utils/slide.ts +57 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import 'flatpickr/dist/flatpickr.min.css';
|
|
2
|
+
|
|
3
|
+
import flatpickr from 'flatpickr';
|
|
4
|
+
import $ from 'jquery';
|
|
5
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
6
|
+
|
|
7
|
+
function padTwo(n: number) {
|
|
8
|
+
return n < 10 ? `0${n}` : `${n}`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function initTimePicker(input: HTMLInputElement) {
|
|
12
|
+
const $input = $(input);
|
|
13
|
+
const interval = 15;
|
|
14
|
+
const $wrapper = $('<div>').css({ position: 'relative', display: 'inline-block', width: '100%' });
|
|
15
|
+
$input.wrap($wrapper);
|
|
16
|
+
|
|
17
|
+
const $dropdown = $('<div>').css({
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
top: $input.outerHeight(),
|
|
20
|
+
left: 0,
|
|
21
|
+
right: 0,
|
|
22
|
+
maxHeight: 0,
|
|
23
|
+
overflowY: 'auto',
|
|
24
|
+
background: 'var(--bg-color, #fff)',
|
|
25
|
+
border: '1px solid #ccc',
|
|
26
|
+
borderTop: 'none',
|
|
27
|
+
borderRadius: '0 0 4px 4px',
|
|
28
|
+
zIndex: 1000,
|
|
29
|
+
opacity: 0,
|
|
30
|
+
boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
|
|
31
|
+
transition: 'max-height .2s ease, opacity .2s ease',
|
|
32
|
+
pointerEvents: 'none',
|
|
33
|
+
}).addClass('time-picker-dropdown');
|
|
34
|
+
|
|
35
|
+
for (let h = 0; h < 24; h++) {
|
|
36
|
+
for (let m = 0; m < 60; m += interval) {
|
|
37
|
+
const time = `${padTwo(h)}:${padTwo(m)}`;
|
|
38
|
+
const $item = $('<div>').text(time).css({
|
|
39
|
+
padding: '6px 12px',
|
|
40
|
+
cursor: 'pointer',
|
|
41
|
+
}).on('mousedown', (e) => {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
$input.val(time).trigger('change');
|
|
44
|
+
closeDropdown(); // eslint-disable-line ts/no-use-before-define
|
|
45
|
+
}).on('mouseenter', function () {
|
|
46
|
+
$(this).css('background', 'var(--highlight-color, #e8f0fe)');
|
|
47
|
+
}).on('mouseleave', function () {
|
|
48
|
+
$(this).css('background', '');
|
|
49
|
+
});
|
|
50
|
+
$dropdown.append($item);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let isOpen = false;
|
|
55
|
+
|
|
56
|
+
function openDropdown() {
|
|
57
|
+
if (isOpen) return;
|
|
58
|
+
isOpen = true;
|
|
59
|
+
$dropdown.css({ maxHeight: '200px', opacity: 1, pointerEvents: 'auto' });
|
|
60
|
+
const val = $input.val() as string;
|
|
61
|
+
if (val) {
|
|
62
|
+
$dropdown.children().each(function cb() {
|
|
63
|
+
if ($(this).text() !== val) return;
|
|
64
|
+
const el = this as HTMLElement;
|
|
65
|
+
el.parentElement!.scrollTop = el.offsetTop - el.parentElement!.offsetTop - 80;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function closeDropdown() {
|
|
71
|
+
if (!isOpen) return;
|
|
72
|
+
isOpen = false;
|
|
73
|
+
$dropdown.css({ maxHeight: 0, opacity: 0, pointerEvents: 'none' });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
$input.after($dropdown);
|
|
77
|
+
$input.on('focus', openDropdown);
|
|
78
|
+
// Only close when the element actually loses focus within the page,
|
|
79
|
+
// not when the whole window loses focus (alt-tab)
|
|
80
|
+
$input.on('blur', () => {
|
|
81
|
+
if (document.hasFocus()) closeDropdown();
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const datepickerPage = new AutoloadPage('datepickerPage', async () => {
|
|
86
|
+
$('[data-pick-date]').each(function () {
|
|
87
|
+
flatpickr(this, { allowInput: true });
|
|
88
|
+
});
|
|
89
|
+
$('[data-pick-time]').each(function () {
|
|
90
|
+
initTimePicker(this as HTMLInputElement);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
export default datepickerPage;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import DOMAttachedObject from 'vj/components/DOMAttachedObject';
|
|
3
|
+
import { zIndexManager } from 'vj/utils';
|
|
4
|
+
|
|
5
|
+
export interface DialogOptions {
|
|
6
|
+
classes: string;
|
|
7
|
+
$body: HTMLElement | JQuery<HTMLElement> | string;
|
|
8
|
+
$action: any;
|
|
9
|
+
width?: string;
|
|
10
|
+
height?: string;
|
|
11
|
+
cancelByClickingBack?: boolean;
|
|
12
|
+
cancelByEsc?: boolean;
|
|
13
|
+
canCancel?: boolean;
|
|
14
|
+
onDispatch?: (data: any) => any;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default class DomDialog extends DOMAttachedObject {
|
|
18
|
+
static DOMAttachKey = 'vjDomDialogInstance';
|
|
19
|
+
isShown = false;
|
|
20
|
+
isAnimating = false;
|
|
21
|
+
options: DialogOptions;
|
|
22
|
+
_resolve: (value: string | PromiseLike<string>) => void;
|
|
23
|
+
|
|
24
|
+
constructor($dom, options: Partial<DialogOptions> = {}) {
|
|
25
|
+
super($dom);
|
|
26
|
+
this.options = {
|
|
27
|
+
cancelByClickingBack: false,
|
|
28
|
+
cancelByEsc: false,
|
|
29
|
+
onDispatch: () => { },
|
|
30
|
+
...options as any,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async _show() {
|
|
35
|
+
this.$dom.css('z-index', zIndexManager.getNext());
|
|
36
|
+
this.$dom.trigger('vjDomDialogShow');
|
|
37
|
+
this.isAnimating = true;
|
|
38
|
+
|
|
39
|
+
if (this.options.cancelByClickingBack) {
|
|
40
|
+
this.$dom.on(`click.${this.eventNS}`, this.handleClick.bind(this));
|
|
41
|
+
}
|
|
42
|
+
if (this.options.cancelByEsc) {
|
|
43
|
+
$(document).on(`keyup.${this.eventNS}`, this.handleKeyUp.bind(this));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const $wrap = this.$dom;
|
|
47
|
+
$wrap.css({
|
|
48
|
+
display: 'flex',
|
|
49
|
+
opacity: 0,
|
|
50
|
+
});
|
|
51
|
+
$wrap.width();
|
|
52
|
+
$wrap.transition(
|
|
53
|
+
{ opacity: 1 },
|
|
54
|
+
{
|
|
55
|
+
duration: 100,
|
|
56
|
+
easing: 'easeOutCubic',
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const $dgContent = this.$dom.find('.dialog__content');
|
|
61
|
+
$dgContent.css({ scale: 0.8 });
|
|
62
|
+
$dgContent.trigger('vjContentNew');
|
|
63
|
+
await $dgContent
|
|
64
|
+
.transition({
|
|
65
|
+
scale: 1,
|
|
66
|
+
}, {
|
|
67
|
+
duration: 200,
|
|
68
|
+
easing: 'easeOutCubic',
|
|
69
|
+
})
|
|
70
|
+
.promise();
|
|
71
|
+
|
|
72
|
+
this.$dom.find('[data-autofocus]').focus();
|
|
73
|
+
|
|
74
|
+
this.isShown = true;
|
|
75
|
+
this.isAnimating = false;
|
|
76
|
+
this.$dom.trigger('vjDomDialogShown');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async _hide() {
|
|
80
|
+
this.$dom.trigger('vjDomDialogHide');
|
|
81
|
+
this.isAnimating = true;
|
|
82
|
+
|
|
83
|
+
$(document).off(`keyup.${this.eventNS}`);
|
|
84
|
+
this.$dom.off(`click.${this.eventNS}`);
|
|
85
|
+
|
|
86
|
+
this.$dom.css({ opacity: 1 });
|
|
87
|
+
this.$dom.transition({
|
|
88
|
+
opacity: 0,
|
|
89
|
+
}, {
|
|
90
|
+
duration: 200,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const $dgContent = this.$dom.find('.dialog__content');
|
|
94
|
+
$dgContent.css({ scale: 1 });
|
|
95
|
+
await $dgContent
|
|
96
|
+
.transition(
|
|
97
|
+
{ scale: 0.8 },
|
|
98
|
+
{
|
|
99
|
+
duration: 200,
|
|
100
|
+
easing: 'easeOutCubic',
|
|
101
|
+
},
|
|
102
|
+
).promise();
|
|
103
|
+
|
|
104
|
+
this.$dom.css('display', 'none');
|
|
105
|
+
|
|
106
|
+
this.isShown = false;
|
|
107
|
+
this.isAnimating = false;
|
|
108
|
+
this.$dom.trigger('vjDomDialogHidden');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
show() {
|
|
112
|
+
if (this.isShown) return Promise.reject(new Error('dialog isShown'));
|
|
113
|
+
if (this.isAnimating) return Promise.reject(new Error('dialog isAnimating'));
|
|
114
|
+
const promise = new Promise<string>((resolve) => {
|
|
115
|
+
this._resolve = resolve;
|
|
116
|
+
});
|
|
117
|
+
this._show();
|
|
118
|
+
return promise;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
hide() {
|
|
122
|
+
if (!this.isShown || this.isAnimating) return false;
|
|
123
|
+
this._resolve('cancel');
|
|
124
|
+
this._hide();
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
dispatchAction(data: string) {
|
|
129
|
+
if (this.options.onDispatch(data) === false) return;
|
|
130
|
+
this._resolve(data);
|
|
131
|
+
this.hide();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
handleClick(e) {
|
|
135
|
+
if (e.target === this.$dom.get(0)) {
|
|
136
|
+
this.dispatchAction('cancel');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
handleKeyUp(e) {
|
|
141
|
+
if (e.keyCode === 27) {
|
|
142
|
+
this.dispatchAction('cancel');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
.dialog
|
|
2
|
+
position: fixed
|
|
3
|
+
left: 0
|
|
4
|
+
top: 0
|
|
5
|
+
width: 100%
|
|
6
|
+
height: 100%
|
|
7
|
+
opacity: 0
|
|
8
|
+
z-index: 1000 // managed
|
|
9
|
+
// display flex will be added after animation completes
|
|
10
|
+
flex-direction: column
|
|
11
|
+
align-items: center
|
|
12
|
+
justify-content: center
|
|
13
|
+
display: none
|
|
14
|
+
background: $dialog-layer-bg-color
|
|
15
|
+
|
|
16
|
+
.dialog__content
|
|
17
|
+
position: relative
|
|
18
|
+
|
|
19
|
+
.dialog.withBg .dialog__content
|
|
20
|
+
background: $dialog-bg-color
|
|
21
|
+
border: 1px solid $dialog-border-color
|
|
22
|
+
box-shadow: $dialog-shadow
|
|
23
|
+
min-width: rem(500px)
|
|
24
|
+
max-width: rem(900px)
|
|
25
|
+
max-height: 90vh
|
|
26
|
+
padding: rem(40px) rem(30px)
|
|
27
|
+
overflow-y: auto
|
|
28
|
+
|
|
29
|
+
.dialog__body
|
|
30
|
+
margin-bottom: rem(20px)
|
|
31
|
+
min-height: rem(50px)
|
|
32
|
+
|
|
33
|
+
h1
|
|
34
|
+
font-size: 1.6rem
|
|
35
|
+
color: $dialog-title-color
|
|
36
|
+
margin-bottom: 1rem
|
|
37
|
+
|
|
38
|
+
.dialog__action button
|
|
39
|
+
margin-left: rem(10px)
|
|
40
|
+
margin-bottom: 0
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/* eslint-disable react-refresh/only-export-components */
|
|
2
|
+
import $ from 'jquery';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import ReactDOM from 'react-dom/client';
|
|
5
|
+
import Notification from 'vj/components/notification';
|
|
6
|
+
import { i18n, tpl } from 'vj/utils';
|
|
7
|
+
import DomainSelectAutoComplete from '../autocomplete/components/DomainSelectAutoComplete';
|
|
8
|
+
import UserSelectAutoComplete from '../autocomplete/components/UserSelectAutoComplete';
|
|
9
|
+
import DomDialog, { DialogOptions } from './DomDialog';
|
|
10
|
+
|
|
11
|
+
export class Dialog {
|
|
12
|
+
options: DialogOptions;
|
|
13
|
+
$dom: JQuery<any>;
|
|
14
|
+
domDialogInstance: DomDialog;
|
|
15
|
+
|
|
16
|
+
constructor(options: Partial<DialogOptions> = {}) {
|
|
17
|
+
this.options = {
|
|
18
|
+
classes: '',
|
|
19
|
+
$body: null,
|
|
20
|
+
$action: null,
|
|
21
|
+
...options,
|
|
22
|
+
};
|
|
23
|
+
const box: React.CSSProperties = {};
|
|
24
|
+
if (options.width) box.width = box.maxWidth = options.width;
|
|
25
|
+
if (options.height) box.height = box.maxHeight = options.height;
|
|
26
|
+
this.$dom = $(tpl(
|
|
27
|
+
<div className={`dialog withBg ${this.options.classes}`} style={{ display: 'none' }}>
|
|
28
|
+
<div className="dialog__content" style={box}>
|
|
29
|
+
<div className="dialog__body" style={{ height: 'calc(100% - 45px)' }} />
|
|
30
|
+
<div className="row"><div className="columns clearfix">
|
|
31
|
+
<div className="float-right dialog__action" />
|
|
32
|
+
</div></div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>,
|
|
35
|
+
));
|
|
36
|
+
this.$dom.on('click', '[data-action]', this.handleActionButton.bind(this));
|
|
37
|
+
this.$dom.on('vjDomDialogShow', this.beforeShow.bind(this));
|
|
38
|
+
this.$dom.on('vjDomDialogHidden', this.afterHide.bind(this));
|
|
39
|
+
this.$dom.find('.dialog__body').append(this.options.$body);
|
|
40
|
+
this.$dom.find('.dialog__action').append(this.options.$action);
|
|
41
|
+
this.domDialogInstance = new DomDialog(this.$dom, this.options);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
beforeShow() {
|
|
45
|
+
this.$dom.appendTo('body');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
afterHide() {
|
|
49
|
+
this.$dom.detach();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
open() {
|
|
53
|
+
return this.domDialogInstance.show();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
close() {
|
|
57
|
+
return this.domDialogInstance.hide();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
handleActionButton(ev) {
|
|
61
|
+
this.domDialogInstance.dispatchAction($(ev.currentTarget).attr('data-action'));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default Dialog;
|
|
66
|
+
|
|
67
|
+
const buttonOk = tpl`<button class="primary rounded button" data-action="ok">${i18n('Ok')}</button>`;
|
|
68
|
+
const buttonCancel = tpl`<button class="rounded button" data-action="cancel">${i18n('Cancel')}</button>`;
|
|
69
|
+
const buttonYes = tpl`<button class="primary rounded button" data-action="yes">${i18n('Yes')}</button>`;
|
|
70
|
+
const buttonNo = tpl`<button class="rounded button" data-action="no">${i18n('No')}</button>`;
|
|
71
|
+
|
|
72
|
+
export class InfoDialog extends Dialog {
|
|
73
|
+
constructor(options: Partial<DialogOptions> = {}) {
|
|
74
|
+
super({
|
|
75
|
+
$action: buttonOk,
|
|
76
|
+
cancelByClickingBack: true,
|
|
77
|
+
cancelByEsc: true,
|
|
78
|
+
...options,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export class ActionDialog extends Dialog {
|
|
84
|
+
constructor(options: Partial<DialogOptions> = {}) {
|
|
85
|
+
super({
|
|
86
|
+
$action: [buttonCancel, buttonOk].join('\n'),
|
|
87
|
+
cancelByClickingBack: true,
|
|
88
|
+
cancelByEsc: true,
|
|
89
|
+
...options,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
clear() {
|
|
94
|
+
this.$dom.find('input').val('');
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export class ConfirmDialog extends Dialog {
|
|
100
|
+
constructor(options: Partial<DialogOptions> = {}) {
|
|
101
|
+
let buttons = [];
|
|
102
|
+
if (options.canCancel) {
|
|
103
|
+
buttons = [buttonCancel, buttonNo, buttonYes];
|
|
104
|
+
} else {
|
|
105
|
+
buttons = [buttonNo, buttonYes];
|
|
106
|
+
}
|
|
107
|
+
super({
|
|
108
|
+
$action: buttons.join('\n'),
|
|
109
|
+
cancelByClickingBack: options.canCancel,
|
|
110
|
+
cancelByEsc: options.canCancel,
|
|
111
|
+
...options,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface Field {
|
|
117
|
+
type: 'text' | 'textarea' | 'checkbox' | 'user' | 'userId' | 'username' | 'domain';
|
|
118
|
+
options?: string[] | Record<string, string>;
|
|
119
|
+
placeholder?: string;
|
|
120
|
+
label?: string;
|
|
121
|
+
autofocus?: boolean;
|
|
122
|
+
required?: boolean;
|
|
123
|
+
default?: string;
|
|
124
|
+
columns?: number;
|
|
125
|
+
rows?: number;
|
|
126
|
+
multi?: boolean;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
type Result<T extends string, R extends Record<T, Field>> = {
|
|
130
|
+
[K in keyof R]: R[K]['type'] extends ('text' | 'password' | 'username' | 'domain' | 'textarea') ? string
|
|
131
|
+
: R[K]['type'] extends 'checkbox' ? boolean
|
|
132
|
+
: R[K]['type'] extends 'userId' ? number
|
|
133
|
+
: R[K]['type'] extends 'user' ? any
|
|
134
|
+
: never;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
interface PromptOptions {
|
|
138
|
+
cancelByClickingBack: boolean;
|
|
139
|
+
cancelByEsc: boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export async function prompt<T extends string, R extends Record<T, Field>>(title: string, fields: R, options?: PromptOptions): Promise<Result<T, R>> {
|
|
143
|
+
let valueCache: Result<T, R> = {} as any;
|
|
144
|
+
const defaultValues = Object.fromEntries(Object.entries(fields)
|
|
145
|
+
.map(([name, field]: [T, Field]) => {
|
|
146
|
+
let firstOption = '';
|
|
147
|
+
if (field.options) {
|
|
148
|
+
if (Array.isArray(field.options)) firstOption = field.options[0];
|
|
149
|
+
else firstOption = Object.keys(field.options)[0];
|
|
150
|
+
}
|
|
151
|
+
return [name, field.default || firstOption || ''];
|
|
152
|
+
})) as Result<T, R>;
|
|
153
|
+
|
|
154
|
+
const layout: [string, Field][][] = [];
|
|
155
|
+
let pending: [string, Field][] = [];
|
|
156
|
+
for (const [name, field] of Object.entries(fields) as [T, Field][]) {
|
|
157
|
+
pending.push([name, field]);
|
|
158
|
+
if ((field.columns || -12) < 0) {
|
|
159
|
+
layout.push(pending);
|
|
160
|
+
pending = [];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (pending.length > 0) layout.push(pending);
|
|
164
|
+
|
|
165
|
+
const Component = () => {
|
|
166
|
+
const [values, setValues] = React.useState(defaultValues);
|
|
167
|
+
const [selected, setSelected] = React.useState<Partial<Result<T, R>>>({});
|
|
168
|
+
const refs = React.useRef<Partial<Record<T, React.RefObject<any>>>>({});
|
|
169
|
+
|
|
170
|
+
React.useEffect(() => {
|
|
171
|
+
valueCache = values;
|
|
172
|
+
}, [values]);
|
|
173
|
+
|
|
174
|
+
return <div>
|
|
175
|
+
<div className="row"><div className="columns">
|
|
176
|
+
<h1>{title}</h1>
|
|
177
|
+
</div></div>
|
|
178
|
+
{layout.map((i) => <div className="row" key={i[0][0]}>
|
|
179
|
+
{i.map(([name, field]: [string, Field]) => <div key={name} className={`columns medium-${Math.abs(field.columns || 12)}`}>
|
|
180
|
+
{field.type === 'textarea' && <label>
|
|
181
|
+
{field.label}
|
|
182
|
+
<textarea
|
|
183
|
+
className="textbox"
|
|
184
|
+
rows={field.rows || 6}
|
|
185
|
+
placeholder={field.placeholder}
|
|
186
|
+
defaultValue={field.default}
|
|
187
|
+
data-autofocus={field.autofocus}
|
|
188
|
+
style={{ fontFamily: 'monospace' }}
|
|
189
|
+
onChange={(e) => setValues({ ...values, [name]: e.target.value })}
|
|
190
|
+
/>
|
|
191
|
+
</label>}
|
|
192
|
+
{['text', 'user', 'userId', 'username', 'domain'].includes(field.type) && <label>
|
|
193
|
+
{field.label}
|
|
194
|
+
<div className="textbox-container">
|
|
195
|
+
{['text', 'password'].includes(field.type) && (field.options
|
|
196
|
+
? <select
|
|
197
|
+
defaultValue={field.default}
|
|
198
|
+
className="select"
|
|
199
|
+
data-autofocus={field.autofocus}
|
|
200
|
+
onChange={(e) => setValues({ ...values, [name]: e.target.value })}
|
|
201
|
+
>
|
|
202
|
+
{Object.entries(field.options).map(([value, label]) => (
|
|
203
|
+
<option value={Array.isArray(field.options) ? label : value} key={value}>{label}</option>
|
|
204
|
+
))}
|
|
205
|
+
</select>
|
|
206
|
+
: <input
|
|
207
|
+
type={field.type}
|
|
208
|
+
className="textbox"
|
|
209
|
+
data-autofocus={field.autofocus}
|
|
210
|
+
defaultValue={field.default}
|
|
211
|
+
onChange={(e) => setValues({ ...values, [name]: e.target.value })}
|
|
212
|
+
/>)}
|
|
213
|
+
{['userId', 'username', 'user'].includes(field.type) && <UserSelectAutoComplete
|
|
214
|
+
data-autofocus={field.autofocus}
|
|
215
|
+
multi={field.multi}
|
|
216
|
+
ref={(el) => { refs.current[name] = el; }}
|
|
217
|
+
selectedKeys={selected[name]
|
|
218
|
+
? (field.multi
|
|
219
|
+
? String(selected[name]).split(',').filter(Boolean)
|
|
220
|
+
: [selected[name].toString()])
|
|
221
|
+
: []}
|
|
222
|
+
onChange={(e) => {
|
|
223
|
+
if (e === selected[name]) return;
|
|
224
|
+
const items = refs.current[name].getSelectedItems();
|
|
225
|
+
const extract = (v) => (field.type === 'username' ? v?.uname : field.type === 'userId' ? v?._id : v);
|
|
226
|
+
setValues({ ...values, [name]: field.multi ? items.map(extract) : extract(items[0]) });
|
|
227
|
+
setSelected({ ...selected, [name]: e });
|
|
228
|
+
}}
|
|
229
|
+
/>}
|
|
230
|
+
{field.type === 'domain' && <DomainSelectAutoComplete
|
|
231
|
+
data-autofocus={field.autofocus}
|
|
232
|
+
selectedKeys={values[name] ? [values[name]] : []}
|
|
233
|
+
onChange={(e) => setValues({ ...values, [name]: e })}
|
|
234
|
+
/>}
|
|
235
|
+
</div>
|
|
236
|
+
</label>}
|
|
237
|
+
{field.type === 'checkbox' && <label className="checkbox">
|
|
238
|
+
<input
|
|
239
|
+
type="checkbox"
|
|
240
|
+
defaultChecked={field.default === 'true'}
|
|
241
|
+
onChange={(e) => setValues({ ...values, [name]: !!e.target.checked })}
|
|
242
|
+
/>
|
|
243
|
+
{field.label}
|
|
244
|
+
</label>}
|
|
245
|
+
</div>)}</div>)}
|
|
246
|
+
</div>;
|
|
247
|
+
};
|
|
248
|
+
const div = document.createElement('div');
|
|
249
|
+
const root = ReactDOM.createRoot(div);
|
|
250
|
+
root.render(<Component />);
|
|
251
|
+
const res = await new Dialog({
|
|
252
|
+
$body: $(div),
|
|
253
|
+
$action: [buttonCancel, buttonOk].join('\n'),
|
|
254
|
+
cancelByClickingBack: options?.cancelByClickingBack ?? false,
|
|
255
|
+
cancelByEsc: options?.cancelByEsc ?? false,
|
|
256
|
+
onDispatch(action) {
|
|
257
|
+
if (action === 'ok') {
|
|
258
|
+
for (const [name, field] of Object.entries(fields) as [string, Field][]) {
|
|
259
|
+
if ((field as any).required && !valueCache[name]) {
|
|
260
|
+
console.log('missing ', name);
|
|
261
|
+
Notification.error(i18n('{0} is required', field.label || name));
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return true;
|
|
267
|
+
},
|
|
268
|
+
}).open();
|
|
269
|
+
root.unmount();
|
|
270
|
+
if (res !== 'ok') return null;
|
|
271
|
+
return valueCache;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export async function confirm(text: string) {
|
|
275
|
+
const res = await new ConfirmDialog({
|
|
276
|
+
$body: tpl.typoMsg(text),
|
|
277
|
+
}).open();
|
|
278
|
+
return res === 'yes';
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export async function alert(text: string) {
|
|
282
|
+
return await new InfoDialog({
|
|
283
|
+
$body: tpl.typoMsg(text),
|
|
284
|
+
}).open();
|
|
285
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import DOMAttachedObject from 'vj/components/DOMAttachedObject';
|
|
3
|
+
import TextareaHandler from 'vj/components/editor/textareaHandler';
|
|
4
|
+
import Notification from 'vj/components/notification';
|
|
5
|
+
import { request } from 'vj/utils';
|
|
6
|
+
|
|
7
|
+
let initialized = false;
|
|
8
|
+
const $template = $('.dczcomments__box').eq(0).clone();
|
|
9
|
+
|
|
10
|
+
function getClosestInstance($dom) {
|
|
11
|
+
return $dom.closest('.dczcomments__box').data('instance');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function onBoxCancel(ev) {
|
|
15
|
+
const commentBox = getClosestInstance($(ev.currentTarget));
|
|
16
|
+
if (commentBox) commentBox.onCancel(ev);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function onBoxSubmit(ev) {
|
|
20
|
+
const commentBox = getClosestInstance($(ev.currentTarget));
|
|
21
|
+
if (commentBox) commentBox.onSubmit(ev);
|
|
22
|
+
ev.preventDefault();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function init() {
|
|
26
|
+
if (initialized) return;
|
|
27
|
+
$(document).on('submit', '[name="dczcomments__box__form"]', onBoxSubmit);
|
|
28
|
+
$(document).on('vjCommentBoxCancel', '[name="dczcomments__box__form"]', onBoxCancel);
|
|
29
|
+
$(document).on('click', '[name="dczcomments__box__cancel"]', onBoxCancel);
|
|
30
|
+
initialized = true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default class CommentBox extends DOMAttachedObject {
|
|
34
|
+
static DOMAttachKey = 'vjCommentBoxInstance';
|
|
35
|
+
|
|
36
|
+
constructor($dom, options = {}) {
|
|
37
|
+
super($dom);
|
|
38
|
+
init();
|
|
39
|
+
this.$box = $template.clone();
|
|
40
|
+
this.$box.data('instance', this);
|
|
41
|
+
this.options = {
|
|
42
|
+
initialText: null,
|
|
43
|
+
mode: null,
|
|
44
|
+
form: null,
|
|
45
|
+
onCancel: () => null,
|
|
46
|
+
...options,
|
|
47
|
+
};
|
|
48
|
+
if (this.options.initialText) this.setText(this.options.initialText);
|
|
49
|
+
if (this.options.mode) {
|
|
50
|
+
const submitButton = this.$box.find('.dczcomments__box__submit');
|
|
51
|
+
submitButton.val(submitButton.attr(`data-value-${this.options.mode}`));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getTextareaHandler() {
|
|
56
|
+
const $textarea = this.$box.find('textarea');
|
|
57
|
+
return TextareaHandler.getOrConstruct($textarea);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
focus() {
|
|
61
|
+
this.getTextareaHandler().focus();
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
setText(text) {
|
|
66
|
+
this.getTextareaHandler().val(text);
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getText() {
|
|
71
|
+
return this.getTextareaHandler().val();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
insertText(text) {
|
|
75
|
+
const handler = this.getTextareaHandler();
|
|
76
|
+
handler.val(handler.val() + text);
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
appendTo($dom) {
|
|
81
|
+
this.$box.appendTo($dom);
|
|
82
|
+
this.$box.trigger('vjContentNew');
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async onSubmit() {
|
|
87
|
+
try {
|
|
88
|
+
await request.post('', {
|
|
89
|
+
...this.options.form,
|
|
90
|
+
content: this.getText(),
|
|
91
|
+
});
|
|
92
|
+
window.location.reload();
|
|
93
|
+
} catch (error) {
|
|
94
|
+
Notification.error(error.message);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async onCancel(ev) {
|
|
99
|
+
await this.options.onCancel(ev);
|
|
100
|
+
this.$box.remove();
|
|
101
|
+
this.detach();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
.collapsible-content
|
|
2
|
+
position: relative
|
|
3
|
+
|
|
4
|
+
&::after
|
|
5
|
+
content: ""
|
|
6
|
+
position: absolute
|
|
7
|
+
bottom: rem(16px)
|
|
8
|
+
left: 0
|
|
9
|
+
right: 0
|
|
10
|
+
height: rem(55px)
|
|
11
|
+
background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1))
|
|
12
|
+
pointer-events: none
|
|
13
|
+
transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1)
|
|
14
|
+
opacity: 1
|
|
15
|
+
z-index: 1
|
|
16
|
+
|
|
17
|
+
&__inner
|
|
18
|
+
overflow: hidden
|
|
19
|
+
max-height: rem(300px)
|
|
20
|
+
transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1)
|
|
21
|
+
|
|
22
|
+
.collapsible-toggle
|
|
23
|
+
text-align: center
|
|
24
|
+
opacity: 0
|
|
25
|
+
|
|
26
|
+
&.visible
|
|
27
|
+
opacity: 1
|
|
28
|
+
|
|
29
|
+
&__link
|
|
30
|
+
color: $primary-color
|
|
31
|
+
text-decoration: none
|
|
32
|
+
display: inline-block
|
|
33
|
+
position: relative
|
|
34
|
+
overflow: hidden
|
|
35
|
+
|
|
36
|
+
.collapsible-content.expanded
|
|
37
|
+
&::after
|
|
38
|
+
opacity: 0 !important
|
|
39
|
+
.collapsible-content__inner
|
|
40
|
+
max-height: none
|