Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
4ba2767
refactor(noop): migration lodash-es noop -> arrow function(() => {})
annie1229 Dec 9, 2022
f76dd7f
refactor(isobject): migration isObject lodash-es -> typeUtils
annie1229 Dec 9, 2022
82b944c
refactor(isnil): migration isNil lodash-es -> typeUtils
annie1229 Dec 9, 2022
0f7995a
refactor(isfunction): migration isFunction lodash-es -> typeUtils
annie1229 Dec 9, 2022
106a05f
refactor(isinteger): migration isInteger lodash-es -> Number.isInteger
annie1229 Dec 9, 2022
9e9a6dd
refactor(isarray): migration isArray lodash-es -> Array.isArray
annie1229 Dec 9, 2022
777fb6c
refactor(isstring): migration isString lodash-es -> typeUtils
annie1229 Dec 9, 2022
d682e85
refactor(isnumber): migration isNumber lodash-es -> typeUtils
annie1229 Dec 9, 2022
0197c94
refactor(isboolean): migration isBoolean lodash-es -> typeUtils
annie1229 Dec 9, 2022
0b1ced0
refactor(map): migration lodash-es map -> es6 map
annie1229 Dec 12, 2022
9ce08c2
refactor(filter): migration lodash-es filter -> es6 filter
annie1229 Dec 12, 2022
485f261
refactor(some): migration lodash-es some -> es6 some
annie1229 Dec 12, 2022
8ff1731
refactor(size): migration lodash-es size -> length
annie1229 Dec 12, 2022
1811e6a
refactor(has): migration has lodash-es -> objectUtils
annie1229 Dec 12, 2022
ea57aee
refactor(get): migration get lodash-es
annie1229 Dec 12, 2022
76cbcab
refactor(range): migration range lodash-es -> numberUtils
annie1229 Dec 12, 2022
34d079e
refactor(trim): migration trim lodash-es
annie1229 Dec 12, 2022
ac46c76
refactor(keys): migration keys lodash-es -> Object.keys
annie1229 Dec 12, 2022
bf66e75
refactor(values): migration values lodash-es -> Object.values
annie1229 Dec 12, 2022
e52807e
refactor(entries): migration entries lodash-es -> Object.entries
annie1229 Dec 12, 2022
d5a5d4b
refactor(isempty): migration isEmpty lodash-es -> typeUtils
annie1229 Dec 13, 2022
e452f79
refactor(compact): migration compact lodash-es -> arrayUtils
annie1229 Dec 13, 2022
8d57bf8
refactor(includes): migration includes lodash-es -> es6
annie1229 Dec 13, 2022
079243d
refactor(pick): migration pick lodash-es -> objectUtils
annie1229 Dec 13, 2022
09514f3
refactor(omit): migration omit lodash-es -> objectUtils, refactoring …
annie1229 Dec 13, 2022
0ace708
refactor(frompairs): migration fromPairs lodash-es -> Object.fromEntries
annie1229 Dec 13, 2022
71d5a20
refactor(flattendeep): migration flattenDeep lodash-es -> arrayUtils
annie1229 Dec 13, 2022
6b4464b
refactor(random): migration random lodash-es -> Math.random
annie1229 Dec 13, 2022
9ad7949
refactor(isnan): migration isNaN lodash-es -> Number.isNaN
annie1229 Dec 13, 2022
c5958b9
refactor(clamp): migration clamp lodash-es -> numberUtils
annie1229 Dec 13, 2022
f66c56d
refactor(endswith): migration endsWith lodash-es
annie1229 Dec 13, 2022
ccac384
refactor(tostring): migration toString lodash-es -> stringUtils
annie1229 Dec 13, 2022
9df91a6
refactor(camelcase): migration camelCase lodash-es -> stringUtils
annie1229 Dec 13, 2022
ac155de
refactor(isequal): migration isEqual lodash-es -> objectUtils and add…
annie1229 Dec 14, 2022
ad285d0
refactor(throttle): migration throttle lodash-es -> timingUtils
annie1229 Dec 15, 2022
36d188f
test(typeutils): add typeUtils test
annie1229 Dec 15, 2022
8929d98
test(stringutils): add toString, camelCase test in stringUtils
annie1229 Dec 15, 2022
eaaf561
test(objectutils): add test objectUtils
annie1229 Dec 15, 2022
aa10d71
test(arrayutils): add test arrayUtils(compact, flattenDeep)
annie1229 Dec 15, 2022
04160a9
test(numberutils): add test numberUtils and fix range function
annie1229 Dec 15, 2022
53f000f
test(timingutils): add test timingUtils
annie1229 Dec 20, 2022
9485922
feat(kebabcase): migration kebabCase lodash-es -> stringUtils
annie1229 Dec 20, 2022
abb120f
test(stringutils): add test kebabCase
annie1229 Dec 20, 2022
4f7513a
build(npm): remove lodash-es
annie1229 Dec 20, 2022
644a7d7
fix(arrayutils): fix flattenDeep return type unknown[] -> T[]
annie1229 Dec 20, 2022
ea622ab
fix: fix lint error, change the import order
annie1229 Dec 20, 2022
94d4291
fix(stringutils): fix kebabCase and camelCase logic when input value …
annie1229 Dec 20, 2022
3126b21
fix(timingutils): fix time-related throttle test code failing intermi…
annie1229 Dec 20, 2022
a76f01f
chore(changeset): add changeset
annie1229 Dec 20, 2022
dc99497
fix: remove lodash-es related code added during rebase
annie1229 Dec 22, 2022
0808672
refactor(stringutils): refactor kebabCase RegExp
annie1229 Dec 22, 2022
2313d08
refactor(kebabcase): change the location of the declation outside fun…
annie1229 Jan 2, 2023
4ab2827
refactor(typeutils): add isArray, isInteger, isNaN
annie1229 Jan 2, 2023
cf7a579
refactor(typeutils): add noop and migration arrow function () => {}
annie1229 Jan 2, 2023
a99203b
fix: remove lodash-es related code added during rebase
annie1229 Jan 2, 2023
755eeda
refactor(noop): move to functionUtils
annie1229 Jan 25, 2023
e6e86fb
test(arrayutils): rebase and delete unnecessary code
annie1229 Feb 24, 2023
48f1c05
refactor(timingutils): delete unused util
annie1229 Feb 24, 2023
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
5 changes: 5 additions & 0 deletions .changeset/small-suns-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@channel.io/bezier-react": patch
---

