cx-chat 0.0.1
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/.cursor/rules/i18n-cn-gloss-comments.mdc +31 -0
- package/.cursor/rules/list-page-view-pageconfig.mdc +32 -0
- package/.cursor/rules/no-over-defensive-programming.mdc +90 -0
- package/.cursor/rules/requirement-description-for-agent.mdc +33 -0
- package/.cursor/rules/use-showToast-not-antd-message.mdc +28 -0
- package/.docker/Dockerfile +7 -0
- package/.env +9 -0
- package/.env.development +7 -0
- package/.env.production +7 -0
- package/.gitlab-ci/docker-build.yaml +28 -0
- package/.gitlab-ci/k8s-deploy-dev-master.yaml +42 -0
- package/.gitlab-ci/npm-build.yaml +17 -0
- package/.gitlab-ci.yml +8 -0
- package/.k8s/0-namespace.yaml +6 -0
- package/.k8s/1-configmap-web.yaml +7 -0
- package/.k8s/1-nginx-conf-dev.yaml +110 -0
- package/.k8s/2-deployment.yaml +27 -0
- package/.k8s/3-service.yaml +16 -0
- package/.k8s/4-ingress-dev.yaml +30 -0
- package/.lingma/rules/use-showToast-not-antd-message.md +34 -0
- package/.nginx/nginx.conf +52 -0
- package/.prettierrc +9 -0
- package/README.md +1 -0
- package/eslint.config.js +32 -0
- package/index.html +13 -0
- package/package.json +67 -0
- package/postcss.config.js +6 -0
- package/public/favicon.ico +0 -0
- package/public/vite.svg +1 -0
- package/src/App.tsx +96 -0
- package/src/_doc/0.docs-overview.md +28 -0
- package/src/_doc/cx-ui/0.docs-overview.md +30 -0
- package/src/_doc/cx-ui/comp.1.cx-ui-overview.md +82 -0
- package/src/_doc/cx-ui/comp.2.cx-modal.md +82 -0
- package/src/_doc/cx-ui/comp.3.cx-button.md +89 -0
- package/src/_doc/cx-ui/comp.4.cx-form.md +72 -0
- package/src/_doc/cx-ui/comp.5.cx-fields.md +76 -0
- package/src/_doc/cx-ui/comp.6.cx-tag.md +57 -0
- package/src/_doc/cx-ui/comp.7.cx-empty-state.md +29 -0
- package/src/_doc/meta/0.docs-overview.md +24 -0
- package/src/_doc/meta/comp.1.enum-runtime.md +33 -0
- package/src/_doc/meta/comp.2.dict-runtime.md +39 -0
- package/src/_doc/router/0.docs-overview.md +14 -0
- package/src/_doc/router/guide.1.menu-component-config.md +181 -0
- package/src/_doc/router/guide.2.router-auto-registration.md +114 -0
- package/src/_doc/table-view/0.docs-overview.md +30 -0
- package/src/_doc/table-view/comp.1.table-view.md +542 -0
- package/src/_doc/table-view/props.1.create-table-view-config.md +193 -0
- package/src/_doc/table-view/props.2.table-view-search-fields.md +106 -0
- package/src/api/_mock/README.md +340 -0
- package/src/api/_mock/api.ts +1642 -0
- package/src/api/_mock/bundle-shim.ts +16 -0
- package/src/api/_mock/handler-shim.ts +6 -0
- package/src/api/_mock/handler.ts +458 -0
- package/src/api/_mock/index.ts +711 -0
- package/src/api/_mock/interceptor.ts +15 -0
- package/src/api/_mock/mod.ts +12 -0
- package/src/api/_mock/utils.ts +65 -0
- package/src/api/base/memory.js +24 -0
- package/src/api/chat.js +210 -0
- package/src/api/common/auth.js +70 -0
- package/src/api/menus/business-rules.js +76 -0
- package/src/api/menus/feedback.js +102 -0
- package/src/api/menus/knowledge.js +159 -0
- package/src/api/menus/model-metadata/manage.js +70 -0
- package/src/api/menus/model-metadata/role.js +50 -0
- package/src/api/menus/model-metadata/training-detail-mock-data.js +569 -0
- package/src/api/menus/model-metadata/training.js +28 -0
- package/src/api/menus/skill.js +40 -0
- package/src/api/system/agent-config.js +16 -0
- package/src/api/system/department.js +94 -0
- package/src/api/system/dict.js +86 -0
- package/src/api/system/menu.js +37 -0
- package/src/api/system/permission.js +26 -0
- package/src/api/system/role.js +34 -0
- package/src/api/system/sys-config.js +16 -0
- package/src/api/system/sys-log.js +17 -0
- package/src/api/system/user.js +75 -0
- package/src/api/upload.js +39 -0
- package/src/assets/react.svg +1 -0
- package/src/components/auth/current-user-avatar.tsx +77 -0
- package/src/components/common/code-view.tsx +149 -0
- package/src/components/common/detail-link.tsx +67 -0
- package/src/components/common/error-boundary.tsx +98 -0
- package/src/components/common/language-switcher.tsx +91 -0
- package/src/components/common/lite-table/index.tsx +135 -0
- package/src/components/common/md-editor.tsx +126 -0
- package/src/components/common/modal/confirm-dialog.tsx +113 -0
- package/src/components/common/modal/dep-user-select-multi.tsx +324 -0
- package/src/components/common/modal/dep-user-select.tsx +249 -0
- package/src/components/common/modal/user-select-multi.tsx +266 -0
- package/src/components/common/pagination.tsx +472 -0
- package/src/components/common/path.tsx +175 -0
- package/src/components/common/system-logo-mark.tsx +48 -0
- package/src/components/cx-ui/button/index.less +208 -0
- package/src/components/cx-ui/button/index.tsx +611 -0
- package/src/components/cx-ui/checkbox/index.tsx +78 -0
- package/src/components/cx-ui/date-picker/index.less +17 -0
- package/src/components/cx-ui/date-picker/index.tsx +193 -0
- package/src/components/cx-ui/drawer/index.tsx +47 -0
- package/src/components/cx-ui/empty-state/index.tsx +20 -0
- package/src/components/cx-ui/floating-shell/CxFloatingShell.tsx +89 -0
- package/src/components/cx-ui/floating-shell/cx-floating-shell.less +283 -0
- package/src/components/cx-ui/floating-shell/has-floating-value.ts +41 -0
- package/src/components/cx-ui/form/CxForm.tsx +15 -0
- package/src/components/cx-ui/form/index.tsx +20 -0
- package/src/components/cx-ui/form-item/index.less +26 -0
- package/src/components/cx-ui/form-item/index.tsx +36 -0
- package/src/components/cx-ui/index.ts +70 -0
- package/src/components/cx-ui/input/auto-complete.tsx +134 -0
- package/src/components/cx-ui/input/index.tsx +259 -0
- package/src/components/cx-ui/input-number/index.jsx +66 -0
- package/src/components/cx-ui/modal/index.jsx +212 -0
- package/src/components/cx-ui/modal/index.less +144 -0
- package/src/components/cx-ui/modal/useCxModal.ts +125 -0
- package/src/components/cx-ui/multi-select/index.jsx +74 -0
- package/src/components/cx-ui/multi-select/index.less +40 -0
- package/src/components/cx-ui/multi-select/index2.tsx +361 -0
- package/src/components/cx-ui/radio/index.tsx +33 -0
- package/src/components/cx-ui/range-picker/index.less +65 -0
- package/src/components/cx-ui/range-picker/index.tsx +219 -0
- package/src/components/cx-ui/select/index.less +34 -0
- package/src/components/cx-ui/select/index.tsx +196 -0
- package/src/components/cx-ui/skeleton/index.tsx +12 -0
- package/src/components/cx-ui/steps/index.tsx +14 -0
- package/src/components/cx-ui/styles/_tokens.less +79 -0
- package/src/components/cx-ui/styles/index.less +246 -0
- package/src/components/cx-ui/switch/index.less +106 -0
- package/src/components/cx-ui/switch/index.tsx +120 -0
- package/src/components/cx-ui/table/index.less +160 -0
- package/src/components/cx-ui/table/index.tsx +152 -0
- package/src/components/cx-ui/tabs/index.less +15 -0
- package/src/components/cx-ui/tabs/index.tsx +34 -0
- package/src/components/cx-ui/tag/index.less +51 -0
- package/src/components/cx-ui/tag/index.tsx +140 -0
- package/src/components/cx-ui/timeline/index.tsx +14 -0
- package/src/components/cx-ui/tooltip/index.tsx +67 -0
- package/src/components/cx-ui/tree/index.tsx +193 -0
- package/src/components/cx-ui/tree-select/index.jsx +91 -0
- package/src/components/cx-ui/tree-select/index.less +27 -0
- package/src/components/cx-ui/upload-file/index.less +223 -0
- package/src/components/cx-ui/upload-file/index.tsx +640 -0
- package/src/components/cx-ui/upload-img/index.tsx +291 -0
- package/src/components/layout/components/Header.tsx +216 -0
- package/src/components/layout/components/Sidebar.tsx +717 -0
- package/src/components/layout/index.tsx +95 -0
- package/src/components/table-view/components/search-area.tsx +411 -0
- package/src/components/table-view/components/table-view-config.tsx +528 -0
- package/src/components/table-view/components/table-view.types.ts +478 -0
- package/src/components/table-view/components/tree-api-normalize.ts +38 -0
- package/src/components/table-view/components/tree-data-annotate.ts +31 -0
- package/src/components/table-view/components/tree-sidebar.tsx +74 -0
- package/src/components/table-view/index.tsx +61 -0
- package/src/components/table-view/list-page-view.tsx +1049 -0
- package/src/components/table-view/select-table-view.tsx +1094 -0
- package/src/components/table-view/styles/select-table-view.less +51 -0
- package/src/config/default-system-name.ts +9 -0
- package/src/config/system.ts +165 -0
- package/src/constants/countryCodes.ts +3 -0
- package/src/contexts/AuthContext.tsx +256 -0
- package/src/contexts/ChatContext.tsx +839 -0
- package/src/contexts/MenuContext.tsx +62 -0
- package/src/contexts/ToastContext.tsx +181 -0
- package/src/hooks/useCopyToClipboard.ts +47 -0
- package/src/hooks/useModalSubmit.ts +104 -0
- package/src/hooks/useRouter.ts +240 -0
- package/src/hooks/useStepForm.ts +46 -0
- package/src/hooks/useStickyHeader.ts +42 -0
- package/src/hooks/useThreadActions.ts +105 -0
- package/src/hooks/useUserPreferences.ts +101 -0
- package/src/http/axios.js +372 -0
- package/src/http/mock.interceptor.ts +9 -0
- package/src/http/obfuscationKey.ts +41 -0
- package/src/i18n.ts +60 -0
- package/src/index.js +1 -0
- package/src/index.less +169 -0
- package/src/locales/en/auth.ts +70 -0
- package/src/locales/en/base/memory.ts +28 -0
- package/src/locales/en/base/settings.ts +41 -0
- package/src/locales/en/chat.ts +40 -0
- package/src/locales/en/common.ts +173 -0
- package/src/locales/en/enum.ts +27 -0
- package/src/locales/en/menus/business-rules.ts +48 -0
- package/src/locales/en/menus/feedback.ts +62 -0
- package/src/locales/en/menus/knowledge.ts +120 -0
- package/src/locales/en/menus/model-metadata/index.ts +10 -0
- package/src/locales/en/menus/model-metadata/manage.ts +151 -0
- package/src/locales/en/menus/model-metadata/role.ts +48 -0
- package/src/locales/en/menus/model-metadata/training.ts +65 -0
- package/src/locales/en/menus/skill.ts +34 -0
- package/src/locales/en/system/agent-config.ts +34 -0
- package/src/locales/en/system/department.ts +68 -0
- package/src/locales/en/system/dict.ts +44 -0
- package/src/locales/en/system/menu.ts +45 -0
- package/src/locales/en/system/permission.ts +89 -0
- package/src/locales/en/system/role.ts +25 -0
- package/src/locales/en/system/sys-config.ts +33 -0
- package/src/locales/en/system/sys-log.ts +38 -0
- package/src/locales/en/system/user.ts +113 -0
- package/src/locales/en.ts +68 -0
- package/src/locales/zh/auth.ts +70 -0
- package/src/locales/zh/base/memory.ts +29 -0
- package/src/locales/zh/base/settings.ts +41 -0
- package/src/locales/zh/chat.ts +47 -0
- package/src/locales/zh/common.ts +178 -0
- package/src/locales/zh/enum.ts +28 -0
- package/src/locales/zh/menus/business-rules.ts +47 -0
- package/src/locales/zh/menus/feedback.ts +62 -0
- package/src/locales/zh/menus/knowledge.ts +117 -0
- package/src/locales/zh/menus/model-metadata/index.ts +10 -0
- package/src/locales/zh/menus/model-metadata/manage.ts +151 -0
- package/src/locales/zh/menus/model-metadata/role.ts +47 -0
- package/src/locales/zh/menus/model-metadata/training.ts +64 -0
- package/src/locales/zh/menus/skill.ts +34 -0
- package/src/locales/zh/system/agent-config.ts +33 -0
- package/src/locales/zh/system/department.ts +69 -0
- package/src/locales/zh/system/dict.ts +44 -0
- package/src/locales/zh/system/menu.ts +47 -0
- package/src/locales/zh/system/permission.ts +94 -0
- package/src/locales/zh/system/role.ts +25 -0
- package/src/locales/zh/system/sys-config.ts +32 -0
- package/src/locales/zh/system/sys-log.ts +38 -0
- package/src/locales/zh/system/user.ts +114 -0
- package/src/locales/zh.ts +67 -0
- package/src/main.tsx +50 -0
- package/src/meta/const/index.ts +40 -0
- package/src/meta/index-dict.ts +56 -0
- package/src/meta/index-enum.ts +95 -0
- package/src/meta/index.ts +14 -0
- package/src/meta/module/dict-data/runtime.ts +199 -0
- package/src/meta/module/dict-data/types.ts +17 -0
- package/src/meta/module/enum-data/runtime.ts +75 -0
- package/src/meta/module/enum-data/types.ts +18 -0
- package/src/router/index.tsx +312 -0
- package/src/styles/AntdThemeProvider.tsx +40 -0
- package/src/styles/antd-theme.ts +20 -0
- package/src/styles/global.less +107 -0
- package/src/styles/variable.less +103 -0
- package/src/types/feedback.ts +43 -0
- package/src/types/index.ts +85 -0
- package/src/types/menu.ts +43 -0
- package/src/utils/aesUtil.ts +123 -0
- package/src/utils/chatUtils.ts +524 -0
- package/src/utils/cn.ts +6 -0
- package/src/utils/crypto.ts +164 -0
- package/src/utils/date.ts +72 -0
- package/src/utils/file-icons.tsx +79 -0
- package/src/utils/index.ts +168 -0
- package/src/utils/markdown-math-plugins.ts +21 -0
- package/src/utils/menuI18n.ts +305 -0
- package/src/utils/menuRouteRegistry.ts +78 -0
- package/src/utils/permission-crud.ts +147 -0
- package/src/utils/routeConfig.ts +350 -0
- package/src/utils/storage.ts +135 -0
- package/src/utils/toastBridge.ts +26 -0
- package/src/utils/url.ts +38 -0
- package/src/utils/validation.ts +16 -0
- package/src/views/auth/auth-code/index.less +169 -0
- package/src/views/auth/auth-code/index.module.less +174 -0
- package/src/views/auth/auth-code/index.tsx +233 -0
- package/src/views/auth/login.tsx +498 -0
- package/src/views/auth/register.tsx +388 -0
- package/src/views/base/memory/index.tsx +136 -0
- package/src/views/base/memory/modal/detail-modal.tsx +89 -0
- package/src/views/base/memory/modal/submit-modal.tsx +134 -0
- package/src/views/base/settings/index.tsx +657 -0
- package/src/views/chat/chat.less +323 -0
- package/src/views/chat/components/chat-input.tsx +298 -0
- package/src/views/chat/components/header-thread-title.tsx +210 -0
- package/src/views/chat/components/message-list/content-answer.tsx +100 -0
- package/src/views/chat/components/message-list/content-question.tsx +18 -0
- package/src/views/chat/components/message-list/index.tsx +520 -0
- package/src/views/chat/components/message-list/message-item.tsx +199 -0
- package/src/views/chat/components/message-list/preparation-demo-items.ts +147 -0
- package/src/views/chat/components/message-list/preparation-steps.tsx +506 -0
- package/src/views/chat/components/message-list/suggestion-list.tsx +36 -0
- package/src/views/chat/components/message-list/thinking-process.tsx +49 -0
- package/src/views/chat/components/message-list/toolbar.tsx +224 -0
- package/src/views/chat/components/message-list/use-message-list-scroll.ts +214 -0
- package/src/views/chat/components/references-knowledge/context.tsx +57 -0
- package/src/views/chat/components/references-knowledge/index.ts +9 -0
- package/src/views/chat/components/references-knowledge/modal/knowledge-detail-drawer.tsx +556 -0
- package/src/views/chat/components/references-knowledge/modal/knowledge-doc-detail-drawer.tsx +529 -0
- package/src/views/chat/components/references-knowledge/panel.tsx +115 -0
- package/src/views/chat/hooks/use-chat-common.ts +19 -0
- package/src/views/chat/index-session.tsx +647 -0
- package/src/views/chat/index.tsx +127 -0
- package/src/views/page-error/401.tsx +56 -0
- package/src/views/page-error/404.tsx +56 -0
- package/src/views/page-menus/business-rules/index.tsx +376 -0
- package/src/views/page-menus/business-rules/modal/detail-modal.tsx +186 -0
- package/src/views/page-menus/business-rules/modal/scope-modal.tsx +272 -0
- package/src/views/page-menus/business-rules/modal/submit-modal.tsx +142 -0
- package/src/views/page-menus/feedback/components/feedback-dataset-list.tsx +471 -0
- package/src/views/page-menus/feedback/index.tsx +166 -0
- package/src/views/page-menus/feedback/modal/export-feedback-modal.tsx +367 -0
- package/src/views/page-menus/knowledge/components/doc-editor-by-type.tsx +32 -0
- package/src/views/page-menus/knowledge/components/doc-editor-type-file.tsx +330 -0
- package/src/views/page-menus/knowledge/detail.tsx +600 -0
- package/src/views/page-menus/knowledge/index.tsx +337 -0
- package/src/views/page-menus/knowledge/modal/detail-modal.tsx +618 -0
- package/src/views/page-menus/knowledge/modal/doc-detail-modal.tsx +550 -0
- package/src/views/page-menus/knowledge/modal/doc-parse.ts +99 -0
- package/src/views/page-menus/knowledge/modal/doc-submit-modal.tsx +349 -0
- package/src/views/page-menus/knowledge/modal/doc-type-picker-modal.tsx +88 -0
- package/src/views/page-menus/knowledge/modal/knowledge-user-select-modal.tsx +283 -0
- package/src/views/page-menus/knowledge/modal/submit-modal.tsx +179 -0
- package/src/views/page-menus/model-metadata/manage/components/metadata-detail-schema-tab.tsx +114 -0
- package/src/views/page-menus/model-metadata/manage/components/step1-basic-info.tsx +232 -0
- package/src/views/page-menus/model-metadata/manage/components/step2-schema.tsx +316 -0
- package/src/views/page-menus/model-metadata/manage/components/step3-permissions.tsx +134 -0
- package/src/views/page-menus/model-metadata/manage/components/step4-documents.tsx +134 -0
- package/src/views/page-menus/model-metadata/manage/components/step5-example-sql.tsx +101 -0
- package/src/views/page-menus/model-metadata/manage/components/submit-add.tsx +338 -0
- package/src/views/page-menus/model-metadata/manage/components/submit-edit.tsx +276 -0
- package/src/views/page-menus/model-metadata/manage/detail.tsx +298 -0
- package/src/views/page-menus/model-metadata/manage/hooks/model-metadata-submit-shared.ts +113 -0
- package/src/views/page-menus/model-metadata/manage/hooks/use-model-metadata-item-state.ts +20 -0
- package/src/views/page-menus/model-metadata/manage/index.tsx +304 -0
- package/src/views/page-menus/model-metadata/manage/modal/components/table-schema.ts +374 -0
- package/src/views/page-menus/model-metadata/manage/modal/components/use-table-detail-tabs.tsx +151 -0
- package/src/views/page-menus/model-metadata/manage/modal/components/use-table-submit-tabs.tsx +423 -0
- package/src/views/page-menus/model-metadata/manage/modal/detail-modal.tsx +218 -0
- package/src/views/page-menus/model-metadata/manage/modal/submit-modal.tsx +261 -0
- package/src/views/page-menus/model-metadata/manage/modal/table-detail-modal.tsx +196 -0
- package/src/views/page-menus/model-metadata/manage/modal/table-submit-modal.tsx +229 -0
- package/src/views/page-menus/model-metadata/manage/submit.tsx +31 -0
- package/src/views/page-menus/model-metadata/role/index.tsx +207 -0
- package/src/views/page-menus/model-metadata/role/modal/detail-modal.tsx +97 -0
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-modal.tsx +254 -0
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-panel.tsx +393 -0
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-utils.ts +120 -0
- package/src/views/page-menus/model-metadata/role/modal/role-permission-assign-panel.tsx +698 -0
- package/src/views/page-menus/model-metadata/role/modal/role-permission-modal.tsx +237 -0
- package/src/views/page-menus/model-metadata/role/modal/submit-modal.tsx +135 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/index.ts +4 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/node-card.tsx +72 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/summary-lines.ts +196 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/summary-list.tsx +153 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/timeline.tsx +103 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/types.ts +82 -0
- package/src/views/page-menus/model-metadata/training/detail.tsx +159 -0
- package/src/views/page-menus/model-metadata/training/index.tsx +236 -0
- package/src/views/page-menus/model-metadata/training/modal/update-detail-modal.tsx +154 -0
- package/src/views/page-menus/skill/index.tsx +201 -0
- package/src/views/page-menus/skill/modal/detail-modal.tsx +156 -0
- package/src/views/page-menus/skill/modal/submit-modal.tsx +214 -0
- package/src/views/page-system/agent-config/index.tsx +370 -0
- package/src/views/page-system/department/departmentFormShared.ts +36 -0
- package/src/views/page-system/department/index.tsx +541 -0
- package/src/views/page-system/department/modal/detail-modal.tsx +94 -0
- package/src/views/page-system/department/modal/member-role-modal.tsx +128 -0
- package/src/views/page-system/department/modal/submit-modal.tsx +265 -0
- package/src/views/page-system/dict/index.tsx +440 -0
- package/src/views/page-system/dict/modal/cate-submit-modal.tsx +315 -0
- package/src/views/page-system/dict/modal/submit-modal.tsx +184 -0
- package/src/views/page-system/logs/components/index.ts +3 -0
- package/src/views/page-system/logs/components/log-message-demo.tsx +30 -0
- package/src/views/page-system/logs/components/log-message-stream.ts +184 -0
- package/src/views/page-system/logs/components/message-list/content-answer.tsx +100 -0
- package/src/views/page-system/logs/components/message-list/content-question.tsx +18 -0
- package/src/views/page-system/logs/components/message-list/index.tsx +515 -0
- package/src/views/page-system/logs/components/message-list/message-item.tsx +193 -0
- package/src/views/page-system/logs/components/message-list/preparation-demo-items.ts +147 -0
- package/src/views/page-system/logs/components/message-list/preparation-steps.tsx +506 -0
- package/src/views/page-system/logs/components/message-list/suggestion-list.tsx +36 -0
- package/src/views/page-system/logs/components/message-list/thinking-process.tsx +49 -0
- package/src/views/page-system/logs/components/message-list/toolbar.tsx +134 -0
- package/src/views/page-system/logs/components/message-list/use-message-list-scroll.ts +214 -0
- package/src/views/page-system/logs/components/message-modal.tsx +239 -0
- package/src/views/page-system/logs/index.tsx +132 -0
- package/src/views/page-system/logs/modal/detail-modal.tsx +157 -0
- package/src/views/page-system/menu/components/menuFormShared.ts +283 -0
- package/src/views/page-system/menu/index.less +12 -0
- package/src/views/page-system/menu/index.tsx +410 -0
- package/src/views/page-system/menu/modal/icon-modal.less +51 -0
- package/src/views/page-system/menu/modal/icon-modal.tsx +87 -0
- package/src/views/page-system/menu/modal/submit-modal.tsx +263 -0
- package/src/views/page-system/permission/index.tsx +562 -0
- package/src/views/page-system/permission/modal/detail-modal.tsx +179 -0
- package/src/views/page-system/permission/modal/submit-modal.less +146 -0
- package/src/views/page-system/permission/modal/submit-modal.tsx +650 -0
- package/src/views/page-system/role/index.tsx +163 -0
- package/src/views/page-system/role/modal/detail-modal.tsx +127 -0
- package/src/views/page-system/role/modal/permission-assign-group-rules.ts +86 -0
- package/src/views/page-system/role/modal/permission-modal.tsx +111 -0
- package/src/views/page-system/role/modal/role-modal-shell-styles.ts +21 -0
- package/src/views/page-system/role/modal/role-permission-assign-panel.tsx +916 -0
- package/src/views/page-system/role/modal/role-permission-assign-shared.ts +1047 -0
- package/src/views/page-system/role/modal/submit-modal.tsx +193 -0
- package/src/views/page-system/sys-config/index.tsx +294 -0
- package/src/views/page-system/user/components/user-role-column.tsx +87 -0
- package/src/views/page-system/user/index.tsx +439 -0
- package/src/views/page-system/user/modal/assign-roles-modal.tsx +389 -0
- package/src/views/page-system/user/modal/detail-modal.tsx +72 -0
- package/src/views/page-system/user/modal/modal-style/submit-modal.less +40 -0
- package/src/views/page-system/user/modal/submit-modal.less +40 -0
- package/src/views/page-system/user/modal/submit-modal.tsx +287 -0
- package/src/views/page-system/user/userFormShared.ts +51 -0
- package/tailwind.config.js +17 -0
- package/tsconfig.app.json +48 -0
- package/tsconfig.json +11 -0
- package/tsconfig.node.json +26 -0
- package/vite.config.ts +264 -0
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
import type { ButtonProps } from 'antd'
|
|
2
|
+
import { Button } from 'antd'
|
|
3
|
+
import clsx from 'clsx'
|
|
4
|
+
import {
|
|
5
|
+
Check,
|
|
6
|
+
CircleCheck,
|
|
7
|
+
CircleX,
|
|
8
|
+
Download,
|
|
9
|
+
Edit,
|
|
10
|
+
Edit2,
|
|
11
|
+
Eye,
|
|
12
|
+
Plus,
|
|
13
|
+
Star,
|
|
14
|
+
Trash2,
|
|
15
|
+
Upload,
|
|
16
|
+
X,
|
|
17
|
+
} from 'lucide-react'
|
|
18
|
+
import type { CSSProperties, ReactNode } from 'react'
|
|
19
|
+
import React from 'react'
|
|
20
|
+
import { useTranslation } from 'react-i18next'
|
|
21
|
+
import type { CxTooltipTone } from '../tooltip'
|
|
22
|
+
import { CxTooltip } from '../tooltip'
|
|
23
|
+
import './index.less'
|
|
24
|
+
|
|
25
|
+
/** 方框风格图标容器:用于让图标呈现“带方框”的视觉效果(保持整体占位与 iconSize 一致) */
|
|
26
|
+
function SquareIconFrame({ size, children }: { size: number; children: React.ReactNode }) {
|
|
27
|
+
return (
|
|
28
|
+
<span
|
|
29
|
+
className="inline-flex items-center justify-center border-2 border-current rounded-[2px] box-border"
|
|
30
|
+
style={{ width: size, height: size }}
|
|
31
|
+
>
|
|
32
|
+
{children}
|
|
33
|
+
</span>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function toCssLength(value: number | string | undefined | null): string | undefined {
|
|
38
|
+
if (value == null) return undefined
|
|
39
|
+
return typeof value === 'number' ? `${value}px` : value
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const ICON_TYPE_CLASS: Record<string, string> = {
|
|
43
|
+
default: 'text-gray-500 hover:text-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800',
|
|
44
|
+
primary:
|
|
45
|
+
'text-gray-500 hover:text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/20 active:bg-blue-100 dark:active:bg-blue-900/40',
|
|
46
|
+
/** 与 `CxTooltip` success 色(#15803d)同一语义,悬停为绿色系 */
|
|
47
|
+
success:
|
|
48
|
+
'text-green-700 hover:bg-green-50 dark:hover:bg-green-900/25 active:bg-green-100 dark:active:bg-green-900/40',
|
|
49
|
+
danger:
|
|
50
|
+
'text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 active:bg-red-100 dark:active:bg-red-900/40',
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function normalizeAntdButtonSize(
|
|
54
|
+
sizeProp: ButtonProps['size'] | undefined | null,
|
|
55
|
+
): 'small' | 'medium' | 'large' {
|
|
56
|
+
if (sizeProp === undefined || sizeProp === null) return 'medium'
|
|
57
|
+
if (sizeProp === 'middle') return 'medium'
|
|
58
|
+
return sizeProp
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** 与 antd Button 一致,并支持 icon 模式与 height;icon 模式下 `type` 可作色调(含 danger) */
|
|
62
|
+
export type CxButtonBaseProps = Omit<ButtonProps, 'type'> & {
|
|
63
|
+
buttonType?: 'antd' | 'icon'
|
|
64
|
+
height?: number | string
|
|
65
|
+
type?: ButtonProps['type'] | 'danger' | 'success'
|
|
66
|
+
/** 图标按钮:悬停文案,优先于原生 `title` */
|
|
67
|
+
tooltipTitle?: ReactNode
|
|
68
|
+
/** 图标按钮:`CxTooltip` 背景语义色 */
|
|
69
|
+
tooltipTone?: CxTooltipTone
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** 纯图标按钮:必须传入 `icon`;语义等价于 `buttonType="icon"` 的 `CxButton` */
|
|
73
|
+
export type CxButtonIconProps = Omit<CxButtonBaseProps, 'buttonType' | 'icon'> & {
|
|
74
|
+
icon: ReactNode
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** 预设图标的变体:默认图标在组件内写死;可选 `icon` 覆盖、`iconSize` 控制边长 */
|
|
78
|
+
export type CxButtonIconPresetProps = Omit<CxButtonIconProps, 'icon'> & {
|
|
79
|
+
icon?: ReactNode
|
|
80
|
+
iconSize?: number
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** 纯图标按钮 / 行内预设(IconEdit 等)默认边长:与列表操作列常用 16 对齐;非列表场景请传 `iconSize` 或自定义 `icon` */
|
|
84
|
+
const CX_ICON_PX = 16
|
|
85
|
+
/** antd 文字按钮上默认图标的边长(与未传 `icon` 时配套;自定义 `icon` 时忽略) */
|
|
86
|
+
const TEXT_BTN_ICON_PX = 16
|
|
87
|
+
|
|
88
|
+
export function CxButtonIcon({ icon, ...props }: CxButtonIconProps) {
|
|
89
|
+
return <CxButtonPrimitive buttonType="icon" icon={icon} {...props} />
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 与 antd Button 一致:size 支持 large / medium / small;不传 size 默认为 small(表格、搜索、弹窗等)。
|
|
94
|
+
* 列表页顶栏「新增」等需显式 `size="medium"` 或 `large`。
|
|
95
|
+
* `middle` 为历史别名,内部会规范为 `medium`。
|
|
96
|
+
*/
|
|
97
|
+
function CxButtonPrimitive({
|
|
98
|
+
buttonType = 'antd',
|
|
99
|
+
height,
|
|
100
|
+
style,
|
|
101
|
+
icon,
|
|
102
|
+
size: sizeProp,
|
|
103
|
+
className,
|
|
104
|
+
tooltipTitle: tooltipTitleProp,
|
|
105
|
+
tooltipTone = 'default',
|
|
106
|
+
...props
|
|
107
|
+
}: CxButtonBaseProps) {
|
|
108
|
+
if (buttonType === 'icon') {
|
|
109
|
+
const {
|
|
110
|
+
type: iconTone = 'primary',
|
|
111
|
+
title: legacyTitle,
|
|
112
|
+
onClick,
|
|
113
|
+
disabled,
|
|
114
|
+
...rest
|
|
115
|
+
} = props as CxButtonBaseProps & {
|
|
116
|
+
type?: 'default' | 'primary' | 'danger' | 'success'
|
|
117
|
+
title?: string
|
|
118
|
+
}
|
|
119
|
+
const tipContent = tooltipTitleProp ?? legacyTitle
|
|
120
|
+
const showTip =
|
|
121
|
+
tipContent != null &&
|
|
122
|
+
tipContent !== '' &&
|
|
123
|
+
(typeof tipContent !== 'string' || tipContent.trim() !== '')
|
|
124
|
+
|
|
125
|
+
const buttonEl = (
|
|
126
|
+
<button
|
|
127
|
+
type="button"
|
|
128
|
+
disabled={disabled}
|
|
129
|
+
onClick={onClick}
|
|
130
|
+
aria-label={
|
|
131
|
+
showTip && typeof tipContent === 'string' ? tipContent : undefined
|
|
132
|
+
}
|
|
133
|
+
style={style as CSSProperties | undefined}
|
|
134
|
+
{...(rest as React.ButtonHTMLAttributes<HTMLButtonElement>)}
|
|
135
|
+
className={clsx(
|
|
136
|
+
'p-1.5 rounded-lg transition-all active:scale-90',
|
|
137
|
+
ICON_TYPE_CLASS[iconTone as string] || ICON_TYPE_CLASS.primary,
|
|
138
|
+
disabled && 'opacity-50 cursor-not-allowed active:scale-100',
|
|
139
|
+
className,
|
|
140
|
+
)}>
|
|
141
|
+
{icon}
|
|
142
|
+
</button>
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
if (showTip) {
|
|
146
|
+
const trigger =
|
|
147
|
+
disabled ? (
|
|
148
|
+
<span className="inline-flex cursor-not-allowed">{buttonEl}</span>
|
|
149
|
+
) : (
|
|
150
|
+
buttonEl
|
|
151
|
+
)
|
|
152
|
+
return (
|
|
153
|
+
<CxTooltip title={tipContent} tone={tooltipTone}>
|
|
154
|
+
{trigger}
|
|
155
|
+
</CxTooltip>
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return buttonEl
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const sizeForAntd = normalizeAntdButtonSize(sizeProp)
|
|
163
|
+
|
|
164
|
+
const styleObj = style && typeof style === 'object' ? style : {}
|
|
165
|
+
const fromStyleHeight = styleObj.height
|
|
166
|
+
const hasCustomHeight =
|
|
167
|
+
(fromStyleHeight !== undefined && fromStyleHeight !== null) ||
|
|
168
|
+
(height !== undefined && height !== null)
|
|
169
|
+
|
|
170
|
+
const defaultHeightBySize =
|
|
171
|
+
sizeForAntd === 'small' ? 32 : sizeForAntd === 'large' ? 44 : 40
|
|
172
|
+
const resolved =
|
|
173
|
+
fromStyleHeight !== undefined && fromStyleHeight !== null
|
|
174
|
+
? fromStyleHeight
|
|
175
|
+
: height !== undefined && height !== null
|
|
176
|
+
? toCssLength(height)
|
|
177
|
+
: defaultHeightBySize
|
|
178
|
+
const resolvedStr = toCssLength(resolved) ?? String(resolved)
|
|
179
|
+
|
|
180
|
+
const { height: _drop, ...restStyle } = styleObj
|
|
181
|
+
|
|
182
|
+
const mergedStyle: CSSProperties = {
|
|
183
|
+
boxSizing: 'border-box',
|
|
184
|
+
...restStyle,
|
|
185
|
+
}
|
|
186
|
+
if (hasCustomHeight) {
|
|
187
|
+
mergedStyle.height = resolvedStr
|
|
188
|
+
mergedStyle.minHeight = resolvedStr
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const antdProps = { ...(props as Record<string, unknown>) }
|
|
192
|
+
if (antdProps.type === 'success') {
|
|
193
|
+
antdProps.type = 'default'
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<Button
|
|
198
|
+
{...(antdProps as ButtonProps)}
|
|
199
|
+
size={sizeForAntd}
|
|
200
|
+
icon={icon}
|
|
201
|
+
className={clsx(
|
|
202
|
+
'cx-button',
|
|
203
|
+
`cx-button--size-${sizeForAntd}`,
|
|
204
|
+
className,
|
|
205
|
+
)}
|
|
206
|
+
style={mergedStyle}
|
|
207
|
+
/>
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
type VariantProps = CxButtonBaseProps & { children?: ReactNode }
|
|
212
|
+
|
|
213
|
+
type VariantPropsWithBuiltInIcon = VariantProps & {
|
|
214
|
+
/** 内置默认图标的边长;仅在使用默认图标时生效(`icon` 为 `undefined`) */
|
|
215
|
+
iconSize?: number
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** 添加按钮(未传 `icon` 时默认 Plus;不要图标可传 `icon={null}`) */
|
|
219
|
+
export function CxButtonAdd({
|
|
220
|
+
children,
|
|
221
|
+
icon,
|
|
222
|
+
iconSize = TEXT_BTN_ICON_PX,
|
|
223
|
+
...props
|
|
224
|
+
}: VariantPropsWithBuiltInIcon) {
|
|
225
|
+
const { t } = useTranslation()
|
|
226
|
+
const resolvedIcon = icon === undefined ? <Plus size={iconSize} /> : icon
|
|
227
|
+
return (
|
|
228
|
+
<CxButtonPrimitive type="primary" icon={resolvedIcon} {...props}>
|
|
229
|
+
{children || t('common.add')}
|
|
230
|
+
</CxButtonPrimitive>
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** 删除按钮(未传 `icon` 时默认 Trash2;不要图标可传 `icon={null}`) */
|
|
235
|
+
export function CxButtonDelete({
|
|
236
|
+
children,
|
|
237
|
+
icon,
|
|
238
|
+
iconSize = TEXT_BTN_ICON_PX,
|
|
239
|
+
...props
|
|
240
|
+
}: VariantPropsWithBuiltInIcon) {
|
|
241
|
+
const { t } = useTranslation()
|
|
242
|
+
const resolvedIcon = icon === undefined ? <Trash2 size={iconSize} /> : icon
|
|
243
|
+
return (
|
|
244
|
+
<CxButtonPrimitive danger icon={resolvedIcon} {...props}>
|
|
245
|
+
{children || t('common.delete')}
|
|
246
|
+
</CxButtonPrimitive>
|
|
247
|
+
)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** 确定按钮 */
|
|
251
|
+
export function CxButtonOk({ children, ...props }: VariantProps) {
|
|
252
|
+
const { t } = useTranslation()
|
|
253
|
+
return (
|
|
254
|
+
<CxButtonPrimitive type="primary" {...props}>
|
|
255
|
+
{children || t('common.ok')}
|
|
256
|
+
</CxButtonPrimitive>
|
|
257
|
+
)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** 提交按钮 */
|
|
261
|
+
export function CxButtonSubmit({ children, ...props }: VariantProps) {
|
|
262
|
+
const { t } = useTranslation()
|
|
263
|
+
return (
|
|
264
|
+
<CxButtonPrimitive type="primary" htmlType="submit" {...props}>
|
|
265
|
+
{children || t('common.submit')}
|
|
266
|
+
</CxButtonPrimitive>
|
|
267
|
+
)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* 取消按钮(antd 文本按钮:`type="text"` → 无边框、无填充底)。
|
|
272
|
+
* 注意:antd 6 仅传 `variant` 而不传 `color` 时不会生效,会回退成 `default`+`outlined`(有边框、浅底)。
|
|
273
|
+
* 若需自定义,可同时传 `color` + `variant`,此时不再默认 `type="text"`。
|
|
274
|
+
*/
|
|
275
|
+
export function CxButtonCancel({
|
|
276
|
+
children,
|
|
277
|
+
type,
|
|
278
|
+
color,
|
|
279
|
+
variant,
|
|
280
|
+
...props
|
|
281
|
+
}: VariantProps) {
|
|
282
|
+
const { t } = useTranslation()
|
|
283
|
+
if (color != null && variant != null) {
|
|
284
|
+
return (
|
|
285
|
+
<CxButtonPrimitive {...props} color={color} variant={variant}>
|
|
286
|
+
{children || t('common.cancel')}
|
|
287
|
+
</CxButtonPrimitive>
|
|
288
|
+
)
|
|
289
|
+
}
|
|
290
|
+
return (
|
|
291
|
+
<CxButtonPrimitive {...props} type={type ?? 'text'}>
|
|
292
|
+
{children || t('common.cancel')}
|
|
293
|
+
</CxButtonPrimitive>
|
|
294
|
+
)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* 表单旁辅助按钮:`type="default"` + `height={42}`,与常见表单项/输入框高度对齐(如图标选择、次要操作)。
|
|
299
|
+
*/
|
|
300
|
+
export function CxButtonSecondary({ children, ...props }: VariantProps) {
|
|
301
|
+
return (
|
|
302
|
+
<CxButtonPrimitive type="default" height={42} {...props}>
|
|
303
|
+
{children}
|
|
304
|
+
</CxButtonPrimitive>
|
|
305
|
+
)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** 编辑按钮(未传 `icon` 时默认 Edit;不要图标可传 `icon={null}`) */
|
|
309
|
+
export function CxButtonEdit({
|
|
310
|
+
children,
|
|
311
|
+
icon,
|
|
312
|
+
iconSize = TEXT_BTN_ICON_PX,
|
|
313
|
+
...props
|
|
314
|
+
}: VariantPropsWithBuiltInIcon) {
|
|
315
|
+
const { t } = useTranslation()
|
|
316
|
+
const resolvedIcon = icon === undefined ? <Edit size={iconSize} /> : icon
|
|
317
|
+
return (
|
|
318
|
+
<CxButtonPrimitive type="link" icon={resolvedIcon} {...props}>
|
|
319
|
+
{children || t('common.edit')}
|
|
320
|
+
</CxButtonPrimitive>
|
|
321
|
+
)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** 查看按钮 */
|
|
325
|
+
export function CxButtonView({ children, ...props }: VariantProps) {
|
|
326
|
+
const { t } = useTranslation()
|
|
327
|
+
return (
|
|
328
|
+
<CxButtonPrimitive type="link" {...props}>
|
|
329
|
+
{children || t('common.view')}
|
|
330
|
+
</CxButtonPrimitive>
|
|
331
|
+
)
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** 下载按钮 */
|
|
335
|
+
export function CxButtonDownload({ children, ...props }: VariantProps) {
|
|
336
|
+
const { t } = useTranslation()
|
|
337
|
+
return (
|
|
338
|
+
<CxButtonPrimitive type="link" {...props}>
|
|
339
|
+
{children || t('common.download')}
|
|
340
|
+
</CxButtonPrimitive>
|
|
341
|
+
)
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** 导出按钮 */
|
|
345
|
+
export function CxButtonExport({ children, ...props }: VariantProps) {
|
|
346
|
+
const { t } = useTranslation()
|
|
347
|
+
return (
|
|
348
|
+
<CxButtonPrimitive type="link" {...props}>
|
|
349
|
+
{children || t('common.export')}
|
|
350
|
+
</CxButtonPrimitive>
|
|
351
|
+
)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** 保存按钮 */
|
|
355
|
+
export function CxButtonSave({ children, ...props }: VariantProps) {
|
|
356
|
+
const { t } = useTranslation()
|
|
357
|
+
return (
|
|
358
|
+
<CxButtonPrimitive type="primary" {...props}>
|
|
359
|
+
{children || t('common.save')}
|
|
360
|
+
</CxButtonPrimitive>
|
|
361
|
+
)
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** 编辑图标按钮(默认 Edit2;默认 Tooltip 为「编辑」) */
|
|
365
|
+
export function CxButtonIconEdit({
|
|
366
|
+
iconSize = CX_ICON_PX,
|
|
367
|
+
icon,
|
|
368
|
+
tooltipTitle,
|
|
369
|
+
title,
|
|
370
|
+
tooltipTone = 'primary',
|
|
371
|
+
...rest
|
|
372
|
+
}: CxButtonIconPresetProps) {
|
|
373
|
+
const { t } = useTranslation()
|
|
374
|
+
return (
|
|
375
|
+
<CxButtonIcon
|
|
376
|
+
icon={icon ?? <Edit2 size={iconSize} />}
|
|
377
|
+
tooltipTitle={tooltipTitle ?? title ?? t('common.edit')}
|
|
378
|
+
tooltipTone={tooltipTone}
|
|
379
|
+
{...rest}
|
|
380
|
+
/>
|
|
381
|
+
)
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** 删除图标按钮(默认 Trash2 + danger 色调;默认 Tooltip 为「删除」) */
|
|
385
|
+
export function CxButtonIconDelete({
|
|
386
|
+
iconSize = CX_ICON_PX,
|
|
387
|
+
icon,
|
|
388
|
+
tooltipTitle,
|
|
389
|
+
title,
|
|
390
|
+
tooltipTone = 'danger',
|
|
391
|
+
...rest
|
|
392
|
+
}: CxButtonIconPresetProps) {
|
|
393
|
+
const { t } = useTranslation()
|
|
394
|
+
return (
|
|
395
|
+
<CxButtonIcon
|
|
396
|
+
type="danger"
|
|
397
|
+
icon={icon ?? <Trash2 size={iconSize} />}
|
|
398
|
+
tooltipTitle={tooltipTitle ?? title ?? t('common.delete')}
|
|
399
|
+
tooltipTone={tooltipTone}
|
|
400
|
+
{...rest}
|
|
401
|
+
/>
|
|
402
|
+
)
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** 查看图标按钮(默认 Tooltip 为「查看」) */
|
|
406
|
+
export function CxButtonIconView({
|
|
407
|
+
iconSize = CX_ICON_PX,
|
|
408
|
+
icon,
|
|
409
|
+
tooltipTitle,
|
|
410
|
+
title,
|
|
411
|
+
tooltipTone = 'default',
|
|
412
|
+
...rest
|
|
413
|
+
}: CxButtonIconPresetProps) {
|
|
414
|
+
const { t } = useTranslation()
|
|
415
|
+
return (
|
|
416
|
+
<CxButtonIcon
|
|
417
|
+
icon={icon ?? <Eye size={iconSize} />}
|
|
418
|
+
tooltipTitle={tooltipTitle ?? title ?? t('common.view')}
|
|
419
|
+
tooltipTone={tooltipTone}
|
|
420
|
+
{...rest}
|
|
421
|
+
/>
|
|
422
|
+
)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/** 下载图标按钮(默认 Tooltip 为「下载」) */
|
|
426
|
+
export function CxButtonIconDownload({
|
|
427
|
+
iconSize = CX_ICON_PX,
|
|
428
|
+
icon,
|
|
429
|
+
tooltipTitle,
|
|
430
|
+
title,
|
|
431
|
+
tooltipTone = 'primary',
|
|
432
|
+
...rest
|
|
433
|
+
}: CxButtonIconPresetProps) {
|
|
434
|
+
const { t } = useTranslation()
|
|
435
|
+
return (
|
|
436
|
+
<CxButtonIcon
|
|
437
|
+
icon={icon ?? <Download size={iconSize} />}
|
|
438
|
+
tooltipTitle={tooltipTitle ?? title ?? t('common.download')}
|
|
439
|
+
tooltipTone={tooltipTone}
|
|
440
|
+
{...rest}
|
|
441
|
+
/>
|
|
442
|
+
)
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** 导出图标按钮(默认 Tooltip 为「导出」) */
|
|
446
|
+
export function CxButtonIconExport({
|
|
447
|
+
iconSize = CX_ICON_PX,
|
|
448
|
+
icon,
|
|
449
|
+
tooltipTitle,
|
|
450
|
+
title,
|
|
451
|
+
tooltipTone = 'primary',
|
|
452
|
+
...rest
|
|
453
|
+
}: CxButtonIconPresetProps) {
|
|
454
|
+
const { t } = useTranslation()
|
|
455
|
+
return (
|
|
456
|
+
<CxButtonIcon
|
|
457
|
+
icon={icon ?? <Upload size={iconSize} />}
|
|
458
|
+
tooltipTitle={tooltipTitle ?? title ?? t('common.export')}
|
|
459
|
+
tooltipTone={tooltipTone}
|
|
460
|
+
{...rest}
|
|
461
|
+
/>
|
|
462
|
+
)
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/** 设为默认等:方框打钩(勾选为默认);默认 Tooltip 为 common.set_as_default */
|
|
466
|
+
export function CxButtonIconSetDefault({
|
|
467
|
+
iconSize = CX_ICON_PX,
|
|
468
|
+
icon,
|
|
469
|
+
tooltipTitle,
|
|
470
|
+
title,
|
|
471
|
+
tooltipTone = 'primary',
|
|
472
|
+
type: _typeIgnored,
|
|
473
|
+
...rest
|
|
474
|
+
}: CxButtonIconPresetProps) {
|
|
475
|
+
const { t } = useTranslation()
|
|
476
|
+
return (
|
|
477
|
+
<CxButtonIcon
|
|
478
|
+
type="primary"
|
|
479
|
+
icon={icon ?? <Star size={iconSize} />}
|
|
480
|
+
tooltipTitle={tooltipTitle ?? title ?? t('common.set_as_default')}
|
|
481
|
+
tooltipTone={tooltipTone}
|
|
482
|
+
{...rest}
|
|
483
|
+
/>
|
|
484
|
+
)
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** 启用图标按钮(默认 Check;hover 与 Tooltip 均为 success 语义) */
|
|
488
|
+
export function CxButtonIconEnable({
|
|
489
|
+
iconSize = CX_ICON_PX,
|
|
490
|
+
icon,
|
|
491
|
+
tooltipTitle,
|
|
492
|
+
title,
|
|
493
|
+
tooltipTone = 'success',
|
|
494
|
+
type: _typeIgnored,
|
|
495
|
+
...rest
|
|
496
|
+
}: CxButtonIconPresetProps) {
|
|
497
|
+
const { t } = useTranslation()
|
|
498
|
+
return (
|
|
499
|
+
<CxButtonIcon
|
|
500
|
+
type="success"
|
|
501
|
+
icon={
|
|
502
|
+
icon ?? (
|
|
503
|
+
<SquareIconFrame size={iconSize}>
|
|
504
|
+
<Check size={iconSize - 4} strokeWidth={2.6} />
|
|
505
|
+
</SquareIconFrame>
|
|
506
|
+
)
|
|
507
|
+
}
|
|
508
|
+
tooltipTitle={tooltipTitle ?? title ?? t('common.enabled')}
|
|
509
|
+
tooltipTone={tooltipTone}
|
|
510
|
+
{...rest}
|
|
511
|
+
/>
|
|
512
|
+
)
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/** 禁用图标按钮(默认 X;hover 与 Tooltip 均为 danger 语义) */
|
|
516
|
+
export function CxButtonIconDisable({
|
|
517
|
+
iconSize = CX_ICON_PX,
|
|
518
|
+
icon,
|
|
519
|
+
tooltipTitle,
|
|
520
|
+
title,
|
|
521
|
+
tooltipTone = 'danger',
|
|
522
|
+
type: _typeIgnored,
|
|
523
|
+
...rest
|
|
524
|
+
}: CxButtonIconPresetProps) {
|
|
525
|
+
const { t } = useTranslation()
|
|
526
|
+
return (
|
|
527
|
+
<CxButtonIcon
|
|
528
|
+
type="danger"
|
|
529
|
+
icon={
|
|
530
|
+
icon ?? (
|
|
531
|
+
<SquareIconFrame size={iconSize}>
|
|
532
|
+
<X size={iconSize - 4} strokeWidth={2.6} />
|
|
533
|
+
</SquareIconFrame>
|
|
534
|
+
)
|
|
535
|
+
}
|
|
536
|
+
tooltipTitle={tooltipTitle ?? title ?? t('common.disabled')}
|
|
537
|
+
tooltipTone={tooltipTone}
|
|
538
|
+
{...rest}
|
|
539
|
+
/>
|
|
540
|
+
)
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/** 通过图标按钮(默认 CircleCheck;hover 与 Tooltip 均为 success 语义) */
|
|
544
|
+
export function CxButtonIconAccept({
|
|
545
|
+
iconSize = CX_ICON_PX,
|
|
546
|
+
icon,
|
|
547
|
+
tooltipTitle,
|
|
548
|
+
title,
|
|
549
|
+
tooltipTone = 'success',
|
|
550
|
+
type: _typeIgnored,
|
|
551
|
+
...rest
|
|
552
|
+
}: CxButtonIconPresetProps) {
|
|
553
|
+
return (
|
|
554
|
+
<CxButtonIcon
|
|
555
|
+
type="success"
|
|
556
|
+
icon={icon ?? <CircleCheck size={iconSize} />}
|
|
557
|
+
tooltipTitle={tooltipTitle ?? title}
|
|
558
|
+
tooltipTone={tooltipTone}
|
|
559
|
+
{...rest}
|
|
560
|
+
/>
|
|
561
|
+
)
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/** 拒绝图标按钮(默认 CircleX;hover 与 Tooltip 均为 danger 语义) */
|
|
565
|
+
export function CxButtonIconReject({
|
|
566
|
+
iconSize = CX_ICON_PX,
|
|
567
|
+
icon,
|
|
568
|
+
tooltipTitle,
|
|
569
|
+
title,
|
|
570
|
+
tooltipTone = 'danger',
|
|
571
|
+
type: _typeIgnored,
|
|
572
|
+
...rest
|
|
573
|
+
}: CxButtonIconPresetProps) {
|
|
574
|
+
return (
|
|
575
|
+
<CxButtonIcon
|
|
576
|
+
type="danger"
|
|
577
|
+
icon={icon ?? <CircleX size={iconSize} />}
|
|
578
|
+
tooltipTitle={tooltipTitle ?? title}
|
|
579
|
+
tooltipTone={tooltipTone}
|
|
580
|
+
{...rest}
|
|
581
|
+
/>
|
|
582
|
+
)
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
const CxButton = Object.assign(CxButtonPrimitive, {
|
|
586
|
+
Add: CxButtonAdd,
|
|
587
|
+
Cancel: CxButtonCancel,
|
|
588
|
+
Delete: CxButtonDelete,
|
|
589
|
+
Download: CxButtonDownload,
|
|
590
|
+
Edit: CxButtonEdit,
|
|
591
|
+
Export: CxButtonExport,
|
|
592
|
+
Icon: CxButtonIcon,
|
|
593
|
+
IconAccept: CxButtonIconAccept,
|
|
594
|
+
IconDelete: CxButtonIconDelete,
|
|
595
|
+
IconDisable: CxButtonIconDisable,
|
|
596
|
+
IconDownload: CxButtonIconDownload,
|
|
597
|
+
IconEdit: CxButtonIconEdit,
|
|
598
|
+
IconEnable: CxButtonIconEnable,
|
|
599
|
+
IconReject: CxButtonIconReject,
|
|
600
|
+
IconSetDefault: CxButtonIconSetDefault,
|
|
601
|
+
IconExport: CxButtonIconExport,
|
|
602
|
+
IconView: CxButtonIconView,
|
|
603
|
+
Ok: CxButtonOk,
|
|
604
|
+
Save: CxButtonSave,
|
|
605
|
+
Secondary: CxButtonSecondary,
|
|
606
|
+
Submit: CxButtonSubmit,
|
|
607
|
+
View: CxButtonView,
|
|
608
|
+
})
|
|
609
|
+
|
|
610
|
+
export { CxButton }
|
|
611
|
+
export default CxButton
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
import type { MouseEvent } from 'react'
|
|
3
|
+
|
|
4
|
+
export type CxCheckboxProps = {
|
|
5
|
+
checked: boolean
|
|
6
|
+
/** 点击后目标状态为 `!checked`;事件已 `stopPropagation`,适合放在可点击行内 */
|
|
7
|
+
onChange?: (checked: boolean, e: MouseEvent<HTMLButtonElement>) => void
|
|
8
|
+
disabled?: boolean
|
|
9
|
+
className?: string
|
|
10
|
+
/** 格子尺寸,默认与权限卡片一致 */
|
|
11
|
+
size?: 'sm' | 'md'
|
|
12
|
+
'aria-label'?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const sizeClass: Record<NonNullable<CxCheckboxProps['size']>, string> = {
|
|
16
|
+
sm: 'h-4 w-4',
|
|
17
|
+
md: 'h-5 w-5',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const iconSizeClass: Record<NonNullable<CxCheckboxProps['size']>, string> = {
|
|
21
|
+
sm: 'h-3 w-3',
|
|
22
|
+
md: 'h-3.5 w-3.5',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 视觉勾选框:与分配权限弹框右侧权限项一致(蓝底白勾 / 灰边框白底)。
|
|
27
|
+
* 使用 `button` 实现,避免原生 checkbox 与自定义样式不一致。
|
|
28
|
+
*/
|
|
29
|
+
export function CxCheckbox({
|
|
30
|
+
checked,
|
|
31
|
+
onChange,
|
|
32
|
+
disabled = false,
|
|
33
|
+
className,
|
|
34
|
+
size = 'md',
|
|
35
|
+
'aria-label': ariaLabel,
|
|
36
|
+
}: CxCheckboxProps) {
|
|
37
|
+
return (
|
|
38
|
+
<button
|
|
39
|
+
type="button"
|
|
40
|
+
role="checkbox"
|
|
41
|
+
aria-checked={checked}
|
|
42
|
+
aria-label={ariaLabel}
|
|
43
|
+
disabled={disabled}
|
|
44
|
+
onClick={(e) => {
|
|
45
|
+
e.stopPropagation()
|
|
46
|
+
if (disabled) return
|
|
47
|
+
onChange?.(!checked, e)
|
|
48
|
+
}}
|
|
49
|
+
className={clsx(
|
|
50
|
+
'flex shrink-0 items-center justify-center rounded-md border transition-all outline-none',
|
|
51
|
+
'focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-1 focus-visible:ring-offset-white dark:focus-visible:ring-offset-gray-900',
|
|
52
|
+
sizeClass[size],
|
|
53
|
+
checked
|
|
54
|
+
? 'border-blue-600 bg-blue-600 shadow-md shadow-blue-500/20'
|
|
55
|
+
: 'border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-900',
|
|
56
|
+
disabled && 'cursor-not-allowed opacity-50',
|
|
57
|
+
className,
|
|
58
|
+
)}>
|
|
59
|
+
{checked && (
|
|
60
|
+
<svg
|
|
61
|
+
className={clsx(iconSizeClass[size], 'text-white')}
|
|
62
|
+
fill="none"
|
|
63
|
+
viewBox="0 0 24 24"
|
|
64
|
+
stroke="currentColor"
|
|
65
|
+
aria-hidden>
|
|
66
|
+
<path
|
|
67
|
+
strokeLinecap="round"
|
|
68
|
+
strokeLinejoin="round"
|
|
69
|
+
strokeWidth={3.5}
|
|
70
|
+
d="M5 13l4 4L19 7"
|
|
71
|
+
/>
|
|
72
|
+
</svg>
|
|
73
|
+
)}
|
|
74
|
+
</button>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default CxCheckbox
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.cx-date-picker {
|
|
2
|
+
border-radius: 8px;
|
|
3
|
+
|
|
4
|
+
&.cx-date-picker--cxForm {
|
|
5
|
+
min-height: 42px;
|
|
6
|
+
height: 42px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
&.cx-date-picker--cxSearch {
|
|
10
|
+
min-height: 40px;
|
|
11
|
+
height: 40px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.ant-picker-input > input {
|
|
15
|
+
font-size: inherit;
|
|
16
|
+
}
|
|
17
|
+
}
|