@rhc-shared-components/rich-text-editor 0.3.2 → 0.3.5
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 +7 -8
- package/dist/index.modern.js +8 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -204,15 +204,15 @@ 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);
|
|
211
212
|
|
|
212
213
|
var _useFormikContext = formik.useFormikContext(),
|
|
213
214
|
isSubmitting = _useFormikContext.isSubmitting,
|
|
214
|
-
setFieldValue = _useFormikContext.setFieldValue
|
|
215
|
-
validateField = _useFormikContext.validateField;
|
|
215
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
216
216
|
|
|
217
217
|
var _React$useState = React__namespace.useState(maxLength || 0),
|
|
218
218
|
numberOfCharacters = _React$useState[0],
|
|
@@ -224,7 +224,7 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
|
|
|
224
224
|
}
|
|
225
225
|
}, [value, maxLength]);
|
|
226
226
|
return React__namespace.createElement(FormGroupContainer, {
|
|
227
|
-
validated: meta.error ? reactCore.ValidatedOptions.error : reactCore.ValidatedOptions["default"],
|
|
227
|
+
validated: meta.touched && meta.error ? reactCore.ValidatedOptions.error : reactCore.ValidatedOptions["default"],
|
|
228
228
|
onClick: function onClick() {
|
|
229
229
|
if (editorRef) {
|
|
230
230
|
// @ts-ignore
|
|
@@ -246,12 +246,11 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
|
|
|
246
246
|
},
|
|
247
247
|
disabled: disabled || isSubmitting,
|
|
248
248
|
onChange: function onChange(data) {
|
|
249
|
-
setFieldValue(rest.name, data);
|
|
250
|
-
validateField(rest.name);
|
|
249
|
+
setFieldValue(rest.name, data, true);
|
|
251
250
|
},
|
|
252
251
|
onBlur: function onBlur(data) {
|
|
253
|
-
setFieldValue(rest.name, data);
|
|
254
|
-
|
|
252
|
+
setFieldValue(rest.name, data, true);
|
|
253
|
+
setTouched(true);
|
|
255
254
|
}
|
|
256
255
|
}), showMaxLengthText && React__namespace.createElement("div", {
|
|
257
256
|
"data-testid": 'formTextAreaMaxLengthText',
|
package/dist/index.modern.js
CHANGED
|
@@ -183,7 +183,9 @@ const RichTextEditorFormComponent = _ref => {
|
|
|
183
183
|
} = _ref,
|
|
184
184
|
rest = _objectWithoutPropertiesLoose$1(_ref, _excluded);
|
|
185
185
|
|
|
186
|
-
const [, meta
|
|
186
|
+
const [, meta, {
|
|
187
|
+
setTouched
|
|
188
|
+
}] = useField({
|
|
187
189
|
name: rest.name
|
|
188
190
|
});
|
|
189
191
|
const {
|
|
@@ -192,8 +194,7 @@ const RichTextEditorFormComponent = _ref => {
|
|
|
192
194
|
const editorRef = React.useRef(null);
|
|
193
195
|
const {
|
|
194
196
|
isSubmitting,
|
|
195
|
-
setFieldValue
|
|
196
|
-
validateField
|
|
197
|
+
setFieldValue
|
|
197
198
|
} = useFormikContext();
|
|
198
199
|
const [numberOfCharacters, setNoOfCharacters] = React.useState(maxLength || 0);
|
|
199
200
|
React.useEffect(() => {
|
|
@@ -202,7 +203,7 @@ const RichTextEditorFormComponent = _ref => {
|
|
|
202
203
|
}
|
|
203
204
|
}, [value, maxLength]);
|
|
204
205
|
return React.createElement(FormGroupContainer, {
|
|
205
|
-
validated: meta.error ? ValidatedOptions.error : ValidatedOptions.default,
|
|
206
|
+
validated: meta.touched && meta.error ? ValidatedOptions.error : ValidatedOptions.default,
|
|
206
207
|
onClick: () => {
|
|
207
208
|
if (editorRef) {
|
|
208
209
|
// @ts-ignore
|
|
@@ -224,12 +225,11 @@ const RichTextEditorFormComponent = _ref => {
|
|
|
224
225
|
},
|
|
225
226
|
disabled: disabled || isSubmitting,
|
|
226
227
|
onChange: data => {
|
|
227
|
-
setFieldValue(rest.name, data);
|
|
228
|
-
validateField(rest.name);
|
|
228
|
+
setFieldValue(rest.name, data, true);
|
|
229
229
|
},
|
|
230
230
|
onBlur: data => {
|
|
231
|
-
setFieldValue(rest.name, data);
|
|
232
|
-
|
|
231
|
+
setFieldValue(rest.name, data, true);
|
|
232
|
+
setTouched(true);
|
|
233
233
|
}
|
|
234
234
|
}), showMaxLengthText && React.createElement("div", {
|
|
235
235
|
"data-testid": 'formTextAreaMaxLengthText',
|