@loadsmart/loadsmart-ui 7.1.0 → 7.2.0
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/dist/components/Select/Select.types.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Select/Select.test.tsx +16 -0
- package/src/components/Select/Select.types.ts +1 -0
- package/src/components/Select/SelectTrigger.tsx +1 -1
- package/src/components/Select/useSelect.ts +2 -0
package/package.json
CHANGED
|
@@ -32,6 +32,22 @@ describe('Select', () => {
|
|
|
32
32
|
screen.getByTestId('select-trigger-search-field')
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
+
it('transfer additional input props to SelectTrigger', () => {
|
|
36
|
+
const props: Partial<SelectProps> = {
|
|
37
|
+
getInputProps: () => ({
|
|
38
|
+
minLength: 11,
|
|
39
|
+
maxLength: 33,
|
|
40
|
+
}),
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setup({ ...props })
|
|
44
|
+
|
|
45
|
+
const searchInput = screen.getByTestId('select-trigger-search-field')
|
|
46
|
+
|
|
47
|
+
expect(searchInput).toHaveAttribute('minlength', '11')
|
|
48
|
+
expect(searchInput).toHaveAttribute('maxlength', '33')
|
|
49
|
+
})
|
|
50
|
+
|
|
35
51
|
describe('when disabled', () => {
|
|
36
52
|
it('does not expand with the available options when search input is clicked', () => {
|
|
37
53
|
setup({ disabled: true })
|
|
@@ -87,6 +87,7 @@ export interface SelectProps extends DropdownProps {
|
|
|
87
87
|
onChange?: OnChange
|
|
88
88
|
onCreate?: OnCreate
|
|
89
89
|
onQueryChange?: OnQueryChange
|
|
90
|
+
getInputProps?: () => Partial<TextFieldProps>
|
|
90
91
|
isValidNewOption?: ((query: string) => boolean) | boolean
|
|
91
92
|
createOptionPosition?: CreateOptionPosition
|
|
92
93
|
/**
|
|
@@ -61,8 +61,8 @@ const SelectTrigger = forwardRef<HTMLInputElement, SelectTriggerProps>(function
|
|
|
61
61
|
return (
|
|
62
62
|
<GenericSelectTrigger className={className}>
|
|
63
63
|
<SelectTriggerSearchField
|
|
64
|
-
data-testid="select-trigger-search-field"
|
|
65
64
|
{...others}
|
|
65
|
+
data-testid="select-trigger-search-field"
|
|
66
66
|
ref={(node) => {
|
|
67
67
|
if (isFunction(ref)) {
|
|
68
68
|
ref(node)
|
|
@@ -220,6 +220,7 @@ function useSelect(props: SelectProps): useSelectReturn {
|
|
|
220
220
|
onQueryChange,
|
|
221
221
|
onChange,
|
|
222
222
|
onCreate,
|
|
223
|
+
getInputProps,
|
|
223
224
|
id,
|
|
224
225
|
name,
|
|
225
226
|
disabled = false,
|
|
@@ -348,6 +349,7 @@ function useSelect(props: SelectProps): useSelectReturn {
|
|
|
348
349
|
const getTriggerProps = useCallback(
|
|
349
350
|
function getTriggerProps() {
|
|
350
351
|
return {
|
|
352
|
+
...getInputProps?.(),
|
|
351
353
|
id,
|
|
352
354
|
ref(node: HTMLInputElement | null) {
|
|
353
355
|
if (node != null) {
|