Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use lodash-es instead of lodash #516

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module.exports = (api, options) => {
'@babel/typescript'
],
plugins: [
'lodash',
['@babel/plugin-transform-class-properties', { loose: true }],
'@babel/plugin-transform-optional-chaining',
'@babel/plugin-transform-export-namespace-from',
Expand Down
6 changes: 3 additions & 3 deletions docs/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { Nav } from 'rsuite';
import CodeView from 'react-code-view';
import Frame from './components/Frame';
import TableIcon from '@rsuite/icons/Table';
import GithubIcon from '@rsuite/icons/legacy/Github';
import BookIcon from '@rsuite/icons/legacy/Book';
import kebabCase from 'lodash/kebabCase';
import Frame from './components/Frame';
import { Nav } from 'rsuite';
import { kebabCase } from 'lodash-es';

interface ExampleType {
title: string;
Expand Down
19 changes: 8 additions & 11 deletions docs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import React, { StrictMode } from 'react';
import ReactDOM from 'react-dom/client';
import GearIcon from '@rsuite/icons/Gear';
import ArrowDownIcon from '@rsuite/icons/ArrowDown';
import ArrowUpIcon from '@rsuite/icons/ArrowUp';
import SortIcon from '@rsuite/icons/Sort';
import fakeDataForColSpan from './data/usersForColSpan';
import fakeDataForRowSpan from './data/usersForRowSpan';
import App from './App';
import {
Popover,
Whisper,
Expand All @@ -16,19 +23,9 @@ import {
VStack,
HStack
} from 'rsuite';
import clone from 'lodash/clone';
import isFunction from 'lodash/isFunction';
import get from 'lodash/get';
import without from 'lodash/without';
import App from './App';
import { clone, isFunction, get, without } from 'lodash-es';
import { Table, Column, Cell, HeaderCell, ColumnGroup } from '../src';
import fakeDataForColSpan from './data/usersForColSpan';
import fakeDataForRowSpan from './data/usersForRowSpan';
import { createUser, mockUsers, mockTreeData } from './data/mock';
import GearIcon from '@rsuite/icons/Gear';
import ArrowDownIcon from '@rsuite/icons/ArrowDown';
import ArrowUpIcon from '@rsuite/icons/ArrowUp';
import SortIcon from '@rsuite/icons/Sort';
import { useDrag, useDrop, DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import { faker } from '@faker-js/faker';
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@
"@babel/runtime": "^7.20.1",
"@juggle/resize-observer": "^3.4.0",
"@rsuite/icons": "^1.3.0",
"@types/lodash-es": "^4.17.12",
"classnames": "^2.3.1",
"dom-lib": "^3.3.1",
"lodash": "^4.17.21"
"lodash-es": "^4.17.21"
},
"peerDependencies": {
"react": ">=18",
Expand All @@ -68,15 +69,13 @@
"@faker-js/faker": "^7.6.0",
"@size-limit/file": "^11.1.6",
"@testing-library/react": "^13.4.0",
"@types/lodash": "^4.14.165",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"autoprefixer": "^8.3.0",
"babel-loader": "^8.2.2",
"babel-plugin-istanbul": "^7.0.0",
"babel-plugin-lodash": "^3.3.4",
"chai": "^4.3.5",
"conventional-changelog-cli": "^2.1.1",
"coveralls": "^3.1.0",
Expand Down
96 changes: 16 additions & 80 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions src/Cell.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React, { useCallback } from 'react';
import omit from 'lodash/omit';
import isNil from 'lodash/isNil';
import get from 'lodash/get';
import { LAYER_WIDTH, ROW_HEADER_HEIGHT, ROW_HEIGHT } from './constants';
import { useClassNames, convertToFlex } from './utils';
import TableContext from './TableContext';
import ArrowRight from '@rsuite/icons/ArrowRight';
import ArrowDown from '@rsuite/icons/ArrowDown';
import { omit, isNil, get } from 'lodash-es';
import { LAYER_WIDTH, ROW_HEADER_HEIGHT, ROW_HEIGHT } from './constants';
import { useClassNames, convertToFlex } from './utils';
import { StandardProps, RowDataType, RowKeyType } from './@types/common';
import { columnHandledProps } from './Column';

Expand Down
4 changes: 2 additions & 2 deletions src/ColumnResizeHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useCallback, useContext, useEffect, useRef } from 'react';
import clamp from 'lodash/clamp';
import DOMMouseMoveTracker from 'dom-lib/DOMMouseMoveTracker';
import { useClassNames } from './utils';
import TableContext from './TableContext';
import { clamp } from 'lodash-es';
import { useClassNames } from './utils';
import { RESIZE_MIN_WIDTH } from './constants';
import type { StandardProps } from './@types/common';

Expand Down
4 changes: 2 additions & 2 deletions src/HeaderCell.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useState, useCallback } from 'react';
import classNames from 'classnames';
import isNil from 'lodash/isNil';
import Sort from '@rsuite/icons/Sort';
import SortUp from '@rsuite/icons/SortUp';
import SortDown from '@rsuite/icons/SortDown';
import ColumnResizeHandler, { FixedType } from './ColumnResizeHandler';
import { useUpdateEffect, useClassNames } from './utils';
import Cell, { InnerCellProps } from './Cell';
import { useUpdateEffect, useClassNames } from './utils';
import { isNil } from 'lodash-es';
import { RowDataType, RowKeyType } from './@types/common';

export interface HeaderCellProps<Row extends RowDataType, Key extends RowKeyType>
Expand Down
7 changes: 3 additions & 4 deletions src/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import React, { useRef, useCallback, useImperativeHandle, useReducer, useMemo } from 'react';
import { isElement } from './utils/react-is';
import { getTranslateDOMPositionXY } from 'dom-lib/translateDOMPositionXY';
import isFunction from 'lodash/isFunction';
import debounce from 'lodash/debounce';
import Row, { RowProps } from './Row';
import CellGroup from './CellGroup';
import Scrollbar, { ScrollbarInstance } from './Scrollbar';
Expand All @@ -14,6 +10,9 @@ import Cell, { InnerCellProps } from './Cell';
import HeaderCell, { HeaderCellProps } from './HeaderCell';
import Column, { ColumnProps } from './Column';
import ColumnGroup from './ColumnGroup';
import { debounce, isFunction } from 'lodash-es';
import { isElement } from './utils/react-is';
import { getTranslateDOMPositionXY } from 'dom-lib/translateDOMPositionXY';
import {
SCROLLBAR_WIDTH,
CELL_PADDING_HEIGHT,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/defer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import defer from 'lodash/defer';
import { defer } from 'lodash-es';

/**
* Defer callbacks to wait for DOM rendering to complete.
Expand Down
Loading
Loading