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-multi-combobox): initial implementation #379

Merged
merged 17 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/base/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module.exports = {
"no-script-url": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-unused-expressions": 1,
"no-unused-expressions": [1, { allowShortCircuit: true }],
"no-void": 2,
"no-warning-comments": 0,
"no-with": 2,
Expand Down
4 changes: 4 additions & 0 deletions packages/base/src/delegate/ItemNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ class ItemNavigation extends EventProvider {
_getCurrentItem() {
const items = this._getItems();

if (!items.length) {
return null;
}

// normalize the index
while (this.currentIndex >= items.length) {
this.currentIndex -= this.rowSize;
Expand Down
15 changes: 15 additions & 0 deletions packages/base/src/events/PseudoEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ const isTabNext = event => (event.key ? event.key === "Tab" : event.keyCode ===

const isTabPrevious = event => (event.key ? event.key === "Tab" : event.keyCode === KeyCodes.TAB) && checkModifierKeys(event, /* Ctrl */ false, /* Alt */ false, /* Shift */ true);

const isBackSpace = event => (event.key ? (event.key === "Backspace" || event.key === "Backspace") : event.keyCode === KeyCodes.BACKSPACE) && !hasModifierKeys(event);

const isDelete = event => (event.key ? (event.key === "Delete" || event.key === "Delete") : event.keyCode === KeyCodes.DELETE) && !hasModifierKeys(event);

const isShow = event => {
if (event.key) {
return (event.key === "F4" && !hasModifierKeys(event)) || ((event.key === "ArrowDown" || event.key === "Down") && checkModifierKeys(event, /* Ctrl */ false, /* Alt */ true, /* Shift */ false));
}

return (event.keyCode === KeyCodes.F4 && !hasModifierKeys(event)) || (event.keyCode === KeyCodes.ARROW_DOWN && checkModifierKeys(event, /* Ctrl */ false, /* Alt */ true, /* Shift */ false));
};

const hasModifierKeys = event => event.shiftKey || event.altKey || getCtrlKey(event);

const getCtrlKey = event => !!(event.metaKey || event.ctrlKey); // double negation doesn't have effect on boolean but ensures null and undefined are equivalent to false.
Expand All @@ -40,4 +52,7 @@ export {
isEscape,
isTabNext,
isTabPrevious,
isBackSpace,
isDelete,
isShow,
};
2 changes: 1 addition & 1 deletion packages/main/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module.exports = {
"no-script-url": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-unused-expressions": 1,
"no-unused-expressions": [1, { allowShortCircuit: true }],
"no-void": 2,
"no-warning-comments": 1,
"no-with": 2,
Expand Down
3 changes: 3 additions & 0 deletions packages/main/bundle.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import ShellBar from "./dist/ShellBar.js";
import ShellBarItem from "./dist/ShellBarItem.js";
import Switch from "./dist/Switch.js";
import MessageStrip from "./dist/MessageStrip.js";
import MultiComboBox from "./dist/MultiComboBox.js";
import TabContainer from "./dist/TabContainer.js";
import Tab from "./dist/Tab.js";
import TabSeparator from "./dist/TabSeparator.js";
Expand All @@ -42,6 +43,8 @@ import TextArea from "./dist/TextArea.js";
import Timeline from "./dist/Timeline.js";
import TimelineItem from "./dist/TimelineItem.js";
import Title from "./dist/Title.js";
import Token from "./dist/Token.js";
import Tokenizer from "./dist/Tokenizer.js";
import ToggleButton from "./dist/ToggleButton.js";

import List from "./dist/List.js";
Expand Down
3 changes: 2 additions & 1 deletion packages/main/lib/i18n-transform/USED_KEYS.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
TEXTAREA_CHARACTERS_LEFT
TEXTAREA_CHARACTERS_EXCEEDED
PANEL_ICON
PANEL_ICON
MULTIINPUT_SHOW_MORE_TOKENS
4 changes: 4 additions & 0 deletions packages/main/src/Input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<div id="{{ctr._id}}-wrapper"
class="{{classes.wrapper}}"
>
{{#if ctr._beginContent}}
<slot name="_beginContent"></slot>
{{/if}}

<input id="{{ctr._id}}-inner"
class="sapWCInputBaseInner"
type="{{type}}"
Expand Down
5 changes: 5 additions & 0 deletions packages/main/src/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import UI5Element from "@ui5/webcomponents-base/src/UI5Element.js";
import Bootstrap from "@ui5/webcomponents-base/src/Bootstrap.js";
import { isIE } from "@ui5/webcomponents-core/dist/sap/ui/Device.js";
import ValueState from "@ui5/webcomponents-base/src/types/ValueState.js";

import {
isUp,
isDown,
Expand Down Expand Up @@ -61,6 +62,10 @@ const metadata = {
type: HTMLElement,
multiple: true,
},

_beginContent: {
type: HTMLElement,
},
},
properties: /** @lends sap.ui.webcomponents.main.Input.prototype */ {

Expand Down
70 changes: 70 additions & 0 deletions packages/main/src/MultiComboBox.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<div class="ui5-multi-combobox--wrapper">
<ui5-input id="ui5-multi-combobox--input"
value="{{ctr.value}}"
placeholder="{{ctr.placeholder}}"
?disabled={{ctr.disabled}}
?readonly={{ctr.readonly}}
value-state="{{ctr.valueState}}"
show-suggestions
@ui5-input="{{ctr._inputLiveChange}}"
@ui5-change={{ctr._inputChange}}
@keydown="{{ctr._keydown}}">

<ui5-tokenizer slot="_beginContent"
show-more
class="ui5-multi-combobox-tokenizer"
?disabled="{{ctr.disabled}}"
@ui5-showMoreItemsPress="{{ctr._showMorePopover}}"
@ui5-tokenDelete="{{ctr._tokenDelete}}"
@focusout="{{ctr._tokenizerFocusOut}}"
>
{{#each ctr.items}}
{{#if this.selected}}
<ui5-token ?readonly="{{../../ctr.readonly}}" class="ui5-multi-combobox--token" data-ui5-id="{{this._id}}" >{{this.textContent}}</ui5-token>
{{/if}}
{{/each}}
</ui5-tokenizer>

{{#unless ctr.readonly}}
<ui5-icon src="sap-icon://slim-arrow-down"
slot="icon"
@ui5-press={{ctr._showAllItemsPopover}}
class="{{classes.icon}}"
></ui5-icon>
{{/unless}}
</ui5-input>

<ui5-popover
class="ui5-multi-combobox-selected-items--popover"
horizontal-align="Stretch"
hide-header
?hide-arrow={{editable}}
placement-type="Bottom">
<ui5-list separators="None" mode="{{selectedItemsListMode}}"
@ui5-selectionChange={{ctr._selectedItemsSelectionChange}}>
{{#each ctr.items}}
{{#if this.selected}}
<ui5-li type="Active" data-ui5-token-id="{{this._id}}" .selected="{{../../editable}}">{{this.textContent}}</ui5-li>
{{/if}}
{{/each}}
</ui5-list>
</ui5-popover>

<ui5-popover class="ui5-multi-combobox-all-items--popover"
hide-header
hide-arrow
horizontal-align="Stretch"
initial-focus="ui5-multi-combobox--input"
horizontal-align="Left"
placement-type="Bottom"
@ui5-selectionChange={{ctr._allItemsSelectionChange}}
@ui5-afterClose={{ctr._afterAllPopoverClose}}
@ui5-afterOpen={{ctr._afterAllPopoverOpen}}>
<ui5-list separators="None" mode="MultiSelect" class="ui5-multi-combobox-all-items-list">
{{#each ctr._filteredItems}}
<ui5-li type="Active" ?selected={{this.selected}} data-ui5-token-id="{{this._id}}">{{this.textContent}}</ui5-li>
{{/each}}
</ui5-list>
</ui5-popover>

</div>
Loading