Skip to content

Commit 51ab544

Browse files
committed
Merge branch 'develop' into feature/fix-types
2 parents 94615af + 285805b commit 51ab544

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solved-ac/ui-react",
3-
"version": "0.3.1",
3+
"version": "0.4.2",
44
"description": "React component library used by solved.ac",
55
"author": "shiftpsh",
66
"license": "MIT",
@@ -15,6 +15,7 @@
1515
"files": [
1616
"dist"
1717
],
18+
"sideEffects": false,
1819
"scripts": {
1920
"build": "rimraf --no-glob ./dist && microbundle --no-compress --format modern,cjs --jsx React.createElement",
2021
"start": "rimraf --no-glob ./dist && microbundle watch --no-compress --format modern,cjs --jsx React.createElement",
@@ -34,23 +35,22 @@
3435
"@floating-ui/react-dom-interactions": "^0.13.3",
3536
"framer-motion": "6.x",
3637
"react": ">=17",
37-
"react-dom": ">=17",
38-
"react-icons": "^4.8.0"
38+
"react-dom": ">=17"
3939
},
4040
"devDependencies": {
4141
"@babel/plugin-proposal-decorators": "^7.17.9",
4242
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
4343
"@emotion/react": "^11.1.5",
4444
"@emotion/styled": "^11.1.5",
4545
"@floating-ui/react-dom-interactions": "^0.13.3",
46+
"@tabler/icons-react": "^2.11.0",
4647
"@testing-library/jest-dom": "^4.2.4",
4748
"@testing-library/react": "^9.5.0",
4849
"@testing-library/user-event": "^7.2.1",
4950
"@types/jest": "^25.1.4",
5051
"@types/node": "^12.12.38",
5152
"@types/react": "^18.0.9",
5253
"@types/react-dom": "^18.0.3",
53-
"@types/react-icons": "^3.0.0",
5454
"@typescript-eslint/eslint-plugin": "^5.22.0",
5555
"@typescript-eslint/parser": "^5.22.0",
5656
"babel-eslint": "^10.0.3",
@@ -80,7 +80,6 @@
8080
"prettier": "^2.6.2",
8181
"react": "^17.0.1",
8282
"react-dom": "^17.0.1",
83-
"react-icons": "^4.8.0",
8483
"react-scripts": "^5.0.1",
8584
"typescript": "^4.6.4"
8685
}

