forked from erizocosmico/react-categorized-tag-input
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (47 loc) · 901 Bytes
/
index.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
44
45
46
47
48
49
50
51
52
import React from 'react';
import Input from './src/index';
const categories = [
{
id: 'animals',
title: 'Animals',
type: 'animal',
items: ['Dog', 'Cat', 'Bird', 'Dolphin', 'Apes']
},
{
id: 'something',
title: 'Something cool',
items: ['Something cool'],
single: true
},
{
id: 'food',
title: 'food',
type: 'food',
items: ['Apple', 'Banana', 'Grapes', 'Pear']
},
{
id: 'professions',
title: 'Professions',
type: 'profession',
items: ['Waiter', 'Writer', 'Hairdresser', 'Policeman']
}
];
function transformTag(category, item) {
return `${category}/${item}`;
}
const props = {
addNew: true,
categories,
transformTag,
value: ['initial'],
onChange(tags) {
console.log('Changed', tags);
},
onBlur() {
console.log('Blur')
}
};
React.render(
React.createElement(Input, props),
document.body
);