@desynova-digital/components 9.0.9 → 9.0.10

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.
@@ -60,7 +60,8 @@ var DraftInputText = function DraftInputText(_ref) {
60
60
  label = _ref.label,
61
61
  value = _ref.value,
62
62
  autoFocus = _ref.autoFocus,
63
- props = _objectWithoutProperties(_ref, ['maxLength', 'defaultValue', 'type', 'showLengthCount', 'label', 'value', 'autoFocus']);
63
+ isFocused = _ref.isFocused,
64
+ props = _objectWithoutProperties(_ref, ['maxLength', 'defaultValue', 'type', 'showLengthCount', 'label', 'value', 'autoFocus', 'isFocused']);
64
65
 
65
66
  var _useState = (0, _react.useState)(true),
66
67
  _useState2 = _slicedToArray(_useState, 2),
@@ -242,7 +243,9 @@ var DraftInputText = function DraftInputText(_ref) {
242
243
  return match === '<em>' ? '<i>' : '</i>';
243
244
  });
244
245
  };
245
-
246
+ /**
247
+ * this useEffect is used to send value to parent component as soon as editor state gets updated
248
+ */
246
249
  (0, _react.useEffect)(function () {
247
250
  var html = (0, _draftConvert.convertToHTML)(editorState.getCurrentContent());
248
251
  html = removeOuterPTag(html);
@@ -256,6 +259,9 @@ var DraftInputText = function DraftInputText(_ref) {
256
259
  }
257
260
  }, [editorState]);
258
261
 
262
+ /**
263
+ * This useEffect handles our focus condition and also updates state when the props value changes
264
+ */
259
265
  (0, _react.useEffect)(function () {
260
266
  if (diff && value !== '' && value !== undefined) {
261
267
  props.simpleEdit = true;
@@ -263,12 +269,19 @@ var DraftInputText = function DraftInputText(_ref) {
263
269
  setFocus(true);
264
270
  var dummy = (0, _draftConvert.convertFromHTML)(value);
265
271
  var newState = _draftJs.EditorState.createWithContent(dummy);
266
- setEditorState(function () {
267
- return _draftJs.EditorState.moveFocusToEnd(newState);
268
- });
272
+ if (isFocused) {
273
+ setEditorState(function () {
274
+ return _draftJs.EditorState.moveFocusToEnd(newState);
275
+ });
276
+ } else {
277
+ setEditorState(newState);
278
+ }
269
279
  }
270
280
  }, [value]);
271
281
 
282
+ /**
283
+ * This useEffect is used to chnage our value when timeline is changed
284
+ */
272
285
  (0, _react.useEffect)(function () {
273
286
  if (listScrollTop !== null) {
274
287
  if (!props.simpleEdit) {
@@ -281,11 +294,16 @@ var DraftInputText = function DraftInputText(_ref) {
281
294
  }
282
295
  }, [listScrollTop]);
283
296
 
297
+ /**
298
+ * This useEffect is used to focus on Line1 when a new segment is created
299
+ */
300
+
284
301
  (0, _react.useEffect)(function () {
285
302
  if (autoFocus) {
286
303
  editorRef.current.focus();
287
304
  }
288
305
  }, [autoFocus]);
306
+
289
307
  return _react2.default.createElement(
290
308
  DraftInputTextDiv,
291
309
  { theme: props.theme, inputWidth: props.inputWidth },
@@ -424,11 +442,13 @@ DraftInputText.propTypes = {
424
442
  showLengthCount: _propTypes2.default.bool,
425
443
  simpleEdit: _propTypes2.default.bool,
426
444
  autoFocus: _propTypes2.default.bool,
445
+ isFocused: _propTypes2.default.bool,
427
446
  theme: _propTypes2.default.oneOf(['light', 'dark', 'nexc']),
428
447
  fieldType: _propTypes2.default.oneOf(['inputField', 'textArea'])
429
448
  };
430
449
 
431
450
  DraftInputText.defaultProps = {
451
+ isFocused: false,
432
452
  autoFocus: false,
433
453
  fieldType: 'textArea',
434
454
  readOnly: false,
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@desynova-digital/components",
3
- "version": "9.0.9",
3
+ "version": "9.0.10",
4
4
  "description": "Components for Desynova Digital",
5
5
  "main": "index.js",
6
6
  "author": "desynova-digital",
7
7
  "license": "MIT",
8
8
  "repository": "desynova-digital",
9
9
  "dependencies": {
10
- "@desynova-digital/tokens": "9.0.9",
10
+ "@desynova-digital/tokens": "9.0.10",
11
11
  "prop-types": "^15.7.2",
12
12
  "styled-components": "^4.3.2"
13
13
  },