Skip to content

Commit

Permalink
refactor: rename XConfigProvider -> XProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
YumoImer committed Sep 19, 2024
1 parent eee2c27 commit f0de5b5
Show file tree
Hide file tree
Showing 45 changed files with 129 additions and 133 deletions.
4 changes: 2 additions & 2 deletions .dumi/components/SemanticPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { XConfigProvider } from '@ant-design/x';
import { XProvider } from '@ant-design/x';
import { Col, Flex, Row, Tag, Typography, theme } from 'antd';
import { createStyles, css } from 'antd-style';
import classnames from 'classnames';
Expand Down Expand Up @@ -138,7 +138,7 @@ const SemanticPreview: React.FC<SemanticPreviewProps> = (props) => {
<div className={classnames(styles.container)} ref={containerRef}>
<Row style={{ minHeight: height }}>
<Col span={16} className={classnames(styles.colWrap)}>
<XConfigProvider theme={{ token: { motion: false } }}>{cloneNode}</XConfigProvider>
<XProvider theme={{ token: { motion: false } }}>{cloneNode}</XProvider>
</Col>
<Col span={8}>
<ul className={classnames(styles.listWrap)}>
Expand Down
14 changes: 7 additions & 7 deletions .dumi/theme/builtins/ComponentTokenTable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LinkOutlined, QuestionCircleOutlined, RightOutlined } from '@ant-design/icons';
import { XConfigProvider } from '@ant-design/x';
import { XProvider } from '@ant-design/x';
import { Popover, Table, Typography } from 'antd';
import { createStyles, css, useTheme } from 'antd-style';
import { getDesignToken } from 'antd-token-previewer';
Expand Down Expand Up @@ -128,7 +128,7 @@ const SubTokenTable: React.FC<SubTokenTableProps> = (props) => {
.filter(Boolean);

const code = component
? `<XConfigProvider
? `<XProvider
theme={{
components: {
${component}: {
Expand All @@ -138,16 +138,16 @@ const SubTokenTable: React.FC<SubTokenTableProps> = (props) => {
}}
>
...
</XConfigProvider>`
: `<XConfigProvider
</XProvider>`
: `<XProvider
theme={{
token: {
/* ${comment?.globalComment} */
},
}}
>
...
</XConfigProvider>`;
</XProvider>`;

return (
<>
Expand Down Expand Up @@ -177,7 +177,7 @@ const SubTokenTable: React.FC<SubTokenTableProps> = (props) => {
</h3>
</div>
{open && (
<XConfigProvider theme={{ token: { borderRadius: 0 } }}>
<XProvider theme={{ token: { borderRadius: 0 } }}>
<Table
size="middle"
columns={columns}
Expand All @@ -187,7 +187,7 @@ const SubTokenTable: React.FC<SubTokenTableProps> = (props) => {
pagination={false}
rowKey={(record) => record.name}
/>
</XConfigProvider>
</XProvider>
)}
</>
);
Expand Down
6 changes: 3 additions & 3 deletions .dumi/theme/builtins/DemoWrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ExperimentFilled,
ExperimentOutlined,
} from '@ant-design/icons';
import { XConfigProvider } from '@ant-design/x';
import { XProvider } from '@ant-design/x';
import { Tooltip } from 'antd';
import classNames from 'classnames';
import { DumiDemoGrid, FormattedMessage } from 'dumi';
Expand Down Expand Up @@ -109,9 +109,9 @@ const DemoWrapper: typeof DumiDemoGrid = ({ items }) => {
)}
</Tooltip>
</span>
<XConfigProvider theme={{ cssVar: enableCssVar, hashed: !enableCssVar }}>
<XProvider theme={{ cssVar: enableCssVar, hashed: !enableCssVar }}>
<DumiDemoGrid items={demos} />
</XConfigProvider>
</XProvider>
</div>
);
};
Expand Down
6 changes: 3 additions & 3 deletions .dumi/theme/builtins/InstallDependencies/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { XConfigProvider } from '@ant-design/x';
import { XProvider } from '@ant-design/x';
import { Tabs } from 'antd';
import SourceCode from 'dumi/theme-default/builtins/SourceCode';
import type { Tab } from 'rc-tabs/lib/interface';
Expand Down Expand Up @@ -46,9 +46,9 @@ const InstallDependencies: React.FC<InstallProps> = (props) => {
].filter((item) => item.children);

return (
<XConfigProvider theme={{ components: { Tabs: { horizontalMargin: '0' } } }}>
<XProvider theme={{ components: { Tabs: { horizontalMargin: '0' } } }}>
<Tabs className="markdown" size="small" defaultActiveKey="npm" items={items} />
</XConfigProvider>
</XProvider>
);
};

Expand Down
6 changes: 3 additions & 3 deletions .dumi/theme/layouts/DocLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import dayjs from 'dayjs';

import 'dayjs/locale/zh-cn';

import { XConfigProvider } from '@ant-design/x';
import { XProvider } from '@ant-design/x';
import zhCN from 'antd/es/locale/zh_CN';
import { Helmet, useOutlet, useSiteData } from 'dumi';
import React, { useContext, useEffect, useLayoutEffect, useRef } from 'react';
Expand Down Expand Up @@ -106,11 +106,11 @@ const DocLayout: React.FC = () => {
content="https://gw.alipayobjects.com/zos/rmsportal/rlpTLlbMzTNYuZGGCVYM.png"
/>
</Helmet>
<XConfigProvider direction={direction} locale={lang === 'cn' ? zhCN : undefined}>
<XProvider direction={direction} locale={lang === 'cn' ? zhCN : undefined}>
<GlobalStyles />
<Header />
{content}
</XConfigProvider>
</XProvider>
</>
);
};
Expand Down
6 changes: 3 additions & 3 deletions .dumi/theme/slots/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GithubOutlined, MenuOutlined } from '@ant-design/icons';
import { XConfigProvider } from '@ant-design/x';
import { XProvider } from '@ant-design/x';
import { Alert, Col, Popover, Row, Select } from 'antd';
import { createStyles } from 'antd-style';
import classNames from 'classnames';
Expand Down Expand Up @@ -370,7 +370,7 @@ const Header: React.FC = () => {
</Popover>
)}
{isZhCN && bannerVisible && (
<XConfigProvider
<XProvider
theme={{
token: {
colorInfoBg: 'linear-gradient(90deg, #84fab0, #8fd3f4)',
Expand Down Expand Up @@ -405,7 +405,7 @@ const Header: React.FC = () => {
showIcon={false}
onClose={onBannerClose}
/>
</XConfigProvider>
</XProvider>
)}
<Row style={{ flexFlow: 'nowrap', height: 64 }}>
<Col {...colProps[0]}>
Expand Down
6 changes: 3 additions & 3 deletions .dumi/theme/slots/Sidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { XConfigProvider } from '@ant-design/x';
import { XProvider } from '@ant-design/x';
import { Col, Menu } from 'antd';
import { createStyles, useTheme } from 'antd-style';
import { useSidebarData } from 'dumi';
Expand Down Expand Up @@ -122,7 +122,7 @@ const Sidebar: React.FC = () => {
const { colorBgContainer } = useTheme();

const menuChild = (
<XConfigProvider
<XProvider
theme={{ components: { Menu: { itemBg: colorBgContainer, darkItemBg: colorBgContainer } } }}
>
<Menu
Expand All @@ -134,7 +134,7 @@ const Sidebar: React.FC = () => {
selectedKeys={[selectedKey]}
defaultOpenKeys={sidebarData?.map<string>(({ title }) => title!).filter(Boolean)}
/>
</XConfigProvider>
</XProvider>
);

return isMobile ? (
Expand Down
2 changes: 1 addition & 1 deletion components/_util/motion.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { CSSMotionProps, MotionEndEventHandler, MotionEventHandler } from 'rc-motion';
import type { MotionEvent } from 'rc-motion/lib/interface';
import { defaultPrefixCls } from '../x-config-provider';
import { defaultPrefixCls } from '../x-provider';

// ================== Collapse Motion ==================
const getCollapsedHeight: MotionEventHandler = () => ({ height: 0, opacity: 0 });
Expand Down
4 changes: 2 additions & 2 deletions components/bubble/Bubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';

import { Avatar } from 'antd';
import mergeStyles from '../_util/merge-styles';
import { useXConfig } from '../x-config-provider';
import { useXProvider } from '../x-provider';
import useTypedEffect from './hooks/useTypedEffect';
import useTypingConfig from './hooks/useTypingConfig';
import type { BubbleProps } from './interface';
Expand Down Expand Up @@ -47,7 +47,7 @@ const Bubble: React.ForwardRefRenderFunction<BubbleRef, BubbleProps> = (props, r
}));

// ============================ Prefix ============================
const { direction, getPrefixCls, bubble } = useXConfig();
const { direction, getPrefixCls, bubble } = useXProvider();

const prefixCls = getPrefixCls('bubble', customizePrefixCls);

Expand Down
4 changes: 2 additions & 2 deletions components/bubble/BubbleList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import classNames from 'classnames';
import { useEvent } from 'rc-util';
import pickAttrs from 'rc-util/lib/pickAttrs';
import * as React from 'react';
import { useXConfig } from '../x-config-provider';
import { useXProvider } from '../x-provider';
import Bubble, { BubbleContext } from './Bubble';
import type { BubbleRef } from './Bubble';
import useListData from './hooks/useListData';
Expand Down Expand Up @@ -57,7 +57,7 @@ const BubbleList: React.ForwardRefRenderFunction<BubbleListRef, BubbleListProps>
const bubbleRefs = React.useRef<Record<string, BubbleRef>>({});

// ============================ Prefix ============================
const { getPrefixCls } = useXConfig();
const { getPrefixCls } = useXProvider();

const prefixCls = getPrefixCls('bubble', customizePrefixCls);
const listPrefixCls = `${prefixCls}-list`;
Expand Down
4 changes: 2 additions & 2 deletions components/conversations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ConversationsItem, { type ConversationsItemProps } from './Item';

import useMergedState from 'rc-util/lib/hooks/useMergedState';
import mergeStyles from '../_util/merge-styles';
import { useXConfig } from '../x-config-provider';
import { useXProvider } from '../x-provider';
import useGroupable from './hooks/useGroupable';

import useStyle from './style';
Expand Down Expand Up @@ -116,7 +116,7 @@ const Conversations: React.FC<ConversationsProps> = (props) => {
const [groupList, enableGroup] = useGroupable(groupable, items);

// ============================ Prefix ============================
const { getPrefixCls, direction, conversations } = useXConfig();
const { getPrefixCls, direction, conversations } = useXProvider();

const prefixCls = getPrefixCls('conversations', customizePrefixCls);

Expand Down
4 changes: 2 additions & 2 deletions components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export { default as ThoughtChain } from './thought-chain';
export type { ThoughtChainProps, ThoughtChainItem } from './thought-chain';
export { default as Suggestion } from './suggestion';
export type { SuggestionProps } from './suggestion';
export { default as XConfigProvider } from './x-config-provider';
export type { XConfigProviderProps } from './x-config-provider';
export { default as XProvider } from './x-provider';
export type { XProviderProps } from './x-provider';
export { default as version } from './version';
4 changes: 2 additions & 2 deletions components/prompts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classnames from 'classnames';
import React from 'react';

import mergeStyles from '../_util/merge-styles';
import { useXConfig } from '../x-config-provider';
import { useXProvider } from '../x-provider';

import useStyle from './style';

Expand Down Expand Up @@ -85,7 +85,7 @@ const Prompts: React.FC<PromptsProps> = (props) => {
} = props;

// ============================ PrefixCls ============================
const { getPrefixCls, direction, prompts } = useXConfig();
const { getPrefixCls, direction, prompts } = useXProvider();

const prefixCls = getPrefixCls('prompts', customizePrefixCls);

Expand Down
4 changes: 2 additions & 2 deletions components/sender/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import pickAttrs from 'rc-util/lib/pickAttrs';
import getValue from 'rc-util/lib/utils/get';
import React from 'react';
import mergeStyles from '../_util/merge-styles';
import { useXConfig } from '../x-config-provider';
import { useXProvider } from '../x-provider';
import { ActionButtonContext } from './components/ActionButton';
import ClearButton from './components/ClearButton';
import LoadingButton from './components/LoadingButton';
Expand Down Expand Up @@ -88,7 +88,7 @@ const Sender: React.FC<SenderProps> = (props) => {
} = props;

// ============================= MISC =============================
const { direction, getPrefixCls, sender } = useXConfig();
const { direction, getPrefixCls, sender } = useXProvider();
const prefixCls = getPrefixCls('sender', customizePrefixCls);

const domProps = pickAttrs(rest, {
Expand Down
4 changes: 2 additions & 2 deletions components/suggestion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classnames from 'classnames';
import { useEvent, useMergedState } from 'rc-util';
import React, { useState } from 'react';
import mergeStyles from '../_util/merge-styles';
import { useXConfig } from '../x-config-provider';
import { useXProvider } from '../x-provider';
import useStyle from './style';
import useActive from './useActive';

Expand Down Expand Up @@ -57,7 +57,7 @@ function Suggestion<T = any>(props: SuggestionProps<T>) {
} = props;

// ============================= MISC =============================
const { direction, getPrefixCls, suggestion } = useXConfig();
const { direction, getPrefixCls, suggestion } = useXProvider();
const prefixCls = getPrefixCls('suggestion', customizePrefixCls);
const itemCls = `${prefixCls}-item`;

Expand Down
6 changes: 3 additions & 3 deletions components/theme/genStyleUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { genStyleUtils } from '@ant-design/cssinjs-utils';

import { useXConfig } from '../x-config-provider';
import { useXProvider } from '../x-provider';
import { useInternalToken } from './useToken';

import type { ComponentTokenMap } from './components';
Expand All @@ -12,7 +12,7 @@ export const { genStyleHooks, genComponentStyleHook, genSubStyleComponent } = ge
SeedToken
>({
usePrefix: () => {
const { getPrefixCls, iconPrefixCls } = useXConfig();
const { getPrefixCls, iconPrefixCls } = useXProvider();
return {
iconPrefixCls,
rootPrefixCls: getPrefixCls(),
Expand All @@ -23,7 +23,7 @@ export const { genStyleHooks, genComponentStyleHook, genSubStyleComponent } = ge
return { theme, realToken, hashId, token, cssVar };
},
useCSP: () => {
const { csp } = useXConfig();
const { csp } = useXProvider();
return csp ?? {};
},
layer: {
Expand Down
2 changes: 1 addition & 1 deletion components/theme/useToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import formatToken from 'antd/es/theme/util/alias';
import React from 'react';

import version from '../version';
import { defaultPrefixCls } from '../x-config-provider';
import { defaultPrefixCls } from '../x-provider';

import type { Theme } from '@ant-design/cssinjs';
import type { DesignTokenProviderProps } from 'antd/es/theme/context';
Expand Down
4 changes: 2 additions & 2 deletions components/thought-chain/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import classnames from 'classnames';
import pickAttrs from 'rc-util/lib/pickAttrs';
import React from 'react';

import { useXConfig } from '../x-config-provider';
import { useXProvider } from '../x-provider';
import useCollapsible from './hooks/useCollapsible';
import useStyle from './style';

Expand Down Expand Up @@ -80,7 +80,7 @@ const ThoughtChain: React.FC<ThoughtChainProps> = (props) => {
});

// ============================ Prefix ============================
const { getPrefixCls, direction, thoughtChain } = useXConfig();
const { getPrefixCls, direction, thoughtChain } = useXProvider();

const rootPrefixCls = getPrefixCls();

Expand Down
Loading

0 comments on commit f0de5b5

Please sign in to comment.