@faststore/ui 1.5.10 → 1.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/dist/index.d.ts +1 -1
- package/dist/molecules/SearchInput/SearchInput.d.ts +5 -1
- package/dist/molecules/SearchInput/index.d.ts +1 -1
- package/dist/ui.cjs.development.js +11 -6
- package/dist/ui.cjs.development.js.map +1 -1
- package/dist/ui.cjs.production.min.js +1 -1
- package/dist/ui.cjs.production.min.js.map +1 -1
- package/dist/ui.esm.js +12 -7
- package/dist/ui.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -1
- package/src/molecules/SearchInput/SearchInput.tsx +18 -7
- package/src/molecules/SearchInput/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/ui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.14",
|
|
4
4
|
"description": "A lightweight, framework agnostic component library for React",
|
|
5
5
|
"author": "emersonlaurentino",
|
|
6
6
|
"license": "MIT",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@types/jest-axe": "^3.5.3",
|
|
77
77
|
"@types/tabbable": "^3.1.1",
|
|
78
78
|
"@types/testing-library__jest-dom": "^5.9.5",
|
|
79
|
-
"@vtex/theme-b2c-tailwind": "^1.5.
|
|
79
|
+
"@vtex/theme-b2c-tailwind": "^1.5.14",
|
|
80
80
|
"@vtex/tsconfig": "^0.5.0",
|
|
81
81
|
"chalk": "^5.0.0",
|
|
82
82
|
"jest-axe": "^5.0.1",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"tsdx": "^0.14.1",
|
|
90
90
|
"typescript": "^4.2.4"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "a51e880c27a8a7a6bc1b685d1777e4525e3024e7"
|
|
93
93
|
}
|
package/src/index.ts
CHANGED
|
@@ -58,7 +58,7 @@ export { default as Bullets } from './molecules/Bullets'
|
|
|
58
58
|
export type { BulletsProps } from './molecules/Bullets'
|
|
59
59
|
|
|
60
60
|
export { default as SearchInput } from './molecules/SearchInput'
|
|
61
|
-
export type { SearchInputProps } from './molecules/SearchInput'
|
|
61
|
+
export type { SearchInputProps, SearchInputRef } from './molecules/SearchInput'
|
|
62
62
|
|
|
63
63
|
export { default as Carousel } from './molecules/Carousel'
|
|
64
64
|
export type { CarouselProps } from './molecules/Carousel'
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
InputHTMLAttributes,
|
|
5
5
|
ReactNode,
|
|
6
6
|
} from 'react'
|
|
7
|
-
import React, { forwardRef, useRef } from 'react'
|
|
7
|
+
import React, { useImperativeHandle, forwardRef, useRef } from 'react'
|
|
8
8
|
|
|
9
9
|
import Button from '../../atoms/Button'
|
|
10
10
|
import Icon from '../../atoms/Icon'
|
|
@@ -50,7 +50,12 @@ export interface SearchInputProps extends InputProps {
|
|
|
50
50
|
testId?: string
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
export interface SearchInputRef {
|
|
54
|
+
inputRef?: HTMLInputElement | null
|
|
55
|
+
formRef?: HTMLFormElement | null
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const SearchInput = forwardRef<SearchInputRef | null, SearchInputProps>(
|
|
54
59
|
function SearchInput(
|
|
55
60
|
{
|
|
56
61
|
onSubmit,
|
|
@@ -61,25 +66,31 @@ const SearchInput = forwardRef<HTMLFormElement, SearchInputProps>(
|
|
|
61
66
|
},
|
|
62
67
|
ref
|
|
63
68
|
) {
|
|
64
|
-
const
|
|
69
|
+
const inputRef = useRef<HTMLInputElement>(null)
|
|
70
|
+
const formRef = useRef<HTMLFormElement>(null)
|
|
65
71
|
|
|
66
72
|
const handleSubmit = (event: FormEvent) => {
|
|
67
73
|
event.preventDefault()
|
|
68
74
|
|
|
69
|
-
if (
|
|
70
|
-
onSubmit(
|
|
75
|
+
if (inputRef.current?.value !== '') {
|
|
76
|
+
onSubmit(inputRef.current!.value)
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
79
|
|
|
80
|
+
useImperativeHandle(ref, () => ({
|
|
81
|
+
inputRef: inputRef.current,
|
|
82
|
+
formRef: formRef.current,
|
|
83
|
+
}))
|
|
84
|
+
|
|
74
85
|
return (
|
|
75
86
|
<Form
|
|
76
|
-
ref={
|
|
87
|
+
ref={formRef}
|
|
77
88
|
data-store-search-input
|
|
78
89
|
data-testid={testId}
|
|
79
90
|
onSubmit={handleSubmit}
|
|
80
91
|
role="search"
|
|
81
92
|
>
|
|
82
|
-
<Input ref={
|
|
93
|
+
<Input ref={inputRef} aria-label={ariaLabel} {...otherProps} />
|
|
83
94
|
<Button type="submit" aria-label="Submit Search">
|
|
84
95
|
<Icon component={icon ?? <SearchIcon />} />
|
|
85
96
|
</Button>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from './SearchInput'
|
|
2
|
-
export type { SearchInputProps } from './SearchInput'
|
|
2
|
+
export type { SearchInputProps, SearchInputRef } from './SearchInput'
|