Skip to content

Commit d80420e

Browse files
authored
feat(ui5-step-input): inintial implementation (#2804)
Fixes #2640
1 parent 98024d5 commit d80420e

14 files changed

+1725
-8
lines changed

packages/base/src/Keys.js

+12
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ const isUpCtrl = event => (event.key ? (event.key === "ArrowUp" || event.key ===
127127

128128
const isDownCtrl = event => (event.key ? (event.key === "ArrowDown" || event.key === "Down") : event.keyCode === KeyCodes.ARROW_DOWN) && checkModifierKeys(event, true, false, false);
129129

130+
const isUpShift = event => (event.key ? (event.key === "ArrowUp" || event.key === "Up") : event.keyCode === KeyCodes.ARROW_UP) && checkModifierKeys(event, false, false, true);
131+
132+
const isDownShift = event => (event.key ? (event.key === "ArrowDown" || event.key === "Down") : event.keyCode === KeyCodes.ARROW_DOWN) && checkModifierKeys(event, false, false, true);
133+
134+
const isUpShiftCtrl = event => (event.key ? (event.key === "ArrowUp" || event.key === "Up") : event.keyCode === KeyCodes.ARROW_UP) && checkModifierKeys(event, true, false, true);
135+
136+
const isDownShiftCtrl = event => (event.key ? (event.key === "ArrowDown" || event.key === "Down") : event.keyCode === KeyCodes.ARROW_DOWN) && checkModifierKeys(event, true, false, true);
137+
130138
const isHome = event => (event.key ? event.key === "Home" : event.keyCode === KeyCodes.HOME) && !hasModifierKeys(event);
131139

132140
const isEnd = event => (event.key ? event.key === "End" : event.keyCode === KeyCodes.END) && !hasModifierKeys(event);
@@ -198,6 +206,10 @@ export {
198206
isRightCtrl,
199207
isUpCtrl,
200208
isDownCtrl,
209+
isUpShift,
210+
isDownShift,
211+
isUpShiftCtrl,
212+
isDownShiftCtrl,
201213
isHome,
202214
isEnd,
203215
isPlus,

packages/main/bundle.esm.js

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import ResponsivePopover from "./dist/ResponsivePopover.js";
6969
import SegmentedButton from "./dist/SegmentedButton.js";
7070
import Select from "./dist/Select.js";
7171
import Slider from "./dist/Slider.js";
72+
import StepInput from "./dist/StepInput.js";
7273
import RangeSlider from "./dist/RangeSlider.js";
7374
import Switch from "./dist/Switch.js";
7475
import MessageStrip from "./dist/MessageStrip.js";

packages/main/src/Input.hbs

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
@focusin={{innerFocusIn}}
3636
data-sap-no-tab-ref
3737
data-sap-focus-ref
38-
step="{{step}}"
38+
step="{{nativeInputAttributes.step}}"
39+
min="{{nativeInputAttributes.min}}"
40+
max="{{nativeInputAttributes.max}}"
3941
/>
4042
{{#if icon.length}}
4143
<div class="ui5-input-icon-root">

packages/main/src/Input.js

+12
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ const metadata = {
332332
type: Object,
333333
},
334334

335+
_nativeInputAttributes: {
336+
type: Object,
337+
},
338+
335339
_inputWidth: {
336340
type: Integer,
337341
},
@@ -1076,6 +1080,14 @@ class Input extends UI5Element {
10761080
};
10771081
}
10781082

1083+
get nativeInputAttributes() {
1084+
return {
1085+
"min": this.type === InputType.Number ? this._nativeInputAttributes.min : undefined,
1086+
"max": this.type === InputType.Number ? this._nativeInputAttributes.max : undefined,
1087+
"step": this.type === InputType.Number ? (this._nativeInputAttributes.step || "any") : undefined,
1088+
};
1089+
}
1090+
10791091
get ariaValueStateHiddenText() {
10801092
if (!this.hasValueStateMessage) {
10811093
return;

packages/main/src/StepInput.hbs

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<div
2+
id="{{_id}}"
3+
class="ui5-step-input-root"
4+
style="{{styles}}"
5+
@keydown="{{_onkeydown}}"
6+
@focusin="{{_onfocusin}}"
7+
@focusout="{{_onfocusout}}"
8+
>
9+
<!-- Decrement Icon -->
10+
<div
11+
class="ui5-step-icon ui5-step-dec"
12+
title="{{decIconTitle}}"
13+
>
14+
<ui5-icon
15+
id="{{_id}}-dec"
16+
name="{{decIconName}}"
17+
tabindex="-1"
18+
accessible-name="{{decIconTitle}}"
19+
@click="{{_decValue}}"
20+
@focusout="{{_onButtonFocusOut}}"
21+
@mousedown="{{_decSpin}}"
22+
@mouseup="{{_resetSpin}}"
23+
@mouseout="{{_resetSpinOut}}"
24+
input-icon
25+
show-tooltip
26+
?clickable="{{_decIconClickable}}"
27+
></ui5-icon>
28+
</div>
29+
30+
<!-- INPUT -->
31+
<ui5-input
32+
id="{{_id}}-inner"
33+
class="ui5-step-input-input"
34+
placeholder="{{placeholder}}"
35+
type="{{type}}"
36+
value="{{_valuePrecisioned}}"
37+
?disabled="{{disabled}}"
38+
?required="{{required}}"
39+
?readonly="{{readonly}}"
40+
value-state="{{valueState}}"
41+
data-sap-focus-ref
42+
._inputAccInfo ="{{accInfo}}"
43+
._nativeInputAttributes="{{inputAttributes}}"
44+
@ui5-change="{{_onInputChange}}"
45+
@ui5-submit="{{_onInputChange}}"
46+
@focusout="{{_onInputFocusOut}}"
47+
@focusin="{{_onInputFocusIn}}"
48+
>
49+
50+
{{#if valueStateMessage.length}}
51+
<slot name="valueStateMessage" slot="valueStateMessage"></slot>
52+
{{/if}}
53+
54+
</ui5-input>
55+
56+
<!-- Increment Icon -->
57+
<div
58+
class="ui5-step-icon ui5-step-inc"
59+
title="{{incIconTitle}}"
60+
>
61+
<ui5-icon
62+
id="{{_id}}-inc"
63+
name="{{incIconName}}"
64+
tabindex="-1"
65+
accessible-name="{{incIconTitle}}"
66+
@click="{{_incValue}}"
67+
@focusout="{{_onButtonFocusOut}}"
68+
@mousedown="{{_incSpin}}"
69+
@mouseup="{{_resetSpin}}"
70+
@mouseout="{{_resetSpinOut}}"
71+
input-icon
72+
show-tooltip
73+
?clickable="{{_incIconClickable}}"
74+
></ui5-icon>
75+
</div>
76+
77+
<slot name="formSupport"></slot>
78+
79+
</div>

0 commit comments

Comments
 (0)