Skip to content

Commit c7fc705

Browse files
committed
feat: add Iconfont support, and enhance useSplitter hook
1 parent 95ade05 commit c7fc705

File tree

22 files changed

+280
-55
lines changed

22 files changed

+280
-55
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
'react/no-array-index-key': 'error',
99
'react-hooks/exhaustive-deps': 0,
1010
'react-hooks/rules-of-hooks': 0,
11+
'react/prop-types': 0,
1112
'@tiny-codes/react-hooks/rules-of-hooks': ['error'],
1213
'@tiny-codes/react-hooks/exhaustive-deps': ['error'],
1314
},

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"i18n-ally.keystyle": "nested",
1919
"i18n-ally.fullReloadOnChanged": true,
2020
"i18n-ally.annotationInPlace": true,
21-
"cSpell.words": ["contexify"],
21+
"cSpell.words": ["contexify", "Iconfont"],
2222
"files.exclude": {
2323
"**/.git": true,
2424
"**/.svn": true,

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,21 @@
22

33
# Changelog
44

5-
## 1.7.5
5+
## 1.7.7
6+
7+
2026-3-9
8+
9+
### Features
10+
11+
- **ConfigProvider.ConfigContext**
12+
13+
- ✨ Add `getPrefixCls` in ConfigProvider.ConfigContext.
14+
15+
- **Iconfont**
16+
17+
- ✨ Add `createIconfont` function to create custom Iconfont components.
18+
19+
## 1.7.6
620

721
2026-2-28
822

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tiny-codes/react-easy",
3-
"version": "1.7.6",
3+
"version": "1.7.7",
44
"description": "Simplify React and AntDesign development with practical components and hooks",
55
"keywords": [
66
"react",

src/components/ColumnSetting/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { useContext, useEffect, useMemo, useState } from 'react';
2-
import { Button, Checkbox, ConfigProvider, Divider, Dropdown, Space, Typography } from 'antd';
2+
import { Button, Checkbox, Divider, Dropdown, Space, Typography } from 'antd';
33
import type { ButtonProps, DropdownProps } from 'antd';
44
import type { ColumnType } from 'antd/es/table';
55
import classNames from 'classnames';
66
import { ReloadOutlined, SettingOutlined } from '@ant-design/icons';
77
import { useRefFunction, useRefValue } from '../../hooks';
88
import useLocalStorage from '../../hooks/useLocalStorage';
99
import useT from '../../hooks/useT';
10+
import ConfigProvider from '../ConfigProvider';
1011
import useStyle from './style';
1112

1213
export interface ColumnSettingProps<T extends ColumnSettingItem = ColumnSettingItem> {

src/components/ConfigProvider/context.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { EditableTextProps } from '../EditableText';
99
import type { ModalActionProps } from '../ModalAction';
1010

1111
export interface ReactEasyContextProps {
12+
getPrefixCls: (suffixCls: string, customizePrefixCls?: string) => string;
1213
/**
1314
* - **EN:** Language of the component, used for global configuration, can be 'en-US' or 'zh-CN'
1415
* - **CN:** 组件的语言,用于全局配置,可以是'en-US'或'zh-CN'
@@ -92,6 +93,7 @@ export interface ReactEasyContextProps {
9293
}
9394

9495
export const defaultContextValue: ReactEasyContextProps = {
96+
getPrefixCls: undefined!,
9597
lang: 'en-US',
9698
};
9799

src/components/ConfigProvider/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type localesEn from '../../locales/langs/en';
77
import ReactEasyContext, { type ReactEasyContextProps } from './context';
88
import useStyle from './style';
99

10-
export interface ConfigProviderProps extends ReactEasyContextProps {
10+
export interface ConfigProviderProps extends Omit<ReactEasyContextProps, 'getPrefixCls'> {
1111
/**
1212
* - **EN:** Child elements of the ConfigProvider
1313
* - **CN:** ConfigProvider 的子元素
@@ -40,7 +40,7 @@ export interface ConfigProviderProps extends ReactEasyContextProps {
4040
* - **EN:** Provide global configuration for AntdHelper
4141
* - **CN:** 提供AntdHelper的全局配置
4242
*/
43-
const ConfigProvider: FC<ConfigProviderProps> = (props) => {
43+
const ConfigProvider: FC<ConfigProviderProps> & { ConfigContext: typeof ReactEasyContext } = (props) => {
4444
const { children, locales: userLocales, prefixCls: prefixClsInProps, className, style, ...restProps } = props;
4545
const { lang: langInProps } = restProps;
4646
const { getPrefixCls, rootPrefixCls } = useContext(ReactConfigProvider.ConfigContext);
@@ -51,10 +51,14 @@ const ConfigProvider: FC<ConfigProviderProps> = (props) => {
5151
if (langInProps !== locales.language) {
5252
locales.changeLanguage(langInProps || 'en-US');
5353
}
54-
return restProps;
54+
return {
55+
...restProps,
56+
getPrefixCls: (suffixCls: string, customizePrefixCls?: string) =>
57+
getPrefixCls(`easy-${suffixCls}`, customizePrefixCls),
58+
};
5559
},
5660
// eslint-disable-next-line @tiny-codes/react-hooks/exhaustive-deps
57-
[langInProps, ...Object.values(restProps)]
61+
[langInProps, getPrefixCls, ...Object.values(restProps)]
5862
);
5963

6064
useEffect(() => {
@@ -79,5 +83,6 @@ const ConfigProvider: FC<ConfigProviderProps> = (props) => {
7983
);
8084
};
8185
ConfigProvider.displayName = 'ReactEasyConfigProvider';
86+
ConfigProvider.ConfigContext = ReactEasyContext;
8287

8388
export default ConfigProvider;

src/components/ConfigProvider/style/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import type { AliasToken, GenerateStyle } from 'antd/es/theme/internal';
33
import type { CSSObject } from '@ant-design/cssinjs';
44
import type { FullToken } from '@ant-design/cssinjs-utils';
55

6-
type OverflowTagsToken = FullToken<{ ''?: object }, AliasToken, ''>;
6+
type ConfigProviderToken = FullToken<{ ''?: object }, AliasToken, ''>;
77

8-
const genStyle: GenerateStyle<OverflowTagsToken> = (token): CSSObject => {
8+
const genStyle: GenerateStyle<ConfigProviderToken> = (token): CSSObject => {
99
const { componentCls } = token;
1010
return {
1111
[componentCls]: {
@@ -87,4 +87,4 @@ const genStyle: GenerateStyle<OverflowTagsToken> = (token): CSSObject => {
8787
};
8888
};
8989

90-
export default genStyleHooks('EasyConfigProvider' as never, genStyle);
90+
export default genStyleHooks('ConfigProvider' as never, genStyle);

src/components/ContextMenu/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import type { CSSProperties, ReactNode } from 'react';
22
import { forwardRef, useContext, useImperativeHandle, useMemo } from 'react';
3-
import { theme as AntdTheme, ConfigProvider, Typography } from 'antd';
3+
import { ConfigProvider as AntConfigProvider, theme as AntdTheme, Typography } from 'antd';
44
import classNames from 'classnames';
55
import type { ItemProps, MenuProps, SeparatorProps, ShowContextMenuParams, SubMenuProps } from 'react-contexify';
66
import { Item, Menu, RightSlot, Separator, Submenu, useContextMenu } from 'react-contexify';
77
import { useRefFunction } from '../../hooks';
8+
import ConfigProvider from '../ConfigProvider';
89
import useStyle from './style';
910
import 'react-contexify/dist/ReactContexify.css';
1011

@@ -209,11 +210,11 @@ function getShortcutText(
209210
const keys: ReactNode[] = [];
210211
const Keyboard = (props: { children: ReactNode }) => {
211212
return (
212-
<ConfigProvider theme={{ algorithm: theme === 'dark' ? AntdTheme.darkAlgorithm : undefined }}>
213+
<AntConfigProvider theme={{ algorithm: theme === 'dark' ? AntdTheme.darkAlgorithm : undefined }}>
213214
<Typography.Text keyboard className={`${cmpPrefixCls}-shortcut-key`}>
214215
{props.children}
215216
</Typography.Text>
216-
</ConfigProvider>
217+
</AntConfigProvider>
217218
);
218219
};
219220
if (event.ctrlKey) keys.push(<Keyboard>^</Keyboard>);

src/components/ContextMenu/style/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import type { AliasToken, GenerateStyle } from 'antd/es/theme/internal';
33
import type { CSSObject } from '@ant-design/cssinjs';
44
import type { FullToken } from '@ant-design/cssinjs-utils';
55

6-
type OverflowTagsToken = FullToken<{ ''?: object }, AliasToken, ''>;
6+
type ContextMenuToken = FullToken<{ ''?: object }, AliasToken, ''>;
77

8-
const genStyle: GenerateStyle<OverflowTagsToken> = (token): CSSObject => {
8+
const genStyle: GenerateStyle<ContextMenuToken> = (token): CSSObject => {
99
const { componentCls } = token;
1010
return {
1111
[componentCls]: {

0 commit comments

Comments
 (0)