Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui5-step-input): inintial implementation #2804

Merged
merged 11 commits into from
Feb 22, 2021
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 @@ -66,6 +66,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 @@ -34,7 +34,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
16 changes: 16 additions & 0 deletions packages/main/src/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ const metadata = {
type: Object,
},

_wrapperAccInfo: {
type: Object,
NHristov-sap marked this conversation as resolved.
Show resolved Hide resolved
},

_nativeInputAttributes: {
type: Object,
},

_inputWidth: {
type: Integer,
},
Expand Down Expand Up @@ -1072,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
76 changes: 76 additions & 0 deletions packages/main/src/StepInput.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<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"
NHristov-sap marked this conversation as resolved.
Show resolved Hide resolved
name="{{decIconName}}"
tabindex="-1"
accessible-name="{{decIconTitle}}"
@click="{{_decValue}}"
@focusout="{{_onButtonFocusOut}}"
@mousedown="{{_decSpin}}"
@mouseup="{{_resetSpin}}"
@mouseout="{{_resetSpinOut}}"
input-icon
?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
._nativeInputAttributes="{{inputAttributes}}"
@ui5-change="{{_onInputChange}}"
@ui5-submit="{{_onInputChange}}"
@focusout="{{_onInputFocusOut}}"
@focusin="{{_onInputFocusIn}}"
>

{{#if valueStateMessage.length}}
<slot name="valueStateMessage" slot="valueStateMessage" style="width: 100%"></slot>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style="width: 100%" Is this have any effect on the slot element

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err, no... just tried something... will remove it now!

{{/if}}

</ui5-input>

<!-- Increment Icon -->
<div
class="ui5-step-icon ui5-step-inc"
title="{{incIconTitle}}"
>
<ui5-icon
id="{{_id}}-inc"
NHristov-sap marked this conversation as resolved.
Show resolved Hide resolved
name="{{incIconName}}"
tabindex="-1"
accessible-name="{{incIconTitle}}"
@click="{{_incValue}}"
@focusout="{{_onButtonFocusOut}}"
@mousedown="{{_incSpin}}"
@mouseup="{{_resetSpin}}"
@mouseout="{{_resetSpinOut}}"
input-icon
?clickable="{{_incIconClickable}}"
></ui5-icon>
</div>

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

</div>
Loading