Skip to content

Commit

Permalink
feat(ui5-step-input): inintial implementation (#2804)
Browse files Browse the repository at this point in the history
Fixes #2640
  • Loading branch information
NHristov-sap committed Feb 22, 2021
1 parent 98024d5 commit d80420e
Show file tree
Hide file tree
Showing 14 changed files with 1,725 additions and 8 deletions.
12 changes: 12 additions & 0 deletions packages/base/src/Keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ const isUpCtrl = event => (event.key ? (event.key === "ArrowUp" || event.key ===

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

const isUpShift = event => (event.key ? (event.key === "ArrowUp" || event.key === "Up") : event.keyCode === KeyCodes.ARROW_UP) && checkModifierKeys(event, false, false, true);

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

const isUpShiftCtrl = event => (event.key ? (event.key === "ArrowUp" || event.key === "Up") : event.keyCode === KeyCodes.ARROW_UP) && checkModifierKeys(event, true, false, true);

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

const isHome = event => (event.key ? event.key === "Home" : event.keyCode === KeyCodes.HOME) && !hasModifierKeys(event);

const isEnd = event => (event.key ? event.key === "End" : event.keyCode === KeyCodes.END) && !hasModifierKeys(event);
Expand Down Expand Up @@ -198,6 +206,10 @@ export {
isRightCtrl,
isUpCtrl,
isDownCtrl,
isUpShift,
isDownShift,
isUpShiftCtrl,
isDownShiftCtrl,
isHome,
isEnd,
isPlus,
Expand Down
1 change: 1 addition & 0 deletions packages/main/bundle.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import ResponsivePopover from "./dist/ResponsivePopover.js";
import SegmentedButton from "./dist/SegmentedButton.js";
import Select from "./dist/Select.js";
import Slider from "./dist/Slider.js";
import StepInput from "./dist/StepInput.js";
import RangeSlider from "./dist/RangeSlider.js";
import Switch from "./dist/Switch.js";
import MessageStrip from "./dist/MessageStrip.js";
Expand Down
4 changes: 3 additions & 1 deletion packages/main/src/Input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
@focusin={{innerFocusIn}}
data-sap-no-tab-ref
data-sap-focus-ref
step="{{step}}"
step="{{nativeInputAttributes.step}}"
min="{{nativeInputAttributes.min}}"
max="{{nativeInputAttributes.max}}"
/>
{{#if icon.length}}
<div class="ui5-input-icon-root">
Expand Down
12 changes: 12 additions & 0 deletions packages/main/src/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ const metadata = {
type: Object,
},

_nativeInputAttributes: {
type: Object,
},

_inputWidth: {
type: Integer,
},
Expand Down Expand Up @@ -1076,6 +1080,14 @@ class Input extends UI5Element {
};
}

get nativeInputAttributes() {
return {
"min": this.type === InputType.Number ? this._nativeInputAttributes.min : undefined,
"max": this.type === InputType.Number ? this._nativeInputAttributes.max : undefined,
"step": this.type === InputType.Number ? (this._nativeInputAttributes.step || "any") : undefined,
};
}

get ariaValueStateHiddenText() {
if (!this.hasValueStateMessage) {
return;
Expand Down
79 changes: 79 additions & 0 deletions packages/main/src/StepInput.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<div
id="{{_id}}"
class="ui5-step-input-root"
style="{{styles}}"
@keydown="{{_onkeydown}}"
@focusin="{{_onfocusin}}"
@focusout="{{_onfocusout}}"
>
<!-- Decrement Icon -->
<div
class="ui5-step-icon ui5-step-dec"
title="{{decIconTitle}}"
>
<ui5-icon
id="{{_id}}-dec"
name="{{decIconName}}"
tabindex="-1"
accessible-name="{{decIconTitle}}"
@click="{{_decValue}}"
@focusout="{{_onButtonFocusOut}}"
@mousedown="{{_decSpin}}"
@mouseup="{{_resetSpin}}"
@mouseout="{{_resetSpinOut}}"
input-icon
show-tooltip
?clickable="{{_decIconClickable}}"
></ui5-icon>
</div>

<!-- INPUT -->
<ui5-input
id="{{_id}}-inner"
class="ui5-step-input-input"
placeholder="{{placeholder}}"
type="{{type}}"
value="{{_valuePrecisioned}}"
?disabled="{{disabled}}"
?required="{{required}}"
?readonly="{{readonly}}"
value-state="{{valueState}}"
data-sap-focus-ref
._inputAccInfo ="{{accInfo}}"
._nativeInputAttributes="{{inputAttributes}}"
@ui5-change="{{_onInputChange}}"
@ui5-submit="{{_onInputChange}}"
@focusout="{{_onInputFocusOut}}"
@focusin="{{_onInputFocusIn}}"
>

{{#if valueStateMessage.length}}
<slot name="valueStateMessage" slot="valueStateMessage"></slot>
{{/if}}

</ui5-input>

<!-- Increment Icon -->
<div
class="ui5-step-icon ui5-step-inc"
title="{{incIconTitle}}"
>
<ui5-icon
id="{{_id}}-inc"
name="{{incIconName}}"
tabindex="-1"
accessible-name="{{incIconTitle}}"
@click="{{_incValue}}"
@focusout="{{_onButtonFocusOut}}"
@mousedown="{{_incSpin}}"
@mouseup="{{_resetSpin}}"
@mouseout="{{_resetSpinOut}}"
input-icon
show-tooltip
?clickable="{{_incIconClickable}}"
></ui5-icon>
</div>

<slot name="formSupport"></slot>

</div>
Loading

0 comments on commit d80420e

Please sign in to comment.