diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 66c8a27..90f3e55 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -82,5 +82,16 @@ module.exports = { 'no-param-reassign': ['error', { props: true, ignorePropertyModificationsForRegex: ['^html'] }], 'no-underscore-dangle': ['error', { allow: ['__filename', '__dirname', '__TDESIGN_THEME_PREFIX__'] }], 'import/no-duplicates': 'off', + 'no-restricted-imports': [ + 'error', + { + paths: [ + { + name: 'lodash', + message: 'Please use lodash-es instead.', + }, + ], + }, + ], }, }; diff --git a/package-lock.json b/package-lock.json index 92cb6af..15ccf05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "clsx": "^2.1.0", "copy-to-clipboard": "^3.3.3", "htm": "^3.1.1", - "lodash": "~4.17.15", + "lodash-es": "^4.17.21", "omi": "^7.7.5", "omi-transition": "^0.1.11", "tailwind-merge": "^2.2.1", @@ -35,7 +35,7 @@ "@rollup/plugin-replace": "^5.0.7", "@rollup/plugin-url": "^8.0.2", "@tailwindcss/typography": "^0.5.10", - "@types/lodash": "^4.17.5", + "@types/lodash-es": "^4.17.12", "@types/markdown-it": "^13.0.7", "@types/prismjs": "^1.26.3", "@typescript-eslint/eslint-plugin": "^7.9.0", @@ -3274,10 +3274,21 @@ "dev": true }, "node_modules/@types/lodash": { - "version": "4.17.5", - "resolved": "https://mirrors.tencent.com/npm/@types/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha512-MBIOHVZqVqgfro1euRDWX7OO0fBVUUMrN6Pwm8LQsz8cWhEpihlvR70ENj3f40j58TNxZaWv2ndSkInykNBBJw==", - "dev": true + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-jsxagdikDiDBeIRaPYtArcT8my4tN1og7MtMRquFT3XNA6axxyHDRUemqDz/taRDdOUn0GnGHRCuff4q48sW9A==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/lodash-es": { + "version": "4.17.12", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz", + "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/lodash": "*" + } }, "node_modules/@types/markdown-it": { "version": "13.0.7", @@ -8382,7 +8393,14 @@ "node_modules/lodash": { "version": "4.17.21", "resolved": "https://mirrors.tencent.com/npm/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", + "license": "MIT" }, "node_modules/lodash.camelcase": { "version": "4.3.0", diff --git a/package.json b/package.json index 05142ce..2761a20 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "clsx": "^2.1.0", "copy-to-clipboard": "^3.3.3", "htm": "^3.1.1", - "lodash": "~4.17.15", + "lodash-es": "^4.17.21", "omi": "^7.7.5", "omi-transition": "^0.1.11", "tailwind-merge": "^2.2.1", @@ -87,7 +87,7 @@ "@rollup/plugin-replace": "^5.0.7", "@rollup/plugin-url": "^8.0.2", "@tailwindcss/typography": "^0.5.10", - "@types/lodash": "^4.17.5", + "@types/lodash-es": "^4.17.12", "@types/markdown-it": "^13.0.7", "@types/prismjs": "^1.26.3", "@typescript-eslint/eslint-plugin": "^7.9.0", diff --git a/src/_common b/src/_common index 7033aea..e23ad04 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 7033aea8c26f5619c2e8ed44325a94752920a2bb +Subproject commit e23ad04213d64f3b7161cc4cc758f8ca03d06ae9 diff --git a/src/_util/dom.ts b/src/_util/dom.ts index eaca149..049a6c7 100644 --- a/src/_util/dom.ts +++ b/src/_util/dom.ts @@ -1,4 +1,4 @@ -import isString from 'lodash/isString'; +import { isString } from 'lodash-es'; import raf from 'raf'; import { ScrollContainer, ScrollContainerElement } from '../common'; diff --git a/src/_util/helper.ts b/src/_util/helper.ts index 0f462d9..e55d53a 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 0179c1d..a0714c6 100644 --- a/src/_util/parseTNode.ts +++ b/src/_util/parseTNode.ts @@ -1,4 +1,4 @@ -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { cloneElement, VNode } from 'omi'; import log from '../_common/js/log'; diff --git a/src/_util/useControlled.ts b/src/_util/useControlled.ts index e866a9b..c57d40f 100644 --- a/src/_util/useControlled.ts +++ b/src/_util/useControlled.ts @@ -1,4 +1,4 @@ -import upperFirst from 'lodash/upperFirst'; +import { upperFirst } from 'lodash-es'; import { Component, setActiveComponent, signal, SignalValue } from 'omi'; export interface ChangeHandler { diff --git a/src/affix/affix.tsx b/src/affix/affix.tsx index 5afc575..87a0338 100644 --- a/src/affix/affix.tsx +++ b/src/affix/affix.tsx @@ -1,4 +1,4 @@ -import { isFunction } from 'lodash'; +import { isFunction } from 'lodash-es'; import { Component, createRef, tag } from 'omi'; import { getClassPrefix } from '../_util/classname'; diff --git a/src/alert/alert.tsx b/src/alert/alert.tsx index 5de3e9d..1f7062e 100644 --- a/src/alert/alert.tsx +++ b/src/alert/alert.tsx @@ -3,7 +3,7 @@ import 'tdesign-icons-web-components/esm/components/info-circle-filled'; import 'tdesign-icons-web-components/esm/components/error-circle-filled'; import 'tdesign-icons-web-components/esm/components/close'; -import { isObject } from 'lodash'; +import { isObject } from 'lodash-es'; import { Component, createRef, signal, SignalValue, tag } from 'omi'; import classname, { getClassPrefix } from '../_util/classname'; diff --git a/src/avatar/avatar-group.tsx b/src/avatar/avatar-group.tsx index 2b87ca2..b7a0ef3 100644 --- a/src/avatar/avatar-group.tsx +++ b/src/avatar/avatar-group.tsx @@ -1,6 +1,6 @@ import './avatar'; -import { toArray } from 'lodash'; +import { toArray } from 'lodash-es'; import { classNames, cloneElement, Component, OmiProps, tag } from 'omi'; import { getClassPrefix } from '../_util/classname'; diff --git a/src/checkbox/checkbox-group.tsx b/src/checkbox/checkbox-group.tsx index cc05210..fabaf89 100644 --- a/src/checkbox/checkbox-group.tsx +++ b/src/checkbox/checkbox-group.tsx @@ -1,4 +1,4 @@ -import { intersection, isObject, isString, isUndefined, toArray } from 'lodash'; +import { intersection, isObject, isString, isUndefined, toArray } from 'lodash-es'; import { bind, Component, signal, tag, VNode } from 'omi'; import classname, { getClassPrefix } from '../_util/classname'; diff --git a/src/common/check/index.tsx b/src/common/check/index.tsx index f40c964..9a65bc8 100644 --- a/src/common/check/index.tsx +++ b/src/common/check/index.tsx @@ -1,4 +1,4 @@ -import { isBoolean, omit } from 'lodash'; +import { isBoolean, omit } from 'lodash-es'; import { classNames, Component, tag } from 'omi'; import { getClassPrefix } from '../../_util/classname'; diff --git a/src/dialog/dialog.tsx b/src/dialog/dialog.tsx index 2112f56..6b67d4c 100644 --- a/src/dialog/dialog.tsx +++ b/src/dialog/dialog.tsx @@ -5,7 +5,7 @@ import 'tdesign-icons-web-components/esm/components/error-circle'; import 'omi-transition'; import '../common/portal'; -import { isNumber, isObject, isString } from 'lodash'; +import { isNumber, isObject, isString } from 'lodash-es'; import { bind, Component, createRef, OmiProps, signal, tag } from 'omi'; import classname, { classPrefix } from '../_util/classname'; diff --git a/src/dropdown/dropdown.tsx b/src/dropdown/dropdown.tsx index f181c1b..61630ef 100644 --- a/src/dropdown/dropdown.tsx +++ b/src/dropdown/dropdown.tsx @@ -2,8 +2,7 @@ import './dropdownItem'; import './dropdownMenu'; import '../popup'; -import { isFunction } from 'lodash'; -import omit from 'lodash/omit'; +import { isFunction, omit } from 'lodash-es'; import { Component, css, tag } from 'omi'; import classNames, { getClassPrefix } from '../_util/classname'; diff --git a/src/dropdown/dropdownMenu.tsx b/src/dropdown/dropdownMenu.tsx index f2d5ebf..a12d014 100644 --- a/src/dropdown/dropdownMenu.tsx +++ b/src/dropdown/dropdownMenu.tsx @@ -2,7 +2,7 @@ import 'tdesign-icons-web-components/esm/components/chevron-right'; import './dropdownItem'; import '../divider'; -import throttle from 'lodash/throttle'; +import { throttle } from 'lodash-es'; import { Component, createRef, tag } from 'omi'; import classNames, { getClassPrefix } from '../_util/classname'; diff --git a/src/dropdown/getDropdownOptions.ts b/src/dropdown/getDropdownOptions.ts index 0d2575f..27c665a 100644 --- a/src/dropdown/getDropdownOptions.ts +++ b/src/dropdown/getDropdownOptions.ts @@ -1,7 +1,7 @@ import './dropdownItem'; import './dropdownMenu'; -import { toArray } from 'lodash'; +import { toArray } from 'lodash-es'; import { TElement, TNode } from '../common'; import { DropdownOption } from './type'; diff --git a/src/grid/col.tsx b/src/grid/col.tsx index 1c8d86c..fd7f419 100644 --- a/src/grid/col.tsx +++ b/src/grid/col.tsx @@ -1,4 +1,4 @@ -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import { Component, tag } from 'omi'; import classNames, { getClassPrefix } from '../_util/classname'; diff --git a/src/grid/row.tsx b/src/grid/row.tsx index 4191132..30528a6 100644 --- a/src/grid/row.tsx +++ b/src/grid/row.tsx @@ -1,4 +1,4 @@ -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import { cloneElement, Component, createElement, tag } from 'omi'; import classNames, { getClassPrefix } from '../_util/classname'; diff --git a/src/input-number/input-number.tsx b/src/input-number/input-number.tsx index e4ef91c..27e4c64 100644 --- a/src/input-number/input-number.tsx +++ b/src/input-number/input-number.tsx @@ -5,7 +5,7 @@ import 'tdesign-icons-web-components/esm/components/remove'; import '../button'; import '../input'; -import { isEqual, pick } from 'lodash'; +import { isEqual, pick } from 'lodash-es'; import { bind, Component, createRef, OmiProps, signal, tag } from 'omi'; import { diff --git a/src/notification/NotificationList.tsx b/src/notification/NotificationList.tsx index 1a8528f..309448c 100644 --- a/src/notification/NotificationList.tsx +++ b/src/notification/NotificationList.tsx @@ -1,6 +1,6 @@ import './Notification'; -import { noop } from 'lodash'; +import { noop } from 'lodash-es'; import { Component, createRef, OmiProps, render, tag } from 'omi'; import { getClassPrefix } from '../_util/classname'; diff --git a/src/popconfirm/popcontent.tsx b/src/popconfirm/popcontent.tsx index 9f1c4a5..7b9f575 100644 --- a/src/popconfirm/popcontent.tsx +++ b/src/popconfirm/popcontent.tsx @@ -1,6 +1,6 @@ import 'tdesign-icons-web-components/esm/components/info-circle-filled'; -import isString from 'lodash/isString'; +import { isString } from 'lodash-es'; import { cloneElement, Component, OmiProps, tag, VNode } from 'omi'; import classname, { getClassPrefix } from '../_util/classname'; diff --git a/src/popup/popup.tsx b/src/popup/popup.tsx index 6f2656c..fd9f86d 100644 --- a/src/popup/popup.tsx +++ b/src/popup/popup.tsx @@ -3,7 +3,7 @@ import './popupTrigger'; import '../common/portal'; import { createPopper, Instance } from '@popperjs/core'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; import { cloneElement, Component, createRef, OmiProps, tag, VNode } from 'omi'; import { getIEVersion } from '../_common/js/utils/helper'; diff --git a/src/popup/popupTrigger.tsx b/src/popup/popupTrigger.tsx index c711aa3..bd07c12 100644 --- a/src/popup/popupTrigger.tsx +++ b/src/popup/popupTrigger.tsx @@ -1,4 +1,4 @@ -import { toArray } from 'lodash'; +import { toArray } from 'lodash-es'; import { cloneElement, Component, tag, VNode } from 'omi'; import { TNode } from '../common'; diff --git a/src/radio/radioGroup.tsx b/src/radio/radioGroup.tsx index a31225f..92fccc8 100644 --- a/src/radio/radioGroup.tsx +++ b/src/radio/radioGroup.tsx @@ -1,6 +1,6 @@ import './radio'; -import { toArray } from 'lodash'; +import { toArray } from 'lodash-es'; import { classNames, cloneElement, Component, OmiProps, tag } from 'omi'; import { getClassPrefix, getCommonClassName } from '../_util/classname'; diff --git a/src/select-input/SelectInput.tsx b/src/select-input/SelectInput.tsx index f4b3835..e2051a0 100644 --- a/src/select-input/SelectInput.tsx +++ b/src/select-input/SelectInput.tsx @@ -4,7 +4,7 @@ import './SelectInputSingle'; import '../popup'; import classNames from 'classnames'; -import { pick } from 'lodash'; +import { pick } from 'lodash-es'; import { Component, createRef, OmiProps, tag } from 'omi'; import { getClassPrefix } from '../_util/classname'; diff --git a/src/select-input/SelectInputMultiple.tsx b/src/select-input/SelectInputMultiple.tsx index 06935d6..94233f7 100644 --- a/src/select-input/SelectInputMultiple.tsx +++ b/src/select-input/SelectInputMultiple.tsx @@ -1,7 +1,7 @@ import '../tag-input'; import classNames from 'classnames'; -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import { Component, createRef, tag } from 'omi'; import { getClassPrefix } from '../_util/classname'; diff --git a/src/select-input/SelectInputSingle.tsx b/src/select-input/SelectInputSingle.tsx index 7956af6..98b17c8 100644 --- a/src/select-input/SelectInputSingle.tsx +++ b/src/select-input/SelectInputSingle.tsx @@ -1,7 +1,7 @@ import '../input'; import classNames from 'classnames'; -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import { Component, createRef, tag } from 'omi'; import { getClassPrefix } from '../_util/classname'; diff --git a/src/select-input/useOverlayInnerStyle.ts b/src/select-input/useOverlayInnerStyle.ts index 37f486e..ddb70ae 100644 --- a/src/select-input/useOverlayInnerStyle.ts +++ b/src/select-input/useOverlayInnerStyle.ts @@ -1,5 +1,4 @@ -import isFunction from 'lodash/isFunction'; -import isObject from 'lodash/isObject'; +import { isFunction, isObject } from 'lodash-es'; import { Component } from 'omi'; import useControlled from '../_util/useControlled'; diff --git a/src/skeleton/skeleton.tsx b/src/skeleton/skeleton.tsx index cf0b9d2..dfe211b 100644 --- a/src/skeleton/skeleton.tsx +++ b/src/skeleton/skeleton.tsx @@ -1,4 +1,4 @@ -import isNumber from 'lodash/isNumber'; +import { isNumber } from 'lodash-es'; import { classNames, Component, createRef, tag } from 'omi'; import { pxCompat } from '../_common/js/utils/helper'; diff --git a/src/space/space.tsx b/src/space/space.tsx index 3c504f4..f1fecf0 100644 --- a/src/space/space.tsx +++ b/src/space/space.tsx @@ -1,4 +1,4 @@ -import { toArray } from 'lodash'; +import { toArray } from 'lodash-es'; import { classNames, Component, OmiProps, tag } from 'omi'; import { getClassPrefix } from '../_util/classname'; diff --git a/src/swiper/swiper.tsx b/src/swiper/swiper.tsx index f86fcf6..ae56d86 100644 --- a/src/swiper/swiper.tsx +++ b/src/swiper/swiper.tsx @@ -2,7 +2,7 @@ import 'tdesign-icons-web-components/esm/components/chevron-right'; import 'tdesign-icons-web-components/esm/components/chevron-left'; import './swiper-item'; -import { isEqual } from 'lodash'; +import { isEqual } from 'lodash-es'; import { bind, cloneElement, Component, createRef, signal, tag } from 'omi'; import classname, { classPrefix } from '../_util/classname'; diff --git a/src/tabs/TabNav.tsx b/src/tabs/TabNav.tsx index 7737a12..1b310f5 100644 --- a/src/tabs/TabNav.tsx +++ b/src/tabs/TabNav.tsx @@ -4,8 +4,7 @@ import 'tdesign-icons-web-components/esm/components/chevron-right'; import './TabNavItem'; import './TabBar'; -import { debounce, toArray } from 'lodash'; -import omit from 'lodash/omit'; +import { debounce, omit, toArray } from 'lodash-es'; import { Component, createRef, signal, tag, VNode } from 'omi'; import { calcMaxOffset, calcPrevOrNextOffset, calculateOffset, calcValidOffset } from '../_common/js/tabs/base'; diff --git a/src/tabs/tabs.tsx b/src/tabs/tabs.tsx index b05678c..0c1b13f 100644 --- a/src/tabs/tabs.tsx +++ b/src/tabs/tabs.tsx @@ -1,7 +1,7 @@ import './TabNav'; import './tabPanel'; -import { toArray } from 'lodash'; +import { toArray } from 'lodash-es'; import { Component, tag, VNode } from 'omi'; import classname from '../_util/classname'; diff --git a/src/upload/utils/index.ts b/src/upload/utils/index.ts index 74d6756..de437fc 100644 --- a/src/upload/utils/index.ts +++ b/src/upload/utils/index.ts @@ -1,4 +1,4 @@ -import { isFunction, isString } from 'lodash'; +import { isFunction, isString } from 'lodash-es'; import { computed, signal, SignalValue } from 'omi'; export const toSignal = >(props: T) => { diff --git a/src/watermark/utils.ts b/src/watermark/utils.ts index b57535f..7824006 100644 --- a/src/watermark/utils.ts +++ b/src/watermark/utils.ts @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; const toLowercaseSeparator = (key: string) => key.replace(/([A-Z])/g, '-$1').toLowerCase();