@rh-support/components 1.1.52 → 1.1.55

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.
Files changed (43) hide show
  1. package/lib/cjs/CustomTextInput/CustomTextInput.d.ts +13 -0
  2. package/lib/cjs/CustomTextInput/CustomTextInput.d.ts.map +1 -0
  3. package/lib/cjs/CustomTextInput/CustomTextInput.js +35 -0
  4. package/lib/cjs/CustomTextInput/index.d.ts +2 -0
  5. package/lib/cjs/CustomTextInput/index.d.ts.map +1 -0
  6. package/lib/cjs/CustomTextInput/index.js +13 -0
  7. package/lib/cjs/InlineEdit/InlineEdit.d.ts +2 -0
  8. package/lib/cjs/InlineEdit/InlineEdit.d.ts.map +1 -1
  9. package/lib/cjs/InlineEdit/InlineEdit.js +9 -3
  10. package/lib/cjs/Input/Input.d.ts +7 -2
  11. package/lib/cjs/Input/Input.d.ts.map +1 -1
  12. package/lib/cjs/Input/Input.js +26 -2
  13. package/lib/cjs/TextAreaResizable/TextAreaResizable.d.ts +20 -0
  14. package/lib/cjs/TextAreaResizable/TextAreaResizable.d.ts.map +1 -0
  15. package/lib/cjs/TextAreaResizable/TextAreaResizable.js +36 -0
  16. package/lib/cjs/TextAreaResizable/index.d.ts +2 -0
  17. package/lib/cjs/TextAreaResizable/index.d.ts.map +1 -0
  18. package/lib/cjs/TextAreaResizable/index.js +13 -0
  19. package/lib/cjs/index.d.ts +2 -0
  20. package/lib/cjs/index.d.ts.map +1 -1
  21. package/lib/cjs/index.js +2 -0
  22. package/lib/esm/CustomTextInput/CustomTextInput.d.ts +13 -0
  23. package/lib/esm/CustomTextInput/CustomTextInput.d.ts.map +1 -0
  24. package/lib/esm/CustomTextInput/CustomTextInput.js +28 -0
  25. package/lib/esm/CustomTextInput/index.d.ts +2 -0
  26. package/lib/esm/CustomTextInput/index.d.ts.map +1 -0
  27. package/lib/esm/CustomTextInput/index.js +1 -0
  28. package/lib/esm/InlineEdit/InlineEdit.d.ts +2 -0
  29. package/lib/esm/InlineEdit/InlineEdit.d.ts.map +1 -1
  30. package/lib/esm/InlineEdit/InlineEdit.js +7 -1
  31. package/lib/esm/Input/Input.d.ts +7 -2
  32. package/lib/esm/Input/Input.d.ts.map +1 -1
  33. package/lib/esm/Input/Input.js +26 -2
  34. package/lib/esm/TextAreaResizable/TextAreaResizable.d.ts +20 -0
  35. package/lib/esm/TextAreaResizable/TextAreaResizable.d.ts.map +1 -0
  36. package/lib/esm/TextAreaResizable/TextAreaResizable.js +29 -0
  37. package/lib/esm/TextAreaResizable/index.d.ts +2 -0
  38. package/lib/esm/TextAreaResizable/index.d.ts.map +1 -0
  39. package/lib/esm/TextAreaResizable/index.js +1 -0
  40. package/lib/esm/index.d.ts +2 -0
  41. package/lib/esm/index.d.ts.map +1 -1
  42. package/lib/esm/index.js +2 -0
  43. package/package.json +4 -4
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { TextInputProps } from '@patternfly/react-core';
3
+ interface IProps extends TextInputProps {
4
+ className?: string;
5
+ maxLength?: number;
6
+ value?: string;
7
+ isSpaceAllowed?: boolean;
8
+ name?: string;
9
+ isDisabled?: boolean;
10
+ }
11
+ export declare const CustomTextInput: (props: IProps) => JSX.Element;
12
+ export {};
13
+ //# sourceMappingURL=CustomTextInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomTextInput.d.ts","sourceRoot":"","sources":["../../../src/CustomTextInput/CustomTextInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,cAAc,EAAoB,MAAM,wBAAwB,CAAC;AAIrF,UAAU,MAAO,SAAQ,cAAc;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,eAAe,UAAW,MAAM,gBAiD5C,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CustomTextInput = void 0;
7
+ var react_core_1 = require("@patternfly/react-core");
8
+ var lodash_1 = require("lodash");
9
+ var react_1 = __importDefault(require("react"));
10
+ var CustomTextInput = function (props) {
11
+ // To set defaultProps
12
+ var onChange = props.onChange, _a = props.isSpaceAllowed, isSpaceAllowed = _a === void 0 ? false : _a, isRequired = props.isRequired, className = props.className, type = props.type, maxLength = props.maxLength, value = props.value, isDisabled = props.isDisabled, placeholder = props.placeholder, validated = props.validated, name = props.name;
13
+ // To handle on input change
14
+ var onTextInputChange = function (value, event) {
15
+ onChange(value, event);
16
+ event.preventDefault();
17
+ return [];
18
+ };
19
+ // Function to check for validity
20
+ var validatedCheck = function () {
21
+ if (validated === 'error') {
22
+ return 'error';
23
+ }
24
+ else if (isSpaceAllowed) {
25
+ return validated;
26
+ }
27
+ else if (!isSpaceAllowed) {
28
+ return lodash_1.isEmpty(value === null || value === void 0 ? void 0 : value.trim()) ? 'error' : 'default';
29
+ }
30
+ else
31
+ return validated;
32
+ };
33
+ return (react_1.default.createElement(react_core_1.TextInput, { isRequired: isRequired, className: className, type: type, maxLength: maxLength, value: value, isDisabled: isDisabled, "aria-label": props['aria-label'], placeholder: placeholder, onChange: onTextInputChange, validated: validatedCheck(), name: name }));
34
+ };
35
+ exports.CustomTextInput = CustomTextInput;
@@ -0,0 +1,2 @@
1
+ export * from './CustomTextInput';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/CustomTextInput/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./CustomTextInput"), exports);
@@ -25,6 +25,8 @@ interface IProps {
25
25
  cancelOnBlur?: boolean;
26
26
  initialIsEditing?: boolean;
27
27
  hideLabel?: boolean;
28
+ isSpaceAllowed?: boolean;
29
+ inputValue?: string;
28
30
  }
