-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathreactable-extras.js
More file actions
58 lines (46 loc) · 1.87 KB
/
reactable-extras.js
File metadata and controls
58 lines (46 loc) · 1.87 KB
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
53
54
55
56
57
function ButtonExtras ({ id, label, uuid, column, className, children }) {
const onClick = event => {
Shiny.setInputValue(id, { row: uuid, column: column}, { priority: 'event' })
}
return React.createElement('button', { onClick, className, key: uuid }, label)
};
function checkboxExtras ({ id, value, uuid, column, className, children }) {
const onChange = event => {
Shiny.setInputValue(id, { row: uuid, value: event.target.checked, column: column }, { priority: 'event' })
}
return React.createElement('input', { type: 'checkbox', key: uuid, defaultChecked: value, className, onChange })
};
function dateExtras ({ id, value, uuid, column, className, children }) {
const onChange = event => {
Shiny.setInputValue(id, { row: uuid, value: event.target.value, column: column }, { priority: 'event' })
}
return React.createElement(
'input',
{ type: 'date', key: uuid, defaultValue: value, onChange, className }
)
};
function dropdownExtras ({ id, value, uuid, column, choices, className, children }) {
const onChange = event => {
Shiny.setInputValue(id, { row: uuid, value: event.target.value, column: column }, { priority: 'event' })
}
const items = choices.map((name) => {
return React.createElement('option', { value: name }, name)
})
return React.createElement(
'select',
{ onChange, className, key: uuid, defaultValue: value },
items
)
};
function textExtras ({ id, value, uuid, column, page, className, children }) {
const onInput = event => {
Shiny.setInputValue(id, { row: uuid, value: event.target.value, column: column }, { priority: 'event' })
}
const onBlur = event => {
Shiny.setInputValue(`${id}_blur`, { row: uuid, value: event.target.value, column: column }, { priority: 'event' })
}
return React.createElement(
'input',
{ onInput, onBlur, className, defaultValue: value, key: uuid }
)
};