-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
38 lines (34 loc) · 891 Bytes
/
index.ts
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
import { configurable, origin, provide, tag, Events, Tag } from '@storefront/core';
import SearchBox from '../search-box';
@configurable
@provide('query')
@origin('search')
@tag('gb-query', require('./index.html'))
class Query {
registered: SearchBox[] = [];
props: Query.Props = {
mode: 'default',
showSayt: true,
};
state: Query.State = {
register: (_tag) => this.registered.push(_tag),
submit: () => {
if (this.registered.length !== 0) {
this.actions.search(this.registered[0].refs.searchBox.value);
}
},
};
}
interface Query extends Tag<Query.Props, Query.State> {}
namespace Query {
export interface Props extends Tag.Props {
// TODO handle other modes
mode: 'default' | 'automatic';
showSayt: boolean;
}
export interface State {
register(tag: SearchBox): void;
submit(): void;
}
}
export default Query;