@synerise/ds-search 0.6.0 → 0.6.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/CHANGELOG.md CHANGED
@@ -3,6 +3,38 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.6.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-search@0.6.3...@synerise/ds-search@0.6.4) (2021-11-23)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-search
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.6.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-search@0.6.2...@synerise/ds-search@0.6.3) (2021-11-22)
15
+
16
+ **Note:** Version bump only for package @synerise/ds-search
17
+
18
+
19
+
20
+
21
+
22
+ ## [0.6.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-search@0.6.1...@synerise/ds-search@0.6.2) (2021-11-16)
23
+
24
+ **Note:** Version bump only for package @synerise/ds-search
25
+
26
+
27
+
28
+
29
+
30
+ ## [0.6.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-search@0.5.54...@synerise/ds-search@0.6.1) (2021-11-09)
31
+
32
+ **Note:** Version bump only for package @synerise/ds-search
33
+
34
+
35
+
36
+
37
+
6
38
  # [0.6.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-search@0.5.54...@synerise/ds-search@0.6.0) (2021-11-09)
7
39
 
8
40
  **Note:** Version bump only for package @synerise/ds-search
@@ -1,26 +1,10 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
-
3
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
2
 
5
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
-
7
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8
-
9
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10
-
11
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
12
-
13
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14
-
15
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16
-
17
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
18
-
19
3
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20
4
 
21
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
5
+ function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
22
6
 
23
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
7
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
24
8
 
25
9
  import * as React from 'react';
26
10
  import onClickOutside from 'react-onclickoutside';
@@ -32,20 +16,16 @@ import * as S from '../../Search.styles';
32
16
  import SearchButton from '../SearchButton/SearchButton';
33
17
 
34
18
  var SearchInput = /*#__PURE__*/function (_React$Component) {
35
- _inherits(SearchInput, _React$Component);
36
-
37
- var _super = _createSuper(SearchInput);
19
+ _inheritsLoose(SearchInput, _React$Component);
38
20
 
39
21
  function SearchInput(props) {
40
22
  var _this;
41
23
 
42
- _classCallCheck(this, SearchInput);
43
-
44
- _this = _super.call(this, props); // eslint-disable-next-line react/state-in-constructor
24
+ _this = _React$Component.call(this, props) || this; // eslint-disable-next-line react/state-in-constructor
45
25
 
46
- _this.inputRef = /*#__PURE__*/React.createRef();
26
+ _defineProperty(_assertThisInitialized(_this), "inputRef", React.createRef());
47
27
 
48
- _this.componentDidUpdate = function () {
28
+ _defineProperty(_assertThisInitialized(_this), "componentDidUpdate", function () {
49
29
  var _this$props = _this.props,
50
30
  moveCursorToEnd = _this$props.moveCursorToEnd,
51
31
  value = _this$props.value;
@@ -55,13 +35,13 @@ var SearchInput = /*#__PURE__*/function (_React$Component) {
55
35
  input.current.input.selectionStart = value.length || 0;
56
36
  input.current.input.selectionEnd = value.length || 0;
57
37
  }
58
- };
38
+ });
59
39
 
60
- _this.focusInput = function () {
40
+ _defineProperty(_assertThisInitialized(_this), "focusInput", function () {
61
41
  _this.inputRef.current && _this.inputRef.current.focus();
62
- };
42
+ });
63
43
 
64
- _this.toggleOpen = function () {
44
+ _defineProperty(_assertThisInitialized(_this), "toggleOpen", function () {
65
45
  var onToggle = _this.props.onToggle;
66
46
  var isInputOpen = _this.state.isInputOpen;
67
47
  onToggle && onToggle(!isInputOpen);
@@ -71,9 +51,9 @@ var SearchInput = /*#__PURE__*/function (_React$Component) {
71
51
  isInputOpen: !prevState.isInputOpen
72
52
  };
73
53
  });
74
- };
54
+ });
75
55
 
76
- _this.handleSearchButtonClick = function () {
56
+ _defineProperty(_assertThisInitialized(_this), "handleSearchButtonClick", function () {
77
57
  var _this$props2 = _this.props,
78
58
  alwaysExpanded = _this$props2.alwaysExpanded,
79
59
  onButtonClick = _this$props2.onButtonClick;
@@ -85,9 +65,9 @@ var SearchInput = /*#__PURE__*/function (_React$Component) {
85
65
 
86
66
  onButtonClick && onButtonClick();
87
67
  }
88
- };
68
+ });
89
69
 
