@woosmap/ui 4.4.0 → 4.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@woosmap/ui",
3
- "version": "4.4.0",
3
+ "version": "4.6.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/WebGeoServices/ui.git"
@@ -62,8 +62,16 @@ class UseCase extends Component {
62
62
  this.state = { stateSelected: false };
63
63
  }
64
64
 
65
+ onClick = () => {
66
+ const { stateSelected } = this.state;
67
+ const { isSelectable } = this.props;
68
+ if (isSelectable) {
69
+ this.setState({ stateSelected: !stateSelected });
70
+ }
71
+ };
72
+
65
73
  render() {
66
- const { className, children, testId, ...rest } = this.props;
74
+ const { className, children, isSelectable, testId, ...rest } = this.props;
67
75
  const { stateSelected } = this.state;
68
76
  const classes = cl('use-case', stateSelected ? 'use-case--selected' : false, className);
69
77
  return (
@@ -71,7 +79,7 @@ class UseCase extends Component {
71
79
  className={classes}
72
80
  role="button"
73
81
  data-testid={testId}
74
- onClick={() => this.setState({ stateSelected: !stateSelected })}
82
+ onClick={this.onClick}
75
83
  onKeyDown={() => {}}
76
84
  tabIndex="-1"
77
85
  {...rest}
@@ -85,6 +93,7 @@ class UseCase extends Component {
85
93
  UseCase.defaultProps = {
86
94
  testId: 'usecase',
87
95
  className: '',
96
+ isSelectable: false,
88
97
  product: PropTypes.oneOf([
89
98
  'LOCALITIES',
90
99
  'LOCALITIES_ADDRESS_UK',
@@ -108,6 +117,7 @@ UseCase.propTypes = {
108
117
  testId: PropTypes.string,
109
118
  className: PropTypes.string,
110
119
  product: PropTypes.string,
120
+ isSelectable: PropTypes.bool,
111
121
  };
112
122
 
113
123
  export default Object.assign(UseCase, {
@@ -10,7 +10,7 @@ export default Story;
10
10
 
11
11
  const Template = () => (
12
12
  <div className="mbib flex-column">
13
- <UseCase>
13
+ <UseCase isSelectable>
14
14
  <div className="use-case__header">Store Locator</div>
15
15
  <div className="use-case__body">Store Locator</div>
16
16
  <div className="use-case__footer">
package/src/index.js CHANGED
@@ -20,6 +20,7 @@ export { default as Icon } from './components/Icon/Icon';
20
20
  export { default as InfoMessage } from './components/InfoMessage/InfoMessage';
21
21
  export { default as Input } from './components/Input/Input';
22
22
  export { default as Label } from './components/Label/Label';
23
+ export { default as UseCase } from './components/UseCase/UseCase';
23
24
  export { default as LocalitiesAutocomplete } from './components/Woosmap/LocalitiesAutocomplete';
24
25
  export { default as AddressAutocomplete } from './components/Woosmap/AddressAutocomplete';
25
26
  export { default as Modal } from './components/Modal/Modal';