homeflowjs 0.11.3 → 0.11.4

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": "homeflowjs",
3
- "version": "0.11.3",
3
+ "version": "0.11.4",
4
4
  "description": "JavaScript toolkit for Homeflow themes",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -5,7 +5,9 @@ import { Radio } from 'pretty-checkbox-react';
5
5
 
6
6
  import { setChannel } from '../../actions/search.actions';
7
7
 
8
- const PrettyRadio = ({ channel, value, handleChange, children }) => {
8
+ const PrettyRadio = ({
9
+ channel, value, handleChange, children,
10
+ }) => {
9
11
  const checked = value === channel;
10
12
 
11
13
  return (
@@ -15,6 +17,18 @@ const PrettyRadio = ({ channel, value, handleChange, children }) => {
15
17
  );
16
18
  };
17
19
 
20
+ PrettyRadio.propTypes = {
21
+ value: PropTypes.oneOf(['sales', 'lettings']),
22
+ channel: PropTypes.string.isRequired,
23
+ handleChange: PropTypes.func.isRequired,
24
+ children: PropTypes.node.isRequired,
25
+ };
26
+
27
+ PrettyRadio.defaultProps = {
28
+ // TODO: make this configurable via prop
29
+ value: 'sales',
30
+ };
31
+
18
32
  const ChannelRadioButton = (props) => {
19
33
  const {
20
34
  pretty,
@@ -22,13 +36,14 @@ const ChannelRadioButton = (props) => {
22
36
  channel,
23
37
  setChannel,
24
38
  onChange,
39
+ withAria,
25
40
  ...otherProps
26
41
  } = props;
27
42
 
28
43
  const handleChange = (e) => {
29
44
  setChannel(value);
30
45
  if (onChange) onChange(e);
31
- }
46
+ };
32
47
 
33
48
  if (pretty) return <PrettyRadio {...props} handleChange={handleChange} />;
34
49
 
@@ -36,13 +51,15 @@ const ChannelRadioButton = (props) => {
36
51
  <input
37
52
  type="radio"
38
53
  name="channel"
39
- aria-label={`${value}-radio`}
40
54
  value={value}
41
55
  onChange={handleChange}
42
56
  checked={channel === value}
57
+ {...(withAria && {
58
+ 'aria-label': `${value}-radio`,
59
+ })}
43
60
  {...otherProps}
44
61
  />
45
- )
62
+ );
46
63
  };
47
64
 
48
65
  ChannelRadioButton.propTypes = {
@@ -50,15 +67,19 @@ ChannelRadioButton.propTypes = {
50
67
  channel: PropTypes.string.isRequired,
51
68
  setChannel: PropTypes.func.isRequired,
52
69
  onChange: PropTypes.func,
70
+ pretty: PropTypes.bool,
71
+ withAria: PropTypes.bool,
53
72
  };
54
73
 
55
74
  ChannelRadioButton.defaultProps = {
56
75
  // TODO: make this configurable via prop
57
76
  value: 'sales',
58
77
  onChange: null,
78
+ pretty: false,
79
+ withAria: true,
59
80
  };
60
81
 
61
- const mapStateToProps = state => ({
82
+ const mapStateToProps = (state) => ({
62
83
  channel: state.search.currentSearch.channel,
63
84
  });
64
85
 
@@ -87,7 +87,9 @@ class LocationInput extends Component {
87
87
  }
88
88
 
89
89
  render() {
90
- const { suggestions, search: { q = '' }, className, placeholder } = this.props;
90
+ const {
91
+ suggestions, search: { q = '' }, className, placeholder,
92
+ } = this.props;
91
93
 
92
94
  const inputProps = {
93
95
  placeholder,
@@ -103,7 +105,13 @@ class LocationInput extends Component {
103
105
  onSuggestionsClearRequested={this.onSuggestionsClearRequested.bind(this)}
104
106
  getSuggestionValue={this.getSuggestionValue.bind(this)}
105
107
  renderSuggestion={this.renderSuggestion.bind(this)}
106
- inputProps={{ ...inputProps, className, 'data-testid': 'location-input' }}
108
+ inputProps={{
109
+ ...inputProps,
110
+ className,
111
+ 'data-testid': 'location-input',
112
+ id: 'search-location-input',
113
+ name: 'Location search',
114
+ }}
107
115
  containerProps={{ 'data-testid': 'suggestions' }}
108
116
  theme={autosuggestTheme}
109
117
  />
@@ -116,17 +124,19 @@ LocationInput.propTypes = {
116
124
  setSuggestions: PropTypes.func.isRequired,
117
125
  setSearchField: PropTypes.func.isRequired,
118
126
  placeholder: PropTypes.string,
127
+ className: PropTypes.string,
119
128
  search: PropTypes.object.isRequired,
120
129
  searchOnSelection: PropTypes.bool,
121
130
  };
122
131
 
123
132
  LocationInput.defaultProps = {
124
133
  placeholder: 'Enter a location...',
134
+ className: '',
125
135
  suggestions: [],
126
136
  searchOnSelection: false,
127
137
  };
128
138
 
129
- const mapStateToProps = state => ({
139
+ const mapStateToProps = (state) => ({
130
140
  suggestions: state.search.currentSearch.suggestions,
131
141
  search: state.search.currentSearch,
132
142
  });