@rhc-shared-components/rich-text-editor 0.3.2 → 0.3.3
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 +25 -2
- package/dist/index.modern.js +25 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -123,6 +123,24 @@ var InsertCss$1 = function InsertCss() {
|
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
+
function _extends() {
|
|
127
|
+
_extends = Object.assign || function (target) {
|
|
128
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
129
|
+
var source = arguments[i];
|
|
130
|
+
|
|
131
|
+
for (var key in source) {
|
|
132
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
133
|
+
target[key] = source[key];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return target;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
return _extends.apply(this, arguments);
|
|
142
|
+
}
|
|
143
|
+
|
|
126
144
|
function _objectWithoutPropertiesLoose$1(source, excluded) {
|
|
127
145
|
if (source == null) return {};
|
|
128
146
|
var target = {};
|
|
@@ -212,7 +230,9 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
|
|
|
212
230
|
var _useFormikContext = formik.useFormikContext(),
|
|
213
231
|
isSubmitting = _useFormikContext.isSubmitting,
|
|
214
232
|
setFieldValue = _useFormikContext.setFieldValue,
|
|
215
|
-
validateField = _useFormikContext.validateField
|
|
233
|
+
validateField = _useFormikContext.validateField,
|
|
234
|
+
setTouched = _useFormikContext.setTouched,
|
|
235
|
+
touched = _useFormikContext.touched;
|
|
216
236
|
|
|
217
237
|
var _React$useState = React__namespace.useState(maxLength || 0),
|
|
218
238
|
numberOfCharacters = _React$useState[0],
|
|
@@ -224,7 +244,7 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
|
|
|
224
244
|
}
|
|
225
245
|
}, [value, maxLength]);
|
|
226
246
|
return React__namespace.createElement(FormGroupContainer, {
|
|
227
|
-
validated: meta.error ? reactCore.ValidatedOptions.error : reactCore.ValidatedOptions["default"],
|
|
247
|
+
validated: meta.touched && meta.error ? reactCore.ValidatedOptions.error : reactCore.ValidatedOptions["default"],
|
|
228
248
|
onClick: function onClick() {
|
|
229
249
|
if (editorRef) {
|
|
230
250
|
// @ts-ignore
|
|
@@ -250,6 +270,9 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
|
|
|
250
270
|
validateField(rest.name);
|
|
251
271
|
},
|
|
252
272
|
onBlur: function onBlur(data) {
|
|
273
|
+
var _extends2;
|
|
274
|
+
|
|
275
|
+
setTouched(_extends({}, touched, (_extends2 = {}, _extends2[rest.name] = true, _extends2)));
|
|
253
276
|
setFieldValue(rest.name, data);
|
|
254
277
|
validateField(rest.name);
|
|
255
278
|
}
|
package/dist/index.modern.js
CHANGED
|
@@ -100,6 +100,24 @@ const InsertCss$1 = () => {
|
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
+
function _extends() {
|
|
104
|
+
_extends = Object.assign || function (target) {
|
|
105
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
106
|
+
var source = arguments[i];
|
|
107
|
+
|
|
108
|
+
for (var key in source) {
|
|
109
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
110
|
+
target[key] = source[key];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return target;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return _extends.apply(this, arguments);
|
|
119
|
+
}
|
|
120
|
+
|
|
103
121
|
function _objectWithoutPropertiesLoose$1(source, excluded) {
|
|
104
122
|
if (source == null) return {};
|
|
105
123
|
var target = {};
|
|
@@ -193,7 +211,9 @@ const RichTextEditorFormComponent = _ref => {
|
|
|
193
211
|
const {
|
|
194
212
|
isSubmitting,
|
|
195
213
|
setFieldValue,
|
|
196
|
-
validateField
|
|
214
|
+
validateField,
|
|
215
|
+
setTouched,
|
|
216
|
+
touched
|
|
197
217
|
} = useFormikContext();
|
|
198
218
|
const [numberOfCharacters, setNoOfCharacters] = React.useState(maxLength || 0);
|
|
199
219
|
React.useEffect(() => {
|
|
@@ -202,7 +222,7 @@ const RichTextEditorFormComponent = _ref => {
|
|
|
202
222
|
}
|
|
203
223
|
}, [value, maxLength]);
|
|
204
224
|
return React.createElement(FormGroupContainer, {
|
|
205
|
-
validated: meta.error ? ValidatedOptions.error : ValidatedOptions.default,
|
|
225
|
+
validated: meta.touched && meta.error ? ValidatedOptions.error : ValidatedOptions.default,
|
|
206
226
|
onClick: () => {
|
|
207
227
|
if (editorRef) {
|
|
208
228
|
// @ts-ignore
|
|
@@ -228,6 +248,9 @@ const RichTextEditorFormComponent = _ref => {
|
|
|
228
248
|
validateField(rest.name);
|
|
229
249
|
},
|
|
230
250
|
onBlur: data => {
|
|
251
|
+
setTouched(_extends({}, touched, {
|
|
252
|
+
[rest.name]: true
|
|
253
|
+
}));
|
|
231
254
|
setFieldValue(rest.name, data);
|
|
232
255
|
validateField(rest.name);
|
|
233
256
|
}
|