@tiny-codes/react-easy 1.7.5 → 1.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/es/components/Animation/Pulse/index.d.ts +18 -2
- package/es/components/Animation/Pulse/index.js +1 -1
- package/es/components/Animation/Pulse/index.js.map +1 -1
- package/es/components/BreakLines/index.d.ts +7 -7
- package/es/components/BreakLines/index.js.map +1 -1
- package/es/components/ColumnSetting/index.d.ts +7 -2
- package/es/components/ColumnSetting/index.js +27 -16
- package/es/components/ColumnSetting/index.js.map +1 -1
- package/es/components/ConfigProvider/context.d.ts +2 -0
- package/es/components/ConfigProvider/context.js +1 -1
- package/es/components/ConfigProvider/context.js.map +1 -1
- package/es/components/ConfigProvider/index.d.ts +17 -1
- package/es/components/ConfigProvider/index.js +15 -8
- package/es/components/ConfigProvider/index.js.map +1 -1
- package/es/components/ContextMenu/index.d.ts +16 -0
- package/es/components/ContextMenu/index.js.map +1 -1
- package/es/components/EditableText/form.d.ts +4 -0
- package/es/components/EditableText/form.js.map +1 -1
- package/es/components/EditableText/index.d.ts +6 -2
- package/es/components/EditableText/index.js.map +1 -1
- package/es/components/FloatDrawer/index.d.ts +10 -0
- package/es/components/FloatDrawer/index.js.map +1 -1
- package/es/components/OverflowTags/index.d.ts +2 -0
- package/es/components/OverflowTags/index.js.map +1 -1
- package/es/hooks/index.d.ts +2 -0
- package/es/hooks/index.js +2 -0
- package/es/hooks/index.js.map +1 -1
- package/es/hooks/useLocalStorage.d.ts +16 -0
- package/es/hooks/useLocalStorage.js +115 -0
- package/es/hooks/useLocalStorage.js.map +1 -0
- package/es/hooks/useMovable.js +2 -2
- package/es/hooks/useMovable.js.map +1 -1
- package/es/locales/index.js +1 -1
- package/es/locales/index.js.map +1 -1
- package/es/utils/math.d.ts +11 -3
- package/es/utils/math.js +62 -9
- package/es/utils/math.js.map +1 -1
- package/lib/components/Animation/Pulse/index.d.ts +18 -2
- package/lib/components/Animation/Pulse/index.js +0 -5
- package/lib/components/Animation/Pulse/index.js.map +2 -2
- package/lib/components/BreakLines/index.d.ts +7 -7
- package/lib/components/BreakLines/index.js.map +1 -1
- package/lib/components/ColumnSetting/index.d.ts +7 -2
- package/lib/components/ColumnSetting/index.js +18 -14
- package/lib/components/ColumnSetting/index.js.map +3 -3
- package/lib/components/ConfigProvider/context.d.ts +2 -0
- package/lib/components/ConfigProvider/context.js +1 -1
- package/lib/components/ConfigProvider/context.js.map +2 -2
- package/lib/components/ConfigProvider/index.d.ts +17 -1
- package/lib/components/ConfigProvider/index.js +13 -6
- package/lib/components/ConfigProvider/index.js.map +2 -2
- package/lib/components/ContextMenu/index.d.ts +16 -0
- package/lib/components/ContextMenu/index.js.map +2 -2
- package/lib/components/EditableText/form.d.ts +4 -0
- package/lib/components/EditableText/form.js.map +2 -2
- package/lib/components/EditableText/index.d.ts +6 -2
- package/lib/components/EditableText/index.js.map +2 -2
- package/lib/components/FloatDrawer/index.d.ts +10 -0
- package/lib/components/FloatDrawer/index.js.map +2 -2
- package/lib/components/OverflowTags/index.d.ts +2 -0
- package/lib/components/OverflowTags/index.js.map +2 -2
- package/lib/hooks/index.d.ts +2 -0
- package/lib/hooks/index.js +5 -0
- package/lib/hooks/index.js.map +2 -2
- package/lib/hooks/useLocalStorage.d.ts +16 -0
- package/lib/hooks/useLocalStorage.js +120 -0
- package/lib/hooks/useLocalStorage.js.map +7 -0
- package/lib/hooks/useMovable.js +2 -2
- package/lib/hooks/useMovable.js.map +3 -3
- package/lib/locales/index.js +1 -1
- package/lib/locales/index.js.map +1 -1
- package/lib/utils/math.d.ts +11 -3
- package/lib/utils/math.js +43 -8
- package/lib/utils/math.js.map +3 -3
- package/package.json +14 -7
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
## 1.7.5
|
|
6
6
|
|
|
7
|
+
2026-2-28
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- **useLocalStorage**
|
|
12
|
+
- ✨ Add `useLocalStorage` hook for managing state with localStorage.
|
|
13
|
+
- **utils.math.random**
|
|
14
|
+
- ✨ Add an override method with zero parameters for generating random float numbers between 0 and 1.
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
- 🐞 Fix the issue where the `storageKey` is empty in `ColumnSetting` and `useMovable`.
|
|
19
|
+
- 🐞 Fix the issue where the reset button in `ColumnSetting` is always disabled.
|
|
20
|
+
|
|
21
|
+
## 1.7.5
|
|
22
|
+
|
|
7
23
|
2026-2-24
|
|
8
24
|
|
|
9
25
|
### Features
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import type { CSSProperties, FC } from 'react';
|
|
2
2
|
export interface PulseAnimationProps {
|
|
3
|
+
/**
|
|
4
|
+
* - **EN:** Custom class name for the root element
|
|
5
|
+
* - **CN:** 根元素的自定义类名
|
|
6
|
+
*/
|
|
3
7
|
className?: string;
|
|
8
|
+
/**
|
|
9
|
+
* - **EN:** Custom styles for the root element
|
|
10
|
+
* - **CN:** 根元素的自定义样式
|
|
11
|
+
*/
|
|
4
12
|
style?: CSSProperties;
|
|
13
|
+
/**
|
|
14
|
+
* - **EN:** Custom styles for the pulse bars
|
|
15
|
+
* - **CN:** 心跳条的自定义样式
|
|
16
|
+
*/
|
|
5
17
|
barStyle?: CSSProperties;
|
|
18
|
+
/**
|
|
19
|
+
* - **EN:** Custom prefix for the component's CSS class.
|
|
20
|
+
* - **CN:** 组件的自定义 CSS 类前缀。
|
|
21
|
+
*/
|
|
6
22
|
prefixCls?: string;
|
|
7
23
|
/**
|
|
8
24
|
* - **EN:** Number of bars, default is `24`
|
|
9
|
-
* - **CN:**
|
|
25
|
+
* - **CN:** 心跳条数量,默认`24`
|
|
10
26
|
*/
|
|
11
27
|
bars?: number;
|
|
12
28
|
/**
|
|
@@ -48,5 +64,5 @@ export interface PulseAnimationProps {
|
|
|
48
64
|
*
|
|
49
65
|
* > 使用 `token.AnimationPulse` 来全局配置 `barMinSize` 和 `barMaxSize` 属性
|
|
50
66
|
*/
|
|
51
|
-
|
|
67
|
+
declare const PulseAnimation: FC<PulseAnimationProps>;
|
|
52
68
|
export default PulseAnimation;
|
|
@@ -24,7 +24,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
24
24
|
*
|
|
25
25
|
* > 使用 `token.AnimationPulse` 来全局配置 `barMinSize` 和 `barMaxSize` 属性
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
var PulseAnimation = function PulseAnimation(props) {
|
|
28
28
|
var _props$bars = props.bars,
|
|
29
29
|
bars = _props$bars === void 0 ? 8 : _props$bars,
|
|
30
30
|
barGap = props.barGap,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useContext","useMemo","ConfigProvider","classNames","useStyle","jsx","_jsx","PulseAnimation","props","_props$bars","bars","barGap","barColor","duration","_props$delayRate","delayRate","prefixClsInProps","prefixCls","className","style","barStyle","_useContext","ConfigContext","getPrefixCls","_useStyle","_useStyle2","_slicedToArray","wrapCSSVar","hashId","cssVarCls","array","Array","from","length","_objectSpread","gridTemplateColumns","concat","gap","children","map","_","i","animationDuration","undefined","animationDelay","backgroundColor"],"sources":["../../../../src/components/Animation/Pulse/index.tsx"],"sourcesContent":["import type { CSSProperties, FC } from 'react';\nimport { useContext, useMemo } from 'react';\nimport { ConfigProvider } from 'antd';\nimport classNames from 'classnames';\nimport useStyle from './style';\n\nexport interface PulseAnimationProps {\n className?: string;\n style?: CSSProperties;\n barStyle?: CSSProperties;\n prefixCls?: string;\n /**\n * - **EN:** Number of bars, default is `24`\n * - **CN:**
|
|
1
|
+
{"version":3,"names":["useContext","useMemo","ConfigProvider","classNames","useStyle","jsx","_jsx","PulseAnimation","props","_props$bars","bars","barGap","barColor","duration","_props$delayRate","delayRate","prefixClsInProps","prefixCls","className","style","barStyle","_useContext","ConfigContext","getPrefixCls","_useStyle","_useStyle2","_slicedToArray","wrapCSSVar","hashId","cssVarCls","array","Array","from","length","_objectSpread","gridTemplateColumns","concat","gap","children","map","_","i","animationDuration","undefined","animationDelay","backgroundColor"],"sources":["../../../../src/components/Animation/Pulse/index.tsx"],"sourcesContent":["import type { CSSProperties, FC } from 'react';\nimport { useContext, useMemo } from 'react';\nimport { ConfigProvider } from 'antd';\nimport classNames from 'classnames';\nimport useStyle from './style';\n\nexport interface PulseAnimationProps {\n /**\n * - **EN:** Custom class name for the root element\n * - **CN:** 根元素的自定义类名\n */\n className?: string;\n /**\n * - **EN:** Custom styles for the root element\n * - **CN:** 根元素的自定义样式\n */\n style?: CSSProperties;\n /**\n * - **EN:** Custom styles for the pulse bars\n * - **CN:** 心跳条的自定义样式\n */\n barStyle?: CSSProperties;\n /**\n * - **EN:** Custom prefix for the component's CSS class.\n * - **CN:** 组件的自定义 CSS 类前缀。\n */\n prefixCls?: string;\n /**\n * - **EN:** Number of bars, default is `24`\n * - **CN:** 心跳条数量,默认`24`\n */\n\n bars?: number;\n /**\n * - **EN:** Gap between bars, default is `4px`\n * - **CN:** 心跳柱子间隙,默认`4px`\n */\n barGap?: CSSProperties['gap'];\n /**\n * - **EN:** Background color of the bars, default is theme's `colorFillSecondary`\n * - **CN:** 心跳柱子背景色,默认主题的 `colorFillSecondary`\n */\n barColor?: CSSProperties['backgroundColor'];\n /**\n * - **EN:** Minimum height of the bar, default is `10%`\n * - **CN:** 心跳柱子最小高度,默认`10%`\n */\n // barMinSize?: CSSProperties['height'];\n /**\n * - **EN:** Maximum height of the bar, default is `90%`\n * - **CN:** 心跳柱子最大高度,默认`90%`\n */\n // barMaxSize?: CSSProperties['height'];\n /**\n * - **EN:** Animation duration in seconds, default is `1.6` seconds\n * - **CN:** 动画持续时间,单位秒,默认`1.6`秒\n */\n duration?: number;\n /**\n * - **EN:** Animation delay rate, the delay between bars is calculated based on `{bars *\n * delayRate}`, default is `0.09`\n * - **CN:** 动画延迟的百分比,根据 `{bars * delayRate}` 计算柱子之间的延迟,默认 `0.09`\n */\n delayRate?: number;\n}\n\n/**\n * - **EN:** Pulse animation component, used to indicate loading or processing state\n *\n * > Use `token.AnimationPulse` to globally configure `barMinSize` and `barMaxSize` properties\n *\n * - **CN:** 脉动动画组件,用于表示加载或处理状态\n *\n * > 使用 `token.AnimationPulse` 来全局配置 `barMinSize` 和 `barMaxSize` 属性\n */\nconst PulseAnimation: FC<PulseAnimationProps> = (props) => {\n const {\n bars = 8,\n barGap,\n barColor,\n duration,\n delayRate = 0.09,\n prefixCls: prefixClsInProps,\n className,\n style,\n barStyle,\n } = props;\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('animation-pulse', prefixClsInProps);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const array = useMemo(() => Array.from({ length: bars }), [bars]);\n\n return wrapCSSVar(\n <div\n className={classNames(prefixCls, hashId, cssVarCls, className)}\n style={{\n gridTemplateColumns: `repeat(${array.length}, 1fr)`,\n gap: barGap,\n ...style,\n }}\n >\n {array.map((_, i) => (\n <div\n // eslint-disable-next-line react/no-array-index-key\n key={i}\n className={`${prefixCls}-bar`}\n style={{\n animationDuration: duration != null ? `${duration}s` : undefined,\n animationDelay: `${(i % array.length) * delayRate}s`,\n backgroundColor: barColor != null ? barColor : undefined,\n ...barStyle,\n }}\n />\n ))}\n </div>\n );\n};\n\nexport default PulseAnimation;\n"],"mappings":";;;;;;;;;;;;AACA,SAASA,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3C,SAASC,cAAc,QAAQ,MAAM;AACrC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,QAAQ;AAAgB,SAAAC,GAAA,IAAAC,IAAA;AA8D/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,cAAuC,GAAG,SAA1CA,cAAuCA,CAAIC,KAAK,EAAK;EACzD,IAAAC,WAAA,GAUID,KAAK,CATPE,IAAI;IAAJA,IAAI,GAAAD,WAAA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BACdnC,IAAA;QAGEY,SAAS,KAAAkB,MAAA,CAAKnB,SAAS,SAAO;QAC9BE,KAAK,EAAAe,aAAA;UACHQ,iBAAiB,EAAE7B,QAAQ,IAAI,IAAI,MAAAuB,MAAA,CAAMvB,QAAQ,SAAM8B,SAAS;UAChEC,cAAc,KAAAR,MAAA,CAAMK,CAAC,GAAGX,KAAK,CAACG,MAAM,GAAIlB,SAAS,MAAG;UACpD8B,eAAe,EAAEjC,QAAQ,IAAI,IAAI,GAAGA,QAAQ,GAAG+B;QAAS,GACrDvB,QAAQ;MACX,GAPGqB,CAQN,CAAC;IAAA,CACH;EAAC,CACC,CACP,CAAC;AACH,CAAC;AAED,eAAelC,cAAc"}
|
|
@@ -6,26 +6,26 @@ export interface BreakLinesProps {
|
|
|
6
6
|
*/
|
|
7
7
|
value: string | undefined;
|
|
8
8
|
/**
|
|
9
|
-
* - **EN:** Whether
|
|
10
|
-
* - **CN:**
|
|
9
|
+
* - **EN:** Whether the line break conversion is enabled
|
|
10
|
+
* - **CN:** 是否启用换行转换
|
|
11
11
|
*
|
|
12
12
|
* @default true
|
|
13
13
|
*/
|
|
14
14
|
enabled?: boolean;
|
|
15
15
|
/**
|
|
16
|
-
* - **EN:**
|
|
17
|
-
* - **CN:**
|
|
16
|
+
* - **EN:** The end-of-line character to use for splitting lines
|
|
17
|
+
* - **CN:** 用于分割行的行结束字符
|
|
18
18
|
*
|
|
19
19
|
* @default '\n'
|
|
20
20
|
*/
|
|
21
21
|
EOL?: string;
|
|
22
22
|
/**
|
|
23
|
-
* - **
|
|
24
|
-
* - **
|
|
23
|
+
* - **EN:** The HTML tag to use for rendering the content
|
|
24
|
+
* - **CN:** 用于渲染内容的 HTML 标签
|
|
25
25
|
*
|
|
26
26
|
* @default false
|
|
27
27
|
*/
|
|
28
|
-
tagName?: 'span' | 'div' | 'i' | 'pre' | (string & {})
|
|
28
|
+
tagName?: false | 'span' | 'div' | 'i' | 'pre' | (string & {});
|
|
29
29
|
/**
|
|
30
30
|
* - **EN:** The CSS class name of the dom node, if `tagName` is set to false, this property is
|
|
31
31
|
* invalid
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createElement","Fragment","jsx","_jsx","jsxs","_jsxs","_Fragment","BreakLines","props","value","className","_props$tagName","tagName","_props$enabled","enabled","_props$EOL","EOL","content","includes","segments","split","map","str","i","children","length","concat"],"sources":["../../../src/components/BreakLines/index.tsx"],"sourcesContent":["import { createElement, type FC, Fragment, type ReactNode } from 'react';\n\nexport interface BreakLinesProps {\n /**\n * - **EN:** Text content\n * - **CN:** 文本内容\n */\n value: string | undefined;\n /**\n * - **EN:** Whether
|
|
1
|
+
{"version":3,"names":["createElement","Fragment","jsx","_jsx","jsxs","_jsxs","_Fragment","BreakLines","props","value","className","_props$tagName","tagName","_props$enabled","enabled","_props$EOL","EOL","content","includes","segments","split","map","str","i","children","length","concat"],"sources":["../../../src/components/BreakLines/index.tsx"],"sourcesContent":["import { createElement, type FC, Fragment, type ReactNode } from 'react';\n\nexport interface BreakLinesProps {\n /**\n * - **EN:** Text content\n * - **CN:** 文本内容\n */\n value: string | undefined;\n /**\n * - **EN:** Whether the line break conversion is enabled\n * - **CN:** 是否启用换行转换\n *\n * @default true\n */\n enabled?: boolean;\n /**\n * - **EN:** The end-of-line character to use for splitting lines\n * - **CN:** 用于分割行的行结束字符\n *\n * @default '\\n'\n */\n EOL?: string;\n /**\n * - **EN:** The HTML tag to use for rendering the content\n * - **CN:** 用于渲染内容的 HTML 标签\n *\n * @default false\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n tagName?: false | 'span' | 'div' | 'i' | 'pre' | (string & {});\n /**\n * - **EN:** The CSS class name of the dom node, if `tagName` is set to false, this property is\n * invalid\n * - **CN:** dom节点的css类名,如果`tagName`设置为false,则此属性无效\n */\n className?: string;\n}\n\n/**\n * - **EN:** Output a piece of text, keeping line breaks\n * - **CN:** 输出一段文本,保留换行符\n *\n * @example\n * <BreakLines value=\"hello \\n world\" />;\n * // hello <br/> world\n */\nconst BreakLines: FC<BreakLinesProps> = (props) => {\n const { value, className, tagName = false, enabled = true, EOL = '\\n' } = props;\n\n let content: ReactNode;\n if (value) {\n if (enabled) {\n if (value.includes(EOL)) {\n const segments = value?.split(EOL);\n content = segments.map((str, i) => (\n // eslint-disable-next-line react/no-array-index-key\n <Fragment key={`${str}:${i}`}>\n {str}\n {i !== segments.length - 1 && <br />}\n </Fragment>\n ));\n } else {\n content = value;\n }\n } else {\n content = value;\n }\n } else {\n content = value;\n }\n\n if (tagName) {\n return createElement(tagName, { className }, content);\n } else {\n return <>{content}</>;\n }\n};\n\nexport default BreakLines;\n"],"mappings":"AAAA,SAASA,aAAa,EAAWC,QAAQ,QAAwB,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAAA,SAAAJ,QAAA,IAAAK,SAAA;AAsCzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,UAA+B,GAAG,SAAlCA,UAA+BA,CAAIC,KAAK,EAAK;EACjD,IAAQC,KAAK,GAA6DD,KAAK,CAAvEC,KAAK;IAAEC,SAAS,GAAkDF,KAAK,CAAhEE,SAAS;IAAAC,cAAA,GAAkDH,KAAK,CAArDI,OAAO;IAAPA,OAAO,GAAAD,cAAA,cAAG,KAAK,GAAAA,cAAA;IAAAE,cAAA,GAAiCL,KAAK,CAApCM,OAAO;IAAPA,OAAO,GAAAD,cAAA,cAAG,IAAI,GAAAA,cAAA;IAAAE,UAAA,GAAiBP,KAAK,CAApBQ,GAAG;IAAHA,GAAG,GAAAD,UAAA,cAAG,IAAI,GAAAA,UAAA;EAErE,IAAIE,OAAkB;EACtB,IAAIR,KAAK,EAAE;IACT,IAAIK,OAAO,EAAE;MACX,IAAIL,KAAK,CAACS,QAAQ,CAACF,GAAG,CAAC,EAAE;QACvB,IAAMG,QAAQ,GAAGV,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEW,KAAK,CAACJ,GAAG,CAAC;QAClCC,OAAO,GAAGE,QAAQ,CAACE,GAAG,CAAC,UAACC,GAAG,EAAEC,CAAC;UAAA;YAAA;YAC5B;YACAlB,KAAA,CAACJ,QAAQ;cAAAuB,QAAA,GACNF,GAAG,EACHC,CAAC,KAAKJ,QAAQ,CAACM,MAAM,GAAG,CAAC,iBAAItB,IAAA,SAAK,CAAC;YAAA,MAAAuB,MAAA,CAFpBJ,GAAG,OAAAI,MAAA,CAAIH,CAAC,CAGhB;UAAC;QAAA,CACZ,CAAC;MACJ,CAAC,MAAM;QACLN,OAAO,GAAGR,KAAK;MACjB;IACF,CAAC,MAAM;MACLQ,OAAO,GAAGR,KAAK;IACjB;EACF,CAAC,MAAM;IACLQ,OAAO,GAAGR,KAAK;EACjB;EAEA,IAAIG,OAAO,EAAE;IACX,oBAAOZ,aAAa,CAACY,OAAO,EAAE;MAAEF,SAAS,EAATA;IAAU,CAAC,EAAEO,OAAO,CAAC;EACvD,CAAC,MAAM;IACL,oBAAOd,IAAA,CAAAG,SAAA;MAAAkB,QAAA,EAAGP;IAAO,CAAG,CAAC;EACvB;AACF,CAAC;AAED,eAAeV,UAAU"}
|
|
@@ -13,8 +13,9 @@ export interface ColumnSettingProps<T extends ColumnSettingItem = ColumnSettingI
|
|
|
13
13
|
*/
|
|
14
14
|
onChange?: (nextColumns: T[]) => void;
|
|
15
15
|
/**
|
|
16
|
-
* - **EN:**
|
|
17
|
-
*
|
|
16
|
+
* - **EN:** Set a local storage key for persisting column settings. If not set, local storage is
|
|
17
|
+
* not enabled.
|
|
18
|
+
* - **CN:** 设置一个本地存储的键值,用于持久化保存列设置。如果未设置,则不启用本地存储。
|
|
18
19
|
*/
|
|
19
20
|
storageKey?: string;
|
|
20
21
|
/**
|
|
@@ -47,6 +48,10 @@ export interface ColumnSettingProps<T extends ColumnSettingItem = ColumnSettingI
|
|
|
47
48
|
* - **CN:** “重置”按钮的属性。
|
|
48
49
|
*/
|
|
49
50
|
resetProps?: ButtonProps;
|
|
51
|
+
/**
|
|
52
|
+
* - **EN:** Custom prefix for the component's CSS class.
|
|
53
|
+
* - **CN:** 组件的自定义 CSS 类前缀。
|
|
54
|
+
*/
|
|
50
55
|
prefixCls?: string;
|
|
51
56
|
}
|
|
52
57
|
/**
|
|
@@ -14,12 +14,12 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
14
14
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
15
15
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
-
import { useContext, useEffect, useMemo,
|
|
17
|
+
import { useContext, useEffect, useMemo, useState } from 'react';
|
|
18
18
|
import { Button, Checkbox, ConfigProvider, Divider, Dropdown, Space, Typography } from 'antd';
|
|
19
19
|
import classNames from 'classnames';
|
|
20
|
-
import { useLocalStorage } from 'react-use';
|
|
21
20
|
import { ReloadOutlined, SettingOutlined } from '@ant-design/icons';
|
|
22
21
|
import { useRefFunction, useRefValue } from "../../hooks";
|
|
22
|
+
import useLocalStorage from "../../hooks/useLocalStorage";
|
|
23
23
|
import useT from "../../hooks/useT";
|
|
24
24
|
import useStyle from "./style";
|
|
25
25
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -47,25 +47,28 @@ function ColumnSetting(props) {
|
|
|
47
47
|
wrapCSSVar = _useStyle2[0],
|
|
48
48
|
hashId = _useStyle2[1],
|
|
49
49
|
cssVarCls = _useStyle2[2];
|
|
50
|
-
var initialSelectedRef = useRef(normalizeToSelectedKeys(columns));
|
|
51
50
|
var _useState = useState(false),
|
|
52
51
|
_useState2 = _slicedToArray(_useState, 2),
|
|
53
52
|
open = _useState2[0],
|
|
54
53
|
setOpen = _useState2[1];
|
|
55
|
-
var _useState3 = useState(initialSelectedRef.current),
|
|
56
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
57
|
-
selectedKeys = _useState4[0],
|
|
58
|
-
setSelectedKeys = _useState4[1];
|
|
59
54
|
var t = useT();
|
|
60
|
-
var _useLocalStorage = useLocalStorage(storageKey
|
|
55
|
+
var _useLocalStorage = useLocalStorage(storageKey, []),
|
|
61
56
|
_useLocalStorage2 = _slicedToArray(_useLocalStorage, 2),
|
|
62
57
|
selectedKeysFromStorage = _useLocalStorage2[0],
|
|
63
58
|
setSelectedKeysFromStorage = _useLocalStorage2[1];
|
|
59
|
+
var _useState3 = useState(selectedKeysFromStorage !== null && selectedKeysFromStorage !== void 0 ? selectedKeysFromStorage : []),
|
|
60
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
61
|
+
initialKeys = _useState4[0],
|
|
62
|
+
setInitialKeys = _useState4[1];
|
|
63
|
+
var _useState5 = useState(initialKeys),
|
|
64
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
65
|
+
selectedKeys = _useState6[0],
|
|
66
|
+
setSelectedKeys = _useState6[1];
|
|
64
67
|
var storageRef = useRefValue(storageKey);
|
|
65
68
|
var selectedKeysFromStorageRef = useRefValue(selectedKeysFromStorage);
|
|
66
69
|
var hasChange = useMemo(function () {
|
|
67
|
-
return _toConsumableArray(selectedKeys).sort().join(',') !==
|
|
68
|
-
}, [selectedKeys]);
|
|
70
|
+
return _toConsumableArray(selectedKeys).sort().join(',') !== initialKeys.join(',');
|
|
71
|
+
}, [selectedKeys, initialKeys]);
|
|
69
72
|
|
|
70
73
|
// Compute keys and selectable keys
|
|
71
74
|
var keys = useMemo(function () {
|
|
@@ -133,23 +136,30 @@ function ColumnSetting(props) {
|
|
|
133
136
|
|
|
134
137
|
// Reset to initial selected columns
|
|
135
138
|
var handleReset = function handleReset() {
|
|
136
|
-
var next =
|
|
139
|
+
var next = initialKeys.length > 0 ? initialKeys : [keys[0]];
|
|
137
140
|
change(next, true);
|
|
138
141
|
};
|
|
142
|
+
var handleOpenChange = function handleOpenChange(nextOpen) {
|
|
143
|
+
setOpen(nextOpen);
|
|
144
|
+
if (nextOpen) {
|
|
145
|
+
setInitialKeys(normalizeToSelectedKeys(columns));
|
|
146
|
+
} else {
|
|
147
|
+
setInitialKeys([]);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
139
150
|
|
|
140
151
|
// Sync when columns change
|
|
141
152
|
useEffect(function () {
|
|
142
153
|
var next = normalizeToSelectedKeys(columns);
|
|
143
|
-
initialSelectedRef.current = next;
|
|
144
154
|
change(next, false);
|
|
145
155
|
}, [columns]);
|
|
146
156
|
|
|
147
157
|
// Fire change on mount if storage exists and differs from initial values
|
|
148
158
|
useEffect(function () {
|
|
149
|
-
if (storageRef.current && selectedKeysFromStorageRef.current && selectedKeysFromStorageRef.current.join(',') !==
|
|
159
|
+
if (storageRef.current && selectedKeysFromStorageRef.current && selectedKeysFromStorageRef.current.join(',') !== initialKeys.join(',')) {
|
|
150
160
|
change(selectedKeysFromStorageRef.current, true);
|
|
151
161
|
}
|
|
152
|
-
}, []);
|
|
162
|
+
}, [initialKeys]);
|
|
153
163
|
var dropdownRender = function dropdownRender() {
|
|
154
164
|
return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({}, popupProps), {}, {
|
|
155
165
|
className: classNames("".concat(prefixCls, "-popup"), popupProps === null || popupProps === void 0 ? void 0 : popupProps.className),
|
|
@@ -220,9 +230,10 @@ function ColumnSetting(props) {
|
|
|
220
230
|
};
|
|
221
231
|
return wrapCSSVar( /*#__PURE__*/_jsx(Dropdown, _objectSpread(_objectSpread({
|
|
222
232
|
open: open,
|
|
223
|
-
onOpenChange:
|
|
233
|
+
onOpenChange: handleOpenChange,
|
|
224
234
|
trigger: ['click'],
|
|
225
|
-
dropdownRender: dropdownRender
|
|
235
|
+
dropdownRender: dropdownRender // To be compatible with lower versions of antd
|
|
236
|
+
,
|
|
226
237
|
popupRender: dropdownRender,
|
|
227
238
|
placement: "bottomRight"
|
|
228
239
|
}, dropdownProps), {}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useContext","useEffect","useMemo","useRef","useState","Button","Checkbox","ConfigProvider","Divider","Dropdown","Space","Typography","classNames","useLocalStorage","ReloadOutlined","SettingOutlined","useRefFunction","useRefValue","useT","useStyle","jsx","_jsx","jsxs","_jsxs","ColumnSetting","props","columns","storageKey","triggerProps","dropdownProps","popupProps","prefixClsInProps","prefixCls","checkAllProps","resetProps","onChange","renderColumnTitle","_useContext","ConfigContext","getPrefixCls","_useStyle","_useStyle2","_slicedToArray","wrapCSSVar","hashId","cssVarCls","initialSelectedRef","normalizeToSelectedKeys","_useState","_useState2","open","setOpen","_useState3","current","_useState4","selectedKeys","setSelectedKeys","t","_useLocalStorage","_useLocalStorage2","selectedKeysFromStorage","setSelectedKeysFromStorage","storageRef","selectedKeysFromStorageRef","hasChange","_toConsumableArray","sort","join","keys","map","c","i","String","getColKey","allSelectableKeys","k","disabled","filter","x","isAllChecked","length","every","includes","isIndeterminate","change","nextSelected","fireEvent","next","col","visible","_objectSpread","hidden","toggleOne","key","checked","Set","add","delete","nextArr","Array","from","handleCheckAll","concat","slice","ensured","handleReset","dropdownRender","className","onClick","e","_popupProps$onClick","stopPropagation","call","children","Text","direction","size","idx","_ref","_col$title","_renderColumnTitle","label","title","dataIndex","disableUncheck","target","type","_checkAllProps$onClic","indeterminate","icon","_resetProps$onClick","onOpenChange","trigger","popupRender","placement","rootClassName","_ref2","_col$key","cols"],"sources":["../../../src/components/ColumnSetting/index.tsx"],"sourcesContent":["import { useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { Button, Checkbox, ConfigProvider, Divider, Dropdown, Space, Typography } from 'antd';\nimport type { ButtonProps, DropdownProps } from 'antd';\nimport type { ColumnType } from 'antd/es/table';\nimport classNames from 'classnames';\nimport { useLocalStorage } from 'react-use';\nimport { ReloadOutlined, SettingOutlined } from '@ant-design/icons';\nimport { useRefFunction, useRefValue } from '../../hooks';\nimport useT from '../../hooks/useT';\nimport useStyle from './style';\n\nexport interface ColumnSettingProps<T extends ColumnSettingItem = ColumnSettingItem> {\n /**\n * - **EN:** The columns to be displayed in the column setting.\n * - **CN:** 列设置中要显示的列。\n */\n columns: T[];\n /**\n * - **EN:** Callback function triggered when the selected columns change.\n * - **CN:** 选中列变化时触发的回调函数。\n */\n onChange?: (nextColumns: T[]) => void;\n /**\n * - **EN:** Local storage key for persisting column settings.\n * - **CN:** 用于持久化列设置的本地存储键。\n */\n storageKey?: string;\n /**\n * - **EN:** Function to render custom column titles.\n * - **CN:** 自定义列标题的渲染函数。\n */\n renderColumnTitle?: (col: ColumnSettingItem, index: number) => React.ReactNode;\n /**\n * - **EN:** Props for the button that triggers the dropdown.\n * - **CN:** 触发下拉菜单的按钮属性。\n */\n triggerProps?: ButtonProps;\n /**\n * - **EN:** Props for the dropdown component.\n * - **CN:** 下拉菜单组件的属性。\n */\n dropdownProps?: DropdownProps;\n /**\n * - **EN:** Props for the dropdown popup container.\n * - **CN:** 下拉菜单弹出层容器的属性。\n */\n popupProps?: React.HTMLAttributes<HTMLDivElement>;\n /**\n * - **EN:** Props for the \"Check All\" button.\n * - **CN:** “全选”按钮的属性。\n */\n checkAllProps?: ButtonProps;\n /**\n * - **EN:** Props for the \"Reset\" button.\n * - **CN:** “重置”按钮的属性。\n */\n resetProps?: ButtonProps;\n prefixCls?: string;\n}\n\n/**\n * - **EN:** A component for configuring table column visibility.\n * - **CN:** 用于配置表格列可见性的组件。\n */\nfunction ColumnSetting<T extends ColumnSettingItem = ColumnSettingItem>(props: ColumnSettingProps<T>) {\n const {\n columns,\n storageKey,\n triggerProps,\n dropdownProps,\n popupProps,\n prefixCls: prefixClsInProps,\n checkAllProps,\n resetProps,\n onChange,\n renderColumnTitle,\n } = props;\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('column-setting', prefixClsInProps);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const initialSelectedRef = useRef<string[]>(normalizeToSelectedKeys(columns));\n const [open, setOpen] = useState(false);\n const [selectedKeys, setSelectedKeys] = useState<string[]>(initialSelectedRef.current);\n const t = useT();\n const [selectedKeysFromStorage, setSelectedKeysFromStorage] = useLocalStorage<string[]>(\n storageKey ?? '',\n initialSelectedRef.current\n );\n const storageRef = useRefValue(storageKey);\n const selectedKeysFromStorageRef = useRefValue(selectedKeysFromStorage);\n const hasChange = useMemo(() => {\n return [...selectedKeys].sort().join(',') !== initialSelectedRef.current.join(',');\n }, [selectedKeys]);\n\n // Compute keys and selectable keys\n const keys = useMemo(() => columns.map((c, i) => String(getColKey(c, i))), [columns]);\n const allSelectableKeys = useMemo(\n () =>\n columns\n .map((c, i) => ({ k: String(getColKey(c, i)), disabled: !!c.disabled }))\n .filter((x) => !x.disabled)\n .map((x) => x.k),\n [columns]\n );\n const isAllChecked = allSelectableKeys.length > 0 && allSelectableKeys.every((k) => selectedKeys.includes(k));\n const isIndeterminate = selectedKeys.length > 0 && !isAllChecked;\n\n // Fire change event when selectedKeysFromStorage changes\n const change = useRefFunction((nextSelected: string[], fireEvent?: boolean) => {\n setSelectedKeys(nextSelected);\n if (storageKey) {\n setSelectedKeysFromStorage(nextSelected);\n }\n if (fireEvent) {\n const next = columns.map((col, i) => {\n const k = String(getColKey(col, i));\n const visible = nextSelected.includes(k);\n return { ...col, hidden: !visible } as T;\n });\n onChange?.(next as T[]);\n }\n });\n\n // Toggle one column change\n const toggleOne = (key: string, checked: boolean) => {\n const next = new Set(selectedKeys);\n if (checked) {\n next.add(key);\n } else {\n // Keep at least one visible column\n if (selectedKeys.length <= 1) return;\n next.delete(key);\n }\n const nextArr = Array.from(next);\n change(nextArr, true);\n };\n\n // Toggle all columns change\n const handleCheckAll = (checked: boolean) => {\n const nextArr = checked\n ? Array.from(new Set([...selectedKeys, ...allSelectableKeys]))\n : selectedKeys.filter((k) => !allSelectableKeys.includes(k)).slice(0, 1);\n const ensured = checked ? nextArr : nextArr.length > 0 ? nextArr : [keys[0]];\n change(ensured, true);\n };\n\n // Reset to initial selected columns\n const handleReset = () => {\n const next = initialSelectedRef.current.length > 0 ? initialSelectedRef.current : [keys[0]];\n change(next, true);\n };\n\n // Sync when columns change\n useEffect(() => {\n const next = normalizeToSelectedKeys(columns);\n initialSelectedRef.current = next;\n change(next, false);\n }, [columns]);\n\n // Fire change on mount if storage exists and differs from initial values\n useEffect(() => {\n if (\n storageRef.current &&\n selectedKeysFromStorageRef.current &&\n selectedKeysFromStorageRef.current.join(',') !== initialSelectedRef.current.join(',')\n ) {\n change(selectedKeysFromStorageRef.current, true);\n }\n }, []);\n\n const dropdownRender = () => (\n <div\n {...popupProps}\n className={classNames(`${prefixCls}-popup`, popupProps?.className)}\n onClick={(e) => {\n e.stopPropagation();\n popupProps?.onClick?.(e);\n }}\n >\n <Typography.Text className={`${prefixCls}-popup-title`}>{t('components.ColumnSetting.title')}</Typography.Text>\n <Space direction=\"vertical\" className={`${prefixCls}-column-list`} size={12}>\n {columns.map((col, idx) => {\n const k = String(getColKey(col, idx));\n const label = col.title ?? col.dataIndex ?? k;\n const checked = selectedKeys.includes(k);\n const disabled = !!col.disabled;\n const disableUncheck = !disabled && checked && selectedKeys.length <= 1; // 禁止取消最后一个\n return (\n <Checkbox\n key={k}\n className={`${prefixCls}-column-item`}\n disabled={disabled || disableUncheck}\n checked={checked}\n onChange={(e) => toggleOne(k, e.target.checked)}\n >\n <span className={`${prefixCls}-column-item-title`}>{renderColumnTitle?.(col, idx) ?? label}</span>\n </Checkbox>\n );\n })}\n </Space>\n <Divider className={`${prefixCls}-divider`} />\n <div className={`${prefixCls}-footer`}>\n <Button\n type=\"text\"\n {...checkAllProps}\n className={classNames(`${prefixCls}-select-all`, checkAllProps?.className)}\n onClick={(e) => {\n handleCheckAll(!isAllChecked);\n checkAllProps?.onClick?.(e);\n }}\n >\n <Checkbox checked={isAllChecked} indeterminate={isIndeterminate}></Checkbox>\n {t('components.ColumnSetting.selectAll')}\n </Button>\n <Button\n type=\"text\"\n icon={<ReloadOutlined />}\n disabled={!hasChange}\n {...resetProps}\n className={classNames(`${prefixCls}-reset`, resetProps?.className)}\n onClick={(e) => {\n handleReset();\n resetProps?.onClick?.(e);\n }}\n >\n {t('components.ColumnSetting.reset')}\n </Button>\n </div>\n </div>\n );\n\n return wrapCSSVar(\n <Dropdown\n open={open}\n onOpenChange={setOpen}\n trigger={['click']}\n dropdownRender={dropdownRender}\n popupRender={dropdownRender}\n placement=\"bottomRight\"\n {...dropdownProps}\n rootClassName={classNames(hashId, cssVarCls, prefixCls, `${prefixCls}-dropdown`, dropdownProps?.className)}\n >\n <Button\n icon={<SettingOutlined />}\n {...triggerProps}\n className={classNames(hashId, cssVarCls, prefixCls, `${prefixCls}-trigger`, triggerProps?.className)}\n />\n </Dropdown>\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ColumnSettingItem<T = any> extends ColumnType<T> {\n /**\n * - **EN:** Disable toggling visibility for this column.\n * - **CN:** 禁止切换此列的可见性。\n */\n disabled?: boolean;\n}\n\nfunction getColKey(col: ColumnType, idx: number): React.Key {\n return col.key ?? (col.dataIndex as string) ?? idx;\n}\n\nfunction normalizeToSelectedKeys(cols: ColumnType[]): string[] {\n return cols\n .map((c, i) => ({ key: String(getColKey(c, i)), hidden: !!c.hidden }))\n .filter((c) => !c.hidden)\n .map((c) => c.key)\n .sort();\n}\n\nexport default ColumnSetting;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAASA,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ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,CAACe,GAAe,EAAE6B,GAAW,EAAa;EAAA,IAAAmB,KAAA,EAAAC,QAAA;EAC1D,QAAAD,KAAA,IAAAC,QAAA,GAAOjD,GAAG,CAACK,GAAG,cAAA4C,QAAA,cAAAA,QAAA,GAAKjD,GAAG,CAACmC,SAAS,cAAAa,KAAA,cAAAA,KAAA,GAAenB,GAAG;AACpD;AAEA,SAAStE,uBAAuBA,CAAC2F,IAAkB,EAAY;EAC7D,OAAOA,IAAI,CACRrE,GAAG,CAAC,UAACC,CAAC,EAAEC,CAAC;IAAA,OAAM;MAAEsB,GAAG,EAAErB,MAAM,CAACC,SAAS,CAACH,CAAC,EAAEC,CAAC,CAAC,CAAC;MAAEoB,MAAM,EAAE,CAAC,CAACrB,CAAC,CAACqB;IAAO,CAAC;EAAA,CAAC,CAAC,CACrEd,MAAM,CAAC,UAACP,CAAC;IAAA,OAAK,CAACA,CAAC,CAACqB,MAAM;EAAA,EAAC,CACxBtB,GAAG,CAAC,UAACC,CAAC;IAAA,OAAKA,CAAC,CAACuB,GAAG;EAAA,EAAC,CACjB3B,IAAI,CAAC,CAAC;AACX;AAEA,eAAe1C,aAAa"}
|
|
1
|
+
{"version":3,"names":["useContext","useEffect","useMemo","useState","Button","Checkbox","ConfigProvider","Divider","Dropdown","Space","Typography","classNames","ReloadOutlined","SettingOutlined","useRefFunction","useRefValue","useLocalStorage","useT","useStyle","jsx","_jsx","jsxs","_jsxs","ColumnSetting","props","columns","storageKey","triggerProps","dropdownProps","popupProps","prefixClsInProps","prefixCls","checkAllProps","resetProps","onChange","renderColumnTitle","_useContext","ConfigContext","getPrefixCls","_useStyle","_useStyle2","_slicedToArray","wrapCSSVar","hashId","cssVarCls","_useState","_useState2","open","setOpen","t","_useLocalStorage","_useLocalStorage2","selectedKeysFromStorage","setSelectedKeysFromStorage","_useState3","_useState4","initialKeys","setInitialKeys","_useState5","_useState6","selectedKeys","setSelectedKeys","storageRef","selectedKeysFromStorageRef","hasChange","_toConsumableArray","sort","join","keys","map","c","i","String","getColKey","allSelectableKeys","k","disabled","filter","x","isAllChecked","length","every","includes","isIndeterminate","change","nextSelected","fireEvent","next","col","visible","_objectSpread","hidden","toggleOne","key","checked","Set","add","delete","nextArr","Array","from","handleCheckAll","concat","slice","ensured","handleReset","handleOpenChange","nextOpen","normalizeToSelectedKeys","current","dropdownRender","className","onClick","e","_popupProps$onClick","stopPropagation","call","children","Text","direction","size","idx","_ref","_col$title","_renderColumnTitle","label","title","dataIndex","disableUncheck","target","type","_checkAllProps$onClic","indeterminate","icon","_resetProps$onClick","onOpenChange","trigger","popupRender","placement","rootClassName","_ref2","_col$key","cols"],"sources":["../../../src/components/ColumnSetting/index.tsx"],"sourcesContent":["import { useContext, useEffect, useMemo, useState } from 'react';\nimport { Button, Checkbox, ConfigProvider, Divider, Dropdown, Space, Typography } from 'antd';\nimport type { ButtonProps, DropdownProps } from 'antd';\nimport type { ColumnType } from 'antd/es/table';\nimport classNames from 'classnames';\nimport { ReloadOutlined, SettingOutlined } from '@ant-design/icons';\nimport { useRefFunction, useRefValue } from '../../hooks';\nimport useLocalStorage from '../../hooks/useLocalStorage';\nimport useT from '../../hooks/useT';\nimport useStyle from './style';\n\nexport interface ColumnSettingProps<T extends ColumnSettingItem = ColumnSettingItem> {\n /**\n * - **EN:** The columns to be displayed in the column setting.\n * - **CN:** 列设置中要显示的列。\n */\n columns: T[];\n /**\n * - **EN:** Callback function triggered when the selected columns change.\n * - **CN:** 选中列变化时触发的回调函数。\n */\n onChange?: (nextColumns: T[]) => void;\n /**\n * - **EN:** Set a local storage key for persisting column settings. If not set, local storage is\n * not enabled.\n * - **CN:** 设置一个本地存储的键值,用于持久化保存列设置。如果未设置,则不启用本地存储。\n */\n storageKey?: string;\n /**\n * - **EN:** Function to render custom column titles.\n * - **CN:** 自定义列标题的渲染函数。\n */\n renderColumnTitle?: (col: ColumnSettingItem, index: number) => React.ReactNode;\n /**\n * - **EN:** Props for the button that triggers the dropdown.\n * - **CN:** 触发下拉菜单的按钮属性。\n */\n triggerProps?: ButtonProps;\n /**\n * - **EN:** Props for the dropdown component.\n * - **CN:** 下拉菜单组件的属性。\n */\n dropdownProps?: DropdownProps;\n /**\n * - **EN:** Props for the dropdown popup container.\n * - **CN:** 下拉菜单弹出层容器的属性。\n */\n popupProps?: React.HTMLAttributes<HTMLDivElement>;\n /**\n * - **EN:** Props for the \"Check All\" button.\n * - **CN:** “全选”按钮的属性。\n */\n checkAllProps?: ButtonProps;\n /**\n * - **EN:** Props for the \"Reset\" button.\n * - **CN:** “重置”按钮的属性。\n */\n resetProps?: ButtonProps;\n /**\n * - **EN:** Custom prefix for the component's CSS class.\n * - **CN:** 组件的自定义 CSS 类前缀。\n */\n prefixCls?: string;\n}\n\n/**\n * - **EN:** A component for configuring table column visibility.\n * - **CN:** 用于配置表格列可见性的组件。\n */\nfunction ColumnSetting<T extends ColumnSettingItem = ColumnSettingItem>(props: ColumnSettingProps<T>) {\n const {\n columns,\n storageKey,\n triggerProps,\n dropdownProps,\n popupProps,\n prefixCls: prefixClsInProps,\n checkAllProps,\n resetProps,\n onChange,\n renderColumnTitle,\n } = props;\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('column-setting', prefixClsInProps);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const [open, setOpen] = useState(false);\n const t = useT();\n const [selectedKeysFromStorage, setSelectedKeysFromStorage] = useLocalStorage<string[]>(storageKey, []);\n const [initialKeys, setInitialKeys] = useState<string[]>(selectedKeysFromStorage ?? []);\n const [selectedKeys, setSelectedKeys] = useState<string[]>(initialKeys);\n const storageRef = useRefValue(storageKey);\n const selectedKeysFromStorageRef = useRefValue(selectedKeysFromStorage);\n const hasChange = useMemo(() => {\n return [...selectedKeys].sort().join(',') !== initialKeys.join(',');\n }, [selectedKeys, initialKeys]);\n\n // Compute keys and selectable keys\n const keys = useMemo(() => columns.map((c, i) => String(getColKey(c, i))), [columns]);\n const allSelectableKeys = useMemo(\n () =>\n columns\n .map((c, i) => ({ k: String(getColKey(c, i)), disabled: !!c.disabled }))\n .filter((x) => !x.disabled)\n .map((x) => x.k),\n [columns]\n );\n const isAllChecked = allSelectableKeys.length > 0 && allSelectableKeys.every((k) => selectedKeys.includes(k));\n const isIndeterminate = selectedKeys.length > 0 && !isAllChecked;\n\n // Fire change event when selectedKeysFromStorage changes\n const change = useRefFunction((nextSelected: string[], fireEvent?: boolean) => {\n setSelectedKeys(nextSelected);\n if (storageKey) {\n setSelectedKeysFromStorage(nextSelected);\n }\n if (fireEvent) {\n const next = columns.map((col, i) => {\n const k = String(getColKey(col, i));\n const visible = nextSelected.includes(k);\n return { ...col, hidden: !visible } as T;\n });\n onChange?.(next as T[]);\n }\n });\n\n // Toggle one column change\n const toggleOne = (key: string, checked: boolean) => {\n const next = new Set(selectedKeys);\n if (checked) {\n next.add(key);\n } else {\n // Keep at least one visible column\n if (selectedKeys.length <= 1) return;\n next.delete(key);\n }\n const nextArr = Array.from(next);\n change(nextArr, true);\n };\n\n // Toggle all columns change\n const handleCheckAll = (checked: boolean) => {\n const nextArr = checked\n ? Array.from(new Set([...selectedKeys, ...allSelectableKeys]))\n : selectedKeys.filter((k) => !allSelectableKeys.includes(k)).slice(0, 1);\n const ensured = checked ? nextArr : nextArr.length > 0 ? nextArr : [keys[0]];\n change(ensured, true);\n };\n\n // Reset to initial selected columns\n const handleReset = () => {\n const next = initialKeys.length > 0 ? initialKeys : [keys[0]];\n change(next, true);\n };\n\n const handleOpenChange = (nextOpen: boolean) => {\n setOpen(nextOpen);\n if (nextOpen) {\n setInitialKeys(normalizeToSelectedKeys(columns));\n } else {\n setInitialKeys([]);\n }\n };\n\n // Sync when columns change\n useEffect(() => {\n const next = normalizeToSelectedKeys(columns);\n change(next, false);\n }, [columns]);\n\n // Fire change on mount if storage exists and differs from initial values\n useEffect(() => {\n if (\n storageRef.current &&\n selectedKeysFromStorageRef.current &&\n selectedKeysFromStorageRef.current.join(',') !== initialKeys.join(',')\n ) {\n change(selectedKeysFromStorageRef.current, true);\n }\n }, [initialKeys]);\n\n const dropdownRender = () => (\n <div\n {...popupProps}\n className={classNames(`${prefixCls}-popup`, popupProps?.className)}\n onClick={(e) => {\n e.stopPropagation();\n popupProps?.onClick?.(e);\n }}\n >\n <Typography.Text className={`${prefixCls}-popup-title`}>{t('components.ColumnSetting.title')}</Typography.Text>\n <Space direction=\"vertical\" className={`${prefixCls}-column-list`} size={12}>\n {columns.map((col, idx) => {\n const k = String(getColKey(col, idx));\n const label = col.title ?? col.dataIndex ?? k;\n const checked = selectedKeys.includes(k);\n const disabled = !!col.disabled;\n const disableUncheck = !disabled && checked && selectedKeys.length <= 1; // 禁止取消最后一个\n return (\n <Checkbox\n key={k}\n className={`${prefixCls}-column-item`}\n disabled={disabled || disableUncheck}\n checked={checked}\n onChange={(e) => toggleOne(k, e.target.checked)}\n >\n <span className={`${prefixCls}-column-item-title`}>{renderColumnTitle?.(col, idx) ?? label}</span>\n </Checkbox>\n );\n })}\n </Space>\n <Divider className={`${prefixCls}-divider`} />\n <div className={`${prefixCls}-footer`}>\n <Button\n type=\"text\"\n {...checkAllProps}\n className={classNames(`${prefixCls}-select-all`, checkAllProps?.className)}\n onClick={(e) => {\n handleCheckAll(!isAllChecked);\n checkAllProps?.onClick?.(e);\n }}\n >\n <Checkbox checked={isAllChecked} indeterminate={isIndeterminate}></Checkbox>\n {t('components.ColumnSetting.selectAll')}\n </Button>\n <Button\n type=\"text\"\n icon={<ReloadOutlined />}\n disabled={!hasChange}\n {...resetProps}\n className={classNames(`${prefixCls}-reset`, resetProps?.className)}\n onClick={(e) => {\n handleReset();\n resetProps?.onClick?.(e);\n }}\n >\n {t('components.ColumnSetting.reset')}\n </Button>\n </div>\n </div>\n );\n\n return wrapCSSVar(\n <Dropdown\n open={open}\n onOpenChange={handleOpenChange}\n trigger={['click']}\n dropdownRender={dropdownRender} // To be compatible with lower versions of antd\n popupRender={dropdownRender}\n placement=\"bottomRight\"\n {...dropdownProps}\n rootClassName={classNames(hashId, cssVarCls, prefixCls, `${prefixCls}-dropdown`, dropdownProps?.className)}\n >\n <Button\n icon={<SettingOutlined />}\n {...triggerProps}\n className={classNames(hashId, cssVarCls, prefixCls, `${prefixCls}-trigger`, triggerProps?.className)}\n />\n </Dropdown>\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ColumnSettingItem<T = any> extends ColumnType<T> {\n /**\n * - **EN:** Disable toggling visibility for this column.\n * - **CN:** 禁止切换此列的可见性。\n */\n disabled?: boolean;\n}\n\nfunction getColKey(col: ColumnType, idx: number): React.Key {\n return col.key ?? (col.dataIndex as string) ?? idx;\n}\n\nfunction normalizeToSelectedKeys(cols: ColumnType[]): string[] {\n return cols\n .map((c, i) => ({ key: String(getColKey(c, i)), hidden: !!c.hidden }))\n .filter((c) => !c.hidden)\n .map((c) => c.key)\n .sort();\n}\n\nexport default ColumnSetting;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAASA,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAChE,SAASC,MAAM,EAAEC,QAAQ,EAAEC,cAAc,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,UAAU,QAAQ,MAAM;AAG7F,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,cAAc,EAAEC,eAAe,QAAQ,mBAAmB;AACnE,SAASC,cAAc,EAAEC,WAAW;AACpC,OAAOC,eAAe;AACtB,OAAOC,IAAI;AACX,OAAOC,QAAQ;AAAgB,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAwD/B;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAAkDC,KAA4B,EAAE;EACpG,IACEC,OAAO,GAULD,KAAK,CAVPC,OAAO;IACPC,UAAU,GASRF,KAAK,CATPE,UAAU;IACVC,YAAY,GAQVH,KAAK,CARPG,YAAY;IACZC,aAAa,GAOXJ,KAAK,CAPPI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AAA,OAAM;MAAEsB,GAAG,EAAErB,MAAM,CAACC,SAAS,CAACH,CAAC,EAAEC,CAAC,CAAC,CAAC;MAAEoB,MAAM,EAAE,CAAC,CAACrB,CAAC,CAACqB;IAAO,CAAC;EAAA,CAAC,CAAC,CACrEd,MAAM,CAAC,UAACP,CAAC;IAAA,OAAK,CAACA,CAAC,CAACqB,MAAM;EAAA,EAAC,CACxBtB,GAAG,CAAC,UAACC,CAAC;IAAA,OAAKA,CAAC,CAACuB,GAAG;EAAA,EAAC,CACjB3B,IAAI,CAAC,CAAC;AACX;AAEA,eAAe3C,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","defaultContextValue","lang","ReactEasyContext"],"sources":["../../../src/components/ConfigProvider/context.tsx"],"sourcesContent":["import { createContext, type ReactNode } from 'react';\nimport type { Langs } from '../../locales';\nimport type { ConfirmActionProps } from '../ConfirmAction';\nimport type { ModalActionProps } from '../ModalAction';\n\nexport interface ReactEasyContextProps {\n /**\n * - **EN:** Language of the component, used for global configuration, can be 'en-US' or 'zh-CN'\n * - **CN:** 组件的语言,用于全局配置,可以是'en-US'或'zh-CN'\n */\n lang?: Langs;\n /**\n * - **EN:** Get localized text\n * - **CN:** 获取本地化文本\n *\n * @param key Normal text or key of local resource | 普通文本或本地资源的键值\n * @param args Parameters of the localized text | 本地化文本的参数\n *\n * @returns Localized text | 本地化文本\n */\n localize?: <T>(key: T, args?: Record<string, unknown>) => ReactNode;\n\n /**\n * - **EN:** Global configuration for `ConfirmAction` component, which can be used to set default\n * modal title and content for all `ConfirmAction` components in the application.\n * - **CN:** `ConfirmAction`组件的全局配置,可以用来设置应用中所有`ConfirmAction`组件的默认模态框标题和内容。\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ConfirmAction?: ConfirmActionProps<any, never>;\n /** @deprecated Use `ConfirmAction.title` instead */\n defaultConfirmTitle?: ReactNode;\n /** @deprecated Use `ConfirmAction.content` instead */\n defaultConfirmContent?: ReactNode;\n\n /**\n * - **EN:** Global configuration for `DeleteConfirmAction` component, which can be used to set\n * default modal title and content for all `DeleteConfirmAction` components in the application.\n * - **CN:** `DeleteConfirmAction`组件的全局配置,可以用来设置应用中所有`DeleteConfirmAction`组件的默认模态框标题和内容。\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n DeletionConfirmAction?: ConfirmActionProps<any, never>;\n /** @deprecated Use `DeletionConfirmAction.title` instead */\n defaultDeletionConfirmTitle?: ReactNode;\n /** @deprecated Use `DeletionConfirmAction.content` instead */\n defaultDeletionConfirmContent?: ReactNode;\n\n /**\n * - **EN:** Global configuration for `ModalAction` component, which can be used to set default\n * modal title and content for all `ModalAction` components in the application.\n * - **CN:** `ModalAction`组件的全局配置,可以用来设置应用中所有`ModalAction`组件的默认模态框标题和内容。\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ModalAction?: Partial<ModalActionProps<any, any, any, any, any>>;\n}\n\nexport const defaultContextValue: ReactEasyContextProps = {\n lang: 'en',\n};\n\nconst ReactEasyContext = createContext<ReactEasyContextProps>(defaultContextValue);\n\nexport default ReactEasyContext;\n"],"mappings":"AAAA,SAASA,aAAa,QAAwB,OAAO;
|
|
1
|
+
{"version":3,"names":["createContext","defaultContextValue","lang","ReactEasyContext"],"sources":["../../../src/components/ConfigProvider/context.tsx"],"sourcesContent":["import { createContext, type ReactNode } from 'react';\nimport type { Langs } from '../../locales';\nimport type { ConfirmActionProps } from '../ConfirmAction';\nimport type { ModalActionProps } from '../ModalAction';\n\nexport interface ReactEasyContextProps {\n /**\n * - **EN:** Language of the component, used for global configuration, can be 'en-US' or 'zh-CN'\n * - **CN:** 组件的语言,用于全局配置,可以是'en-US'或'zh-CN'\n *\n * @default 'en-US'\n */\n lang?: Langs;\n /**\n * - **EN:** Get localized text\n * - **CN:** 获取本地化文本\n *\n * @param key Normal text or key of local resource | 普通文本或本地资源的键值\n * @param args Parameters of the localized text | 本地化文本的参数\n *\n * @returns Localized text | 本地化文本\n */\n localize?: <T>(key: T, args?: Record<string, unknown>) => ReactNode;\n\n /**\n * - **EN:** Global configuration for `ConfirmAction` component, which can be used to set default\n * modal title and content for all `ConfirmAction` components in the application.\n * - **CN:** `ConfirmAction`组件的全局配置,可以用来设置应用中所有`ConfirmAction`组件的默认模态框标题和内容。\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ConfirmAction?: ConfirmActionProps<any, never>;\n /** @deprecated Use `ConfirmAction.title` instead */\n defaultConfirmTitle?: ReactNode;\n /** @deprecated Use `ConfirmAction.content` instead */\n defaultConfirmContent?: ReactNode;\n\n /**\n * - **EN:** Global configuration for `DeleteConfirmAction` component, which can be used to set\n * default modal title and content for all `DeleteConfirmAction` components in the application.\n * - **CN:** `DeleteConfirmAction`组件的全局配置,可以用来设置应用中所有`DeleteConfirmAction`组件的默认模态框标题和内容。\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n DeletionConfirmAction?: ConfirmActionProps<any, never>;\n /** @deprecated Use `DeletionConfirmAction.title` instead */\n defaultDeletionConfirmTitle?: ReactNode;\n /** @deprecated Use `DeletionConfirmAction.content` instead */\n defaultDeletionConfirmContent?: ReactNode;\n\n /**\n * - **EN:** Global configuration for `ModalAction` component, which can be used to set default\n * modal title and content for all `ModalAction` components in the application.\n * - **CN:** `ModalAction`组件的全局配置,可以用来设置应用中所有`ModalAction`组件的默认模态框标题和内容。\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ModalAction?: Partial<ModalActionProps<any, any, any, any, any>>;\n}\n\nexport const defaultContextValue: ReactEasyContextProps = {\n lang: 'en-US',\n};\n\nconst ReactEasyContext = createContext<ReactEasyContextProps>(defaultContextValue);\n\nexport default ReactEasyContext;\n"],"mappings":"AAAA,SAASA,aAAa,QAAwB,OAAO;AAyDrD,OAAO,IAAMC,mBAA0C,GAAG;EACxDC,IAAI,EAAE;AACR,CAAC;AAED,IAAMC,gBAAgB,gBAAGH,aAAa,CAAwBC,mBAAmB,CAAC;AAElF,eAAeE,gBAAgB"}
|
|
@@ -2,8 +2,25 @@ import type { CSSProperties, FC, ReactNode } from 'react';
|
|
|
2
2
|
import type localesEn from '../../locales/langs/en';
|
|
3
3
|
import { type ReactEasyContextProps } from './context';
|
|
4
4
|
export interface ConfigProviderProps extends ReactEasyContextProps {
|
|
5
|
+
/**
|
|
6
|
+
* - **EN:** Child elements of the ConfigProvider
|
|
7
|
+
* - **CN:** ConfigProvider 的子元素
|
|
8
|
+
*/
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* - **EN:** Custom prefix for the component's CSS class.
|
|
12
|
+
* - **CN:** 组件的自定义 CSS 类前缀。
|
|
13
|
+
*/
|
|
5
14
|
prefixCls?: string;
|
|
15
|
+
/**
|
|
16
|
+
* - **EN:** Custom class name for the root element
|
|
17
|
+
* - **CN:** 根元素的自定义类名
|
|
18
|
+
*/
|
|
6
19
|
className?: string;
|
|
20
|
+
/**
|
|
21
|
+
* - **EN:** Custom styles for the root element
|
|
22
|
+
* - **CN:** 根元素的自定义样式
|
|
23
|
+
*/
|
|
7
24
|
style?: CSSProperties;
|
|
8
25
|
/**
|
|
9
26
|
* - **EN:** Custom localization resources, if `lang` exists, it will override the localization
|
|
@@ -11,7 +28,6 @@ export interface ConfigProviderProps extends ReactEasyContextProps {
|
|
|
11
28
|
* - **CN:** 自定义本地化资源,如果`lang`存在,则会覆盖该语言的本地化资源,否则,会添加一种新的语言
|
|
12
29
|
*/
|
|
13
30
|
locales?: Partial<typeof localesEn>;
|
|
14
|
-
children: ReactNode;
|
|
15
31
|
}
|
|
16
32
|
/**
|
|
17
33
|
* - **EN:** Provide global configuration for AntdHelper
|
|
@@ -5,6 +5,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
7
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
12
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
13
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
14
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -13,7 +17,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
13
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
18
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
15
19
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
|
-
import { useContext, useEffect } from 'react';
|
|
20
|
+
import { useContext, useEffect, useMemo } from 'react';
|
|
17
21
|
import { ConfigProvider as ReactConfigProvider } from 'antd';
|
|
18
22
|
import classNames from 'classnames';
|
|
19
23
|
import locales, { langs, resources } from "../../locales";
|
|
@@ -41,24 +45,27 @@ var ConfigProvider = function ConfigProvider(props) {
|
|
|
41
45
|
wrapCSSVar = _useStyle2[0],
|
|
42
46
|
hashId = _useStyle2[1],
|
|
43
47
|
cssVarCls = _useStyle2[2];
|
|
48
|
+
var contextValue = useMemo(function () {
|
|
49
|
+
if (langInProps !== locales.language) {
|
|
50
|
+
locales.changeLanguage(langInProps || 'en-US');
|
|
51
|
+
}
|
|
52
|
+
return restProps;
|
|
53
|
+
}, // eslint-disable-next-line @tiny-codes/react-hooks/exhaustive-deps
|
|
54
|
+
[langInProps].concat(_toConsumableArray(Object.values(restProps))));
|
|
44
55
|
useEffect(function () {
|
|
45
56
|
// Dynamically add language pack
|
|
46
57
|
if (userLocales) {
|
|
47
|
-
var lang = langInProps || 'en';
|
|
58
|
+
var lang = langInProps || 'en-US';
|
|
48
59
|
if (lang && langs.includes(lang)) {
|
|
49
60
|
locales.removeResourceBundle(lang, 'translation');
|
|
50
61
|
locales.addResourceBundle(lang, 'translation', _objectSpread(_objectSpread({}, resources[lang].translation), userLocales));
|
|
51
62
|
} else {
|
|
52
|
-
locales.addResourceBundle(lang, 'translation', _objectSpread(_objectSpread({}, resources
|
|
63
|
+
locales.addResourceBundle(lang, 'translation', _objectSpread(_objectSpread({}, resources['en-US'].translation), userLocales));
|
|
53
64
|
}
|
|
54
65
|
}
|
|
55
66
|
}, [langInProps, userLocales]);
|
|
56
|
-
useEffect(function () {
|
|
57
|
-
// Set the language of the component
|
|
58
|
-
locales.changeLanguage(langInProps || 'en');
|
|
59
|
-
}, [langInProps]);
|
|
60
67
|
return wrapCSSVar( /*#__PURE__*/_jsx(ReactEasyContext.Provider, {
|
|
61
|
-
value:
|
|
68
|
+
value: contextValue,
|
|
62
69
|
children: /*#__PURE__*/_jsx("div", {
|
|
63
70
|
className: classNames(hashId, cssVarCls, prefixCls, className),
|
|
64
71
|
style: style,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useContext","useEffect","ConfigProvider","ReactConfigProvider","classNames","locales","langs","resources","ReactEasyContext","useStyle","jsx","_jsx","props","children","userLocales","prefixClsInProps","prefixCls","className","style","restProps","_objectWithoutProperties","_excluded","langInProps","lang","_useContext","ConfigContext","getPrefixCls","rootPrefixCls","_useStyle","_useStyle2","_slicedToArray","wrapCSSVar","hashId","cssVarCls","
|
|
1
|
+
{"version":3,"names":["useContext","useEffect","useMemo","ConfigProvider","ReactConfigProvider","classNames","locales","langs","resources","ReactEasyContext","useStyle","jsx","_jsx","props","children","userLocales","prefixClsInProps","prefixCls","className","style","restProps","_objectWithoutProperties","_excluded","langInProps","lang","_useContext","ConfigContext","getPrefixCls","rootPrefixCls","_useStyle","_useStyle2","_slicedToArray","wrapCSSVar","hashId","cssVarCls","contextValue","language","changeLanguage","concat","_toConsumableArray","Object","values","includes","removeResourceBundle","addResourceBundle","_objectSpread","translation","Provider","value","displayName"],"sources":["../../../src/components/ConfigProvider/index.tsx"],"sourcesContent":["import type { CSSProperties, FC, ReactNode } from 'react';\nimport { useContext, useEffect, useMemo } from 'react';\nimport { ConfigProvider as ReactConfigProvider } from 'antd';\nimport classNames from 'classnames';\nimport locales, { langs, resources } from '../../locales';\nimport type localesEn from '../../locales/langs/en';\nimport ReactEasyContext, { type ReactEasyContextProps } from './context';\nimport useStyle from './style';\n\nexport interface ConfigProviderProps extends ReactEasyContextProps {\n /**\n * - **EN:** Child elements of the ConfigProvider\n * - **CN:** ConfigProvider 的子元素\n */\n children: ReactNode;\n /**\n * - **EN:** Custom prefix for the component's CSS class.\n * - **CN:** 组件的自定义 CSS 类前缀。\n */\n prefixCls?: string;\n /**\n * - **EN:** Custom class name for the root element\n * - **CN:** 根元素的自定义类名\n */\n className?: string;\n /**\n * - **EN:** Custom styles for the root element\n * - **CN:** 根元素的自定义样式\n */\n style?: CSSProperties;\n /**\n * - **EN:** Custom localization resources, if `lang` exists, it will override the localization\n * resources of that language, otherwise, it will add a new language\n * - **CN:** 自定义本地化资源,如果`lang`存在,则会覆盖该语言的本地化资源,否则,会添加一种新的语言\n */\n locales?: Partial<typeof localesEn>;\n}\n\n/**\n * - **EN:** Provide global configuration for AntdHelper\n * - **CN:** 提供AntdHelper的全局配置\n */\nconst ConfigProvider: FC<ConfigProviderProps> = (props) => {\n const { children, locales: userLocales, prefixCls: prefixClsInProps, className, style, ...restProps } = props;\n const { lang: langInProps } = restProps;\n const { getPrefixCls, rootPrefixCls } = useContext(ReactConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('react-easy', prefixClsInProps);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls, rootPrefixCls);\n const contextValue = useMemo(\n () => {\n if (langInProps !== locales.language) {\n locales.changeLanguage(langInProps || 'en-US');\n }\n return restProps;\n },\n // eslint-disable-next-line @tiny-codes/react-hooks/exhaustive-deps\n [langInProps, ...Object.values(restProps)]\n );\n\n useEffect(() => {\n // Dynamically add language pack\n if (userLocales) {\n const lang = langInProps || 'en-US';\n if (lang && langs.includes(lang)) {\n locales.removeResourceBundle(lang, 'translation');\n locales.addResourceBundle(lang, 'translation', { ...resources[lang].translation, ...userLocales });\n } else {\n locales.addResourceBundle(lang, 'translation', { ...resources['en-US'].translation, ...userLocales });\n }\n }\n }, [langInProps, userLocales]);\n\n return wrapCSSVar(\n <ReactEasyContext.Provider value={contextValue}>\n <div className={classNames(hashId, cssVarCls, prefixCls, className)} style={style}>\n {children}\n </div>\n </ReactEasyContext.Provider>\n );\n};\nConfigProvider.displayName = 'ReactEasyConfigProvider';\n\nexport default ConfigProvider;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA,SAASA,UAAU,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AACtD,SAASC,cAAc,IAAIC,mBAAmB,QAAQ,MAAM;AAC5D,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,OAAO,IAAIC,KAAK,EAAEC,SAAS;AAElC,OAAOC,gBAAgB;AACvB,OAAOC,QAAQ;AAAgB,SAAAC,GAAA,IAAAC,IAAA;AA+B/B;AACA;AACA;AACA;AACA,IAAMT,cAAuC,GAAG,SAA1CA,cAAuCA,CAAIU,KAAK,EAAK;EACzD,IAAQC,QAAQ,GAAwFD,KAAK,CAArGC,QAAQ;IAAWC,WAAW,GAAkEF,KAAK,CAA3FP,OAAO;IAA0BU,gBAAgB,GAAqCH,KAAK,CAArEI,SAAS;IAAoBC,SAAS,GAA0BL,KAAK,CAAxCK,SAAS;IAAEC,KAAK,GAAmBN,KAAK,CAA7BM,KAAK;IAAKC,SAAS,GAAAC,wBAAA,CAAKR,KAAK,EAAAS,SAAA;EAC7G,IAAcC,WAAW,GAAKH,SAAS,CAA/BI,IAAI;EACZ,IAAAC,WAAA,GAAwCzB,UAAU,CAACI,mBAAmB,CAACsB,aAAa,CAAC;IAA7EC,YAAY,GAAAF,WAAA,CAAZE,YAAY;IAAEC,aAAa,GAAAH,WAAA,CAAbG,aAAa;EACnC,IAAMX,SAAS,GAAGU,YAAY,CAAC,YAAY,EAAEX,gBAAgB,CAAC;EAC9D,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AAKM,SAAS,EAAEb,UAAU,CAAC4B,MAAM,EAAEC,SAAS,EAAEjB,SAAS,EAAEC,SAAS,CAAE;MAACC,KAAK,EAAEA,KAAM;MAAAL,QAAA,EAC/EA;IAAQ,CACN;EAAC,CACmB,CAC7B,CAAC;AACH,CAAC;AACDX,cAAc,CAAC8C,WAAW,GAAG,yBAAyB;AAEtD,eAAe9C,cAAc"}
|
|
@@ -12,10 +12,26 @@ export interface ContextMenuProps extends MenuProps {
|
|
|
12
12
|
* - **CN:** 触发显示菜单的方式,默认是 `['contextMenu']`
|
|
13
13
|
*/
|
|
14
14
|
trigger?: ('click' | 'doubleClick' | 'hover' | 'contextMenu')[];
|
|
15
|
+
/**
|
|
16
|
+
* - **EN:** Custom properties for the trigger element
|
|
17
|
+
* - **CN:** 触发元素的自定义属性
|
|
18
|
+
*/
|
|
15
19
|
triggerProps?: {
|
|
20
|
+
/**
|
|
21
|
+
* - **EN:** Custom class name for the trigger element
|
|
22
|
+
* - **CN:** 触发元素的自定义类名
|
|
23
|
+
*/
|
|
16
24
|
className?: string;
|
|
25
|
+
/**
|
|
26
|
+
* - **EN:** Custom styles for the trigger element
|
|
27
|
+
* - **CN:** 触发元素的自定义样式
|
|
28
|
+
*/
|
|
17
29
|
style?: CSSProperties;
|
|
18
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* - **EN:** Custom prefix for the component's CSS class.
|
|
33
|
+
* - **CN:** 组件的自定义 CSS 类前缀。
|
|
34
|
+
*/
|
|
19
35
|
prefixCls?: string;
|
|
20
36
|
}
|
|
21
37
|
declare const ContextMenu: import("react").ForwardRefExoticComponent<ContextMenuProps & import("react").RefAttributes<ContextMenuRef>>;
|