-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathButton-36d57e33.js
More file actions
30 lines (27 loc) · 1002 Bytes
/
Button-36d57e33.js
File metadata and controls
30 lines (27 loc) · 1002 Bytes
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
import { h } from './index-93b10a2a.js';
// Given a set of provided props and extra props,
// merge to two except for the class prop which is concated
const applyProps = (props, extra = {}) => {
const allKeys = new Set(Object.keys(props).concat(Object.keys(extra)));
return Array.from(allKeys).reduce((v, k) => {
if (k in extra) {
if (k === 'class') {
if (typeof extra[k] === 'string') {
v[k] = `${extra[k]} ${props[k] ? props[k] : ''}`;
}
else {
v[k] = Object.assign(Object.assign({}, props[k]), extra[k]);
}
}
else {
v[k] = extra[k];
}
}
else if (k in props) {
v[k] = props[k];
}
return v;
}, {});
};
const Button = (props, children) => (h("button", Object.assign({}, applyProps(props, { class: 'ui-button' })), children));
export { Button as B, applyProps as a };