@jasperoosthoek/react-toolbox 0.6.1 → 0.6.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jasperoosthoek/react-toolbox",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "author": "jasperoosthoek",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,4 +1,4 @@
1
- import React, { ChangeEvent } from 'react';
1
+ import React, { ChangeEvent, ReactNode } from 'react';
2
2
  import { InputGroup, Form, FormControlProps } from 'react-bootstrap';
3
3
 
4
4
  import { useLocalization } from '../../localization/LocalizationContext';
@@ -10,29 +10,47 @@ export type SearchBoxProps = {
10
10
  onChange: (value: string) => void;
11
11
  onClear?: () => void;
12
12
  onSearch?: () => void;
13
+ label?: ReactNode | string | number;
14
+ placeholder?: string | false;
13
15
  }
14
- export const SearchBox = ({ className='', value, onChange, onClear, onSearch }: SearchBoxProps) => {
16
+ export const SearchBox = ({
17
+ className='',
18
+ value,
19
+ onChange,
20
+ onClear,
21
+ onSearch,
22
+ label,
23
+ placeholder,
24
+ }: SearchBoxProps) => {
15
25
  const { strings } = useLocalization();
16
26
 
17
- return (<>
18
- <InputGroup {...className ? { className } : {}}>
19
- <Form.Control
20
- value={value}
21
- placeholder={strings.getString('search')}
22
- onChange={(e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value)}
23
- />
24
- {onClear &&
25
- <UnCheckButton
26
- variant="outline-secondary"
27
- onClick={() => onClear()}
27
+ return (
28
+ <Form.Group>
29
+ {label && <Form.Label>{label}</Form.Label>}
30
+
31
+ <InputGroup {...className ? { className } : {}}>
32
+ <Form.Control
33
+ value={value}
34
+ placeholder={
35
+ placeholder
36
+ ? placeholder
37
+ : placeholder !== false && strings.getString('search')
38
+ }
39
+ onChange={(e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value)}
28
40
  />
29
- }
30
- {onSearch &&
31
- <SearchButton
32
- variant="outline-secondary"
33
- onClick={() => onSearch()}
34
- />
35
- }
36
- </InputGroup></>
41
+ {onClear &&
42
+ <UnCheckButton
43
+ variant="outline-secondary"
44
+ onClick={() => onClear()}
45
+ />
46
+ }
47
+ {onSearch &&
48
+ <SearchButton
49
+ variant="outline-secondary"
50
+ onClick={() => onSearch()}
51
+ />
52
+ }
53
+ </InputGroup>
54
+ </Form.Group>
37
55
  )
38
56
  }