Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: sync main to feature #379

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
17 changes: 17 additions & 0 deletions .dumi/theme/common/PeterCat.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Assistant } from '@petercatai/assistant';
import React from 'react';
import '@petercatai/assistant/style';

const PeterCat: React.FC = () => {
return (
<Assistant
showBubble={true}
isVisible={false}
bottom={48}
token="e3092c32-9ed9-44c2-ad0c-7251e382c2df"
apiDomain="https://api.petercat.ai"
/>
);
};

export default PeterCat;
1 change: 1 addition & 0 deletions .dumi/theme/common/ThemeSwitch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const ThemeSwitch: React.FC<ThemeSwitchProps> = (props) => {
icon={<ThemeIcon />}
aria-label="Theme Switcher"
badge={{ dot: true }}
style={{ bottom: 120 }}
>
<Link
to={getLocalizedPathname('/theme-editor', isZhCN(pathname), search)}
Expand Down
4 changes: 4 additions & 0 deletions .dumi/theme/layouts/GlobalLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ import { DarkContext } from '../../hooks/useDark';
import useLayoutState from '../../hooks/useLayoutState';
import useLocation from '../../hooks/useLocation';
import SiteThemeProvider from '../SiteThemeProvider';
import PeterCat from '../common/PeterCat';
import type { ThemeName } from '../common/ThemeSwitch';
import type { SiteContextProps } from '../slots/SiteContext';
import SiteContext from '../slots/SiteContext';

import '@petercatai/assistant/style';

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

type Entries<T> = { [K in keyof T]: [K, T[K]] }[keyof T][];
Expand Down Expand Up @@ -203,6 +206,7 @@ const GlobalLayout: React.FC = () => {
value={theme}
onChange={(nextTheme) => updateSiteConfig({ theme: nextTheme })}
/>
<PeterCat />
</Suspense>
</App>
);
Expand Down
5 changes: 3 additions & 2 deletions .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 Expand Up @@ -170,7 +171,7 @@ const Footer: React.FC = () => {
},
{
title: <FormattedMessage id="app.footer.chinamirror" />,
url: 'https://ant-design.antgroup.com',
url: 'https://ant-design-x.antgroup.com',
},
],
};
Expand Down
24 changes: 10 additions & 14 deletions .dumi/theme/slots/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import useMenu from '../../../hooks/useMenu';
import SiteContext from '../SiteContext';

const useStyle = createStyles(({ token, css }) => {
const { antCls, fontFamily, colorSplit } = token;
const { antCls, fontFamily, colorSplit, marginXXL, paddingXXS } = token;

return {
asideContainer: css`
min-height: 100%;
padding-bottom: 48px;
padding-bottom: ${marginXXL}px !important;
font-family: Avenir, ${fontFamily}, sans-serif;
padding: 0 ${paddingXXS}px;

&${antCls}-menu-inline {
${antCls}-menu-submenu-title h4,
Expand Down Expand Up @@ -92,18 +93,13 @@ const useStyle = createStyles(({ token, css }) => {
`,
mainMenu: css`
z-index: 1;
position: sticky;
top: ${token.headerHeight}px;
width: 100%;
height: 100%;
max-height: calc(100vh - ${token.headerHeight}px);
overflow: hidden;
scrollbar-width: thin;
scrollbar-color: unset;

.ant-menu {
padding: 0 4px;
}
position: sticky;
top: ${token.headerHeight + token.contentMarginTop}px;
width: 100%;
max-height: calc(100vh - ${token.headerHeight + token.contentMarginTop}px);
overflow: hidden;
scrollbar-width: thin;
scrollbar-gutter: stable;

&:hover {
overflow-y: auto;
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
Loading