-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathinput-search.js
43 lines (38 loc) · 1.13 KB
/
input-search.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
/**
* @module InputSearch
* This component renders an input that fires a callback on "keyup" containing the input's value
*
* @example
* <InputSearch @initialValue="secret/path/" @onChange={{this.handleSearch}} @placeholder="search..." />
*
* @param {string} [id] - unique id for the input
* @param {string} [initialValue] - initial search value, i.e. a secret path prefix, that pre-fills the input field
* @param {string} [placeholder] - placeholder text for the input
* @param {string} [label] - label for the input
* @param {string} [subtext] - displays below the label
*/
export default class InputSearch extends Component {
/*
* @public
* @param Function
*
* Function called when any of the inputs change
*
*/
@tracked searchInput = '';
constructor() {
super(...arguments);
this.searchInput = this.args?.initialValue;
}
@action
inputChanged() {
this.args.onChange(this.searchInput);
}
}