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,20 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Form } from 'antd'
|
|
3
|
+
import type { FormProps } from 'antd'
|
|
4
|
+
import { CxFormContext, type CxFormRulesMap } from './CxForm'
|
|
5
|
+
|
|
6
|
+
type Props = Omit<FormProps, 'children'> & {
|
|
7
|
+
children?: React.ReactNode
|
|
8
|
+
rules?: CxFormRulesMap
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function CxForm(props: Props) {
|
|
12
|
+
const { rules, children, ...formProps } = props
|
|
13
|
+
return (
|
|
14
|
+
<CxFormContext.Provider value={{ rules }}>
|
|
15
|
+
<Form {...formProps}>{children}</Form>
|
|
16
|
+
</CxFormContext.Provider>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type { CxFormRulesMap }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.cx-form-item {
|
|
2
|
+
.ant-form-item-control-input {
|
|
3
|
+
min-height: 42px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.ant-form-item-control-input-content {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
/* 上层 overflow:hidden(如宽屏角色弹窗)时避免裁切加粗边框与焦点 ring */
|
|
10
|
+
padding: 2px;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.ant-form-horizontal .cx-form-item {
|
|
15
|
+
.ant-form-item-row {
|
|
16
|
+
align-items: center;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.ant-form-item-label > label {
|
|
20
|
+
min-height: 42px;
|
|
21
|
+
display: inline-flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
line-height: 1.2;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Form } from 'antd'
|
|
3
|
+
import type { FormItemProps } from 'antd'
|
|
4
|
+
import type { Rule } from 'antd/es/form'
|
|
5
|
+
import { useCxFormRules } from '../form/CxForm'
|
|
6
|
+
import './index.less'
|
|
7
|
+
|
|
8
|
+
type NameType = FormItemProps['name']
|
|
9
|
+
|
|
10
|
+
function pickRuleKey(name: NameType, ruleKey?: string): string | undefined {
|
|
11
|
+
if (ruleKey) return ruleKey
|
|
12
|
+
if (typeof name === 'string') return name
|
|
13
|
+
return undefined
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type Props = FormItemProps & {
|
|
17
|
+
/** 规则键;不传则尝试用 name(string) 作为键 */
|
|
18
|
+
ruleKey?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function CxFormItem({ ruleKey, rules, name, ...props }: Props) {
|
|
22
|
+
const rulesMap = useCxFormRules()
|
|
23
|
+
const key = pickRuleKey(name, ruleKey)
|
|
24
|
+
const autoRules = key ? (rulesMap?.[key] as Rule[] | undefined) : undefined
|
|
25
|
+
const mergedClassName = ['cx-form-item', props.className].filter(Boolean).join(' ')
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Form.Item
|
|
29
|
+
{...props}
|
|
30
|
+
className={mergedClassName}
|
|
31
|
+
name={name}
|
|
32
|
+
rules={rules ?? autoRules}
|
|
33
|
+
/>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import './styles/index.less'
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
CxButton,
|
|
5
|
+
CxButtonAdd,
|
|
6
|
+
CxButtonCancel,
|
|
7
|
+
CxButtonDelete,
|
|
8
|
+
CxButtonDownload,
|
|
9
|
+
CxButtonEdit,
|
|
10
|
+
CxButtonExport,
|
|
11
|
+
CxButtonIcon,
|
|
12
|
+
CxButtonIconDelete,
|
|
13
|
+
CxButtonIconDisable,
|
|
14
|
+
CxButtonIconDownload,
|
|
15
|
+
CxButtonIconEdit,
|
|
16
|
+
CxButtonIconEnable, CxButtonIconExport, CxButtonIconSetDefault, CxButtonIconView,
|
|
17
|
+
CxButtonOk,
|
|
18
|
+
CxButtonSave,
|
|
19
|
+
CxButtonSecondary,
|
|
20
|
+
CxButtonSubmit,
|
|
21
|
+
CxButtonView
|
|
22
|
+
} from './button'
|
|
23
|
+
export { CxCheckbox } from './checkbox'
|
|
24
|
+
export type { CxCheckboxProps } from './checkbox'
|
|
25
|
+
export { default as CxDatePicker } from './date-picker'
|
|
26
|
+
export type { CxDatePickerProps } from './date-picker'
|
|
27
|
+
export { default as CxDrawer } from './drawer'
|
|
28
|
+
export { CxEmptyState } from './empty-state'
|
|
29
|
+
export type { CxEmptyStateProps } from './empty-state'
|
|
30
|
+
export { default as CxForm } from './form'
|
|
31
|
+
export type { CxFormRulesMap } from './form'
|
|
32
|
+
export { default as CxFormItem } from './form-item'
|
|
33
|
+
export { CxFormContext, useCxFormRules } from './form/CxForm'
|
|
34
|
+
export { default as CxInput } from './input'
|
|
35
|
+
export type { CxInputAutoCompleteProps, CxInputProps } from './input'
|
|
36
|
+
export { default as CxInputNumber } from './input-number'
|
|
37
|
+
export { default as CxModal, useCxModal } from './modal'
|
|
38
|
+
export { default as CxMultiSelect } from './multi-select'
|
|
39
|
+
export { default as CxRadio } from './radio'
|
|
40
|
+
export type { CxRadioOption, CxRadioProps } from './radio'
|
|
41
|
+
export { default as CxRangePicker } from './range-picker'
|
|
42
|
+
export type { CxRangePickerProps } from './range-picker'
|
|
43
|
+
export { default as CxSelect } from './select'
|
|
44
|
+
export type { CxSelectProps } from './select'
|
|
45
|
+
export { CxSteps } from './steps'
|
|
46
|
+
export type { CxStepsProps } from './steps'
|
|
47
|
+
export { CxTimeline } from './timeline'
|
|
48
|
+
export type { CxTimelineProps } from './timeline'
|
|
49
|
+
export { CxSkeleton } from './skeleton'
|
|
50
|
+
export type { CxSkeletonProps } from './skeleton'
|
|
51
|
+
export { default as CxSwitch } from './switch'
|
|
52
|
+
export type { CxSwitchProps, CxSwitchVariant } from './switch'
|
|
53
|
+
export { default as CxTable } from './table'
|
|
54
|
+
export type { CxTableProps } from './table'
|
|
55
|
+
export { CxTabs } from './tabs'
|
|
56
|
+
export type { CxTabsProps } from './tabs'
|
|
57
|
+
export { CxTag } from './tag'
|
|
58
|
+
export type { CxTagProps } from './tag'
|
|
59
|
+
export { CxTooltip } from './tooltip'
|
|
60
|
+
export type { CxTooltipProps, CxTooltipTone } from './tooltip'
|
|
61
|
+
export { CxTree } from './tree'
|
|
62
|
+
export type {
|
|
63
|
+
CxTreeFieldNames,
|
|
64
|
+
CxTreeProps,
|
|
65
|
+
CxTreeSameNodeReselect
|
|
66
|
+
} from './tree'
|
|
67
|
+
export { default as CxTreeSelect } from './tree-select'
|
|
68
|
+
export { default as UploadFile } from './upload-file'
|
|
69
|
+
export { default as UploadImg } from './upload-img'
|
|
70
|
+
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { AutoCompleteProps } from 'antd'
|
|
2
|
+
import { AutoComplete, Input } from 'antd'
|
|
3
|
+
import { clsx } from 'clsx'
|
|
4
|
+
import { ChevronDown } from 'lucide-react'
|
|
5
|
+
import { useCallback, useState } from 'react'
|
|
6
|
+
|
|
7
|
+
export type CxInputAutoCompleteProps = Omit<AutoCompleteProps, 'children'> & {
|
|
8
|
+
/** 与 CxInput small/middle 对齐,默认 small(表格内紧凑) */
|
|
9
|
+
size?: 'small' | 'middle' | 'large'
|
|
10
|
+
/** 透传到内部 antd Input */
|
|
11
|
+
inputClassName?: string
|
|
12
|
+
/**
|
|
13
|
+
* 是否在输入框**内侧**展示下拉箭头(与 Select 后缀一致);默认 true。
|
|
14
|
+
* 为 false 时仅靠焦点展开,无箭头。
|
|
15
|
+
*/
|
|
16
|
+
showDropdownArrow?: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 与 CxInput 默认行高一致:primitive 未写 style 时为 42;CxInputMedium=40;CxInputLarge=42。
|
|
21
|
+
* (若需 32px 紧凑行请使用 CxInput.Small,本组件暂无对应档,可后续加 `compact`)
|
|
22
|
+
*/
|
|
23
|
+
const inputHeights = { small: 42, middle: 40, large: 42 } as const
|
|
24
|
+
|
|
25
|
+
/** AutoComplete 底层是 Select,去掉 selector 壳层多余 min-height/padding,避免比同行 CxInput 高或矮一截 */
|
|
26
|
+
const autocompleteSelectShellClass =
|
|
27
|
+
'[&_.ant-select-selector]:!min-h-0 [&_.ant-select-selector]:!h-full [&_.ant-select-selector]:border-0 [&_.ant-select-selector]:bg-transparent [&_.ant-select-selector]:p-0 [&_.ant-select-selector]:shadow-none'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 与 CxInput 同系样式的可输入下拉(antd AutoComplete + 统一样式)。
|
|
31
|
+
* - 下拉展开时默认展示**全部**候选项(不按当前输入过滤);仍可手输列表外的类型如 VARCHAR(100)
|
|
32
|
+
* - 需要按输入过滤时可传入 `filterOption`
|
|
33
|
+
* - 获得焦点时展开;箭头在输入框内作后缀,点击可切换展开(mousedown 防失焦)
|
|
34
|
+
*/
|
|
35
|
+
export function CxInputAutoComplete({
|
|
36
|
+
size = 'small',
|
|
37
|
+
className,
|
|
38
|
+
inputClassName,
|
|
39
|
+
style,
|
|
40
|
+
open: openProp,
|
|
41
|
+
onOpenChange,
|
|
42
|
+
onFocus,
|
|
43
|
+
filterOption,
|
|
44
|
+
suffixIcon: _suffixIcon,
|
|
45
|
+
showDropdownArrow = true,
|
|
46
|
+
disabled,
|
|
47
|
+
...rest
|
|
48
|
+
}: CxInputAutoCompleteProps) {
|
|
49
|
+
const [internalOpen, setInternalOpen] = useState(false)
|
|
50
|
+
const mergedOpen = openProp ?? internalOpen
|
|
51
|
+
|
|
52
|
+
const handleOpenChange = useCallback(
|
|
53
|
+
(next: boolean) => {
|
|
54
|
+
if (openProp === undefined) {
|
|
55
|
+
setInternalOpen(next)
|
|
56
|
+
}
|
|
57
|
+
onOpenChange?.(next)
|
|
58
|
+
},
|
|
59
|
+
[openProp, onOpenChange],
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
const h = inputHeights[size] ?? inputHeights.small
|
|
63
|
+
|
|
64
|
+
const inputSuffix =
|
|
65
|
+
showDropdownArrow === false ? undefined : (
|
|
66
|
+
<span
|
|
67
|
+
role="button"
|
|
68
|
+
tabIndex={-1}
|
|
69
|
+
aria-label="toggle options"
|
|
70
|
+
className="flex cursor-pointer items-center text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300"
|
|
71
|
+
onMouseDown={(e) => {
|
|
72
|
+
e.preventDefault()
|
|
73
|
+
e.stopPropagation()
|
|
74
|
+
if (!disabled) {
|
|
75
|
+
handleOpenChange(!mergedOpen)
|
|
76
|
+
}
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<ChevronDown size={14} strokeWidth={2} aria-hidden />
|
|
80
|
+
</span>
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
/** 默认 false:展开下列表为全量候选项,避免“只剩与当前输入匹配的几项” */
|
|
84
|
+
const mergedFilter = filterOption !== undefined ? filterOption : false
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<AutoComplete
|
|
88
|
+
{...rest}
|
|
89
|
+
disabled={disabled}
|
|
90
|
+
open={mergedOpen}
|
|
91
|
+
onOpenChange={handleOpenChange}
|
|
92
|
+
filterOption={mergedFilter}
|
|
93
|
+
popupMatchSelectWidth={rest.popupMatchSelectWidth ?? false}
|
|
94
|
+
className={clsx(
|
|
95
|
+
'cx-input-autocomplete w-full min-w-0',
|
|
96
|
+
autocompleteSelectShellClass,
|
|
97
|
+
className,
|
|
98
|
+
)}
|
|
99
|
+
style={{
|
|
100
|
+
width: '100%',
|
|
101
|
+
height: h,
|
|
102
|
+
minHeight: h,
|
|
103
|
+
...style,
|
|
104
|
+
}}
|
|
105
|
+
suffixIcon={null}
|
|
106
|
+
>
|
|
107
|
+
<Input
|
|
108
|
+
size={size}
|
|
109
|
+
disabled={disabled}
|
|
110
|
+
className={clsx('cx-input min-w-0', inputClassName)}
|
|
111
|
+
rootClassName="cx-input-root"
|
|
112
|
+
suffix={inputSuffix}
|
|
113
|
+
styles={{
|
|
114
|
+
root: {
|
|
115
|
+
boxSizing: 'border-box',
|
|
116
|
+
minHeight: h,
|
|
117
|
+
height: h,
|
|
118
|
+
borderRadius: 8,
|
|
119
|
+
},
|
|
120
|
+
}}
|
|
121
|
+
style={{
|
|
122
|
+
boxSizing: 'border-box',
|
|
123
|
+
borderRadius: 8,
|
|
124
|
+
height: h,
|
|
125
|
+
minHeight: h,
|
|
126
|
+
}}
|
|
127
|
+
onFocus={(e) => {
|
|
128
|
+
handleOpenChange(true)
|
|
129
|
+
onFocus?.(e)
|
|
130
|
+
}}
|
|
131
|
+
/>
|
|
132
|
+
</AutoComplete>
|
|
133
|
+
)
|
|
134
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import type { GetProps } from 'antd'
|
|
2
|
+
import { Input, Space } from 'antd'
|
|
3
|
+
import clsx from 'clsx'
|
|
4
|
+
import React, { useMemo } from 'react'
|
|
5
|
+
|
|
6
|
+
import { CxInputAutoComplete } from './auto-complete'
|
|
7
|
+
import { CxFloatingShell } from '../floating-shell/CxFloatingShell'
|
|
8
|
+
import { hasCxFloatingValue } from '../floating-shell/has-floating-value'
|
|
9
|
+
|
|
10
|
+
type TextAreaProps = GetProps<typeof Input.TextArea>
|
|
11
|
+
type AntInputProps = GetProps<typeof Input>
|
|
12
|
+
type InputStyles = NonNullable<AntInputProps['styles']>
|
|
13
|
+
|
|
14
|
+
type CxInputOwn = {
|
|
15
|
+
cxFloatingLabel?: React.ReactNode
|
|
16
|
+
cxFocusPlaceholder?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type CxInputProps =
|
|
20
|
+
| (Omit<AntInputProps, 'variant'> & CxInputOwn)
|
|
21
|
+
| (TextAreaProps & CxInputOwn & { type: 'textarea' })
|
|
22
|
+
|
|
23
|
+
type CxInputTextProps = Omit<AntInputProps, 'variant'> & CxInputOwn
|
|
24
|
+
|
|
25
|
+
/** CxInput 基础组件:统一 Input / TextArea 与浮动标签能力。 */
|
|
26
|
+
const CxInputPrimitive: React.FC<CxInputProps> = (props) => {
|
|
27
|
+
const {
|
|
28
|
+
style = undefined,
|
|
29
|
+
cxFloatingLabel,
|
|
30
|
+
cxFocusPlaceholder,
|
|
31
|
+
placeholder,
|
|
32
|
+
value,
|
|
33
|
+
onFocus,
|
|
34
|
+
onBlur,
|
|
35
|
+
disabled,
|
|
36
|
+
className,
|
|
37
|
+
rootClassName: rootClassNameProp,
|
|
38
|
+
addonBefore,
|
|
39
|
+
addonAfter,
|
|
40
|
+
styles: stylesProp,
|
|
41
|
+
size,
|
|
42
|
+
...rest
|
|
43
|
+
} = props as AntInputProps & CxInputOwn
|
|
44
|
+
|
|
45
|
+
const resolveHeight = () => {
|
|
46
|
+
const h = (style && typeof style === 'object' ? (style as any).height : undefined) ??
|
|
47
|
+
((props as any).style && typeof (props as any).style === 'object' ? (props as any).style.height : undefined)
|
|
48
|
+
if (typeof h === 'number') return h
|
|
49
|
+
if (size === 'small') return 32
|
|
50
|
+
if (size === 'middle') return 40
|
|
51
|
+
return 42
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** 根据高度推导浮动壳的布局类型:40 及以下按搜索区,其他按表单区。 */
|
|
55
|
+
const shellVariant: 'cxForm' | 'cxSearch' = resolveHeight() <= 40 ? 'cxSearch' : 'cxForm'
|
|
56
|
+
|
|
57
|
+
const height = resolveHeight()
|
|
58
|
+
const hasAddon = addonBefore != null || addonAfter != null
|
|
59
|
+
const mergedStyles = useMemo((): InputStyles | undefined => {
|
|
60
|
+
if (!hasAddon) return stylesProp
|
|
61
|
+
const box = {
|
|
62
|
+
height,
|
|
63
|
+
minHeight: height,
|
|
64
|
+
boxSizing: 'border-box' as const,
|
|
65
|
+
}
|
|
66
|
+
const base = (stylesProp ?? {}) as InputStyles & { input?: Record<string, unknown> }
|
|
67
|
+
return {
|
|
68
|
+
...base,
|
|
69
|
+
input: { ...box, ...(base.input ?? {}) },
|
|
70
|
+
} as InputStyles
|
|
71
|
+
}, [hasAddon, height, stylesProp])
|
|
72
|
+
const isTextarea = (rest as AntInputProps).type === 'textarea'
|
|
73
|
+
|
|
74
|
+
if (isTextarea) {
|
|
75
|
+
const { type, ...restProps } = rest as AntInputProps & { type?: string }
|
|
76
|
+
return (
|
|
77
|
+
<CxInputTextarea
|
|
78
|
+
{...(restProps as unknown as TextAreaProps)}
|
|
79
|
+
rootClassName={rootClassNameProp}
|
|
80
|
+
className={className}
|
|
81
|
+
style={style}
|
|
82
|
+
/>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const useFloat =
|
|
87
|
+
cxFloatingLabel != null &&
|
|
88
|
+
cxFloatingLabel !== false &&
|
|
89
|
+
String(cxFloatingLabel).trim() !== ''
|
|
90
|
+
|
|
91
|
+
const hasValue = useMemo(
|
|
92
|
+
() => hasCxFloatingValue(value, 'default'),
|
|
93
|
+
[value],
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
const inputStyle: React.CSSProperties = {
|
|
97
|
+
boxSizing: 'border-box',
|
|
98
|
+
/* addon 时样式在 Input.Group 根上,圆角会破坏与 addon 的拼接,交给 antd */
|
|
99
|
+
...(!hasAddon ? { borderRadius: 8 } : {}),
|
|
100
|
+
...(useFloat
|
|
101
|
+
? { minHeight: 49 }
|
|
102
|
+
: hasAddon
|
|
103
|
+
? { minHeight: height }
|
|
104
|
+
: { height }),
|
|
105
|
+
...(style && typeof style === 'object' ? style : {}),
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const isPassword = (rest as AntInputProps).type === 'password'
|
|
109
|
+
|
|
110
|
+
if (isPassword) {
|
|
111
|
+
const { type, ...restProps } = rest as AntInputProps & { type?: string }
|
|
112
|
+
return (
|
|
113
|
+
<Input.Password
|
|
114
|
+
{...(restProps as any)}
|
|
115
|
+
size={size}
|
|
116
|
+
rootClassName={clsx('cx-input-root', rootClassNameProp)}
|
|
117
|
+
disabled={disabled}
|
|
118
|
+
value={value}
|
|
119
|
+
className={clsx('cx-input', className)}
|
|
120
|
+
style={inputStyle}
|
|
121
|
+
styles={mergedStyles}
|
|
122
|
+
placeholder={useFloat ? undefined : placeholder}
|
|
123
|
+
onBlur={onBlur}
|
|
124
|
+
onFocus={onFocus}
|
|
125
|
+
/>
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const inputEl = (
|
|
130
|
+
addonBefore != null || addonAfter != null ? (
|
|
131
|
+
<Space.Compact style={{ width: '100%' }}>
|
|
132
|
+
{addonBefore}
|
|
133
|
+
<Input
|
|
134
|
+
{...(rest as AntInputProps)}
|
|
135
|
+
size={size}
|
|
136
|
+
rootClassName={clsx('cx-input-root', rootClassNameProp)}
|
|
137
|
+
disabled={disabled}
|
|
138
|
+
value={value}
|
|
139
|
+
className={clsx('cx-input', className)}
|
|
140
|
+
style={inputStyle}
|
|
141
|
+
styles={mergedStyles}
|
|
142
|
+
placeholder={useFloat ? undefined : placeholder}
|
|
143
|
+
onBlur={onBlur}
|
|
144
|
+
onFocus={onFocus}
|
|
145
|
+
/>
|
|
146
|
+
{addonAfter}
|
|
147
|
+
</Space.Compact>
|
|
148
|
+
) : (
|
|
149
|
+
<Input
|
|
150
|
+
{...(rest as AntInputProps)}
|
|
151
|
+
size={size}
|
|
152
|
+
rootClassName={clsx('cx-input-root', rootClassNameProp)}
|
|
153
|
+
disabled={disabled}
|
|
154
|
+
value={value}
|
|
155
|
+
className={clsx('cx-input', className)}
|
|
156
|
+
style={inputStyle}
|
|
157
|
+
styles={mergedStyles}
|
|
158
|
+
placeholder={useFloat ? undefined : placeholder}
|
|
159
|
+
onBlur={onBlur}
|
|
160
|
+
onFocus={onFocus}
|
|
161
|
+
/>
|
|
162
|
+
)
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
if (!useFloat) {
|
|
166
|
+
return inputEl
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
<CxFloatingShell
|
|
171
|
+
disabled={disabled}
|
|
172
|
+
focusPlaceholder={cxFocusPlaceholder ?? placeholder}
|
|
173
|
+
hasValue={hasValue}
|
|
174
|
+
label={cxFloatingLabel}
|
|
175
|
+
variant={shellVariant}
|
|
176
|
+
>
|
|
177
|
+
{inputEl}
|
|
178
|
+
</CxFloatingShell>
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Large:42px,高度偏表单主输入。 */
|
|
183
|
+
export function CxInputLarge(props: CxInputTextProps): React.ReactElement
|
|
184
|
+
export function CxInputLarge(props: CxInputProps) {
|
|
185
|
+
return (
|
|
186
|
+
<CxInputPrimitive
|
|
187
|
+
{...(props as any)}
|
|
188
|
+
style={{ ...(props as any)?.style, height: 42, minHeight: 42 }}
|
|
189
|
+
/>
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Medium:40px,高度偏搜索区输入。 */
|
|
194
|
+
export function CxInputMedium(props: CxInputTextProps): React.ReactElement
|
|
195
|
+
export function CxInputMedium(props: CxInputProps) {
|
|
196
|
+
return (
|
|
197
|
+
<CxInputPrimitive
|
|
198
|
+
{...(props as any)}
|
|
199
|
+
style={{ ...(props as any)?.style, height: 40, minHeight: 40 }}
|
|
200
|
+
/>
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Small:32px,更紧凑。 */
|
|
205
|
+
export function CxInputSmall(props: CxInputTextProps): React.ReactElement
|
|
206
|
+
export function CxInputSmall(props: CxInputProps) {
|
|
207
|
+
return (
|
|
208
|
+
<CxInputPrimitive
|
|
209
|
+
{...(props as any)}
|
|
210
|
+
style={{ ...(props as any)?.style, height: 32, minHeight: 32 }}
|
|
211
|
+
/>
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** Float:第 4 种类型,浮动标签输入(使用 CxFloatingShell)。 */
|
|
216
|
+
export function CxInputFloat(props: CxInputTextProps): React.ReactElement
|
|
217
|
+
export function CxInputFloat(props: CxInputTextProps) {
|
|
218
|
+
const hasLabel =
|
|
219
|
+
(props as any)?.cxFloatingLabel != null &&
|
|
220
|
+
(props as any)?.cxFloatingLabel !== false &&
|
|
221
|
+
String((props as any)?.cxFloatingLabel).trim() !== ''
|
|
222
|
+
return (
|
|
223
|
+
<CxInputPrimitive
|
|
224
|
+
{...(props as any)}
|
|
225
|
+
cxFloatingLabel={
|
|
226
|
+
hasLabel ? (props as any)?.cxFloatingLabel : (props as any)?.placeholder
|
|
227
|
+
}
|
|
228
|
+
/>
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** Textarea:第 5 种类型,独立文本域输入。 */
|
|
233
|
+
export function CxInputTextarea(props: TextAreaProps & CxInputOwn) {
|
|
234
|
+
const { style, className, rootClassName, ...rest } = props as any
|
|
235
|
+
return (
|
|
236
|
+
<Input.TextArea
|
|
237
|
+
{...(rest as TextAreaProps)}
|
|
238
|
+
rootClassName={clsx('cx-input-root', rootClassName)}
|
|
239
|
+
className={clsx('cx-input', 'cx-input--textarea', className)}
|
|
240
|
+
style={{
|
|
241
|
+
boxSizing: 'border-box',
|
|
242
|
+
borderRadius: 8,
|
|
243
|
+
...(style && typeof style === 'object' ? style : {}),
|
|
244
|
+
}}
|
|
245
|
+
/>
|
|
246
|
+
)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const ExportedCxInput = Object.assign(CxInputPrimitive, {
|
|
250
|
+
Large: CxInputLarge,
|
|
251
|
+
Medium: CxInputMedium,
|
|
252
|
+
Small: CxInputSmall,
|
|
253
|
+
Float: CxInputFloat,
|
|
254
|
+
Textarea: CxInputTextarea,
|
|
255
|
+
AutoComplete: CxInputAutoComplete,
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
export type { CxInputAutoCompleteProps } from './auto-complete'
|
|
259
|
+
export default ExportedCxInput
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import clsx from 'clsx'
|
|
3
|
+
import { InputNumber } from 'antd'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 基础数字输入框:用于统一 cx-ui 样式与高度。
|
|
7
|
+
* @param {import('antd').InputNumberProps & { height?: number, rootClassName?: string }} props
|
|
8
|
+
*/
|
|
9
|
+
function CxInputNumberPrimitive({
|
|
10
|
+
height,
|
|
11
|
+
style = undefined,
|
|
12
|
+
rootClassName,
|
|
13
|
+
className,
|
|
14
|
+
...props
|
|
15
|
+
}) {
|
|
16
|
+
const resolvedHeight = height ?? 42
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<InputNumber
|
|
20
|
+
{...props}
|
|
21
|
+
rootClassName={clsx('cx-input-number-root', rootClassName)}
|
|
22
|
+
className={['cx-input-number', className].filter(Boolean).join(' ')}
|
|
23
|
+
style={{
|
|
24
|
+
height: resolvedHeight,
|
|
25
|
+
width: style?.width ?? props.style?.width ?? '100%',
|
|
26
|
+
boxSizing: 'border-box',
|
|
27
|
+
borderRadius: 8,
|
|
28
|
+
...(props.style || {}),
|
|
29
|
+
...(style || {}),
|
|
30
|
+
}}
|
|
31
|
+
/>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* cxForm 场景数字输入框:高度 42px。
|
|
37
|
+
* @param {import('antd').InputNumberProps} props
|
|
38
|
+
*/
|
|
39
|
+
export function CxInputNumberLarge(props) {
|
|
40
|
+
return <CxInputNumberPrimitive {...props} height={42} />
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* cxSearch 场景数字输入框:高度 40px。
|
|
45
|
+
* @param {import('antd').InputNumberProps} props
|
|
46
|
+
*/
|
|
47
|
+
export function CxInputNumberMedium(props) {
|
|
48
|
+
return <CxInputNumberPrimitive {...props} height={40} />
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* small 场景数字输入框:高度 32px。
|
|
53
|
+
* @param {import('antd').InputNumberProps} props
|
|
54
|
+
*/
|
|
55
|
+
export function CxInputNumberSmall(props) {
|
|
56
|
+
return <CxInputNumberPrimitive {...props} height={32} />
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const ExportedCxInputNumber = Object.assign(CxInputNumberPrimitive, {
|
|
60
|
+
Large: CxInputNumberLarge,
|
|
61
|
+
Medium: CxInputNumberMedium,
|
|
62
|
+
Small: CxInputNumberSmall,
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
export default ExportedCxInputNumber
|
|
66
|
+
|