@rh-support/components 1.1.62 → 1.1.69
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/README.md +2 -0
- package/lib/cjs/SupportFeedbackForm/SupportFeedbackModal.d.ts.map +1 -1
- package/lib/cjs/SupportFeedbackForm/SupportFeedbackModal.js +18 -7
- package/lib/cjs/TextAreaResizable/TextAreaResizable.d.ts.map +1 -1
- package/lib/cjs/TextAreaResizable/TextAreaResizable.js +46 -13
- package/lib/esm/SupportFeedbackForm/SupportFeedbackModal.d.ts.map +1 -1
- package/lib/esm/SupportFeedbackForm/SupportFeedbackModal.js +24 -14
- package/lib/esm/TextAreaResizable/TextAreaResizable.d.ts.map +1 -1
- package/lib/esm/TextAreaResizable/TextAreaResizable.js +12 -11
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SupportFeedbackModal.d.ts","sourceRoot":"","sources":["../../../src/SupportFeedbackForm/SupportFeedbackModal.tsx"],"names":[],"mappings":";AAuBA,UAAU,MAAM;IACZ,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAMD,iBAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SupportFeedbackModal.d.ts","sourceRoot":"","sources":["../../../src/SupportFeedbackForm/SupportFeedbackModal.tsx"],"names":[],"mappings":";AAuBA,UAAU,MAAM;IACZ,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAMD,iBAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,eAqN1C;kBArNQ,oBAAoB;;;AAwN7B,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -119,7 +119,8 @@ function SupportFeedbackModal(props) {
|
|
|
119
119
|
};
|
|
120
120
|
var _c = __read(react_1.useState(formInitState), 2), values = _c[0], setValues = _c[1];
|
|
121
121
|
var _d = useFetch_1.useFetch(hydrajs_1.pcm.sendFeedbackForm, { propgateErrors: true }), request = _d.request, isFetching = _d.isFetching;
|
|
122
|
-
var _e = __read(react_1.useState(
|
|
122
|
+
var _e = __read(react_1.useState(false), 2), isSubmitDisabled = _e[0], setIsSubmitDisabled = _e[1];
|
|
123
|
+
var _f = __read(react_1.useState(true), 2), isSubmitButtonValid = _f[0], setSubmitButtonValid = _f[1];
|
|
123
124
|
react_1.useEffect(function () {
|
|
124
125
|
var valid = true;
|
|
125
126
|
Object.keys(values).forEach(function (key) {
|
|
@@ -127,11 +128,12 @@ function SupportFeedbackModal(props) {
|
|
|
127
128
|
valid = valid && !isEmpty_1.default(values[key]);
|
|
128
129
|
}
|
|
129
130
|
});
|
|
130
|
-
|
|
131
|
+
setSubmitButtonValid(!valid);
|
|
131
132
|
}, [values]);
|
|
132
133
|
// To Handle the Feedback Satisfaction values
|
|
133
134
|
var handleSentimentChange = function (event) {
|
|
134
135
|
var _a;
|
|
136
|
+
setIsSubmitDisabled(false);
|
|
135
137
|
setValues(__assign(__assign({}, values), (_a = {}, _a[event.target.name] = event.target.value, _a)));
|
|
136
138
|
};
|
|
137
139
|
// To Handle the Text Area Input (Feedback Description)
|
|
@@ -145,6 +147,7 @@ function SupportFeedbackModal(props) {
|
|
|
145
147
|
switch (_a.label) {
|
|
146
148
|
case 0:
|
|
147
149
|
event.preventDefault();
|
|
150
|
+
if (!!isSubmitButtonValid) return [3 /*break*/, 5];
|
|
148
151
|
_a.label = 1;
|
|
149
152
|
case 1:
|
|
150
153
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -159,13 +162,18 @@ function SupportFeedbackModal(props) {
|
|
|
159
162
|
error_1 = _a.sent();
|
|
160
163
|
ToastNotification_1.ToastNotification.addDangerMessage(t('Failed to submit feedback.'));
|
|
161
164
|
return [3 /*break*/, 4];
|
|
162
|
-
case 4: return [
|
|
165
|
+
case 4: return [3 /*break*/, 6];
|
|
166
|
+
case 5:
|
|
167
|
+
setIsSubmitDisabled(true);
|
|
168
|
+
_a.label = 6;
|
|
169
|
+
case 6: return [2 /*return*/];
|
|
163
170
|
}
|
|
164
171
|
});
|
|
165
172
|
}); };
|
|
166
173
|
// Function for Toggling the Modal when Provide feedback button is clicked
|
|
167
174
|
var handleModalToggle = function () {
|
|
168
175
|
props.onClose();
|
|
176
|
+
setIsSubmitDisabled(false);
|
|
169
177
|
setValues({ levelOfSatisfied: null, moreInfo: '' });
|
|
170
178
|
};
|
|
171
179
|
// Feedback Satisfaction Values
|
|
@@ -198,8 +206,8 @@ function SupportFeedbackModal(props) {
|
|
|
198
206
|
];
|
|
199
207
|
function renderModalBody() {
|
|
200
208
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
201
|
-
react_1.default.createElement("form", { action: "", onSubmit: handleSubmit },
|
|
202
|
-
react_1.default.createElement("fieldset", { className: "form-group radios feedback-satisfaction", role: "radiogroup", "aria-labelledby": "feedback-satisfaction-label" },
|
|
209
|
+
react_1.default.createElement("form", { className: "support-feedback-form", action: "", onSubmit: handleSubmit },
|
|
210
|
+
react_1.default.createElement("fieldset", { className: "form-group radios feedback-satisfaction pf-u-mb-sm", role: "radiogroup", "aria-labelledby": "feedback-satisfaction-label" },
|
|
203
211
|
react_1.default.createElement("legend", { id: "feedback-satisfaction-label", className: "pf-u-mb-md" },
|
|
204
212
|
react_1.default.createElement(react_i18next_1.Trans, null, "How satisfied are you with customer support\u2019s web experience?"),
|
|
205
213
|
react_1.default.createElement("span", { className: "form-required", "aria-hidden": "true" }, "*"),
|
|
@@ -210,8 +218,11 @@ function SupportFeedbackModal(props) {
|
|
|
210
218
|
' ',
|
|
211
219
|
sentiment.icon,
|
|
212
220
|
react_1.default.createElement(react_i18next_1.Trans, null, sentiment.label)));
|
|
213
|
-
}))
|
|
214
|
-
|
|
221
|
+
})),
|
|
222
|
+
isSubmitDisabled && (react_1.default.createElement("div", null,
|
|
223
|
+
react_1.default.createElement("p", { className: "form-instructions form-invalid" },
|
|
224
|
+
react_1.default.createElement(react_i18next_1.Trans, null, "Please select a value"))))),
|
|
225
|
+
react_1.default.createElement("div", { className: "form-group pf-u-mb-md" },
|
|
215
226
|
react_1.default.createElement("label", { htmlFor: "moreFeedback" },
|
|
216
227
|
react_1.default.createElement(react_i18next_1.Trans, null, "How can we improve?")),
|
|
217
228
|
react_1.default.createElement(TextAreaAutosize_1.TextAreaAutosize, { name: "moreInfo", id: "moreFeedback", placeholder: t('i18nDescribeSuggestionDetail', 'Describe your suggestion in detail'), disabled: isFetching, value: values.moreInfo, className: "form-control", onChange: handleFeedbackTextChange, rowsMin: 3 })),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAreaResizable.d.ts","sourceRoot":"","sources":["../../../src/TextAreaResizable/TextAreaResizable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,KAAK,EAAE,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"TextAreaResizable.d.ts","sourceRoot":"","sources":["../../../src/TextAreaResizable/TextAreaResizable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAEnD,UAAU,MAAO,SAAQ,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,EAAE,KAAK,GAAG,UAAU,GAAG,MAAM,GAAG,WAAW,CAAC;IACpG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAC;CACpF;AACD,eAAO,MAAM,iBAAiB,UAAW,MAAM,gBAoD9C,CAAC"}
|
|
@@ -1,35 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
22
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
23
|
+
if (!m) return o;
|
|
24
|
+
var i = m.call(o), r, ar = [], e;
|
|
25
|
+
try {
|
|
26
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
27
|
+
}
|
|
28
|
+
catch (error) { e = { error: error }; }
|
|
29
|
+
finally {
|
|
30
|
+
try {
|
|
31
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
32
|
+
}
|
|
33
|
+
finally { if (e) throw e.error; }
|
|
34
|
+
}
|
|
35
|
+
return ar;
|
|
4
36
|
};
|
|
5
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
38
|
exports.TextAreaResizable = void 0;
|
|
7
39
|
var react_core_1 = require("@patternfly/react-core");
|
|
8
40
|
var lodash_1 = require("lodash");
|
|
9
|
-
var react_1 =
|
|
41
|
+
var react_1 = __importStar(require("react"));
|
|
10
42
|
var TextAreaResizable = function (props) {
|
|
11
43
|
// To set defaultProps
|
|
12
44
|
var _a = props.rowsMin, rowsMin = _a === void 0 ? 2 : _a, _b = props.autoResize, autoResize = _b === void 0 ? false : _b, onChange = props.onChange, rows = props.rows, id = props.id, className = props.className, isRequired = props.isRequired, maxLength = props.maxLength, name = props.name, value = props.value, isDisabled = props.isDisabled, _c = props.isSpaceAllowed, isSpaceAllowed = _c === void 0 ? true : _c;
|
|
13
|
-
var
|
|
45
|
+
var _d = __read(react_1.useState(false), 2), isTextAreaEmpty = _d[0], setIsTextAreaEmpty = _d[1];
|
|
14
46
|
// Function to handle onChange event
|
|
15
47
|
var onTextAreaChange = function (value, event) {
|
|
16
48
|
onChange(value, event);
|
|
49
|
+
setIsTextAreaEmpty(lodash_1.isEmpty(value === null || value === void 0 ? void 0 : value.trim()));
|
|
17
50
|
event.preventDefault();
|
|
18
51
|
return [];
|
|
19
52
|
};
|
|
20
53
|
// Function to check for validity
|
|
21
54
|
var validatedCheck = function () {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
55
|
+
var isValidated = 'default';
|
|
56
|
+
if (isRequired) {
|
|
57
|
+
if (isSpaceAllowed) {
|
|
58
|
+
return isValidated;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return isTextAreaEmpty ? 'error' : 'default';
|
|
62
|
+
}
|
|
30
63
|
}
|
|
31
64
|
else
|
|
32
|
-
return
|
|
65
|
+
return 'default';
|
|
33
66
|
};
|
|
34
67
|
return (react_1.default.createElement(react_core_1.TextArea, { id: id, rows: rows || rowsMin, className: className, "aria-required": props['aria-required'], isRequired: isRequired, maxLength: maxLength, name: name, value: value, autoResize: autoResize, validated: validatedCheck(), onChange: onTextAreaChange, disabled: isDisabled }));
|
|
35
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SupportFeedbackModal.d.ts","sourceRoot":"","sources":["../../../src/SupportFeedbackForm/SupportFeedbackModal.tsx"],"names":[],"mappings":";AAuBA,UAAU,MAAM;IACZ,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAMD,iBAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SupportFeedbackModal.d.ts","sourceRoot":"","sources":["../../../src/SupportFeedbackForm/SupportFeedbackModal.tsx"],"names":[],"mappings":";AAuBA,UAAU,MAAM;IACZ,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAMD,iBAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,eAqN1C;kBArNQ,oBAAoB;;;AAwN7B,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -39,7 +39,8 @@ function SupportFeedbackModal(props) {
|
|
|
39
39
|
};
|
|
40
40
|
const [values, setValues] = useState(formInitState);
|
|
41
41
|
const { request, isFetching } = useFetch(pcm.sendFeedbackForm, { propgateErrors: true });
|
|
42
|
-
const [isSubmitDisabled,
|
|
42
|
+
const [isSubmitDisabled, setIsSubmitDisabled] = useState(false);
|
|
43
|
+
const [isSubmitButtonValid, setSubmitButtonValid] = useState(true);
|
|
43
44
|
useEffect(() => {
|
|
44
45
|
let valid = true;
|
|
45
46
|
Object.keys(values).forEach((key) => {
|
|
@@ -47,10 +48,11 @@ function SupportFeedbackModal(props) {
|
|
|
47
48
|
valid = valid && !isEmpty(values[key]);
|
|
48
49
|
}
|
|
49
50
|
});
|
|
50
|
-
|
|
51
|
+
setSubmitButtonValid(!valid);
|
|
51
52
|
}, [values]);
|
|
52
53
|
// To Handle the Feedback Satisfaction values
|
|
53
54
|
const handleSentimentChange = (event) => {
|
|
55
|
+
setIsSubmitDisabled(false);
|
|
54
56
|
setValues(Object.assign(Object.assign({}, values), { [event.target.name]: event.target.value }));
|
|
55
57
|
};
|
|
56
58
|
// To Handle the Text Area Input (Feedback Description)
|
|
@@ -59,19 +61,24 @@ function SupportFeedbackModal(props) {
|
|
|
59
61
|
};
|
|
60
62
|
const handleSubmit = (event) => __awaiter(this, void 0, void 0, function* () {
|
|
61
63
|
event.preventDefault();
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
if (!isSubmitButtonValid) {
|
|
65
|
+
try {
|
|
66
|
+
yield request(values, window.sessionjs, window.location.href, seSessionId);
|
|
67
|
+
setValues(formInitState);
|
|
68
|
+
ToastNotification.addSuccessMessage(t(`Thank you. We've received your feedback.`), t('Have a great day!'));
|
|
69
|
+
handleModalToggle();
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
ToastNotification.addDangerMessage(t('Failed to submit feedback.'));
|
|
73
|
+
}
|
|
70
74
|
}
|
|
75
|
+
else
|
|
76
|
+
setIsSubmitDisabled(true);
|
|
71
77
|
});
|
|
72
78
|
// Function for Toggling the Modal when Provide feedback button is clicked
|
|
73
79
|
const handleModalToggle = () => {
|
|
74
80
|
props.onClose();
|
|
81
|
+
setIsSubmitDisabled(false);
|
|
75
82
|
setValues({ levelOfSatisfied: null, moreInfo: '' });
|
|
76
83
|
};
|
|
77
84
|
// Feedback Satisfaction Values
|
|
@@ -104,8 +111,8 @@ function SupportFeedbackModal(props) {
|
|
|
104
111
|
];
|
|
105
112
|
function renderModalBody() {
|
|
106
113
|
return (React.createElement(React.Fragment, null,
|
|
107
|
-
React.createElement("form", { action: "", onSubmit: handleSubmit },
|
|
108
|
-
React.createElement("fieldset", { className: "form-group radios feedback-satisfaction", role: "radiogroup", "aria-labelledby": "feedback-satisfaction-label" },
|
|
114
|
+
React.createElement("form", { className: "support-feedback-form", action: "", onSubmit: handleSubmit },
|
|
115
|
+
React.createElement("fieldset", { className: "form-group radios feedback-satisfaction pf-u-mb-sm", role: "radiogroup", "aria-labelledby": "feedback-satisfaction-label" },
|
|
109
116
|
React.createElement("legend", { id: "feedback-satisfaction-label", className: "pf-u-mb-md" },
|
|
110
117
|
React.createElement(Trans, null, "How satisfied are you with customer support\u2019s web experience?"),
|
|
111
118
|
React.createElement("span", { className: "form-required", "aria-hidden": "true" }, "*"),
|
|
@@ -116,8 +123,11 @@ function SupportFeedbackModal(props) {
|
|
|
116
123
|
' ',
|
|
117
124
|
sentiment.icon,
|
|
118
125
|
React.createElement(Trans, null, sentiment.label)));
|
|
119
|
-
}))
|
|
120
|
-
|
|
126
|
+
})),
|
|
127
|
+
isSubmitDisabled && (React.createElement("div", null,
|
|
128
|
+
React.createElement("p", { className: "form-instructions form-invalid" },
|
|
129
|
+
React.createElement(Trans, null, "Please select a value"))))),
|
|
130
|
+
React.createElement("div", { className: "form-group pf-u-mb-md" },
|
|
121
131
|
React.createElement("label", { htmlFor: "moreFeedback" },
|
|
122
132
|
React.createElement(Trans, null, "How can we improve?")),
|
|
123
133
|
React.createElement(TextAreaAutosize, { name: "moreInfo", id: "moreFeedback", placeholder: t('i18nDescribeSuggestionDetail', 'Describe your suggestion in detail'), disabled: isFetching, value: values.moreInfo, className: "form-control", onChange: handleFeedbackTextChange, rowsMin: 3 })),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAreaResizable.d.ts","sourceRoot":"","sources":["../../../src/TextAreaResizable/TextAreaResizable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,KAAK,EAAE,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"TextAreaResizable.d.ts","sourceRoot":"","sources":["../../../src/TextAreaResizable/TextAreaResizable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAEnD,UAAU,MAAO,SAAQ,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,EAAE,KAAK,GAAG,UAAU,GAAG,MAAM,GAAG,WAAW,CAAC;IACpG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAC;CACpF;AACD,eAAO,MAAM,iBAAiB,UAAW,MAAM,gBAoD9C,CAAC"}
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
import { TextArea } from '@patternfly/react-core';
|
|
2
2
|
import { isEmpty } from 'lodash';
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
4
|
export const TextAreaResizable = (props) => {
|
|
5
5
|
// To set defaultProps
|
|
6
6
|
const { rowsMin = 2, autoResize = false, onChange, rows, id, className, isRequired, maxLength, name, value, isDisabled, isSpaceAllowed = true, } = props;
|
|
7
|
-
|
|
7
|
+
const [isTextAreaEmpty, setIsTextAreaEmpty] = useState(false);
|
|
8
8
|
// Function to handle onChange event
|
|
9
9
|
const onTextAreaChange = (value, event) => {
|
|
10
10
|
onChange(value, event);
|
|
11
|
+
setIsTextAreaEmpty(isEmpty(value === null || value === void 0 ? void 0 : value.trim()));
|
|
11
12
|
event.preventDefault();
|
|
12
13
|
return [];
|
|
13
14
|
};
|
|
14
15
|
// Function to check for validity
|
|
15
16
|
const validatedCheck = () => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
let isValidated = 'default';
|
|
18
|
+
if (isRequired) {
|
|
19
|
+
if (isSpaceAllowed) {
|
|
20
|
+
return isValidated;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return isTextAreaEmpty ? 'error' : 'default';
|
|
24
|
+
}
|
|
24
25
|
}
|
|
25
26
|
else
|
|
26
|
-
return
|
|
27
|
+
return 'default';
|
|
27
28
|
};
|
|
28
29
|
return (React.createElement(TextArea, { id: id, rows: rows || rowsMin, className: className, "aria-required": props['aria-required'], isRequired: isRequired, maxLength: maxLength, name: name, value: value, autoResize: autoResize, validated: validatedCheck(), onChange: onTextAreaChange, disabled: isDisabled }));
|
|
29
30
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/components",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.69",
|
|
4
4
|
"description": "Contains all reusabel components for support app",
|
|
5
5
|
"author": "Vikas Rathee <vrathee@redhat.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"prepublishOnly": "npm run build"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@cee-eng/hydrajs": "4.10.
|
|
55
|
+
"@cee-eng/hydrajs": "4.10.2",
|
|
56
56
|
"@cee-eng/ui-toolkit": "1.1.6",
|
|
57
57
|
"@patternfly/patternfly": "4.185.1",
|
|
58
58
|
"@patternfly/react-core": "4.202.16",
|
|
@@ -80,15 +80,15 @@
|
|
|
80
80
|
"use-deep-compare-effect": "^1.6.1"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@cee-eng/hydrajs": "4.10.
|
|
83
|
+
"@cee-eng/hydrajs": "4.10.2",
|
|
84
84
|
"@cee-eng/ui-toolkit": "1.1.6",
|
|
85
85
|
"@patternfly/patternfly": "4.185.1",
|
|
86
86
|
"@patternfly/react-core": "4.202.16",
|
|
87
87
|
"@patternfly/react-table": "4.71.16",
|
|
88
|
-
"@rh-support/api": "0.3.
|
|
89
|
-
"@rh-support/types": "0.
|
|
90
|
-
"@rh-support/user-permissions": "0.2.
|
|
91
|
-
"@rh-support/utils": "0.2.
|
|
88
|
+
"@rh-support/api": "0.3.21",
|
|
89
|
+
"@rh-support/types": "0.2.0",
|
|
90
|
+
"@rh-support/user-permissions": "0.2.58",
|
|
91
|
+
"@rh-support/utils": "0.2.43",
|
|
92
92
|
"@storybook/addon-a11y": "^5.3.19",
|
|
93
93
|
"@storybook/addon-actions": "^5.3.19",
|
|
94
94
|
"@storybook/addon-docs": "^5.3.19",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"not ie <= 11",
|
|
129
129
|
"not op_mini all"
|
|
130
130
|
],
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "83213f63a0200c2976231df845612f7ef9d73c3e"
|
|
132
132
|
}
|