Skip to content

Commit 6710038

Browse files
authored
feat(ui5-textarea): add "valueState" property (#1411)
The property works as in the ui5-input, with one note: If maxlength property is set, the component turns into "Warning" state once the characters exceeds the limit.In this case, only the "Error" state is considered and can be applied.
1 parent 1871ca7 commit 6710038

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

packages/main/src/TextArea.js

+27-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
44
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
55
import { getFeature } from "@ui5/webcomponents-base/dist/FeaturesRegistry.js";
66
import { isIE } from "@ui5/webcomponents-base/dist/Device.js";
7-
import TextAreaTemplate from "./generated/templates/TextAreaTemplate.lit.js";
7+
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js";
88

9+
import TextAreaTemplate from "./generated/templates/TextAreaTemplate.lit.js";
910
import { TEXTAREA_CHARACTERS_LEFT, TEXTAREA_CHARACTERS_EXCEEDED } from "./generated/i18n/i18n-defaults.js";
1011

1112
// Styles
@@ -78,6 +79,31 @@ const metadata = {
7879
type: String,
7980
},
8081

82+
/**
83+
* Defines the value state of the <code>ui5-textarea</code>.
84+
* <br><br>
85+
* Available options are:
86+
* <ul>
87+
* <li><code>None</code></li>
88+
* <li><code>Error</code></li>
89+
* <li><code>Warning</code></li>
90+
* <li><code>Success</code></li>
91+
* <li><code>Information</code></li>
92+
* </ul>
93+
* <br><br>
94+
* <b>Note:</b> If <code>maxlength</code> property is set,
95+
* the component turns into "Warning" state once the characters exceeds the limit.
96+
* In this case, only the "Error" state is considered and can be applied.
97+
* @type {ValueState}
98+
* @defaultvalue "None"
99+
* @since 1.0.0-rc.7
100+
* @public
101+
*/
102+
valueState: {
103+
type: ValueState,
104+
defaultValue: ValueState.None,
105+
},
106+
81107
/**
82108
* Defines the number of visible text lines for the component.
83109
* <br><br>

packages/main/src/themes/TextArea.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -168,20 +168,20 @@
168168
background-color: var(--sapField_WarningBackground);
169169
}
170170

171-
:host([value-state="Success"]:not([readonly])) {
171+
:host([value-state="Success"]:not([readonly]):not([exceeding])) {
172172
border-color: var(--sapField_SuccessColor);
173173
}
174174

175-
:host([value-state="Success"]:not([readonly])) .ui5-textarea-inner {
175+
:host([value-state="Success"]:not([readonly]):not([exceeding])) .ui5-textarea-inner {
176176
background-color: var(--sapField_SuccessBackground);
177177
border-width: 1px;
178178
}
179179

180-
:host([value-state="Information"]:not([readonly])) {
180+
:host([value-state="Information"]:not([readonly]):not([exceeding])) {
181181
border-color: var(--sapField_InformationColor);
182182
}
183183

184-
:host([value-state="Information"]:not([readonly])) .ui5-textarea-inner {
184+
:host([value-state="Information"]:not([readonly]):not([exceeding])) .ui5-textarea-inner {
185185
background-color: var(--sapField_InformationBackground);
186186
}
187187

0 commit comments

Comments
 (0)