Skip to content

Commit

Permalink
feat(core/select): input event (#608)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Maurer <lukas.maurer@siemens.com>
Co-authored-by: Daniel Leroux <daniel.leroux@siemens.com>
  • Loading branch information
3 people committed Jul 17, 2023
1 parent b7e95f5 commit 750eb8e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/angular/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ export class IxSelect {
constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
c.detach();
this.el = r.nativeElement;
proxyOutputs(this, this.el, ['itemSelectionChange', 'addItem']);
proxyOutputs(this, this.el, ['itemSelectionChange', 'inputChange', 'addItem']);
}
}

Expand All @@ -1703,6 +1703,10 @@ export declare interface IxSelect extends Components.IxSelect {
* Item selection changed
*/
itemSelectionChange: EventEmitter<CustomEvent<string | string[]>>;
/**
* Event dispatched whenever the text input changes. @since 2.0.0
*/
inputChange: EventEmitter<CustomEvent<string>>;
/**
* Item added to selection
*/
Expand Down
14 changes: 14 additions & 0 deletions packages/core/component-doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8802,6 +8802,20 @@
"docs": "Item added to selection",
"docsTags": []
},
{
"event": "inputChange",
"detail": "string",
"bubbles": true,
"cancelable": true,
"composed": true,
"docs": "Event dispatched whenever the text input changes.",
"docsTags": [
{
"name": "since",
"text": "2.0.0"
}
]
},
{
"event": "itemSelectionChange",
"detail": "string | string[]",
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4458,6 +4458,11 @@ declare namespace LocalJSX {
* Item added to selection
*/
"onAddItem"?: (event: IxSelectCustomEvent<string>) => void;
/**
* Event dispatched whenever the text input changes.
* @since 2.0.0
*/
"onInputChange"?: (event: IxSelectCustomEvent<string>) => void;
/**
* Item selection changed
*/
Expand Down
13 changes: 13 additions & 0 deletions packages/core/src/components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ export class Select {
*/
@Event() itemSelectionChange: EventEmitter<string | string[]>;

/**
* Event dispatched whenever the text input changes.
*
* @since 2.0.0
*/
@Event() inputChange: EventEmitter<string>;

/**
* Item added to selection
*/
Expand Down Expand Up @@ -207,6 +214,12 @@ export class Select {
this.inputValue = null;
}

componentDidLoad() {
this.inputRef.addEventListener('input', () => {
this.inputChange.emit(this.inputRef.value);
});
}

componentWillLoad() {
if (this.selectedIndices) {
this.selectValue(
Expand Down
1 change: 1 addition & 0 deletions packages/vue/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ export const IxSelect = /*@__PURE__*/ defineContainer<JSX.IxSelect>('ix-select',
'i18nNoMatches',
'hideListHeader',
'itemSelectionChange',
'inputChange',
'addItem'
]);

Expand Down

0 comments on commit 750eb8e

Please sign in to comment.