mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 09:26:06 +08:00
chore: Compatible for @types/react@18 (#34937)
* chore: bump types def * chore: part ts def * chore: part ts def * chore: part ts def * chore: part ts def * chore: part ts def * chore: part ts def * chore: part ts def * chore: part ts def * chore: part ts def * chore: part ts def * chore: free --legacy-peer-deps * chore: ignore peer * chore: fix ts logic * chore: use fork docsearch * chore: fix demo ts
This commit is contained in:
parent
f41b6a8a90
commit
5b8e4e51e9
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -40,7 +40,7 @@ jobs:
|
|||||||
|
|
||||||
- name: install
|
- name: install
|
||||||
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
|
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
|
||||||
run: npm ci --force
|
run: npm ci
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -12,6 +12,7 @@ export interface ActionButtonProps {
|
|||||||
buttonProps?: ButtonProps;
|
buttonProps?: ButtonProps;
|
||||||
emitEvent?: boolean;
|
emitEvent?: boolean;
|
||||||
quitOnNullishReturnValue?: boolean;
|
quitOnNullishReturnValue?: boolean;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isThenable(thing?: PromiseLike<any>): boolean {
|
function isThenable(thing?: PromiseLike<any>): boolean {
|
||||||
|
@ -27,6 +27,7 @@ function isNotGrey(color: string) {
|
|||||||
export interface WaveProps {
|
export interface WaveProps {
|
||||||
insertExtraNode?: boolean;
|
insertExtraNode?: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Wave extends React.Component<WaveProps> {
|
export default class Wave extends React.Component<WaveProps> {
|
||||||
|
@ -4,6 +4,7 @@ import Alert from '.';
|
|||||||
interface ErrorBoundaryProps {
|
interface ErrorBoundaryProps {
|
||||||
message?: React.ReactNode;
|
message?: React.ReactNode;
|
||||||
description?: React.ReactNode;
|
description?: React.ReactNode;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ErrorBoundary extends React.Component<
|
export default class ErrorBoundary extends React.Component<
|
||||||
|
@ -98,7 +98,7 @@ export default class Anchor extends React.Component<AnchorProps, AnchorState, Co
|
|||||||
activeLink: null,
|
activeLink: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
content: ConfigConsumerProps;
|
context: ConfigConsumerProps;
|
||||||
|
|
||||||
private wrapperRef = React.createRef<HTMLDivElement>();
|
private wrapperRef = React.createRef<HTMLDivElement>();
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ const SizeContext = React.createContext<AvatarSize>('default');
|
|||||||
|
|
||||||
export interface SizeContextProps {
|
export interface SizeContextProps {
|
||||||
size?: AvatarSize;
|
size?: AvatarSize;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => (
|
export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => (
|
||||||
|
@ -34,6 +34,7 @@ export interface BadgeProps {
|
|||||||
size?: 'default' | 'small';
|
size?: 'default' | 'small';
|
||||||
offset?: [number | string, number | string];
|
offset?: [number | string, number | string];
|
||||||
title?: string;
|
title?: string;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Badge: CompoundedComponent = ({
|
const Badge: CompoundedComponent = ({
|
||||||
|
@ -27,6 +27,7 @@ export interface BreadcrumbProps {
|
|||||||
) => React.ReactNode;
|
) => React.ReactNode;
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBreadcrumbName(route: Route, params: any) {
|
function getBreadcrumbName(route: Route, params: any) {
|
||||||
|
@ -12,6 +12,7 @@ export interface BreadcrumbItemProps {
|
|||||||
dropdownProps?: DropDownProps;
|
dropdownProps?: DropDownProps;
|
||||||
onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLSpanElement>;
|
onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLSpanElement>;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
interface BreadcrumbItemInterface extends React.FC<BreadcrumbItemProps> {
|
interface BreadcrumbItemInterface extends React.FC<BreadcrumbItemProps> {
|
||||||
__ANT_BREADCRUMB_ITEM: boolean;
|
__ANT_BREADCRUMB_ITEM: boolean;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { ConfigContext } from '../config-provider';
|
import { ConfigContext } from '../config-provider';
|
||||||
|
|
||||||
interface BreadcrumbSeparatorInterface extends React.FC {
|
interface BreadcrumbSeparatorInterface extends React.FC<{ children?: React.ReactNode }> {
|
||||||
__ANT_BREADCRUMB_SEPARATOR: boolean;
|
__ANT_BREADCRUMB_SEPARATOR: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ export interface ButtonGroupProps {
|
|||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
className?: string;
|
className?: string;
|
||||||
prefixCls?: string;
|
prefixCls?: string;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ButtonGroup: React.FC<ButtonGroupProps> = props => (
|
const ButtonGroup: React.FC<ButtonGroupProps> = props => (
|
||||||
|
@ -28,6 +28,7 @@ export interface CollapseProps {
|
|||||||
expandIconPosition?: ExpandIconPosition;
|
expandIconPosition?: ExpandIconPosition;
|
||||||
ghost?: boolean;
|
ghost?: boolean;
|
||||||
collapsible?: CollapsibleType;
|
collapsible?: CollapsibleType;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PanelProps {
|
interface PanelProps {
|
||||||
|
@ -6,6 +6,7 @@ const SizeContext = React.createContext<SizeType>(undefined);
|
|||||||
|
|
||||||
export interface SizeContextProps {
|
export interface SizeContextProps {
|
||||||
size?: SizeType;
|
size?: SizeType;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => (
|
export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => (
|
||||||
|
@ -61,6 +61,7 @@ export interface DropDownProps {
|
|||||||
mouseEnterDelay?: number;
|
mouseEnterDelay?: number;
|
||||||
mouseLeaveDelay?: number;
|
mouseLeaveDelay?: number;
|
||||||
openClassName?: string;
|
openClassName?: string;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DropdownInterface extends React.FC<DropDownProps> {
|
interface DropdownInterface extends React.FC<DropDownProps> {
|
||||||
|
@ -427,7 +427,7 @@ function FormItem<Values = any>(props: FormItemProps<Values>): React.ReactElemen
|
|||||||
'Form.Item',
|
'Form.Item',
|
||||||
'`name` is only used for validate React element. If you are using Form.Item as layout display, please remove `name` instead.',
|
'`name` is only used for validate React element. If you are using Form.Item as layout display, please remove `name` instead.',
|
||||||
);
|
);
|
||||||
childNode = children;
|
childNode = children as React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return renderLayout(childNode, fieldId, isRequired);
|
return renderLayout(childNode, fieldId, isRequired);
|
||||||
|
@ -53,7 +53,7 @@ export interface ListProps<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ListLocale {
|
export interface ListLocale {
|
||||||
emptyText: React.ReactNode | (() => React.ReactNode);
|
emptyText: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListConsumerProps {
|
export interface ListConsumerProps {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import defaultLocaleData from './default';
|
import defaultLocaleData from './default';
|
||||||
import LocaleContext from './context';
|
import LocaleContext from './context';
|
||||||
|
import type { LocaleContextProps } from './context';
|
||||||
import { Locale } from '.';
|
import { Locale } from '.';
|
||||||
|
|
||||||
export type LocaleComponentName = Exclude<keyof Locale, 'locale'>;
|
export type LocaleComponentName = Exclude<keyof Locale, 'locale'>;
|
||||||
@ -8,11 +9,7 @@ export type LocaleComponentName = Exclude<keyof Locale, 'locale'>;
|
|||||||
export interface LocaleReceiverProps<C extends LocaleComponentName = LocaleComponentName> {
|
export interface LocaleReceiverProps<C extends LocaleComponentName = LocaleComponentName> {
|
||||||
componentName: C;
|
componentName: C;
|
||||||
defaultLocale?: Locale[C] | (() => Locale[C]);
|
defaultLocale?: Locale[C] | (() => Locale[C]);
|
||||||
children: (
|
children: (locale: Locale[C], localeCode?: string, fullLocale?: object) => React.ReactNode;
|
||||||
locale: Exclude<Locale[C], undefined>,
|
|
||||||
localeCode?: string,
|
|
||||||
fullLocale?: object,
|
|
||||||
) => React.ReactNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class LocaleReceiver<
|
export default class LocaleReceiver<
|
||||||
@ -24,7 +21,9 @@ export default class LocaleReceiver<
|
|||||||
|
|
||||||
static contextType = LocaleContext;
|
static contextType = LocaleContext;
|
||||||
|
|
||||||
getLocale(): Exclude<Locale[C], undefined> {
|
context: LocaleContextProps;
|
||||||
|
|
||||||
|
getLocale(): Locale[C] {
|
||||||
const { componentName, defaultLocale } = this.props;
|
const { componentName, defaultLocale } = this.props;
|
||||||
const locale = defaultLocale || defaultLocaleData[componentName ?? 'global'];
|
const locale = defaultLocale || defaultLocaleData[componentName ?? 'global'];
|
||||||
const antLocale = this.context;
|
const antLocale = this.context;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { createContext } from 'react';
|
import { createContext } from 'react';
|
||||||
import { Locale } from '.';
|
import { Locale } from '.';
|
||||||
|
|
||||||
const LocaleContext = createContext<(Partial<Locale> & { exist?: boolean }) | undefined>(undefined);
|
export type LocaleContextProps = Partial<Locale> & { exist?: boolean };
|
||||||
|
|
||||||
|
const LocaleContext = createContext<LocaleContextProps | undefined>(undefined);
|
||||||
|
|
||||||
export default LocaleContext;
|
export default LocaleContext;
|
||||||
|
@ -111,9 +111,13 @@ function InternalMenu(props: InternalMenuProps) {
|
|||||||
prefixCls={prefixCls}
|
prefixCls={prefixCls}
|
||||||
direction={direction}
|
direction={direction}
|
||||||
defaultMotions={defaultMotions}
|
defaultMotions={defaultMotions}
|
||||||
expandIcon={cloneElement(expandIcon, {
|
expandIcon={
|
||||||
className: `${prefixCls}-submenu-expand-icon`,
|
typeof expandIcon === 'function'
|
||||||
})}
|
? expandIcon
|
||||||
|
: cloneElement(expandIcon, {
|
||||||
|
className: `${prefixCls}-submenu-expand-icon`,
|
||||||
|
})
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</MenuContext.Provider>
|
</MenuContext.Provider>
|
||||||
);
|
);
|
||||||
|
@ -132,9 +132,9 @@ export type NoticeType = keyof typeof typeToIcon;
|
|||||||
export const typeList = Object.keys(typeToIcon) as NoticeType[];
|
export const typeList = Object.keys(typeToIcon) as NoticeType[];
|
||||||
|
|
||||||
export interface ArgsProps {
|
export interface ArgsProps {
|
||||||
content: React.ReactNode;
|
content: any;
|
||||||
duration?: number;
|
duration?: number;
|
||||||
type: NoticeType;
|
type?: NoticeType;
|
||||||
prefixCls?: string;
|
prefixCls?: string;
|
||||||
rootPrefixCls?: string;
|
rootPrefixCls?: string;
|
||||||
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
||||||
@ -152,7 +152,7 @@ function getRCNoticeProps(
|
|||||||
iconPrefixCls?: string,
|
iconPrefixCls?: string,
|
||||||
): NoticeContent {
|
): NoticeContent {
|
||||||
const duration = args.duration !== undefined ? args.duration : defaultDuration;
|
const duration = args.duration !== undefined ? args.duration : defaultDuration;
|
||||||
const IconComponent = typeToIcon[args.type];
|
const IconComponent = typeToIcon[args.type!];
|
||||||
const messageClass = classNames(`${prefixCls}-custom-content`, {
|
const messageClass = classNames(`${prefixCls}-custom-content`, {
|
||||||
[`${prefixCls}-${args.type}`]: args.type,
|
[`${prefixCls}-${args.type}`]: args.type,
|
||||||
[`${prefixCls}-rtl`]: rtl === true,
|
[`${prefixCls}-rtl`]: rtl === true,
|
||||||
|
@ -81,6 +81,7 @@ export interface ModalProps {
|
|||||||
closeIcon?: React.ReactNode;
|
closeIcon?: React.ReactNode;
|
||||||
modalRender?: (node: React.ReactNode) => React.ReactNode;
|
modalRender?: (node: React.ReactNode) => React.ReactNode;
|
||||||
focusTriggerAfterClose?: boolean;
|
focusTriggerAfterClose?: boolean;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
type getContainerFunc = () => HTMLElement;
|
type getContainerFunc = () => HTMLElement;
|
||||||
|
@ -27,6 +27,7 @@ export interface PageHeaderProps {
|
|||||||
onBack?: (e?: React.MouseEvent<HTMLDivElement>) => void;
|
onBack?: (e?: React.MouseEvent<HTMLDivElement>) => void;
|
||||||
className?: string;
|
className?: string;
|
||||||
ghost?: boolean;
|
ghost?: boolean;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderBack = (
|
const renderBack = (
|
||||||
|
@ -49,6 +49,7 @@ export interface ProgressProps {
|
|||||||
steps?: number;
|
steps?: number;
|
||||||
/** @deprecated Use `success` instead */
|
/** @deprecated Use `success` instead */
|
||||||
successPercent?: number;
|
successPercent?: number;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Progress extends React.Component<ProgressProps> {
|
export default class Progress extends React.Component<ProgressProps> {
|
||||||
|
@ -37,6 +37,7 @@ export interface ResultProps {
|
|||||||
prefixCls?: string;
|
prefixCls?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExceptionImageMap keys
|
// ExceptionImageMap keys
|
||||||
@ -76,9 +77,9 @@ const renderExtra = (prefixCls: string, { extra }: ResultProps) =>
|
|||||||
extra && <div className={`${prefixCls}-extra`}>{extra}</div>;
|
extra && <div className={`${prefixCls}-extra`}>{extra}</div>;
|
||||||
|
|
||||||
export interface ResultType extends React.FC<ResultProps> {
|
export interface ResultType extends React.FC<ResultProps> {
|
||||||
PRESENTED_IMAGE_404: React.ReactNode;
|
PRESENTED_IMAGE_404: React.FC;
|
||||||
PRESENTED_IMAGE_403: React.ReactNode;
|
PRESENTED_IMAGE_403: React.FC;
|
||||||
PRESENTED_IMAGE_500: React.ReactNode;
|
PRESENTED_IMAGE_500: React.FC;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Result: ResultType = ({
|
const Result: ResultType = ({
|
||||||
|
@ -9,6 +9,8 @@ import SearchOutlined from '@ant-design/icons/SearchOutlined';
|
|||||||
import { ValidateStatus } from '../../form/FormItem';
|
import { ValidateStatus } from '../../form/FormItem';
|
||||||
import { getFeedbackIcon } from '../../_util/statusUtils';
|
import { getFeedbackIcon } from '../../_util/statusUtils';
|
||||||
|
|
||||||
|
type RenderNode = React.ReactNode | ((props: any) => React.ReactNode);
|
||||||
|
|
||||||
export default function getIcons({
|
export default function getIcons({
|
||||||
suffixIcon,
|
suffixIcon,
|
||||||
clearIcon,
|
clearIcon,
|
||||||
@ -22,9 +24,9 @@ export default function getIcons({
|
|||||||
showArrow,
|
showArrow,
|
||||||
}: {
|
}: {
|
||||||
suffixIcon?: React.ReactNode;
|
suffixIcon?: React.ReactNode;
|
||||||
clearIcon?: React.ReactNode;
|
clearIcon?: RenderNode;
|
||||||
menuItemSelectedIcon?: React.ReactNode;
|
menuItemSelectedIcon?: RenderNode;
|
||||||
removeIcon?: React.ReactNode;
|
removeIcon?: RenderNode;
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
multiple?: boolean;
|
multiple?: boolean;
|
||||||
hasFeedback?: boolean;
|
hasFeedback?: boolean;
|
||||||
|
@ -13,7 +13,7 @@ title:
|
|||||||
|
|
||||||
A simple loading status.
|
A simple loading status.
|
||||||
|
|
||||||
```jsx
|
```tsx
|
||||||
import { Spin } from 'antd';
|
import { Spin } from 'antd';
|
||||||
|
|
||||||
export default () => <Spin />;
|
export default () => <Spin />;
|
||||||
|
@ -13,7 +13,7 @@ title:
|
|||||||
|
|
||||||
Spin in a container.
|
Spin in a container.
|
||||||
|
|
||||||
```jsx
|
```tsx
|
||||||
import { Spin } from 'antd';
|
import { Spin } from 'antd';
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
|
@ -13,13 +13,13 @@ title:
|
|||||||
|
|
||||||
Embedding content into `Spin` will set it into loading state.
|
Embedding content into `Spin` will set it into loading state.
|
||||||
|
|
||||||
```jsx
|
```tsx
|
||||||
import { Spin, Switch, Alert } from 'antd';
|
import { Spin, Switch, Alert } from 'antd';
|
||||||
|
|
||||||
class Card extends React.Component {
|
class Card extends React.Component {
|
||||||
state = { loading: false };
|
state = { loading: false };
|
||||||
|
|
||||||
toggle = value => {
|
toggle = (value: boolean) => {
|
||||||
this.setState({ loading: value });
|
this.setState({ loading: value });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ export interface SpinProps {
|
|||||||
delay?: number;
|
delay?: number;
|
||||||
wrapperClassName?: string;
|
wrapperClassName?: string;
|
||||||
indicator?: SpinIndicator;
|
indicator?: SpinIndicator;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SpinState {
|
export interface SpinState {
|
||||||
|
@ -140,7 +140,7 @@ function InternalTable<RecordType extends object = any>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const baseColumns = React.useMemo(
|
const baseColumns = React.useMemo(
|
||||||
() => columns || convertChildrenToColumns(children),
|
() => columns || (convertChildrenToColumns(children) as ColumnsType<RecordType>),
|
||||||
[columns, children],
|
[columns, children],
|
||||||
);
|
);
|
||||||
const needResponsive = React.useMemo(
|
const needResponsive = React.useMemo(
|
||||||
@ -154,8 +154,7 @@ function InternalTable<RecordType extends object = any>(
|
|||||||
const matched = new Set(Object.keys(screens).filter((m: Breakpoint) => screens[m]));
|
const matched = new Set(Object.keys(screens).filter((m: Breakpoint) => screens[m]));
|
||||||
|
|
||||||
return baseColumns.filter(
|
return baseColumns.filter(
|
||||||
(c: ColumnType<RecordType>) =>
|
c => !c.responsive || c.responsive.some((r: Breakpoint) => matched.has(r)),
|
||||||
!c.responsive || c.responsive.some((r: Breakpoint) => matched.has(r)),
|
|
||||||
);
|
);
|
||||||
}, [baseColumns, screens]);
|
}, [baseColumns, screens]);
|
||||||
|
|
||||||
@ -501,7 +500,7 @@ function InternalTable<RecordType extends object = any>(
|
|||||||
{topPaginationNode}
|
{topPaginationNode}
|
||||||
<RcTable<RecordType>
|
<RcTable<RecordType>
|
||||||
{...tableProps}
|
{...tableProps}
|
||||||
columns={mergedColumns}
|
columns={mergedColumns as RcTableProps<RecordType>['columns']}
|
||||||
direction={direction}
|
direction={direction}
|
||||||
expandable={mergedExpandable}
|
expandable={mergedExpandable}
|
||||||
prefixCls={prefixCls}
|
prefixCls={prefixCls}
|
||||||
@ -518,7 +517,7 @@ function InternalTable<RecordType extends object = any>(
|
|||||||
// Internal
|
// Internal
|
||||||
internalHooks={INTERNAL_HOOKS}
|
internalHooks={INTERNAL_HOOKS}
|
||||||
internalRefs={internalRefs as any}
|
internalRefs={internalRefs as any}
|
||||||
transformColumns={transformColumns}
|
transformColumns={transformColumns as RcTableProps<RecordType>['transformColumns']}
|
||||||
/>
|
/>
|
||||||
{bottomPaginationNode}
|
{bottomPaginationNode}
|
||||||
</Spin>
|
</Spin>
|
||||||
|
@ -88,7 +88,7 @@ export interface FilterDropdownProps {
|
|||||||
visible: boolean;
|
visible: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ColumnType<RecordType> extends RcColumnType<RecordType> {
|
export interface ColumnType<RecordType> extends Omit<RcColumnType<RecordType>, 'title'> {
|
||||||
title?: ColumnTitle<RecordType>;
|
title?: ColumnTitle<RecordType>;
|
||||||
// Sorter
|
// Sorter
|
||||||
sorter?:
|
sorter?:
|
||||||
|
@ -15,6 +15,7 @@ export interface TimelineProps {
|
|||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
reverse?: boolean;
|
reverse?: boolean;
|
||||||
mode?: 'left' | 'alternate' | 'right';
|
mode?: 'left' | 'alternate' | 'right';
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TimelineType extends React.FC<TimelineProps> {
|
interface TimelineType extends React.FC<TimelineProps> {
|
||||||
|
@ -11,9 +11,10 @@ export interface TimelineItemProps {
|
|||||||
position?: string;
|
position?: string;
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
label?: React.ReactNode;
|
label?: React.ReactNode;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for compatibililty
|
// for compatibility
|
||||||
// https://github.com/ant-design/ant-design/pull/26832
|
// https://github.com/ant-design/ant-design/pull/26832
|
||||||
export interface TimeLineItemProps extends TimelineItemProps {
|
export interface TimeLineItemProps extends TimelineItemProps {
|
||||||
__deprecated_do_not_use_it__?: any; // eslint-disable-line camelcase
|
__deprecated_do_not_use_it__?: any; // eslint-disable-line camelcase
|
||||||
|
@ -20,8 +20,8 @@ import { isValidElement } from '../_util/reactNode';
|
|||||||
|
|
||||||
const defaultRender = () => null;
|
const defaultRender = () => null;
|
||||||
|
|
||||||
function isRenderResultPlainObject(result: RenderResult) {
|
function isRenderResultPlainObject(result: RenderResult): result is RenderResultObject {
|
||||||
return (
|
return !!(
|
||||||
result &&
|
result &&
|
||||||
!isValidElement(result) &&
|
!isValidElement(result) &&
|
||||||
Object.prototype.toString.call(result) === '[object Object]'
|
Object.prototype.toString.call(result) === '[object Object]'
|
||||||
@ -274,7 +274,7 @@ export default class TransferList<
|
|||||||
|
|
||||||
renderItem = (item: RecordType): RenderedItem<RecordType> => {
|
renderItem = (item: RecordType): RenderedItem<RecordType> => {
|
||||||
const { render = defaultRender } = this.props;
|
const { render = defaultRender } = this.props;
|
||||||
const renderResult: RenderResult = render(item);
|
const renderResult = render(item);
|
||||||
const isRenderResultPlain = isRenderResultPlainObject(renderResult);
|
const isRenderResultPlain = isRenderResultPlainObject(renderResult);
|
||||||
return {
|
return {
|
||||||
renderedText: isRenderResultPlain
|
renderedText: isRenderResultPlain
|
||||||
|
@ -10,10 +10,12 @@ import { isValidElement, cloneElement } from '../../_util/reactNode';
|
|||||||
|
|
||||||
export default function renderSwitcherIcon(
|
export default function renderSwitcherIcon(
|
||||||
prefixCls: string,
|
prefixCls: string,
|
||||||
switcherIcon: React.ReactNode,
|
switcherIcon: React.ReactNode | ((props: any) => React.ReactNode),
|
||||||
showLine: boolean | { showLeafIcon: boolean } | undefined,
|
showLine: boolean | { showLeafIcon: boolean } | undefined,
|
||||||
{ isLeaf, expanded, loading }: AntTreeNodeProps,
|
treeNodeProps: AntTreeNodeProps,
|
||||||
) {
|
): React.ReactNode {
|
||||||
|
const { isLeaf, expanded, loading } = treeNodeProps;
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return <LoadingOutlined className={`${prefixCls}-switcher-loading-icon`} />;
|
return <LoadingOutlined className={`${prefixCls}-switcher-loading-icon`} />;
|
||||||
}
|
}
|
||||||
@ -38,7 +40,7 @@ export default function renderSwitcherIcon(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (switcherIcon) {
|
if (switcherIcon) {
|
||||||
return switcherIcon;
|
return typeof switcherIcon === 'function' ? switcherIcon(treeNodeProps) : switcherIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showLine) {
|
if (showLine) {
|
||||||
|
@ -129,6 +129,7 @@ export interface UploadProps<T = any> extends Pick<RcUploadProps, 'capture'> {
|
|||||||
itemRender?: ItemRender<T>;
|
itemRender?: ItemRender<T>;
|
||||||
/** Config max count of `fileList`. Will replace current one when `maxCount` is 1 */
|
/** Config max count of `fileList`. Will replace current one when `maxCount` is 1 */
|
||||||
maxCount?: number;
|
maxCount?: number;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UploadState<T = any> {
|
export interface UploadState<T = any> {
|
||||||
|
@ -161,8 +161,8 @@
|
|||||||
"@ant-design/bisheng-plugin": "^3.0.1",
|
"@ant-design/bisheng-plugin": "^3.0.1",
|
||||||
"@ant-design/hitu": "^0.0.0-alpha.13",
|
"@ant-design/hitu": "^0.0.0-alpha.13",
|
||||||
"@ant-design/tools": "^14.0.2",
|
"@ant-design/tools": "^14.0.2",
|
||||||
"@docsearch/css": "^3.0.0-alpha.39",
|
"@docsearch/css": "^3.0.0",
|
||||||
"@docsearch/react": "^3.0.0-alpha.39",
|
"docsearch-react-fork": "^0.0.0-alpha.0",
|
||||||
"@qixian.cs/github-contributors-list": "^1.0.3",
|
"@qixian.cs/github-contributors-list": "^1.0.3",
|
||||||
"@stackblitz/sdk": "^1.3.0",
|
"@stackblitz/sdk": "^1.3.0",
|
||||||
"@testing-library/jest-dom": "^5.16.3",
|
"@testing-library/jest-dom": "^5.16.3",
|
||||||
@ -175,7 +175,7 @@
|
|||||||
"@types/jest-image-snapshot": "^4.1.0",
|
"@types/jest-image-snapshot": "^4.1.0",
|
||||||
"@types/lodash": "^4.14.139",
|
"@types/lodash": "^4.14.139",
|
||||||
"@types/puppeteer": "^5.4.0",
|
"@types/puppeteer": "^5.4.0",
|
||||||
"@types/react": "^17.0.0",
|
"@types/react": "^18.0.0",
|
||||||
"@types/react-color": "^3.0.1",
|
"@types/react-color": "^3.0.1",
|
||||||
"@types/react-copy-to-clipboard": "^5.0.0",
|
"@types/react-copy-to-clipboard": "^5.0.0",
|
||||||
"@types/react-dom": "^18.0.0",
|
"@types/react-dom": "^18.0.0",
|
||||||
|
10
site/theme/template/Components/Helmet.tsx
Normal file
10
site/theme/template/Components/Helmet.tsx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
import { Helmet, HelmetProps } from 'react-helmet-async';
|
||||||
|
|
||||||
|
export interface WrapHelmetProps extends HelmetProps {
|
||||||
|
children?: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function WrapHelmet(props: WrapHelmetProps) {
|
||||||
|
return <Helmet {...props} />;
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
import React, { Children, cloneElement } from 'react';
|
import React, { Children, cloneElement } from 'react';
|
||||||
import { FormattedMessage, injectIntl } from 'react-intl';
|
import { FormattedMessage, injectIntl } from 'react-intl';
|
||||||
import { Helmet } from 'react-helmet-async';
|
|
||||||
import { getChildren } from 'jsonml.js/lib/utils';
|
import { getChildren } from 'jsonml.js/lib/utils';
|
||||||
import { Timeline, Alert, Affix } from 'antd';
|
import { Timeline, Alert, Affix } from 'antd';
|
||||||
import EditButton from './EditButton';
|
import EditButton from './EditButton';
|
||||||
import { getMetaDescription } from '../utils';
|
import { getMetaDescription } from '../utils';
|
||||||
|
import WrapHelmet from '../Components/Helmet';
|
||||||
|
|
||||||
interface LocaleString {
|
interface LocaleString {
|
||||||
[locale: string]: string;
|
[locale: string]: string;
|
||||||
@ -111,11 +111,11 @@ class Article extends React.Component<ArticleProps> {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<article className="markdown" onClick={this.onResourceClick}>
|
<article className="markdown" onClick={this.onResourceClick}>
|
||||||
<Helmet encodeSpecialCharacters={false}>
|
<WrapHelmet encodeSpecialCharacters={false}>
|
||||||
{helmetTitle && <title>{helmetTitle}</title>}
|
{helmetTitle && <title>{helmetTitle}</title>}
|
||||||
{helmetTitle && <meta property="og:title" content={helmetTitle} />}
|
{helmetTitle && <meta property="og:title" content={helmetTitle} />}
|
||||||
{metaDesc && <meta name="description" content={metaDesc} />}
|
{metaDesc && <meta name="description" content={metaDesc} />}
|
||||||
</Helmet>
|
</WrapHelmet>
|
||||||
{isNotTranslated && (
|
{isNotTranslated && (
|
||||||
<Alert
|
<Alert
|
||||||
type="warning"
|
type="warning"
|
||||||
@ -131,7 +131,7 @@ class Article extends React.Component<ArticleProps> {
|
|||||||
)}
|
)}
|
||||||
<div className={titleRegionClassName}>
|
<div className={titleRegionClassName}>
|
||||||
<h1>
|
<h1>
|
||||||
{(title as LocaleString)[locale] || title}
|
{typeof title === 'object' && title ? title[locale] : title}
|
||||||
{!subtitle || locale === 'en-US' ? null : <span className="subtitle">{subtitle}</span>}
|
{!subtitle || locale === 'en-US' ? null : <span className="subtitle">{subtitle}</span>}
|
||||||
<EditButton
|
<EditButton
|
||||||
title={<FormattedMessage id="app.content.edit-page" />}
|
title={<FormattedMessage id="app.content.edit-page" />}
|
||||||
|
@ -29,6 +29,7 @@ function getStyle() {
|
|||||||
interface BlockContentProps {
|
interface BlockContentProps {
|
||||||
title: React.ReactNode;
|
title: React.ReactNode;
|
||||||
extra?: React.ReactNode;
|
extra?: React.ReactNode;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BlockContent: React.FC<BlockContentProps> = ({ title, children, extra }) => (
|
const BlockContent: React.FC<BlockContentProps> = ({ title, children, extra }) => (
|
||||||
|
@ -2,14 +2,18 @@ import * as React from 'react';
|
|||||||
import * as ReactDOM from 'react-dom';
|
import * as ReactDOM from 'react-dom';
|
||||||
import { Link } from 'bisheng/router';
|
import { Link } from 'bisheng/router';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { Helmet } from 'react-helmet-async';
|
|
||||||
import canUseDom from 'rc-util/lib/Dom/canUseDom';
|
import canUseDom from 'rc-util/lib/Dom/canUseDom';
|
||||||
import { Input, Tooltip, Typography } from 'antd';
|
import { Input, Tooltip, Typography } from 'antd';
|
||||||
import { SearchOutlined } from '@ant-design/icons';
|
import { SearchOutlined } from '@ant-design/icons';
|
||||||
import { DocSearchProps, useDocSearchKeyboardEvents, DocSearchModalProps } from '@docsearch/react';
|
import {
|
||||||
|
DocSearchProps,
|
||||||
|
useDocSearchKeyboardEvents,
|
||||||
|
DocSearchModalProps,
|
||||||
|
} from 'docsearch-react-fork';
|
||||||
import '@docsearch/css';
|
import '@docsearch/css';
|
||||||
import { SharedProps } from './interface';
|
import { SharedProps } from './interface';
|
||||||
import { IAlgoliaConfig, transformHitUrl } from './algolia-config';
|
import { IAlgoliaConfig, transformHitUrl } from './algolia-config';
|
||||||
|
import WrapHelmet from '../../Components/Helmet';
|
||||||
|
|
||||||
import './SearchBar.less';
|
import './SearchBar.less';
|
||||||
|
|
||||||
@ -62,7 +66,7 @@ const SearchBar = ({
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
return import('@docsearch/react/modal').then(({ DocSearchModal }) => {
|
return import('docsearch-react-fork/modal').then(({ DocSearchModal }) => {
|
||||||
SearchModal = DocSearchModal;
|
SearchModal = DocSearchModal;
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
@ -127,14 +131,14 @@ const SearchBar = ({
|
|||||||
focused: isInputFocus,
|
focused: isInputFocus,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Helmet>
|
<WrapHelmet>
|
||||||
{/* pre-connect to algolia server */}
|
{/* pre-connect to algolia server */}
|
||||||
<link
|
<link
|
||||||
rel="preconnect"
|
rel="preconnect"
|
||||||
href={`https://${algoliaConfig.appId}-dsn.algolia.net`}
|
href={`https://${algoliaConfig.appId}-dsn.algolia.net`}
|
||||||
crossOrigin="anonymous"
|
crossOrigin="anonymous"
|
||||||
/>
|
/>
|
||||||
</Helmet>
|
</WrapHelmet>
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
placeholder={searchInputPlaceholder}
|
placeholder={searchInputPlaceholder}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { DocSearchHit } from '@docsearch/react/dist/esm/types';
|
import { DocSearchHit } from 'docsearch-react-fork/dist/esm/types';
|
||||||
|
|
||||||
let _internalATag: HTMLAnchorElement | null;
|
let _internalATag: HTMLAnchorElement | null;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import SearchBar from './SearchBar';
|
|||||||
import More from './More';
|
import More from './More';
|
||||||
import Navigation from './Navigation';
|
import Navigation from './Navigation';
|
||||||
import Github from './Github';
|
import Github from './Github';
|
||||||
import SiteContext from '../SiteContext';
|
import SiteContext, { SiteContextProps } from '../SiteContext';
|
||||||
import { ping } from '../../utils';
|
import { ping } from '../../utils';
|
||||||
import { AlgoliaConfig } from './algolia-config';
|
import { AlgoliaConfig } from './algolia-config';
|
||||||
|
|
||||||
@ -89,6 +89,8 @@ class Header extends React.Component<HeaderProps, HeaderState> {
|
|||||||
showTechUIButton: false,
|
showTechUIButton: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
context: SiteContextProps;
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { intl, router } = this.props;
|
const { intl, router } = this.props;
|
||||||
router.listen(this.handleHideMenu);
|
router.listen(this.handleHideMenu);
|
||||||
|
6
typings/custom-typings.d.ts
vendored
6
typings/custom-typings.d.ts
vendored
@ -32,10 +32,10 @@ declare module '*.json' {
|
|||||||
export default value;
|
export default value;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module '@docsearch/react/style/modal';
|
declare module 'docsearch-react-fork/style/modal';
|
||||||
|
|
||||||
declare module '@docsearch/react/modal' {
|
declare module 'docsearch-react-fork/modal' {
|
||||||
import { DocSearchModal as value } from '@docsearch/react';
|
import { DocSearchModal as value } from 'docsearch-react-fork';
|
||||||
export const DocSearchModal = value;
|
export const DocSearchModal = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user