Skip to content

Commit

Permalink
Merge branch 'main' into docs/fix-sider-border
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 authored Dec 17, 2024
2 parents 9bcf3f4 + f04a8dd commit e4bcb21
Show file tree
Hide file tree
Showing 72 changed files with 2,830 additions and 1,139 deletions.
3 changes: 2 additions & 1 deletion .dumi/pages/index/components/MainBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { createStyles } from 'antd-style';
import classnames from 'classnames';
import { Link, useLocation } from 'dumi';
import { useLocation } from 'dumi';
import React from 'react';

import { Button } from 'antd';
import useLocale from '../../../hooks/useLocale';
import useLottie from '../../../hooks/useLottie';
import Link from '../../../theme/common/Link';
import { getLocalizedPathname, isZhCN } from '../../../theme/utils';
import Container from '../common/Container';
import SiteContext from './SiteContext';
Expand Down
2 changes: 1 addition & 1 deletion .dumi/theme/builtins/ComponentOverview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ const Overview: React.FC = () => {
{cardContent}
</a>
) : (
<Link to={url} prefetch key={component.title}>
<Link to={url} key={component.title}>
{cardContent}
</Link>
);
Expand Down
8 changes: 5 additions & 3 deletions .dumi/theme/builtins/DemoWrapper/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useContext } from 'react';
import { BugOutlined, CodeOutlined, ExperimentOutlined } from '@ant-design/icons';
import { XProvider } from '@ant-design/x';
import { Tooltip, Button } from 'antd';
import { Button, Tooltip } from 'antd';
import classNames from 'classnames';
import { DumiDemoGrid, FormattedMessage } from 'dumi';
import React, { Suspense, useContext } from 'react';

import useLayoutState from '../../../hooks/useLayoutState';
import useLocale from '../../../hooks/useLocale';
Expand Down Expand Up @@ -106,7 +106,9 @@ const DemoWrapper: typeof DumiDemoGrid = ({ items }) => {
</Tooltip>
</span>
<XProvider theme={{ cssVar: enableCssVar, hashed: !enableCssVar }}>
<DumiDemoGrid items={demos} />
<Suspense>
<DumiDemoGrid items={demos} />
</Suspense>
</XProvider>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion .dumi/theme/builtins/LocaleLink/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Link } from 'dumi';

import useLocale from '../../../hooks/useLocale';
import Link from '../../../theme/common/Link';

type LinkProps = Parameters<typeof Link>[0];

Expand Down
98 changes: 41 additions & 57 deletions .dumi/theme/common/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,72 +1,56 @@
import { Link as DumiLink, useLocation, useNavigate } from 'dumi';
import nprogress from 'nprogress';
import { Link as DumiLink, useAppData, useLocation, useNavigate } from 'dumi';
import type { MouseEvent, MouseEventHandler } from 'react';
import React, { forwardRef, useLayoutEffect, useTransition } from 'react';
import React, { useMemo, forwardRef } from 'react';

export interface LinkProps {
to: string | { pathname?: string; search?: string; hash?: string };
style?: React.CSSProperties;
className?: string;
onClick?: MouseEventHandler;
component?: React.ComponentType<any>;
children?: React.ReactNode;
}

nprogress.configure({ showSpinner: false });

