Skip to content

Commit

Permalink
chore: auto merge branches (ant-design#44202)
Browse files Browse the repository at this point in the history
chore: feature merge master
  • Loading branch information
github-actions[bot] authored Aug 14, 2023
2 parents a5203eb + 72b449a commit 0a4463e
Show file tree
Hide file tree
Showing 22 changed files with 132 additions and 145 deletions.
136 changes: 13 additions & 123 deletions .dumi/pages/theme-editor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import { createStyles } from 'antd-style';
import { ThemeEditor, enUS, zhCN } from 'antd-token-previewer';
import { enUS, zhCN } from 'antd-token-previewer';
import { Helmet } from 'dumi';
import React, { Suspense, useCallback, useEffect, useState } from 'react';
import type { JSONContent, TextContent } from 'vanilla-jsoneditor';
import React, { Suspense, useEffect } from 'react';
import type { ThemeConfig } from 'antd/es/config-provider/context';
import { Button, ConfigProvider, Modal, Spin, Typography, message } from 'antd';
import { Button, message, Skeleton } from 'antd';
import useLocale from '../../hooks/useLocale';

const JSONEditor = React.lazy(() => import('../../theme/common/JSONEditor'));

function isObject(target: any) {
return Object.prototype.toString.call(target) === '[object Object]';
}
const ThemeEditor = React.lazy(() => import('antd-token-previewer/lib/ThemeEditor'));

const locales = {
cn: {
Expand All @@ -38,17 +32,6 @@ const locales = {
},
};

const useStyle = createStyles(({ css }) => ({
header: css({
display: 'flex',
height: 56,
alignItems: 'center',
padding: '0 24px',
justifyContent: 'space-between',
borderBottom: '1px solid #F0F0F0',
}),
}));

const ANT_DESIGN_V5_THEME_EDITOR_THEME = 'ant-design-v5-theme-editor-theme';

const CustomTheme = () => {
Expand All @@ -57,13 +40,6 @@ const CustomTheme = () => {

const [theme, setTheme] = React.useState<ThemeConfig>({});

const [editModelOpen, setEditModelOpen] = useState<boolean>(false);
const [editThemeFormatRight, setEditThemeFormatRight] = useState<boolean>(true);
const [themeConfigContent, setThemeConfigContent] = useState<JSONContent & TextContent>({
text: '{}',
json: undefined,
});

useEffect(() => {
const storedConfig = localStorage.getItem(ANT_DESIGN_V5_THEME_EDITOR_THEME);
if (storedConfig) {
Expand All @@ -77,120 +53,34 @@ const CustomTheme = () => {
}
}, []);

const { styles } = useStyle();

const handleSave = () => {
localStorage.setItem(ANT_DESIGN_V5_THEME_EDITOR_THEME, JSON.stringify(theme));
messageApi.success(locale.saveSuccessfully);
};

const handleEditConfig = () => {
setEditModelOpen(true);
};

const editModelClose = useCallback(() => {
setEditModelOpen(false);
}, [themeConfigContent]);

const handleEditConfigChange = (newcontent, preContent, status) => {
setThemeConfigContent(newcontent);
setEditThemeFormatRight(!status.contentErrors);
};

const editSave = useCallback(() => {
const contentFormatError = !editThemeFormatRight;

if (contentFormatError) {
message.error(locale.editJsonContentTypeError);
return;
}
const themeConfig = themeConfigContent.text
? JSON.parse(themeConfigContent.text)
: themeConfigContent.json;
if (!isObject(themeConfig)) {
message.error(locale.editJsonContentTypeError);
return;
}
setTheme(themeConfig);
editModelClose();
messageApi.success(locale.editSuccessfully);
}, [themeConfigContent, editThemeFormatRight]);

const handleExport = () => {
const file = new File([JSON.stringify(theme, null, 2)], `Ant Design Theme.json`, {
type: 'text/json; charset=utf-8;',
});
const tmpLink = document.createElement('a');
const objectUrl = URL.createObjectURL(file);

tmpLink.href = objectUrl;
tmpLink.download = file.name;
document.body.appendChild(tmpLink);
tmpLink.click();

document.body.removeChild(tmpLink);
URL.revokeObjectURL(objectUrl);
};

return (
<div>
<Helmet>
<title>{`${locale.title} - Ant Design`}</title>
<meta property="og:title" content={`${locale.title} - Ant Design`} />
</Helmet>
{contextHolder}
<ConfigProvider theme={{ inherit: false }}>
<div className={styles.header}>
<Typography.Title level={5} style={{ margin: 0 }}>
{locale.title}
</Typography.Title>
<div>
<Modal
open={editModelOpen}
title={locale.editModelTitle}
width={600}
okText={locale.save}
onOk={editSave}
onCancel={editModelClose}
>
<Suspense
fallback={
<div style={{ textAlign: 'center', width: '100%', padding: '24px 0' }}>
<Spin tip={locale.initialEditor} />
</div>
}
>
<JSONEditor
content={themeConfigContent}
onChange={handleEditConfigChange}
mainMenuBar={false}
/>
</Suspense>
</Modal>
<Button onClick={handleExport} style={{ marginRight: 8 }}>
{locale.export}
</Button>
<Button onClick={handleEditConfig} style={{ marginRight: 8 }}>
{locale.edit}
</Button>
<Button type="primary" onClick={handleSave}>
{locale.save}
</Button>
</div>
</div>
<Suspense fallback={<Skeleton style={{ margin: 24 }} />}>
<ThemeEditor
advanced
theme={{ name: 'Custom Theme', key: 'test', config: theme }}
style={{ height: 'calc(100vh - 64px - 56px)' }}
style={{ height: 'calc(100vh - 64px)' }}
onThemeChange={(newTheme) => {
setTheme(newTheme.config);
setThemeConfigContent({
json: newTheme.config,
text: undefined,
});
}}
locale={lang === 'cn' ? zhCN : enUS}
actions={
<Button type="primary" onClick={handleSave}>
{locale.save}
</Button>
}
/>
</ConfigProvider>
</Suspense>
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion .dumi/theme/builtins/IconSearch/Category.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Category: React.FC<CategoryProps> = (props) => {
const { icons, title, newIcons, theme } = props;
const intl = useIntl();
const [justCopied, setJustCopied] = React.useState<string | null>(null);
const copyId = React.useRef<NodeJS.Timeout | null>(null);
const copyId = React.useRef<ReturnType<typeof setTimeout> | null>(null);
const onCopied = React.useCallback((type: string, text: string) => {
message.success(
<span>
Expand Down
2 changes: 1 addition & 1 deletion .dumi/theme/layouts/DocLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const DocLayout: React.FC = () => {
const location = useLocation();
const { pathname, search, hash } = location;
const [locale, lang] = useLocale(locales);
const timerRef = useRef<NodeJS.Timeout | null>(null);
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const { direction } = useContext(SiteContext);
const { loading } = useSiteData();

Expand Down
23 changes: 21 additions & 2 deletions .dumi/theme/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,28 @@ import type { IApi, IRoute } from 'dumi';
import ReactTechStack from 'dumi/dist/techStacks/react';
import chalk from 'chalk';
import sylvanas from 'sylvanas';
import { extractStaticStyle } from 'antd-style';
import createEmotionServer from '@emotion/server/create-instance';
import localPackage from '../../package.json';

function extractEmotionStyle(html: string) {
// copy from emotion ssr
// https://github.com/vercel/next.js/blob/deprecated-main/examples/with-emotion-vanilla/pages/_document.js
const styles = global.__ANTD_STYLE_CACHE_MANAGER_FOR_SSR__.getCacheList().map((cache) => {
const result = createEmotionServer(cache).extractCritical(html);
if (!result.css) return null;

const { css, ids } = result;

return {
key: cache.key,
css,
ids,
tag: `<style data-emotion="${cache.key} ${result.ids.join(' ')}">${result.css}</style>`,
};
});
return styles.filter(Boolean);
}

export const getHash = (str: string, length = 8) =>
createHash('md5').update(str).digest('hex').slice(0, length);

Expand Down Expand Up @@ -129,7 +148,7 @@ const RoutesPlugin = (api: IApi) => {
file.content = file.content.replace('</head>', `${globalStyles}</head>`);

// 1. 提取 antd-style 样式
const styles = extractStaticStyle(file.content, { includeAntd: false });
const styles = extractEmotionStyle(file.content);

// 2. 提取每个样式到独立 css 文件
styles.forEach((result) => {
Expand Down
2 changes: 1 addition & 1 deletion .dumi/theme/slots/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const Header: React.FC = () => {
searching: false,
});
const { direction, isMobile, updateSiteConfig } = useContext<SiteContextProps>(SiteContext);
const pingTimer = useRef<NodeJS.Timeout | null>(null);
const pingTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
const location = useLocation();
const { pathname, search } = location;

Expand Down
2 changes: 1 addition & 1 deletion .dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default defineConfig({
},
ssr: process.env.NODE_ENV === 'production' ? {} : false,
hash: true,
mfsu: false,
crossorigin: {},
outputPath: '_site',
favicons: ['https://gw.alipayobjects.com/zos/rmsportal/rlpTLlbMzTNYuZGGCVYM.png'],
Expand All @@ -34,7 +35,6 @@ export default defineConfig({
},
extraRehypePlugins: [rehypeAntd],
extraRemarkPlugins: [remarkAntd],
mfsu: false,
metas: [{ name: 'theme-color', content: '#1677ff' }],
analytics: {
ga_v2: 'UA-72788897-1',
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/pr-contributor-welcome.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 当 PR 被合并时,留言欢迎加入共建群
name: PullRequest Contributor Welcome

on:
pull_request_target:
types:
- closed
paths:
- 'components/**'

jobs:
check-merged:
runs-on: ubuntu-latest
needs: read-file
if: github.event.pull_request.merged == true
steps:
- uses: actions-cool/maintain-one-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
🎉 Thanks for contribution. Please feel free to join DingTalk Social Community (Provide the PR link please).
🎉 感谢参与贡献,欢迎扫码加入钉钉社区(进群后请提供 PR 地址)。
<img src="https://github.com/ant-design/ant-design/assets/5378891/e24c6080-bf38-4523-b1cd-f6c43ad7375f" height="200" />
<!-- WELCOME_CONTRIBUTION -->
body-include: '<!-- WELCOME_CONTRIBUTION -->'
2 changes: 2 additions & 0 deletions .jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ module.exports = {
'/\\.(css|less)$/': 'identity-obj-proxy',
'^antd$': '<rootDir>/components/index',
'^antd/es/(.*)$': '<rootDir>/components/$1',
'^antd/lib/(.*)$': '<rootDir>/components/$1',
'^antd/locale/(.*)$': '<rootDir>/components/locale/$1',
},
testPathIgnorePatterns: ['/node_modules/', 'dekko', 'node', 'image.test.js', 'image.test.ts'],
transform: {
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,29 @@ tag: vVERSION

---

## 5.8.3

`2023-08-11`

- DatePicker
- 🐞 Fix DatePicker panel cannot toggle when selecting time with truthy `open` and truthy `defaultOpen`. [#44105](https://github.com/ant-design/ant-design/pull/44105) [@Yuiai01](https://github.com/Yuiai01)
- 🐞 Fix DatePicker and RangePicker still show the clear button when disable `allowClear`. [#44015](https://github.com/ant-design/ant-design/pull/44015) [@bartpio](https://github.com/bartpio)
- Carousel
- 🐞 Fix Carousel do not support `id` prop. [#44079](https://github.com/ant-design/ant-design/pull/44079)
- 💄 Fix Carousel `dots` extra margin style. [#44076](https://github.com/ant-design/ant-design/pull/44076)
- 🐞 Fix Modal footer disabled state that affect by Form. [#43055](https://github.com/ant-design/ant-design/pull/43055) [@Wxh16144](https://github.com/Wxh16144)
- 🐞 Fix Upload thumbnail that gif will not play. [#44083](https://github.com/ant-design/ant-design/pull/44083) [@linxianxi](https://github.com/linxianxi)
- 🐞 Fix FloatButton that menu mode didn't support `badge` prop. [#44109](https://github.com/ant-design/ant-design/pull/44109) [@MadCcc](https://github.com/MadCcc)
- 🐞 Fix Grid & List responsive config take effect after first render which cause screen flick. [#44075](https://github.com/ant-design/ant-design/pull/44075)
- 🐞 Fix that Design Token partially missing when `@ant-design/cssinjs` version `1.15.0`. [#44091](https://github.com/ant-design/ant-design/pull/44091) [@MadCcc](https://github.com/MadCcc)
- 💄 Fix Badge `status="processing"` with `dot` wave style issue. [#44153](https://github.com/ant-design/ant-design/pull/44153)
- 💄 Fix Descriptions border styles when it nests itself. [#43454](https://github.com/ant-design/ant-design/pull/43454) [@Yuiai01](https://github.com/Yuiai01)
- 💄 Fix Pagination transition style in prev/next buttons. [#44030](https://github.com/ant-design/ant-design/pull/44030)
- 💄 Fix Popconfirm button group wraps unexpectedly. [#44022](https://github.com/ant-design/ant-design/pull/44022) [@MuxinFeng](https://github.com/MuxinFeng)
- 💄 Optimize style of Image preview operation icons. [#44141](https://github.com/ant-design/ant-design/pull/44141) [@MadCcc](https://github.com/MadCcc)
- 💄 Optimize Input and InputNumber font size in large mode. [#44000](https://github.com/ant-design/ant-design/pull/44000) [@MuxinFeng](https://github.com/MuxinFeng)
- 💄 Remove Space part useless style. [#44098](https://github.com/ant-design/ant-design/pull/44098)

## 5.8.2

`2023-08-04`
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,29 @@ tag: vVERSION

---

## 5.8.3

`2023-08-11`

- DatePicker
- 🐞 修复 DatePicker 在 `open``defaultOpen``true` 时选中时间不会切换面板的问题。[#44105](https://github.com/ant-design/ant-design/pull/44105) [@Yuiai01](https://github.com/Yuiai01)
- 🐞 修复 DatePicker 和 RangePicker 禁用 `allowClear` 时仍然展示清除按钮的问题。[#44015](https://github.com/ant-design/ant-design/pull/44015) [@bartpio](https://github.com/bartpio)
- Carousel
- 🐞 修复 Carousel 不支持 `id` 属性的问题。[#44079](https://github.com/ant-design/ant-design/pull/44079)
- 💄 修复 Carousel `dots` 切换点有多余 margin 的问题。[#44076](https://github.com/ant-design/ant-design/pull/44076)
- 🐞 修复 Modal 页脚禁用态受 Form 影响的问题。[#43055](https://github.com/ant-design/ant-design/pull/43055) [@Wxh16144](https://github.com/Wxh16144)
- 🐞 修复 Upload gif 缩略图不会动的问题。[#44083](https://github.com/ant-design/ant-design/pull/44083) [@linxianxi](https://github.com/linxianxi)
- 🐞 修复 FloatButton 组件菜单模式不支持 `badge` 配置的问题。[#44109](https://github.com/ant-design/ant-design/pull/44109) [@MadCcc](https://github.com/MadCcc)
- 🐞 修复 Grid 与 List 响应式布局生效稍晚于首次渲染导致屏幕闪动的问题。[#44075](https://github.com/ant-design/ant-design/pull/44075)
- 🐞 修复 `@ant-design/cssinjs` 版本小于 `1.15.0` 时 Design Token 部分丢失的问题。[#44091](https://github.com/ant-design/ant-design/pull/44091) [@MadCcc](https://github.com/MadCcc)
- 💄 修复 Badge `status="processing"``dot` 配合使用时,波纹样式异常的问题。[#44153](https://github.com/ant-design/ant-design/pull/44153)
- 💄 修复 Descriptions 组件自行嵌套时的边框样式问题。[#43454](https://github.com/ant-design/ant-design/pull/43454) [@Yuiai01](https://github.com/Yuiai01)
- 💄 修复 Pagination 上下页切换按钮 `transition`` 丢失的问题。[#44030](https://github.com/ant-design/ant-design/pull/44030)
- 💄 修复 Popconfirm 按钮组意外换行的问题。[#44022](https://github.com/ant-design/ant-design/pull/44022) [@MuxinFeng](https://github.com/MuxinFeng)
- 💄 优化 Image 组件预览操作图标的样式。[#44141](https://github.com/ant-design/ant-design/pull/44141) [@MadCcc](https://github.com/MadCcc)
- 💄 优化 Input 和 InputNumber 在大尺寸下的字体大小。[#44000](https://github.com/ant-design/ant-design/pull/44000) [@MuxinFeng](https://github.com/MuxinFeng)
- 💄 移除 Space 部分未使用的样式。[#44098](https://github.com/ant-design/ant-design/pull/44098)

## 5.8.2

`2023-08-04`
Expand Down
2 changes: 1 addition & 1 deletion components/_util/ActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const ActionButton: React.FC<ActionButtonProps> = (props) => {
};

React.useEffect(() => {
let timeoutId: NodeJS.Timer | null = null;
let timeoutId: ReturnType<typeof setTimeout> | null = null;
if (autoFocus) {
timeoutId = setTimeout(() => {
buttonRef.current?.focus();
Expand Down
2 changes: 1 addition & 1 deletion components/affix/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class InternalAffix extends React.Component<InternalAffixProps, AffixState> {

private fixedNodeRef = createRef<HTMLDivElement>();

private timer: NodeJS.Timeout | null;
private timer: ReturnType<typeof setTimeout> | null;

context: ConfigConsumerProps;

Expand Down
2 changes: 1 addition & 1 deletion components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const InternalButton: React.ForwardRefRenderFunction<
const needInserted = Children.count(children) === 1 && !icon && !isUnBorderedButtonType(type);

useEffect(() => {
let delayTimer: NodeJS.Timer | null = null;
let delayTimer: ReturnType<typeof setTimeout> | null = null;
if (loadingOrDelay.delay > 0) {
delayTimer = setTimeout(() => {
delayTimer = null;
Expand Down
Loading

0 comments on commit 0a4463e

Please sign in to comment.