Skip to content

Commit ed3c393

Browse files
authored
feat(ui5-duration-picker): implement valueStateMessage (#2102)
Related to: #1086
1 parent 1fe4afb commit ed3c393

File tree

5 files changed

+54
-14
lines changed

5 files changed

+54
-14
lines changed

packages/main/src/DurationPicker.hbs

+16-12
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,21 @@
99
@keydown="{{_onkeydown}}"
1010
class="ui5-duration-picker-input"
1111
>
12-
{{#unless readonly}}
13-
<ui5-icon
14-
slot="icon"
15-
name="fob-watch"
16-
tabindex="-1"
17-
show-tooltip
18-
@click="{{togglePicker}}"
19-
input-icon
20-
?pressed="{{_isPickerOpen}}"
21-
class="ui5-duration-picker-input-icon-button"
22-
></ui5-icon>
23-
{{/unless}}
12+
{{#unless readonly}}
13+
<ui5-icon
14+
slot="icon"
15+
name="fob-watch"
16+
tabindex="-1"
17+
show-tooltip
18+
@click="{{togglePicker}}"
19+
input-icon
20+
?pressed="{{_isPickerOpen}}"
21+
class="ui5-duration-picker-input-icon-button"
22+
></ui5-icon>
23+
{{/unless}}
24+
25+
{{#if valueStateMessage.length}}
26+
<slot name="valueStateMessage" slot="valueStateMessage"></slot>
27+
{{/if}}
2428
</ui5-input>
2529
</div>

packages/main/src/DurationPicker.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import DurationPickerPopoverCss from "./generated/themes/DurationPickerPopover.c
3232
const metadata = {
3333
tag: "ui5-duration-picker",
3434
languageAware: true,
35+
managedSlots: true,
3536
properties: /** @lends sap.ui.webcomponents.main.DurationPicker.prototype */ {
3637
/**
3738
* Defines a formatted time value.
@@ -173,7 +174,22 @@ const metadata = {
173174
},
174175
},
175176
slots: /** @lends sap.ui.webcomponents.main.DurationPicker.prototype */ {
176-
//
177+
/**
178+
* Defines the value state message that will be displayed as pop up under the <code>ui5-duration-picker</code>.
179+
* <br><br>
180+
*
181+
* <b>Note:</b> If not specified, a default text (in the respective language) will be displayed.
182+
* <br>
183+
* <b>Note:</b> The <code>valueStateMessage</code> would be displayed,
184+
* when the <code>ui5-duration-picker</code> is in <code>Information</code>, <code>Warning</code> or <code>Error</code> value state.
185+
* @type {HTMLElement}
186+
* @since 1.0.0-rc.9
187+
* @slot
188+
* @public
189+
*/
190+
valueStateMessage: {
191+
type: HTMLElement,
192+
},
177193
},
178194
events: /** @lends sap.ui.webcomponents.main.DurationPicker.prototype */ {
179195
/**

packages/main/test/pages/DurationPicker.html

+8
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,13 @@
6262
<br>
6363
<br>
6464
<ui5-duration-picker id="duration-default"></ui5-duration-picker>
65+
66+
<br>
67+
<br>
68+
<ui5-duration-picker value-state="Error"></ui5-duration-picker>
69+
70+
<ui5-duration-picker value-state="Error" id="pickerValueStateMessage">
71+
<div slot="valueStateMessage" id="customValueStateMessage">Please provide valid value</div>
72+
</ui5-duration-picker>
6573
</body>
6674
</html>

packages/main/test/specs/DurationPicker.spec.js

+12
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,16 @@ describe("Duration Picker general interaction", () => {
9595
// close picker
9696
duratationPickerIcon.click();
9797
});
98+
99+
it("tests valueStateMessage slot", () => {
100+
const picker = browser.$("#pickerValueStateMessage");
101+
102+
picker.click();
103+
104+
const inputId = picker.shadow$("ui5-input").getProperty("_id");
105+
const inputStaticAreaItem = browser.$(`.${inputId}`);
106+
const slot = inputStaticAreaItem.shadow$("ui5-popover").$("#customValueStateMessage");
107+
108+
assert.ok(slot, "The value state message is set.");
109+
});
98110
});

packages/main/test/specs/TimePicker.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe("TimePicker general interaction", () => {
6868
const inputStaticAreaItem = browser.$(`.${inputId}`);
6969
const slot = inputStaticAreaItem.shadow$("ui5-popover").$("#customValueStateMessage");
7070

71-
assert.notOk(slot.error, "cValue State message slot is working");
71+
assert.notOk(slot.error, "Value State message slot is working");
7272
});
7373

7474
it("tests change event", () => {

0 commit comments

Comments
 (0)