@commercetools-uikit/rich-text-input 13.0.2 → 14.0.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.
@@ -2,7 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
6
5
  var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
7
6
  var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
8
7
  var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
@@ -11,17 +10,17 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/in
11
10
  var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
12
11
  var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
13
12
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
14
- var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
13
+ var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
15
14
  var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
16
15
  var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
17
16
  var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
18
17
  var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
19
18
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
19
+ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
20
+ require('prop-types');
20
21
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
21
22
  var _setTimeout = require('@babel/runtime-corejs3/core-js-stable/set-timeout');
22
23
  var react = require('react');
23
- require('prop-types');
24
- require('react-required-if');
25
24
  var slateReact = require('slate-react');
26
25
  var pick = require('lodash/pick');
27
26
  var utils = require('@commercetools-uikit/utils');
@@ -40,7 +39,6 @@ var jsxRuntime = require('@emotion/react/jsx-runtime');
40
39
 
41
40
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
42
41
 
43
- var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
44
42
  var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
45
43
  var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
46
44
  var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
@@ -49,6 +47,7 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
49
47
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
50
48
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
51
49
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
50
+ var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
52
51
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
53
52
  var _setTimeout__default = /*#__PURE__*/_interopDefault(_setTimeout);
54
53
  var pick__default = /*#__PURE__*/_interopDefault(pick);
@@ -58,11 +57,10 @@ var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
58
57
  var FlatButton__default = /*#__PURE__*/_interopDefault(FlatButton);
59
58
  var _styled__default = /*#__PURE__*/_interopDefault(_styled);
60
59
 
61
- /* eslint-disable import/prefer-default-export */
62
60
  var EditorWrapper = _styled__default["default"]("div", {
63
- target: "e125ents0"
61
+ target: "e1d53kc50"
64
62
  } )("align-self:stretch;cursor:", function (props) {
65
- return props.isDisabled ? 'not-allowed' : 'inherit';
63
+ return props.isDisabled || props.isReadOnly ? 'not-allowed' : 'inherit';
66
64
  }, ";" + ("" ));
67
65
 
68
66
  function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -70,9 +68,9 @@ function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["d
70
68
  function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
71
69
  var COLLAPSED_HEIGHT = 32;
72
70
 
73
- var Editor = function Editor(props) {
71
+ var Editor$1 = function Editor(props) {
74
72
  var intl = reactIntl.useIntl();
75
- var ref = react.useRef();
73
+ var ref = react.useRef(null);
76
74
  var prevIsFocused = hooks.usePrevious(props.editor.value.selection.isFocused);
77
75
 
78
76
  var _useState = react.useState(false),
@@ -81,7 +79,9 @@ var Editor = function Editor(props) {
81
79
  setRenderToggleButton = _useState2[1];
82
80
 
83
81
  var updateRenderToggleButton = react.useCallback(function () {
84
- var doesExceedCollapsedHeightLimit = ref.current.clientHeight > COLLAPSED_HEIGHT;
82
+ var _ref$current;
83
+
84
+ var doesExceedCollapsedHeightLimit = Number((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.clientHeight) > COLLAPSED_HEIGHT;
85
85
 
86
86
  if (doesExceedCollapsedHeightLimit && !renderToggleButton) {
87
87
  setRenderToggleButton(true);
@@ -108,6 +108,10 @@ var Editor = function Editor(props) {
108
108
  toggle();
109
109
  }
110
110
 
111
+ var refObj = {
112
+ containerRef: ref,
113
+ registerContentNode: registerContentNode
114
+ };
111
115
  return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
112
116
  max: props.horizontalConstraint,
113
117
  children: jsxRuntime.jsxs(Stack__default["default"], {
@@ -117,22 +121,18 @@ var Editor = function Editor(props) {
117
121
  isDisabled: props.isDisabled,
118
122
  isReadOnly: props.isReadOnly,
119
123
  children: jsxRuntime.jsx(richTextUtils.RichTextBody, {
120
- ref: {
121
- containerRef: ref,
122
- registerContentNode: registerContentNode
123
- },
124
+ ref: refObj,
124
125
  hasError: props.hasError,
125
126
  isDisabled: props.isDisabled,
126
127
  hasWarning: props.hasWarning,
127
- isReadOnly: props.isReadOnly,
128
- showExpandIcon: props.showExpandIcon,
128
+ isReadOnly: Boolean(props.isReadOnly),
129
+ showExpandIcon: Boolean(props.showExpandIcon),
129
130
  onClickExpand: props.onClickExpand,
130
131
  editor: props.editor,
131
132
  containerStyles: containerStyles,
132
133
  children: props.children
133
134
  })
134
- }), renderToggleButton && // <div>
135
- jsxRuntime.jsx(FlatButton__default["default"], {
135
+ }), renderToggleButton && jsxRuntime.jsx(FlatButton__default["default"], {
136
136
  onClick: toggle,
137
137
  label: isOpen ? intl.formatMessage(inputUtils.messagesMultilineInput.collapse) : intl.formatMessage(inputUtils.messagesMultilineInput.expand),
138
138
  icon: isOpen ? jsxRuntime.jsx(icons.AngleUpIcon, {
@@ -140,14 +140,14 @@ var Editor = function Editor(props) {
140
140
  }) : jsxRuntime.jsx(icons.AngleDownIcon, {
141
141
  size: "small"
142
142
  })
143
- }) // </div>
144
- ]
143
+ })]
145
144
  })
146
145
  });
147
146
  }
148
147
  });
