Skip to content

Commit cbd3adc

Browse files
committed
Merge branch 'main' into feat-select
2 parents 247f40a + fcd3e5a commit cbd3adc

File tree

16 files changed

+536
-14
lines changed

16 files changed

+536
-14
lines changed

.changeset/free-bats-create.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@devup-ui/components": patch
3+
---
4+
5+
Add Stepper component

.changeset/happy-mammals-travel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@devup-ui/components": patch
3+
---
4+
5+
Fix Input test snapshot

.changeset/silly-trams-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@devup-ui/components": patch
3+
---
4+
5+
Fix Input

packages/components/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @devup-ui/components
22

3+
## 0.1.3
4+
5+
### Patch Changes
6+
7+
- 9d7b342: Add onClear prop in input component
8+
39
## 0.1.2
410

511
### Patch Changes

packages/components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"css-in-js-framework",
1717
"react"
1818
],
19-
"version": "0.1.2",
19+
"version": "0.1.3",
2020
"type": "module",
2121
"scripts": {
2222
"lint": "eslint",

packages/components/src/__tests__/index.browser.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ describe('export', () => {
44
expect({ ...index }).toEqual({
55
Button: expect.any(Function),
66
Input: expect.any(Function),
7+
Stepper: expect.any(Function),
78
})
89
})
910
})

packages/components/src/components/Input/__tests__/__snapshots__/index.browser.test.tsx.snap

Lines changed: 12 additions & 12 deletions
Large diffs are not rendered by default.

packages/components/src/components/Input/__tests__/index.browser.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,16 @@ describe('Input', () => {
155155
})
156156
expect(onChange).toHaveBeenCalledWith(expect.any(Object))
157157
})
158+
159+
it('should call onClear props when click clear button', () => {
160+
const onClear = vi.fn()
161+
const { container } = render(<Input onClear={onClear} />)
162+
fireEvent.change(container.querySelector('input')!, {
163+
target: { value: 'test' },
164+
})
165+
fireEvent.click(container.querySelector('[aria-label="clear-button"]')!)
166+
expect(onClear).toHaveBeenCalled()
167+
})
158168
})
159169

160170
describe('Controlled Input', () => {

packages/components/src/components/Input/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ interface InputProps extends Omit<ComponentProps<'input'>, 'type'> {
1717
errorMessage?: string
1818
allowClear?: boolean
1919
classNames?: {
20+
container?: string
2021
input?: string
2122
icon?: string
2223
errorMessage?: string
2324
}
25+
onClear?: () => void
2426
colors?: {
2527
primary?: string
2628
error?: string
@@ -49,6 +51,7 @@ export function Input({
4951
className,
5052
classNames,
5153
ref,
54+
onClear,
5255
...props
5356
}: InputProps) {
5457
const [value, setValue] = useState(defaultValue || '')
@@ -58,11 +61,13 @@ export function Input({
5861
}
5962
const handleClear = () => {
6063
setValue('')
64+
onClear?.()
6165
}
6266
const clearButtonVisible = value && !disabled && allowClear
6367

6468
return (
6569
<Box
70+
className={classNames?.container}
6671
display="inline-block"
6772
pos="relative"
6873
selectors={{ '&, & *': { boxSizing: 'border-box' } }}
@@ -102,7 +107,7 @@ export function Input({
102107
outline: 'none',
103108
}}
104109
_hover={{
105-
border: '1px solid var(--primary, light-dark(red, blue))',
110+
border: '1px solid var(--primary, light-dark(#674DC7, #8163E1))',
106111
}}
107112
_placeholder={{
108113
color: 'var(--inputPlaceholder, light-dark(#A9A8AB, #CBCBCB))',
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { SVGProps } from 'react'
2+
3+
export function IconMinus({ ...props }: SVGProps<SVGSVGElement>) {
4+
return (
5+
<svg
6+
fill="none"
7+
height="28"
8+
viewBox="0 0 28 28"
9+
width="28"
10+
xmlns="http://www.w3.org/2000/svg"
11+
{...props}
12+
>
13+
<path
14+
clipRule="evenodd"
15+
d="M9 14C9 13.4477 9.3731 13 9.83333 13H18.1667C18.6269 13 19 13.4477 19 14C19 14.5523 18.6269 15 18.1667 15H9.83333C9.3731 15 9 14.5523 9 14Z"
16+
fill="currentColor"
17+
fillRule="evenodd"
18+
/>
19+
</svg>
20+
)
21+
}

0 commit comments

Comments
 (0)