From f2fb98809f2790a1edd1f9998bd124bfce4f4e79 Mon Sep 17 00:00:00 2001 From: Marin Atanasov Date: Mon, 29 Aug 2022 18:01:32 +0300 Subject: [PATCH] Lodash: Remove completely from edit-widgets package --- package-lock.json | 3 +-- packages/edit-widgets/package.json | 3 +-- .../keyboard-shortcut-help-modal/shortcut.js | 8 ++---- .../more-menu/tools-more-menu-group.js | 7 +----- .../src/components/notices/index.js | 25 +++++++------------ 5 files changed, 14 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index 96b15cb29fbe1..77413a70d7913 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17131,8 +17131,7 @@ "@wordpress/reusable-blocks": "file:packages/reusable-blocks", "@wordpress/url": "file:packages/url", "@wordpress/widgets": "file:packages/widgets", - "classnames": "^2.3.1", - "lodash": "^4.17.21" + "classnames": "^2.3.1" } }, "@wordpress/editor": { diff --git a/packages/edit-widgets/package.json b/packages/edit-widgets/package.json index 32cdf9ea5af97..537dacd5c75b8 100644 --- a/packages/edit-widgets/package.json +++ b/packages/edit-widgets/package.json @@ -51,8 +51,7 @@ "@wordpress/reusable-blocks": "file:../reusable-blocks", "@wordpress/url": "file:../url", "@wordpress/widgets": "file:../widgets", - "classnames": "^2.3.1", - "lodash": "^4.17.21" + "classnames": "^2.3.1" }, "peerDependencies": { "react": "^17.0.0", diff --git a/packages/edit-widgets/src/components/keyboard-shortcut-help-modal/shortcut.js b/packages/edit-widgets/src/components/keyboard-shortcut-help-modal/shortcut.js index 8270a36a3ccce..cdf056785d2d9 100644 --- a/packages/edit-widgets/src/components/keyboard-shortcut-help-modal/shortcut.js +++ b/packages/edit-widgets/src/components/keyboard-shortcut-help-modal/shortcut.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import { castArray } from 'lodash'; - /** * WordPress dependencies */ @@ -20,13 +15,14 @@ function KeyCombination( { keyCombination, forceAriaLabel } ) { keyCombination.character ) : keyCombination.character; + const shortcuts = Array.isArray( shortcut ) ? shortcut : [ shortcut ]; return ( - { castArray( shortcut ).map( ( character, index ) => { + { shortcuts.map( ( character, index ) => { if ( character === '+' ) { return { character }; } diff --git a/packages/edit-widgets/src/components/more-menu/tools-more-menu-group.js b/packages/edit-widgets/src/components/more-menu/tools-more-menu-group.js index d9543521404c1..8264e1c272a02 100644 --- a/packages/edit-widgets/src/components/more-menu/tools-more-menu-group.js +++ b/packages/edit-widgets/src/components/more-menu/tools-more-menu-group.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import { isEmpty } from 'lodash'; - /** * WordPress dependencies */ @@ -14,7 +9,7 @@ const { Fill: ToolsMoreMenuGroup, Slot } = createSlotFill( ToolsMoreMenuGroup.Slot = ( { fillProps } ) => ( - { ( fills ) => ! isEmpty( fills ) && fills } + { ( fills ) => fills.length > 0 && fills } ); diff --git a/packages/edit-widgets/src/components/notices/index.js b/packages/edit-widgets/src/components/notices/index.js index dcd366033985f..bb02274e92871 100644 --- a/packages/edit-widgets/src/components/notices/index.js +++ b/packages/edit-widgets/src/components/notices/index.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import { filter } from 'lodash'; - /** * WordPress dependencies */ @@ -18,17 +13,15 @@ function Notices() { }; }, [] ); - const dismissibleNotices = filter( notices, { - isDismissible: true, - type: 'default', - } ); - const nonDismissibleNotices = filter( notices, { - isDismissible: false, - type: 'default', - } ); - const snackbarNotices = filter( notices, { - type: 'snackbar', - } ); + const dismissibleNotices = notices.filter( + ( { isDismissible, type } ) => isDismissible && type === 'default' + ); + const nonDismissibleNotices = notices.filter( + ( { isDismissible, type } ) => ! isDismissible && type === 'default' + ); + const snackbarNotices = notices.filter( + ( { type } ) => type === 'snackbar' + ); return ( <>