@rhc-shared-components/rich-text-editor 0.3.1 → 0.3.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/dist/index.js CHANGED
@@ -204,7 +204,8 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
204
204
  var _useField = formik.useField({
205
205
  name: rest.name
206
206
  }),
207
- meta = _useField[1];
207
+ meta = _useField[1],
208
+ setTouched = _useField[2].setTouched;
208
209
 
209
210
  var value = meta.value;
210
211
  var editorRef = React__namespace.useRef(null);
@@ -219,10 +220,12 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
219
220
  setNoOfCharacters = _React$useState[1];
220
221
 
221
222
  React__namespace.useEffect(function () {
222
- setNoOfCharacters(value && value.length && maxLength ? maxLength - value.length : 0);
223
+ if (maxLength) {
224
+ setNoOfCharacters(value && value.length ? maxLength - value.length : maxLength);
225
+ }
223
226
  }, [value, maxLength]);
224
227
  return React__namespace.createElement(FormGroupContainer, {
225
- validated: meta.error ? reactCore.ValidatedOptions.error : reactCore.ValidatedOptions["default"],
228
+ validated: meta.touched && meta.error ? reactCore.ValidatedOptions.error : reactCore.ValidatedOptions["default"],
226
229
  onClick: function onClick() {
227
230
  if (editorRef) {
228
231
  // @ts-ignore
@@ -248,6 +251,7 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
248
251
  validateField(rest.name);
249
252
  },
250
253
  onBlur: function onBlur(data) {
254
+ setTouched(true);
251
255
  setFieldValue(rest.name, data);
252
256
  validateField(rest.name);
253
257
  }
@@ -183,7 +183,9 @@ const RichTextEditorFormComponent = _ref => {
183
183
  } = _ref,
184
184
  rest = _objectWithoutPropertiesLoose$1(_ref, _excluded);
185
185
 
186
- const [, meta] = useField({
186
+ const [, meta, {
187
+ setTouched
188
+ }] = useField({
187
189
  name: rest.name
188
190
  });
189
191
  const {
@@ -197,10 +199,12 @@ const RichTextEditorFormComponent = _ref => {
197
199
  } = useFormikContext();
198
200
  const [numberOfCharacters, setNoOfCharacters] = React.useState(maxLength || 0);
199
201
  React.useEffect(() => {
200
- setNoOfCharacters(value && value.length && maxLength ? maxLength - value.length : 0);
202
+ if (maxLength) {
203
+ setNoOfCharacters(value && value.length ? maxLength - value.length : maxLength);
204
+ }
201
205
  }, [value, maxLength]);
202
206
  return React.createElement(FormGroupContainer, {
203
- validated: meta.error ? ValidatedOptions.error : ValidatedOptions.default,
207
+ validated: meta.touched && meta.error ? ValidatedOptions.error : ValidatedOptions.default,
204
208
  onClick: () => {
205
209
  if (editorRef) {
206
210
  // @ts-ignore
@@ -226,6 +230,7 @@ const RichTextEditorFormComponent = _ref => {
226
230
  validateField(rest.name);
227
231
  },
228
232
  onBlur: data => {
233
+ setTouched(true);
229
234
  setFieldValue(rest.name, data);
230
235
  validateField(rest.name);
231
236
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhc-shared-components/rich-text-editor",
3
- "version": "0.3.1",
3
+ "version": "0.3.4",
4
4
  "description": "WYSWYG Editor for Red Hat Certified Apps",
5
5
  "author": "gautamkrishnar",
6
6
  "license": "MIT",