Compare commits

...

14 Commits

Author SHA1 Message Date
renovate[bot]
3b52894cf3 chore(deps): update dependency @eslint-react/eslint-plugin to v2.13.0 (#57004)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-15 09:35:38 +08:00
github-actions[bot]
ad9149ba24 chore: upgrade deps (#57003)
Co-authored-by: afc163 <507615+afc163@users.noreply.github.com>
2026-02-15 09:14:48 +08:00
thinkasany
95f032bc3d refactor: turn on react-naming-convention/use-state (#56998)
Co-authored-by: 遇见同学 <1875694521@qq.com>
2026-02-14 11:50:16 +08:00
lijianan
5dfaf14db7 feat(a11y): apply prefers-reduced-motion handling for transitions (#56902)
* up

* up

* update

* update

---------

Co-authored-by: 遇见同学 <1875694521@qq.com>
2026-02-14 11:14:18 +08:00
遇见同学
5ad1ecd723 chore: remove duplicate classNames example code (#56994)
Co-authored-by: thinkasany <480968828@qq.com>
2026-02-14 10:57:07 +08:00
遇见同学
9b03f7ae6c chore(transfer): code style optimization (#56993)
* fix(Transfer): improve RTL support and type safety for item selection

* chore: adj

---------

Co-authored-by: thinkasany <480968828@qq.com>
2026-02-14 10:51:35 +08:00
遇见同学
852ed686d2 docs: remove duplicate demo classNames (#56991)
* docs:  remove unused classNames demo for Modal component

* chore: update

* chore: rm
2026-02-14 10:22:57 +08:00
lijianan
47159dd3b2 chore: code style optimization (#56990) 2026-02-14 10:19:48 +08:00
lijianan
70f564603b chore: unify coding style (#56989)
* chore: 统一代码风格

* update
2026-02-14 09:32:30 +08:00
luozz
d534dd8b17 fix: issue with echoing when the value of Select is an empty string. … (#56966)
* fix: issue with echoing when the value of Select is an empty string. #56960

* ci: add select's demo when defaultValue is empty

* ci: trigger

* test: update snap

* chore: upgrade deps (#56977)

Co-authored-by: afc163 <507615+afc163@users.noreply.github.com>

* test: update demo for image diff (#56976)

* chore: update @rc-component/select to v1.6.7 and update debug demo

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: update Input component snapshots

Add updated snapshot tests for input component demo and demo-extend.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: bump deps

* chore: trigger CI re-run

* chore: format

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* ci: resolving conflicts.

* chore(deps): update @rc-component/select to 1.6.9

* test: update snap

---------

Co-authored-by: 罗忠泽 <victor.luo@spotterio.com>
Co-authored-by: thinkasany <480968828@qq.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: afc163 <507615+afc163@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 16:13:49 +08:00
yanyu
d271104014 fix(Progress): prevent animation overflow when status is set to active (#56972)
Co-authored-by: thinkasany <480968828@qq.com>
2026-02-13 14:31:34 +08:00
二货爱吃白萝卜
6915342818 test: update demo for image diff (#56976)
* chore: update @rc-component/select to v1.6.7 and update debug demo

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: update Input component snapshots

Add updated snapshot tests for input component demo and demo-extend.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: bump deps

* chore: trigger CI re-run

* chore: format

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 13:41:03 +08:00
github-actions[bot]
956c1d1b51 chore: upgrade deps (#56977)
Co-authored-by: afc163 <507615+afc163@users.noreply.github.com>
2026-02-13 09:44:05 +08:00
高艳兵
6e993d2ef8 fix: correct mismatched JSDoc parameter names in plugin files (#56969) 2026-02-12 20:54:15 +08:00
55 changed files with 672 additions and 697 deletions

View File

@@ -31,7 +31,7 @@ export const useIssueCount = (options: UseIssueCountOptions) => {
// Note: current query only filters by title keywords. Filtering by component name can be added later if needed.
const searchUrl = useMemo(() => {
const tokens = (titleKeywords || []).filter(Boolean).map((k) => encodeURIComponent(String(k)));
const tokens = (titleKeywords || []).filter(Boolean).map<string>(encodeURIComponent);
const orExpr = tokens.length > 0 ? tokens.join('%20OR%20') : '';
const titlePart = orExpr ? `in:title+(${orExpr})` : 'in:title';
const q = `repo:${repo}+is:issue+is:open+${titlePart}`;
@@ -45,7 +45,7 @@ export const useIssueCount = (options: UseIssueCountOptions) => {
const issueNewUrl = `https://github.com/${repo}/issues/new/choose`;
const issueSearchUrl = useMemo(() => {
const keywords = (titleKeywords || []).filter(Boolean).map((k) => String(k));
const keywords = (titleKeywords || []).filter(Boolean).map<string>(String);
const groupExpr =
keywords.length > 0 ? `(${keywords.map((k) => `is:issue in:title ${k}`).join(' OR ')})` : '';
const qRaw = `is:open ${groupExpr}`.trim();

View File

@@ -113,8 +113,10 @@ const RecommendItem: React.FC<RecommendItemProps> = (props) => {
const [mousePosition, setMousePosition] = React.useState<[number, number]>([0, 0]);
const [transMousePosition, setTransMousePosition] = React.useState<[number, number]>([0, 0]);
const onMouseMove = (e: React.MouseEvent<HTMLAnchorElement>) => {
if (!cardRef.current) return;
const onMouseMove: React.MouseEventHandler<HTMLAnchorElement> = (e) => {
if (!cardRef.current) {
return;
}
const rect = cardRef.current.getBoundingClientRect();
const x = e.clientX - rect.left;

View File

@@ -29,13 +29,13 @@ const VersionUpgradeModal = () => {
const [locale, lang] = useLocale(locales);
const { pathname } = useLocation();
const [open, updateOpen] = React.useState(false);
const [open, setOpen] = React.useState(false);
const isCN = lang === 'cn' || utils.isZhCN(pathname);
function handleClose() {
localStorage.setItem(STORAGE_KEY, Date.now().toString());
updateOpen(false);
setOpen(false);
}
React.useEffect(() => {
@@ -48,7 +48,7 @@ const VersionUpgradeModal = () => {
if (!lastTime) {
const timer = setTimeout(() => {
updateOpen(true);
setOpen(true);
}, 1000);
return () => {

View File

@@ -101,7 +101,9 @@ let TOKEN_CACHE: { meta: TokenMeta; data: TokenData } | null | undefined;
*/
function readJsonIfExists<T>(abs: string): T | null {
try {
if (!fs.existsSync(abs)) return null;
if (!fs.existsSync(abs)) {
return null;
}
return JSON.parse(fs.readFileSync(abs, 'utf-8')) as T;
} catch {
return null;
@@ -144,7 +146,9 @@ function replaceSemanticDomSection(md: string, context: ContentFilterContext) {
// 从文档路径推断组件路径(用于生成链接)
// 例如components/card/index.en-US.md -> components/card/semantic.md
const componentPathMatch = context.file.match(/components\/([^/]+)\//);
if (!componentPathMatch) return md;
if (!componentPathMatch) {
return md;
}
const componentName = componentPathMatch[1];
const isZhCN = /-cn\.md$/i.test(context.file) || /\.zh-CN\.md$/i.test(context.file);
@@ -154,10 +158,14 @@ function replaceSemanticDomSection(md: string, context: ContentFilterContext) {
return md.replace(/<code[^>]*_semantic[^>]*>.*?<\/code>/g, (match) => {
// 从匹配的标签中提取文件名
const demoIndex = match.indexOf('./demo/');
if (demoIndex === -1) return match;
if (demoIndex === -1) {
return match;
}
const start = demoIndex + './demo/'.length;
const end = match.indexOf('"', start);
if (end === -1) return match;
if (end === -1) {
return match;
}
const semanticFile = match.substring(start, end);
// 生成对应的 semantic.md 文件名_semantic.tsx -> semantic.md, _semantic_meta.tsx -> semantic_meta.md
const semanticMdFileName = semanticFile
@@ -180,7 +188,9 @@ function getMaxBacktickRun(text: string) {
let m: RegExpExecArray | null = re.exec(text);
while (m) {
if (m[0].length > max) max = m[0].length;
if (m[0].length > max) {
max = m[0].length;
}
m = re.exec(text);
}
return max;
@@ -244,7 +254,9 @@ function antdCodeAppend(docFileAbs: string, src: string): string {
'i',
);
const match = demoMd.match(re);
if (!match) return demoMd.trim();
if (!match) {
return demoMd.trim();
}
return (match[2] ?? '').trim();
}
@@ -255,7 +267,7 @@ function antdCodeAppend(docFileAbs: string, src: string): string {
*
* @param md - 原始 markdown 内容
* @param docFileAbs - 文档文件的绝对路径,用于解析相对路径和检测语言
* @param enablePickLocaleBlock - 是否启用多语言块提取,可以是布尔值或函数,默认为 true
* @param codeAppend - 代码追加函数:在替换 <code src> 标签时,用于追加额外的内容(如 demo 描述信息)
* @returns 替换后的 markdown 内容
*/
function replaceCodeSrcToMarkdown(
@@ -305,8 +317,9 @@ function replaceCodeSrcToMarkdown(
* @returns token 元数据和数据对象,如果文件不存在则返回 null
*/
function loadTokenFromRepo(api: IApi) {
if (TOKEN_CACHE !== undefined) return TOKEN_CACHE;
if (TOKEN_CACHE !== undefined) {
return TOKEN_CACHE;
}
const cwd = api.paths.cwd;
const metaPath = path.join(cwd, 'components', 'version', 'token-meta.json');
const dataPath = path.join(cwd, 'components', 'version', 'token.json');
@@ -345,9 +358,15 @@ function escapeMdCell(v: unknown) {
* @returns 规范化后的字符串null/undefined 返回空字符串
*/
function normalizeValue(v: unknown) {
if (v === undefined || v === null) return '';
if (typeof v === 'string') return v.trim();
if (typeof v === 'number' || typeof v === 'boolean') return String(v);
if (v === undefined || v === null) {
return '';
}
if (typeof v === 'string') {
return v.trim();
}
if (typeof v === 'number' || typeof v === 'boolean') {
return String(v);
}
try {
return JSON.stringify(v);
} catch {
@@ -369,7 +388,9 @@ function normalizeValue(v: unknown) {
*/
function replaceComponentTokenTable(md: string, context: ContentFilterContext) {
const tokens = loadTokenFromRepo(context.api);
if (!tokens) return md;
if (!tokens) {
return md;
}
const { meta: tokenMeta, data: tokenData } = tokens;
const locale = detectDocLocale(context.file);
@@ -398,7 +419,9 @@ function replaceComponentTokenTable(md: string, context: ContentFilterContext) {
return md.replace(re, (full, componentProp) => {
const comp = String(componentProp || '').trim();
if (!comp) return full;
if (!comp) {
return full;
}
const comps = comp
.split(',')
@@ -474,7 +497,9 @@ function replaceComponentTokenTable(md: string, context: ContentFilterContext) {
}
// 如果没有生成任何内容,则保留原标签
if (!out.length) return full;
if (!out.length) {
return full;
}
// 返回生成的 markdown 表格,前后添加换行确保格式正确
return `\n\n${out.join('\n').trim()}\n\n`;
});
@@ -489,8 +514,12 @@ function replaceComponentTokenTable(md: string, context: ContentFilterContext) {
* @param api - Dumi API 实例,用于获取输出路径等配置
*/
function emitRawMd(api: IApi) {
if (process.env.NODE_ENV !== 'production') return;
if (RAW_MD_EMITTED) return;
if (process.env.NODE_ENV !== 'production') {
return;
}
if (RAW_MD_EMITTED) {
return;
}
RAW_MD_EMITTED = true;
const outRoot = api.paths.absOutputPath;
@@ -499,7 +528,9 @@ function emitRawMd(api: IApi) {
try {
const { absPath, file } = route;
const relPath = absPath.replace(/^\//, '');
if (!relPath || !fs.existsSync(file)) return;
if (!relPath || !fs.existsSync(file)) {
return;
}
// 应用路由过滤器
if (PLUGIN_OPTIONS.routeFilter && !PLUGIN_OPTIONS.routeFilter(route)) {
@@ -556,7 +587,6 @@ function emitRawMd(api: IApi) {
* 2. 在 HTML 文件导出阶段输出处理后的 raw markdown 文件
*
* @param api - Dumi API 实例
* @param options - 插件配置选项
*/
export default function rawMdPlugin(api: IApi) {
// 注册配置键,允许用户在配置中使用 rawMd 键

View File

@@ -19,8 +19,8 @@ function extractSemantics(objContent: string): Record<string, string> {
}
/**
* 从 _semantic*.tsx 文件中提取语义信息
* @param semanticFile - _semantic*.tsx 文件的绝对路径
* 从 _semantic*.tsx 文件内容中提取语义信息
* @param content - _semantic*.tsx 文件的文件内容字符串
* @returns 包含中文和英文语义描述的对象,失败返回 null
*/
function extractLocaleInfoFromContent(content: string): {
@@ -29,14 +29,20 @@ function extractLocaleInfoFromContent(content: string): {
} | null {
// 匹配 locales 对象定义
const localesMatch = content.match(/const locales = \{([\s\S]*?)\};/);
if (!localesMatch) return null;
if (!localesMatch) {
return null;
}
// 提取中文和英文的语义描述
const cnMatch = content.match(/cn:\s*\{([\s\S]*?)\},?\s*en:/);
if (!cnMatch) return null;
if (!cnMatch) {
return null;
}
const enMatch = content.match(/en:\s*\{([\s\S]*?)\}\s*[,;]/);
if (!enMatch) return null;
if (!enMatch) {
return null;
}
const cnContent = cnMatch[1];
const enContent = enMatch[1];
@@ -44,7 +50,9 @@ function extractLocaleInfoFromContent(content: string): {
const cnSemantics = extractSemantics(cnContent);
const enSemantics = extractSemantics(enContent);
if (Object.keys(cnSemantics).length === 0) return null;
if (Object.keys(cnSemantics).length === 0) {
return null;
}
return { cn: cnSemantics, en: enSemantics };
}
@@ -60,7 +68,9 @@ function resolveTemplateFilePath(semanticFile: string, importPath: string): stri
path.join(basePath, 'index.ts'),
];
for (const candidate of candidates) {
if (fs.existsSync(candidate)) return candidate;
if (fs.existsSync(candidate)) {
return candidate;
}
}
return null;
}
@@ -72,7 +82,9 @@ function parseTemplateUsage(content: string): Array<{ componentName: string; imp
for (const match of content.matchAll(importRegex)) {
const importClause = match[1].trim();
const importPath = match[2].trim();
if (!importPath.startsWith('.')) continue;
if (!importPath.startsWith('.')) {
continue;
}
const componentNames: string[] = [];
if (importClause.startsWith('{')) {
@@ -119,7 +131,9 @@ function parseTemplateUsage(content: string): Array<{ componentName: string; imp
// 解析 ignoreSemantics 属性值
function parseIgnoreSemantics(propsString: string): string[] {
const ignoreMatch = propsString.match(/ignoreSemantics\s*=\s*\{([\s\S]*?)\}/);
if (!ignoreMatch) return [];
if (!ignoreMatch) {
return [];
}
const ignoreContent = ignoreMatch[1];
return Array.from(ignoreContent.matchAll(/['"]([^'"]+)['"]/g)).map((match) => match[1]);
}
@@ -127,8 +141,12 @@ function parseIgnoreSemantics(propsString: string): string[] {
// 解析 singleOnly 属性值
function parseSingleOnly(propsString: string): boolean {
const singleOnlyMatch = propsString.match(/singleOnly(\s*=\s*\{?([^}\s]+)\}?)?/);
if (!singleOnlyMatch) return false;
if (!singleOnlyMatch[1]) return true;
if (!singleOnlyMatch) {
return false;
}
if (!singleOnlyMatch[1]) {
return true;
}
const value = singleOnlyMatch[2];
return value !== 'false';
}
@@ -136,7 +154,9 @@ function parseSingleOnly(propsString: string): boolean {
// 抽取模板组件 JSX 的属性字符串
function extractTemplateProps(content: string, componentName: string): string {
const start = content.indexOf(`<${componentName}`);
if (start === -1) return '';
if (start === -1) {
return '';
}
let index = start + componentName.length + 1;
const propsStart = index;
let braceDepth = 0;
@@ -164,7 +184,9 @@ function extractTemplateProps(content: string, componentName: string): string {
}
if (ch === '}') {
if (braceDepth > 0) braceDepth -= 1;
if (braceDepth > 0) {
braceDepth -= 1;
}
continue;
}
@@ -198,15 +220,21 @@ function extractSemanticInfoFromTemplate(
content: string,
): { cn: Record<string, string>; en: Record<string, string> } | null {
const templates = parseTemplateUsage(content);
if (templates.length === 0) return null;
if (templates.length === 0) {
return null;
}
for (const template of templates) {
const templatePath = resolveTemplateFilePath(semanticFile, template.importPath);
if (!templatePath) continue;
if (!templatePath) {
continue;
}
const templateContent = fs.readFileSync(templatePath, 'utf-8');
const templateLocales = extractLocaleInfoFromContent(templateContent);
if (!templateLocales) continue;
if (!templateLocales) {
continue;
}
const propsString = extractTemplateProps(content, template.componentName);
const ignoreSemantics = parseIgnoreSemantics(propsString);
@@ -235,11 +263,15 @@ function extractSemanticInfo(semanticFile: string): {
en: Record<string, string>;
} | null {
try {
if (!fs.existsSync(semanticFile)) return null;
if (!fs.existsSync(semanticFile)) {
return null;
}
const content = fs.readFileSync(semanticFile, 'utf-8');
const localeInfo = extractLocaleInfoFromContent(content);
if (localeInfo) return localeInfo;
if (localeInfo) {
return localeInfo;
}
return extractSemanticInfoFromTemplate(semanticFile, content);
} catch (error) {
@@ -324,9 +356,12 @@ function getComponentHTMLSnapshot(semanticFile: string, cwd: string): string | n
try {
const relativePath = path.relative(cwd, semanticFile);
const pathMatch = relativePath.match(/^components\/([^/]+)\/demo\/([^/]+)\.tsx$/);
if (!pathMatch) return null;
if (!pathMatch) {
return null;
}
const [, componentName, fileName] = pathMatch;
const snapshotPath = path.join(
cwd,
'components',
@@ -336,7 +371,9 @@ function getComponentHTMLSnapshot(semanticFile: string, cwd: string): string | n
'demo-semantic.test.tsx.snap',
);
if (!fs.existsSync(snapshotPath)) return null;
if (!fs.existsSync(snapshotPath)) {
return null;
}
const snapshotContent = fs.readFileSync(snapshotPath, 'utf-8');
// 匹配快照 keyexports[`renders components/button/demo/_semantic.tsx correctly 1`] = `...`;
@@ -345,7 +382,9 @@ function getComponentHTMLSnapshot(semanticFile: string, cwd: string): string | n
`exports\\[\\\`[^\\\`]*${snapshotKeyPattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[^\\\`]*\\\`\\]\\s*=\\s*\\\`([\\s\\S]*?)\\\`;`,
);
const snapshotMatch = snapshotContent.match(regex);
if (!snapshotMatch) return null;
if (!snapshotMatch) {
return null;
}
let html = snapshotMatch[1].trim();
@@ -415,8 +454,12 @@ function getComponentHTMLSnapshot(semanticFile: string, cwd: string): string | n
* @param api - Dumi API 实例
*/
function emitSemanticMd(api: IApi) {
if (process.env.NODE_ENV !== 'production') return;
if (SEMANTIC_MD_EMITTED) return;
if (process.env.NODE_ENV !== 'production') {
return;
}
if (SEMANTIC_MD_EMITTED) {
return;
}
SEMANTIC_MD_EMITTED = true;
const outRoot = api.paths.absOutputPath;

View File

@@ -34,7 +34,7 @@ const WaveEffect: React.FC<WaveEffectProps> = (props) => {
const [varName] = genCssVar(rootPrefixCls, 'wave');
// ===================== Effect =====================
const [color, setWaveColor] = React.useState<string | null>(null);
const [waveColor, setWaveColor] = React.useState<string | null>(null);
const [borderRadius, setBorderRadius] = React.useState<number[]>([]);
const [left, setLeft] = React.useState(0);
const [top, setTop] = React.useState(0);
@@ -50,8 +50,8 @@ const WaveEffect: React.FC<WaveEffectProps> = (props) => {
borderRadius: borderRadius.map((radius) => `${radius}px`).join(' '),
};
if (color) {
waveStyle[varName('color')] = color;
if (waveColor) {
waveStyle[varName('color')] = waveColor;
}
function syncPos() {

View File

@@ -225,7 +225,7 @@ const InternalCompoundedButton = React.forwardRef<
const loadingOrDelay = useMemo<LoadingConfigType>(() => getLoadingConfig(loading), [loading]);
const [innerLoading, setLoading] = useState<boolean>(loadingOrDelay.loading);
const [innerLoading, setInnerLoading] = useState<boolean>(loadingOrDelay.loading);
const [hasTwoCNChar, setHasTwoCNChar] = useState<boolean>(false);
@@ -255,10 +255,10 @@ const InternalCompoundedButton = React.forwardRef<
if (loadingOrDelay.delay > 0) {
delayTimer = setTimeout(() => {
delayTimer = null;
setLoading(true);
setInnerLoading(true);
}, loadingOrDelay.delay);
} else {
setLoading(loadingOrDelay.loading);
setInnerLoading(loadingOrDelay.loading);
}
function cleanupTimer() {

View File

@@ -2,6 +2,7 @@ import type { CSSInterpolation, CSSObject } from '@ant-design/cssinjs';
import { unit } from '@ant-design/cssinjs';
import { genFocusStyle, resetIcon } from '../../style';
import { genNoMotionStyle } from '../../style/motion';
import type { GenerateStyle } from '../../theme/internal';
import { genStyleHooks, mergeToken } from '../../theme/internal';
import genGroupStyle from './group';
@@ -40,7 +41,7 @@ const genSharedButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token): CSS
transition: `all ${token.motionDurationMid} ${token.motionEaseInOut}`,
userSelect: 'none',
touchAction: 'manipulation',
...genNoMotionStyle(),
'&:disabled > *': {
pointerEvents: 'none',
},
@@ -80,7 +81,7 @@ const genSharedButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token): CSS
[`${componentCls}-loading-icon`]: {
transition: ['width', 'opacity', 'margin']
.map((transition) => `${transition} ${motionDurationSlow} ${motionEaseInOut}`)
.map((prop) => `${prop} ${motionDurationSlow} ${motionEaseInOut}`)
.join(','),
},

View File

@@ -99,7 +99,7 @@ const App: React.FC = () => {
const { styles } = useStyle({ test: true });
const [selectDate, setSelectDate] = React.useState<Dayjs>(() => dayjs());
const [panelDateDate, setPanelDate] = React.useState<Dayjs>(() => dayjs());
const [panelDate, setPanelDate] = React.useState<Dayjs>(() => dayjs());
const onPanelChange = (value: Dayjs, mode: CalendarProps<Dayjs>['mode']) => {
console.log(value.format('YYYY-MM-DD'), mode);
@@ -131,7 +131,7 @@ const App: React.FC = () => {
<span
className={clsx({
[styles.weekend]: isWeekend,
gray: !panelDateDate.isSame(date, 'month'),
gray: !panelDate.isSame(date, 'month'),
})}
>
{date.get('date')}

View File

@@ -44,12 +44,12 @@ const options: Option[] = [
];
const App: React.FC = () => {
const [placement, SetPlacement] = useState<'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight'>(
const [placement, setPlacement] = useState<'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight'>(
'topLeft',
);
const placementChange = (e: RadioChangeEvent) => {
SetPlacement(e.target.value);
setPlacement(e.target.value);
};
return (

View File

@@ -1,6 +1,7 @@
import { unit } from '@ant-design/cssinjs';
import { genFocusOutline, resetComponent } from '../../style';
import { genNoMotionStyle } from '../../style/motion';
import type { FullToken, GenerateStyle } from '../../theme/internal';
import { genStyleHooks, mergeToken } from '../../theme/internal';
@@ -99,6 +100,7 @@ export const genCheckboxStyle: GenerateStyle<CheckboxToken> = (token) => {
borderRadius: token.borderRadiusSM,
borderCollapse: 'separate',
transition: `all ${token.motionDurationSlow}`,
...genNoMotionStyle(),
// Checkmark
'&:after': {
@@ -116,6 +118,7 @@ export const genCheckboxStyle: GenerateStyle<CheckboxToken> = (token) => {
opacity: 0,
content: '""',
transition: `all ${token.motionDurationFast} ${token.motionEaseInBack}, opacity ${token.motionDurationFast}`,
...genNoMotionStyle(),
},
// Wrapper > Checkbox > input
@@ -173,6 +176,7 @@ export const genCheckboxStyle: GenerateStyle<CheckboxToken> = (token) => {
opacity: 1,
transform: 'rotate(45deg) scale(1) translate(-50%,-50%)',
transition: `all ${token.motionDurationMid} ${token.motionEaseOutBack} ${token.motionDurationFast}`,
...genNoMotionStyle(),
},
// Hover on checked checkbox directly

View File

@@ -225,11 +225,11 @@ const Page: React.FC = () => {
};
const App: React.FC = () => {
const [locale, setLocal] = useState<Locale>(enUS);
const [locale, setLocale] = useState<Locale>(enUS);
const changeLocale = (e: RadioChangeEvent) => {
const localeValue = e.target.value;
setLocal(localeValue);
setLocale(localeValue);
if (!localeValue) {
dayjs.locale('en');
} else {

View File

@@ -5,10 +5,10 @@ import { DatePicker, Radio } from 'antd';
const { RangePicker } = DatePicker;
const App: React.FC = () => {
const [placement, SetPlacement] = useState<DatePickerProps['placement']>('topLeft');
const [placement, setPlacement] = useState<DatePickerProps['placement']>('topLeft');
const placementChange = (e: RadioChangeEvent) => {
SetPlacement(e.target.value);
setPlacement(e.target.value);
};
return (

View File

@@ -88,205 +88,6 @@ Array [
exports[`renders components/drawer/demo/basic-right.tsx extend context correctly 2`] = `[]`;
exports[`renders components/drawer/demo/classNames.tsx extend context correctly 1`] = `
Array [
<div
class="ant-space ant-space-horizontal ant-space-align-center ant-space-gap-row-small ant-space-gap-col-small css-var-test-id"
>
<div
class="ant-space-item"
>
<button
class="ant-btn css-var-test-id ant-btn-primary ant-btn-color-primary ant-btn-variant-solid"
type="button"
>
<span>
Open
</span>
</button>
</div>
<div
class="ant-space-item"
>
<button
class="ant-btn css-var-test-id ant-btn-primary ant-btn-color-primary ant-btn-variant-solid"
type="button"
>
<span>
ConfigProvider
</span>
</button>
</div>
</div>,
<div
class="ant-drawer ant-drawer-right css-var-test-id ant-drawer-open ant-drawer-inline"
tabindex="-1"
>
<div
class="ant-drawer-mask acss-c0hvaj"
/>
<div
class="ant-drawer-content-wrapper"
style="width: 378px;"
>
<div
aria-labelledby="test-id"
aria-modal="true"
class="ant-drawer-section acss-10412ne"
role="dialog"
style="box-shadow: -10px 0 10px #666;"
>
<div
class="ant-drawer-header acss-1l0wu1y"
style="border-bottom: 1px solid rgb(22, 119, 255);"
>
<div
class="ant-drawer-header-title"
>
<button
aria-label="Close"
class="ant-drawer-close"
type="button"
>
<span
aria-label="close"
class="anticon anticon-close"
role="img"
>
<svg
aria-hidden="true"
data-icon="close"
fill="currentColor"
fill-rule="evenodd"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M799.86 166.31c.02 0 .04.02.08.06l57.69 57.7c.04.03.05.05.06.08a.12.12 0 010 .06c0 .03-.02.05-.06.09L569.93 512l287.7 287.7c.04.04.05.06.06.09a.12.12 0 010 .07c0 .02-.02.04-.06.08l-57.7 57.69c-.03.04-.05.05-.07.06a.12.12 0 01-.07 0c-.03 0-.05-.02-.09-.06L512 569.93l-287.7 287.7c-.04.04-.06.05-.09.06a.12.12 0 01-.07 0c-.02 0-.04-.02-.08-.06l-57.69-57.7c-.04-.03-.05-.05-.06-.07a.12.12 0 010-.07c0-.03.02-.05.06-.09L454.07 512l-287.7-287.7c-.04-.04-.05-.06-.06-.09a.12.12 0 010-.07c0-.02.02-.04.06-.08l57.7-57.69c.03-.04.05-.05.07-.06a.12.12 0 01.07 0c.03 0 .05.02.09.06L512 454.07l287.7-287.7c.04-.04.06-.05.09-.06a.12.12 0 01.07 0z"
/>
</svg>
</span>
</button>
<div
class="ant-drawer-title"
id="test-id"
>
Basic Drawer
</div>
</div>
</div>
<div
class="ant-drawer-body acss-pgpe64"
style="font-size: 16px;"
>
<p>
Some contents...
</p>
<p>
Some contents...
</p>
<p>
Some contents...
</p>
</div>
<div
class="ant-drawer-footer acss-r4s437"
style="border-top: 1px solid rgb(217, 217, 217);"
>
Footer
</div>
</div>
</div>
</div>,
<div
class="ant-drawer ant-drawer-right css-var-test-id ant-drawer-open ant-drawer-inline"
tabindex="-1"
>
<div
class="ant-drawer-mask acss-c0hvaj"
/>
<div
class="ant-drawer-content-wrapper"
style="width: 378px;"
>
<div
aria-labelledby="test-id"
aria-modal="true"
class="ant-drawer-section acss-10412ne"
role="dialog"
style="box-shadow: -10px 0 10px #666;"
>
<div
class="ant-drawer-header acss-1l0wu1y"
style="border-bottom: 1px solid rgb(22, 119, 255);"
>
<div
class="ant-drawer-header-title"
>
<button
aria-label="Close"
class="ant-drawer-close"
type="button"
>
<span
aria-label="close"
class="anticon anticon-close"
role="img"
>
<svg
aria-hidden="true"
data-icon="close"
fill="currentColor"
fill-rule="evenodd"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M799.86 166.31c.02 0 .04.02.08.06l57.69 57.7c.04.03.05.05.06.08a.12.12 0 010 .06c0 .03-.02.05-.06.09L569.93 512l287.7 287.7c.04.04.05.06.06.09a.12.12 0 010 .07c0 .02-.02.04-.06.08l-57.7 57.69c-.03.04-.05.05-.07.06a.12.12 0 01-.07 0c-.03 0-.05-.02-.09-.06L512 569.93l-287.7 287.7c-.04.04-.06.05-.09.06a.12.12 0 01-.07 0c-.02 0-.04-.02-.08-.06l-57.69-57.7c-.04-.03-.05-.05-.06-.07a.12.12 0 010-.07c0-.03.02-.05.06-.09L454.07 512l-287.7-287.7c-.04-.04-.05-.06-.06-.09a.12.12 0 010-.07c0-.02.02-.04.06-.08l57.7-57.69c.03-.04.05-.05.07-.06a.12.12 0 01.07 0c.03 0 .05.02.09.06L512 454.07l287.7-287.7c.04-.04.06-.05.09-.06a.12.12 0 01.07 0z"
/>
</svg>
</span>
</button>
<div
class="ant-drawer-title"
id="test-id"
>
Basic Drawer
</div>
</div>
</div>
<div
class="ant-drawer-body acss-pgpe64"
style="font-size: 16px;"
>
<p>
Some contents...
</p>
<p>
Some contents...
</p>
<p>
Some contents...
</p>
</div>
<div
class="ant-drawer-footer acss-r4s437"
style="border-top: 1px solid rgb(217, 217, 217);"
>
Footer
</div>
</div>
</div>
</div>,
]
`;
exports[`renders components/drawer/demo/classNames.tsx extend context correctly 2`] = `[]`;
exports[`renders components/drawer/demo/closable-placement.tsx extend context correctly 1`] = `
Array [
<button

View File

@@ -11,37 +11,6 @@ exports[`renders components/drawer/demo/basic-right.tsx correctly 1`] = `
</button>
`;
exports[`renders components/drawer/demo/classNames.tsx correctly 1`] = `
<div
class="ant-space ant-space-horizontal ant-space-align-center ant-space-gap-row-small ant-space-gap-col-small css-var-test-id"
>
<div
class="ant-space-item"
>
<button
class="ant-btn css-var-test-id ant-btn-primary ant-btn-color-primary ant-btn-variant-solid"
type="button"
>
<span>
Open
</span>
</button>
</div>
<div
class="ant-space-item"
>
<button
class="ant-btn css-var-test-id ant-btn-primary ant-btn-color-primary ant-btn-variant-solid"
type="button"
>
<span>
ConfigProvider
</span>
</button>
</div>
</div>
`;
exports[`renders components/drawer/demo/closable-placement.tsx correctly 1`] = `
<button
class="ant-btn css-var-test-id ant-btn-primary ant-btn-color-primary ant-btn-variant-solid"

View File

@@ -1,7 +0,0 @@
## zh-CN
通过 `classNames` 属性设置抽屉内部区域header、body、footer、mask、wrapper`className`
## en-US
Set the `className` of the build-in module (header, body, footer, mask, wrapper) of the drawer through the `classNames`.

View File

@@ -1,102 +0,0 @@
import React, { useState } from 'react';
import { Button, ConfigProvider, Drawer, Space } from 'antd';
import type { DrawerProps } from 'antd';
import { createStyles, useTheme } from 'antd-style';
const useStyle = createStyles(({ token }) => ({
'my-drawer-body': {
background: token.blue1,
},
'my-drawer-mask': {
boxShadow: `inset 0 0 15px #fff`,
},
'my-drawer-header': {
background: token.green1,
},
'my-drawer-footer': {
color: token.colorPrimary,
},
'my-drawer-section': {
borderInlineStart: '2px dotted #333',
},
}));
const App: React.FC = () => {
const [open, setOpen] = useState([false, false]);
const { styles } = useStyle();
const token = useTheme();
const toggleDrawer = (idx: number, target: boolean) => {
setOpen((p) => {
p[idx] = target;
return [...p];
});
};
const classNames: DrawerProps['classNames'] = {
body: styles['my-drawer-body'],
mask: styles['my-drawer-mask'],
header: styles['my-drawer-header'],
footer: styles['my-drawer-footer'],
section: styles['my-drawer-section'],
};
const drawerStyles: DrawerProps['styles'] = {
mask: {
backdropFilter: 'blur(10px)',
},
section: {
boxShadow: '-10px 0 10px #666',
},
header: {
borderBottom: `1px solid ${token.colorPrimary}`,
},
body: {
fontSize: token.fontSizeLG,
},
footer: {
borderTop: `1px solid ${token.colorBorder}`,
},
};
return (
<>
<Space>
<Button type="primary" onClick={() => toggleDrawer(0, true)}>
Open
</Button>
<Button type="primary" onClick={() => toggleDrawer(1, true)}>
ConfigProvider
</Button>
</Space>
<Drawer
title="Basic Drawer"
placement="right"
footer="Footer"
onClose={() => toggleDrawer(0, false)}
open={open[0]}
classNames={classNames}
styles={drawerStyles}
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Drawer>
<ConfigProvider drawer={{ classNames, styles: drawerStyles }}>
<Drawer
title="Basic Drawer"
placement="right"
footer="Footer"
onClose={() => toggleDrawer(1, false)}
open={open[1]}
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Drawer>
</ConfigProvider>
</>
);
};
export default App;

View File

@@ -54,8 +54,8 @@ const stylesFn: DrawerProps['styles'] = (info) => {
};
const App: React.FC = () => {
const [drawerOpen, setOpen] = useState(false);
const [drawerFnOpen, setFnOpen] = useState(false);
const [drawerOpen, setDrawerOpen] = useState(false);
const [drawerFnOpen, setDrawerFnOpen] = useState(false);
const sharedProps: DrawerProps = {
classNames,
@@ -65,7 +65,7 @@ const App: React.FC = () => {
const footer: React.ReactNode = (
<Flex gap="middle" justify="flex-end">
<Button
onClick={() => setFnOpen(false)}
onClick={() => setDrawerFnOpen(false)}
styles={{ root: { borderColor: '#ccc', color: '#171717', backgroundColor: '#fff' } }}
>
Cancel
@@ -73,7 +73,7 @@ const App: React.FC = () => {
<Button
type="primary"
styles={{ root: { backgroundColor: '#171717' } }}
onClick={() => setOpen(true)}
onClick={() => setDrawerOpen(true)}
>
Submit
</Button>
@@ -82,8 +82,8 @@ const App: React.FC = () => {
return (
<Flex gap="middle">
<Button onClick={() => setOpen(true)}>Open Style Drawer</Button>
<Button type="primary" onClick={() => setFnOpen(true)}>
<Button onClick={() => setDrawerOpen(true)}>Open Style Drawer</Button>
<Button type="primary" onClick={() => setDrawerFnOpen(true)}>
Open Function Drawer
</Button>
<Drawer
@@ -92,7 +92,7 @@ const App: React.FC = () => {
title="Custom Style Drawer"
styles={styles}
open={drawerOpen}
onClose={() => setOpen(false)}
onClose={() => setDrawerOpen(false)}
>
{sharedContent}
</Drawer>
@@ -103,7 +103,7 @@ const App: React.FC = () => {
styles={stylesFn}
mask={{ enabled: true, blur: true }}
open={drawerFnOpen}
onClose={() => setFnOpen(false)}
onClose={() => setDrawerFnOpen(false)}
>
{sharedContent}
</Drawer>

View File

@@ -34,7 +34,6 @@ A Drawer is a panel that is typically overlaid on top of a page and slides in fr
<code src="./demo/user-profile.tsx">Preview drawer</code>
<code src="./demo/multi-level-drawer.tsx">Multi-level drawer</code>
<code src="./demo/size.tsx">Preset size</code>
<code src="./demo/classNames.tsx">Customize className for build-in module</code>
<code src="./demo/mask.tsx">mask</code>
<code src="./demo/closable-placement.tsx" version="5.28.0">Closable placement</code>
<code src="./demo/style-class.tsx" version="6.0.0">Custom semantic dom styling</code>

View File

@@ -35,7 +35,6 @@ demo:
<code src="./demo/multi-level-drawer.tsx">多层抽屉</code>
<code src="./demo/size.tsx">预设宽度</code>
<code src="./demo/mask.tsx">遮罩</code>
<code src="./demo/classNames.tsx">自定义内部样式</code>
<code src="./demo/closable-placement.tsx" version="5.28.0">关闭按钮位置</code>
<code src="./demo/style-class.tsx" version="6.0.0">自定义语义结构的样式和类</code>
<code src="./demo/config-provider.tsx" debug>ConfigProvider</code>

View File

@@ -829,13 +829,13 @@ describe('Form', () => {
// https://github.com/ant-design/ant-design/issues/20813
it('should update help directly when provided', async () => {
const App: React.FC = () => {
const [message, updateMessage] = React.useState('');
const [message, setMessage] = React.useState('');
return (
<Form>
<Form.Item label="hello" help={message}>
<Input />
</Form.Item>
<Button onClick={() => updateMessage('bamboo')} />
<Button onClick={() => setMessage('bamboo')} />
</Form>
);
};

View File

@@ -14,10 +14,10 @@ const customizeRequiredMark = (label: React.ReactNode, { required }: { required:
const App: React.FC = () => {
const [form] = Form.useForm();
const [requiredMark, setRequiredMarkType] = useState<RequiredMark>('optional');
const [requiredMark, setRequiredMark] = useState<RequiredMark>('optional');
const onRequiredTypeChange: FormProps<any>['onValuesChange'] = ({ requiredMarkValue }) => {
setRequiredMarkType(requiredMarkValue);
setRequiredMark(requiredMarkValue);
};
return (

View File

@@ -3146,7 +3146,7 @@ Array [
style="width: 100px;"
>
<div
class="ant-select-content ant-select-content-has-value"
class="ant-select-content"
title=""
>
<input

View File

@@ -684,7 +684,7 @@ Array [
style="width:100px"
>
<div
class="ant-select-content ant-select-content-has-value"
class="ant-select-content"
title=""
>
<input

View File

@@ -39,39 +39,6 @@ exports[`renders components/modal/demo/button-props.tsx extend context correctly
exports[`renders components/modal/demo/button-props.tsx extend context correctly 2`] = `[]`;
exports[`renders components/modal/demo/classNames.tsx extend context correctly 1`] = `
<div
class="ant-space ant-space-horizontal ant-space-align-center ant-space-gap-row-small ant-space-gap-col-small css-var-test-id"
>
<div
class="ant-space-item"
>
<button
class="ant-btn css-var-test-id ant-btn-primary ant-btn-color-primary ant-btn-variant-solid"
type="button"
>
<span>
Open Modal
</span>
</button>
</div>
<div
class="ant-space-item"
>
<button
class="ant-btn css-var-test-id ant-btn-primary ant-btn-color-primary ant-btn-variant-solid"
type="button"
>
<span>
ConfigProvider
</span>
</button>
</div>
</div>
`;
exports[`renders components/modal/demo/classNames.tsx extend context correctly 2`] = `[]`;
exports[`renders components/modal/demo/component-token.tsx extend context correctly 1`] = `
<div
style="display: flex; flex-direction: column; row-gap: 16px;"

View File

@@ -33,37 +33,6 @@ exports[`renders components/modal/demo/button-props.tsx correctly 1`] = `
</button>
`;
exports[`renders components/modal/demo/classNames.tsx correctly 1`] = `
<div
class="ant-space ant-space-horizontal ant-space-align-center ant-space-gap-row-small ant-space-gap-col-small css-var-test-id"
>
<div
class="ant-space-item"
>
<button
class="ant-btn css-var-test-id ant-btn-primary ant-btn-color-primary ant-btn-variant-solid"
type="button"
>
<span>
Open Modal
</span>
</button>
</div>
<div
class="ant-space-item"
>
<button
class="ant-btn css-var-test-id ant-btn-primary ant-btn-color-primary ant-btn-variant-solid"
type="button"
>
<span>
ConfigProvider
</span>
</button>
</div>
</div>
`;
exports[`renders components/modal/demo/component-token.tsx correctly 1`] = `
<div
style="display:flex;flex-direction:column;row-gap:16px"

View File

@@ -1,7 +0,0 @@
## zh-CN
通过 `classNames` 属性设置弹窗内部区域header、body、footer、mask、wrapper`className`
## en-US
Set the className of the build-in module (header, body, footer, mask, wrapper) of the modal through the classNames property.

View File

@@ -1,110 +0,0 @@
import React, { useState } from 'react';
import { Button, ConfigProvider, Modal, Space } from 'antd';
import { createStyles, useTheme } from 'antd-style';
const useStyle = createStyles(({ token }) => ({
'my-modal-body': {
background: token.blue1,
padding: token.paddingSM,
},
'my-modal-mask': {
boxShadow: `inset 0 0 15px #fff`,
},
'my-modal-header': {
borderBottom: `1px dotted ${token.colorPrimary}`,
},
'my-modal-footer': {
color: token.colorPrimary,
},
'my-modal-content': {
border: '1px solid #333',
},
}));
const App: React.FC = () => {
const [isModalOpen, setIsModalOpen] = useState([false, false]);
const { styles } = useStyle();
const token = useTheme();
const toggleModal = (idx: number, target: boolean) => {
setIsModalOpen((p) => {
p[idx] = target;
return [...p];
});
};
const classNames = {
body: styles['my-modal-body'],
mask: styles['my-modal-mask'],
header: styles['my-modal-header'],
footer: styles['my-modal-footer'],
content: styles['my-modal-content'],
};
const modalStyles = {
header: {
borderInlineStart: `5px solid ${token.colorPrimary}`,
borderRadius: 0,
paddingInlineStart: 5,
},
body: {
boxShadow: 'inset 0 0 5px #999',
borderRadius: 5,
},
mask: {
backdropFilter: 'blur(10px)',
},
footer: {
borderTop: '1px solid #333',
},
content: {
boxShadow: '0 0 30px #999',
},
};
return (
<>
<Space>
<Button type="primary" onClick={() => toggleModal(0, true)}>
Open Modal
</Button>
<Button type="primary" onClick={() => toggleModal(1, true)}>
ConfigProvider
</Button>
</Space>
<Modal
title="Basic Modal"
open={isModalOpen[0]}
onOk={() => toggleModal(0, false)}
onCancel={() => toggleModal(0, false)}
footer="Footer"
classNames={classNames}
styles={modalStyles}
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Modal>
<ConfigProvider
modal={{
classNames,
styles: modalStyles,
}}
>
<Modal
title="Basic Modal"
open={isModalOpen[1]}
onOk={() => toggleModal(1, false)}
onCancel={() => toggleModal(1, false)}
footer="Footer"
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Modal>
</ConfigProvider>
</>
);
};
export default App;

View File

@@ -60,8 +60,8 @@ const stylesFn: ModalProps['styles'] = (info) => {
};
const App: React.FC = () => {
const [modalOpen, setOpen] = useState(false);
const [modalFnOpen, setFnOpen] = useState(false);
const [modalOpen, setModalOpen] = useState(false);
const [modalFnOpen, setModalFnOpen] = useState(false);
const sharedProps: ModalProps = {
centered: true,
@@ -71,7 +71,7 @@ const App: React.FC = () => {
const footer: React.ReactNode = (
<>
<Button
onClick={() => setFnOpen(false)}
onClick={() => setModalFnOpen(false)}
styles={{ root: { borderColor: '#ccc', color: '#171717', backgroundColor: '#fff' } }}
>
Cancel
@@ -79,7 +79,7 @@ const App: React.FC = () => {
<Button
type="primary"
styles={{ root: { backgroundColor: '#171717' } }}
onClick={() => setOpen(true)}
onClick={() => setModalOpen(true)}
>
Submit
</Button>
@@ -88,8 +88,8 @@ const App: React.FC = () => {
return (
<Flex gap="middle">
<Button onClick={() => setOpen(true)}>Open Style Modal</Button>
<Button type="primary" onClick={() => setFnOpen(true)}>
<Button onClick={() => setModalOpen(true)}>Open Style Modal</Button>
<Button type="primary" onClick={() => setModalFnOpen(true)}>
Open Function Modal
</Button>
<Modal
@@ -98,8 +98,8 @@ const App: React.FC = () => {
title="Custom Style Modal"
styles={styles}
open={modalOpen}
onOk={() => setOpen(false)}
onCancel={() => setOpen(false)}
onOk={() => setModalOpen(false)}
onCancel={() => setModalOpen(false)}
>
{sharedContent}
</Modal>
@@ -110,8 +110,8 @@ const App: React.FC = () => {
styles={stylesFn}
mask={{ enabled: true, blur: true }}
open={modalFnOpen}
onOk={() => setFnOpen(false)}
onCancel={() => setFnOpen(false)}
onOk={() => setModalFnOpen(false)}
onCancel={() => setModalFnOpen(false)}
>
{sharedContent}
</Modal>

View File

@@ -34,7 +34,6 @@ Additionally, if you need to show a simple confirmation dialog, you can use [`Ap
<code src="./demo/width.tsx">To customize the width of modal</code>
<code src="./demo/static-info.tsx">Static Method</code>
<code src="./demo/confirm.tsx">Static confirmation</code>
<code src="./demo/classNames.tsx">Customize className for build-in module</code>
<code src="./demo/confirm-router.tsx">destroy confirmation modal dialog</code>
<code src="./demo/style-class.tsx" version="6.0.0">Custom semantic dom styling</code>
<code src="./demo/nested.tsx" debug>Nested Modal</code>

View File

@@ -35,7 +35,6 @@ demo:
<code src="./demo/width.tsx">自定义模态的宽度</code>
<code src="./demo/static-info.tsx">静态方法</code>
<code src="./demo/confirm.tsx">静态确认对话框</code>
<code src="./demo/classNames.tsx">自定义内部模块 className</code>
<code src="./demo/confirm-router.tsx">销毁确认对话框</code>
<code src="./demo/style-class.tsx" version="6.0.0">自定义语义结构的样式和类</code>
<code src="./demo/nested.tsx" debug>嵌套弹框</code>

View File

@@ -148,7 +148,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
// Generate options
const mergedPageSizeOptions = React.useMemo(() => {
return pageSizeOptions ? pageSizeOptions.map((option) => Number(option)) : undefined;
return pageSizeOptions ? pageSizeOptions.map<number>(Number) : undefined;
}, [pageSizeOptions]);
// Render size changer

View File

@@ -147,6 +147,7 @@ const genLineStyle: GenerateStyle<ProgressToken> = (token) => {
borderRadius: token.lineBorderRadius,
position: 'relative',
width: '100%',
overflow: 'hidden',
},
[`&${componentCls}-status-active`]: {

View File

@@ -1778,7 +1778,9 @@ Array [
exports[`renders components/select/demo/custom-tag-render.tsx extend context correctly 2`] = `[]`;
exports[`renders components/select/demo/debug.tsx extend context correctly 1`] = `
Array [
<div
class="ant-flex css-var-test-id ant-flex-align-stretch ant-flex-gap-middle ant-flex-vertical"
>
<div
class="ant-space ant-space-horizontal ant-space-align-center ant-space-gap-row-small ant-space-gap-col-small css-var-test-id"
style="flex-wrap: wrap; width: 500px; position: relative; z-index: 1; border: 1px solid red; background-color: rgb(255, 255, 255);"
@@ -2210,9 +2212,184 @@ Array [
</span>
</button>
</div>
</div>,
<div
class="ant-space-item"
>
<div
class="ant-select ant-select-outlined css-var-test-id ant-select-css-var ant-select-single ant-select-show-arrow"
style="width: 120px;"
>
<div
class="ant-select-content"
title=" "
>
<input
aria-autocomplete="list"
aria-expanded="false"
aria-haspopup="listbox"
autocomplete="off"
class="ant-select-input"
id="test-id"
readonly=""
role="combobox"
type="search"
value=""
/>
</div>
<div
class="ant-select-suffix"
>
<span
aria-label="down"
class="anticon anticon-down"
role="img"
>
<svg
aria-hidden="true"
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</div>
</div>
<div
class="ant-select-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up css-var-test-id ant-select-css-var ant-select-dropdown-placement-bottomLeft"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; right: auto; bottom: auto; box-sizing: border-box;"
>
<div>
<div
id="test-id_list"
role="listbox"
style="height: 0px; width: 0px; overflow: hidden;"
>
<div
aria-label="Jack"
aria-selected="false"
id="test-id_list_0"
role="option"
>
jack
</div>
<div
aria-label="Lucy"
aria-selected="false"
id="test-id_list_1"
role="option"
>
lucy
</div>
</div>
<div
class="rc-virtual-list"
style="position: relative;"
>
<div
class="rc-virtual-list-holder"
style="max-height: 256px; overflow-y: auto; overflow-anchor: none;"
>
<div>
<div
class="rc-virtual-list-holder-inner"
style="display: flex; flex-direction: column;"
>
<div
class="ant-select-item ant-select-item-option ant-select-item-option-active"
title="Jack"
>
<div
class="ant-select-item-option-content"
>
Jack
</div>
<span
aria-hidden="true"
class="ant-select-item-option-state"
style="user-select: none;"
unselectable="on"
/>
</div>
<div
class="ant-select-item ant-select-item-option"
title="Lucy"
>
<div
class="ant-select-item-option-content"
>
Lucy
</div>
<span
aria-hidden="true"
class="ant-select-item-option-state"
style="user-select: none;"
unselectable="on"
/>
</div>
<div
class="ant-select-item ant-select-item-option ant-select-item-option-disabled"
title="Disabled"
>
<div
class="ant-select-item-option-content"
>
Disabled
</div>
<span
aria-hidden="true"
class="ant-select-item-option-state"
style="user-select: none;"
unselectable="on"
/>
</div>
<div
class="ant-select-item ant-select-item-option"
title="yiminghe"
>
<div
class="ant-select-item-option-content"
>
yiminghe
</div>
<span
aria-hidden="true"
class="ant-select-item-option-state"
style="user-select: none;"
unselectable="on"
/>
</div>
<div
class="ant-select-item ant-select-item-option"
title="I am super super long!"
>
<div
class="ant-select-item-option-content"
>
I am super super long!
</div>
<span
aria-hidden="true"
class="ant-select-item-option-state"
style="user-select: none;"
unselectable="on"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
style="width: 200px; margin-top: 24px;"
style="width: 200px;"
>
<div
class="ant-select ant-select-outlined css-var-test-id ant-select-css-var ant-select-multiple ant-select-show-arrow ant-select-show-search"
@@ -2379,8 +2556,113 @@ Array [
</div>
</div>
</div>
</div>,
]
</div>
<div
class="ant-select ant-select-outlined css-var-test-id ant-select-css-var ant-select-single ant-select-show-arrow"
>
<div
class="ant-select-content"
title=""
>
<input
aria-autocomplete="list"
aria-expanded="false"
aria-haspopup="listbox"
autocomplete="off"
class="ant-select-input"
id="test-id"
readonly=""
role="combobox"
type="search"
value=""
/>
</div>
<div
class="ant-select-suffix"
>
<span
aria-label="down"
class="anticon anticon-down"
role="img"
>
<svg
aria-hidden="true"
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</div>
</div>
<div
class="ant-select-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up css-var-test-id ant-select-css-var ant-select-dropdown-empty ant-select-dropdown-placement-bottomLeft"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; right: auto; bottom: auto; box-sizing: border-box;"
>
<div>
<div
class="ant-select-item-empty"
id="test-id_list"
role="listbox"
>
<div
class="css-var-test-id ant-empty ant-empty-normal ant-empty-small"
>
<div
class="ant-empty-image"
>
<svg
height="41"
viewBox="0 0 64 41"
width="64"
xmlns="http://www.w3.org/2000/svg"
>
<title>
No data
</title>
<g
fill="none"
fill-rule="evenodd"
transform="translate(0 1)"
>
<ellipse
cx="32"
cy="33"
fill="#f5f5f5"
rx="32"
ry="7"
/>
<g
fill-rule="nonzero"
stroke="#d9d9d9"
>
<path
d="M55 12.8 44.9 1.3Q44 0 42.9 0H21.1q-1.2 0-2 1.3L9 12.8V22h46z"
/>
<path
d="M41.6 16c0-1.7 1-3 2.2-3H55v18.1c0 2.2-1.3 3.9-3 3.9H12c-1.7 0-3-1.7-3-3.9V13h11.2c1.2 0 2.2 1.3 2.2 3s1 2.9 2.2 2.9h14.8c1.2 0 2.2-1.4 2.2-3"
fill="#fafafa"
/>
</g>
</g>
</svg>
</div>
<div
class="ant-empty-description"
>
No data
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`renders components/select/demo/debug.tsx extend context correctly 2`] = `[]`;

View File

@@ -741,7 +741,9 @@ exports[`renders components/select/demo/custom-tag-render.tsx correctly 1`] = `
`;
exports[`renders components/select/demo/debug.tsx correctly 1`] = `
Array [
<div
class="ant-flex css-var-test-id ant-flex-align-stretch ant-flex-gap-middle ant-flex-vertical"
>
<div
class="ant-space ant-space-horizontal ant-space-align-center ant-space-gap-row-small ant-space-gap-col-small css-var-test-id"
style="flex-wrap:wrap;width:500px;position:relative;z-index:1;border:1px solid red;background-color:#fff"
@@ -924,9 +926,58 @@ Array [
</span>
</button>
</div>
</div>,
<div
class="ant-space-item"
>
<div
class="ant-select ant-select-outlined css-var-test-id ant-select-css-var ant-select-single ant-select-show-arrow"
style="width:120px"
>
<div
class="ant-select-content"
title=" "
>
<input
aria-autocomplete="list"
aria-expanded="false"
aria-haspopup="listbox"
autocomplete="off"
class="ant-select-input"
id="test-id"
readonly=""
role="combobox"
type="search"
value=""
/>
</div>
<div
class="ant-select-suffix"
>
<span
aria-label="down"
class="anticon anticon-down"
role="img"
>
<svg
aria-hidden="true"
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</div>
</div>
</div>
</div>
<div
style="width:200px;margin-top:24px"
style="width:200px"
>
<div
class="ant-select ant-select-outlined css-var-test-id ant-select-css-var ant-select-multiple ant-select-show-arrow ant-select-show-search"
@@ -1018,8 +1069,52 @@ Array [
</span>
</div>
</div>
</div>,
]
</div>
<div
class="ant-select ant-select-outlined css-var-test-id ant-select-css-var ant-select-single ant-select-show-arrow"
>
<div
class="ant-select-content"
title=""
>
<input
aria-autocomplete="list"
aria-expanded="false"
aria-haspopup="listbox"
autocomplete="off"
class="ant-select-input"
id="test-id"
readonly=""
role="combobox"
type="search"
value=""
/>
</div>
<div
class="ant-select-suffix"
>
<span
aria-label="down"
class="anticon anticon-down"
role="img"
>
<svg
aria-hidden="true"
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</div>
</div>
</div>
`;
exports[`renders components/select/demo/debug-flip-shift.tsx correctly 1`] = `

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { Button, Input, Select, Space } from 'antd';
import { Button, Flex, Input, Select, Space } from 'antd';
const style: React.CSSProperties = {
width: 500,
@@ -14,7 +14,7 @@ const handleChange = (value: string | string[]) => {
};
const App: React.FC = () => (
<>
<Flex vertical gap="middle">
<Space style={style} wrap>
<Input style={{ width: 100 }} value="222" />
<Select
@@ -47,8 +47,21 @@ const App: React.FC = () => (
/>
<span className="debug-align">AntDesign</span>
<Button>222</Button>
{/* https://github.com/ant-design/ant-design/issues/56960 */}
<Select
style={{ width: 120 }}
defaultValue=" "
placeholder="Please select"
options={[
{ value: 'jack', label: 'Jack' },
{ value: 'lucy', label: 'Lucy' },
{ value: 'disabled', disabled: true, label: 'Disabled' },
{ value: 'Yiminghe', label: 'yiminghe' },
{ value: 'long', label: 'I am super super long!' },
]}
/>
</Space>
<div style={{ width: 200, marginTop: 24 }}>
<div style={{ width: 200 }}>
{/* https://github.com/ant-design/ant-design/issues/54179 */}
<Select
mode="multiple"
@@ -62,7 +75,9 @@ const App: React.FC = () => (
]}
/>
</div>
</>
<Select defaultValue="" />
</Flex>
);
export default App;

View File

@@ -15,12 +15,12 @@ const randomOptions = (count?: number) => {
};
const App: React.FC = () => {
const [placement, SetPlacement] = useState<SelectCommonPlacement>('topLeft');
const [placement, setPlacement] = useState<SelectCommonPlacement>('topLeft');
const [open, setOpen] = useState(false);
const [options, setOptions] = useState(() => randomOptions(3));
const placementChange = (e: RadioChangeEvent) => {
SetPlacement(e.target.value);
setPlacement(e.target.value);
};
return (

View File

@@ -5,10 +5,10 @@ import { Radio, Select } from 'antd';
type SelectCommonPlacement = SelectProps['placement'];
const App: React.FC = () => {
const [placement, SetPlacement] = useState<SelectCommonPlacement>('topLeft');
const [placement, setPlacement] = useState<SelectCommonPlacement>('topLeft');
const placementChange = (e: RadioChangeEvent) => {
SetPlacement(e.target.value);
setPlacement(e.target.value);
};
return (

View File

@@ -3,7 +3,7 @@ import type { StepsProps } from 'antd';
import { Button, Space, Steps } from 'antd';
const App: React.FC = () => {
const [percent, setPercentage] = useState<number | undefined>(0);
const [percent, setPercent] = useState<number | undefined>(0);
const [current, setCurrent] = useState(1);
const [status, setStatus] = useState<StepsProps['status']>('process');
const content = 'This is a content.';
@@ -25,10 +25,10 @@ const App: React.FC = () => {
return (
<>
<Space.Compact block>
<Button onClick={() => setPercentage(undefined)}>Percentage to undefined</Button>
<Button onClick={() => setPercent(undefined)}>Percentage to undefined</Button>
<Button
onClick={() =>
setPercentage((prev) => {
setPercent((prev) => {
const next = (prev ?? 0) + 10;
return next > 100 ? 0 : next;
})

View File

@@ -22,6 +22,7 @@ import {
slideUpIn,
slideUpOut,
} from './slide';
import { genNoMotionStyle } from './util';
import {
initZoomMotion,
zoomBigIn,
@@ -42,6 +43,7 @@ export {
fadeIn,
fadeOut,
genCollapseMotion,
genNoMotionStyle,
initFadeMotion,
initMoveMotion,
initSlideMotion,

View File

@@ -0,0 +1,10 @@
import type { CSSObject } from '@ant-design/cssinjs';
export const genNoMotionStyle = (): CSSObject => {
return {
'@media (prefers-reduced-motion: reduce)': {
transition: 'none',
animation: 'none',
},
};
};

View File

@@ -162,6 +162,7 @@ type ZoomMotionTypes =
| 'zoom-right'
| 'zoom-up'
| 'zoom-down';
const zoomMotion: Record<ZoomMotionTypes, { inKeyframes: Keyframes; outKeyframes: Keyframes }> = {
zoom: {
inKeyframes: zoomIn,

View File

@@ -3,6 +3,7 @@ import { unit } from '@ant-design/cssinjs';
import { FastColor } from '@ant-design/fast-color';
import { genFocusStyle, resetComponent } from '../../style';
import { genNoMotionStyle } from '../../style/motion';
import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';
import { genStyleHooks, mergeToken } from '../../theme/internal';
@@ -208,6 +209,7 @@ const genSwitchHandleStyle: GenerateStyle<SwitchToken, CSSObject> = (token) => {
width: handleSize,
height: handleSize,
transition: `all ${token.switchDuration} ease-in-out`,
...genNoMotionStyle(),
'&::before': {
position: 'absolute',
@@ -220,6 +222,7 @@ const genSwitchHandleStyle: GenerateStyle<SwitchToken, CSSObject> = (token) => {
boxShadow: handleShadow,
transition: `all ${token.switchDuration} ease-in-out`,
content: '""',
...genNoMotionStyle(),
},
},
@@ -270,7 +273,7 @@ const genSwitchInnerStyle: GenerateStyle<SwitchToken, CSSObject> = (token) => {
transition: [`padding-inline-start`, `padding-inline-end`]
.map((prop) => `${prop} ${switchDuration} ease-in-out`)
.join(', '),
...genNoMotionStyle(),
[`${switchInnerCls}-checked, ${switchInnerCls}-unchecked`]: {
display: 'block',
color: token.colorTextLightSolid,
@@ -280,6 +283,7 @@ const genSwitchInnerStyle: GenerateStyle<SwitchToken, CSSObject> = (token) => {
transition: [`margin-inline-start`, `margin-inline-end`]
.map((prop) => `${prop} ${switchDuration} ease-in-out`)
.join(', '),
...genNoMotionStyle(),
},
[`${switchInnerCls}-checked`]: {
@@ -347,7 +351,7 @@ const genSwitchStyle = (token: SwitchToken): CSSObject => {
cursor: 'pointer',
transition: `all ${token.motionDurationMid}`,
userSelect: 'none',
...genNoMotionStyle(),
[`&:hover:not(${componentCls}-disabled)`]: {
background: token.colorTextTertiary,
},

View File

@@ -2010,7 +2010,7 @@ describe('Table.filter', () => {
];
const App: React.FC = () => {
const [ddd, setData] = React.useState<Array<DataType>>([
const [data, setData] = React.useState<Array<DataType>>([
{
key: '1',
name: 'John Brown',
@@ -2089,7 +2089,7 @@ describe('Table.filter', () => {
<span className="rest-btn" onClick={handleClick}>
refresh
</span>
<Table columns={cs} dataSource={ddd} />
<Table columns={cs} dataSource={data} />
</div>
);
};

View File

@@ -295,7 +295,7 @@ const FilterDropdown = <RecordType extends AnyObject = AnyObject>(
setSearchValue('');
if (filterResetToDefaultFilteredValue) {
setFilteredKeysSync((defaultFilteredValue || []).map((key) => String(key)));
setFilteredKeysSync((defaultFilteredValue || []).map<string>(String));
} else {
setFilteredKeysSync([]);
}
@@ -330,7 +330,7 @@ const FilterDropdown = <RecordType extends AnyObject = AnyObject>(
const onCheckAll = (e: CheckboxChangeEvent) => {
if (e.target.checked) {
const allFilterKeys = flattenKeys(column?.filters).map((key) => String(key));
const allFilterKeys = flattenKeys(column?.filters).map<string>(String);
setFilteredKeysSync(allFilterKeys);
} else {
setFilteredKeysSync([]);
@@ -349,11 +349,12 @@ const FilterDropdown = <RecordType extends AnyObject = AnyObject>(
}
return item;
});
const getFilterData = (node: FilterTreeDataNode): TreeColumnFilterItem => ({
...node,
text: node.title,
value: node.key,
children: node.children?.map((item) => getFilterData(item)) || [],
children: node.children?.map<TreeColumnFilterItem>(getFilterData) || [],
});
let dropdownContent: React.ReactNode;
@@ -491,13 +492,8 @@ const FilterDropdown = <RecordType extends AnyObject = AnyObject>(
const getResetDisabled = () => {
if (filterResetToDefaultFilteredValue) {
return isEqual(
(defaultFilteredValue || []).map((key) => String(key)),
selectedKeys,
true,
);
return isEqual((defaultFilteredValue || []).map<string>(String), selectedKeys, true);
}
return selectedKeys.length === 0;
};

View File

@@ -275,7 +275,7 @@ const useSelection = <RecordType extends AnyObject = AnyObject>(
const triggerSingleSelection = useCallback(
(key: Key, selected: boolean, keys: Key[], event: Event) => {
if (onSelect) {
const rows = keys.map((k) => getRecordByKey(k));
const rows = keys.map<RecordType>(getRecordByKey);
onSelect(getRecordByKey(key), selected, rows, event);
}
@@ -426,8 +426,8 @@ const useSelection = <RecordType extends AnyObject = AnyObject>(
onSelectAll?.(
!checkedCurrentAll,
keys.map((k) => getRecordByKey(k)),
changeKeys.map((k) => getRecordByKey(k)),
keys.map<RecordType>(getRecordByKey),
changeKeys.map<RecordType>(getRecordByKey),
);
setSelectedKeys(keys, 'all');
@@ -584,8 +584,8 @@ const useSelection = <RecordType extends AnyObject = AnyObject>(
onSelectMultiple?.(
!checked,
keys.map((recordKey) => getRecordByKey(recordKey)),
changedKeys.map((recordKey) => getRecordByKey(recordKey)),
keys.map<RecordType>(getRecordByKey),
changedKeys.map<RecordType>(getRecordByKey),
);
setSelectedKeys(keys, 'multiple');

View File

@@ -128,7 +128,7 @@ describe('Tour', () => {
it('button props onClick', () => {
const App: React.FC = () => {
const coverBtnRef = useRef<HTMLButtonElement>(null);
const [btnName, steBtnName] = React.useState<string>('defaultBtn');
const [btnName, setBtnName] = React.useState<string>('defaultBtn');
return (
<>
<span id="btnName">{btnName}</span>
@@ -143,17 +143,17 @@ describe('Tour', () => {
description: '',
target: () => coverBtnRef.current!,
nextButtonProps: {
onClick: () => steBtnName('nextButton'),
onClick: () => setBtnName('nextButton'),
},
},
{
title: '',
target: () => coverBtnRef.current!,
prevButtonProps: {
onClick: () => steBtnName('prevButton'),
onClick: () => setBtnName('prevButton'),
},
nextButtonProps: {
onClick: () => steBtnName('finishButton'),
onClick: () => setBtnName('finishButton'),
},
},
]}

View File

@@ -229,6 +229,7 @@ const Transfer = <RecordType extends TransferItem = TransferItem>(
const [hashId, cssVarCls] = useStyle(prefixCls);
const mergedActions = actions || operations || [];
const isRtl = dir === 'rtl';
// Fill record with `key`
const [mergedDataSource, leftDataSource, rightDataSource] = useData(
@@ -334,7 +335,7 @@ const Transfer = <RecordType extends TransferItem = TransferItem>(
const onItemSelectAll = (
direction: TransferDirection,
keys: string[],
keys: TransferKey[],
checkAll: boolean | 'replace',
) => {
setStateKeys(direction, (prevKeys) => {
@@ -355,13 +356,15 @@ const Transfer = <RecordType extends TransferItem = TransferItem>(
setPrevSelectedIndex(direction, null);
};
const onLeftItemSelectAll = (keys: string[], checkAll: boolean) => {
onItemSelectAll('left', keys, checkAll);
};
const onLeftItemSelectAll: TransferListProps<KeyWise<RecordType>>['onItemSelectAll'] = (
keys,
checkAll,
) => onItemSelectAll('left', keys, checkAll);
const onRightItemSelectAll = (keys: string[], checkAll: boolean) => {
onItemSelectAll('right', keys, checkAll);
};
const onRightItemSelectAll: TransferListProps<KeyWise<RecordType>>['onItemSelectAll'] = (
keys,
checkAll,
) => onItemSelectAll('right', keys, checkAll);
const leftFilter = (e: ChangeEvent<HTMLInputElement>) => onSearch?.('left', e.target.value);
@@ -407,15 +410,15 @@ const Transfer = <RecordType extends TransferItem = TransferItem>(
multiple?: boolean,
) => {
const isLeftDirection = direction === 'left';
const holder = [...(isLeftDirection ? sourceSelectedKeys : targetSelectedKeys)];
const holder = isLeftDirection ? sourceSelectedKeys : targetSelectedKeys;
const holderSet = new Set(holder);
const data = [...(isLeftDirection ? leftDataSource : rightDataSource)].filter(
(item) => !item?.disabled,
const data: KeyWise<RecordType>[] = (isLeftDirection ? leftDataSource : rightDataSource).filter(
(item): item is KeyWise<RecordType> => !item.disabled,
);
const currentSelectedIndex = data.findIndex((item) => item.key === selectedKey);
// multiple select by hold down the shift key
if (multiple && holder.length > 0) {
handleMultipleSelect(direction, data as any, holderSet, currentSelectedIndex);
handleMultipleSelect(direction, data, holderSet, currentSelectedIndex);
} else {
handleSingleSelect(direction, holderSet, selectedKey, checked, currentSelectedIndex);
}
@@ -434,13 +437,11 @@ const Transfer = <RecordType extends TransferItem = TransferItem>(
onItemSelect('left', selectedKey, checked, e?.shiftKey);
};
const onRightItemSelect = (
selectedKey: TransferKey,
checked: boolean,
e?: React.MouseEvent<Element, MouseEvent>,
) => {
onItemSelect('right', selectedKey, checked, e?.shiftKey);
};
const onRightItemSelect: TransferListProps<KeyWise<RecordType>>['onItemSelect'] = (
selectedKey,
checked,
e,
) => onItemSelect('right', selectedKey, checked, e?.shiftKey);
const onRightItemRemove = (keys: TransferKey[]) => {
setStateKeys('right', []);
@@ -493,7 +494,7 @@ const Transfer = <RecordType extends TransferItem = TransferItem>(
{
[`${prefixCls}-disabled`]: mergedDisabled,
[`${prefixCls}-customize-list`]: !!children,
[`${prefixCls}-rtl`]: dir === 'rtl',
[`${prefixCls}-rtl`]: isRtl,
},
getStatusClassNames(prefixCls, mergedStatus, hasFeedback),
contextClassName,
@@ -543,14 +544,14 @@ const Transfer = <RecordType extends TransferItem = TransferItem>(
handleFilter={leftFilter}
handleClear={handleLeftClear}
onItemSelect={onLeftItemSelect}
onItemSelectAll={onLeftItemSelectAll as any}
onItemSelectAll={onLeftItemSelectAll}
render={render}
showSearch={showSearch}
renderList={children as any}
footer={footer as any}
onScroll={handleLeftScroll}
disabled={mergedDisabled}
direction={dir === 'rtl' ? 'right' : 'left'}
direction={isRtl ? 'right' : 'left'}
showSelectAll={showSelectAll}
selectAllLabel={selectAllLabels[0]}
pagination={mergedPagination}
@@ -584,7 +585,7 @@ const Transfer = <RecordType extends TransferItem = TransferItem>(
handleFilter={rightFilter}
handleClear={handleRightClear}
onItemSelect={onRightItemSelect}
onItemSelectAll={onRightItemSelectAll as any}
onItemSelectAll={onRightItemSelectAll}
onItemRemove={onRightItemRemove}
render={render}
showSearch={showSearch}
@@ -592,7 +593,7 @@ const Transfer = <RecordType extends TransferItem = TransferItem>(
footer={footer as any}
onScroll={handleRightScroll}
disabled={mergedDisabled}
direction={dir === 'rtl' ? 'left' : 'right'}
direction={isRtl ? 'left' : 'right'}
showSelectAll={showSelectAll}
selectAllLabel={selectAllLabels[1]}
showRemove={oneWay}

View File

@@ -37,10 +37,10 @@ const treeData = [
},
];
const App: React.FC = () => {
const [placement, SetPlacement] = useState<SelectCommonPlacement>('topLeft');
const [placement, setPlacement] = useState<SelectCommonPlacement>('topLeft');
const placementChange = (e: RadioChangeEvent) => {
SetPlacement(e.target.value);
setPlacement(e.target.value);
};
return (

View File

@@ -644,12 +644,12 @@ describe('Typography.Ellipsis', () => {
it('Switch locale', async () => {
const ref = React.createRef<HTMLElement>();
const App = () => {
const [locale, setLocal] = React.useState<Locale>();
const [locale, setLocale] = React.useState<Locale>();
return (
<ConfigProvider locale={locale}>
<div>
<button type="button" onClick={() => setLocal(zhCN)}>
<button type="button" onClick={() => setLocale(zhCN)}>
zhcn
</button>
<Base

View File

@@ -21,13 +21,13 @@ export type AppendWatermark = (
container: HTMLElement,
) => void;
export default function useWatermark(
function useWatermark(
markStyle: React.CSSProperties,
onRemove?: () => void,
): [
appendWatermark: AppendWatermark,
removeWatermark: (container: HTMLElement) => void,
isWatermarkEle: (ele: Node) => boolean,
isWatermarkEle: (ele: Node, index?: number) => boolean,
] {
const watermarkMap = React.useRef(new Map<HTMLElement, HTMLDivElement>());
const onRemoveEvent = useEvent(onRemove);
@@ -79,5 +79,7 @@ export default function useWatermark(
const isWatermarkEle = (ele: any) => Array.from(watermarkMap.current.values()).includes(ele);
return [appendWatermark, removeWatermark, isWatermarkEle];
return [appendWatermark, removeWatermark, isWatermarkEle] as const;
}
export default useWatermark;

View File

@@ -15,11 +15,14 @@ export function getPixelRatio() {
}
/** Whether to re-render the watermark */
export const reRendering = (mutation: MutationRecord, isWatermarkEle: (ele: Node) => boolean) => {
export const reRendering = (
mutation: MutationRecord,
isWatermarkEle: (ele: Node, index?: number) => boolean,
) => {
let flag = false;
// Whether to delete the watermark node
if (mutation.removedNodes.length) {
flag = Array.from<Node>(mutation.removedNodes).some((node) => isWatermarkEle(node));
flag = Array.from<Node>(mutation.removedNodes).some(isWatermarkEle);
}
// Whether the watermark dom property value has been modified
if (mutation.type === 'attributes' && isWatermarkEle(mutation.target)) {

View File

@@ -65,7 +65,6 @@ export default antfu(
'react-hooks/refs': 'off',
'react/no-implicit-key': 'off',
'react-naming-convention/ref-name': 'off',
'react-naming-convention/use-state': 'off',
},
},
{

View File

@@ -136,7 +136,7 @@
"@rc-component/rate": "~1.0.1",
"@rc-component/resize-observer": "^1.1.1",
"@rc-component/segmented": "~1.3.0",
"@rc-component/select": "~1.6.5",
"@rc-component/select": "~1.6.10",
"@rc-component/slider": "~1.0.1",
"@rc-component/steps": "~1.2.2",
"@rc-component/switch": "~1.0.3",
@@ -173,7 +173,7 @@
"@emotion/css": "^11.13.5",
"@emotion/react": "^11.14.0",
"@emotion/server": "^11.11.0",
"@eslint-react/eslint-plugin": "2.12.4",
"@eslint-react/eslint-plugin": "2.13.0",
"@ianvs/prettier-plugin-sort-imports": "^4.7.0",
"@inquirer/prompts": "^8.0.2",
"@madccc/duplicate-package-checker-webpack-plugin": "^1.0.0",

View File

@@ -27,9 +27,15 @@ describe('site test', () => {
const html: string = await res.text();
const root = new DOMParser().parseFromString(html, 'text/html');
function getTextContent(node: any): string {
if (!node) return '';
if (typeof node.textContent === 'string') return node.textContent.trim();
if (typeof node.innerText === 'string') return node.innerText.trim();
if (!node) {
return '';
}
if (typeof node.textContent === 'string') {
return node.textContent.trim();
}
if (typeof node.innerText === 'string') {
return node.innerText.trim();
}
// Fallback: recursively get text from children
if (node.children && node.children.length > 0) {
return Array.from(node.children)
@@ -44,8 +50,10 @@ describe('site test', () => {
return {
length: list.length,
text: () => {
if (list.length === 0) return '';
return list.map((n) => getTextContent(n)).join('');
if (list.length === 0) {
return '';
}
return list.map<string>(getTextContent).join('');
},
first: () => wrap(list.slice(0, 1)),
};