mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-15 22:09:21 +08:00
Compare commits
23 Commits
typography
...
get-prop-s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db7d4bf896 | ||
|
|
7c7abd885d | ||
|
|
6ba9b9b72b | ||
|
|
e990f58cc8 | ||
|
|
b32b2dc594 | ||
|
|
90caca416c | ||
|
|
95f032bc3d | ||
|
|
5dfaf14db7 | ||
|
|
5ad1ecd723 | ||
|
|
9b03f7ae6c | ||
|
|
852ed686d2 | ||
|
|
47159dd3b2 | ||
|
|
70f564603b | ||
|
|
cd3f333892 | ||
|
|
d534dd8b17 | ||
|
|
d271104014 | ||
|
|
c9a727c599 | ||
|
|
2c2773a8cc | ||
|
|
6915342818 | ||
|
|
956c1d1b51 | ||
|
|
4490fc6a4e | ||
|
|
6e993d2ef8 | ||
|
|
a46cd9d8ba |
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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 键
|
||||
|
||||
@@ -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');
|
||||
// 匹配快照 key:exports[`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;
|
||||
|
||||
@@ -99,5 +99,12 @@ describe('type', () => {
|
||||
const bamboo: BambooType = 123;
|
||||
expect(bamboo).toBeTruthy();
|
||||
});
|
||||
it('Type is return', () => {
|
||||
interface Props {
|
||||
classNames?: { root?: string } | ((props: any) => { root?: string });
|
||||
}
|
||||
const result: GetProp<Props, 'classNames', 'Return'> = { root: '123' };
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
12
components/_util/fallbackProp.ts
Normal file
12
components/_util/fallbackProp.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Search for the first non-undefined value in the arguments and return it.
|
||||
*
|
||||
* ```js
|
||||
* const mergedIcon = fallbackProp(propIcon, contextIcon, defaultIcon);
|
||||
* ```
|
||||
*
|
||||
* Note: it is different from `??` operator which skips null
|
||||
*/
|
||||
export default function fallbackProp<T>(...args: T[]): T | undefined {
|
||||
return args.find((arg) => arg !== undefined);
|
||||
}
|
||||
@@ -55,7 +55,12 @@ export type GetProps<T extends React.ComponentType<any> | object> =
|
||||
export type GetProp<
|
||||
T extends React.ComponentType<any> | object,
|
||||
PropName extends keyof GetProps<T>,
|
||||
> = NonNullable<GetProps<T>[PropName]>;
|
||||
Type extends 'Default' | 'Return' = 'Default',
|
||||
> = Type extends 'Default'
|
||||
? NonNullable<GetProps<T>[PropName]>
|
||||
: Type extends 'Return'
|
||||
? ReturnType<Extract<NonNullable<GetProps<T>[PropName]>, (...args: any[]) => unknown>>
|
||||
: never;
|
||||
|
||||
type ReactRefComponent<Props extends { ref?: React.Ref<any> | string }> = (
|
||||
props: Props,
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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(','),
|
||||
},
|
||||
|
||||
|
||||
@@ -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')}
|
||||
|
||||
@@ -907,4 +907,115 @@ describe('Cascader', () => {
|
||||
expect(screen.getAllByText('bamboo').length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('clearIcon', () => {
|
||||
it('should support custom clearIcon', () => {
|
||||
render(
|
||||
<Cascader
|
||||
open
|
||||
allowClear={{ clearIcon: <div>bamboo</div> }}
|
||||
options={options}
|
||||
defaultValue={['zhejiang', 'hangzhou']}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getAllByText('bamboo').length).toBe(1);
|
||||
});
|
||||
|
||||
it('should support ConfigProvider clearIcon', () => {
|
||||
render(
|
||||
<ConfigProvider cascader={{ clearIcon: <div>foobar</div> }}>
|
||||
<Cascader options={options} defaultValue={['zhejiang', 'hangzhou']} allowClear />
|
||||
</ConfigProvider>,
|
||||
);
|
||||
expect(screen.getAllByText('foobar').length).toBe(1);
|
||||
});
|
||||
|
||||
it('should prefer prop clearIcon over ConfigProvider clearIcon', () => {
|
||||
render(
|
||||
<ConfigProvider cascader={{ clearIcon: <div>foobar</div> }}>
|
||||
<Cascader
|
||||
allowClear={{ clearIcon: <div>bamboo</div> }}
|
||||
options={options}
|
||||
defaultValue={['zhejiang', 'hangzhou']}
|
||||
/>
|
||||
</ConfigProvider>,
|
||||
);
|
||||
expect(screen.getAllByText('bamboo').length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('removeIcon', () => {
|
||||
it('should support custom removeIcon', () => {
|
||||
render(
|
||||
<Cascader
|
||||
multiple
|
||||
removeIcon={<div>bamboo</div>}
|
||||
options={options}
|
||||
defaultValue={[
|
||||
['zhejiang', 'hangzhou'],
|
||||
['jiangsu', 'nanjing'],
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getAllByText('bamboo').length).toBe(2);
|
||||
});
|
||||
|
||||
it('should support ConfigProvider removeIcon', () => {
|
||||
render(
|
||||
<ConfigProvider cascader={{ removeIcon: <div>foobar</div> }}>
|
||||
<Cascader
|
||||
multiple
|
||||
options={options}
|
||||
defaultValue={[
|
||||
['zhejiang', 'hangzhou'],
|
||||
['jiangsu', 'nanjing'],
|
||||
]}
|
||||
/>
|
||||
</ConfigProvider>,
|
||||
);
|
||||
expect(screen.getAllByText('foobar').length).toBe(2);
|
||||
});
|
||||
|
||||
it('should prefer prop removeIcon over ConfigProvider removeIcon', () => {
|
||||
render(
|
||||
<ConfigProvider cascader={{ removeIcon: <div>foobar</div> }}>
|
||||
<Cascader
|
||||
multiple
|
||||
options={options}
|
||||
defaultValue={[
|
||||
['zhejiang', 'hangzhou'],
|
||||
['jiangsu', 'nanjing'],
|
||||
]}
|
||||
removeIcon={<div>bamboo</div>}
|
||||
/>
|
||||
</ConfigProvider>,
|
||||
);
|
||||
expect(screen.getAllByText('bamboo').length).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('searchIcon', () => {
|
||||
it('should support custom searchIcon', () => {
|
||||
render(<Cascader open showSearch={{ searchIcon: <div>bamboo</div> }} options={options} />);
|
||||
expect(screen.getAllByText('bamboo').length).toBe(1);
|
||||
});
|
||||
|
||||
it('should support ConfigProvider searchIcon', () => {
|
||||
render(
|
||||
<ConfigProvider cascader={{ searchIcon: <div>foobar</div> }}>
|
||||
<Cascader open options={options} showSearch />
|
||||
</ConfigProvider>,
|
||||
);
|
||||
expect(screen.getAllByText('foobar').length).toBe(1);
|
||||
});
|
||||
|
||||
it('should prefer prop searchIcon over ConfigProvider searchIcon', () => {
|
||||
render(
|
||||
<ConfigProvider cascader={{ searchIcon: <div>foobar</div> }}>
|
||||
<Cascader open showSearch={{ searchIcon: <div>bamboo</div> }} options={options} />
|
||||
</ConfigProvider>,
|
||||
);
|
||||
expect(screen.getAllByText('bamboo').length).toBe(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -111,6 +111,7 @@ Common props ref:[Common props](/docs/react/common-props)
|
||||
| sort | Used to sort filtered options | function(a, b, inputValue) | - | |
|
||||
| searchValue | Set search value, Need work with `showSearch` | string | - | 4.17.0 |
|
||||
| onSearch | The callback function triggered when input changed | (search: string) => void | - | 4.17.0 |
|
||||
| searchIcon | Customize the search icon | ReactNode | - | 6.3.0 |
|
||||
|
||||
### Option
|
||||
|
||||
|
||||
@@ -166,6 +166,9 @@ export interface CascaderProps<
|
||||
bordered?: boolean;
|
||||
placement?: SelectCommonPlacement;
|
||||
suffixIcon?: React.ReactNode;
|
||||
showSearch?:
|
||||
| boolean
|
||||
| (SearchConfig<OptionType, keyof OptionType> & { searchIcon?: React.ReactNode });
|
||||
options?: OptionType[];
|
||||
status?: InputStatus;
|
||||
|
||||
@@ -244,11 +247,12 @@ const Cascader = React.forwardRef<CascaderRef, CascaderProps<any>>((props, ref)
|
||||
styles,
|
||||
classNames,
|
||||
loadingIcon,
|
||||
...rest
|
||||
clearIcon,
|
||||
removeIcon,
|
||||
suffixIcon,
|
||||
...restProps
|
||||
} = props;
|
||||
|
||||
const restProps = omit(rest, ['suffixIcon']);
|
||||
|
||||
const {
|
||||
getPrefixCls,
|
||||
getPopupContainer: getContextPopupContainer,
|
||||
@@ -258,6 +262,10 @@ const Cascader = React.forwardRef<CascaderRef, CascaderProps<any>>((props, ref)
|
||||
styles: contextStyles,
|
||||
expandIcon: contextExpandIcon,
|
||||
loadingIcon: contextLoadingIcon,
|
||||
clearIcon: contextClearIcon,
|
||||
removeIcon: contextRemoveIcon,
|
||||
suffixIcon: contextSuffixIcon,
|
||||
searchIcon: contextSearchIcon,
|
||||
} = useComponentConfig('cascader');
|
||||
|
||||
const { popupOverflow } = React.useContext(ConfigContext);
|
||||
@@ -367,9 +375,21 @@ const Cascader = React.forwardRef<CascaderRef, CascaderProps<any>>((props, ref)
|
||||
|
||||
// ===================== Icons =====================
|
||||
const showSuffixIcon = useShowArrow(props.suffixIcon, showArrow);
|
||||
const { suffixIcon, removeIcon, clearIcon } = useSelectIcons({
|
||||
const {
|
||||
suffixIcon: mergedSuffixIcon,
|
||||
removeIcon: mergedRemoveIcon,
|
||||
clearIcon: mergedClearIcon,
|
||||
} = useSelectIcons({
|
||||
...props,
|
||||
clearIcon,
|
||||
contextClearIcon,
|
||||
removeIcon,
|
||||
contextRemoveIcon,
|
||||
loadingIcon: mergedLoadingIcon,
|
||||
suffixIcon,
|
||||
contextSuffixIcon,
|
||||
searchIcon: typeof showSearch === 'object' && showSearch ? showSearch.searchIcon : undefined,
|
||||
contextSearchIcon,
|
||||
hasFeedback,
|
||||
feedbackIcon,
|
||||
showSuffixIcon,
|
||||
@@ -386,7 +406,7 @@ const Cascader = React.forwardRef<CascaderRef, CascaderProps<any>>((props, ref)
|
||||
return isRtl ? 'bottomRight' : 'bottomLeft';
|
||||
}, [placement, isRtl]);
|
||||
|
||||
const mergedAllowClear = allowClear === true ? { clearIcon } : allowClear;
|
||||
const mergedAllowClear = allowClear === true ? { clearIcon: mergedClearIcon } : allowClear;
|
||||
|
||||
// =========== Merged Props for Semantic ==========
|
||||
const mergedProps: CascaderProps<any> = {
|
||||
@@ -468,8 +488,8 @@ const Cascader = React.forwardRef<CascaderRef, CascaderProps<any>>((props, ref)
|
||||
allowClear={mergedAllowClear}
|
||||
showSearch={mergedShowSearch}
|
||||
expandIcon={mergedExpandIcon}
|
||||
suffixIcon={suffixIcon}
|
||||
removeIcon={removeIcon}
|
||||
suffixIcon={mergedSuffixIcon}
|
||||
removeIcon={mergedRemoveIcon}
|
||||
loadingIcon={mergedLoadingIcon}
|
||||
checkable={checkable}
|
||||
popupClassName={mergedPopupClassName}
|
||||
|
||||
@@ -114,6 +114,7 @@ demo:
|
||||
| sort | 用于排序 filter 后的选项 | function(a, b, inputValue) | - | |
|
||||
| searchValue | 设置搜索的值,需要与 `showSearch` 配合使用 | string | - | 4.17.0 |
|
||||
| onSearch | 监听搜索,返回输入的值 | (search: string) => void | - | 4.17.0 |
|
||||
| searchIcon | 自定义的搜索图标 | ReactNode | - | 6.3.0 |
|
||||
|
||||
### Option
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -229,6 +229,34 @@ describe('ConfigProvider.Form', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('form labelAlign', () => {
|
||||
it('set labelAlign left', () => {
|
||||
const { container } = render(
|
||||
<ConfigProvider form={{ labelAlign: 'left' }}>
|
||||
<Form>
|
||||
<Form.Item label="姓名">
|
||||
<input />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</ConfigProvider>,
|
||||
);
|
||||
expect(container.querySelector('.ant-form-item-label-left')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('form labelAlign should override ConfigProvider labelAlign', () => {
|
||||
const { container } = render(
|
||||
<ConfigProvider form={{ labelAlign: 'left' }}>
|
||||
<Form labelAlign="right">
|
||||
<Form.Item label="姓名">
|
||||
<input />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</ConfigProvider>,
|
||||
);
|
||||
expect(container.querySelector('.ant-form-item-label-left')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('form disabled', () => {
|
||||
it('set Input enabled', () => {
|
||||
const { container } = render(
|
||||
|
||||
@@ -302,6 +302,7 @@ export type FormConfig = ComponentStyleConfig &
|
||||
| 'classNames'
|
||||
| 'styles'
|
||||
| 'tooltip'
|
||||
| 'labelAlign'
|
||||
>;
|
||||
|
||||
export type FloatButtonConfig = ComponentStyleConfig &
|
||||
@@ -372,7 +373,10 @@ export type InputNumberConfig = ComponentStyleConfig &
|
||||
Pick<InputNumberProps, 'variant' | 'classNames' | 'styles'>;
|
||||
|
||||
export type CascaderConfig = ComponentStyleConfig &
|
||||
Pick<CascaderProps, 'variant' | 'styles' | 'classNames' | 'expandIcon' | 'loadingIcon'>;
|
||||
Pick<
|
||||
CascaderProps,
|
||||
'variant' | 'styles' | 'classNames' | 'expandIcon' | 'loadingIcon' | 'removeIcon' | 'suffixIcon'
|
||||
> & { clearIcon?: React.ReactNode; searchIcon?: React.ReactNode };
|
||||
|
||||
export type TreeSelectConfig = ComponentStyleConfig &
|
||||
Pick<TreeSelectProps, 'variant' | 'classNames' | 'styles' | 'switcherIcon'>;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -119,7 +119,7 @@ const {
|
||||
| cardMeta | Set Card.Meta common props | { className?: string, style?: React.CSSProperties, classNames?: [CardMetaProps\["classNames"\]](/components/card#semantic-dom), styles?: [CardMetaProps\["styles"\]](/components/card#semantic-dom) } | - | 6.0.0 |
|
||||
| calendar | Set Calendar common props | { className?: string, style?: React.CSSProperties, classNames?: [CalendarConfig\["classNames"\]](/components/calendar#semantic-dom), styles?: [CalendarConfig\["styles"\]](/components/calendar#semantic-dom) } | - | 5.7.0, `classNames` and `styles`: 6.0.0 |
|
||||
| carousel | Set Carousel common props | { className?: string, style?: React.CSSProperties } | - | 5.7.0 |
|
||||
| cascader | Set Cascader common props | { className?: string, style?: React.CSSProperties, classNames?: [CascaderConfig\["classNames"\]](/components/cascader#semantic-dom), styles?: [CascaderConfig\["styles"\]](/components/cascader#semantic-dom), expandIcon?: React.ReactNode, loadingIcon?: React.ReactNode } | - | 5.7.0, `classNames` and `styles`: 6.0.0, `expandIcon` and `loadingIcon`: 6.3.0 |
|
||||
| cascader | Set Cascader common props | { className?: string, style?: React.CSSProperties, classNames?: [CascaderConfig\["classNames"\]](/components/cascader#semantic-dom), styles?: [CascaderConfig\["styles"\]](/components/cascader#semantic-dom), expandIcon?: React.ReactNode, loadingIcon?: React.ReactNode, searchIcon?: React.ReactNode, clearIcon?: React.ReactNode, removeIcon?: React.ReactNode, suffixIcon?: React.ReactNode } | - | 5.7.0, `classNames` and `styles`: 6.0.0, `expandIcon`, `loadingIcon`, `searchIcon`, `clearIcon`, `removeIcon`, `suffixIcon`: 6.4.0 |
|
||||
| checkbox | Set Checkbox common props | { className?: string, style?: React.CSSProperties, classNames?: [CheckboxConfig\["classNames"\]](/components/checkbox#semantic-dom), styles?: [CheckboxConfig\["styles"\]](/components/checkbox#semantic-dom) } | - | 5.7.0, `classNames` and `styles`: 6.0.0 |
|
||||
| collapse | Set Collapse common props | { className?: string, style?: React.CSSProperties, expandIcon?: (props) => ReactNode, classNames?: [CollapseProps\["classNames"\]](/components/collapse#semantic-dom), styles?: [CollapseProps\["styles"\]](/components/collapse#semantic-dom) } | - | 5.7.0, `expandIcon`: 5.15.0, `classNames` and `styles`: 6.0.0 |
|
||||
| colorPicker | Set ColorPicker common props | { className?: string, style?: React.CSSProperties, classNames?: [ColorPickerConfig\["classNames"\]](/components/color-picker#semantic-dom), styles?: [ColorPickerConfig\["styles"\]](/components/color-picker#semantic-dom) } | - | 5.7.0 |
|
||||
@@ -133,7 +133,7 @@ const {
|
||||
| flex | Set Flex common props | { className?: string, style?: React.CSSProperties, vertical?: boolean } | - | 5.10.0 |
|
||||
| floatButton | Set FloatButton common props | { className?: string, style?: React.CSSProperties, classNames?: [FloatButtonProps\["classNames"\]](/components/float-button#semantic-dom), styles?: [FloatButtonProps\["styles"\]](/components/float-button#semantic-dom), backTopIcon?: React.ReactNode } | - | |
|
||||
| floatButtonGroup | Set FloatButton.Group common props | { closeIcon?: React.ReactNode, className?: string, style?: React.CSSProperties, classNames?: [FloatButtonProps\["classNames"\]](/components/float-button#semantic-dom), styles?: [FloatButtonProps\["styles"\]](/components/float-button#semantic-dom) } | - | |
|
||||
| form | Set Form common props | { className?: string, style?: React.CSSProperties, validateMessages?: [ValidateMessages](/components/form/#validatemessages), requiredMark?: boolean \| `optional`, scrollToFirstError?: boolean \| [Options](https://github.com/stipsan/scroll-into-view-if-needed/tree/ece40bd9143f48caf4b99503425ecb16b0ad8249#options), classNames?:[FormConfig\["classNames"\]](/components/form#semantic-dom), styles?: [FormConfig\["styles"\]](/components/form#semantic-dom), tooltip?: [TooltipProps](/components/tooltip#api) & { icon?: ReactNode } } | - | `requiredMark`: 4.8.0; `colon`: 4.18.0; `scrollToFirstError`: 5.2.0; `className` and `style`: 5.7.0; `tooltip`: 6.3.0 |
|
||||
| form | Set Form common props | { className?: string, style?: React.CSSProperties, validateMessages?: [ValidateMessages](/components/form/#validatemessages), requiredMark?: boolean \| `optional`, scrollToFirstError?: boolean \| [Options](https://github.com/stipsan/scroll-into-view-if-needed/tree/ece40bd9143f48caf4b99503425ecb16b0ad8249#options), classNames?:[FormConfig\["classNames"\]](/components/form#semantic-dom), styles?: [FormConfig\["styles"\]](/components/form#semantic-dom), tooltip?: [TooltipProps](/components/tooltip#api) & { icon?: ReactNode }, labelAlign?: `left` \| `right` } | - | `requiredMark`: 4.8.0; `colon`: 4.18.0; `scrollToFirstError`: 5.2.0; `className` and `style`: 5.7.0; `tooltip`: 6.3.0; `labelAlign`: 6.4.0 |
|
||||
| image | Set Image common props | { className?: string, style?: React.CSSProperties, preview?: { closeIcon?: React.ReactNode, classNames?:[ImageConfig\["classNames"\]](/components/image#semantic-dom), styles?: [ImageConfig\["styles"\]](/components/image#semantic-dom) }, fallback?: string } | - | 5.7.0, `closeIcon`: 5.14.0, `classNames` and `styles`: 6.0.0 |
|
||||
| input | Set Input common props | { autoComplete?: string, className?: string, style?: React.CSSProperties, allowClear?: boolean \| { clearIcon?: ReactNode } } | - | 4.2.0, `allowClear`: 5.15.0 |
|
||||
| inputNumber | Set InputNumber common props | { className?: string, style?: React.CSSProperties, classNames?: [InputNumberConfig\["classNames"\]](/components/input-number#semantic-dom), styles?: [InputNumberConfig\["styles"\]](/components/input-number#semantic-dom) } | - | |
|
||||
|
||||
@@ -121,7 +121,7 @@ const {
|
||||
| card | 设置 Card 组件的通用属性 | { className?: string, style?: React.CSSProperties, classNames?: [CardProps\["classNames"\]](/components/card-cn#semantic-dom), styles?: [CardProps\["styles"\]](/components/card-cn#semantic-dom) } | - | 5.7.0, `classNames` 和 `styles`: 5.14.0 |
|
||||
| cardMeta | 设置 Card.Meta 组件的通用属性 | { className?: string, style?: React.CSSProperties, classNames?: [CardMetaProps\["classNames"\]](/components/card-cn#semantic-dom), styles?: [CardMetaProps\["styles"\]](/components/card-cn#semantic-dom) } | - | 6.0.0 |
|
||||
| carousel | 设置 Carousel 组件的通用属性 | { className?: string, style?: React.CSSProperties } | - | 5.7.0 |
|
||||
| cascader | 设置 Cascader 组件的通用属性 | { className?: string, style?: React.CSSProperties, classNames?: [CascaderConfig\["classNames"\]](/components/cascader#semantic-dom), styles?: [CascaderConfig\["styles"\]](/components/cascader#semantic-dom), expandIcon?: React.ReactNode, loadingIcon?: React.ReactNode } | - | 5.7.0, `classNames` 和 `styles`: 6.0.0, `expandIcon` 和 `loadingIcon`: 6.3.0 |
|
||||
| cascader | 设置 Cascader 组件的通用属性 | { className?: string, style?: React.CSSProperties, classNames?: [CascaderConfig\["classNames"\]](/components/cascader#semantic-dom), styles?: [CascaderConfig\["styles"\]](/components/cascader#semantic-dom), expandIcon?: React.ReactNode, loadingIcon?: React.ReactNode, searchIcon?: React.ReactNode, clearIcon?: React.ReactNode, removeIcon?: React.ReactNode, suffixIcon?: React.ReactNode } | - | 5.7.0, `classNames` 和 `styles`: 6.0.0, `expandIcon`, `loadingIcon`, `searchIcon`, `clearIcon`, `removeIcon`, `suffixIcon`: 6.4.0 |
|
||||
| checkbox | 设置 Checkbox 组件的通用属性 | { className?: string, style?: React.CSSProperties, classNames?: [CheckboxConfig\["classNames"\]](/components/checkbox-cn#semantic-dom), styles?: [CheckboxConfig\["styles"\]](/components/checkbox-cn#semantic-dom) } | - | 5.7.0, `classNames` 和 `styles`: 6.0.0 |
|
||||
| collapse | 设置 Collapse 组件的通用属性 | { className?: string, style?: React.CSSProperties, expandIcon?: (props) => ReactNode, classNames?: [CollapseProps\["classNames"\]](/components/collapse-cn#semantic-dom), styles?: [CollapseProps\["styles"\]](/components/collapse-cn#semantic-dom) } | - | 5.7.0, `expandIcon`: 5.15.0, `classNames` 和 `styles`: 6.0.0 |
|
||||
| colorPicker | 设置 ColorPicker 组件的通用属性 | { className?: string, style?: React.CSSProperties, classNames?: [ColorPickerConfig\["classNames"\]](/components/color-picker-cn#semantic-dom), styles?: [ColorPickerConfig\["styles"\]](/components/color-picker-cn#semantic-dom) } | - | 5.7.0 |
|
||||
@@ -135,7 +135,7 @@ const {
|
||||
| flex | 设置 Flex 组件的通用属性 | { className?: string, style?: React.CSSProperties, vertical?: boolean } | - | 5.10.0 |
|
||||
| floatButton | 设置 FloatButton 组件的通用属性 | { className?: string, style?: React.CSSProperties, classNames?: [FloatButtonProps\["classNames"\]](/components/float-button-cn#semantic-dom), styles?: [FloatButtonProps\["styles"\]](/components/float-button-cn#semantic-dom), backTopIcon?: React.ReactNode } | - | |
|
||||
| floatButtonGroup | 设置 FloatButton.Group 组件的通用属性 | { closeIcon?: React.ReactNode, className?: string, style?: React.CSSProperties, classNames?: [FloatButtonProps\["classNames"\]](/components/float-button-cn#semantic-dom), styles?: [FloatButtonProps\["styles"\]](/components/float-button-cn#semantic-dom) } | - | |
|
||||
| form | 设置 Form 组件的通用属性 | { className?: string, style?: React.CSSProperties, validateMessages?: [ValidateMessages](/components/form-cn#validatemessages), requiredMark?: boolean \| `optional`, colon?: boolean, scrollToFirstError?: boolean \| [Options](https://github.com/stipsan/scroll-into-view-if-needed/tree/ece40bd9143f48caf4b99503425ecb16b0ad8249#options), classNames?:[FormConfig\["classNames"\]](/components/form-cn#semantic-dom), styles?: [FormConfig\["styles"\]](/components/form-cn#semantic-dom), tooltip?: [TooltipProps](/components/tooltip-cn#api) & { icon?: ReactNode } } | - | `requiredMark`: 4.8.0; `colon`: 4.18.0; `scrollToFirstError`: 5.2.0; `className` 和 `style`: 5.7.0; `tooltip`: 6.3.0 |
|
||||
| form | 设置 Form 组件的通用属性 | { className?: string, style?: React.CSSProperties, validateMessages?: [ValidateMessages](/components/form-cn#validatemessages), requiredMark?: boolean \| `optional`, colon?: boolean, scrollToFirstError?: boolean \| [Options](https://github.com/stipsan/scroll-into-view-if-needed/tree/ece40bd9143f48caf4b99503425ecb16b0ad8249#options), classNames?:[FormConfig\["classNames"\]](/components/form-cn#semantic-dom), styles?: [FormConfig\["styles"\]](/components/form-cn#semantic-dom), tooltip?: [TooltipProps](/components/tooltip-cn#api) & { icon?: ReactNode }, labelAlign?: `left` \| `right` } | - | `requiredMark`: 4.8.0; `colon`: 4.18.0; `scrollToFirstError`: 5.2.0; `className` 和 `style`: 5.7.0; `tooltip`: 6.3.0; `labelAlign`: 6.4.0 |
|
||||
| image | 设置 Image 组件的通用属性 | { className?: string, style?: React.CSSProperties, preview?: { closeIcon?: React.ReactNode, classNames?:[ImageConfig\["classNames"\]](/components/image-cn#semantic-dom), styles?: [ImageConfig\["styles"\]](/components/image-cn#semantic-dom) }, fallback?: string } | - | 5.7.0, `closeIcon`: 5.14.0, `classNames` 和 `styles`: 6.0.0 |
|
||||
| input | 设置 Input 组件的通用属性 | { autoComplete?: string, className?: string, style?: React.CSSProperties,classNames?:[InputConfig\["classNames"\]](/components/input-cn#semantic-input), styles?: [InputConfig\["styles"\]](/components/input-cn#semantic-input), allowClear?: boolean \| { clearIcon?: ReactNode } } | - | 5.7.0, `allowClear`: 5.15.0 |
|
||||
| inputNumber | 设置 Input 组件的通用属性 | { className?: string, style?: React.CSSProperties, classNames?: [InputNumberConfig\["classNames"\]](/components/input-number-cn#semantic-dom), styles?: [InputNumberConfig\["styles"\]](/components/input-number-cn#semantic-dom) } | - | |
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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`.
|
||||
@@ -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;
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -91,6 +91,7 @@ const InternalForm: React.ForwardRefRenderFunction<FormRef, FormProps> = (props,
|
||||
styles: contextStyles,
|
||||
classNames: contextClassNames,
|
||||
tooltip: contextTooltip,
|
||||
labelAlign: contextLabelAlign,
|
||||
} = useComponentConfig('form');
|
||||
|
||||
const {
|
||||
@@ -144,6 +145,8 @@ const InternalForm: React.ForwardRefRenderFunction<FormRef, FormProps> = (props,
|
||||
|
||||
const mergedColon = colon ?? contextColon;
|
||||
|
||||
const mergedLabelAlign = labelAlign ?? contextLabelAlign;
|
||||
|
||||
const mergedTooltip = { ...contextTooltip, ...tooltip };
|
||||
|
||||
const prefixCls = getPrefixCls('form', customizePrefixCls);
|
||||
@@ -194,7 +197,7 @@ const InternalForm: React.ForwardRefRenderFunction<FormRef, FormProps> = (props,
|
||||
const formContextValue = React.useMemo<FormContextProps>(
|
||||
() => ({
|
||||
name,
|
||||
labelAlign,
|
||||
labelAlign: mergedLabelAlign,
|
||||
labelCol,
|
||||
labelWrap,
|
||||
wrapperCol,
|
||||
@@ -210,7 +213,7 @@ const InternalForm: React.ForwardRefRenderFunction<FormRef, FormProps> = (props,
|
||||
}),
|
||||
[
|
||||
name,
|
||||
labelAlign,
|
||||
mergedLabelAlign,
|
||||
labelCol,
|
||||
wrapperCol,
|
||||
layout,
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -3146,7 +3146,7 @@ Array [
|
||||
style="width: 100px;"
|
||||
>
|
||||
<div
|
||||
class="ant-select-content ant-select-content-has-value"
|
||||
class="ant-select-content"
|
||||
title=""
|
||||
>
|
||||
<input
|
||||
|
||||
@@ -684,7 +684,7 @@ Array [
|
||||
style="width:100px"
|
||||
>
|
||||
<div
|
||||
class="ant-select-content ant-select-content-has-value"
|
||||
class="ant-select-content"
|
||||
title=""
|
||||
>
|
||||
<input
|
||||
|
||||
@@ -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;"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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.
|
||||
@@ -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;
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -147,6 +147,7 @@ const genLineStyle: GenerateStyle<ProgressToken> = (token) => {
|
||||
borderRadius: token.lineBorderRadius,
|
||||
position: 'relative',
|
||||
width: '100%',
|
||||
overflow: 'hidden',
|
||||
},
|
||||
|
||||
[`&${componentCls}-status-active`]: {
|
||||
|
||||
@@ -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`] = `[]`;
|
||||
|
||||
@@ -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`] = `
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -7,17 +7,23 @@ import DownOutlined from '@ant-design/icons/DownOutlined';
|
||||
import LoadingOutlined from '@ant-design/icons/LoadingOutlined';
|
||||
import SearchOutlined from '@ant-design/icons/SearchOutlined';
|
||||
|
||||
import fallbackProp from '../_util/fallbackProp';
|
||||
import { devUseWarning } from '../_util/warning';
|
||||
|
||||
type RenderNode = React.ReactNode | ((props: any) => React.ReactNode);
|
||||
|
||||
export default function useIcons({
|
||||
suffixIcon,
|
||||
contextSuffixIcon,
|
||||
clearIcon,
|
||||
contextClearIcon,
|
||||
menuItemSelectedIcon,
|
||||
removeIcon,
|
||||
contextRemoveIcon,
|
||||
loading,
|
||||
loadingIcon,
|
||||
searchIcon,
|
||||
contextSearchIcon,
|
||||
multiple,
|
||||
hasFeedback,
|
||||
showSuffixIcon,
|
||||
@@ -26,11 +32,16 @@ export default function useIcons({
|
||||
componentName,
|
||||
}: {
|
||||
suffixIcon?: React.ReactNode;
|
||||
clearIcon?: RenderNode;
|
||||
contextSuffixIcon?: React.ReactNode;
|
||||
clearIcon?: React.ReactNode;
|
||||
contextClearIcon?: React.ReactNode;
|
||||
menuItemSelectedIcon?: RenderNode;
|
||||
removeIcon?: RenderNode;
|
||||
contextRemoveIcon?: RenderNode;
|
||||
loading?: boolean;
|
||||
loadingIcon?: React.ReactNode;
|
||||
searchIcon?: React.ReactNode;
|
||||
contextSearchIcon?: React.ReactNode;
|
||||
multiple?: boolean;
|
||||
hasFeedback?: boolean;
|
||||
feedbackIcon?: ReactNode;
|
||||
@@ -45,59 +56,72 @@ export default function useIcons({
|
||||
warning.deprecated(!clearIcon, 'clearIcon', 'allowClear={{ clearIcon: React.ReactNode }}');
|
||||
}
|
||||
|
||||
// Clear Icon
|
||||
const mergedClearIcon = clearIcon ?? <CloseCircleFilled />;
|
||||
return React.useMemo(() => {
|
||||
// Clear Icon
|
||||
const mergedClearIcon = fallbackProp(clearIcon, contextClearIcon, <CloseCircleFilled />);
|
||||
|
||||
// Validation Feedback Icon
|
||||
const getSuffixIconNode = (arrowIcon?: ReactNode) => {
|
||||
if (suffixIcon === null && !hasFeedback && !showArrow) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<>
|
||||
{showSuffixIcon !== false && arrowIcon}
|
||||
{hasFeedback && feedbackIcon}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
// Arrow item icon
|
||||
let mergedSuffixIcon = null;
|
||||
if (suffixIcon !== undefined) {
|
||||
mergedSuffixIcon = getSuffixIconNode(suffixIcon);
|
||||
} else if (loading) {
|
||||
mergedSuffixIcon = getSuffixIconNode(loadingIcon ?? <LoadingOutlined spin />);
|
||||
} else {
|
||||
mergedSuffixIcon = ({ open, showSearch }: { open: boolean; showSearch: boolean }) => {
|
||||
if (open && showSearch) {
|
||||
return getSuffixIconNode(<SearchOutlined />);
|
||||
// Validation Feedback Icon
|
||||
const getSuffixIconNode = (arrowIcon?: ReactNode) => {
|
||||
if (suffixIcon === null && !hasFeedback && !showArrow) {
|
||||
return null;
|
||||
}
|
||||
return getSuffixIconNode(<DownOutlined />);
|
||||
return (
|
||||
<>
|
||||
{showSuffixIcon !== false && arrowIcon}
|
||||
{hasFeedback && feedbackIcon}
|
||||
</>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
// Checked item icon
|
||||
let mergedItemIcon = null;
|
||||
if (menuItemSelectedIcon !== undefined) {
|
||||
mergedItemIcon = menuItemSelectedIcon;
|
||||
} else if (multiple) {
|
||||
mergedItemIcon = <CheckOutlined />;
|
||||
} else {
|
||||
mergedItemIcon = null;
|
||||
}
|
||||
// Arrow item icon
|
||||
let mergedSuffixIcon = null;
|
||||
if (suffixIcon !== undefined) {
|
||||
mergedSuffixIcon = getSuffixIconNode(suffixIcon);
|
||||
} else if (loading) {
|
||||
mergedSuffixIcon = getSuffixIconNode(fallbackProp(loadingIcon, <LoadingOutlined spin />));
|
||||
} else {
|
||||
mergedSuffixIcon = ({ open, showSearch }: { open: boolean; showSearch: boolean }) => {
|
||||
if (open && showSearch) {
|
||||
return getSuffixIconNode(fallbackProp(searchIcon, contextSearchIcon, <SearchOutlined />));
|
||||
}
|
||||
return getSuffixIconNode(fallbackProp(contextSuffixIcon, <DownOutlined />));
|
||||
};
|
||||
}
|
||||
|
||||
let mergedRemoveIcon = null;
|
||||
if (removeIcon !== undefined) {
|
||||
mergedRemoveIcon = removeIcon;
|
||||
} else {
|
||||
mergedRemoveIcon = <CloseOutlined />;
|
||||
}
|
||||
// Checked item icon
|
||||
let mergedItemIcon = null;
|
||||
if (menuItemSelectedIcon !== undefined) {
|
||||
mergedItemIcon = menuItemSelectedIcon;
|
||||
} else if (multiple) {
|
||||
mergedItemIcon = <CheckOutlined />;
|
||||
} else {
|
||||
mergedItemIcon = null;
|
||||
}
|
||||
|
||||
return {
|
||||
// TODO: remove as when all the deps bumped
|
||||
clearIcon: mergedClearIcon as React.ReactNode,
|
||||
suffixIcon: mergedSuffixIcon,
|
||||
itemIcon: mergedItemIcon,
|
||||
removeIcon: mergedRemoveIcon,
|
||||
};
|
||||
const mergedRemoveIcon = fallbackProp(removeIcon, contextRemoveIcon, <CloseOutlined />);
|
||||
|
||||
return {
|
||||
clearIcon: mergedClearIcon,
|
||||
suffixIcon: mergedSuffixIcon,
|
||||
itemIcon: mergedItemIcon,
|
||||
removeIcon: mergedRemoveIcon,
|
||||
};
|
||||
}, [
|
||||
suffixIcon,
|
||||
contextSuffixIcon,
|
||||
clearIcon,
|
||||
contextClearIcon,
|
||||
menuItemSelectedIcon,
|
||||
removeIcon,
|
||||
contextRemoveIcon,
|
||||
loading,
|
||||
loadingIcon,
|
||||
searchIcon,
|
||||
contextSearchIcon,
|
||||
multiple,
|
||||
hasFeedback,
|
||||
showSuffixIcon,
|
||||
feedbackIcon,
|
||||
showArrow,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,14 @@ export const InternalPanel = forwardRef<
|
||||
HTMLDivElement,
|
||||
React.PropsWithChildren<InternalPanelProps>
|
||||
>((props, ref) => {
|
||||
const { prefixCls, className, children, size, style = {} } = props;
|
||||
const { prefixCls, className, children, size, style = {}, supportMotion } = props;
|
||||
|
||||
const panelClassName = clsx(
|
||||
`${prefixCls}-panel`,
|
||||
{ [`${prefixCls}-panel-hidden`]: size === 0 },
|
||||
{
|
||||
[`${prefixCls}-panel-hidden`]: size === 0,
|
||||
[`${prefixCls}-panel-transition`]: supportMotion,
|
||||
},
|
||||
className,
|
||||
);
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ const Splitter: React.FC<React.PropsWithChildren<SplitterProps>> = (props) => {
|
||||
prefixCls: customizePrefixCls,
|
||||
className,
|
||||
classNames,
|
||||
collapsible,
|
||||
style,
|
||||
styles,
|
||||
layout,
|
||||
@@ -217,9 +218,13 @@ const Splitter: React.FC<React.PropsWithChildren<SplitterProps>> = (props) => {
|
||||
style: { ...mergedStyles.panel, ...item.style },
|
||||
};
|
||||
|
||||
// Panel
|
||||
const panel = (
|
||||
<InternalPanel {...panelProps} prefixCls={prefixCls} size={panelSizes[idx]} />
|
||||
<InternalPanel
|
||||
{...panelProps}
|
||||
prefixCls={prefixCls}
|
||||
size={panelSizes[idx]}
|
||||
supportMotion={collapsible?.motion && movingIndex === undefined}
|
||||
/>
|
||||
);
|
||||
|
||||
// Split Bar
|
||||
|
||||
@@ -4,12 +4,40 @@ exports[`renders components/splitter/demo/collapsible.tsx extend context correct
|
||||
<div
|
||||
class="ant-flex css-var-test-id ant-flex-align-stretch ant-flex-gap-middle ant-flex-vertical"
|
||||
>
|
||||
<div
|
||||
class="ant-flex css-var-test-id ant-flex-gap-middle"
|
||||
>
|
||||
<button
|
||||
aria-checked="true"
|
||||
class="ant-switch css-var-test-id ant-switch-checked"
|
||||
role="switch"
|
||||
type="button"
|
||||
>
|
||||
<div
|
||||
class="ant-switch-handle"
|
||||
/>
|
||||
<span
|
||||
class="ant-switch-inner"
|
||||
>
|
||||
<span
|
||||
class="ant-switch-inner-checked"
|
||||
>
|
||||
motion
|
||||
</span>
|
||||
<span
|
||||
class="ant-switch-inner-unchecked"
|
||||
>
|
||||
motion
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
class="ant-splitter ant-splitter-horizontal css-var-test-id ant-splitter-css-var"
|
||||
style="box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); height: 200px;"
|
||||
>
|
||||
<div
|
||||
class="ant-splitter-panel"
|
||||
class="ant-splitter-panel ant-splitter-panel-transition"
|
||||
style="flex-basis: auto; flex-grow: 1;"
|
||||
>
|
||||
<div
|
||||
@@ -36,7 +64,7 @@ exports[`renders components/splitter/demo/collapsible.tsx extend context correct
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="ant-splitter-panel"
|
||||
class="ant-splitter-panel ant-splitter-panel-transition"
|
||||
style="flex-basis: auto; flex-grow: 1;"
|
||||
>
|
||||
<div
|
||||
@@ -57,7 +85,7 @@ exports[`renders components/splitter/demo/collapsible.tsx extend context correct
|
||||
style="box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); height: 300px;"
|
||||
>
|
||||
<div
|
||||
class="ant-splitter-panel"
|
||||
class="ant-splitter-panel ant-splitter-panel-transition"
|
||||
style="flex-basis: auto; flex-grow: 1;"
|
||||
>
|
||||
<div
|
||||
@@ -84,7 +112,7 @@ exports[`renders components/splitter/demo/collapsible.tsx extend context correct
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="ant-splitter-panel"
|
||||
class="ant-splitter-panel ant-splitter-panel-transition"
|
||||
style="flex-basis: auto; flex-grow: 1;"
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -4,12 +4,40 @@ exports[`renders components/splitter/demo/collapsible.tsx correctly 1`] = `
|
||||
<div
|
||||
class="ant-flex css-var-test-id ant-flex-align-stretch ant-flex-gap-middle ant-flex-vertical"
|
||||
>
|
||||
<div
|
||||
class="ant-flex css-var-test-id ant-flex-gap-middle"
|
||||
>
|
||||
<button
|
||||
aria-checked="true"
|
||||
class="ant-switch css-var-test-id ant-switch-checked"
|
||||
role="switch"
|
||||
type="button"
|
||||
>
|
||||
<div
|
||||
class="ant-switch-handle"
|
||||
/>
|
||||
<span
|
||||
class="ant-switch-inner"
|
||||
>
|
||||
<span
|
||||
class="ant-switch-inner-checked"
|
||||
>
|
||||
motion
|
||||
</span>
|
||||
<span
|
||||
class="ant-switch-inner-unchecked"
|
||||
>
|
||||
motion
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
class="ant-splitter ant-splitter-horizontal css-var-test-id ant-splitter-css-var"
|
||||
style="box-shadow:0 0 10px rgba(0, 0, 0, 0.1);height:200px"
|
||||
>
|
||||
<div
|
||||
class="ant-splitter-panel"
|
||||
class="ant-splitter-panel ant-splitter-panel-transition"
|
||||
style="flex-basis:auto;flex-grow:1"
|
||||
>
|
||||
<div
|
||||
@@ -36,7 +64,7 @@ exports[`renders components/splitter/demo/collapsible.tsx correctly 1`] = `
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="ant-splitter-panel"
|
||||
class="ant-splitter-panel ant-splitter-panel-transition"
|
||||
style="flex-basis:auto;flex-grow:1"
|
||||
>
|
||||
<div
|
||||
@@ -57,7 +85,7 @@ exports[`renders components/splitter/demo/collapsible.tsx correctly 1`] = `
|
||||
style="box-shadow:0 0 10px rgba(0, 0, 0, 0.1);height:300px"
|
||||
>
|
||||
<div
|
||||
class="ant-splitter-panel"
|
||||
class="ant-splitter-panel ant-splitter-panel-transition"
|
||||
style="flex-basis:auto;flex-grow:1"
|
||||
>
|
||||
<div
|
||||
@@ -84,7 +112,7 @@ exports[`renders components/splitter/demo/collapsible.tsx correctly 1`] = `
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="ant-splitter-panel"
|
||||
class="ant-splitter-panel ant-splitter-panel-transition"
|
||||
style="flex-basis:auto;flex-grow:1"
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -997,6 +997,21 @@ describe('Splitter', () => {
|
||||
expect(onCollapse).toHaveBeenCalledTimes(2);
|
||||
expect(onCollapse).toHaveBeenCalledWith([false, false], [50, 50]);
|
||||
});
|
||||
|
||||
it('should apply transition when motion is true', async () => {
|
||||
const { container } = render(
|
||||
<SplitterDemo
|
||||
items={[{ collapsible: true }, { collapsible: true }]}
|
||||
collapsible={{
|
||||
motion: true,
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(container.querySelector('.ant-splitter-panel')).toHaveClass(
|
||||
'ant-splitter-panel-transition',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('auto resize', async () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Flex, Splitter, Typography } from 'antd';
|
||||
import React, { useState } from 'react';
|
||||
import { Flex, Splitter, Switch, Typography } from 'antd';
|
||||
import type { SplitterProps } from 'antd';
|
||||
|
||||
const Desc: React.FC<Readonly<{ text?: string | number }>> = (props) => (
|
||||
@@ -21,11 +21,23 @@ const CustomSplitter: React.FC<Readonly<SplitterProps>> = ({ style, ...restProps
|
||||
</Splitter>
|
||||
);
|
||||
|
||||
const App: React.FC = () => (
|
||||
<Flex gap="middle" vertical>
|
||||
<CustomSplitter style={{ height: 200 }} />
|
||||
<CustomSplitter style={{ height: 300 }} orientation="vertical" />
|
||||
</Flex>
|
||||
);
|
||||
const App: React.FC = () => {
|
||||
const [motion, setMotion] = useState(true);
|
||||
|
||||
return (
|
||||
<Flex vertical gap="middle">
|
||||
<Flex gap="middle">
|
||||
<Switch
|
||||
checked={motion}
|
||||
onChange={setMotion}
|
||||
checkedChildren="motion"
|
||||
unCheckedChildren="motion"
|
||||
/>
|
||||
</Flex>
|
||||
<CustomSplitter style={{ height: 200 }} collapsible={{ motion }} />
|
||||
<CustomSplitter style={{ height: 300 }} orientation="vertical" collapsible={{ motion }} />
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
|
||||
@@ -44,6 +44,7 @@ Common props ref:[Common props](/docs/react/common-props)
|
||||
| Property | Description | Type | Default | Version |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| classNames | Customize class for each semantic structure inside the component. Supports object or function. | Record<[SemanticDOM](#semantic-dom), string> \| (info: { props })=> Record<[SemanticDOM](#semantic-dom), string> | - | |
|
||||
| collapsible | Collapse config. Set `motion: true` to enable collapse animation; duration is controlled by Component Token `panelMotionDuration` (inherits from `motionDurationSlow`) | `{ motion?: boolean }` | - | 6.4.0 |
|
||||
| collapsibleIcon | custom collapsible icon | `{start: ReactNode; end: ReactNode}` | - | 6.0.0 |
|
||||
| draggerIcon | custom dragger icon | `ReactNode` | - | 6.0.0 |
|
||||
| ~~layout~~ | Layout direction | `horizontal` \| `vertical` | `horizontal` | - |
|
||||
|
||||
@@ -45,6 +45,7 @@ demo:
|
||||
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| classNames | 用于自定义组件内部各语义化结构的 class,支持对象或函数 | Record<[SemanticDOM](#semantic-dom), string> \| (info: { props })=> Record<[SemanticDOM](#semantic-dom), string> | - | |
|
||||
| collapsible | 折叠配置。`motion: true` 时启用折叠动画,时长由组件 Token `panelMotionDuration` 控制(继承自 `motionDurationSlow`) | `{ motion?: boolean }` | - | 6.4.0 |
|
||||
| collapsibleIcon | 折叠图标 | `{start?: ReactNode; end?: ReactNode}` | - | 6.0.0 |
|
||||
| draggerIcon | 拖拽图标 | `ReactNode` | - | 6.0.0 |
|
||||
| ~~layout~~ | 布局方向 | `horizontal` \| `vertical` | `horizontal` | - |
|
||||
|
||||
@@ -46,6 +46,10 @@ export interface SplitterProps {
|
||||
prefixCls?: string;
|
||||
className?: string;
|
||||
classNames?: SplitterClassNamesType;
|
||||
/**
|
||||
* Collapse configuration. Set `motion: true` to enable collapse animation (duration follows Component Token).
|
||||
*/
|
||||
collapsible?: { motion?: boolean };
|
||||
style?: React.CSSProperties;
|
||||
styles?: SplitterStylesType;
|
||||
rootClassName?: string;
|
||||
@@ -87,6 +91,7 @@ export interface PanelProps {
|
||||
export interface InternalPanelProps extends PanelProps {
|
||||
className?: string;
|
||||
prefixCls?: string;
|
||||
supportMotion?: boolean;
|
||||
}
|
||||
|
||||
export interface UseResizeProps extends Pick<SplitterProps, 'onResize'> {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { CSSObject } from '@ant-design/cssinjs';
|
||||
|
||||
import { resetComponent } from '../../style';
|
||||
import { genNoMotionStyle } from '../../style/motion';
|
||||
import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';
|
||||
import { genStyleHooks } from '../../theme/internal';
|
||||
import { genCssVar } from '../../theme/util/genStyleUtils';
|
||||
@@ -374,6 +375,11 @@ const genSplitterStyle: GenerateStyle<SplitterToken> = (token: SplitterToken): C
|
||||
[`&:has(${componentCls}:only-child)`]: {
|
||||
overflow: 'hidden',
|
||||
},
|
||||
|
||||
'&-transition': {
|
||||
transition: `flex-basis ${token.motionDurationSlow} ${token.motionEaseInOut}`,
|
||||
...genNoMotionStyle(),
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
})
|
||||
|
||||
@@ -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,
|
||||
|
||||
10
components/style/motion/util.ts
Normal file
10
components/style/motion/util.ts
Normal 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',
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -162,6 +162,7 @@ type ZoomMotionTypes =
|
||||
| 'zoom-right'
|
||||
| 'zoom-up'
|
||||
| 'zoom-down';
|
||||
|
||||
const zoomMotion: Record<ZoomMotionTypes, { inKeyframes: Keyframes; outKeyframes: Keyframes }> = {
|
||||
zoom: {
|
||||
inKeyframes: zoomIn,
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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'),
|
||||
},
|
||||
},
|
||||
]}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -280,6 +280,12 @@ export const genBaseStyle = (prefixCls: string, token: TreeToken): CSSObject =>
|
||||
.equal(),
|
||||
},
|
||||
|
||||
// >>> Checkbox
|
||||
// https://github.com/ant-design/ant-design/issues/56957
|
||||
[`${treeCls}-checkbox`]: {
|
||||
flexShrink: 0,
|
||||
},
|
||||
|
||||
// >>> Switcher
|
||||
[`${treeCls}-switcher`]: {
|
||||
...getSwitchStyle(prefixCls, token),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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.9",
|
||||
"@rc-component/slider": "~1.0.1",
|
||||
"@rc-component/steps": "~1.2.2",
|
||||
"@rc-component/switch": "~1.0.3",
|
||||
|
||||
@@ -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)),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user