From 49d056caa6a6f9886fe634bc8a6251415c4c7679 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Sat, 25 Jan 2025 11:28:52 +0800 Subject: [PATCH] refactor: lodash-es instead of lodash (#3345) * refactor: lodash-es instead of lodash * chore: update common * chore: remove packageManager --- package.json | 4 ++-- script/init-component/index.js | 6 +++--- script/rollup.config.js | 4 ++-- site/src/components/codesandbox/content.js | 4 ++-- src/_common | 2 +- src/_util/dom.ts | 2 +- src/_util/helper.ts | 2 +- src/_util/parseTNode.ts | 2 +- src/affix/Affix.tsx | 2 +- src/anchor/Anchor.tsx | 3 +-- src/auto-complete/HighlightOption.tsx | 2 +- src/auto-complete/OptionList.tsx | 3 +-- src/auto-complete/_example/filter.tsx | 2 +- src/breadcrumb/BreadcrumbItem.tsx | 2 +- src/cascader/Cascader.tsx | 3 +-- src/cascader/CascaderPanel.tsx | 2 +- src/cascader/components/Item.tsx | 2 +- src/cascader/core/effect.ts | 4 +--- src/cascader/core/helper.ts | 2 +- src/cascader/hooks.tsx | 3 +-- src/checkbox/CheckboxGroup.tsx | 2 +- src/color-picker/components/panel/format/index.tsx | 2 +- src/color-picker/components/panel/format/inputs.tsx | 2 +- src/color-picker/components/panel/linear-gradient.tsx | 2 +- src/common/Check.tsx | 2 +- src/config-provider/ConfigContext.tsx | 2 +- src/config-provider/ConfigProvider.tsx | 2 +- src/config-provider/_example/calendar.tsx | 2 +- src/config-provider/_example/date-picker.tsx | 2 +- src/config-provider/_example/dialog.tsx | 2 +- src/config-provider/_example/global.tsx | 2 +- src/config-provider/_example/others.tsx | 2 +- src/config-provider/_example/pagination.tsx | 2 +- src/config-provider/_example/popconfirm.tsx | 2 +- src/config-provider/_example/table.tsx | 2 +- src/date-picker/DatePicker.tsx | 2 +- src/date-picker/hooks/useDisableDate.ts | 2 +- src/date-picker/hooks/useSingle.tsx | 2 +- src/date-picker/panel/RangePanel.tsx | 2 +- src/date-picker/panel/SinglePanel.tsx | 2 +- src/date-picker/utils.ts | 2 +- src/descriptions/Descriptions.tsx | 3 +-- src/dialog/DialogCard.tsx | 4 +--- src/drawer/Drawer.tsx | 4 +--- src/dropdown/Dropdown.tsx | 2 +- src/dropdown/DropdownMenu.tsx | 2 +- src/empty/Empty.tsx | 3 +-- src/form/FormItem.tsx | 6 +----- src/form/FormList.tsx | 3 +-- src/form/_example/validator.tsx | 2 +- src/form/formModel.ts | 3 +-- src/form/hooks/useFormItemInitialData.ts | 4 +--- src/form/hooks/useInstance.tsx | 7 +------ src/form/hooks/useWatch.ts | 3 +-- src/form/utils/index.ts | 6 +----- src/grid/Col.tsx | 2 +- src/grid/Row.tsx | 2 +- src/guide/Guide.tsx | 2 +- src/hooks/useControlled.ts | 2 +- src/hooks/useDebounce.ts | 2 +- src/hooks/useMutationObserver.ts | 3 +-- src/hooks/useResizeObserver.ts | 2 +- src/hooks/useWindowSize.ts | 2 +- src/image-viewer/ImageViewer.tsx | 2 +- src/image-viewer/ImageViewerModal.tsx | 3 +-- src/image-viewer/hooks/useList.ts | 3 +-- src/image-viewer/hooks/usePosition.ts | 2 +- src/image/Image.tsx | 2 +- src/input-adornment/InputAdornment.tsx | 3 +-- src/input/Input.tsx | 2 +- src/list/List.tsx | 2 +- src/menu/HeadMenu.tsx | 2 +- src/menu/hooks/useMenuContext.ts | 2 +- src/pagination/Pagination.tsx | 3 +-- src/pagination/PaginationMini.tsx | 2 +- src/popconfirm/Popcontent.tsx | 2 +- src/popup/Popup.tsx | 3 +-- src/popup/PopupPlugin.tsx | 2 +- src/range-input/RangeInput.tsx | 2 +- src/select-input/useMultiple.tsx | 2 +- src/select-input/useOverlayInnerStyle.ts | 3 +-- src/select-input/useSingle.tsx | 3 +-- src/select/base/Option.tsx | 4 +--- src/select/base/Select.tsx | 4 +--- src/select/hooks/useOptions.ts | 2 +- src/select/util/helper.ts | 3 +-- src/skeleton/Skeleton.tsx | 2 +- src/slider/Slider.tsx | 3 +-- src/statistic/Statistic.tsx | 3 +-- src/table/BaseTable.tsx | 2 +- src/table/Cell.tsx | 3 +-- src/table/EditableCell.tsx | 5 +---- src/table/EnhancedTable.tsx | 2 +- src/table/FilterController.tsx | 2 +- src/table/PrimaryTable.tsx | 2 +- src/table/TBody.tsx | 4 +--- src/table/TFoot.tsx | 3 +-- src/table/THead.tsx | 2 +- src/table/TR.tsx | 2 +- src/table/_example/filter-controlled.tsx | 2 +- src/table/_example/tree-select.tsx | 2 +- src/table/hooks/tree-store.ts | 2 +- src/table/hooks/useAsyncLoading.tsx | 2 +- src/table/hooks/useColumnController.tsx | 3 +-- src/table/hooks/useColumnResize.tsx | 2 +- src/table/hooks/useDragSort.ts | 2 +- src/table/hooks/useEditableRow.ts | 3 +-- src/table/hooks/useFilter.tsx | 2 +- src/table/hooks/useFixed.ts | 4 +--- src/table/hooks/useRowExpand.tsx | 3 +-- src/table/hooks/useRowSelect.tsx | 4 +--- src/table/hooks/useRowspanAndColspan.ts | 2 +- src/table/hooks/useSorter.tsx | 2 +- src/table/hooks/useTableHeader.tsx | 2 +- src/table/hooks/useTreeData.tsx | 2 +- src/table/hooks/useTreeSelect.tsx | 3 +-- src/table/utils.ts | 4 +--- src/tabs/TabNav.tsx | 3 +-- src/tag-input/TagInput.tsx | 2 +- src/tag-input/useTagList.tsx | 2 +- src/tag-input/useTagScroll.ts | 2 +- src/time-picker/TimeRangePicker.tsx | 2 +- src/time-picker/panel/SinglePanel.tsx | 3 +-- src/timeline/TimelineItem.tsx | 2 +- src/tooltip/TooltipLite.tsx | 2 +- src/transfer/Transfer.tsx | 3 +-- src/transfer/TransferList.tsx | 4 +--- src/transfer/utils.ts | 4 +--- src/tree-select/TreeSelect.tsx | 2 +- src/tree-select/hooks/useTreeSelectPassthroughProps.ts | 2 +- src/tree/Tree.tsx | 2 +- src/tree/TreeItem.tsx | 2 +- src/tree/_example/state.tsx | 2 +- src/tree/hooks/useDraggable.tsx | 2 +- src/tree/hooks/useStore.ts | 2 +- src/typography/ellipsis/Truncate.tsx | 4 ++-- src/typography/ellipsis/useEllipsis.tsx | 2 +- src/upload/hooks/useUpload.ts | 2 +- src/upload/themes/MultipleFlowList.tsx | 3 +-- 139 files changed, 145 insertions(+), 215 deletions(-) diff --git a/package.json b/package.json index cad62c3841..69a86f0f83 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,7 @@ "@testing-library/user-event": "^14.4.3", "@types/estree": "1.0.6", "@types/hoist-non-react-statics": "^3.3.1", - "@types/lodash": "4.17.13", + "@types/lodash-es": "^4.17.12", "@types/node": "^22.7.0", "@types/raf": "^3.4.0", "@types/react": "~18.2.0", @@ -208,7 +208,7 @@ "classnames": "~2.5.1", "dayjs": "1.11.10", "hoist-non-react-statics": "~3.3.2", - "lodash": "~4.17.15", + "lodash-es": "^4.17.21", "mitt": "^3.0.0", "raf": "~3.4.1", "react-is": "^18.2.0", diff --git a/script/init-component/index.js b/script/init-component/index.js index 679de08810..68b60e4c2c 100644 --- a/script/init-component/index.js +++ b/script/init-component/index.js @@ -13,7 +13,7 @@ const fs = require('fs'); const path = require('path'); -const _ = require('lodash'); +const { startCase, camelCase, template } = require('lodash-es'); const config = require('./config'); const cwdPath = process.cwd(); @@ -29,13 +29,13 @@ function createFile(path, data = '', desc) { } function getPascalCase(name) { - return _.startCase(_.camelCase(name)).replace(/ /g, ''); + return startCase(camelCase(name)).replace(/ /g, ''); } function outputFileWithTemplate(item, component, desc, _d) { const tplPath = path.resolve(__dirname, `./tpl/${item.template}`); let data = fs.readFileSync(tplPath).toString(); - const compiled = _.template(data); + const compiled = template(data); data = compiled({ component, PascalCaseComponent: getPascalCase(component), diff --git a/script/rollup.config.js b/script/rollup.config.js index 278d5e84ab..d228063782 100644 --- a/script/rollup.config.js +++ b/script/rollup.config.js @@ -215,7 +215,7 @@ const umdConfig = { banner, format: 'umd', exports: 'named', - globals: { react: 'React', lodash: '_' }, + globals: { react: 'React' }, sourcemap: true, file: `dist/${name}.js`, }, @@ -234,7 +234,7 @@ const umdMinConfig = { banner, format: 'umd', exports: 'named', - globals: { react: 'React', lodash: '_' }, + globals: { react: 'React' }, sourcemap: true, file: `dist/${name}.min.js`, }, diff --git a/site/src/components/codesandbox/content.js b/site/src/components/codesandbox/content.js index 6d4ce19b6b..255c8bd4db 100644 --- a/site/src/components/codesandbox/content.js +++ b/site/src/components/codesandbox/content.js @@ -80,11 +80,11 @@ export const pkgContent = JSON.stringify( 'react-scripts': '^5.0.0', '@types/react': orgPkg.devDependencies['@types/react'], '@types/react-dom': orgPkg.devDependencies['@types/react-dom'], - lodash: orgPkg.dependencies.lodash, + 'lodash-es': orgPkg.dependencies['lodash-es'], }, devDependencies: { typescript: '^4.4.4', - '@types/lodash': orgPkg.devDependencies['@types/lodash'], + '@types/lodash-es': orgPkg.devDependencies['@types/lodash-es'], }, scripts: { start: 'react-scripts start', diff --git a/src/_common b/src/_common index 58ffcb16f6..e23ad04213 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 58ffcb16f6c310b678604a5b3309c280df669fad +Subproject commit e23ad04213d64f3b7161cc4cc758f8ca03d06ae9 diff --git a/src/_util/dom.ts b/src/_util/dom.ts index 65865a9b8f..cdc0374d1c 100644 --- a/src/_util/dom.ts +++ b/src/_util/dom.ts @@ -1,5 +1,5 @@ import raf from 'raf'; -import isString from 'lodash/isString'; +import { isString } from 'lodash-es'; import { easeInOutCubic, EasingFunction } from './easing'; import { ScrollContainer, ScrollContainerElement } from '../common'; diff --git a/src/_util/helper.ts b/src/_util/helper.ts index c86070d6d6..24a6c20dc9 100644 --- a/src/_util/helper.ts +++ b/src/_util/helper.ts @@ -1,4 +1,4 @@ -import camelCase from 'lodash/camelCase'; +import { camelCase } from 'lodash-es'; export function omit(obj: object, fields: string[]): object { const shallowCopy = { diff --git a/src/_util/parseTNode.ts b/src/_util/parseTNode.ts index 468639ee23..7dc12e870f 100644 --- a/src/_util/parseTNode.ts +++ b/src/_util/parseTNode.ts @@ -1,5 +1,5 @@ import React, { ReactElement, ReactNode } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { TNode } from '../common'; import log from '../_common/js/log'; diff --git a/src/affix/Affix.tsx b/src/affix/Affix.tsx index d0db2483fa..8413a40937 100644 --- a/src/affix/Affix.tsx +++ b/src/affix/Affix.tsx @@ -1,5 +1,5 @@ import React, { useEffect, forwardRef, useCallback, useImperativeHandle, useRef } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { StyledProps, ScrollContainerElement } from '../common'; import { TdAffixProps } from './type'; import { getScrollContainer } from '../_util/dom'; diff --git a/src/anchor/Anchor.tsx b/src/anchor/Anchor.tsx index c93d77efa4..330d0501a6 100644 --- a/src/anchor/Anchor.tsx +++ b/src/anchor/Anchor.tsx @@ -1,7 +1,6 @@ import React, { useState, useRef, useEffect, useCallback, useImperativeHandle } from 'react'; import classNames from 'classnames'; -import isEmpty from 'lodash/isEmpty'; -import isFunction from 'lodash/isFunction'; +import { isEmpty , isFunction } from 'lodash-es'; import { StyledProps } from '../common'; import { TdAnchorProps } from './type'; import useConfig from '../hooks/useConfig'; diff --git a/src/auto-complete/HighlightOption.tsx b/src/auto-complete/HighlightOption.tsx index b53a8a798a..e51064024c 100644 --- a/src/auto-complete/HighlightOption.tsx +++ b/src/auto-complete/HighlightOption.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import escapeRegExp from 'lodash/escapeRegExp'; +import { escapeRegExp } from 'lodash-es'; import useConfig from '../hooks/useConfig'; export interface TdHighlightOptionProps { diff --git a/src/auto-complete/OptionList.tsx b/src/auto-complete/OptionList.tsx index 6ed131af1e..73ad75c040 100644 --- a/src/auto-complete/OptionList.tsx +++ b/src/auto-complete/OptionList.tsx @@ -1,7 +1,6 @@ import React, { useMemo, useState, useRef, MouseEvent, useEffect, useImperativeHandle, forwardRef } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; -import escapeRegExp from 'lodash/escapeRegExp'; +import { isFunction , escapeRegExp } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import log from '../_common/js/log'; import { CommonClassNameType } from '../hooks/useCommonClassName'; diff --git a/src/auto-complete/_example/filter.tsx b/src/auto-complete/_example/filter.tsx index b54d00ab1a..2379263524 100644 --- a/src/auto-complete/_example/filter.tsx +++ b/src/auto-complete/_example/filter.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; import { Space, AutoComplete } from 'tdesign-react'; import type { AutoCompleteProps } from 'tdesign-react'; -import escapeRegExp from 'lodash/escapeRegExp'; +import { escapeRegExp } from 'lodash-es'; const LIST = ['第一个 AutoComplete 默认联想词', '第二个 AutoComplete 默认联想词', '第三个 AutoComplete 默认联想词']; diff --git a/src/breadcrumb/BreadcrumbItem.tsx b/src/breadcrumb/BreadcrumbItem.tsx index 26bb5ea55d..0004dc1783 100644 --- a/src/breadcrumb/BreadcrumbItem.tsx +++ b/src/breadcrumb/BreadcrumbItem.tsx @@ -1,7 +1,7 @@ import React, { forwardRef, useContext, useEffect, useMemo, useRef, useState } from 'react'; import classNames from 'classnames'; import { ChevronRightIcon as TdChevronRightIcon } from 'tdesign-icons-react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import useGlobalIcon from '../hooks/useGlobalIcon'; import useCommonClassName from '../hooks/useCommonClassName'; diff --git a/src/cascader/Cascader.tsx b/src/cascader/Cascader.tsx index 1d907e57f2..febd1f0535 100644 --- a/src/cascader/Cascader.tsx +++ b/src/cascader/Cascader.tsx @@ -1,7 +1,6 @@ import React, { useMemo } from 'react'; import classNames from 'classnames'; -import pick from 'lodash/pick'; -import omit from 'lodash/omit'; +import { pick , omit } from 'lodash-es'; import Panel from './components/Panel'; import SelectInput from '../select-input'; import FakeArrow from '../common/FakeArrow'; diff --git a/src/cascader/CascaderPanel.tsx b/src/cascader/CascaderPanel.tsx index feff148f44..3f76758523 100644 --- a/src/cascader/CascaderPanel.tsx +++ b/src/cascader/CascaderPanel.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import pick from 'lodash/pick'; +import { pick } from 'lodash-es'; import classNames from 'classnames'; import Panel from './components/Panel'; import { TdCascaderProps } from './interface'; diff --git a/src/cascader/components/Item.tsx b/src/cascader/components/Item.tsx index d8184cd2e8..970247d5ac 100644 --- a/src/cascader/components/Item.tsx +++ b/src/cascader/components/Item.tsx @@ -2,7 +2,7 @@ import React, { forwardRef, useMemo } from 'react'; import classNames from 'classnames'; import { ChevronRightIcon as TdChevronRightIcon } from 'tdesign-icons-react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import TLoading from '../../loading'; import Checkbox from '../../checkbox'; diff --git a/src/cascader/core/effect.ts b/src/cascader/core/effect.ts index c17b1d4394..70e5eb183b 100644 --- a/src/cascader/core/effect.ts +++ b/src/cascader/core/effect.ts @@ -1,6 +1,4 @@ -import isNumber from 'lodash/isNumber'; -import isFunction from 'lodash/isFunction'; -import cloneDeep from 'lodash/cloneDeep'; +import { isNumber , isFunction , cloneDeep } from 'lodash-es'; import { TreeNode, CascaderContextType, TdCascaderProps, TreeNodeValue, TreeNodeModel } from '../interface'; import { getFullPathLabel, getTreeValue } from './helper'; diff --git a/src/cascader/core/helper.ts b/src/cascader/core/helper.ts index 8f64ddce8b..1960aa11da 100644 --- a/src/cascader/core/helper.ts +++ b/src/cascader/core/helper.ts @@ -1,4 +1,4 @@ -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { TreeNode, CascaderContextType, diff --git a/src/cascader/hooks.tsx b/src/cascader/hooks.tsx index b6f62e70a8..6b80a84398 100644 --- a/src/cascader/hooks.tsx +++ b/src/cascader/hooks.tsx @@ -1,7 +1,6 @@ import { useState, useEffect, useMemo } from 'react'; -import isEqual from 'lodash/isEqual'; -import isFunction from 'lodash/isFunction'; +import { isEqual , isFunction } from 'lodash-es'; import TreeStore from '../_common/js/tree-v1/tree-store'; import { getTreeValue, getCascaderValue, isEmptyValues, isValueInvalid } from './core/helper'; diff --git a/src/checkbox/CheckboxGroup.tsx b/src/checkbox/CheckboxGroup.tsx index eed7e1216f..42a0d44b45 100644 --- a/src/checkbox/CheckboxGroup.tsx +++ b/src/checkbox/CheckboxGroup.tsx @@ -1,6 +1,6 @@ import React, { ReactElement, useCallback, useEffect, useMemo, useState } from 'react'; import classNames from 'classnames'; -import isNumber from 'lodash/isNumber'; +import { isNumber } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import { CheckContext, CheckContextValue, CheckProps } from '../common/Check'; import { CheckboxGroupValue, CheckboxOption, CheckboxOptionObj, TdCheckboxGroupProps, TdCheckboxProps } from './type'; diff --git a/src/color-picker/components/panel/format/index.tsx b/src/color-picker/components/panel/format/index.tsx index bb4c3e1685..35d93cc08c 100644 --- a/src/color-picker/components/panel/format/index.tsx +++ b/src/color-picker/components/panel/format/index.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import upperCase from 'lodash/upperCase'; +import { upperCase } from 'lodash-es'; import Select from '../../../../select'; import FormatInput from './inputs'; import Color from '../../../../_common/js/color-picker/color'; diff --git a/src/color-picker/components/panel/format/inputs.tsx b/src/color-picker/components/panel/format/inputs.tsx index f85cdbaae8..10a97442ad 100644 --- a/src/color-picker/components/panel/format/inputs.tsx +++ b/src/color-picker/components/panel/format/inputs.tsx @@ -1,5 +1,5 @@ import React, { useRef, useEffect } from 'react'; -import throttle from 'lodash/throttle'; +import { throttle } from 'lodash-es'; import Color from '../../../../_common/js/color-picker/color'; import Input from '../../../../input'; import InputNumber from '../../../../input-number'; diff --git a/src/color-picker/components/panel/linear-gradient.tsx b/src/color-picker/components/panel/linear-gradient.tsx index b16b89ee72..cd8cdb10bc 100644 --- a/src/color-picker/components/panel/linear-gradient.tsx +++ b/src/color-picker/components/panel/linear-gradient.tsx @@ -1,5 +1,5 @@ import React, { KeyboardEvent, MouseEvent as ReactMouseEvent, useCallback, useEffect, useRef, useState } from 'react'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import classNames from 'classnames'; import useClassName from '../../hooks/useClassNames'; import { genGradientPoint, gradientColors2string } from '../../../_common/js/color-picker/color'; diff --git a/src/common/Check.tsx b/src/common/Check.tsx index f2a0f07cbc..ea6d36cbb4 100644 --- a/src/common/Check.tsx +++ b/src/common/Check.tsx @@ -1,6 +1,6 @@ import React, { forwardRef, useContext, MouseEvent, ChangeEvent } from 'react'; import classNames from 'classnames'; -import isBoolean from 'lodash/isBoolean'; +import { isBoolean } from 'lodash-es'; import { omit } from '../_util/helper'; import { StyledProps } from '../common'; import useConfig from '../hooks/useConfig'; diff --git a/src/config-provider/ConfigContext.tsx b/src/config-provider/ConfigContext.tsx index 92d8a1fb7e..20b2ee3d75 100644 --- a/src/config-provider/ConfigContext.tsx +++ b/src/config-provider/ConfigContext.tsx @@ -1,5 +1,5 @@ import { createContext } from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import defaultLocale from '../locale/zh_CN'; import defaultConfig from '../_common/js/global-config/default-config'; import { GlobalConfigProvider } from './type'; diff --git a/src/config-provider/ConfigProvider.tsx b/src/config-provider/ConfigProvider.tsx index 27891d94c4..e512800f54 100644 --- a/src/config-provider/ConfigProvider.tsx +++ b/src/config-provider/ConfigProvider.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import _mergeWith from 'lodash/mergeWith'; +import { mergeWith as _mergeWith } from 'lodash-es'; import ConfigContext, { defaultGlobalConfig, Config } from './ConfigContext'; import { GlobalConfigProvider } from './type'; diff --git a/src/config-provider/_example/calendar.tsx b/src/config-provider/_example/calendar.tsx index 15c9d8c636..cb697bdb32 100644 --- a/src/config-provider/_example/calendar.tsx +++ b/src/config-provider/_example/calendar.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, Calendar } from 'tdesign-react'; import enConfig from 'tdesign-react/es/locale/en_US'; diff --git a/src/config-provider/_example/date-picker.tsx b/src/config-provider/_example/date-picker.tsx index c7074f0c82..93b1de9552 100644 --- a/src/config-provider/_example/date-picker.tsx +++ b/src/config-provider/_example/date-picker.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, DatePicker, DateRangePicker, Space } from 'tdesign-react'; import enConfig from 'tdesign-react/es/locale/en_US'; diff --git a/src/config-provider/_example/dialog.tsx b/src/config-provider/_example/dialog.tsx index f7d13377c7..1e8e3bb0ec 100644 --- a/src/config-provider/_example/dialog.tsx +++ b/src/config-provider/_example/dialog.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, DialogCard, Space } from 'tdesign-react'; import enConfig from 'tdesign-react/es/locale/en_US'; diff --git a/src/config-provider/_example/global.tsx b/src/config-provider/_example/global.tsx index 1a18faf60a..90bb968544 100644 --- a/src/config-provider/_example/global.tsx +++ b/src/config-provider/_example/global.tsx @@ -1,6 +1,6 @@ /* eslint-disable react/no-unescaped-entities */ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, Space } from 'tdesign-react'; import enConfig from 'tdesign-react/es/locale/en_US'; diff --git a/src/config-provider/_example/others.tsx b/src/config-provider/_example/others.tsx index 2835533a76..127bfc469a 100644 --- a/src/config-provider/_example/others.tsx +++ b/src/config-provider/_example/others.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, Form, diff --git a/src/config-provider/_example/pagination.tsx b/src/config-provider/_example/pagination.tsx index aa14399f6d..3ffff40dcd 100644 --- a/src/config-provider/_example/pagination.tsx +++ b/src/config-provider/_example/pagination.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, Pagination } from 'tdesign-react'; import enConfig from 'tdesign-react/es/locale/en_US'; diff --git a/src/config-provider/_example/popconfirm.tsx b/src/config-provider/_example/popconfirm.tsx index 46e82a1ac9..06a3c90f87 100644 --- a/src/config-provider/_example/popconfirm.tsx +++ b/src/config-provider/_example/popconfirm.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, Popconfirm, Button, Space } from 'tdesign-react'; import enConfig from 'tdesign-react/es/locale/en_US'; diff --git a/src/config-provider/_example/table.tsx b/src/config-provider/_example/table.tsx index 7515a585b6..cee62c4874 100644 --- a/src/config-provider/_example/table.tsx +++ b/src/config-provider/_example/table.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, Table, Space } from 'tdesign-react'; import { ChevronRightIcon, CaretDownSmallIcon } from 'tdesign-icons-react'; import enConfig from 'tdesign-react/es/locale/en_US'; diff --git a/src/date-picker/DatePicker.tsx b/src/date-picker/DatePicker.tsx index f61413ccf1..ae81f04642 100644 --- a/src/date-picker/DatePicker.tsx +++ b/src/date-picker/DatePicker.tsx @@ -1,7 +1,7 @@ import React, { forwardRef, useEffect, useCallback } from 'react'; import classNames from 'classnames'; import dayjs from 'dayjs'; -import isDate from 'lodash/isDate'; +import { isDate } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import { StyledProps } from '../common'; import { TdDatePickerProps, PresetDate, DateMultipleValue, DateValue } from './type'; diff --git a/src/date-picker/hooks/useDisableDate.ts b/src/date-picker/hooks/useDisableDate.ts index 8670dda675..2e09ec0a3e 100644 --- a/src/date-picker/hooks/useDisableDate.ts +++ b/src/date-picker/hooks/useDisableDate.ts @@ -1,4 +1,4 @@ -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import type { TdDatePickerProps, TdDateRangePickerProps } from '../type'; import { isEnabledDate } from '../../_common/js/date-picker/utils'; diff --git a/src/date-picker/hooks/useSingle.tsx b/src/date-picker/hooks/useSingle.tsx index 85d31d169b..1e859e60f8 100644 --- a/src/date-picker/hooks/useSingle.tsx +++ b/src/date-picker/hooks/useSingle.tsx @@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef } from 'react'; import { CalendarIcon as TdCalendarIcon } from 'tdesign-icons-react'; import dayjs from 'dayjs'; import classNames from 'classnames'; -import omit from 'lodash/omit'; +import { omit } from 'lodash-es'; import useConfig from '../../hooks/useConfig'; import useGlobalIcon from '../../hooks/useGlobalIcon'; import { TdDatePickerProps } from '../type'; diff --git a/src/date-picker/panel/RangePanel.tsx b/src/date-picker/panel/RangePanel.tsx index 85d42a60d3..3bf7eb226e 100644 --- a/src/date-picker/panel/RangePanel.tsx +++ b/src/date-picker/panel/RangePanel.tsx @@ -1,6 +1,6 @@ import React, { forwardRef } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import useConfig from '../../hooks/useConfig'; import { StyledProps } from '../../common'; import PanelContent from './PanelContent'; diff --git a/src/date-picker/panel/SinglePanel.tsx b/src/date-picker/panel/SinglePanel.tsx index 96fc61a625..5402b8d421 100644 --- a/src/date-picker/panel/SinglePanel.tsx +++ b/src/date-picker/panel/SinglePanel.tsx @@ -1,6 +1,6 @@ import React, { forwardRef } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import useConfig from '../../hooks/useConfig'; import { StyledProps } from '../../common'; import PanelContent from './PanelContent'; diff --git a/src/date-picker/utils.ts b/src/date-picker/utils.ts index 90df439244..3d7737f8c4 100644 --- a/src/date-picker/utils.ts +++ b/src/date-picker/utils.ts @@ -1,4 +1,4 @@ -import isNil from 'lodash/isNil'; +import { isNil } from 'lodash-es'; import { parseToDayjs } from '../_common/js/date-picker/format'; // 用于头部日期切换修正 diff --git a/src/descriptions/Descriptions.tsx b/src/descriptions/Descriptions.tsx index e0a72636ae..0af1b2f237 100644 --- a/src/descriptions/Descriptions.tsx +++ b/src/descriptions/Descriptions.tsx @@ -1,7 +1,6 @@ import React from 'react'; import classNames from 'classnames'; -import isArray from 'lodash/isArray'; -import assign from 'lodash/assign'; +import { isArray , assign } from 'lodash-es'; import { TdDescriptionItemProps, TdDescriptionsProps } from './type'; import { descriptionItemDefaultProps, descriptionsDefaultProps } from './defaultProps'; import useDefaultProps from '../hooks/useDefaultProps'; diff --git a/src/dialog/DialogCard.tsx b/src/dialog/DialogCard.tsx index 42de883326..198eff6d8f 100644 --- a/src/dialog/DialogCard.tsx +++ b/src/dialog/DialogCard.tsx @@ -1,8 +1,6 @@ import React, { forwardRef, isValidElement } from 'react'; import classNames from 'classnames'; -import isString from 'lodash/isString'; -import isObject from 'lodash/isObject'; -import isFunction from 'lodash/isFunction'; +import { isString , isObject , isFunction } from 'lodash-es'; import { CloseIcon as TdCloseIcon, InfoCircleFilledIcon as TdInfoCircleFilledIcon, diff --git a/src/drawer/Drawer.tsx b/src/drawer/Drawer.tsx index 9b48802511..bbb0c18c23 100644 --- a/src/drawer/Drawer.tsx +++ b/src/drawer/Drawer.tsx @@ -1,8 +1,6 @@ import React, { forwardRef, useState, useEffect, useImperativeHandle, useRef, useMemo, isValidElement } from 'react'; import classnames from 'classnames'; -import isString from 'lodash/isString'; -import isObject from 'lodash/isObject'; -import isFunction from 'lodash/isFunction'; +import { isString , isObject , isFunction } from 'lodash-es'; import { CSSTransition } from 'react-transition-group'; import { CloseIcon as TdCloseIcon } from 'tdesign-icons-react'; diff --git a/src/dropdown/Dropdown.tsx b/src/dropdown/Dropdown.tsx index 06bbe046af..6900ea98c2 100644 --- a/src/dropdown/Dropdown.tsx +++ b/src/dropdown/Dropdown.tsx @@ -1,6 +1,6 @@ import React, { isValidElement, useState } from 'react'; import classNames from 'classnames'; -import omit from 'lodash/omit'; +import { omit } from 'lodash-es'; import { DropdownOption, TdDropdownProps } from './type'; import { StyledProps } from '../common'; import Popup, { PopupVisibleChangeContext } from '../popup'; diff --git a/src/dropdown/DropdownMenu.tsx b/src/dropdown/DropdownMenu.tsx index 89662249dd..1261d975b2 100644 --- a/src/dropdown/DropdownMenu.tsx +++ b/src/dropdown/DropdownMenu.tsx @@ -1,6 +1,6 @@ import React, { ReactElement, useEffect, useRef, useState } from 'react'; import classNames from 'classnames'; -import throttle from 'lodash/throttle'; +import { throttle } from 'lodash-es'; import { ChevronRightIcon as TdIconChevronRight } from 'tdesign-icons-react'; import useConfig from '../hooks/useConfig'; import { DropdownProps } from './Dropdown'; diff --git a/src/empty/Empty.tsx b/src/empty/Empty.tsx index ff8367a7d1..a5cff98dc4 100644 --- a/src/empty/Empty.tsx +++ b/src/empty/Empty.tsx @@ -1,8 +1,7 @@ import React, { isValidElement } from 'react'; import type { ReactNode } from 'react'; import cls from 'classnames'; -import isObject from 'lodash/isObject'; -import isString from 'lodash/isString'; +import { isObject , isString } from 'lodash-es'; import useDefaultProps from '../hooks/useDefaultProps'; import useConfig from '../hooks/useConfig'; import { useLocaleReceiver } from '../locale/LocalReceiver'; diff --git a/src/form/FormItem.tsx b/src/form/FormItem.tsx index 262c7f9969..2e539e7f8f 100644 --- a/src/form/FormItem.tsx +++ b/src/form/FormItem.tsx @@ -1,9 +1,5 @@ import React, { forwardRef, ReactNode, useState, useImperativeHandle, useEffect, useRef, useMemo } from 'react'; -import isObject from 'lodash/isObject'; -import isString from 'lodash/isString'; -import get from 'lodash/get'; -import merge from 'lodash/merge'; -import isFunction from 'lodash/isFunction'; +import { isObject , isString , get , merge , isFunction } from 'lodash-es'; import { CheckCircleFilledIcon as TdCheckCircleFilledIcon, CloseCircleFilledIcon as TdCloseCircleFilledIcon, diff --git a/src/form/FormList.tsx b/src/form/FormList.tsx index d1dd6ed630..708d0cffb5 100644 --- a/src/form/FormList.tsx +++ b/src/form/FormList.tsx @@ -1,6 +1,5 @@ import React, { useState, useEffect, useRef, useImperativeHandle } from 'react'; -import merge from 'lodash/merge'; -import get from 'lodash/get'; +import { merge , get } from 'lodash-es'; import { FormListContext, useFormContext } from './FormContext'; import { FormItemInstance } from './FormItem'; import { HOOK_MARK } from './hooks/useForm'; diff --git a/src/form/_example/validator.tsx b/src/form/_example/validator.tsx index 401d65cb6e..5383d353e9 100644 --- a/src/form/_example/validator.tsx +++ b/src/form/_example/validator.tsx @@ -1,7 +1,7 @@ import React, { useRef } from 'react'; import { Form, Input, Radio, Checkbox, Button, MessagePlugin } from 'tdesign-react'; import type { FormProps, CustomValidator } from 'tdesign-react'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; const { FormItem } = Form; diff --git a/src/form/formModel.ts b/src/form/formModel.ts index 3dc8fc65ab..d85dc106b6 100644 --- a/src/form/formModel.ts +++ b/src/form/formModel.ts @@ -2,9 +2,8 @@ import isDate from 'validator/lib/isDate'; import isEmail from 'validator/lib/isEmail'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty , isNumber } from 'lodash-es'; import isURL from 'validator/lib/isURL'; -import isNumber from 'lodash/isNumber'; import { getCharacterLength } from '../_common/js/utils/helper'; import { CustomValidator, diff --git a/src/form/hooks/useFormItemInitialData.ts b/src/form/hooks/useFormItemInitialData.ts index 9ff275729a..34ca15c5bf 100644 --- a/src/form/hooks/useFormItemInitialData.ts +++ b/src/form/hooks/useFormItemInitialData.ts @@ -1,7 +1,5 @@ import React, { useEffect } from 'react'; -import get from 'lodash/get'; -import unset from 'lodash/unset'; -import isEmpty from 'lodash/isEmpty'; +import { get , unset , isEmpty } from 'lodash-es'; // 兼容特殊数据结构和受控 key import Tree from '../../tree/Tree'; diff --git a/src/form/hooks/useInstance.tsx b/src/form/hooks/useInstance.tsx index a4d006f78d..491f96d097 100644 --- a/src/form/hooks/useInstance.tsx +++ b/src/form/hooks/useInstance.tsx @@ -1,9 +1,4 @@ -import isEmpty from 'lodash/isEmpty'; -import isFunction from 'lodash/isFunction'; -import isEqual from 'lodash/isEqual'; -import merge from 'lodash/merge'; -import get from 'lodash/get'; -import set from 'lodash/set'; +import { isEmpty , isFunction , isEqual , merge , get , set } from 'lodash-es'; import type { TdFormProps, FormValidateResult, diff --git a/src/form/hooks/useWatch.ts b/src/form/hooks/useWatch.ts index 725fc12814..acb761f914 100644 --- a/src/form/hooks/useWatch.ts +++ b/src/form/hooks/useWatch.ts @@ -1,6 +1,5 @@ import { useState, useEffect, useMemo, useRef } from 'react'; -import get from 'lodash/get'; -import isUndefined from 'lodash/isUndefined'; +import { get , isUndefined } from 'lodash-es'; import type { NamePath } from '../type'; import type { InternalFormInstance } from './interface'; import { HOOK_MARK } from './useForm'; diff --git a/src/form/utils/index.ts b/src/form/utils/index.ts index fbb94f7428..fdcaa3b3ef 100644 --- a/src/form/utils/index.ts +++ b/src/form/utils/index.ts @@ -1,8 +1,4 @@ -import has from 'lodash/has'; -import get from 'lodash/get'; -import isObject from 'lodash/isObject'; -import isArray from 'lodash/isArray'; -import isEmpty from 'lodash/isEmpty'; +import { has , get , isObject , isArray , isEmpty } from 'lodash-es'; import type { NamePath } from '../type'; // 获取 formMap 管理的数据 diff --git a/src/grid/Col.tsx b/src/grid/Col.tsx index 31f434721a..4ce6e62c17 100644 --- a/src/grid/Col.tsx +++ b/src/grid/Col.tsx @@ -1,6 +1,6 @@ import React, { useContext, forwardRef } from 'react'; import classNames from 'classnames'; -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import { StyledProps } from '../common'; import { TdColProps, TdRowProps } from './type'; diff --git a/src/grid/Row.tsx b/src/grid/Row.tsx index 91bfbefb02..cb77a09d50 100644 --- a/src/grid/Row.tsx +++ b/src/grid/Row.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState, forwardRef, createContext } from 'react'; import classNames from 'classnames'; -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import { StyledProps } from '../common'; import { TdRowProps } from './type'; diff --git a/src/guide/Guide.tsx b/src/guide/Guide.tsx index 6a24181a60..f73043a848 100644 --- a/src/guide/Guide.tsx +++ b/src/guide/Guide.tsx @@ -1,5 +1,5 @@ import React, { useMemo, useEffect, useRef, useState } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import cx from 'classnames'; import { createPortal } from 'react-dom'; import Button from '../button'; diff --git a/src/hooks/useControlled.ts b/src/hooks/useControlled.ts index a34cc539af..e3c3eb1c97 100644 --- a/src/hooks/useControlled.ts +++ b/src/hooks/useControlled.ts @@ -1,5 +1,5 @@ import { useState } from 'react'; -import upperFirst from 'lodash/upperFirst'; +import { upperFirst } from 'lodash-es'; import noop from '../_util/noop'; export interface ChangeHandler { diff --git a/src/hooks/useDebounce.ts b/src/hooks/useDebounce.ts index eab6c01a93..8b543faf15 100644 --- a/src/hooks/useDebounce.ts +++ b/src/hooks/useDebounce.ts @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; import type { DebounceSettingsLeading } from 'lodash'; import { useCallback, useEffect } from 'react'; import { usePersistFn } from './usePersistFn'; diff --git a/src/hooks/useMutationObserver.ts b/src/hooks/useMutationObserver.ts index 699f9e2ec5..de92137d8c 100644 --- a/src/hooks/useMutationObserver.ts +++ b/src/hooks/useMutationObserver.ts @@ -1,6 +1,5 @@ import { useRef, useEffect } from 'react'; -import debounce from 'lodash/debounce'; -import isEqual from 'lodash/isEqual'; +import { debounce , isEqual } from 'lodash-es'; import useLatest from './useLatest'; const DEFAULT_OPTIONS = { diff --git a/src/hooks/useResizeObserver.ts b/src/hooks/useResizeObserver.ts index 06041f08df..51d139096d 100644 --- a/src/hooks/useResizeObserver.ts +++ b/src/hooks/useResizeObserver.ts @@ -1,5 +1,5 @@ import { useLayoutEffect } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; export default function useResizeObserver(container: HTMLElement, callback: (data: [ResizeObserverEntry]) => void) { let containerObserver: ResizeObserver = null; diff --git a/src/hooks/useWindowSize.ts b/src/hooks/useWindowSize.ts index 551ab93f9f..7f06636f02 100644 --- a/src/hooks/useWindowSize.ts +++ b/src/hooks/useWindowSize.ts @@ -1,5 +1,5 @@ import { useCallback, useEffect, useState } from 'react'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; export interface WindowSize { width: number; diff --git a/src/image-viewer/ImageViewer.tsx b/src/image-viewer/ImageViewer.tsx index 5e338c5745..2db2f26f00 100644 --- a/src/image-viewer/ImageViewer.tsx +++ b/src/image-viewer/ImageViewer.tsx @@ -1,6 +1,6 @@ import React, { useMemo, useState } from 'react'; import { createPortal } from 'react-dom'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { ImageModal } from './ImageViewerModal'; import { imageViewerDefaultProps } from './defaultProps'; import type { TdImageViewerProps } from './type'; diff --git a/src/image-viewer/ImageViewerModal.tsx b/src/image-viewer/ImageViewerModal.tsx index cb7df7e438..65d402fd5c 100644 --- a/src/image-viewer/ImageViewerModal.tsx +++ b/src/image-viewer/ImageViewerModal.tsx @@ -1,6 +1,5 @@ import React, { useState, useEffect, useCallback, MouseEvent, KeyboardEvent, useRef } from 'react'; -import isArray from 'lodash/isArray'; -import isFunction from 'lodash/isFunction'; +import { isArray , isFunction } from 'lodash-es'; import { ImageErrorIcon as TdImageErrorIcon, ImageIcon as TdImageIcon, diff --git a/src/image-viewer/hooks/useList.ts b/src/image-viewer/hooks/useList.ts index f90e7bb37d..25c14a0873 100644 --- a/src/image-viewer/hooks/useList.ts +++ b/src/image-viewer/hooks/useList.ts @@ -1,6 +1,5 @@ import { useMemo } from 'react'; -import isString from 'lodash/isString'; -import isArray from 'lodash/isArray'; +import { isString , isArray } from 'lodash-es'; import type { ImageInfo, TdImageViewerProps } from '../type'; const isImageInfo = (image: string | File | ImageInfo): image is ImageInfo => diff --git a/src/image-viewer/hooks/usePosition.ts b/src/image-viewer/hooks/usePosition.ts index 173e16245d..cd5d117e3d 100644 --- a/src/image-viewer/hooks/usePosition.ts +++ b/src/image-viewer/hooks/usePosition.ts @@ -1,5 +1,5 @@ import { MouseEventHandler, useCallback, useEffect, useRef, useState } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; export type PositionType = [number, number]; diff --git a/src/image/Image.tsx b/src/image/Image.tsx index 35aea54f88..54803dd60e 100644 --- a/src/image/Image.tsx +++ b/src/image/Image.tsx @@ -1,6 +1,6 @@ import React, { Fragment, useEffect, useRef, useState, SyntheticEvent, MouseEvent } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { ImageErrorIcon as TdImageErrorIcon, ImageIcon as TdImageIcon } from 'tdesign-icons-react'; import observe from '../_common/js/utils/observe'; import useConfig from '../hooks/useConfig'; diff --git a/src/input-adornment/InputAdornment.tsx b/src/input-adornment/InputAdornment.tsx index f715fbcdec..a473786b5c 100644 --- a/src/input-adornment/InputAdornment.tsx +++ b/src/input-adornment/InputAdornment.tsx @@ -1,7 +1,6 @@ import React, { forwardRef } from 'react'; import classNames from 'classnames'; -import isString from 'lodash/isString'; -import isNumber from 'lodash/isNumber'; +import { isString , isNumber } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import { TdInputAdornmentProps } from './type'; import { StyledProps } from '../common'; diff --git a/src/input/Input.tsx b/src/input/Input.tsx index 1291f438b1..9835ac355f 100644 --- a/src/input/Input.tsx +++ b/src/input/Input.tsx @@ -5,7 +5,7 @@ import { BrowseOffIcon as TdBrowseOffIcon, CloseCircleFilledIcon as TdCloseCircleFilledIcon, } from 'tdesign-icons-react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import useLayoutEffect from '../hooks/useLayoutEffect'; import forwardRefWithStatics from '../_util/forwardRefWithStatics'; import useConfig from '../hooks/useConfig'; diff --git a/src/list/List.tsx b/src/list/List.tsx index e44b0794bb..bf875c4ef6 100644 --- a/src/list/List.tsx +++ b/src/list/List.tsx @@ -1,7 +1,7 @@ import React, { MouseEvent, WheelEvent } from 'react'; import classNames from 'classnames'; -import isString from 'lodash/isString'; +import { isString } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import { useLocaleReceiver } from '../locale/LocalReceiver'; import forwardRefWithStatics from '../_util/forwardRefWithStatics'; diff --git a/src/menu/HeadMenu.tsx b/src/menu/HeadMenu.tsx index d4fa900280..936e0095c7 100644 --- a/src/menu/HeadMenu.tsx +++ b/src/menu/HeadMenu.tsx @@ -1,6 +1,6 @@ import classNames from 'classnames'; import React, { FC, ReactElement, useMemo } from 'react'; -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import Tabs from '../tabs'; import { StyledProps } from '../common'; import { TdHeadMenuProps } from './type'; diff --git a/src/menu/hooks/useMenuContext.ts b/src/menu/hooks/useMenuContext.ts index 3332e718b7..db976519a2 100644 --- a/src/menu/hooks/useMenuContext.ts +++ b/src/menu/hooks/useMenuContext.ts @@ -1,4 +1,4 @@ -import noop from 'lodash/noop'; +import { noop } from 'lodash-es'; import { useState, ReactNode } from 'react'; import { MenuState, SetMenuState, MenuMode } from '../MenuContext'; import checkSubMenuChildExpanded from '../_util/checkSubMenuChildExpanded'; diff --git a/src/pagination/Pagination.tsx b/src/pagination/Pagination.tsx index 06514ed87c..9d043af24b 100644 --- a/src/pagination/Pagination.tsx +++ b/src/pagination/Pagination.tsx @@ -1,7 +1,6 @@ import React, { useState, useMemo, forwardRef, useEffect } from 'react'; import classNames from 'classnames'; -import omit from 'lodash/omit'; -import isNaN from 'lodash/isNaN'; +import { omit , isNaN } from 'lodash-es'; import noop from '../_util/noop'; import useConfig from '../hooks/useConfig'; diff --git a/src/pagination/PaginationMini.tsx b/src/pagination/PaginationMini.tsx index 1ff910e5ca..598a2dfb5d 100644 --- a/src/pagination/PaginationMini.tsx +++ b/src/pagination/PaginationMini.tsx @@ -1,6 +1,6 @@ import React, { forwardRef, useMemo } from 'react'; import classNames from 'classnames'; -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import { RoundIcon as TdRoundIcon, ChevronUpIcon as TdChevronUpIcon, diff --git a/src/popconfirm/Popcontent.tsx b/src/popconfirm/Popcontent.tsx index 10abb01ce0..c06a51f0a8 100644 --- a/src/popconfirm/Popcontent.tsx +++ b/src/popconfirm/Popcontent.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import isString from 'lodash/isString'; +import { isString } from 'lodash-es'; import classNames from 'classnames'; import { InfoCircleFilledIcon as TdInfoCircleFilledIcon } from 'tdesign-icons-react'; import Button, { ButtonProps } from '../button'; diff --git a/src/popup/Popup.tsx b/src/popup/Popup.tsx index 797812f7b5..6c3e8305e9 100644 --- a/src/popup/Popup.tsx +++ b/src/popup/Popup.tsx @@ -1,7 +1,6 @@ import React, { forwardRef, useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react'; import { CSSTransition } from 'react-transition-group'; -import isFunction from 'lodash/isFunction'; -import debounce from 'lodash/debounce'; +import { isFunction , debounce } from 'lodash-es'; import classNames from 'classnames'; import { usePopper } from 'react-popper'; import { Placement } from '@popperjs/core'; diff --git a/src/popup/PopupPlugin.tsx b/src/popup/PopupPlugin.tsx index 3e180c076b..4ef6b47310 100644 --- a/src/popup/PopupPlugin.tsx +++ b/src/popup/PopupPlugin.tsx @@ -1,6 +1,6 @@ import React, { useLayoutEffect, useMemo, useRef, useState } from 'react'; import { createPopper, Instance, Placement } from '@popperjs/core'; -import isString from 'lodash/isString'; +import { isString } from 'lodash-es'; import classNames from 'classnames'; import { CSSTransition } from 'react-transition-group'; import { render, unmount } from '../_util/react-render'; diff --git a/src/range-input/RangeInput.tsx b/src/range-input/RangeInput.tsx index b0c838bf14..6a21a8bb7c 100644 --- a/src/range-input/RangeInput.tsx +++ b/src/range-input/RangeInput.tsx @@ -1,6 +1,6 @@ import React, { useState, useRef, useImperativeHandle } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { CloseCircleFilledIcon as TdCloseCircleFilledIcon } from 'tdesign-icons-react'; import Input, { InputRef } from '../input'; import useConfig from '../hooks/useConfig'; diff --git a/src/select-input/useMultiple.tsx b/src/select-input/useMultiple.tsx index 8146a01b21..5bf3e0af33 100644 --- a/src/select-input/useMultiple.tsx +++ b/src/select-input/useMultiple.tsx @@ -1,5 +1,5 @@ import React, { useRef, MouseEvent } from 'react'; -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import classNames from 'classnames'; import { TdSelectInputProps, SelectInputChangeContext, SelectInputKeys, SelectInputValue } from './type'; import TagInput, { TagInputValue } from '../tag-input'; diff --git a/src/select-input/useOverlayInnerStyle.ts b/src/select-input/useOverlayInnerStyle.ts index 213f88ec87..5a58546c3d 100644 --- a/src/select-input/useOverlayInnerStyle.ts +++ b/src/select-input/useOverlayInnerStyle.ts @@ -1,6 +1,5 @@ import React, { useMemo } from 'react'; -import isObject from 'lodash/isObject'; -import isFunction from 'lodash/isFunction'; +import { isObject , isFunction } from 'lodash-es'; import useControlled from '../hooks/useControlled'; diff --git a/src/select-input/useSingle.tsx b/src/select-input/useSingle.tsx index 64e75b5896..1d433c61a0 100644 --- a/src/select-input/useSingle.tsx +++ b/src/select-input/useSingle.tsx @@ -1,6 +1,5 @@ import React, { useRef, MouseEvent } from 'react'; -import isObject from 'lodash/isObject'; -import pick from 'lodash/pick'; +import { isObject , pick } from 'lodash-es'; import classNames from 'classnames'; import { SelectInputCommonProperties } from './interface'; import Input, { InputRef, TdInputProps } from '../input'; diff --git a/src/select/base/Option.tsx b/src/select/base/Option.tsx index 3077247aee..f7381c217d 100644 --- a/src/select/base/Option.tsx +++ b/src/select/base/Option.tsx @@ -1,8 +1,6 @@ import React, { useEffect, useMemo } from 'react'; import classNames from 'classnames'; -import isNumber from 'lodash/isNumber'; -import isString from 'lodash/isString'; -import get from 'lodash/get'; +import { isNumber , isString , get } from 'lodash-es'; import useConfig from '../../hooks/useConfig'; import useDomRefCallback from '../../hooks/useDomRefCallback'; diff --git a/src/select/base/Select.tsx b/src/select/base/Select.tsx index 4f440dff7b..b27b2989f6 100644 --- a/src/select/base/Select.tsx +++ b/src/select/base/Select.tsx @@ -11,9 +11,7 @@ import React, { useState, } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; -import get from 'lodash/get'; -import debounce from 'lodash/debounce'; +import { isFunction , get , debounce } from 'lodash-es'; import { getOffsetTopToContainer } from '../../_util/helper'; import useControlled from '../../hooks/useControlled'; import { useLocaleReceiver } from '../../locale/LocalReceiver'; diff --git a/src/select/hooks/useOptions.ts b/src/select/hooks/useOptions.ts index 60dc6443a0..d55902bca6 100644 --- a/src/select/hooks/useOptions.ts +++ b/src/select/hooks/useOptions.ts @@ -1,5 +1,5 @@ import React, { useState, useEffect, ReactNode, ReactElement } from 'react'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import { SelectKeysType, SelectOption, SelectValue } from '../type'; import { getValueToOption } from '../util/helper'; import Option from '../base/Option'; diff --git a/src/select/util/helper.ts b/src/select/util/helper.ts index 1a0f689738..42859ee49d 100644 --- a/src/select/util/helper.ts +++ b/src/select/util/helper.ts @@ -1,6 +1,5 @@ import { ReactElement } from 'react'; -import isPlainObject from 'lodash/isPlainObject'; -import get from 'lodash/get'; +import { isPlainObject , get } from 'lodash-es'; import OptionGroup from '../base/OptionGroup'; import Option from '../base/Option'; diff --git a/src/skeleton/Skeleton.tsx b/src/skeleton/Skeleton.tsx index 815204c0e0..a959935dff 100644 --- a/src/skeleton/Skeleton.tsx +++ b/src/skeleton/Skeleton.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import isNumber from 'lodash/isNumber'; +import { isNumber } from 'lodash-es'; import classNames from 'classnames'; import { SkeletonRowCol, SkeletonRowColObj, TdSkeletonProps } from './type'; diff --git a/src/slider/Slider.tsx b/src/slider/Slider.tsx index bfabe398d9..1897f28a9f 100644 --- a/src/slider/Slider.tsx +++ b/src/slider/Slider.tsx @@ -1,7 +1,6 @@ import React, { useMemo, useRef } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; -import isString from 'lodash/isString'; +import { isFunction , isString } from 'lodash-es'; import { TdSliderProps } from './type'; import useConfig from '../hooks/useConfig'; import useControlled from '../hooks/useControlled'; diff --git a/src/statistic/Statistic.tsx b/src/statistic/Statistic.tsx index f78a22cdd0..529fcf5db7 100644 --- a/src/statistic/Statistic.tsx +++ b/src/statistic/Statistic.tsx @@ -1,7 +1,6 @@ import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'; import classNames from 'classnames'; -import isNumber from 'lodash/isNumber'; -import isFunction from 'lodash/isFunction'; +import { isNumber , isFunction } from 'lodash-es'; import { ArrowTriangleDownFilledIcon as TDArrowTriangleDownFilledIcon, ArrowTriangleUpFilledIcon as TDArrowTriangleUpFilledIcon, diff --git a/src/table/BaseTable.tsx b/src/table/BaseTable.tsx index 712749f988..2d1d8bc197 100644 --- a/src/table/BaseTable.tsx +++ b/src/table/BaseTable.tsx @@ -8,7 +8,7 @@ import React, { WheelEvent, RefAttributes, } from 'react'; -import pick from 'lodash/pick'; +import { pick } from 'lodash-es'; import classNames from 'classnames'; import TBody, { extendTableProps, TableBodyProps } from './TBody'; import { Affix, AffixRef } from '../affix'; diff --git a/src/table/Cell.tsx b/src/table/Cell.tsx index 34fce64796..7bef7e35a0 100644 --- a/src/table/Cell.tsx +++ b/src/table/Cell.tsx @@ -1,7 +1,6 @@ import React, { MouseEvent, MutableRefObject, ReactNode } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; -import get from 'lodash/get'; +import { isFunction , get } from 'lodash-es'; import TEllipsis from './Ellipsis'; import { BaseTableCellParams, RowspanColspan, TableRowData, TdBaseTableProps } from './type'; import { RowAndColFixedPosition } from './interface'; diff --git a/src/table/EditableCell.tsx b/src/table/EditableCell.tsx index 831a81da09..6e8cf081f4 100644 --- a/src/table/EditableCell.tsx +++ b/src/table/EditableCell.tsx @@ -1,8 +1,5 @@ import React, { useEffect, useMemo, useRef, useState, MouseEvent } from 'react'; -import get from 'lodash/get'; -import set from 'lodash/set'; -import isFunction from 'lodash/isFunction'; -import cloneDeep from 'lodash/cloneDeep'; +import { get , set , isFunction , cloneDeep } from 'lodash-es'; import { Edit1Icon as TdEdit1Icon } from 'tdesign-icons-react'; import classNames from 'classnames'; import { diff --git a/src/table/EnhancedTable.tsx b/src/table/EnhancedTable.tsx index 0c2316ea8b..a4f714e136 100644 --- a/src/table/EnhancedTable.tsx +++ b/src/table/EnhancedTable.tsx @@ -1,5 +1,5 @@ import React, { RefAttributes, forwardRef, useImperativeHandle, useRef } from 'react'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import PrimaryTable from './PrimaryTable'; import { PrimaryTableCol, TableRowData, DragSortContext, TdPrimaryTableProps } from './type'; import useTreeData from './hooks/useTreeData'; diff --git a/src/table/FilterController.tsx b/src/table/FilterController.tsx index a44f20ffd2..742459c8c2 100644 --- a/src/table/FilterController.tsx +++ b/src/table/FilterController.tsx @@ -1,6 +1,6 @@ import React, { useState, useRef } from 'react'; import { FilterIcon as TdFilterIcon } from 'tdesign-icons-react'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import classNames from 'classnames'; import Popup, { PopupProps } from '../popup'; import Checkbox from '../checkbox'; diff --git a/src/table/PrimaryTable.tsx b/src/table/PrimaryTable.tsx index 259faa4b38..93030733b0 100644 --- a/src/table/PrimaryTable.tsx +++ b/src/table/PrimaryTable.tsx @@ -1,5 +1,5 @@ import React, { useRef, forwardRef, useImperativeHandle, ReactNode, RefAttributes } from 'react'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import classNames from 'classnames'; import BaseTable from './BaseTable'; import useColumnController from './hooks/useColumnController'; diff --git a/src/table/TBody.tsx b/src/table/TBody.tsx index 2dac7828a7..c82d29b3a6 100644 --- a/src/table/TBody.tsx +++ b/src/table/TBody.tsx @@ -1,7 +1,5 @@ import React, { CSSProperties, MutableRefObject, ReactNode, useMemo } from 'react'; -import camelCase from 'lodash/camelCase'; -import get from 'lodash/get'; -import pick from 'lodash/pick'; +import { camelCase , get , pick } from 'lodash-es'; import classNames from 'classnames'; import TR, { ROW_LISTENERS, TABLE_PROPS } from './TR'; import { useLocaleReceiver } from '../locale/LocalReceiver'; diff --git a/src/table/TFoot.tsx b/src/table/TFoot.tsx index 5356397ea0..5852657be6 100644 --- a/src/table/TFoot.tsx +++ b/src/table/TFoot.tsx @@ -1,7 +1,6 @@ import React, { CSSProperties, useRef } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction , get } from 'lodash-es'; import classNames from 'classnames'; -import get from 'lodash/get'; import { BaseTableCellParams, RowspanColspan, TableRowData, TdBaseTableProps } from './type'; import { formatRowAttributes, formatRowClassNames } from './utils'; import { RowAndColFixedPosition } from './interface'; diff --git a/src/table/THead.tsx b/src/table/THead.tsx index dae5c9bd2b..485ceef961 100644 --- a/src/table/THead.tsx +++ b/src/table/THead.tsx @@ -1,5 +1,5 @@ import React, { useRef, MutableRefObject, CSSProperties, useMemo } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import classNames from 'classnames'; import { getColumnFixedStyles } from './hooks/useFixed'; import { RowAndColFixedPosition } from './interface'; diff --git a/src/table/TR.tsx b/src/table/TR.tsx index cf4ae5dbe3..cd165b005a 100644 --- a/src/table/TR.tsx +++ b/src/table/TR.tsx @@ -1,5 +1,5 @@ import React, { useMemo, useRef, MouseEvent, useEffect, MutableRefObject } from 'react'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import classnames from 'classnames'; import { formatRowAttributes, formatRowClassNames } from './utils'; import { getRowFixedStyles } from './hooks/useFixed'; diff --git a/src/table/_example/filter-controlled.tsx b/src/table/_example/filter-controlled.tsx index e38b886fa8..a877f9fca3 100644 --- a/src/table/_example/filter-controlled.tsx +++ b/src/table/_example/filter-controlled.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import isNumber from 'lodash/isNumber'; +import { isNumber } from 'lodash-es'; import { Table, Button, DateRangePickerPanel, Space, Tag } from 'tdesign-react'; import { ErrorCircleFilledIcon, CheckCircleFilledIcon, CloseCircleFilledIcon } from 'tdesign-icons-react'; diff --git a/src/table/_example/tree-select.tsx b/src/table/_example/tree-select.tsx index 7b0d26fd3e..5b205bfc4e 100644 --- a/src/table/_example/tree-select.tsx +++ b/src/table/_example/tree-select.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useRef } from 'react'; import { EnhancedTable, Radio, Space, Button, MessagePlugin, Tag } from 'tdesign-react'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import { ErrorCircleFilledIcon, CheckCircleFilledIcon, CloseCircleFilledIcon } from 'tdesign-icons-react'; import type { EnhancedTableProps, TableProps } from 'tdesign-react'; diff --git a/src/table/hooks/tree-store.ts b/src/table/hooks/tree-store.ts index e176ba2149..c6e3048bc9 100644 --- a/src/table/hooks/tree-store.ts +++ b/src/table/hooks/tree-store.ts @@ -1,6 +1,6 @@ /* eslint-disable class-methods-use-this */ /* eslint-disable no-param-reassign */ -import get from 'lodash/get'; +import { get } from 'lodash-es'; import { isRowSelectedDisabled } from '../../_common/js/table/utils'; import { PrimaryTableCol, TableRowState, TableRowValue, TableRowData } from '../type'; import log from '../../_common/js/log'; diff --git a/src/table/hooks/useAsyncLoading.tsx b/src/table/hooks/useAsyncLoading.tsx index 993e6ff574..d356875cd2 100644 --- a/src/table/hooks/useAsyncLoading.tsx +++ b/src/table/hooks/useAsyncLoading.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import isString from 'lodash/isString'; +import { isString } from 'lodash-es'; import classNames from 'classnames'; import { TdPrimaryTableProps } from '../type'; import Loading from '../../loading'; diff --git a/src/table/hooks/useColumnController.tsx b/src/table/hooks/useColumnController.tsx index 01f0acf10f..6da7810929 100644 --- a/src/table/hooks/useColumnController.tsx +++ b/src/table/hooks/useColumnController.tsx @@ -3,8 +3,7 @@ */ import React, { useEffect, ChangeEvent, useRef } from 'react'; import { SettingIcon as TdSettingIcon } from 'tdesign-icons-react'; -import intersection from 'lodash/intersection'; -import xorWith from 'lodash/xorWith'; +import { intersection , xorWith } from 'lodash-es'; import classNames from 'classnames'; import Checkbox, { CheckboxGroupValue, CheckboxOptionObj, CheckboxGroupChangeContext } from '../../checkbox'; import { DialogPlugin } from '../../dialog/plugin'; diff --git a/src/table/hooks/useColumnResize.tsx b/src/table/hooks/useColumnResize.tsx index 25d4e00d21..eea87bc2f5 100644 --- a/src/table/hooks/useColumnResize.tsx +++ b/src/table/hooks/useColumnResize.tsx @@ -6,7 +6,7 @@ * - 当表格内容超出,出现横向滚动条时,会自动调整当前列宽和表格总列宽,不影响相邻列宽 */ import React, { useState, useRef, MutableRefObject, CSSProperties, useEffect } from 'react'; -import isNumber from 'lodash/isNumber'; +import { isNumber } from 'lodash-es'; import { BaseTableCol, TableRowData, TdBaseTableProps } from '../type'; import { on, off } from '../../_util/dom'; diff --git a/src/table/hooks/useDragSort.ts b/src/table/hooks/useDragSort.ts index 908030919f..84e1dbaef0 100644 --- a/src/table/hooks/useDragSort.ts +++ b/src/table/hooks/useDragSort.ts @@ -1,7 +1,7 @@ // 表格 行拖拽 + 列拖拽功能 import { MutableRefObject, useEffect, useMemo, useRef, useState } from 'react'; import Sortable, { SortableEvent, SortableOptions, MoveEvent } from 'sortablejs'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import { PaginationProps } from '../../pagination'; import { TableRowData, TdPrimaryTableProps, DragSortContext } from '../type'; import useClassName from './useClassName'; diff --git a/src/table/hooks/useEditableRow.ts b/src/table/hooks/useEditableRow.ts index 01687c4214..7a8814d1da 100644 --- a/src/table/hooks/useEditableRow.ts +++ b/src/table/hooks/useEditableRow.ts @@ -1,6 +1,5 @@ import { useState, useMemo } from 'react'; -import get from 'lodash/get'; -import isFunction from 'lodash/isFunction'; +import { get , isFunction } from 'lodash-es'; import { PrimaryTableProps } from '../interface'; import { validate } from '../../form/formModel'; import { AllValidateResult } from '../../form'; diff --git a/src/table/hooks/useFilter.tsx b/src/table/hooks/useFilter.tsx index 619a885ff8..da7763a687 100644 --- a/src/table/hooks/useFilter.tsx +++ b/src/table/hooks/useFilter.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState, MutableRefObject } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import useClassName from './useClassName'; import TButton from '../../button'; import { TdPrimaryTableProps, PrimaryTableCol, TableRowData, FilterValue, TableFilterChangeContext } from '../type'; diff --git a/src/table/hooks/useFixed.ts b/src/table/hooks/useFixed.ts index af57a45ebd..f1441305b5 100644 --- a/src/table/hooks/useFixed.ts +++ b/src/table/hooks/useFixed.ts @@ -1,7 +1,5 @@ import { useEffect, useState, useMemo, useRef, WheelEvent } from 'react'; -import get from 'lodash/get'; -import pick from 'lodash/pick'; -import xorWith from 'lodash/xorWith'; +import { get , pick , xorWith } from 'lodash-es'; import { getIEVersion } from '../../_common/js/utils/helper'; import log from '../../_common/js/log'; import { ClassName, Styles } from '../../common'; diff --git a/src/table/hooks/useRowExpand.tsx b/src/table/hooks/useRowExpand.tsx index 2aa8b61fb9..cf7878a8d9 100644 --- a/src/table/hooks/useRowExpand.tsx +++ b/src/table/hooks/useRowExpand.tsx @@ -1,7 +1,6 @@ import React, { MouseEvent, ReactNode, useCallback } from 'react'; import { ChevronRightCircleIcon as TdChevronRightCircleIcon } from 'tdesign-icons-react'; -import get from 'lodash/get'; -import isFunction from 'lodash/isFunction'; +import { get , isFunction } from 'lodash-es'; import classNames from 'classnames'; import { TdPrimaryTableProps, diff --git a/src/table/hooks/useRowSelect.tsx b/src/table/hooks/useRowSelect.tsx index 94db1f483f..d6e3596821 100644 --- a/src/table/hooks/useRowSelect.tsx +++ b/src/table/hooks/useRowSelect.tsx @@ -1,9 +1,7 @@ // 行选中相关功能:单选 + 多选 import React, { useEffect, useState, MouseEvent, useMemo } from 'react'; -import intersection from 'lodash/intersection'; -import get from 'lodash/get'; -import isFunction from 'lodash/isFunction'; +import { intersection , get , isFunction } from 'lodash-es'; import useControlled from '../../hooks/useControlled'; import { PrimaryTableCellParams, diff --git a/src/table/hooks/useRowspanAndColspan.ts b/src/table/hooks/useRowspanAndColspan.ts index 44b52b2083..3698cdcc6a 100644 --- a/src/table/hooks/useRowspanAndColspan.ts +++ b/src/table/hooks/useRowspanAndColspan.ts @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import log from '../../_common/js/log'; import { BaseTableCellParams, BaseTableCol, TableRowData, TableRowspanAndColspanFunc } from '../type'; diff --git a/src/table/hooks/useSorter.tsx b/src/table/hooks/useSorter.tsx index 814642cae5..c63c820742 100644 --- a/src/table/hooks/useSorter.tsx +++ b/src/table/hooks/useSorter.tsx @@ -1,5 +1,5 @@ import React, { useState, MouseEvent, useEffect } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { SortInfo, TdPrimaryTableProps, PrimaryTableCol, TableRowData } from '../type'; import SorterButton from '../SorterButton'; import useControlled from '../../hooks/useControlled'; diff --git a/src/table/hooks/useTableHeader.tsx b/src/table/hooks/useTableHeader.tsx index f547560ffd..f5df4190b6 100644 --- a/src/table/hooks/useTableHeader.tsx +++ b/src/table/hooks/useTableHeader.tsx @@ -1,5 +1,5 @@ import React, { ReactNode, useMemo } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import classNames from 'classnames'; import { BaseTableCol, PrimaryTableCol, TableRowData, TdBaseTableProps } from '../type'; import { TableColumns, getThRowspanAndColspan, getThList } from './useMultiHeader'; diff --git a/src/table/hooks/useTreeData.tsx b/src/table/hooks/useTreeData.tsx index c4961c8b54..a34791c90a 100644 --- a/src/table/hooks/useTreeData.tsx +++ b/src/table/hooks/useTreeData.tsx @@ -3,7 +3,7 @@ import { AddRectangleIcon as TdAddRectangleIcon, MinusRectangleIcon as TdMinusRectangleIcon, } from 'tdesign-icons-react'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import classNames from 'classnames'; import TableTreeStore, { SwapParams } from '../../_common/js/table/tree-store'; import { TdEnhancedTableProps, PrimaryTableCol, TableRowData, TableRowValue, TableRowState } from '../type'; diff --git a/src/table/hooks/useTreeSelect.tsx b/src/table/hooks/useTreeSelect.tsx index d7d273757b..98fbfec8a7 100644 --- a/src/table/hooks/useTreeSelect.tsx +++ b/src/table/hooks/useTreeSelect.tsx @@ -1,6 +1,5 @@ import { useMemo, useState, useEffect } from 'react'; -import get from 'lodash/get'; -import intersection from 'lodash/intersection'; +import { get , intersection } from 'lodash-es'; import { TdEnhancedTableProps, TdPrimaryTableProps, TableRowData, PrimaryTableCol } from '../type'; import { KeysType, TableTreeDataMap, TreeDataMapType } from '../../_common/js/table/tree-store'; import useControlled from '../../hooks/useControlled'; diff --git a/src/table/utils.ts b/src/table/utils.ts index 32fb09024d..0e7ffe3a41 100644 --- a/src/table/utils.ts +++ b/src/table/utils.ts @@ -1,6 +1,4 @@ -import isFunction from 'lodash/isFunction'; -import get from 'lodash/get'; -import isObject from 'lodash/isObject'; +import { isFunction , get , isObject } from 'lodash-es'; import { BaseTableCellParams, CellData, diff --git a/src/tabs/TabNav.tsx b/src/tabs/TabNav.tsx index 45e0c5a8a6..d9f19c9d2c 100644 --- a/src/tabs/TabNav.tsx +++ b/src/tabs/TabNav.tsx @@ -5,8 +5,7 @@ import { ChevronLeftIcon as TdChevronLeftIcon, ChevronRightIcon as TdChevronRightIcon, } from 'tdesign-icons-react'; -import omit from 'lodash/omit'; -import debounce from 'lodash/debounce'; +import { omit , debounce } from 'lodash-es'; import { TdTabsProps, TdTabPanelProps, TabValue } from './type'; import noop from '../_util/noop'; import { useTabClass } from './useTabClass'; diff --git a/src/tag-input/TagInput.tsx b/src/tag-input/TagInput.tsx index 2dd097b912..6760d66bdb 100644 --- a/src/tag-input/TagInput.tsx +++ b/src/tag-input/TagInput.tsx @@ -1,6 +1,6 @@ import React, { CompositionEvent, KeyboardEvent, useRef, useImperativeHandle, forwardRef, MouseEvent } from 'react'; import { CloseCircleFilledIcon as TdCloseCircleFilledIcon } from 'tdesign-icons-react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import classnames from 'classnames'; import useConfig from '../hooks/useConfig'; import useGlobalIcon from '../hooks/useGlobalIcon'; diff --git a/src/tag-input/useTagList.tsx b/src/tag-input/useTagList.tsx index 354efd5f3d..0f239406bf 100644 --- a/src/tag-input/useTagList.tsx +++ b/src/tag-input/useTagList.tsx @@ -1,5 +1,5 @@ import React, { useState, MouseEvent, KeyboardEvent, ReactNode, Fragment } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { TagInputChangeContext, TagInputValue, TdTagInputProps } from './type'; import { InputValue } from '../input'; import Tag from '../tag'; diff --git a/src/tag-input/useTagScroll.ts b/src/tag-input/useTagScroll.ts index 298e31a9f6..7e91a0c9e7 100644 --- a/src/tag-input/useTagScroll.ts +++ b/src/tag-input/useTagScroll.ts @@ -3,7 +3,7 @@ * 如果标签过多时的处理方式,是标签省略,则不需要此功能 */ -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { useRef, useEffect, RefObject, useState, WheelEvent } from 'react'; import { TdTagInputProps } from './type'; diff --git a/src/time-picker/TimeRangePicker.tsx b/src/time-picker/TimeRangePicker.tsx index 94298678f9..4a1e476d6e 100644 --- a/src/time-picker/TimeRangePicker.tsx +++ b/src/time-picker/TimeRangePicker.tsx @@ -3,7 +3,7 @@ import classNames from 'classnames'; import dayjs from 'dayjs'; import { TimeIcon as TdTimeIcon } from 'tdesign-icons-react'; -import isArray from 'lodash/isArray'; +import { isArray } from 'lodash-es'; import noop from '../_util/noop'; import useControlled from '../hooks/useControlled'; import useConfig from '../hooks/useConfig'; diff --git a/src/time-picker/panel/SinglePanel.tsx b/src/time-picker/panel/SinglePanel.tsx index c1d965a037..89206fefd0 100644 --- a/src/time-picker/panel/SinglePanel.tsx +++ b/src/time-picker/panel/SinglePanel.tsx @@ -12,8 +12,7 @@ import React, { import classNames from 'classnames'; import dayjs from 'dayjs'; import customParseFormat from 'dayjs/plugin/customParseFormat'; -import padStart from 'lodash/padStart'; -import range from 'lodash/range'; +import { padStart , range } from 'lodash-es'; import useConfig from '../../hooks/useConfig'; import noop from '../../_util/noop'; diff --git a/src/timeline/TimelineItem.tsx b/src/timeline/TimelineItem.tsx index 38127876b4..b243bb1d80 100644 --- a/src/timeline/TimelineItem.tsx +++ b/src/timeline/TimelineItem.tsx @@ -1,6 +1,6 @@ import React, { useContext, useMemo } from 'react'; import classNames from 'classnames'; -import omit from 'lodash/omit'; +import { omit } from 'lodash-es'; import { TdTimelineItemProps } from './type'; import { StyledProps } from '../common'; import useConfig from '../hooks/useConfig'; diff --git a/src/tooltip/TooltipLite.tsx b/src/tooltip/TooltipLite.tsx index 0aafc13f36..4dd1bd04cf 100644 --- a/src/tooltip/TooltipLite.tsx +++ b/src/tooltip/TooltipLite.tsx @@ -1,7 +1,7 @@ import React, { ReactNode, useState, useRef, useEffect, useCallback } from 'react'; import classnames from 'classnames'; import { CSSTransition } from 'react-transition-group'; -import throttle from 'lodash/throttle'; +import { throttle } from 'lodash-es'; import { StyledProps } from '../common'; import useSwitch from '../hooks/useSwitch'; import useAnimation from '../hooks/useAnimation'; diff --git a/src/transfer/Transfer.tsx b/src/transfer/Transfer.tsx index 4dbf8bd0c3..e3e260ce4a 100644 --- a/src/transfer/Transfer.tsx +++ b/src/transfer/Transfer.tsx @@ -1,7 +1,6 @@ import React, { useState, useMemo, useEffect } from 'react'; -import difference from 'lodash/difference'; +import { difference , isArray } from 'lodash-es'; import classnames from 'classnames'; -import isArray from 'lodash/isArray'; import { ChevronRightIcon as TdChevronRightIcon, ChevronLeftIcon as TdChevronLeftIcon } from 'tdesign-icons-react'; import { TdTransferProps, DataOption, TransferValue, TransferListType } from './type'; import useConfig from '../hooks/useConfig'; diff --git a/src/transfer/TransferList.tsx b/src/transfer/TransferList.tsx index 7f8bb5bbbc..2b2258f992 100644 --- a/src/transfer/TransferList.tsx +++ b/src/transfer/TransferList.tsx @@ -1,8 +1,6 @@ import React, { useMemo, useState } from 'react'; import classnames from 'classnames'; -import isFunction from 'lodash/isFunction'; -import isEmpty from 'lodash/isEmpty'; -import isString from 'lodash/isString'; +import { isFunction , isEmpty , isString } from 'lodash-es'; import { SearchIcon as TdSearchIcon } from 'tdesign-icons-react'; import { getLeafNodes } from './utils'; import useConfig from '../hooks/useConfig'; diff --git a/src/transfer/utils.ts b/src/transfer/utils.ts index b3926a967b..50b694d6f2 100644 --- a/src/transfer/utils.ts +++ b/src/transfer/utils.ts @@ -1,6 +1,4 @@ -import isEmpty from 'lodash/isEmpty'; -import isFunction from 'lodash/isFunction'; -import isString from 'lodash/isString'; +import { isEmpty , isFunction , isString } from 'lodash-es'; import React from 'react'; import { DataOption, TransferValue } from './type'; import { TNode } from '../common'; diff --git a/src/tree-select/TreeSelect.tsx b/src/tree-select/TreeSelect.tsx index f9c66e3ad2..d0ac9d8b3b 100644 --- a/src/tree-select/TreeSelect.tsx +++ b/src/tree-select/TreeSelect.tsx @@ -1,5 +1,5 @@ import React, { useCallback, useMemo, useRef, forwardRef, ElementRef, useImperativeHandle } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import classNames from 'classnames'; import type { TdTreeSelectProps, TreeSelectValue } from './type'; import type { StyledProps, TreeOptionData } from '../common'; diff --git a/src/tree-select/hooks/useTreeSelectPassthroughProps.ts b/src/tree-select/hooks/useTreeSelectPassthroughProps.ts index 6cc9b8ea29..16665c44d5 100644 --- a/src/tree-select/hooks/useTreeSelectPassthroughProps.ts +++ b/src/tree-select/hooks/useTreeSelectPassthroughProps.ts @@ -1,4 +1,4 @@ -import pick from 'lodash/pick'; +import { pick } from 'lodash-es'; import classNames from 'classnames'; import useConfig from '../../hooks/useConfig'; import type { TreeSelectProps } from '../TreeSelect'; diff --git a/src/tree/Tree.tsx b/src/tree/Tree.tsx index 83c019a1c3..1453cfeb87 100644 --- a/src/tree/Tree.tsx +++ b/src/tree/Tree.tsx @@ -10,7 +10,7 @@ import React, { } from 'react'; import { CSSTransition, TransitionGroup } from 'react-transition-group'; import classNames from 'classnames'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import TreeNode from '../_common/js/tree-v1/tree-node'; import { TreeOptionData, StyledProps, ComponentScrollToElementParams } from '../common'; diff --git a/src/tree/TreeItem.tsx b/src/tree/TreeItem.tsx index 3871ddc3a7..e681a0190a 100644 --- a/src/tree/TreeItem.tsx +++ b/src/tree/TreeItem.tsx @@ -11,7 +11,7 @@ import React, { useState, } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { CaretRightSmallIcon as TdCaretRightSmallIcon } from 'tdesign-icons-react'; import Loading from '../loading'; import useRipple from '../hooks/useRipple'; diff --git a/src/tree/_example/state.tsx b/src/tree/_example/state.tsx index 58928d7f4d..3c82fc1b03 100644 --- a/src/tree/_example/state.tsx +++ b/src/tree/_example/state.tsx @@ -1,7 +1,7 @@ import React, { useRef, useState } from 'react'; import { Button, Tree, Space, TreeInstanceFunctions, TreeNodeModel } from 'tdesign-react'; import { Icon } from 'tdesign-icons-react'; -import cloneDeepWith from 'lodash/cloneDeepWith'; +import { cloneDeepWith } from 'lodash-es'; import { TreeOptionData } from '../../common'; let idx = 2; diff --git a/src/tree/hooks/useDraggable.tsx b/src/tree/hooks/useDraggable.tsx index 6c69179dbd..47a7a0da46 100644 --- a/src/tree/hooks/useDraggable.tsx +++ b/src/tree/hooks/useDraggable.tsx @@ -1,4 +1,4 @@ -import throttle from 'lodash/throttle'; +import { throttle } from 'lodash-es'; import { RefObject, DragEvent, useState, useRef } from 'react'; import { TreeNode } from '../../_common/js/tree-v1/tree-node'; import { useTreeDraggableContext } from './TreeDraggableContext'; diff --git a/src/tree/hooks/useStore.ts b/src/tree/hooks/useStore.ts index 0e6826a127..f014ff68e7 100644 --- a/src/tree/hooks/useStore.ts +++ b/src/tree/hooks/useStore.ts @@ -1,5 +1,5 @@ import { useEffect, useRef, useState } from 'react'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import useUpdateLayoutEffect from '../../hooks/useUpdateLayoutEffect'; import usePrevious from '../../hooks/usePrevious'; import TreeStore from '../../_common/js/tree-v1/tree-store'; diff --git a/src/typography/ellipsis/Truncate.tsx b/src/typography/ellipsis/Truncate.tsx index 1c93406bf6..ab8718e3b1 100644 --- a/src/typography/ellipsis/Truncate.tsx +++ b/src/typography/ellipsis/Truncate.tsx @@ -3,7 +3,7 @@ * https://github.com/pablosichert/react-truncate/blob/master/LICENSE.md * * ISC License - * + * Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. @@ -14,7 +14,7 @@ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ import React from 'react'; -import omit from 'lodash/omit'; +import { omit } from 'lodash-es'; import PropTypes from 'prop-types'; export type TruncateProps = { diff --git a/src/typography/ellipsis/useEllipsis.tsx b/src/typography/ellipsis/useEllipsis.tsx index 37188347e2..f23405a336 100644 --- a/src/typography/ellipsis/useEllipsis.tsx +++ b/src/typography/ellipsis/useEllipsis.tsx @@ -1,6 +1,6 @@ /* eslint-disable no-nested-ternary */ import React, { useState } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { TypographyEllipsis } from '../type'; import Tooltip from '../../tooltip'; diff --git a/src/upload/hooks/useUpload.ts b/src/upload/hooks/useUpload.ts index 72dc032a0a..2166b81e71 100644 --- a/src/upload/hooks/useUpload.ts +++ b/src/upload/hooks/useUpload.ts @@ -1,5 +1,5 @@ import { useRef, useState, useMemo, ChangeEventHandler, MouseEvent, useEffect, ClipboardEventHandler } from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { SizeLimitObj, TdUploadProps, UploadChangeContext, UploadFile, UploadRemoveContext } from '../type'; import { getFilesAndErrors, diff --git a/src/upload/themes/MultipleFlowList.tsx b/src/upload/themes/MultipleFlowList.tsx index f3531b5366..45cf798448 100644 --- a/src/upload/themes/MultipleFlowList.tsx +++ b/src/upload/themes/MultipleFlowList.tsx @@ -1,7 +1,6 @@ import React, { MouseEvent, useMemo, useState } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; -import isObject from 'lodash/isObject'; +import { isFunction , isObject } from 'lodash-es'; import { BrowseIcon as TdBrowseIcon, DeleteIcon as TdDeleteIcon,