90
- _this.handleClearValue = function () {
70
+ _defineProperty(_assertThisInitialized(_this), "handleClearValue", function () {
91
71
  var onClear = _this.props.onClear;
92
72
 
93
73
  _this.setState({
@@ -98,9 +78,9 @@ var SearchInput = /*#__PURE__*/function (_React$Component) {
98
78
  _this.focusInput();
99
79
 
100
80
  onClear();
101
- };
81
+ });
102
82
 
103
- _this.handleChangeValue = function (_ref) {
83
+ _defineProperty(_assertThisInitialized(_this), "handleChangeValue", function (_ref) {
104
84
  var value = _ref.target.value;
105
85
  var onChange = _this.props.onChange;
106
86
  onChange(value);
@@ -108,22 +88,22 @@ var SearchInput = /*#__PURE__*/function (_React$Component) {
108
88
  _this.setState({
109
89
  isResultChosen: false
110
90
  });
111
- };
91
+ });
112
92
 
113
- _this.handleSearchInputContentClick = function () {
93
+ _defineProperty(_assertThisInitialized(_this), "handleSearchInputContentClick", function () {
114
94
  var onClick = _this.props.onClick;
115
95
  onClick && onClick();
116
96
 
117
97
  _this.focusInput();
118
- };
98
+ });
119
99
 
120
- _this.handleOffsetWithFilter = function (ref) {
100
+ _defineProperty(_assertThisInitialized(_this), "handleOffsetWithFilter", function (ref) {
121
101
  ref && _this.setState({
122
102
  inputOffset: ref.getBoundingClientRect().width
123
103
  });
124
- };
104
+ });
125
105
 
126
- _this.handleClickOutside = function () {
106
+ _defineProperty(_assertThisInitialized(_this), "handleClickOutside", function () {
127
107
  var _this$props3 = _this.props,
128
108
  closeOnClickOutside = _this$props3.closeOnClickOutside,
129
109
  onToggle = _this$props3.onToggle,
@@ -136,7 +116,7 @@ var SearchInput = /*#__PURE__*/function (_React$Component) {
136
116
 
137
117
  onToggle && onToggle(false);
138
118
  }
139
- };
119
+ });
140
120
 
141
121
  _this.state = {
142
122
  inputOffset: 0,
@@ -147,102 +127,100 @@ var SearchInput = /*#__PURE__*/function (_React$Component) {
147
127
  return _this;
148
128
  }
149
129
 
150
- _createClass(SearchInput, [{
151
- key: "getSnapshotBeforeUpdate",
152
- value: function getSnapshotBeforeUpdate(prevProps) {
153
- var _this2 = this;
130
+ var _proto = SearchInput.prototype;
154
131
 
155
- var _this$props4 = this.props,
156
- focusTrigger = _this$props4.focusTrigger,
157
- toggleTrigger = _this$props4.toggleTrigger;
132
+ _proto.getSnapshotBeforeUpdate = function getSnapshotBeforeUpdate(prevProps) {
133
+ var _this2 = this;
158
134
 
159
- if (prevProps.focusTrigger !== focusTrigger) {
160
- setTimeout(function () {
161
- _this2.focusInput();
162
- }, 0);
163
- }
135
+ var _this$props4 = this.props,
136
+ focusTrigger = _this$props4.focusTrigger,
137
+ toggleTrigger = _this$props4.toggleTrigger;
164
138
 
165
- if (prevProps.toggleTrigger !== toggleTrigger) {
166
- this.toggleOpen();
167
- }
168
-
169
- return null;
139
+ if (prevProps.focusTrigger !== focusTrigger) {
140
+ setTimeout(function () {
141
+ _this2.focusInput();
142
+ }, 0);
170
143
  }
171
- }, {
172
- key: "render",
173
- value: function render() {
174
- var _this3 = this;
175
-
176
- var _this$props5 = this.props,
177
- alwaysExpanded = _this$props5.alwaysExpanded,
178
- alwaysHighlight = _this$props5.alwaysHighlight,
179
- clearTooltip = _this$props5.clearTooltip,
180
- filterLabel = _this$props5.filterLabel,
181
- filterLookupKey = _this$props5.filterLookupKey,
182
- onKeyDown = _this$props5.onKeyDown,
183
- placeholder = _this$props5.placeholder,
184
- textLookupKey = _this$props5.textLookupKey,
185
- value = _this$props5.value,
186
- disableInput = _this$props5.disableInput,
187
- _this$props5$inputPro = _this$props5.inputProps,
188
- inputProps = _this$props5$inputPro === void 0 ? {} : _this$props5$inputPro;
189
- var _this$state = this.state,
190
- isInputOpen = _this$state.isInputOpen,
191
- inputOffset = _this$state.inputOffset,
192
- isResultChosen = _this$state.isResultChosen,
193
- isInputFocused = _this$state.isInputFocused;
194
- return /*#__PURE__*/React.createElement(S.SearchInputWrapper, null, /*#__PURE__*/React.createElement(S.SearchInputContent, {
195
- className: isInputOpen || !!value || !!filterLabel ? 'is-open search-input-wrapper' : 'search-input-wrapper',
196
- offset: inputOffset,
197
- filterLabel: filterLabel,
198
- onClick: this.handleSearchInputContentClick
199
- }, /*#__PURE__*/React.createElement(S.LeftSide, {
200
- isOpen: isInputOpen
201
- }, filterLabel && /*#__PURE__*/React.createElement(S.Filter, {
202
- ref: this.handleOffsetWithFilter
203
- }, filterLabel.icon && !isResultChosen && /*#__PURE__*/React.createElement(Icon, {
204
- component: filterLabel.icon
205
- }), /*#__PURE__*/React.createElement("span", null, filterLabel[filterLookupKey || ''] || filterLabel[textLookupKey || '']))), /*#__PURE__*/React.createElement(S.SearchInner, {
206
- hasValue: !!value,
207
- alwaysHighlight: alwaysHighlight
208
- }, /*#__PURE__*/React.createElement(Input, _extends({
209
- placeholder: placeholder,
210
- ref: this.inputRef,
211
- value: value,
212
- onChange: this.handleChangeValue,
213
- onKeyDown: onKeyDown,
214
- onFocus: function onFocus() {
215
- _this3.setState({
216
- isInputFocused: true
217
- });
218
- },
219
- onBlur: function onBlur() {
220
- _this3.setState({
221
- isInputFocused: false
222
- });
223
- },
224
- autoComplete: "off",
225
- autoFocus: true,
226
- disabled: disableInput
227
- }, inputProps)))), /*#__PURE__*/React.createElement(SearchButton, {
228
- inputOpen: isInputOpen,
229
- hidden: !!value || !!filterLabel,
230
- inputFocused: isInputFocused,
231
- clickable: !alwaysExpanded,
232
- onClick: this.handleSearchButtonClick
233
- }), /*#__PURE__*/React.createElement(S.ClearButton, {
234
- hidden: !value && !filterLabel
235
- }, /*#__PURE__*/React.createElement(Icon, {
236
- "data-testid": "clear",
237
- onClick: this.handleClearValue,
238
- component: /*#__PURE__*/React.createElement(Tooltip, {
239
- title: clearTooltip
240
- }, /*#__PURE__*/React.createElement(Close3M, null)),
241
- color: theme.palette['red-600'],
242
- size: 18
243
- })));
144
+
145
+ if (prevProps.toggleTrigger !== toggleTrigger) {
146
+ this.toggleOpen();
244
147
  }
245
- }]);
148
+
149
+ return null;
150
+ };
151
+
152
+ _proto.render = function render() {
153
+ var _this3 = this;
154
+
155
+ var _this$props5 = this.props,
156
+ alwaysExpanded = _this$props5.alwaysExpanded,
157
+ alwaysHighlight = _this$props5.alwaysHighlight,
158
+ clearTooltip = _this$props5.clearTooltip,
159
+ filterLabel = _this$props5.filterLabel,
160
+ filterLookupKey = _this$props5.filterLookupKey,
161
+ onKeyDown = _this$props5.onKeyDown,
162
+ placeholder = _this$props5.placeholder,
163
+ textLookupKey = _this$props5.textLookupKey,
164
+ value = _this$props5.value,
165
+ disableInput = _this$props5.disableInput,
166
+ _this$props5$inputPro = _this$props5.inputProps,
167
+ inputProps = _this$props5$inputPro === void 0 ? {} : _this$props5$inputPro;
168
+ var _this$state = this.state,
169
+ isInputOpen = _this$state.isInputOpen,
170
+ inputOffset = _this$state.inputOffset,
171
+ isResultChosen = _this$state.isResultChosen,
172
+ isInputFocused = _this$state.isInputFocused;
173
+ return /*#__PURE__*/React.createElement(S.SearchInputWrapper, null, /*#__PURE__*/React.createElement(S.SearchInputContent, {
174
+ className: isInputOpen || !!value || !!filterLabel ? 'is-open search-input-wrapper' : 'search-input-wrapper',
175
+ offset: inputOffset,
176
+ filterLabel: filterLabel,
177
+ onClick: this.handleSearchInputContentClick
178
+ }, /*#__PURE__*/React.createElement(S.LeftSide, {
179
+ isOpen: isInputOpen
180
+ }, filterLabel && /*#__PURE__*/React.createElement(S.Filter, {
181
+ ref: this.handleOffsetWithFilter
182
+ }, filterLabel.icon && !isResultChosen && /*#__PURE__*/React.createElement(Icon, {
183
+ component: filterLabel.icon
184
+ }), /*#__PURE__*/React.createElement("span", null, filterLabel[filterLookupKey || ''] || filterLabel[textLookupKey || '']))), /*#__PURE__*/React.createElement(S.SearchInner, {
185
+ hasValue: !!value,
186
+ alwaysHighlight: alwaysHighlight
187
+ }, /*#__PURE__*/React.createElement(Input, _extends({
188
+ placeholder: placeholder,
189
+ ref: this.inputRef,
190
+ value: value,
191
+ onChange: this.handleChangeValue,
192
+ onKeyDown: onKeyDown,
193
+ onFocus: function onFocus() {
194
+ _this3.setState({
195
+ isInputFocused: true
196
+ });
197
+ },
198
+ onBlur: function onBlur() {
199
+ _this3.setState({
200
+ isInputFocused: false
201
+ });
202
+ },
203
+ autoComplete: "off",
204
+ autoFocus: true,
205
+ disabled: disableInput
206
+ }, inputProps)))), /*#__PURE__*/React.createElement(SearchButton, {
207
+ inputOpen: isInputOpen,
208
+ hidden: !!value || !!filterLabel,
209
+ inputFocused: isInputFocused,
210
+ clickable: !alwaysExpanded,
211
+ onClick: this.handleSearchButtonClick
212
+ }), /*#__PURE__*/React.createElement(S.ClearButton, {
213
+ hidden: !value && !filterLabel
214
+ }, /*#__PURE__*/React.createElement(Icon, {
215
+ "data-testid": "clear",
216
+ onClick: this.handleClearValue,
217
+ component: /*#__PURE__*/React.createElement(Tooltip, {
218
+ title: clearTooltip
219
+ }, /*#__PURE__*/React.createElement(Close3M, null)),
220
+ color: theme.palette['red-600'],
221
+ size: 18
222
+ })));
223
+ };
246
224
 
247
225
  return SearchInput;
248
226
  }(React.Component);
@@ -1,6 +1,6 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
4
4
 
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
6
 
@@ -26,9 +26,9 @@ var rowRenderer = function rowRenderer(_ref) {
26
26
  var itemReturnedFromRenderer = data.itemRender(item);
27
27
  var rendererCustomStyles = itemReturnedFromRenderer && itemReturnedFromRenderer.props && itemReturnedFromRenderer.props.style || {};
28
28
 
29
- var mergedStyles = _objectSpread(_objectSpread({}, rendererCustomStyles), style);
29
+ var mergedStyles = _objectSpread({}, rendererCustomStyles, {}, style);
30
30
 
31
- return /*#__PURE__*/React.cloneElement(itemReturnedFromRenderer, _objectSpread(_objectSpread({}, itemReturnedFromRenderer.props), {}, {
31
+ return React.cloneElement(itemReturnedFromRenderer, _objectSpread({}, itemReturnedFromRenderer.props, {
32
32
  style: mergedStyles,
33
33
  highlight: data.highlight,
34
34
  onClick: function onClick() {