Remove and re-implement lodash-es
2 changes: 0 additions & 2 deletions packages/bezier-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
"@types/jest": "^25.2.3",
"@types/lodash-es": "^4.17.4",
"@types/react": "^18.0.8",
"@types/react-dom": "^18.0.3",
"@types/styled-components": "^5.1.5",
Expand Down Expand Up @@ -124,7 +123,6 @@
"@radix-ui/react-switch": "^1.0.1",
"@radix-ui/react-tabs": "^1.0.1",
"@radix-ui/react-toolbar": "^1.0.1",
"lodash-es": "^4.17.15",
"react-resize-detector": "^7.1.1",
"react-textarea-autosize": "^8.3.4",
"ssr-window": "^3.0.0",
Expand Down
13 changes: 10 additions & 3 deletions packages/bezier-react/scripts/icon-index-template.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
const _ = require('lodash')
const path = require('path')

const kebabCase = (value) => value
.trim()
.replace(/([a-z])([A-Z])/g, '$1-$2')
.replace(/([a-z])([0-9])/g, '$1-$2')
.replace(/([0-9])([A-Z])/g, '$1-$2')
.replace(/([0-9])([a-z])/g, '$1-$2')
.replace(/[\s_]+/g, '-')
.toLowerCase()

function defaultIndexTemplate(filePaths) {
const importEntries = []
const mappedFies = []
const exportEntries = []

filePaths.forEach(filePath => {
const basename = path.basename(filePath, path.extname(filePath))

const exportName = /^\d/.test(basename) ? `Svg${basename}` : basename
importEntries.push(`import ${exportName} from './${basename}'`)
mappedFies.push(` '${_.kebabCase(basename)}': ${exportName},`)
mappedFies.push(` '${kebabCase(basename)}': ${exportName},`)
exportEntries.push(` ${exportName} as ${exportName}Icon,`)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import { Story, Meta } from '@storybook/react'
/* Internal dependencies */
import { styled } from 'Foundation'
import { getTitle } from 'Utils/storyUtils'
import { isNaN } from 'Utils/typeUtils'
import { StatusType } from 'Components/Status'
import { Avatar } from './Avatar'
import AvatarProps, { AvatarSize } from './Avatar.types'

const MOCK_AVATAR_URL = 'https://cf.channel.io/thumb/200x200/pub-file/1/606d87d059a6093594c0/ch-symbol-filled-smiley-bg.png'

const avatarSizeList = Object.keys(AvatarSize)
.filter(value => Number.isNaN(Number(value)) === true)
.filter(value => isNaN(Number(value)) === true)
.map(key => AvatarSize[key])

const statusTypeList = Object.keys(StatusType)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/* External dependencies */
import React, { forwardRef, useMemo } from 'react'
import { noop, isEmpty } from 'lodash-es'

/* Internal denpendencies */
import { backgroundImageVariable } from 'Foundation'
import {
isEmpty,
} from 'Utils/typeUtils'
import { noop } from 'Utils/functionUtils'
import { Status, StatusSize } from 'Components/Status'
// eslint-disable-next-line no-restricted-imports
import defaultAvatarUrl from '../assets/defaultAvatar.svg'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { Story, Meta } from '@storybook/react'

/* Internal dependencies */
import { getTitle } from 'Utils/storyUtils'
import { isNaN } from 'Utils/typeUtils'
import { Avatar, AvatarSize } from 'Components/Avatars/Avatar'
import MOCK_AVATAR_LIST from './__mocks__/avatarList'
import { AvatarGroupEllipsisType, AvatarGroupProps } from './AvatarGroup.types'
import { AvatarGroup } from './AvatarGroup'

const avatarSizeList = Object.keys(AvatarSize)
.filter(value => Number.isNaN(Number(value)) === true)
.filter(value => isNaN(Number(value)) === true)
.map(key => AvatarSize[key])

export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* External dependencies */
import React, { forwardRef, useCallback, useMemo } from 'react'
import { noop } from 'lodash-es'

/* Internal dependencies */
import { Typography } from 'Foundation'
import { isLastIndex } from 'Utils/arrayUtils'
import { noop } from 'Utils/functionUtils'
import { Icon, IconSize, MoreIcon } from 'Components/Icon'
import { AvatarProps, AvatarSize } from 'Components/Avatars/Avatar'
import { AVATAR_GROUP_DEFAULT_SPACING } from 'Components/Avatars/AvatarStyle'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import {
type Meta,
type Story,
} from '@storybook/react'
import {
range,
} from 'lodash-es'
import base from 'paths.macro'

/* Internal dependencies */
import { styled } from 'Foundation'
import { getTitle } from 'Utils/storyUtils'
import {
range,
} from 'Utils/numberUtils'
import {
Avatar,
AvatarSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Story, Meta } from '@storybook/react'
/* Internal dependencies */
import { styled } from 'Foundation'
import { getTitle } from 'Utils/storyUtils'
import { isNaN } from 'Utils/typeUtils'
import { Avatar, AvatarSize } from 'Components/Avatars/Avatar'
import { CheckableAvatar } from './CheckableAvatar'
import CheckableAvatarProps from './CheckableAvatar.types'
Expand Down Expand Up @@ -51,7 +52,7 @@ const MOCK_AVATAR_LIST = [
]

const avatarSizeList = Object.keys(AvatarSize)
.filter(value => Number.isNaN(Number(value)) === true)
.filter(value => isNaN(Number(value)) === true)
.map(key => AvatarSize[key])

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import React from 'react'
import base from 'paths.macro'
import type { Meta, Story } from '@storybook/react'
import { noop } from 'lodash-es'

/* Internal dependencies */
import { getTitle, getObjectFromEnum } from 'Utils/storyUtils'
import { noop } from 'Utils/functionUtils'
import {
StackItem,
VStack,
Expand Down
8 changes: 4 additions & 4 deletions packages/bezier-react/src/components/Banner/Banner.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* External dependencies */
import React, { forwardRef } from 'react'
import {
isNil,
isString,
} from 'lodash-es'

/* Internal dependencies */
import { Typography } from 'Foundation'
import {
isNil,
isString,
} from 'Utils/typeUtils'
import { Text } from 'Components/Text'
import { IconSize } from 'Components/Icon'
import { StackItem } from 'Components/Stack'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import {
Meta,
Story,
} from '@storybook/react'
import {
entries,
} from 'lodash-es'

/* Internal dependencies */
import {
Expand Down Expand Up @@ -570,7 +567,7 @@ VariantsColor.storyName = 'Color variants'

export const VariantsStyle: Story<{}> = () => (
<VStack spacing={16} align="start">
{ entries(ButtonStyleVariant)
{ Object.entries(ButtonStyleVariant)
.map(([key, styleVariant]) => (
<StackItem key={styleVariant}>
<HStack spacing={24} align="center">
Expand All @@ -596,7 +593,7 @@ VariantsStyle.storyName = 'Style variants'

export const VariantsSize: Story<{}> = () => (
<VStack spacing={16} align="start">
{ entries(ButtonSize)
{ Object.entries(ButtonSize)
.map(([key, size]) => (
<StackItem key={key}>
<HStack spacing={24} align="center">
Expand Down
8 changes: 4 additions & 4 deletions packages/bezier-react/src/components/Button/Button.styled.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* External dependencies */
import { isEmpty, includes } from 'lodash-es'

/* Internal dependencies */
import { styled, css, SemanticNames } from 'Foundation'
import DisabledOpacity from 'Constants/DisabledOpacity'
import { gap } from 'Utils/styleUtils'
import {
isEmpty,
} from 'Utils/typeUtils'
import { Text } from 'Components/Text'
import ButtonProps, { ButtonSize, ButtonStyleVariant, ButtonColorVariant } from './Button.types'

Expand Down Expand Up @@ -96,7 +96,7 @@ function getPaddingCSSFromSizeAndContents({
`
}

const paddingVariant = includes([ButtonStyleVariant.Floating, ButtonStyleVariant.FloatingAlt], styleVariant)
const paddingVariant = [ButtonStyleVariant.Floating, ButtonStyleVariant.FloatingAlt].includes(styleVariant)
? 'floating'
: 'default'

Expand Down
22 changes: 14 additions & 8 deletions packages/bezier-react/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
/* External dependencies */
import React, { forwardRef, useCallback, useMemo, useState } from 'react'
import { flattenDeep, fromPairs, isArray, noop, values } from 'lodash-es'

/* Internal dependencies */
import { Typography, SemanticNames } from 'Foundation'
import {
flattenDeep,
} from 'Utils/arrayUtils'
import {
isArray,
} from 'Utils/typeUtils'
import { noop } from 'Utils/functionUtils'
import { LegacyIcon, IconSize, isIconName } from 'Components/Icon'
import { Spinner, SpinnerSize } from 'Components/Spinner'
import ButtonProps, {
Expand Down Expand Up @@ -42,7 +48,7 @@ function combinations(
}

const OVERRIDED_TEXT_DEFAULT_COLORS: { [key in VariantTuple]?: SemanticNames } = {
...fromPairs(
...Object.fromEntries(
combinations(
ButtonColorVariant.Monochrome,
[ButtonStyleVariant.Secondary, ButtonStyleVariant.Tertiary],
Expand All @@ -53,35 +59,35 @@ const OVERRIDED_TEXT_DEFAULT_COLORS: { [key in VariantTuple]?: SemanticNames } =
}

const OVERRIDED_ICON_AND_SPINNER_DEFAULT_COLORS: { [key in VariantTuple]?: SemanticNames } = {
...fromPairs(
...Object.fromEntries(
combinations(
ButtonColorVariant.Monochrome,
[ButtonStyleVariant.Secondary, ButtonStyleVariant.Tertiary],
[ButtonSize.XL, ButtonSize.L, ButtonSize.M],
)
.map((key) => [key, 'txt-black-darker']),
),
...fromPairs(
...Object.fromEntries(
combinations(
ButtonColorVariant.Monochrome,
[ButtonStyleVariant.Secondary, ButtonStyleVariant.Tertiary],
[ButtonSize.S, ButtonSize.XS],
)
.map((key) => [key, 'txt-black-dark']),
),
...fromPairs(
...Object.fromEntries(
combinations(
ButtonColorVariant.MonochromeLight,
[ButtonStyleVariant.Secondary, ButtonStyleVariant.Tertiary, ButtonStyleVariant.Floating],
values(ButtonSize),
Object.values(ButtonSize),
)
.map((key) => [key, 'txt-black-dark']),
),
...fromPairs(
...Object.fromEntries(
combinations(
ButtonColorVariant.MonochromeDark,
[ButtonStyleVariant.Secondary, ButtonStyleVariant.Tertiary, ButtonStyleVariant.Floating],
values(ButtonSize),
Object.values(ButtonSize),
)
.map((key) => [key, 'txt-black-darker']),
),
Expand Down
2 changes: 1 addition & 1 deletion packages/bezier-react/src/components/Emoji/Emoji.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* External dependencies */
import React, { useMemo, forwardRef } from 'react'
import { noop } from 'lodash-es'

/* Internal dependencies */
import { backgroundImageVariable } from 'Foundation'
import { noop } from 'Utils/functionUtils'
import type EmojiProps from './Emoji.types'
import { EmojiSize } from './Emoji.types'
import { Icon } from './Emoji.styled'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* External dependencies */
import React from 'react'
import { noop } from 'lodash-es'

/* Internal dependencies */
import { Themes } from 'Foundation'
import { render } from 'Utils/testUtils'
import { noop } from 'Utils/functionUtils'
import DisabledOpacity from 'Constants/DisabledOpacity'
import Checkbox, { CHECKBOX_TEST_ID, CHECKBOX_CHECKER_TEST_ID } from './Checkbox'
import CheckboxProps from './Checkbox.types'
Expand Down
10 changes: 7 additions & 3 deletions packages/bezier-react/src/components/Forms/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/* External dependencies */
import React, { Ref, forwardRef, useMemo } from 'react'
import { values, isBoolean, isEmpty, includes, noop } from 'lodash-es'

/* Internal dependencies */
import {
isBoolean,
isEmpty,
} from 'Utils/typeUtils'
import { noop } from 'Utils/functionUtils'
import { IconSize, IconProps, CheckBoldIcon, HyphenBoldIcon } from 'Components/Icon'
import useFormFieldProps from 'Components/Forms/useFormFieldProps'
import type CheckboxProps from './Checkbox.types'
Expand All @@ -12,7 +16,7 @@ import * as Styled from './Checkbox.styled'
export const CHECKBOX_TEST_ID = 'bezier-react-checkbox'
export const CHECKBOX_CHECKER_TEST_ID = 'bezier-react-checkbox-checker'

const checkTypeValues = values(CheckType)
const checkTypeValues = Object.values(CheckType)

const checkIconCommonProps: Pick<IconProps, 'size' | 'color'> = {
size: IconSize.XS,
Expand All @@ -38,7 +42,7 @@ function Checkbox(

const checkStatus = useMemo(() => {
if (isBoolean(checked)) { return (checked) ? CheckType.True : CheckType.False }
if (includes(checkTypeValues, checked)) { return checked }
if (checkTypeValues.includes(checked)) { return checked }
return CheckType.False
}, [checked])

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* External dependencies */
import React, { useState, useCallback, useMemo } from 'react'
import { isNil } from 'lodash-es'

/* Internal dependencies */
import { Typography } from 'Foundation'
import useId from 'Hooks/useId'
import {
isNil,
} from 'Utils/typeUtils'
import { omitBezierComponentProps, pickBezierComponentProps } from 'Utils/propsUtils'
// eslint-disable-next-line no-restricted-imports
import FormFieldSize from '../FormFieldSize'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/* External dependencies */
import React, { forwardRef, useEffect, useMemo } from 'react'
import { isEmpty } from 'lodash-es'

/* Internal dependencies */
import { Typography } from 'Foundation'
import {
isEmpty,
} from 'Utils/typeUtils'
import useFormControlContext from 'Components/Forms/useFormControlContext'
import type { BaseHelperTextProps, FormHelperTextProps, FormErrorMessageProps } from './FormHelperText.types'
import * as Styled from './FormHelperText.styled'
Expand Down
Loading