29
31
  declare function InlineEdit(props: IProps): JSX.Element;
30
32
  declare namespace InlineEdit {
@@ -1 +1 @@
1
- {"version":3,"file":"InlineEdit.d.ts","sourceRoot":"","sources":["../../../src/InlineEdit/InlineEdit.tsx"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAG1B,OAAc,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAGnD,UAAU,MAAM;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IACtC,UAAU,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACxC,YAAY,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IAC1C,aAAa,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IAC5C,gBAAgB,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;IAC/B,eAAe,EAAE,OAAO,C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,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;IAC/B,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAClC,SAAS,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAChC,MAAM,EAAE,GAAG,CAAC;IACZ,QAAQ,EAAE,GAAG,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IAGzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAsBD,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,eAmKhC;kBAnKQ,UAAU;;;AAsKnB,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -88,6 +88,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
88
88
  exports.InlineEdit = void 0;
89
89
  require("./inlineEdit.css");
90
90
  var pencil_alt_icon_1 = __importDefault(require("@patternfly/react-icons/dist/js/icons/pencil-alt-icon"));
91
+ var lodash_1 = require("lodash");
91
92
  var react_1 = __importStar(require("react"));
92
93
  var react_i18next_1 = require("react-i18next");
93
94
  var defaultProps = {
@@ -107,13 +108,15 @@ var defaultProps = {
107
108
  cancelOnBlur: false,
108
109
  saveDisabled: false,
109
110
  hideLabel: false,
111
+ isSpaceAllowed: true,
110
112
  };
111
113
  function InlineEdit(props) {
112
114
  var _this = this;
113
- var _a = __read(react_1.useState(props.initialIsEditing), 2), isEditing = _a[0], setIsEditing = _a[1];
115
+ var _a;
116
+ var _b = __read(react_1.useState(props.initialIsEditing), 2), isEditing = _b[0], setIsEditing = _b[1];
114
117
  // editingTrueOnStart is a state to track if inlineEdit component is open on start, we don't want to focus
115
118
  // on input/textareat in this situation as we may have other form elements on page that we want to focus
116
- var _b = __read(react_1.useState(!props.initialIsEditing), 2), canAutoSetFocus = _b[0], setCanAutoSfocus = _b[1];
119
+ var _c = __read(react_1.useState(!props.initialIsEditing), 2), canAutoSetFocus = _c[0], setCanAutoSfocus = _c[1];
117
120
  var onEditClicked = function (e) {
118
121
  setCanAutoSfocus(true);
119
122
  e.preventDefault();
@@ -172,6 +175,8 @@ function InlineEdit(props) {
172
175
  }
173
176
  });
174
177
  }); };
178
+ // Disables button if isSpaceAllowed is False and Input has Spaces
179
+ var diabledCheckForSpaceAllowed = !props.isSpaceAllowed && lodash_1.isEmpty((_a = props.inputValue) === null || _a === void 0 ? void 0 : _a.trim());
175
180
  var handleKeyDown = function (e) { return __awaiter(_this, void 0, void 0, function () {
176
181
  return __generator(this, function (_a) {
177
182
  switch (_a.label) {
@@ -184,6 +189,7 @@ function InlineEdit(props) {
184
189
  if (!(!props.hideSaveCancel &&
185
190
  props.allowInlineEdit &&
186
191
  isEditing &&
192
+ !diabledCheckForSpaceAllowed &&
187
193
  !props.saveDisabled &&
188
194
  e.keyCode === 13)) return [3 /*break*/, 3];
189
195
  return [4 /*yield*/, onSave()];
@@ -199,7 +205,7 @@ function InlineEdit(props) {
199
205
  props.allowInlineEdit &&
200
206
  isEditing && (react_1.default.createElement("span", { className: "edit-actions" },
201
207
  props.loadingIndicator && react_1.default.createElement("span", null, props.loadingIndicator),
202
- react_1.default.createElement("button", { "data-tracking-id": props.dataTrackingId ? props.dataTrackingId + "-inline-edit-save" : null, className: "btn btn-app btn-link", type: "button", onClick: onSaveClicked, disabled: props.saveDisabled },
208
+ react_1.default.createElement("button", { "data-tracking-id": props.dataTrackingId ? props.dataTrackingId + "-inline-edit-save" : null, className: "btn btn-app btn-link", type: "button", onClick: onSaveClicked, disabled: diabledCheckForSpaceAllowed || props.saveDisabled },
203
209
  react_1.default.createElement(react_i18next_1.Trans, null, props.saveLabel)),
204
210
  react_1.default.createElement("button", { type: "button", "data-tracking-id": props.dataTrackingId ? props.dataTrackingId + "-inline-edit-cancel" : null, className: "btn btn-app btn-link", onClick: onCancelClicked },
205
211
  react_1.default.createElement(react_i18next_1.Trans, null, props.cancelLabel))));
@@ -1,15 +1,20 @@
1
- /// <reference types="react" />
2
1
  import '@patternfly/patternfly/components/Button/button.css';
3
2
  import './Input.css';
4
3
  import { IDClassNameProps } from '@rh-support/types/shared';
4
+ import React from 'react';
5
5
  interface IProps extends IDClassNameProps {
6
- ariaLabel: string;
6
+ ariaLabel?: string;
7
7
  isDisabled?: boolean;
8
8
  placeholder?: string;
9
9
  onChange: (input: string) => void;
10
10
  debounce?: number;
11
11
  hasToggleIcon?: boolean;
12
12
  icon?: JSX.Element;
13
+ isSpaceAllowed?: boolean;
14
+ isRequired?: boolean;
15
+ maxLength?: number;
16
+ type?: string;
17
+ children?: React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
13
18
  }
14
19
  export declare const Input: (props: IProps) => JSX.Element;
15
20
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/Input/Input.tsx"],"names":[],"mappings":";AAAA,OAAO,qDAAqD,CAAC;AAC7D,OAAO,aAAa,CAAC;AAGrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAI5D,UAAU,MAAO,SAAQ,gBAAgB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,KAAK,UAAW,MAAM,gBAqClC,CAAC"}
1
+ {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/Input/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,qDAAqD,CAAC;AAC7D,OAAO,aAAa,CAAC;AAGrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,UAAU,MAAO,SAAQ,gBAAgB;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;CACnF;AACD,eAAO,MAAM,KAAK,UAAW,MAAM,gBAgElC,CAAC"}
@@ -53,6 +53,7 @@ exports.Input = void 0;
53
53
  require("@patternfly/patternfly/components/Button/button.css");
54
54
  require("./Input.css");
55
55
  var react_core_1 = require("@patternfly/react-core");
56
+ var lodash_1 = require("lodash");
56
57
  var debounce_1 = __importDefault(require("lodash/debounce"));
57
58
  var react_1 = __importStar(require("react"));
58
59
  var Input = function (props) {
@@ -63,14 +64,37 @@ var Input = function (props) {
63
64
  setInput('');
64
65
  props.onChange('');
65
66
  };
67
+ var _b = __read(react_1.useState(false), 2), isSpaceAllowedLocal = _b[0], setIsSpaceAllowedLocal = _b[1];
68
+ var _c = __read(react_1.useState(''), 2), isInputValid = _c[0], setIsInputValid = _c[1];
69
+ var validityCheck = function (event) {
70
+ props.isSpaceAllowed ? setIsSpaceAllowedLocal(true) : setIsSpaceAllowedLocal(false);
71
+ var diabledCheckForSpaceAllowed = isSpaceAllowedLocal
72
+ ? lodash_1.isEmpty(event.target.value)
73
+ : lodash_1.isEmpty(event.target.value.trim());
74
+ if (diabledCheckForSpaceAllowed) {
75
+ var isValid = 'error';
76
+ return isValid;
77
+ }
78
+ else {
79
+ var isValid = 'success';
80
+ return isValid;
81
+ }
82
+ };
66
83
  var onChange = function (event) {
84
+ var isValid = validityCheck(event);
85
+ setIsInputValid(isValid);
67
86
  debounce_1.default(function (e) {
68
- setInput(e.target.value);
87
+ if (props.isSpaceAllowed) {
88
+ setInput(e.target.value);
89
+ }
90
+ else {
91
+ setInput(e.target.value.trim());
92
+ }
69
93
  props.onChange(e.target.value);
70
94
  }, props.debounce || 300)(__assign({}, event));
71
95
  event.preventDefault();
72
96
  return [];
73
97
  };
74
- return (react_1.default.createElement(react_core_1.Select, { id: props.id, "data-tracking-id": "custom-input-component", className: props.className ? classname + " " + props.className : classname, variant: react_core_1.SelectVariant.typeahead, typeAheadAriaLabel: props.ariaLabel, onToggle: onMultiSelect, onSelect: onMultiSelect, onClear: onClear, onFilter: onChange, selections: input, isOpen: false, placeholderText: props.placeholder, isDisabled: props.isDisabled, toggleIcon: props.hasToggleIcon && props.icon }));
98
+ return (react_1.default.createElement(react_core_1.Select, { id: props.id, "data-tracking-id": "custom-input-component", className: props.className ? classname + " " + props.className : classname, variant: react_core_1.SelectVariant.typeahead, typeAheadAriaLabel: props.ariaLabel, type: props.type, onToggle: onMultiSelect, onSelect: onMultiSelect, onClear: onClear, onFilter: onChange, selections: input, isOpen: false, placeholderText: props.placeholder, isDisabled: props.isDisabled, toggleIcon: props.hasToggleIcon && props.icon, required: props.isRequired, maxLength: props.maxLength, children: props.children, validated: isInputValid }));
75
99
  };
76
100
  exports.Input = Input;
@@ -0,0 +1,20 @@
1
+ import { ValidatedOptions } from '@patternfly/react-core';
2
+ import React, { HTMLProps } from 'react';
3
+ interface IProps extends Omit<HTMLProps<HTMLTextAreaElement>, 'css' | 'onChange' | 'name' | 'validated'> {
4
+ rowsMax?: number;
5
+ rowsMin?: number;
6
+ value?: string;
7
+ autoResize?: boolean;
8
+ isSpaceAllowed?: boolean;
9
+ id?: string;
10
+ className?: string;
11
+ isRequired?: boolean;
12
+ maxLength?: number;
13
+ name?: string;
14
+ isDisabled?: boolean;
15
+ validated?: ValidatedOptions;
16
+ onChange: (value: string, event: React.ChangeEvent<HTMLTextAreaElement>) => void;
17
+ }
18
+ export declare const TextAreaResizable: (props: IProps) => JSX.Element;
19
+ export {};
20
+ //# sourceMappingURL=TextAreaResizable.d.ts.map
@@ -0,0 +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,EAAE,MAAM,OAAO,CAAC;AAEzC,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"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TextAreaResizable = void 0;
7
+ var react_core_1 = require("@patternfly/react-core");
8
+ var lodash_1 = require("lodash");
9
+ var react_1 = __importDefault(require("react"));
10
+ var TextAreaResizable = function (props) {
11
+ // To set defaultProps
12
+ 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 isValidated = 'default';
14
+ // Function to handle onChange event
15
+ var onTextAreaChange = function (value, event) {
16
+ onChange(value, event);
17
+ event.preventDefault();
18
+ return [];
19
+ };
20
+ // Function to check for validity
21
+ var validatedCheck = function () {
22
+ if (isValidated === 'error') {
23
+ return 'error';
24
+ }
25
+ else if (isSpaceAllowed) {
26
+ return isValidated;
27
+ }
28
+ else if (!isSpaceAllowed) {
29
+ return lodash_1.isEmpty(value.trim()) ? 'error' : 'default';
30
+ }
31
+ else
32
+ return isValidated;
33
+ };
34
+ 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
+ };
36
+ exports.TextAreaResizable = TextAreaResizable;
@@ -0,0 +1,2 @@
1
+ export * from './TextAreaResizable';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TextAreaResizable/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./TextAreaResizable"), exports);
@@ -30,4 +30,6 @@ export * from './helperFunctions';
30
30
  export * from './PromisifyModal';
31
31
  export * from './SubscriptionAbuse';
32
32
  export * from './TermsAndConditions';
33
+ export * from './TextAreaResizable';
34
+ export * from './CustomTextInput';
33
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,e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AAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
package/lib/cjs/index.js CHANGED
@@ -42,3 +42,5 @@ __exportStar(require("./helperFunctions"), exports);
42
42
  __exportStar(require("./PromisifyModal"), exports);
43
43
  __exportStar(require("./SubscriptionAbuse"), exports);
44
44
  __exportStar(require("./TermsAndConditions"), exports);
45
+ __exportStar(require("./TextAreaResizable"), exports);
46
+ __exportStar(require("./CustomTextInput"), exports);
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { TextInputProps } from '@patternfly/react-core';
3
+ interface IProps extends TextInputProps {
4
+ className?: string;
5
+ maxLength?: number;
6
+ value?: string;
7
+ isSpaceAllowed?: boolean;
8
+ name?: string;
9
+ isDisabled?: boolean;
10
+ }
11
+ export declare const CustomTextInput: (props: IProps) => JSX.Element;
12
+ export {};
13
+ //# sourceMappingURL=CustomTextInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomTextInput.d.ts","sourceRoot":"","sources":["../../../src/CustomTextInput/CustomTextInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,cAAc,EAAoB,MAAM,wBAAwB,CAAC;AAIrF,UAAU,MAAO,SAAQ,cAAc;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,eAAe,UAAW,MAAM,gBAiD5C,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { TextInput } from '@patternfly/react-core';
2
+ import { isEmpty } from 'lodash';
3
+ import React from 'react';
4
+ export const CustomTextInput = (props) => {
5
+ // To set defaultProps
6
+ const { onChange, isSpaceAllowed = false, isRequired, className, type, maxLength, value, isDisabled, placeholder, validated, name, } = props;
7
+ // To handle on input change
8
+ const onTextInputChange = (value, event) => {
9
+ onChange(value, event);
10
+ event.preventDefault();
11
+ return [];
12
+ };
13
+ // Function to check for validity
14
+ const validatedCheck = () => {
15
+ if (validated === 'error') {
16
+ return 'error';
17
+ }
18
+ else if (isSpaceAllowed) {
19
+ return validated;
20
+ }
21
+ else if (!isSpaceAllowed) {
22
+ return isEmpty(value === null || value === void 0 ? void 0 : value.trim()) ? 'error' : 'default';
23
+ }
24
+ else
25
+ return validated;
26
+ };
27
+ return (React.createElement(TextInput, { isRequired: isRequired, className: className, type: type, maxLength: maxLength, value: value, isDisabled: isDisabled, "aria-label": props['aria-label'], placeholder: placeholder, onChange: onTextInputChange, validated: validatedCheck(), name: name }));
28
+ };
@@ -0,0 +1,2 @@
1
+ export * from './CustomTextInput';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/CustomTextInput/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './CustomTextInput';
@@ -25,6 +25,8 @@ interface IProps {
25
25
  cancelOnBlur?: boolean;
26
26
  initialIsEditing?: boolean;
27
27
  hideLabel?: boolean;
28
+ isSpaceAllowed?: boolean;
29
+ inputValue?: string;
28
30
  }
29
31
  declare function InlineEdit(props: IProps): JSX.Element;
30
32
  declare namespace InlineEdit {
@@ -1 +1 @@
1
- {"version":3,"file":"InlineEdit.d.ts","sourceRoot":"","sources":["../../../src/InlineEdit/InlineEdit.tsx"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAG1B,OAAc,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAGnD,UAAU,MAAM;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IACtC,UAAU,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACxC,YAAY,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IAC1C,aAAa,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IAC5C,gBAAgB,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;IAC/B,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAClC,SAAS,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAChC,MAAM,EAAE,GAAG,CAAC;IACZ,QAAQ,EAAE,GAAG,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IAGzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,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c,CAAC,EAAE,OAAO,CAAC;IAGzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAsBD,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,eAmKhC;kBAnKQ,UAAU;;;AAsKnB,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import './inlineEdit.css';
11
11
  import PencilAltIcon from '@patternfly/react-icons/dist/js/icons/pencil-alt-icon';
12
+ import { isEmpty } from 'lodash';
12
13
  import React, { useState } from 'react';
13
14
  import { Trans } from 'react-i18next';
14
15
  const defaultProps = {
@@ -28,8 +29,10 @@ const defaultProps = {
28
29
  cancelOnBlur: false,
29
30
  saveDisabled: false,
30
31
  hideLabel: false,
32
+ isSpaceAllowed: true,
31
33
  };
32
34
  function InlineEdit(props) {
35
+ var _a;
33
36
  const [isEditing, setIsEditing] = useState(props.initialIsEditing);
34
37
  // editingTrueOnStart is a state to track if inlineEdit component is open on start, we don't want to focus
35
38
  // on input/textareat in this situation as we may have other form elements on page that we want to focus
@@ -70,6 +73,8 @@ function InlineEdit(props) {
70
73
  return;
71
74
  yield onSave();
72
75
  });
76
+ // Disables button if isSpaceAllowed is False and Input has Spaces
77
+ const diabledCheckForSpaceAllowed = !props.isSpaceAllowed && isEmpty((_a = props.inputValue) === null || _a === void 0 ? void 0 : _a.trim());
73
78
  const handleKeyDown = (e) => __awaiter(this, void 0, void 0, function* () {
74
79
  // Cancel on pressing esc
75
80
  if (props.allowInlineEdit && isEditing && e.keyCode === 27) {
@@ -80,6 +85,7 @@ function InlineEdit(props) {
80
85
  else if (!props.hideSaveCancel &&
81
86
  props.allowInlineEdit &&
82
87
  isEditing &&
88
+ !diabledCheckForSpaceAllowed &&
83
89
  !props.saveDisabled &&
84
90
  e.keyCode === 13) {
85
91
  yield onSave();
@@ -89,7 +95,7 @@ function InlineEdit(props) {
89
95
  props.allowInlineEdit &&
90
96
  isEditing && (React.createElement("span", { className: "edit-actions" },
91
97
  props.loadingIndicator && React.createElement("span", null, props.loadingIndicator),
92
- React.createElement("button", { "data-tracking-id": props.dataTrackingId ? `${props.dataTrackingId}-inline-edit-save` : null, className: "btn btn-app btn-link", type: "button", onClick: onSaveClicked, disabled: props.saveDisabled },
98
+ React.createElement("button", { "data-tracking-id": props.dataTrackingId ? `${props.dataTrackingId}-inline-edit-save` : null, className: "btn btn-app btn-link", type: "button", onClick: onSaveClicked, disabled: diabledCheckForSpaceAllowed || props.saveDisabled },
93
99
  React.createElement(Trans, null, props.saveLabel)),
94
100
  React.createElement("button", { type: "button", "data-tracking-id": props.dataTrackingId ? `${props.dataTrackingId}-inline-edit-cancel` : null, className: "btn btn-app btn-link", onClick: onCancelClicked },
95
101
  React.createElement(Trans, null, props.cancelLabel))));
@@ -1,15 +1,20 @@
1
- /// <reference types="react" />
2
1
  import '@patternfly/patternfly/components/Button/button.css';
3
2
  import './Input.css';
4
3
  import { IDClassNameProps } from '@rh-support/types/shared';
4
+ import React from 'react';
5
5
  interface IProps extends IDClassNameProps {
6
- ariaLabel: string;
6
+ ariaLabel?: string;
7
7
  isDisabled?: boolean;
8
8
  placeholder?: string;
9
9
  onChange: (input: string) => void;
10
10
  debounce?: number;
11
11
  hasToggleIcon?: boolean;
12
12
  icon?: JSX.Element;
13
+ isSpaceAllowed?: boolean;
14
+ isRequired?: boolean;
15
+ maxLength?: number;
16
+ type?: string;
17
+ children?: React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
13
18
  }
14
19
  export declare const Input: (props: IProps) => JSX.Element;
15
20
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/Input/Input.tsx"],"names":[],"mappings":";AAAA,OAAO,qDAAqD,CAAC;AAC7D,OAAO,aAAa,CAAC;AAGrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAI5D,UAAU,MAAO,SAAQ,gBAAgB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,KAAK,UAAW,MAAM,gBAqClC,CAAC"}
1
+ {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/Input/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,qDAAqD,CAAC;AAC7D,OAAO,aAAa,CAAC;AAGrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,UAAU,MAAO,SAAQ,gBAAgB;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;CACnF;AACD,eAAO,MAAM,KAAK,UAAW,MAAM,gBAgElC,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import '@patternfly/patternfly/components/Button/button.css';
2
2
  import './Input.css';
3
3
  import { Select, SelectVariant } from '@patternfly/react-core';
4
+ import { isEmpty } from 'lodash';
4
5
  import debounce from 'lodash/debounce';
5
6
  import React, { useState } from 'react';
6
7
  export const Input = (props) => {
@@ -11,13 +12,36 @@ export const Input = (props) => {
11
12
  setInput('');
12
13
  props.onChange('');
13
14
  };
15
+ const [isSpaceAllowedLocal, setIsSpaceAllowedLocal] = useState(false);
16
+ const [isInputValid, setIsInputValid] = useState('');
17
+ const validityCheck = (event) => {
18
+ props.isSpaceAllowed ? setIsSpaceAllowedLocal(true) : setIsSpaceAllowedLocal(false);
19
+ const diabledCheckForSpaceAllowed = isSpaceAllowedLocal
20
+ ? isEmpty(event.target.value)
21
+ : isEmpty(event.target.value.trim());
22
+ if (diabledCheckForSpaceAllowed) {
23
+ let isValid = 'error';
24
+ return isValid;
25
+ }
26
+ else {
27
+ let isValid = 'success';
28
+ return isValid;
29
+ }
30
+ };
14
31
  const onChange = (event) => {
32
+ const isValid = validityCheck(event);
33
+ setIsInputValid(isValid);
15
34
  debounce((e) => {
16
- setInput(e.target.value);
35
+ if (props.isSpaceAllowed) {
36
+ setInput(e.target.value);
37
+ }
38
+ else {
39
+ setInput(e.target.value.trim());
40
+ }
17
41
  props.onChange(e.target.value);
18
42
  }, props.debounce || 300)(Object.assign({}, event));
19
43
  event.preventDefault();
20
44
  return [];
21
45
  };
22
- return (React.createElement(Select, { id: props.id, "data-tracking-id": "custom-input-component", className: props.className ? `${classname} ${props.className}` : classname, variant: SelectVariant.typeahead, typeAheadAriaLabel: props.ariaLabel, onToggle: onMultiSelect, onSelect: onMultiSelect, onClear: onClear, onFilter: onChange, selections: input, isOpen: false, placeholderText: props.placeholder, isDisabled: props.isDisabled, toggleIcon: props.hasToggleIcon && props.icon }));
46
+ return (React.createElement(Select, { id: props.id, "data-tracking-id": "custom-input-component", className: props.className ? `${classname} ${props.className}` : classname, variant: SelectVariant.typeahead, typeAheadAriaLabel: props.ariaLabel, type: props.type, onToggle: onMultiSelect, onSelect: onMultiSelect, onClear: onClear, onFilter: onChange, selections: input, isOpen: false, placeholderText: props.placeholder, isDisabled: props.isDisabled, toggleIcon: props.hasToggleIcon && props.icon, required: props.isRequired, maxLength: props.maxLength, children: props.children, validated: isInputValid }));
23
47
  };
@@ -0,0 +1,20 @@
1
+ import { ValidatedOptions } from '@patternfly/react-core';
2
+ import React, { HTMLProps } from 'react';
3
+ interface IProps extends Omit<HTMLProps<HTMLTextAreaElement>, 'css' | 'onChange' | 'name' | 'validated'> {
4
+ rowsMax?: number;
5
+ rowsMin?: number;
6
+ value?: string;
7
+ autoResize?: boolean;
8
+ isSpaceAllowed?: boolean;
9
+ id?: string;
10
+ className?: string;
11
+ isRequired?: boolean;
12
+ maxLength?: number;
13
+ name?: string;
14
+ isDisabled?: boolean;
15
+ validated?: ValidatedOptions;
16
+ onChange: (value: string, event: React.ChangeEvent<HTMLTextAreaElement>) => void;
17
+ }
18
+ export declare const TextAreaResizable: (props: IProps) => JSX.Element;
19
+ export {};
20
+ //# sourceMappingURL=TextAreaResizable.d.ts.map
@@ -0,0 +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,EAAE,MAAM,OAAO,CAAC;AAEzC,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"}
@@ -0,0 +1,29 @@
1
+ import { TextArea } from '@patternfly/react-core';
2
+ import { isEmpty } from 'lodash';
3
+ import React from 'react';
4
+ export const TextAreaResizable = (props) => {
5
+ // To set defaultProps
6
+ const { rowsMin = 2, autoResize = false, onChange, rows, id, className, isRequired, maxLength, name, value, isDisabled, isSpaceAllowed = true, } = props;
7
+ let isValidated = 'default';
8
+ // Function to handle onChange event
9
+ const onTextAreaChange = (value, event) => {
10
+ onChange(value, event);
11
+ event.preventDefault();
12
+ return [];
13
+ };
14
+ // Function to check for validity
15
+ const validatedCheck = () => {
16
+ if (isValidated === 'error') {
17
+ return 'error';
18
+ }
19
+ else if (isSpaceAllowed) {
20
+ return isValidated;
21
+ }
22
+ else if (!isSpaceAllowed) {
23
+ return isEmpty(value.trim()) ? 'error' : 'default';
24
+ }
25
+ else
26
+ return isValidated;
27
+ };
28
+ 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
+ };
@@ -0,0 +1,2 @@
1
+ export * from './TextAreaResizable';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TextAreaResizable/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './TextAreaResizable';
@@ -30,4 +30,6 @@ export * from './helperFunctions';
30
30
  export * from './PromisifyModal';
31
31
  export * from './SubscriptionAbuse';
32
32
  export * from './TermsAndConditions';
33
+ export * from './TextAreaResizable';
34
+ export * from './CustomTextInput';
33
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;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,5 @@ export * from './helperFunctions';
30
30
  export * from './PromisifyModal';
31
31
  export * from './SubscriptionAbuse';
32
32
  export * from './TermsAndConditions';
33
+ export * from './TextAreaResizable';
34
+ export * from './CustomTextInput';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/components",
3
- "version": "1.1.52",
3
+ "version": "1.1.55",
4
4
  "description": "Contains all reusabel components for support app",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
@@ -87,8 +87,8 @@
87
87
  "@patternfly/react-table": "4.63.0",
88
88
  "@rh-support/api": "0.3.13",
89
89
  "@rh-support/types": "0.2.0",
90
- "@rh-support/user-permissions": "0.2.42",
91
- "@rh-support/utils": "0.2.32",
90
+ "@rh-support/user-permissions": "0.2.44",
91
+ "@rh-support/utils": "0.2.33",
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": "3d97efe5cebb4e398f73d61326cad31e087aa63f"
131
+ "gitHead": "a3df00d1fcf2e999400a0b17f5ac00f2a32d878d"
132
132
  }