src/components/Select.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
useRole,
1818
useTypeahead
1919
} from '@floating-ui/react-dom-interactions'
20+
import { IconChevronDown } from '@tabler/icons-react'
2021
import { AnimatePresence, motion } from 'framer-motion'
2122
import { ellipsis } from 'polished'
2223
import React, {
@@ -28,7 +29,6 @@ import React, {
2829
useRef,
2930
useState
3031
} from 'react'
31-
import { IoChevronDown } from 'react-icons/io5'
3232
import { PP, PR } from '../types/PolymorphicElementProps'
3333
import { forwardRefWithGenerics } from '../utils/ref'
3434
import { cssClickable, cssDisablable } from '../utils/styles'
@@ -107,7 +107,6 @@ export const Select = forwardRefWithGenerics(
107107
value,
108108
onChange,
109109
render = (e) => (typeof e === 'string' ? e : e.value),
110-
as,
111110
ListItemProps,
112111
...rest
113112
} = props
@@ -125,9 +124,13 @@ export const Select = forwardRefWithGenerics(
125124
const [controlledScrolling, setControlledScrolling] = useState(false)
126125
const [touch, setTouch] = useState(false)
127126

128-
useEffect(() => {
129-
if (onChange) onChange(items[selectedIndex])
130-
}, [selectedIndex])
127+
const handleCommit = (index: number): void => {
128+
setSelectedIndex(index)
129+
if (onChange) {
130+
onChange(items[index])
131+
}
132+
setOpen(false)
133+
}
131134

132135
useEffect(() => {
133136
const idx = items.findIndex((it) =>
@@ -180,7 +183,7 @@ export const Select = forwardRefWithGenerics(
180183
useTypeahead(context, {
181184
listRef: listContentRef,
182185
activeIndex,
183-
onMatch: open ? setActiveIndex : setSelectedIndex,
186+
onMatch: open ? setActiveIndex : handleCommit,
184187
}),
185188
])
186189

@@ -267,7 +270,7 @@ export const Select = forwardRefWithGenerics(
267270
>
268271
{selected ? render(selected) : null}
269272
<SelectInputAdornment>
270-
<IoChevronDown />
273+
<IconChevronDown />
271274
</SelectInputAdornment>
272275
</SelectDisplay>
273276
<FloatingPortal>
@@ -340,14 +343,12 @@ export const Select = forwardRefWithGenerics(
340343
onKeyDown(e) {
341344
allowSelectRef.current = true
342345
if (e.key === 'Enter' && allowSelectRef.current) {
343-
setSelectedIndex(i)
344-
setOpen(false)
346+
handleCommit(i)
345347
}
346348
},
347349
onClick() {
348350
if (allowSelectRef.current) {
349-
setSelectedIndex(i)
350-
setOpen(false)
351+
handleCommit(i)
351352
}
352353
},
353354
onMouseUp() {
@@ -356,8 +357,7 @@ export const Select = forwardRefWithGenerics(
356357
}
357358

358359
if (allowSelectRef.current) {
359-
setSelectedIndex(i)
360-
setOpen(false)
360+
handleCommit(i)
361361
}
362362

363363
clearTimeout(selectTimeoutRef.current)

yarn.lock

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,6 +1987,19 @@
19871987
"@svgr/plugin-svgo" "^5.5.0"
19881988
loader-utils "^2.0.0"
19891989

1990+
"@tabler/icons-react@^2.11.0":
1991+
version "2.11.0"
1992+
resolved "https://registry.yarnpkg.com/@tabler/icons-react/-/icons-react-2.11.0.tgz#18d512830e4e9fabe425177fa968136efa7ea372"
1993+
integrity sha512-Mbie8IFLrtI0sGm802Bmierle0ixIi7FVczShoLjPZwRM0da1HcD588TF7oMuQ09zd241BY+L7M/f0Q6lquBng==
1994+
dependencies:
1995+
"@tabler/icons" "2.11.0"
1996+
prop-types "^15.7.2"
1997+
1998+
"@tabler/icons@2.11.0":
1999+
version "2.11.0"
2000+
resolved "https://registry.yarnpkg.com/@tabler/icons/-/icons-2.11.0.tgz#9767f2bb57a716ed71fdc5019ca534d5fddcc816"
2001+
integrity sha512-KPESQnvHoSpbAdgzDdrSmeZ9AE8fSU12fU3Cag79uXJCUkC8f741fcvPJPsFMDe0S96VSq3mMYF8JnA7a570uQ==
2002+
19902003
"@testing-library/dom@*":
19912004
version "8.13.0"
19922005
resolved "https://registry.npmjs.org/@testing-library/dom/-/dom-8.13.0.tgz"
@@ -2304,13 +2317,6 @@
23042317
dependencies:
23052318
"@types/react" "*"
23062319

2307-
"@types/react-icons@^3.0.0":
2308-
version "3.0.0"
2309-
resolved "https://registry.yarnpkg.com/@types/react-icons/-/react-icons-3.0.0.tgz#27ca2823a6add881d06a371bfff093afc1b9c829"
2310-
integrity sha512-Vefs6LkLqF61vfV7AiAqls+vpR94q67gunhMueDznG+msAkrYgRxl7gYjNem/kZ+as2l2mNChmF1jRZzzQQtMg==
2311-
dependencies:
2312-
react-icons "*"
2313-
23142320
"@types/react@*":
23152321
version "18.0.6"
23162322
resolved "https://registry.npmjs.org/@types/react/-/react-18.0.6.tgz"
@@ -8285,7 +8291,7 @@ prompts@^2.0.1, prompts@^2.4.2:
82858291
kleur "^3.0.3"
82868292
sisteransi "^1.0.5"
82878293

8288-
prop-types@^15.8.1:
8294+
prop-types@^15.7.2, prop-types@^15.8.1:
82898295
version "15.8.1"
82908296
resolved "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz"
82918297
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
@@ -8427,11 +8433,6 @@ react-error-overlay@^6.0.11:
84278433
resolved "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz"
84288434
integrity sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==
84298435

8430-
react-icons@*, react-icons@^4.8.0:
8431-
version "4.8.0"
8432-
resolved "https://registry.yarnpkg.com/react-icons/-/react-icons-4.8.0.tgz#621e900caa23b912f737e41be57f27f6b2bff445"
8433-
integrity sha512-N6+kOLcihDiAnj5Czu637waJqSnwlMNROzVZMhfX68V/9bu9qHaMIJC4UdozWoOk57gahFCNHwVvWzm0MTzRjg==
8434-
84358436
react-is@^16.12.0, react-is@^16.13.1, react-is@^16.7.0, react-is@^16.8.4:
84368437
version "16.13.1"
84378438
resolved "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz"

0 commit comments

Comments
 (0)