type: rm useless type of reducer (#49555)

* type: rm useless type of reducer

* Update components/_util/ActionButton.tsx

Signed-off-by: lijianan <574980606@qq.com>

---------

Signed-off-by: lijianan <574980606@qq.com>
This commit is contained in:
lijianan 2024-06-22 23:57:39 +08:00 committed by GitHub
parent 59ad48476b
commit 2b629ef391
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 44 additions and 75 deletions

View File

@ -51,32 +51,27 @@ const DemoWrapper: typeof DumiDemoGrid = ({ items }) => {
const demos = React.useMemo(
() =>
items.reduce(
(acc, item) => {
const { previewerProps } = item;
const { debug } = previewerProps;
if (debug && !showDebug) {
return acc;
}
return acc.concat({
...item,
previewerProps: {
...previewerProps,
expand: expandAll,
// always override debug property, because dumi will hide debug demo in production
debug: false,
/**
* antd extra marker for the original debug
* @see https://github.com/ant-design/ant-design/pull/40130#issuecomment-1380208762
*/
originDebug: debug,
},
});
},
[] as typeof items,
),
items.reduce<typeof items>((acc, item) => {
const { previewerProps } = item;
const { debug } = previewerProps;
if (debug && !showDebug) {
return acc;
}
return acc.concat({
...item,
previewerProps: {
...previewerProps,
expand: expandAll,
// always override debug property, because dumi will hide debug demo in production
debug: false,
/**
* antd extra marker for the original debug
* @see https://github.com/ant-design/ant-design/pull/40130#issuecomment-1380208762
*/
originDebug: debug,
},
});
}, []),
[expandAll, showDebug],
);

View File

@ -13,9 +13,9 @@ let runtimeLocale: ModalLocale = {
let localeList: ModalLocale[] = [];
const generateLocale = () =>
localeList.reduce(
localeList.reduce<ModalLocale>(
(merged, locale) => ({ ...merged, ...locale }),
defaultLocale.Modal as ModalLocale,
defaultLocale.Modal!,
);
export function changeConfirmLocale(newLocale?: ModalLocale) {

View File

@ -27,8 +27,9 @@ const App: React.FC = () => {
const [position, setPosition] = useState<PositionType[]>(['left', 'right']);
const slot = useMemo(() => {
if (position.length === 0) return null;
if (position.length === 0) {
return null;
}
return position.reduce(
(acc, direction) => ({ ...acc, [direction]: OperationsSlot[direction] }),
{},

View File

@ -1,13 +1,7 @@
import { generate } from '@ant-design/colors';
import type { DerivativeFunc } from '@ant-design/cssinjs';
import type {
ColorPalettes,
LegacyColorPalettes,
MapToken,
PresetColorType,
SeedToken,
} from '../../interface';
import type { MapToken, PresetColorType, SeedToken } from '../../interface';
import defaultAlgorithm from '../default';
import { defaultPresetColors } from '../seed';
import genColorMapToken from '../shared/genColorMapToken';
@ -17,24 +11,17 @@ const derivative: DerivativeFunc<SeedToken, MapToken> = (token, mapToken) => {
const colorPalettes = Object.keys(defaultPresetColors)
.map((colorKey) => {
const colors = generate(token[colorKey as keyof PresetColorType], { theme: 'dark' });
return new Array(10).fill(1).reduce((prev, _, i) => {
prev[`${colorKey}-${i + 1}`] = colors[i];
prev[`${colorKey}${i + 1}`] = colors[i];
return prev;
}, {}) as ColorPalettes & LegacyColorPalettes;
}, {});
})
.reduce(
(prev, cur) => {
// biome-ignore lint/style/noParameterAssign: it is a reduce
prev = {
...prev,
...cur,
};
return prev;
},
{} as ColorPalettes & LegacyColorPalettes,
);
.reduce((prev, cur) => {
// biome-ignore lint/style/noParameterAssign: it is a reduce
prev = { ...prev, ...cur };
return prev;
}, {});
const mergedMapToken = mapToken ?? defaultAlgorithm(token);

View File

@ -1,12 +1,6 @@
import { generate } from '@ant-design/colors';
import type {
ColorPalettes,
LegacyColorPalettes,
MapToken,
PresetColorType,
SeedToken,
} from '../../interface';
import type { MapToken, PresetColorType, SeedToken } from '../../interface';
import { defaultPresetColors } from '../seed';
import genColorMapToken from '../shared/genColorMapToken';
import genCommonMapToken from '../shared/genCommonMapToken';
@ -19,24 +13,17 @@ export default function derivative(token: SeedToken): MapToken {
const colorPalettes = Object.keys(defaultPresetColors)
.map((colorKey) => {
const colors = generate(token[colorKey as keyof PresetColorType]);
return new Array(10).fill(1).reduce((prev, _, i) => {
prev[`${colorKey}-${i + 1}`] = colors[i];
prev[`${colorKey}${i + 1}`] = colors[i];
return prev;
}, {}) as ColorPalettes & LegacyColorPalettes;
}, {});
})
.reduce(
(prev, cur) => {
// biome-ignore lint/style/noParameterAssign: it is a reduce
prev = {
...prev,
...cur,
};
return prev;
},
{} as ColorPalettes & LegacyColorPalettes,
);
.reduce((prev, cur) => {
// biome-ignore lint/style/noParameterAssign: it is a reduce
prev = { ...prev, ...cur };
return prev;
}, {});
return {
...token,

View File

@ -22,15 +22,14 @@ export default function genPresetColor<Token extends TokenWithCommonCls<AliasTok
token: Token,
genCss: GenCSS,
): CSSObject {
return PresetColors.reduce((prev: CSSObject, colorKey: PresetColorKey) => {
return PresetColors.reduce<CSSObject>((prev: CSSObject, colorKey: PresetColorKey) => {
const lightColor = token[`${colorKey}1`];
const lightBorderColor = token[`${colorKey}3`];
const darkColor = token[`${colorKey}6`];
const textColor = token[`${colorKey}7`];
return {
...prev,
...genCss(colorKey, { lightColor, lightBorderColor, darkColor, textColor }),
};
}, {} as CSSObject);
}, {});
}

View File

@ -107,7 +107,7 @@ const main = async () => {
}
});
const finalMeta = Object.entries(tokenMeta).reduce((acc, [key, value]) => {
const finalMeta = Object.entries(tokenMeta).reduce<any>((acc, [key, value]) => {
if (key !== 'components') {
(value as any[]).forEach((item) => {
acc.global = acc.global || {};
@ -124,7 +124,7 @@ const main = async () => {
acc.components = value;
}
return acc;
}, {} as any);
}, {});
fs.writeJsonSync(output, finalMeta, 'utf8');
// eslint-disable-next-line no-console