diff --git a/.dumirc.ts b/.dumirc.ts index d2eb325b2..025f2f3a0 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -144,6 +144,7 @@ export default defineConfig({ children: [ { title: 'Card 卡片', link: '/components/card' }, { title: 'Descriptions 描述列表', link: '/components/descriptions' }, + { title: 'Empty 空状态', link: '/components/empty' }, { title: 'List 列表', link: '/components/list' }, { title: 'Table 表格', link: '/components/table' }, { title: 'Tabs 标签页', link: '/components/tabs' }, @@ -163,6 +164,7 @@ export default defineConfig({ { title: 'Modal 对话框', link: '/components/modal' }, { title: 'Drawer 抽屉', link: '/components/drawer' }, { title: 'Notification 通知提醒框', link: '/components/notification' }, + { title: 'Result 结果', link: '/components/result' }, { title: 'Spin 加载中', link: '/components/spin' }, { title: 'Badge 徽标数', link: '/components/badge' }, ], @@ -178,6 +180,7 @@ export default defineConfig({ children: [ { title: 'BasicLayout 导航和布局', link: '/biz-components/basic-layout' }, { title: 'PageContainer 页容器', link: '/biz-components/page-container' }, + { title: 'PageLoading 页面级加载', link: '/biz-components/page-loading' }, { title: 'FooterToolbar 底部操作栏', link: '/biz-components/footer-toolbar' }, { title: 'Login 登录页', link: '/biz-components/login' }, // { title: 'NavMenu', link: '/biz-components/nav-menu' }, diff --git a/.eslintrc.js b/.eslintrc.js index be3b7027b..332637438 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -14,6 +14,7 @@ module.exports = { 'no-unused-expressions': 'off', 'jsx-a11y/mouse-events-have-key-events': 'off', 'react/require-default-props': 'off', + 'react/self-closing-comp': 'off', 'no-shadow': 'off', '@typescript-eslint/no-use-before-define': 'off', 'global-require': 'warn', diff --git a/.prettierignore b/.prettierignore index 706a4f5dd..efdff7ad7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -15,4 +15,5 @@ dist /server /public __testfixtures__ +packages/design/src/spin/assets diff --git a/docs/codemod/codemod-CHANGELOG.md b/docs/codemod/codemod-CHANGELOG.md index 16afed1de..75b7b7d30 100644 --- a/docs/codemod/codemod-CHANGELOG.md +++ b/docs/codemod/codemod-CHANGELOG.md @@ -8,6 +8,18 @@ group: 自动化迁移工具 --- +## 0.3.0 + +`2024-03-22` + +- ⭐️ 支持更多颜色值到 Design Token 的自动改写。[#511](https://github.com/oceanbase/oceanbase-design/pull/511) [#519](https://github.com/oceanbase/oceanbase-design/pull/519) + - `rgb(250,250,250)` => `colorBgLayout` + - `rgb(255 255 255 / 100%)` => `colorBgContainer` + - `rgb(0 0 0 / 85%)` => `colorText` + - `rgb(0 0 0 / 65%)` => `colorTextSecondary` + - `rgb(0 0 0 / 45%)` => `colorTextTertiary` + - `rgb(0 0 0 / 25%)` => `colorTextQuaternary` + ## 0.2.10 `2023-11-09` diff --git a/docs/design/design-CHANGELOG.md b/docs/design/design-CHANGELOG.md index 1501208ea..ab29ccc95 100644 --- a/docs/design/design-CHANGELOG.md +++ b/docs/design/design-CHANGELOG.md @@ -8,6 +8,31 @@ group: 基础组件 --- +## 0.3.0 + +`2024-03-22` + +- ⭐️ 去掉所有组件的重置样式,避免被 Tooltip、Popover、Space、Dropdown 等组件包裹时字体大小、颜色被覆盖。[#450](https://github.com/oceanbase/oceanbase-design/pull/450) +- ⭐️ 组件的样式加载顺序改为 -900,保证自定义样式的优先级高于 antd。[#464](https://github.com/oceanbase/oceanbase-design/pull/464) +- 🌈 更新中性色板,包括 Design Token 以及 less 主题变量。[#484](https://github.com/oceanbase/oceanbase-design/pull/484) +- 🔥 新版 Empty 组件 [#465](https://github.com/oceanbase/oceanbase-design/pull/465) + - 💄 定制插图、主题和样式,以符合 OceanBase Design 设计规范。 + - 🆕 新增 `title` 属性,用于设置空状态标题。 + - 🆕 新增 `steps` 属性,用于设置步骤引导。 + - 🆕 新增 `layout` 属性,用于设置空状态布局,默认为 vertical。 + - 🆕 通过 ConfigProvider `renderEmpty` 定制全局组件的空状态。[#467](https://github.com/oceanbase/oceanbase-design/pull/467) +- 🔥 新版 Result 组件 [#476](https://github.com/oceanbase/oceanbase-design/pull/476) + - 💄 定制插图、主题和样式,以符合 OceanBase Design 设计规范。 + - 🆕 `status` 属性新增 `processing` 枚举值,用于设置进行中的状态。 +- Spin + - 💄 更新 Spin 的加载动画,包括灰色和彩色动画。[#512](https://github.com/oceanbase/oceanbase-design/pull/512) + - 💄 Spin 的默认加载指示符从彩色动画改为灰色动画。[#491](https://github.com/oceanbase/oceanbase-design/pull/491) +- Table + - 🐞 修复 Table 的 loading 动画没有水平和垂直居中的问题。[#518](https://github.com/oceanbase/oceanbase-design/pull/518) + - 💄 Table 处于 `loading` 时隐藏空状态。[#518](https://github.com/oceanbase/oceanbase-design/pull/518) +- 💄 优化 Badge default 状态的颜色,并更新 default 状态和 warning 状态的图标。[#500](https://github.com/oceanbase/oceanbase-design/pull/500) +- [Icon] 🆕 新增 `EllipsisCircleFilled` 图标。[#499](https://github.com/oceanbase/oceanbase-design/pull/499) + ## 0.2.37 `2024-01-30` diff --git a/docs/ui/ui-CHANGELOG.md b/docs/ui/ui-CHANGELOG.md index 22936df76..c97ad4aac 100644 --- a/docs/ui/ui-CHANGELOG.md +++ b/docs/ui/ui-CHANGELOG.md @@ -8,6 +8,14 @@ group: 业务组件 --- +## 0.3.0 + +`2024-03-22` + +- 🆕 新增 PageLoading 页面级加载组件。[#497](https://github.com/oceanbase/oceanbase-design/pull/497) +- 🐞 修复 Password 部分英文文案不正确的问题。[#469](https://github.com/oceanbase/oceanbase-design/pull/469) +- 💄 优化 PageContainer 加载样式,保证页面内垂直居中。[#497](https://github.com/oceanbase/oceanbase-design/pull/497) + ## 0.2.38 `2024-01-30` diff --git a/jest.config.ts b/jest.config.ts deleted file mode 100644 index 846e9fd64..000000000 --- a/jest.config.ts +++ /dev/null @@ -1,28 +0,0 @@ -const { readdirSync } = require('fs'); -const { join } = require('path'); - -const pkgList = readdirSync(join(__dirname, './packages')).filter( - (pkg: string) => pkg.charAt(0) !== '.' -); - -const moduleNameMapper = { - '^react$': require.resolve('react'), - '^.+\\.svg$': require.resolve('jest-svg-transformer'), - '\\.(css|less|sass|scss)$': require.resolve('identity-obj-proxy'), -}; - -pkgList.forEach((shortName: string) => { - const name = `@oceanbase/${shortName}`; - moduleNameMapper[name] = join(__dirname, `./packages/${shortName}/src`); -}); - -module.exports = { - testEnvironment: 'jsdom', - transform: { - '^.+\\.(ts|tsx)?$': 'ts-jest', - '^.+\\.(js|jsx)?$': 'babel-jest', - }, - transformIgnorePatterns: [`/node_modules/(?!${[].join('|')})`], - moduleNameMapper, - setupFilesAfterEnv: ['./tests/setupTests.ts'], -}; diff --git a/package.json b/package.json index 330cddefa..c2a970d07 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,9 @@ "site:deploy": "gh-pages -d site", "postpublish": "npm run sync:other-npm", "sync:other-npm": "node -e 'require(\"./scripts/sync-cnpm-and-tnpm\")()'", - "test": "NODE_OPTIONS=--max_old_space_size=4096 cross-env TZ=UTC jest", - "test:coverage": "NODE_OPTIONS=--max_old_space_size=4096 cross-env TZ=UTC TEST_LOG=none jest --coverage", - "test:update": "NODE_OPTIONS=--max_old_space_size=4096 cross-env TZ=UTC jest --updateSnapshot", + "test": "cross-env vitest", + "test:coverage": "cross-env TEST_LOG=none vitest --coverage", + "test:update": "cross-env vitest -u", "lint": "eslint --cache --ext .js,.jsx,.ts,.tsx", "lint:fix": "eslint --cache --ext .js,.jsx,.ts,.tsx --fix --format=pretty", "prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,less,md,json}\"", @@ -42,86 +42,79 @@ }, "devDependencies": { "@ant-design/colors": "^7.0.2", - "@ant-design/cssinjs": "^1.17.2", - "@ant-design/icons": "^5.2.6", - "@babel/cli": "^7.23.0", - "@babel/preset-env": "^7.23.6", + "@ant-design/cssinjs": "^1.18.4", + "@ant-design/icons": "^5.3.4", + "@babel/cli": "^7.23.9", + "@babel/preset-env": "^7.24.0", "@chenshuai2144/less2cssinjs": "^1.0.7", - "@ctrl/tinycolor": "^4.0.2", + "@ctrl/tinycolor": "^4.0.3", "@emotion/babel-preset-css-prop": "^11.11.0", "@emotion/css": "^11.11.2", - "@emotion/react": "^11.11.3", + "@emotion/react": "^11.11.4", "@emotion/server": "^11.11.0", - "@qixian.cs/github-contributors-list": "^1.1.0", - "@rc-component/trigger": "^1.18.2", + "@qixian.cs/github-contributors-list": "^2.0.1", + "@rc-component/trigger": "^2.0.0", "@stackblitz/sdk": "^1.9.0", - "@testing-library/dom": "^9.3.3", - "@testing-library/jest-dom": "^6.2.0", - "@testing-library/react": "^14.1.0", + "@testing-library/dom": "^9.3.4", + "@testing-library/jest-dom": "^6.4.2", + "@testing-library/react": "^14.2.1", "@testing-library/react-hooks": "^8.0.1", "@testing-library/user-event": "^14.5.2", - "@types/jest": "^29.5.10", "@types/lodash": "^4.14.202", - "@types/node": "^20.10.5", - "@types/react": "^18.2.47", + "@types/node": "^20.11.25", + "@types/react": "^18.2.64", "@umijs/fabric": "^4.0.1", - "@umijs/test": "^4.1.0", - "@vercel/analytics": "^1.1.1", - "antd": "^5.13.2", - "antd-style": "3.5.2", - "antd-token-previewer": "^2.0.5", + "@umijs/test": "^4.1.2", + "@vercel/analytics": "^1.2.2", + "antd": "^5.15.3", + "antd-style": "^3.6.1", + "antd-token-previewer": "^2.0.8", "babel-jest": "^29.7.0", "classnames": "^2.5.1", "copy-to-clipboard": "^3.3.3", "cross-env": "^7.0.3", "dayjs": "^1.11.10", - "dumi": "^2.2.16", - "eslint-plugin-jest": "^27.6.1", + "dumi": "^2.2.17", + "eslint-plugin-jest": "^27.9.0", "execa": "^5.1.1", - "father": "^4.3.8", + "father": "^4.4.0", "fs-extra": "^11.2.0", - "gh-pages": "^6.1.0", + "gh-pages": "^6.1.1", "glob": "^10.3.10", "html2sketch": "^1.0.2", - "husky": "^8.0.3", + "husky": "^9.0.11", "identity-obj-proxy": "^3.0.0", "isomorphic-fetch": "^3.0.0", - "jest": "^29.7.0", - "jest-canvas-mock": "^2.5.2", "jest-environment-jsdom": "^29.7.0", - "jest-fetch-mock": "^3.0.3", - "jest-svg-transformer": "^1.0.0", "jsonml-to-react-element": "^1.1.11", "jsonml.js": "^0.1.0", - "lerna": "^8.0.0", - "lint-staged": "^15.2.0", + "lerna": "^8.1.2", + "lint-staged": "^15.2.2", "lodash": "^4.17.21", - "lz-string": "^1.5.0", "mockdate": "^3.0.5", - "prettier": "^3.2.4", + "prettier": "^3.2.5", "prismjs": "^1.29.0", - "rc-checkbox": "^3.1.0", - "rc-drawer": "^7.0.0", + "rc-checkbox": "^3.2.0", + "rc-drawer": "^7.1.0", "rc-footer": "^0.6.8", "rc-resize-observer": "^1.4.0", - "rc-segmented": "^2.2.2", - "rc-tabs": "^12.13.1", - "rc-util": "^5.38.1", + "rc-segmented": "^2.3.0", + "rc-tabs": "^14.1.1", + "rc-util": "^5.39.1", "react": "^18.2.0", "react-color": "^2.19.3", "react-copy-to-clipboard": "^5.1.0", "react-dom": "^18.2.0", - "react-fast-marquee": "^1.6.2", - "react-intl": "^6.5.1", - "react-router-dom": "^6.19.0", - "runscript": "^1.5.3", - "svg-jest": "^1.0.1", - "sylvanas": "^0.6.1", - "ts-jest": "^29.1.1", - "ts-node": "^10.9.1", - "typescript": "^5.3.3", - "vanilla-jsoneditor": "^0.21.2", - "web-vitals": "^3.5.0", - "yorkie": "^2.0.0" + "react-fast-marquee": "^1.6.4", + "react-intl": "^6.6.2", + "react-router-dom": "^6.22.3", + "runscript": "^1.6.0", + "ts-node": "^10.9.2", + "typescript": "^5.4.2", + "vanilla-jsoneditor": "^0.23.0", + "vitest": "^1.4.0", + "vitest-canvas-mock": "^0.3.3", + "vitest-fetch-mock": "^0.2.2", + "web-vitals": "^3.5.2" } } diff --git a/packages/charts/package.json b/packages/charts/package.json index cd66b6fa6..5e0cdeba7 100644 --- a/packages/charts/package.json +++ b/packages/charts/package.json @@ -27,7 +27,7 @@ "build": "NODE_OPTIONS=--max_old_space_size=4096 father build" }, "dependencies": { - "@ant-design/charts": "^1.4.2", + "@ant-design/charts": "^1.4.3", "@oceanbase/util": "workspace:^", "classnames": "^2.5.1", "lodash": "^4.17.21", diff --git a/packages/charts/src/Area/__tests__/__snapshots__/ref.test.tsx.snap b/packages/charts/src/Area/__tests__/__snapshots__/ref.test.tsx.snap deleted file mode 100644 index 5594283d9..000000000 --- a/packages/charts/src/Area/__tests__/__snapshots__/ref.test.tsx.snap +++ /dev/null @@ -1,26 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Area ref ref 1`] = ` -
-
- -
- - -`; diff --git a/packages/charts/src/DualAxes/__tests__/__snapshots__/ref.test.tsx.snap b/packages/charts/src/DualAxes/__tests__/__snapshots__/ref.test.tsx.snap deleted file mode 100644 index 62365b71f..000000000 --- a/packages/charts/src/DualAxes/__tests__/__snapshots__/ref.test.tsx.snap +++ /dev/null @@ -1,26 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`DualAxes ref ref 1`] = ` -
-
- -
- - -`; diff --git a/packages/charts/src/Line/__tests__/__snapshots__/ref.test.tsx.snap b/packages/charts/src/Line/__tests__/__snapshots__/ref.test.tsx.snap deleted file mode 100644 index 472492495..000000000 --- a/packages/charts/src/Line/__tests__/__snapshots__/ref.test.tsx.snap +++ /dev/null @@ -1,26 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Line ref ref 1`] = ` -
-
- -
- - -`; diff --git a/packages/charts/src/Pie/__tests__/__snapshots__/donut.test.tsx.snap b/packages/charts/src/Pie/__tests__/__snapshots__/donut.test.tsx.snap deleted file mode 100644 index 43467c8ae..000000000 --- a/packages/charts/src/Pie/__tests__/__snapshots__/donut.test.tsx.snap +++ /dev/null @@ -1,91 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`donut floor number 1`] = ` -
-
- -
-
- 总数 -
-
-
-
- 21.16 -
-
-
- - -`; - -exports[`donut statistic title and content formatter 1`] = ` -
-
- -
-
- custom title -
-
-
-
- custom content -
-
-
- - -`; diff --git a/packages/charts/vitest.config.ts b/packages/charts/vitest.config.ts new file mode 100644 index 000000000..132a51652 --- /dev/null +++ b/packages/charts/vitest.config.ts @@ -0,0 +1,4 @@ +import { defineProject, mergeConfig } from 'vitest/config'; +import configShared from '../../vitest.config'; + +export default mergeConfig(configShared, defineProject({})); diff --git a/packages/codemod/package.json b/packages/codemod/package.json index 4d499a429..c243f7885 100644 --- a/packages/codemod/package.json +++ b/packages/codemod/package.json @@ -32,16 +32,16 @@ "is-git-clean": "^1.1.0", "jscodeshift": "^0.15.1", "lodash": "^4.17.21", - "postcss": "^8.4.33", + "postcss": "^8.4.35", "postcss-less": "^6.0.0", - "prettier": "^3.2.4", + "prettier": "^3.2.5", "read-pkg-up": "^10.1.0", - "semver": "^7.5.4", + "semver": "^7.6.0", "update-check": "^1.5.4", "yargs-parser": "^21.1.1" }, "devDependencies": { - "@types/jest": "^29.5.10", + "@types/jest": "^29.5.12", "@types/jscodeshift": "^0.11.11", "enzyme": "^3.11.0", "enzyme-to-json": "^3.6.2" diff --git a/packages/codemod/transforms/__testfixtures__/less-to-token/obui-less-to-token.input.less b/packages/codemod/transforms/__testfixtures__/less-to-token/obui-less-to-token.input.less index ed6154ea1..efae1404e 100644 --- a/packages/codemod/transforms/__testfixtures__/less-to-token/obui-less-to-token.input.less +++ b/packages/codemod/transforms/__testfixtures__/less-to-token/obui-less-to-token.input.less @@ -9,6 +9,7 @@ color: rgba(0, 0, 0, 0.85); background: rgba(0, 0, 0,0.65); background-color: rgba(0,0,0,0.45); + border-color: rgb(0 0 0 / 45%); border: 1px solid #d9d9d9; } } diff --git a/packages/codemod/transforms/__testfixtures__/less-to-token/obui-less-to-token.output.less b/packages/codemod/transforms/__testfixtures__/less-to-token/obui-less-to-token.output.less index 4f25e105d..d251a182c 100644 --- a/packages/codemod/transforms/__testfixtures__/less-to-token/obui-less-to-token.output.less +++ b/packages/codemod/transforms/__testfixtures__/less-to-token/obui-less-to-token.output.less @@ -8,6 +8,7 @@ color: @colorText; background: @colorTextSecondary; background-color: @colorTextTertiary; + border-color: @colorTextTertiary; border: 1px solid @colorBorder; } } diff --git a/packages/codemod/transforms/__testfixtures__/style-to-token/function-component.input.js b/packages/codemod/transforms/__testfixtures__/style-to-token/function-component.input.js index 20667df8f..6062812e1 100644 --- a/packages/codemod/transforms/__testfixtures__/style-to-token/function-component.input.js +++ b/packages/codemod/transforms/__testfixtures__/style-to-token/function-component.input.js @@ -2,6 +2,7 @@ import React from 'react'; import { Alert, Button, Tooltip } from '@oceanbase/design'; const Demo = () => { + const tokenList = ['rgb(0 0 0 / 45%)']; return (
diff --git a/packages/codemod/transforms/__testfixtures__/style-to-token/function-component.output.js b/packages/codemod/transforms/__testfixtures__/style-to-token/function-component.output.js index ca71b9162..ca8969939 100644 --- a/packages/codemod/transforms/__testfixtures__/style-to-token/function-component.output.js +++ b/packages/codemod/transforms/__testfixtures__/style-to-token/function-component.output.js @@ -3,6 +3,7 @@ import { Alert, Button, theme, Tooltip } from '@oceanbase/design'; const Demo = () => { const { token } = theme.useToken(); + const tokenList = [token.colorTextTertiary]; return ( (
diff --git a/packages/codemod/transforms/__tests__/token.test.ts b/packages/codemod/transforms/__tests__/token.test.ts index c4e86e78b..831609e0f 100644 --- a/packages/codemod/transforms/__tests__/token.test.ts +++ b/packages/codemod/transforms/__tests__/token.test.ts @@ -5,7 +5,7 @@ describe('token', () => { expect(TOKEN_MAP_KEYS.every(key => isLower(key))).toEqual(true); }); - it('TOKEN_MAP_KEYS should not include blank space', async () => { - expect(TOKEN_MAP_KEYS.every(key => !key.includes(' '))).toEqual(true); + it('TOKEN_MAP_KEYS should not include `, `', async () => { + expect(TOKEN_MAP_KEYS.every(key => !key.includes(', '))).toEqual(true); }); }); diff --git a/packages/codemod/transforms/utils/token.js b/packages/codemod/transforms/utils/token.js index b38ed3b27..9d423569c 100644 --- a/packages/codemod/transforms/utils/token.js +++ b/packages/codemod/transforms/utils/token.js @@ -27,8 +27,10 @@ const TOKEN_MAP = { '#f0f2f5': 'colorBgLayout', '#fafafa': 'colorBgLayout', '#f7f8fc': 'colorBgLayout', + 'rgb(250,250,250)': 'colorBgLayout', '#ffffff': 'colorBgContainer', '#fff': 'colorBgContainer', + 'rgb(255 255 255 / 100%)': 'colorBgContainer', 'rgba(0,0,0,0.85)': 'colorText', 'rgba(0,0,0,0.65)': 'colorTextSecondary', 'rgba(0,0,0,0.45)': 'colorTextTertiary', @@ -39,6 +41,10 @@ const TOKEN_MAP = { 'rgba(0,0,0,.45)': 'colorTextTertiary', 'rgba(0,0,0,.25)': 'colorTextQuaternary', 'rgba(0,0,0,0.2)': 'colorFillQuaternary', + 'rgb(0 0 0 / 85%)': 'colorText', + 'rgb(0 0 0 / 65%)': 'colorTextSecondary', + 'rgb(0 0 0 / 45%)': 'colorTextTertiary', + 'rgb(0 0 0 / 25%)': 'colorTextQuaternary', '#00000073': 'colorTextDescription', '#f5f5f5': 'colorFillQuaternary', 'rgba(0,0,0,0.02)': 'colorBgLayout', diff --git a/packages/codemod/vitest.config.ts b/packages/codemod/vitest.config.ts new file mode 100644 index 000000000..132a51652 --- /dev/null +++ b/packages/codemod/vitest.config.ts @@ -0,0 +1,4 @@ +import { defineProject, mergeConfig } from 'vitest/config'; +import configShared from '../../vitest.config'; + +export default mergeConfig(configShared, defineProject({})); diff --git a/packages/design/package.json b/packages/design/package.json index 3de8f941e..715a367bf 100644 --- a/packages/design/package.json +++ b/packages/design/package.json @@ -35,11 +35,11 @@ "postbuild": "cp src/style/reset.css dist/" }, "dependencies": { - "@ant-design/cssinjs": "^1.17.2", + "@ant-design/cssinjs": "^1.18.4", "@oceanbase/icons": "workspace:^", "@oceanbase/util": "workspace:^", "ahooks": "^2.10.14", - "antd": "^5.13.2", + "antd": "^5.15.3", "classnames": "^2.5.1", "lodash": "^4.17.21", "lottie-web": "^5.12.2", @@ -48,11 +48,11 @@ "react-sticky-mouse-tooltip": "^0.0.1" }, "devDependencies": { - "@babel/cli": "^7.23.0", - "@babel/preset-env": "^7.23.6", + "@babel/cli": "^7.23.9", + "@babel/preset-env": "^7.23.9", "antd-token-previewer": "^2.0.5", - "rc-select": "^14.10.0", - "rc-table": "^7.35.2" + "rc-select": "^14.11.0", + "rc-table": "^7.40.0" }, "peerDependencies": { "react": ">=16.9.0", diff --git a/packages/design/src/_util/genComponentStyleHook.ts b/packages/design/src/_util/genComponentStyleHook.ts index c629522ff..f32a1c847 100644 --- a/packages/design/src/_util/genComponentStyleHook.ts +++ b/packages/design/src/_util/genComponentStyleHook.ts @@ -22,7 +22,14 @@ export function genComponentStyleHook( token => { return [styleFn(token)]; }, - getDefaultToken + getDefaultToken, + { + resetStyle: false, + // antd style order is -999 and -998 + // ref: https://github.com/ant-design/ant-design/blob/master/components/theme/util/genComponentStyleHook.tsx#L175 + // obui style order should behind to cover it + order: -900, + } ); const [wrapSSR] = useStyle(prefixCls); // use hashId from useToken, as hashId is '' when hashed is false diff --git a/packages/design/src/badge/__tests__/__snapshots__/index.test.tsx.snap b/packages/design/src/badge/__tests__/__snapshots__/index.test.tsx.snap index 27be679dd..12702de4f 100644 --- a/packages/design/src/badge/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/design/src/badge/__tests__/__snapshots__/index.test.tsx.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Badge status custom icon 1`] = ` +exports[`Badge > status custom icon 1`] = ` `; -exports[`Badge status dot 1`] = ` +exports[`Badge > status dot 1`] = ` @@ -51,7 +51,7 @@ exports[`Badge status dot 1`] = ` `; -exports[`Badge status icon 1`] = ` +exports[`Badge > status icon 1`] = ` ( const { wrapSSR, hashId } = useStyle(prefixCls); const iconMap = { - default: , + default: , processing: ( ( ), success: , error: , - warning: , + warning: , }; return wrapSSR( diff --git a/packages/design/src/badge/style/index.ts b/packages/design/src/badge/style/index.ts index 1a6bf02f3..116c95fc2 100644 --- a/packages/design/src/badge/style/index.ts +++ b/packages/design/src/badge/style/index.ts @@ -6,6 +6,8 @@ export type BadgeToken = FullToken<'Badge'>; export const genBadgeStyle: GenerateStyle = (token: BadgeToken): CSSObject => { const { componentCls } = token; + // dot size is larger than antd + const dotSize = token.fontSizeLG / 2; return { [`${componentCls}`]: { // inherit color from parent instead of fixed colorText @@ -14,12 +16,15 @@ export const genBadgeStyle: GenerateStyle = (token: BadgeToken): CSS [`${componentCls}${componentCls}-status`]: { // dot style [`${componentCls}-status-dot`]: { - width: 8, - height: 8, + width: dotSize, + height: dotSize, + [`&${componentCls}-status-default`]: { + backgroundColor: token.colorFill, + }, }, // icon style [`${componentCls}-status-icon`]: { - fontSize: 12, + fontSize: token.fontSizeSM, // remove dot style backgroundColor: 'transparent', ['&::after']: { @@ -32,7 +37,7 @@ export const genBadgeStyle: GenerateStyle = (token: BadgeToken): CSS color: token.colorPrimary, }, [`&${componentCls}-status-default`]: { - color: token.colorTextPlaceholder, + color: token.colorFill, }, [`&${componentCls}-status-error`]: { color: token.colorError, diff --git a/packages/design/src/config-provider/DefaultRenderEmpty.tsx b/packages/design/src/config-provider/DefaultRenderEmpty.tsx new file mode 100644 index 000000000..03b632d63 --- /dev/null +++ b/packages/design/src/config-provider/DefaultRenderEmpty.tsx @@ -0,0 +1,29 @@ +import React, { useContext } from 'react'; +import type { ConfigConsumerProps } from '.'; +import { ConfigContext } from '.'; +import Empty from '../empty'; + +interface EmptyProps { + componentName?: string; +} + +/* refer to: https://github.com/ant-design/ant-design/blob/master/components/config-provider/defaultRenderEmpty.tsx */ +const DefaultRenderEmpty: React.FC = props => { + const { componentName } = props; + const { getPrefixCls } = useContext(ConfigContext); + const prefix = getPrefixCls('empty'); + switch (componentName) { + case 'Select': + case 'TreeSelect': + case 'Cascader': + case 'Transfer': + case 'Mentions': + return ; + default: + return ; + } +}; + +export type RenderEmptyHandler = (componentName?: string) => React.ReactNode; + +export default DefaultRenderEmpty; diff --git a/packages/design/src/config-provider/__tests__/__snapshots__/spin.test.tsx.snap b/packages/design/src/config-provider/__tests__/__snapshots__/spin.test.tsx.snap index 8f03ef83d..36a93018b 100644 --- a/packages/design/src/config-provider/__tests__/__snapshots__/spin.test.tsx.snap +++ b/packages/design/src/config-provider/__tests__/__snapshots__/spin.test.tsx.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`ConfigProvider spin spin.indicator should work 1`] = ` +exports[`ConfigProvider spin > spin.indicator should work 1`] = `
`; -exports[`ConfigProvider spin spin.indicator should work in nested ConfigProvider 1`] = ` +exports[`ConfigProvider spin > spin.indicator should work in nested ConfigProvider 1`] = `
`; +exports[`ConfigProvider styleProviderProps > ConfigProvider styleProviderProps.hashPriority 1`] = `
`; diff --git a/packages/design/src/config-provider/__tests__/navigate.test.tsx b/packages/design/src/config-provider/__tests__/navigate.test.tsx index dc0d43e40..56fce9415 100644 --- a/packages/design/src/config-provider/__tests__/navigate.test.tsx +++ b/packages/design/src/config-provider/__tests__/navigate.test.tsx @@ -1,7 +1,7 @@ import React, { useContext } from 'react'; import { BrowserRouter, useNavigate } from 'react-router-dom'; import { render } from '@testing-library/react'; -import ConfigProvider from '..'; +import { ConfigProvider } from '@oceanbase/design'; describe('ConfigProvider navigate', () => { it('navigate should work', () => { diff --git a/packages/design/src/config-provider/index.md b/packages/design/src/config-provider/index.md index f63b0f209..074c5c5ed 100644 --- a/packages/design/src/config-provider/index.md +++ b/packages/design/src/config-provider/index.md @@ -6,6 +6,7 @@ nav: --- - 🔥 完全继承 antd [ConfigProvider](https://ant.design/components/config-provider-cn) 的能力和 API,可无缝切换。 +- 🌈 定制全局主题和空状态,以符合 OceanBase Design 设计规范。 - 🆕 默认内嵌 [App 包裹组件](https://ant.design/components/app-cn),支持 message, notification 和 Modal 等静态方法消费 ConfigProvider 配置。 - 🆕 新增 `table.selectionColumnWidth` 属性,用于配置表格的展开列宽度。 - 🆕 新增 `injectStaticFunction` 属性,用于配置 `message`, `notification` 和 `Modal` 静态方法是否可以消费全局配置,默认开启。 @@ -21,8 +22,9 @@ nav: + -### 统一样式前缀 +### 样式前缀 - 通过 `prefixCls` 和 `iconPrefixCls` 可设置 antd 组件和图标的统一样式前缀。 diff --git a/packages/design/src/config-provider/index.tsx b/packages/design/src/config-provider/index.tsx index cad4bfa6b..c1c3738c9 100644 --- a/packages/design/src/config-provider/index.tsx +++ b/packages/design/src/config-provider/index.tsx @@ -16,6 +16,7 @@ import StaticFunction from '../static-function'; import themeConfig from '../theme'; import defaultTheme from '../theme/default'; import darkTheme from '../theme/dark'; +import DefaultRenderEmpty from './DefaultRenderEmpty'; import type { NavigateFunction } from './navigate'; import type { Locale } from '../locale'; @@ -127,6 +128,10 @@ const ConfigProvider: ConfigProviderType = ({ }, mergedTheme )} + renderEmpty={ + parentContext.renderEmpty || + (componentName => ) + } {...restProps} > contentProps should work for Descriptions.Item 1`] = `
@@ -51,7 +51,7 @@ exports[`Descriptions contentProps should work for Descriptions.Item 1`] = `
`; -exports[`Descriptions contentProps should work for items 1`] = ` +exports[`Descriptions > contentProps should work for items 1`] = `
@@ -102,7 +102,7 @@ exports[`Descriptions contentProps should work for items 1`] = `
`; -exports[`Descriptions remove colon for vertical layout by default for Descriptions.Item 1`] = ` +exports[`Descriptions > remove colon for vertical layout by default for Descriptions.Item 1`] = `
@@ -302,7 +302,7 @@ exports[`Descriptions remove colon for vertical layout by default for Descriptio
`; -exports[`Descriptions remove colon for vertical layout by default for items 1`] = ` +exports[`Descriptions > remove colon for vertical layout by default for items 1`] = `
@@ -502,7 +502,7 @@ exports[`Descriptions remove colon for vertical layout by default for items 1`]
`; -exports[`Descriptions render for Descriptions.Item 1`] = ` +exports[`Descriptions > render for Descriptions.Item 1`] = `
@@ -649,7 +649,7 @@ exports[`Descriptions render for Descriptions.Item 1`] = `
`; -exports[`Descriptions render for items 1`] = ` +exports[`Descriptions > render for items 1`] = `
diff --git a/packages/design/src/drawer/__tests__/__snapshots__/index.test.tsx.snap b/packages/design/src/drawer/__tests__/__snapshots__/index.test.tsx.snap index 1deda45c6..61f879b0b 100644 --- a/packages/design/src/drawer/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/design/src/drawer/__tests__/__snapshots__/index.test.tsx.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Drawer render correctly 1`] = ` +exports[`Drawer > render correctly 1`] = `
`; -exports[`Drawer render with confirmLoading and okButtonProps 1`] = ` +exports[`Drawer > render with confirmLoading and okButtonProps 1`] = `