From 6d94ea9ca944302a4bb4c37a1272a9ecf87bd067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2?= Date: Mon, 14 Aug 2023 13:34:23 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"feat:=20=E8=A1=A5=E5=85=85=20prefixCl?= =?UTF-8?q?s=20=E9=80=BB=E8=BE=91=20(#11)"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit e88e9df32a8d29c4ce3a65facad1cde24a3fc21b. --- CHANGELOG.md | 6 - examples/with-antd4/src/App.tsx | 19 +-- examples/with-antd5/src/App.tsx | 19 +-- package.json | 3 +- pnpm-lock.yaml | 36 +++- src/drag-modal/BaseModal.tsx | 21 +-- src/drawer/index.tsx | 4 +- src/hooks/useBoolean.ts | 2 +- src/hooks/usePrefixCls.ts | 23 --- src/mobile/Mask.tsx | 2 +- src/modal/index.tsx | 11 +- tests/__snapshots__/drag-modal.test.tsx.snap | 104 ------------ tests/__snapshots__/drawer.test.tsx.snap | 105 ------------ tests/__snapshots__/index.test.tsx.snap | 159 ------------------ .../index.with_antd4.test.tsx.snap | 159 ------------------ .../__snapshots__/mask.test.tsx.snap | 9 - tests/antd-mobile/dialog.test.tsx | 41 ----- tests/antd-mobile/index.test.tsx | 19 --- tests/antd-mobile/mask.test.tsx | 71 -------- tests/antd-mobile/modal.test.tsx | 41 ----- tests/antd-mobile/popup.test.tsx | 41 ----- tests/drag-modal.test.tsx | 44 ----- tests/drawer.test.tsx | 87 ---------- tests/hooks/useBoolean.test.tsx | 44 ----- tests/hooks/usePrefixCls.test.tsx | 14 -- tests/hooks/usePrefixCls.with_antd4.test.tsx | 21 --- tests/index.test.tsx | 81 +-------- tests/index.with_antd4.test.tsx | 30 ---- 28 files changed, 46 insertions(+), 1170 deletions(-) delete mode 100644 src/hooks/usePrefixCls.ts delete mode 100644 tests/__snapshots__/drag-modal.test.tsx.snap delete mode 100644 tests/__snapshots__/drawer.test.tsx.snap delete mode 100644 tests/__snapshots__/index.test.tsx.snap delete mode 100644 tests/__snapshots__/index.with_antd4.test.tsx.snap delete mode 100644 tests/antd-mobile/__snapshots__/mask.test.tsx.snap delete mode 100644 tests/antd-mobile/dialog.test.tsx delete mode 100644 tests/antd-mobile/index.test.tsx delete mode 100644 tests/antd-mobile/mask.test.tsx delete mode 100644 tests/antd-mobile/modal.test.tsx delete mode 100644 tests/antd-mobile/popup.test.tsx delete mode 100644 tests/drag-modal.test.tsx delete mode 100644 tests/drawer.test.tsx delete mode 100644 tests/hooks/useBoolean.test.tsx delete mode 100644 tests/hooks/usePrefixCls.test.tsx delete mode 100644 tests/hooks/usePrefixCls.with_antd4.test.tsx delete mode 100644 tests/index.with_antd4.test.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index c9c6ae7..7e8692c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,3 @@ -# [1.4.0-beta.1](https://github.com/Wxh16144/easy-antd-modal/compare/v1.3.0...v1.4.0-beta.1) (2023-08-14) - -### Features - -- 补充 prefixCls 逻辑 ([#10](https://github.com/Wxh16144/easy-antd-modal/issues/10)) ([287bfde](https://github.com/Wxh16144/easy-antd-modal/commit/287bfdede391840b3b85d3987667724fa9d29e0f)) - # [1.3.0](https://github.com/Wxh16144/easy-antd-modal/compare/v1.2.1...v1.3.0) (2023-08-11) ### Features diff --git a/examples/with-antd4/src/App.tsx b/examples/with-antd4/src/App.tsx index 4c7a4e1..9b9cfb0 100644 --- a/examples/with-antd4/src/App.tsx +++ b/examples/with-antd4/src/App.tsx @@ -1,26 +1,11 @@ import { Button, Typography, version } from 'antd'; -import { DragModal, Drawer, Modal } from 'easy-antd-modal'; +import Modal from 'easy-antd-modal'; export default () => ( <> antd version: {version} - - Modal}> + Click Me}> I ❤️ antd - -
-
- - Drawer}> - I ❤️ antd - - -
-
- - DragModal}> - I ❤️ antd - ); diff --git a/examples/with-antd5/src/App.tsx b/examples/with-antd5/src/App.tsx index 4c7a4e1..9b9cfb0 100644 --- a/examples/with-antd5/src/App.tsx +++ b/examples/with-antd5/src/App.tsx @@ -1,26 +1,11 @@ import { Button, Typography, version } from 'antd'; -import { DragModal, Drawer, Modal } from 'easy-antd-modal'; +import Modal from 'easy-antd-modal'; export default () => ( <> antd version: {version} - - Modal}> + Click Me}> I ❤️ antd - -
-
- - Drawer}> - I ❤️ antd - - -
-
- - DragModal}> - I ❤️ antd - ); diff --git a/package.json b/package.json index ab4e565..04aad2e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "easy-antd-modal", - "version": "1.4.0-beta.1", + "version": "1.3.0", "description": "二次开发, 简化 Ant Design Modal 的使用方式", "keywords": [ "antd", @@ -104,7 +104,6 @@ "@types/testing-library__jest-dom": "^5", "@umijs/lint": "^4", "@vitest/coverage-v8": "latest", - "antd4": "npm:antd@4", "commitlint": "^17", "concurrently": "^7", "cross-env": "^7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5daa5b7..c3bf99c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,9 +57,6 @@ importers: '@vitest/coverage-v8': specifier: latest version: 0.34.1(vitest@0.34.1) - antd4: - specifier: npm:antd@4 - version: /antd@4.24.13(react-dom@18.2.0)(react@18.2.0) commitlint: specifier: ^17 version: 17.6.7 @@ -236,6 +233,7 @@ packages: resolution: {integrity: sha512-qAZRvPzfdWHtfameEGP2Qvuf838NhergR35o+EuVyB5XvSA98xod5r4utvi4TJ3ywmevm290g9nsCG5MryrdWQ==} dependencies: '@ctrl/tinycolor': 3.6.0 + dev: false /@ant-design/colors@7.0.0: resolution: {integrity: sha512-iVm/9PfGCbC0dSMBrz7oiEXZaaGH7ceU40OJEfKmyuzR9R5CRimJYPlRiFtMQGQcbNMea/ePcoIebi4ASGYXtg==} @@ -275,6 +273,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /@ant-design/icons@5.2.5(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-9Jc59v5fl5dzmxqLWtRev3dJwU7Ya9ZheoI6XmZjZiQ7PRtk77rC+Rbt7GJzAPPg43RQ4YO53RE1u8n+Et97vQ==} @@ -5460,6 +5459,7 @@ packages: react: 18.2.0 react-dom: 18.2.0(react@18.2.0) scroll-into-view-if-needed: 2.2.31 + dev: false /antd@5.8.2(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-kkC2BSBde1JzJxk2wNYj/NXgNZQZ2yu6avJoCKleSi32nsjiadi7FFu1AyGxIzoJ9CrxoLacjGvrwbKJQ6kCvw==} @@ -6641,6 +6641,7 @@ packages: /compute-scroll-into-view@1.0.20: resolution: {integrity: sha512-UCB0ioiyj8CRjtrvaceBLqqhZCVP+1B8+NWQhmdsm0VXOJtobBCf1dBQmebCCo34qZmUwZfIH2MZLqNHazrfjg==} + dev: false /compute-scroll-into-view@3.0.3: resolution: {integrity: sha512-nadqwNxghAGTamwIqQSG433W6OADZx2vCo3UXHNrzTRHK/htu+7+L0zhjEoaeaQVNAi3YgqWDv8+tzf0hRfR+A==} @@ -11745,6 +11746,7 @@ packages: /moment@2.29.4: resolution: {integrity: sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==} + dev: false /moo@0.5.2: resolution: {integrity: sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==} @@ -13577,6 +13579,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-checkbox@3.0.1(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-k7nxDWxYF+jDI0ZcCvuvj71xONmWRVe5+1MKcERRR9MRyP3tZ69b+yUCSXXh+sik4/Hc9P5wHr2nnUoGS2zBjA==} @@ -13589,6 +13592,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-checkbox@3.1.0(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-PAwpJFnBa3Ei+5pyqMMXdcKYKNBMS+TvSDiLdDnARnMJHC8ESxwPfm4Ao1gJiKtWLdmGfigascnCpwrHFgoOBQ==} @@ -13615,6 +13619,7 @@ packages: react: 18.2.0 react-dom: 18.2.0(react@18.2.0) shallowequal: 1.1.0 + dev: false /rc-collapse@3.7.1(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-N/7ejyiTf3XElNJBBpxqnZBUuMsQWEOPjB2QkfNvZ/Ca54eAvJXuOD1EGbCWCk2m7v/MSxku7mRpdeaLOCd4Gg==} @@ -13642,6 +13647,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-dialog@9.1.0(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-5ry+JABAWEbaKyYsmITtrJbZbJys8CtMyzV8Xn4LYuXMeUx5XVHNyJRoqLFE4AzBuXXzOWeaC49cg+XkxK6kHA==} @@ -13684,6 +13690,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-dropdown@4.0.1(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-OdpXuOcme1rm45cR0Jzgfl1otzmU4vuBVb+etXM8vcaULGokAKVpKlw8p6xzspG7jGd/XxShvq+N3VNEfk/l5g==} @@ -13697,6 +13704,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-dropdown@4.1.0(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-VZjMunpBdlVzYpEdJSaV7WM7O0jf8uyDjirxXLZRNZ+tAC+NzD3PXPEtliFwGzVwBBdCmGuSqiS9DWcOLxQ9tw==} @@ -13737,6 +13745,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-field-form@1.36.2(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-tCF/JjUsnxW80Gk4E4ZH74ONsaQMxVTRtui6XhQB8DJc4FHWLLa5pP8zwhxtPKC5NaO0QZ0Cv79JggDubn6n2g==} @@ -13777,6 +13786,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-image@7.1.3(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-foMl1rcit1F0+vgxE5kf0c8TygQcHhILsOohQUL+JMUbzOo3OBFRcehJudYbqbCTArzCecS8nA1irUU9vvgQbg==} @@ -13804,6 +13814,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-input-number@8.0.4(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-TP+G5b7mZtbwXJ/YEZXF/OgbEZ6iqD4+RSuxZJ8VGKGXDcdt0FKIvpFoNQr/knspdFC4OxA0OfsWfFWfN4XSyA==} @@ -13830,6 +13841,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-input@1.1.1(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-NTR1Z4em681L8/ewb2KR80RykSmN8I2mzqzJDCoUmTrV1BB9Hk5d7ha4TnfgdEPPL148N+603sW2LExSXk1IbA==} @@ -13857,6 +13869,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-mentions@2.5.0(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-rERXsbUTNVrb5T/iDC0ki/SRGWJnOVraDy6O25Us3FSpuUZ3uq2TPZB4fRk0Hss5kyiEPzz2sprhkI4b+F4jUw==} @@ -13919,6 +13932,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-motion@2.7.3(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-2xUvo8yGHdOHeQbdI8BtBsCIrWKchEmFEIskf0nmHtJsou+meLd/JE+vnvSX2JxcBrJtXY2LuBpxAOxrbY/wMQ==} @@ -13945,6 +13959,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-notification@5.0.5(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-uEz2jggourwv/rR0obe7RHEa63UchqX4k+e+Qt2c3LaY7U9Tc+L6ANhzgCKYSA/afm0ebjmNZHoB5Cv47xEOcA==} @@ -13983,6 +13998,7 @@ packages: classnames: 2.3.2 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-pagination@3.5.0(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-lUBVtVVUn7gGsq4mTyVpcZQr+AMcljbMiL/HcCmSdFrcsK0iZVKwwbXDxhz2IV0JXUs9Hzepr5sQFaF+9ad/pQ==} @@ -14013,6 +14029,7 @@ packages: react: 18.2.0 react-dom: 18.2.0(react@18.2.0) shallowequal: 1.1.0 + dev: false /rc-picker@3.12.0(dayjs@1.11.9)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-SsEhK4hbjAh3pvlqujIQaMcx6mLAwc0KN0TS9dJ0rtwGuUnSDa/mKgna/LjZlOT7U//b+dIH5BLSZttpklRG9A==} @@ -14079,6 +14096,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-resize-observer@1.3.1(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-iFUdt3NNhflbY3mwySv5CA1TC06zdJ+pfo0oc27xpf4PIOvfZwZGtD9Kz41wGYqC4SLio93RVAirSSpYlV/uYg==} @@ -14105,6 +14123,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-segmented@2.2.2(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-Mq52M96QdHMsNdE/042ibT5vkcGcD5jxKp7HgPC2SRofpia99P5fkfHy1pEaajLMF/kj0+2Lkq1UZRvqzo9mSA==} @@ -14135,6 +14154,7 @@ packages: rc-virtual-list: 3.5.3(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-select@14.7.3(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-s0SQ6voafPXRYLSmHtB8GrkMJsXi2xS5vigzeaRDEgzHyj6xb2omUTinP7nrTCkBveEzrfy7eV/OillDzmcFTw==} @@ -14166,6 +14186,7 @@ packages: react: 18.2.0 react-dom: 18.2.0(react@18.2.0) shallowequal: 1.1.0 + dev: false /rc-slider@10.1.1(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-gn8oXazZISEhnmRinI89Z/JD/joAaM35jp+gDtIVSTD/JJMCCBqThqLk1SVJmvtfeiEF/kKaFY0+qt4SDHFUDw==} @@ -14192,6 +14213,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-steps@6.0.1(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-lKHL+Sny0SeHkQKKDJlAjV5oZ8DwCdS2hFhAkIjuQt1/pB81M0cA0ErVFdHq9+jmPmFw1vJB2F5NBzFXLJxV+g==} @@ -14217,6 +14239,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-switch@4.1.0(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-TI8ufP2Az9oEbvyCeVE4+90PDSljGyuwix3fV58p7HV2o4wBnVToEyomJRVyTaZeqNPAp+vqeo4Wnj5u0ZZQBg==} @@ -14244,6 +14267,7 @@ packages: react: 18.2.0 react-dom: 18.2.0(react@18.2.0) shallowequal: 1.1.0 + dev: false /rc-table@7.32.1(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-fHMQteKMocUC9I9Vex3eBLH7QsiaMR/qtzh3B1Ty2PoNGwVTwVdDFyRL05zch+JU3KnNNczgQeVvtf/p//gdrQ==} @@ -14294,6 +14318,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-tabs@12.9.0(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-2HnVowgMVrq0DfQtyu4mCd9E6pXlWNdM6VaDvOOHMsLYqPmpY+7zBqUC6YrrQ9xYXHciTS0e7TtjOHIvpVCHLQ==} @@ -14325,6 +14350,7 @@ packages: react: 18.2.0 react-dom: 18.2.0(react@18.2.0) shallowequal: 1.1.0 + dev: false /rc-textarea@1.3.4(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-wn0YjTpvcVolcfXa0HtzL+jgV2QcwtfB29RwNAKj8hMgZOju1V24M3TfEDjABeQEAQbUGbjMbISREOX/YSVKhg==} @@ -14351,6 +14377,7 @@ packages: rc-trigger: 5.3.4(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-tooltip@6.0.1(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-MdvPlsD1fDSxKp9+HjXrc/CxLmA/s11QYIh1R7aExxfodKP7CZA++DG1AjrW80F8IUdHYcR43HAm0Y2BYPelHA==} @@ -14391,6 +14418,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-tree@5.7.9(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-1hKkToz/EVjJlMVwmZnpXeLXt/1iQMsaAq9m+GNkUbK746gkc7QpJXSN/TzjhTI5Hi+LOSlrMaXLMT0bHPqILQ==} @@ -14421,6 +14449,7 @@ packages: rc-util: 5.36.0(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: false /rc-upload@4.3.4(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-uVbtHFGNjHG/RyAfm9fluXB6pvArAGyAx8z7XzXXyorEgVIWj6mOlriuDm0XowDHYz4ycNK0nE0oP3cbFnzxiQ==} @@ -15288,6 +15317,7 @@ packages: resolution: {integrity: sha512-dGCXy99wZQivjmjIqihaBQNjryrz5rueJY7eHfTdyWEiR4ttYpsajb14rn9s5d4DY4EcY6+4+U/maARBXJedkA==} dependencies: compute-scroll-into-view: 1.0.20 + dev: false /scroll-into-view-if-needed@3.0.10: resolution: {integrity: sha512-t44QCeDKAPf1mtQH3fYpWz8IM/DyvHLjs8wUvvwMYxk5moOqCzrMSxK6HQVD0QVmVjXFavoFIPRVrMuJPKAvtg==} diff --git a/src/drag-modal/BaseModal.tsx b/src/drag-modal/BaseModal.tsx index f5f4900..b5b2d60 100644 --- a/src/drag-modal/BaseModal.tsx +++ b/src/drag-modal/BaseModal.tsx @@ -1,7 +1,6 @@ import { useDraggable } from '@dnd-kit/core'; import { CSS } from '@dnd-kit/utilities'; import type { DragModalProps } from '.'; -import usePrefixCls from '../hooks/usePrefixCls'; import Modal from '../modal'; export interface BaseModalProps extends DragModalProps { @@ -10,10 +9,7 @@ export interface BaseModalProps extends DragModalProps { } function BaseModal(props: BaseModalProps) { - const { modalRender, title, offsetX, offsetY, className, ...resetProps } = props; - - const prefixCls = usePrefixCls('drag-modal', props.prefixCls); - + const { modalRender, title, offsetX, offsetY, ...resetProps } = props; const { attributes, isDragging, listeners, setNodeRef, transform } = useDraggable({ id: 'easy-antd-modal-draggable-modal', }); @@ -27,31 +23,20 @@ function BaseModal(props: BaseModalProps) { top: offsetY, left: offsetX, }} - className={`${prefixCls}-content__wrapper`} > {modalRender?.(rawNode) ?? rawNode} ); - // Compliance with BEM norms - const modalCls = [className, isDragging && `${prefixCls}_dragging`].filter(Boolean).join(' '); - return ( +
{title}
} modalRender={mergeModalRender} + {...resetProps} /> ); } diff --git a/src/drawer/index.tsx b/src/drawer/index.tsx index 21dcfc7..1b44b50 100644 --- a/src/drawer/index.tsx +++ b/src/drawer/index.tsx @@ -1,12 +1,10 @@ import type { DrawerProps as AntdDrawerProps } from 'antd'; import { Drawer as AntdDrawer } from 'antd'; import { UseModalEnhancedProps, useModalEnhanced } from '../hooks'; -import usePrefixCls from '../hooks/usePrefixCls'; export type DrawerProps = Omit & UseModalEnhancedProps; const Modal = (props: DrawerProps) => { - const prefixCls = usePrefixCls('drawer', props.prefixCls); const [visible, { close }, { trigger, content }, restProps] = useModalEnhanced(props); const handleModalCancel: DrawerProps['onClose'] = (event) => { @@ -17,7 +15,7 @@ const Modal = (props: DrawerProps) => { return ( <> {trigger} - + {content} diff --git a/src/hooks/useBoolean.ts b/src/hooks/useBoolean.ts index 59824bd..a7a1f13 100644 --- a/src/hooks/useBoolean.ts +++ b/src/hooks/useBoolean.ts @@ -7,7 +7,7 @@ export interface Actions { } export default function useBoolean(defaultValue = false): [boolean, Actions] { - const [state, setState] = React.useState(!!defaultValue); + const [state, setState] = React.useState(defaultValue); const actions: Actions = React.useMemo(() => { const setTrue = () => setState(true); diff --git a/src/hooks/usePrefixCls.ts b/src/hooks/usePrefixCls.ts deleted file mode 100644 index 0bb5915..0000000 --- a/src/hooks/usePrefixCls.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ConfigProvider as AntdConfigProvider, version } from 'antd'; -import * as React from 'react'; - -/** @@Internal 仅仅用于内部组件开发 */ -function usePrefixCls(suffixCls: string, customPrefixCls?: string): string { - const { getPrefixCls } = React.useContext(AntdConfigProvider.ConfigContext); - - if (customPrefixCls) { - return customPrefixCls; - } - - /** - * 5.x 版本的 antd 会自动加上 easy- 前缀, 可以和 antd 的样式区分开。 - * 4.x 使用的是 less,不是很好处理,直接复用 antd 的样式即可。可以在稳定后直接删除对 4.x 的支持。 - * 二次开发约定 xxx-(antd 的组件 cls 逻辑), 所以处理 4.x 时可以直接 pop() 获取最后一个即可。 - */ - const _prefixCls = version.startsWith('5') ? 'easy-' : ''; - let _suffixCls = version.startsWith('5') ? suffixCls : suffixCls.split('-').pop() ?? ''; - - return `${_prefixCls}${getPrefixCls()}-${_suffixCls}`; -} - -export default usePrefixCls; diff --git a/src/mobile/Mask.tsx b/src/mobile/Mask.tsx index d3d0cdb..3ffd49f 100644 --- a/src/mobile/Mask.tsx +++ b/src/mobile/Mask.tsx @@ -12,7 +12,7 @@ function Mask(props: MaskProps) { }; const handleMaskClose: AntdMMaskProps['afterClose'] = () => { - props.afterClose?.(); + props?.afterClose?.(); close(); }; diff --git a/src/modal/index.tsx b/src/modal/index.tsx index dfffea9..1503ad7 100644 --- a/src/modal/index.tsx +++ b/src/modal/index.tsx @@ -1,13 +1,10 @@ import type { ModalProps as AntdModalProps } from 'antd'; import { Modal as AntdModal } from 'antd'; import { UseModalEnhancedProps, useModalEnhanced } from '../hooks'; -import usePrefixCls from '../hooks/usePrefixCls'; export type ModalProps = Omit & UseModalEnhancedProps; const Modal = (props: ModalProps) => { - const prefixCls = usePrefixCls('modal', props.prefixCls); - const [visible, { close }, { trigger, content }, restProps] = useModalEnhanced(props); const handleModalOk: ModalProps['onOk'] = (event) => { @@ -23,13 +20,7 @@ const Modal = (props: ModalProps) => { return ( <> {trigger} - + {content} diff --git a/tests/__snapshots__/drag-modal.test.tsx.snap b/tests/__snapshots__/drag-modal.test.tsx.snap deleted file mode 100644 index 4ebbe8d..0000000 --- a/tests/__snapshots__/drag-modal.test.tsx.snap +++ /dev/null @@ -1,104 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`DragModal > DragModal 组件可以正常渲染 1`] = ` -