149
- }; // eslint-disable-next-line react/display-name
148
+ };
150
149
 
150
+ Editor$1.propTypes = {};
151
151
 
152
152
  var renderEditor = function renderEditor(props, editor, next) {
153
153
  var internalId = "".concat(props.id, "__internal__id");
@@ -159,11 +159,11 @@ var renderEditor = function renderEditor(props, editor, next) {
159
159
  var passedProps = _objectSpread$1(_objectSpread$1({
160
160
  name: props.name,
161
161
  id: props.id,
162
- isReadOnly: props.readOnly,
163
- isDisabled: props.disabled
162
+ isReadOnly: Boolean(props.readOnly),
163
+ isDisabled: Boolean(props.disabled)
164
164
  }, pick__default["default"](props.options, ['horizontalConstraint', 'defaultExpandMultilineText', 'showExpandIcon', 'onClickExpand', 'hasError', 'hasWarning'])), utils.filterDataAttributes(props));
165
165
 
166
- return jsxRuntime.jsxs(Editor, _objectSpread$1(_objectSpread$1({
166
+ return jsxRuntime.jsxs(Editor$1, _objectSpread$1(_objectSpread$1({
167
167
  editor: editor
168
168
  }, passedProps), {}, {
169
169
  children: [children, jsxRuntime.jsx(richTextUtils.HiddenInput, {
@@ -171,22 +171,29 @@ var renderEditor = function renderEditor(props, editor, next) {
171
171
  handleFocus: editor.focus,
172
172
  id: props.id,
173
173
  disabled: props.disabled,
174
- readOnly: props.readOnly
174
+ readOnly: Boolean(props.readOnly)
175
175
  })]
176
176
  }));
177
177
  };
178
- Editor.displayName = 'Editor';
179
- Editor.propTypes = {};
180
- renderEditor.propTypes = {};
178
+
179
+ Editor$1.displayName = 'Editor';
181
180
  var renderEditor$1 = renderEditor;
182
181
 
182
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
183
+
184
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
185
+
183
186
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
184
187
 
185
188
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
186
189
 
187
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
190
+ // This is a temporary wrapper component helping to mitigate typing issues of `slate-react@0.22.10` package.
191
+ // TODO: remove after upgrade of `slate-react` to the latest version
192
+ var Editor = function Editor(props) {
193
+ return jsxRuntime.jsx(slateReact.Editor, _objectSpread({}, props));
194
+ };
188
195
 
189
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
196
+ Editor.propTypes = {};
190
197
 
191
198
  var RichTextInput = /*#__PURE__*/function (_PureComponent) {
192
199
  _inherits(RichTextInput, _PureComponent);
@@ -205,7 +212,7 @@ var RichTextInput = /*#__PURE__*/function (_PureComponent) {
205
212
  }
206
213
 
207
214
  _this = _super.call.apply(_super, _concatInstanceProperty__default["default"](_context = [this]).call(_context, args));
208
- _this.serializedValue = _this.props.value || '';
215
+ _this.serializedValue = _this.props.value;
209
216
  _this.internalSlateValue = richTextUtils.html.deserialize(_this.props.value || '');
210
217
 
211
218
  _this.onValueChange = function (event) {
@@ -222,6 +229,8 @@ var RichTextInput = /*#__PURE__*/function (_PureComponent) {
222
229
  // onChange unless this value changes.
223
230
 
224
231
  if (hasSerializedValueChanged) {
232
+ var _this$props$onChange, _this$props;
233
+
225
234
  var fakeEvent = {
226
235
  target: {
227
236
  id: _this.props.id,
@@ -229,8 +238,7 @@ var RichTextInput = /*#__PURE__*/function (_PureComponent) {
229
238
  value: serializedValue
230
239
  }
231
240
  };
232
-
233
- _this.props.onChange(fakeEvent);
241
+ (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, fakeEvent);
234
242
  }
235
243
 
236
244
  if (hasInternalSlateValueChanged && !hasSerializedValueChanged) {
@@ -239,7 +247,7 @@ var RichTextInput = /*#__PURE__*/function (_PureComponent) {
239
247
  }
240
248
  };
241
249
 
242
- _this.onBlur = function (event, editor, next) {
250
+ _this.onBlur = function (_event, _editor, next) {
243
251
  next();
244
252
 
245
253
  if (_this.props.onBlur) {
@@ -251,12 +259,14 @@ var RichTextInput = /*#__PURE__*/function (_PureComponent) {
251
259
  };
252
260
 
253
261
  _setTimeout__default["default"](function () {
254
- return _this.props.onBlur(fakeEvent);
262
+ var _this$props$onBlur, _this$props2;
263
+
264
+ return (_this$props$onBlur = (_this$props2 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props2, fakeEvent);
255
265
  }, 0);
256
266
  }
257
267
  };
258
268
 
259
- _this.onFocus = function (event, editor, next) {
269
+ _this.onFocus = function (_event, _editor, next) {
260
270
  next();
261
271
 
262
272
  if (_this.props.onFocus) {
@@ -268,7 +278,9 @@ var RichTextInput = /*#__PURE__*/function (_PureComponent) {
268
278
  };
269
279
 
270
280
  _setTimeout__default["default"](function () {
271
- return _this.props.onFocus(fakeEvent);
281
+ var _this$props$onFocus, _this$props3;
282
+
283
+ return (_this$props$onFocus = (_this$props3 = _this.props).onFocus) === null || _this$props$onFocus === void 0 ? void 0 : _this$props$onFocus.call(_this$props3, fakeEvent);
272
284
  }, 0);
273
285
  }
274
286
  };
@@ -288,15 +300,20 @@ var RichTextInput = /*#__PURE__*/function (_PureComponent) {
288
300
  // can understand, save this value to our class variable, and forceUpdate
289
301
  // this keeps the component in sync.
290
302
  if (this.props.value !== this.serializedValue) {
291
- this.internalSlateValue = richTextUtils.html.deserialize(this.props.value);
292
- this.serializedValue = this.props.value;
303
+ var value = this.props.value || '';
304
+ this.internalSlateValue = richTextUtils.html.deserialize(value);
305
+ this.serializedValue = value;
293
306
  this.forceUpdate();
294
307
  }
295
308
  }
296
309
  }, {
297
310
  key: "render",
298
311
  value: function render() {
299
- return jsxRuntime.jsx(slateReact.Editor, _objectSpread(_objectSpread({}, utils.filterDataAttributes(this.props)), {}, {
312
+ if (!this.props.isReadOnly) ;
313
+
314
+ if (this.props.showExpandIcon) ;
315
+
316
+ return jsxRuntime.jsx(Editor, _objectSpread(_objectSpread({}, utils.filterDataAttributes(this.props)), {}, {
300
317
  autoFocus: this.props.isAutofocussed,
301
318
  id: this.props.id,
302
319
  name: this.props.name,
@@ -336,7 +353,7 @@ RichTextInput.propTypes = {};
336
353
  var RichTextInput$1 = RichTextInput;
337
354
 
338
355
  // NOTE: This string will be replaced on build time with the package version.
339
- var version = "13.0.2";
356
+ var version = "14.0.0";
340
357
 
341
358
  exports["default"] = RichTextInput$1;
342
359
  exports.version = version;
@@ -1,4 +1,3 @@
1
- import _Reflect$construct from '@babel/runtime-corejs3/core-js-stable/reflect/construct';
2
1
  import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
3
2
  import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
4
3
  import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
@@ -7,20 +6,20 @@ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/inst
7
6
  import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
8
7
  import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
9
8
  import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
10
- import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
9
+ import _Reflect$construct from '@babel/runtime-corejs3/core-js-stable/reflect/construct';
11
10
  import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
12
11
  import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
13
12
  import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
14
13
  import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
15
14
  import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
15
+ import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
16
+ import _pt from 'prop-types';
16
17
  import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
17
18
  import _setTimeout from '@babel/runtime-corejs3/core-js-stable/set-timeout';
18
19
  import { cloneElement, useRef, useState, useCallback, useEffect, PureComponent } from 'react';
19
- import PropTypes from 'prop-types';
20
- import requiredIf from 'react-required-if';
21
- import { Editor as Editor$1 } from 'slate-react';
20
+ import { Editor as Editor$2 } from 'slate-react';
22
21
  import pick from 'lodash/pick';
23
- import { filterDataAttributes } from '@commercetools-uikit/utils';
22
+ import { filterDataAttributes, warning } from '@commercetools-uikit/utils';
24
23
  import { HiddenInput, RichTextBody, html, richTextPlugins, isEmpty } from '@commercetools-uikit/rich-text-utils';
25
24
  import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
26
25
  import { useIntl } from 'react-intl';
@@ -34,24 +33,23 @@ import { messagesMultilineInput } from '@commercetools-uikit/input-utils';
34
33
  import _styled from '@emotion/styled/base';
35
34
  import { jsxs, jsx } from '@emotion/react/jsx-runtime';
36
35
 
37
- /* eslint-disable import/prefer-default-export */
38
36
  var EditorWrapper = _styled("div", process.env.NODE_ENV === "production" ? {
39
- target: "e125ents0"
37
+ target: "e1d53kc50"
40
38
  } : {
41
- target: "e125ents0",
39
+ target: "e1d53kc50",
42
40
  label: "EditorWrapper"
43
41
  })("align-self:stretch;cursor:", function (props) {
44
- return props.isDisabled ? 'not-allowed' : 'inherit';
45
- }, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImVkaXRvci5zdHlsZXMuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR2dDIiwiZmlsZSI6ImVkaXRvci5zdHlsZXMuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvKiBlc2xpbnQtZGlzYWJsZSBpbXBvcnQvcHJlZmVyLWRlZmF1bHQtZXhwb3J0ICovXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG5cbmNvbnN0IEVkaXRvcldyYXBwZXIgPSBzdHlsZWQuZGl2YFxuICBhbGlnbi1zZWxmOiBzdHJldGNoO1xuICBjdXJzb3I6ICR7KHByb3BzKSA9PiAocHJvcHMuaXNEaXNhYmxlZCA/ICdub3QtYWxsb3dlZCcgOiAnaW5oZXJpdCcpfTtcbmA7XG5cbmV4cG9ydCB7IEVkaXRvcldyYXBwZXIgfTtcbiJdfQ== */"));
42
+ return props.isDisabled || props.isReadOnly ? 'not-allowed' : 'inherit';
43
+ }, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImVkaXRvci5zdHlsZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBS3FEIiwiZmlsZSI6ImVkaXRvci5zdHlsZXMudHMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG5pbXBvcnQgdHlwZSB7IFRFZGl0b3JQcm9wcyB9IGZyb20gJy4vZWRpdG9yJztcblxudHlwZSBURWRpdG9yV3JhcHBlclByb3BzID0gUGljazxURWRpdG9yUHJvcHMsICdpc0Rpc2FibGVkJyB8ICdpc1JlYWRPbmx5Jz47XG5cbmNvbnN0IEVkaXRvcldyYXBwZXIgPSBzdHlsZWQuZGl2PFRFZGl0b3JXcmFwcGVyUHJvcHM+YFxuICBhbGlnbi1zZWxmOiBzdHJldGNoO1xuICBjdXJzb3I6ICR7KHByb3BzKSA9PlxuICAgIHByb3BzLmlzRGlzYWJsZWQgfHwgcHJvcHMuaXNSZWFkT25seSA/ICdub3QtYWxsb3dlZCcgOiAnaW5oZXJpdCd9O1xuYDtcblxuZXhwb3J0IHsgRWRpdG9yV3JhcHBlciB9O1xuIl19 */"));
46
44
 
47
45
  function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
48
46
 
49
47
  function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys$1(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys$1(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
50
48
  var COLLAPSED_HEIGHT = 32;
51
49
 
52
- var Editor = function Editor(props) {
50
+ var Editor$1 = function Editor(props) {
53
51
  var intl = useIntl();
54
- var ref = useRef();
52
+ var ref = useRef(null);
55
53
  var prevIsFocused = usePrevious(props.editor.value.selection.isFocused);
56
54
 
57
55
  var _useState = useState(false),
@@ -60,7 +58,9 @@ var Editor = function Editor(props) {
60
58
  setRenderToggleButton = _useState2[1];
61
59
 
62
60
  var updateRenderToggleButton = useCallback(function () {
63
- var doesExceedCollapsedHeightLimit = ref.current.clientHeight > COLLAPSED_HEIGHT;
61
+ var _ref$current;
62
+
63
+ var doesExceedCollapsedHeightLimit = Number((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.clientHeight) > COLLAPSED_HEIGHT;
64
64
 
65
65
  if (doesExceedCollapsedHeightLimit && !renderToggleButton) {
66
66
  setRenderToggleButton(true);
@@ -87,6 +87,10 @@ var Editor = function Editor(props) {
87
87
  toggle();
88
88
  }
89
89
 
90
+ var refObj = {
91
+ containerRef: ref,
92
+ registerContentNode: registerContentNode
93
+ };
90
94
  return jsx(Constraints.Horizontal, {
91
95
  max: props.horizontalConstraint,
92
96
  children: jsxs(Stack, {
@@ -96,22 +100,18 @@ var Editor = function Editor(props) {
96
100
  isDisabled: props.isDisabled,
97
101
  isReadOnly: props.isReadOnly,
98
102
  children: jsx(RichTextBody, {
99
- ref: {
100
- containerRef: ref,
101
- registerContentNode: registerContentNode
102
- },
103
+ ref: refObj,
103
104
  hasError: props.hasError,
104
105
  isDisabled: props.isDisabled,
105
106
  hasWarning: props.hasWarning,
106
- isReadOnly: props.isReadOnly,
107
- showExpandIcon: props.showExpandIcon,
107
+ isReadOnly: Boolean(props.isReadOnly),
108
+ showExpandIcon: Boolean(props.showExpandIcon),
108
109
  onClickExpand: props.onClickExpand,
109
110
  editor: props.editor,
110
111
  containerStyles: containerStyles,
111
112
  children: props.children
112
113
  })
113
- }), renderToggleButton && // <div>
114
- jsx(FlatButton, {
114
+ }), renderToggleButton && jsx(FlatButton, {
115
115
  onClick: toggle,
116
116
  label: isOpen ? intl.formatMessage(messagesMultilineInput.collapse) : intl.formatMessage(messagesMultilineInput.expand),
117
117
  icon: isOpen ? jsx(AngleUpIcon, {
@@ -119,14 +119,30 @@ var Editor = function Editor(props) {
119
119
  }) : jsx(AngleDownIcon, {
120
120
  size: "small"
121
121
  })
122
- }) // </div>
123
- ]
122
+ })]
124
123
  })
125
124
  });
126
125
  }
127
126
  });
128
- }; // eslint-disable-next-line react/display-name
127
+ };
129
128
 
129
+ Editor$1.propTypes = process.env.NODE_ENV !== "production" ? {
130
+ editor: _pt.any.isRequired,
131
+ id: _pt.string,
132
+ name: _pt.string,
133
+ placeholder: _pt.string,
134
+ disabled: _pt.bool,
135
+ readOnly: _pt.bool,
136
+ horizontalConstraint: _pt.oneOf([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
137
+ children: _pt.node,
138
+ isDisabled: _pt.bool,
139
+ isReadOnly: _pt.bool,
140
+ showExpandIcon: _pt.bool.isRequired,
141
+ onClickExpand: _pt.func,
142
+ hasWarning: _pt.bool,
143
+ hasError: _pt.bool,
144
+ defaultExpandMultilineText: _pt.bool
145
+ } : {};
130
146
 
131
147
  var renderEditor = function renderEditor(props, editor, next) {
132
148
  var internalId = "".concat(props.id, "__internal__id");
@@ -138,11 +154,11 @@ var renderEditor = function renderEditor(props, editor, next) {
138
154
  var passedProps = _objectSpread$1(_objectSpread$1({
139
155
  name: props.name,
140
156
  id: props.id,
141
- isReadOnly: props.readOnly,
142
- isDisabled: props.disabled
157
+ isReadOnly: Boolean(props.readOnly),
158
+ isDisabled: Boolean(props.disabled)
143
159
  }, pick(props.options, ['horizontalConstraint', 'defaultExpandMultilineText', 'showExpandIcon', 'onClickExpand', 'hasError', 'hasWarning'])), filterDataAttributes(props));
144
160
 
145
- return jsxs(Editor, _objectSpread$1(_objectSpread$1({
161
+ return jsxs(Editor$1, _objectSpread$1(_objectSpread$1({
146
162
  editor: editor
147
163
  }, passedProps), {}, {
148
164
  children: [children, jsx(HiddenInput, {
@@ -150,38 +166,40 @@ var renderEditor = function renderEditor(props, editor, next) {
150
166
  handleFocus: editor.focus,
151
167
  id: props.id,
152
168
  disabled: props.disabled,
153
- readOnly: props.readOnly
169
+ readOnly: Boolean(props.readOnly)
154
170
  })]
155
171
  }));
156
172
  };
157
173
 
158
- var sharedProps = process.env.NODE_ENV !== "production" ? {
159
- id: PropTypes.string,
160
- name: PropTypes.string,
161
- placeholder: PropTypes.string,
162
- disabled: PropTypes.bool,
163
- readOnly: PropTypes.bool,
164
- horizontalConstraint: PropTypes.oneOf([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'])
165
- } : {};
166
- Editor.displayName = 'Editor';
167
- Editor.propTypes = process.env.NODE_ENV !== "production" ? _objectSpread$1(_objectSpread$1({}, sharedProps), {}, {
168
- editor: PropTypes.any
169
- }) : {};
170
- renderEditor.propTypes = process.env.NODE_ENV !== "production" ? _objectSpread$1(_objectSpread$1({}, sharedProps), {}, {
171
- options: PropTypes.shape({
172
- hasWarning: PropTypes.bool,
173
- hasError: PropTypes.bool
174
- })
175
- }) : {};
174
+ Editor$1.displayName = 'Editor';
176
175
  var renderEditor$1 = renderEditor;
177
176
 
177
+ 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); }; }
178
+
179
+ 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; } }
180
+
178
181
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
179
182
 
180
183
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
181
184
 
182
- 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); }; }
185
+ // This is a temporary wrapper component helping to mitigate typing issues of `slate-react@0.22.10` package.
186
+ // TODO: remove after upgrade of `slate-react` to the latest version
187
+ var Editor = function Editor(props) {
188
+ return jsx(Editor$2, _objectSpread({}, props));
189
+ };
183
190
 
184
- 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; } }
191
+ Editor.propTypes = process.env.NODE_ENV !== "production" ? {
192
+ autoFocus: _pt.bool,
193
+ id: _pt.string,
194
+ name: _pt.string,
195
+ onFocus: _pt.func,
196
+ onBlur: _pt.func,
197
+ value: _pt.any.isRequired,
198
+ options: _pt.any.isRequired,
199
+ onChange: _pt.func,
200
+ plugins: _pt.any.isRequired,
201
+ renderEditor: _pt.any.isRequired
202
+ } : {};
185
203
 
186
204
  var RichTextInput = /*#__PURE__*/function (_PureComponent) {
187
205
  _inherits(RichTextInput, _PureComponent);
@@ -200,7 +218,7 @@ var RichTextInput = /*#__PURE__*/function (_PureComponent) {
200
218
  }
201
219
 
202
220
  _this = _super.call.apply(_super, _concatInstanceProperty(_context = [this]).call(_context, args));
203
- _this.serializedValue = _this.props.value || '';
221
+ _this.serializedValue = _this.props.value;
204
222
  _this.internalSlateValue = html.deserialize(_this.props.value || '');
205
223
 
206
224
  _this.onValueChange = function (event) {
@@ -217,6 +235,8 @@ var RichTextInput = /*#__PURE__*/function (_PureComponent) {
217
235
  // onChange unless this value changes.
218
236
 
219
237
  if (hasSerializedValueChanged) {
238
+ var _this$props$onChange, _this$props;
239
+
220
240
  var fakeEvent = {
221
241
  target: {
222
242
  id: _this.props.id,
@@ -224,8 +244,7 @@ var RichTextInput = /*#__PURE__*/function (_PureComponent) {
224
244
  value: serializedValue
225
245
  }
226
246
  };
227
-
228
- _this.props.onChange(fakeEvent);
247
+ (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, fakeEvent);
229
248
  }
230
249
 
231
250
  if (hasInternalSlateValueChanged && !hasSerializedValueChanged) {
@@ -234,7 +253,7 @@ var RichTextInput = /*#__PURE__*/function (_PureComponent) {
234
253
  }
235
254
  };
236
255
 
237
- _this.onBlur = function (event, editor, next) {
256
+ _this.onBlur = function (_event, _editor, next) {
238
257
  next();
239
258
 
240
259
  if (_this.props.onBlur) {
@@ -246,12 +265,14 @@ var RichTextInput = /*#__PURE__*/function (_PureComponent) {
246
265
  };
247
266
 
248
267
  _setTimeout(function () {
249
- return _this.props.onBlur(fakeEvent);
268
+ var _this$props$onBlur, _this$props2;
269
+
270
+ return (_this$props$onBlur = (_this$props2 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props2, fakeEvent);
250
271
  }, 0);
251
272
  }
252
273
  };
253
274
 
254
- _this.onFocus = function (event, editor, next) {
275
+ _this.onFocus = function (_event, _editor, next) {
255
276
  next();
256
277
 
257
278
  if (_this.props.onFocus) {
@@ -263,7 +284,9 @@ var RichTextInput = /*#__PURE__*/function (_PureComponent) {
263
284
  };
264
285
 
265
286
  _setTimeout(function () {
266
- return _this.props.onFocus(fakeEvent);
287
+ var _this$props$onFocus, _this$props3;
288
+
289
+ return (_this$props$onFocus = (_this$props3 = _this.props).onFocus) === null || _this$props$onFocus === void 0 ? void 0 : _this$props$onFocus.call(_this$props3, fakeEvent);
267
290
  }, 0);
268
291
  }
269
292
  };
@@ -283,15 +306,24 @@ var RichTextInput = /*#__PURE__*/function (_PureComponent) {
283
306
  // can understand, save this value to our class variable, and forceUpdate
284
307
  // this keeps the component in sync.
285
308
  if (this.props.value !== this.serializedValue) {
286
- this.internalSlateValue = html.deserialize(this.props.value);
287
- this.serializedValue = this.props.value;
309
+ var value = this.props.value || '';
310
+ this.internalSlateValue = html.deserialize(value);
311
+ this.serializedValue = value;
288
312
  this.forceUpdate();
289
313
  }
290
314
  }
291
315
  }, {
292
316
  key: "render",
293
317
  value: function render() {
294
- return jsx(Editor$1, _objectSpread(_objectSpread({}, filterDataAttributes(this.props)), {}, {
318
+ if (!this.props.isReadOnly) {
319
+ process.env.NODE_ENV !== "production" ? warning(typeof this.props.onChange === 'function', 'RichTextInput: "onChange" is required when field is not read only.') : void 0;
320
+ }
321
+
322
+ if (this.props.showExpandIcon) {
323
+ process.env.NODE_ENV !== "production" ? warning(typeof this.props.onClickExpand === 'function', 'RichTextInput: "onClickExpand" is required when showExpandIcon is true') : void 0;
324
+ }
325
+
326
+ return jsx(Editor, _objectSpread(_objectSpread({}, filterDataAttributes(this.props)), {}, {
295
327
  autoFocus: this.props.isAutofocussed,
296
328
  id: this.props.id,
297
329
  name: this.props.name,
@@ -328,30 +360,18 @@ RichTextInput.isTouched = function (touched) {
328
360
  };
329
361
 
330
362
  RichTextInput.propTypes = process.env.NODE_ENV !== "production" ? {
331
- isAutofocussed: PropTypes.bool,
332
- defaultExpandMultilineText: PropTypes.bool,
333
- hasError: PropTypes.bool,
334
- hasWarning: PropTypes.bool,
335
- id: PropTypes.string,
336
- name: PropTypes.string,
337
- placeholder: PropTypes.string.isRequired,
338
- isDisabled: PropTypes.bool,
339
- isReadOnly: PropTypes.bool,
340
- horizontalConstraint: PropTypes.oneOf([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
341
- onChange: requiredIf(PropTypes.func, function (props) {
342
- return !props.isReadOnly;
343
- }),
344
- onFocus: PropTypes.func,
345
- onBlur: PropTypes.func,
346
- value: PropTypes.string,
347
- showExpandIcon: PropTypes.bool.isRequired,
348
- onClickExpand: requiredIf(PropTypes.func, function (props) {
349
- return props.showExpandIcon;
350
- })
363
+ isAutofocussed: _pt.bool,
364
+ id: _pt.string,
365
+ name: _pt.string,
366
+ placeholder: _pt.string,
367
+ onChange: _pt.func,
368
+ onFocus: _pt.func,
369
+ onBlur: _pt.func,
370
+ value: _pt.string
351
371
  } : {};
352
372
  var RichTextInput$1 = RichTextInput;
353
373
 
354
374
  // NOTE: This string will be replaced on build time with the package version.
355
- var version = "13.0.2";
375
+ var version = "14.0.0";
356
376
 
357
377
  export { RichTextInput$1 as default, version };