Skip to content

Commit

Permalink
docs: add more JSDoc (ant-design#48101)
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jia-nan authored Mar 26, 2024
1 parent 7ec9e68 commit 3e156b0
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 7 deletions.
5 changes: 5 additions & 0 deletions components/_util/warning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ type TypeWarning = BaseTypeWarning & {
};

export interface WarningContextProps {
/**
* @descCN 设置警告等级,设置 `false` 时会将废弃相关信息聚合为单条信息。
* @descEN Set the warning level. When set to `false`, discard related information will be aggregated into a single message.
* @since 5.10.0
*/
strict?: boolean;
}

Expand Down
50 changes: 44 additions & 6 deletions components/config-provider/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,52 @@ type ComponentsConfig = {
};

export interface ThemeConfig {
/**
* @descCN 用于修改 Design Token。
* @descEN Modify Design Token.
*/
token?: Partial<AliasToken>;
/**
* @descCN 用于修改各个组件的 Component Token 以及覆盖该组件消费的 Alias Token。
* @descEN Modify Component Token and Alias Token applied to components.
*/
components?: ComponentsConfig;
/**
* @descCN 用于修改 Seed Token 到 Map Token 的算法。
* @descEN Modify the algorithms of theme.
* @default defaultAlgorithm
*/
algorithm?: MappingAlgorithm | MappingAlgorithm[];
/**
* @descCN 是否继承外层 `ConfigProvider` 中配置的主题。
* @descEN Whether to inherit the theme configured in the outer layer `ConfigProvider`.
* @default true
*/
inherit?: boolean;
/**
* @descCN 是否开启 `hashed` 属性。如果你的应用中只存在一个版本的 antd,你可以设置为 `false` 来进一步减小样式体积。默认值为 `ture`。
* @descEN Whether to enable the `hashed` attribute. If there is only one version of antd in your application, you can set `false` to reduce the bundle size. defaults to `true`.
* @descCN 是否开启 `hashed` 属性。如果你的应用中只存在一个版本的 antd,你可以设置为 `false` 来进一步减小样式体积。
* @descEN Whether to enable the `hashed` attribute. If there is only one version of antd in your application, you can set `false` to reduce the bundle size.
* @default true
* @since 5.12.0
*/
hashed?: boolean;
/**
* @descCN 通过 `cssVar` 配置来开启 CSS 变量模式,这个配置会被继承。默认值为 `false`。
* @descEN Enable CSS variable mode through `cssVar` configuration, This configuration will be inherited. defaults to `false`.
* @descCN 通过 `cssVar` 配置来开启 CSS 变量模式,这个配置会被继承。
* @descEN Enable CSS variable mode through `cssVar` configuration, This configuration will be inherited.
* @default false
* @since 5.12.0
*/
cssVar?:
| {
/**
* Prefix for css variable, default to `ant`.
* @descCN css 变量的前缀
* @descEN Prefix for css variable.
* @default ant
*/
prefix?: string;
/**
* Unique key for theme, should be set manually < react@18.
* @descCN 主题的唯一 key,版本低于 react@18 时需要手动设置。
* @descEN Unique key for theme, should be set manually < react@18.
*/
key?: string;
}
Expand Down Expand Up @@ -141,7 +166,16 @@ export type SpaceConfig = ComponentStyleConfig & Pick<SpaceProps, 'size' | 'clas
export type PopupOverflow = 'viewport' | 'scroll';

export interface WaveConfig {
/**
* @descCN 是否开启水波纹效果。如果需要关闭,可以设置为 `false`。
* @descEN Whether to use wave effect. If it needs to close, set to `false`.
* @default true
*/
disabled?: boolean;
/**
* @descCN 自定义水波纹效果。
* @descEN Customized wave effect.
*/
showEffect?: ShowWaveEffect;
}

Expand All @@ -152,6 +186,10 @@ export interface ConfigConsumerProps {
iconPrefixCls: string;
getPrefixCls: (suffixCls?: string, customizePrefixCls?: string) => string;
renderEmpty?: RenderEmptyHandler;
/**
* @descCN 设置 [Content Security Policy](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CSP) 配置。
* @descEN Set the [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) config.
*/
csp?: CSPConfig;
autoInsertSpaceInButton?: boolean;
input?: InputConfig;
Expand Down
14 changes: 14 additions & 0 deletions components/config-provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,25 @@ export interface ConfigProviderProps {
textArea?: TextAreaConfig;
select?: SelectConfig;
pagination?: PaginationConfig;
/**
* @descCN 语言包配置,语言包可到 `antd/locale` 目录下寻找。
* @descEN Language package setting, you can find the packages in `antd/locale`.
*/
locale?: Locale;
componentSize?: SizeType;
componentDisabled?: boolean;
/**
* @descCN 设置布局展示方向。
* @descEN Set direction of layout.
* @default ltr
*/
direction?: DirectionType;
space?: SpaceConfig;
/**
* @descCN 设置 `false` 时关闭虚拟滚动。
* @descEN Close the virtual scrolling when setting `false`.
* @default true
*/
virtual?: boolean;
/** @deprecated Please use `popupMatchSelectWidth` instead */
dropdownMatchSelectWidth?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion components/config-provider/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default Demo;
| autoInsertSpaceInButton | 设置为 `false` 时,移除按钮中 2 个汉字之间的空格 | boolean | true | |
| componentDisabled | 设置 antd 组件禁用状态 | boolean | - | 4.21.0 |
| componentSize | 设置 antd 组件大小 | `small` \| `middle` \| `large` | - | |
| csp | 设置 [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) 配置 | { nonce: string } | - | |
| csp | 设置 [Content Security Policy](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CSP) 配置 | { nonce: string } | - | |
| direction | 设置文本展示方向。 [示例](#components-config-provider-demo-direction) | `ltr` \| `rtl` | `ltr` | |
| getPopupContainer | 弹出框(Select, Tooltip, Menu 等等)渲染父节点,默认渲染到 body 上。 | function(triggerNode) | () => document.body | |
| getTargetContainer | 配置 Affix、Anchor 滚动监听容器。 | () => HTMLElement | () => window | 4.2.0 |
Expand Down

0 comments on commit 3e156b0

Please sign in to comment.