From 55e981840fda75678baea89260494f6441acdfb5 Mon Sep 17 00:00:00 2001 From: Arno V Date: Sun, 10 Mar 2024 18:50:37 -0400 Subject: [PATCH] fix(ui-private): remove premature optimization and dependencies (#390) ## Summary by CodeRabbit - **Chores** - Removed unused dependencies to streamline the project. - **Refactor** - Simplified utility functions for better performance and maintainability. --- packages/ui-private/package.json | 6 +----- packages/ui-private/src/common/utilities.ts | 24 ++------------------- pnpm-lock.yaml | 12 ----------- 3 files changed, 3 insertions(+), 39 deletions(-) diff --git a/packages/ui-private/package.json b/packages/ui-private/package.json index 85fc803f..fc2307ab 100644 --- a/packages/ui-private/package.json +++ b/packages/ui-private/package.json @@ -44,12 +44,8 @@ }, "dependencies": { "@floating-ui/react": "0.26.9", - "@tailwindcss/typography": "0.5.10", "@versini/ui-hooks": "workspace:../ui-hooks", - "clsx": "2.1.0", - "fast-equals": "5.0.1", - "micro-memoize": "4.1.2", - "tailwindcss": "3.4.1" + "clsx": "2.1.0" }, "sideEffects": [ "**/*.css" diff --git a/packages/ui-private/src/common/utilities.ts b/packages/ui-private/src/common/utilities.ts index 68a8c940..afc7ced3 100644 --- a/packages/ui-private/src/common/utilities.ts +++ b/packages/ui-private/src/common/utilities.ts @@ -1,12 +1,3 @@ -import { deepEqual } from "fast-equals"; -import memoize from "micro-memoize"; - -// import type { SpacingType } from "."; - -// export type SpacingProps = { -// spacing?: SpacingType; -// }; - export type SpacingType = | undefined | string @@ -31,17 +22,6 @@ export type SpacingProps = { spacing?: SpacingType; }; -/** - * Memoize function calls with arguments that are - * complex objects (hence "deep"). Do not use for - * standard types. - * @param {Function} fct - the function to optimize. - * @returns the optimized function. - */ -export function memoizeDeep(fct: any) { - return memoize(fct, { isEqual: deepEqual }); -} - /** * This method returns a string that can be used as a tailwind class relying * on margins definitions (m, mt, mb, etc.). @@ -54,7 +34,7 @@ export function memoizeDeep(fct: any) { * { t: 4, r: 1, b: 3, l: 5} => "mt-4 mr-1 mb-3 ml-5" * */ -export const getSpacing = memoizeDeep((spacing: SpacingType): string => { +export const getSpacing = (spacing: SpacingType): string => { let spacingClass = ""; /** * In this case, spacing is a number or a string. For example: @@ -89,4 +69,4 @@ export const getSpacing = memoizeDeep((spacing: SpacingType): string => { } return spacingClass; -}); +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 907ba0c1..e97538c2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -253,24 +253,12 @@ importers: '@floating-ui/react': specifier: 0.26.9 version: 0.26.9(react-dom@18.2.0)(react@18.2.0) - '@tailwindcss/typography': - specifier: 0.5.10 - version: 0.5.10(tailwindcss@3.4.1) '@versini/ui-hooks': specifier: workspace:../ui-hooks version: link:../ui-hooks clsx: specifier: 2.1.0 version: 2.1.0 - fast-equals: - specifier: 5.0.1 - version: 5.0.1 - micro-memoize: - specifier: 4.1.2 - version: 4.1.2 - tailwindcss: - specifier: 3.4.1 - version: 3.4.1 devDependencies: '@versini/ui-plugins': specifier: workspace:../ui-plugins