cozy-ui 111.18.1 → 111.19.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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [111.19.0](https://github.com/cozy/cozy-ui/compare/v111.18.1...v111.19.0) (2024-10-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **SearchBar:** Ref wasn't spread correctly ([15fc5fe](https://github.com/cozy/cozy-ui/commit/15fc5fe))
7
+
8
+
9
+ ### Features
10
+
11
+ * **SearchBar:** Add `onClear` and `disabledFocus` props ([6c8cabf](https://github.com/cozy/cozy-ui/commit/6c8cabf))
12
+
1
13
  ## [111.18.1](https://github.com/cozy/cozy-ui/compare/v111.18.0...v111.18.1) (2024-10-14)
2
14
 
3
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "111.18.1",
3
+ "version": "111.19.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -116,12 +116,14 @@ const SearchBar = forwardRef(
116
116
  label: labelProp,
117
117
  componentsProps,
118
118
  disabledClear,
119
+ disabledFocus,
119
120
  className,
120
121
  defaultValue,
121
122
  value,
122
123
  elevation,
123
124
  disabled,
124
125
  onChange,
126
+ onClear,
125
127
  onFocus,
126
128
  onBlur,
127
129
  ...props
@@ -155,6 +157,7 @@ const SearchBar = forwardRef(
155
157
 
156
158
  const handleClear = ev => {
157
159
  onChange({ ...ev, target: { ...ev.target, value: '' } })
160
+ onClear(ev)
158
161
  setCurrentValue('')
159
162
  }
160
163
 
@@ -175,7 +178,7 @@ const SearchBar = forwardRef(
175
178
  className={cx(className, classes.root, {
176
179
  [classes.flat]: !elevation,
177
180
  [classes.elevation]: elevation,
178
- [classes.focused]: isFocused,
181
+ [classes.focused]: isFocused && !disabledFocus,
179
182
  [classes.disabled]: disabled
180
183
  })}
181
184
  ref={ref}
@@ -233,9 +236,11 @@ SearchBar.defaultProps = {
233
236
  size: 'small',
234
237
  type: 'search',
235
238
  disabledClear: false,
239
+ disabledFocus: false,
236
240
  defaultValue: '',
237
241
  onChange: () => {},
238
242
  onFocus: () => {},
243
+ onClear: () => {},
239
244
  onBlur: () => {}
240
245
  }
241
246
 
@@ -253,6 +258,7 @@ SearchBar.propTypes = {
253
258
  /** Used only with self-controlled component */
254
259
  defaultValue: PropTypes.string,
255
260
  disabledClear: PropTypes.bool,
261
+ disabledFocus: PropTypes.bool,
256
262
  elevation: PropTypes.bool,
257
263
  placeholder: PropTypes.string,
258
264
  label: PropTypes.oneOfType([
@@ -263,13 +269,14 @@ SearchBar.propTypes = {
263
269
  disabled: PropTypes.bool,
264
270
  onChange: PropTypes.func,
265
271
  onFocus: PropTypes.func,
272
+ onClear: PropTypes.func,
266
273
  onBlur: PropTypes.func
267
274
  }
268
275
 
269
- const SearchBarWithLocales = props => {
276
+ const SearchBarWithLocales = forwardRef((props, ref) => {
270
277
  useExtendI18n(locales)
271
278
 
272
- return <SearchBar {...props} />
273
- }
279
+ return <SearchBar {...props} ref={ref} />
280
+ })
274
281
 
275
282
  export default SearchBarWithLocales
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["placeholder", "icon", "size", "type", "label", "componentsProps", "disabledClear", "className", "defaultValue", "value", "elevation", "disabled", "onChange", "onFocus", "onBlur"];
5
+ var _excluded = ["placeholder", "icon", "size", "type", "label", "componentsProps", "disabledClear", "disabledFocus", "className", "defaultValue", "value", "elevation", "disabled", "onChange", "onClear", "onFocus", "onBlur"];
6
6
 
7
7
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
8
 
@@ -135,12 +135,14 @@ var SearchBar = /*#__PURE__*/forwardRef(function (_ref5, ref) {
135
135
  labelProp = _ref5.label,
136
136
  componentsProps = _ref5.componentsProps,
137
137
  disabledClear = _ref5.disabledClear,
138
+ disabledFocus = _ref5.disabledFocus,
138
139
  className = _ref5.className,
139
140
  defaultValue = _ref5.defaultValue,
140
141
  value = _ref5.value,
141
142
  elevation = _ref5.elevation,
142
143
  disabled = _ref5.disabled,
143
144
  onChange = _ref5.onChange,
145
+ onClear = _ref5.onClear,
144
146
  onFocus = _ref5.onFocus,
145
147
  onBlur = _ref5.onBlur,
146
148
  props = _objectWithoutProperties(_ref5, _excluded);
@@ -190,6 +192,7 @@ var SearchBar = /*#__PURE__*/forwardRef(function (_ref5, ref) {
190
192
  value: ''
191
193
  })
192
194
  }));
195
+ onClear(ev);
193
196
  setCurrentValue('');
194
197
  };
195
198
 
@@ -206,7 +209,7 @@ var SearchBar = /*#__PURE__*/forwardRef(function (_ref5, ref) {
206
209
  return /*#__PURE__*/React.createElement(Paper, _extends({
207
210
  component: "form",
208
211
  elevation: elevation ? 1 : 0,
209
- className: cx(className, classes.root, (_cx = {}, _defineProperty(_cx, classes.flat, !elevation), _defineProperty(_cx, classes.elevation, elevation), _defineProperty(_cx, classes.focused, isFocused), _defineProperty(_cx, classes.disabled, disabled), _cx)),
212
+ className: cx(className, classes.root, (_cx = {}, _defineProperty(_cx, classes.flat, !elevation), _defineProperty(_cx, classes.elevation, elevation), _defineProperty(_cx, classes.focused, isFocused && !disabledFocus), _defineProperty(_cx, classes.disabled, disabled), _cx)),
210
213
  ref: ref
211
214
  }, props), type === 'button' ? /*#__PURE__*/React.createElement(ButtonBase, {
212
215
  className: classes.buttonBase
@@ -245,9 +248,11 @@ SearchBar.defaultProps = {
245
248
  size: 'small',
246
249
  type: 'search',
247
250
  disabledClear: false,
251
+ disabledFocus: false,
248
252
  defaultValue: '',
249
253
  onChange: function onChange() {},
250
254
  onFocus: function onFocus() {},
255
+ onClear: function onClear() {},
251
256
  onBlur: function onBlur() {}
252
257
  };
253
258
  SearchBar.propTypes = {
@@ -266,18 +271,20 @@ SearchBar.propTypes = {
266
271
  /** Used only with self-controlled component */
267
272
  defaultValue: PropTypes.string,
268
273
  disabledClear: PropTypes.bool,
274
+ disabledFocus: PropTypes.bool,
269
275
  elevation: PropTypes.bool,
270
276
  placeholder: PropTypes.string,
271
277
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.object]),
272
278
  disabled: PropTypes.bool,
273
279
  onChange: PropTypes.func,
274
280
  onFocus: PropTypes.func,
281
+ onClear: PropTypes.func,
275
282
  onBlur: PropTypes.func
276
283
  };
277
-
278
- var SearchBarWithLocales = function SearchBarWithLocales(props) {
284
+ var SearchBarWithLocales = /*#__PURE__*/forwardRef(function (props, ref) {
279
285
  useExtendI18n(locales);
280
- return /*#__PURE__*/React.createElement(SearchBar, props);
281
- };
282
-
286
+ return /*#__PURE__*/React.createElement(SearchBar, _extends({}, props, {
287
+ ref: ref
288
+ }));
289
+ });
283
290
  export default SearchBarWithLocales;