const Link = forwardRef<HTMLAnchorElement, React.PropsWithChildren<LinkProps>>((props, ref) => {
const { to, children, component, ...rest } = props;
const [isPending, startTransition] = useTransition();
const navigate = useNavigate();
const { pathname } = useLocation();

const href = React.useMemo<string>(() => {
if (typeof to === 'object') {
return `${to.pathname || pathname}${to.search || ''}${to.hash || ''}`;
}
return to;
}, [to]);

const handleClick = (e: MouseEvent<HTMLAnchorElement>) => {
props.onClick?.(e);
if (!href?.startsWith('http')) {
// Should support open in new tab
if (!e.metaKey && !e.ctrlKey && !e.shiftKey) {
e.preventDefault();
startTransition(() => {
if (href) {
navigate(href);
}
});
const Link = forwardRef<HTMLAnchorElement, React.PropsWithChildren<LinkProps>>(
({ component, children, to, ...rest }, ref) => {
const { pathname } = useLocation();
const { preloadRoute } = useAppData();
const navigate = useNavigate();
const href = useMemo<string>(() => {
if (typeof to === 'object') {
return `${to.pathname || pathname}${to.search || ''}${to.hash || ''}`;
}
return to;
}, [to]);
const onClick = (e: MouseEvent<HTMLAnchorElement>) => {
rest.onClick?.(e);
if (!href?.startsWith('http')) {
// Should support open in new tab
if (!e.metaKey && !e.ctrlKey && !e.shiftKey) {
e.preventDefault();
navigate(href);
}
}
};
if (component) {
return React.createElement(
component,
{
...rest,
ref,
href,
onClick,
onMouseEnter: () => preloadRoute?.(href),
},
children,
);
}
};

useLayoutEffect(() => {
if (isPending) {
nprogress.start();
} else {
nprogress.done();
}
}, [isPending]);

if (component) {
return React.createElement(
component,
{
...rest,
ref,
onClick: handleClick,
href,
},
children,
return (
<DumiLink ref={ref} {...rest} to={href} prefetch>
{children}
</DumiLink>
);
}

return (
<DumiLink ref={ref} onClick={handleClick} {...rest} to={href} prefetch>
{children}
</DumiLink>
);
});
},
);

export default Link;
3 changes: 2 additions & 1 deletion .dumi/theme/slots/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ import {
import { TinyColor } from '@ctrl/tinycolor';
import { createStyles } from 'antd-style';
import getAlphaColor from 'antd/es/theme/util/getAlphaColor';
import { FormattedMessage, Link } from 'dumi';
import { FormattedMessage } from 'dumi';
import RcFooter from 'rc-footer';
import type { FooterColumn } from 'rc-footer/lib/column';
import React, { useContext } from 'react';

import useLocale from '../../../hooks/useLocale';
import useLocation from '../../../hooks/useLocation';
import Link from '../../../theme/common/Link';
import SiteContext from '../SiteContext';
import AdditionalInfo from './AdditionalInfo';

Expand Down
4 changes: 4 additions & 0 deletions .dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { version } from './package.json';

export default defineConfig({
plugins: ['dumi-plugin-color-chunk'],

// For <Link prefetch />
routePrefetch: {},
manifest: {},

conventionRoutes: {
// to avoid generate routes for .dumi/pages/index/components/xx
exclude: [/index\/components\//],
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ tag: vVERSION

---

## 1.0.3

`2024-12-16`

- 💄 Refactor the styles when `placement: 'end'` is set for `Bubble`. [#314](https://github.com/ant-design/x/pull/314) by [@YumoImer](https://github.com/YumoImer)
- 🐛 Fix occasional failure to trigger auto-scrolling when `autoScroll` is set in `Bubble.List`. [#336](https://github.com/ant-design/x/pull/336) by [@anzhou99Ru](https://github.com/anzhou99Ru)
- 📖 Enhance the official website to improve user experience. [#343](https://github.com/ant-design/x/pull/343), [#334](https://github.com/ant-design/x/pull/334), [#315](https://github.com/ant-design/x/pull/315), [#331](https://github.com/ant-design/x/pull/331) by [@afc163](https://github.com/afc163), [@YumoImer](https://github.com/YumoImer), [@Wxh16144](https://github.com/Wxh16144)
- 🛠 Fix errors encountered when running `pnpm lint`. [#313](https://github.com/ant-design/x/pull/313) by [@BQXBQX](https://github.com/BQXBQX)

## 1.0.2

`2024-12-04`
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ tag: vVERSION

---

## 1.0.3

`2024-12-16`

- 💄 优化 `Bubble` 设置 `placement: 'end'` 后的样式。[#314](https://github.com/ant-design/x/pull/314)[@YumoImer](https://github.com/YumoImer)
- 🐛 修复 `Bubble.List` 设置 `autoScroll` 后偶现无法触发自动滚动的问题。[#336](https://github.com/ant-design/x/pull/336)[@anzhou99Ru](https://github.com/anzhou99Ru)
- 📖 优化官网站点提升用户体验。[#343](https://github.com/ant-design/x/pull/343)[#334](https://github.com/ant-design/x/pull/334)[#315](https://github.com/ant-design/x/pull/315)[#331](https://github.com/ant-design/x/pull/331)[@afc163](https://github.com/afc163)[@YumoImer](https://github.com/YumoImer)[@Wxh16144](https://github.com/Wxh16144)
- 🛠 修复 `pnpm lint` 时的错误。[#313](https://github.com/ant-design/x/pull/313)[@BQXBQX](https://github.com/BQXBQX)

## 1.0.2

`2024-12-04`
Expand Down
8 changes: 6 additions & 2 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

轻松打造 AI 驱动的界面。

[![CI status][github-action-image]][github-action-url] [![codecov][codecov-image]][codecov-url] [![NPM version][npm-image]][npm-url] [![NPM downloads][download-image]][download-url] [![][bundlephobia-image]][bundlephobia-url]
[![CI status][github-action-image]][github-action-url] [![codecov][codecov-image]][codecov-url] [![NPM version][npm-image]][npm-url]

[Changelog](./CHANGELOG.zh-US.md) · [Report Bug][github-issues-bug-report] · [Request Feature][github-issues-feature-request] · [English](./README.md) · 中文
[![NPM downloads][download-image]][download-url] [![][bundlephobia-image]][bundlephobia-url] [![antd][antd-image]][antd-url]

[更新日志](./CHANGELOG.zh-US.md) · [报告一个 Bug][github-issues-bug-report] · [想新增特性?][github-issues-feature-request] · [English](./README.md) · 中文

[npm-image]: https://img.shields.io/npm/v/@ant-design/x.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@ant-design/x
Expand All @@ -22,6 +24,8 @@
[bundlephobia-url]: https://bundlephobia.com/package/@ant-design/x
[github-issues-bug-report]: https://github.com/ant-design/x/issues/new?template=bug-report.yml
[github-issues-feature-request]: https://github.com/ant-design/x/issues/new?template=bug-feature-request.yml
[antd-image]: https://img.shields.io/badge/-Ant%20Design-blue?labelColor=black&logo=antdesign&style=flat-square
[antd-url]: https://ant.design

</div>

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

Craft AI-driven interfaces effortlessly.

[![CI status][github-action-image]][github-action-url] [![codecov][codecov-image]][codecov-url] [![NPM version][npm-image]][npm-url] [![NPM downloads][download-image]][download-url] [![][bundlephobia-image]][bundlephobia-url]
[![CI status][github-action-image]][github-action-url] [![codecov][codecov-image]][codecov-url] [![NPM version][npm-image]][npm-url]

[![NPM downloads][download-image]][download-url] [![][bundlephobia-image]][bundlephobia-url] [![antd][antd-image]][antd-url]

[Changelog](./CHANGELOG.en-US.md) · [Report Bug][github-issues-bug-report] · [Request Feature][github-issues-feature-request] · English · [中文](./README-zh_CN.md)

Expand All @@ -22,6 +24,8 @@ Craft AI-driven interfaces effortlessly.
[bundlephobia-url]: https://bundlephobia.com/package/@ant-design/x
[github-issues-bug-report]: https://github.com/ant-design/x/issues/new?template=bug-report.yml
[github-issues-feature-request]: https://github.com/ant-design/x/issues/new?template=bug-feature-request.yml
[antd-image]: https://img.shields.io/badge/-Ant%20Design-blue?labelColor=black&logo=antdesign&style=flat-square
[antd-url]: https://ant.design

</div>

Expand Down
Binary file modified bun.lockb
Binary file not shown.
6 changes: 5 additions & 1 deletion components/bubble/BubbleList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export interface BubbleListProps extends React.HTMLAttributes<HTMLDivElement> {
roles?: RolesType;
}

const TOLERANCE = 1;

const BubbleList: React.ForwardRefRenderFunction<BubbleListRef, BubbleListProps> = (props, ref) => {
const {
prefixCls: customizePrefixCls,
Expand Down Expand Up @@ -89,7 +91,9 @@ const BubbleList: React.ForwardRefRenderFunction<BubbleListRef, BubbleListProps>
const onInternalScroll: React.UIEventHandler<HTMLDivElement> = (e) => {
const target = e.target as HTMLElement;

setScrollReachEnd(target.scrollTop + target.clientHeight === target.scrollHeight);
setScrollReachEnd(
target.scrollHeight - Math.abs(target.scrollTop) - target.clientHeight <= TOLERANCE,
);
};

React.useEffect(() => {
Expand Down
Loading

0 comments on commit e4bcb21

Please sign in to comment.