-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathCheckBoxTemplateContext.js
45 lines (38 loc) · 1.04 KB
/
CheckBoxTemplateContext.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
import { isDesktop } from "@ui5/webcomponents-core/dist/sap/ui/Device";
class CheckBoxTemplateContext {
static calculate(state) {
const mainClasses = CheckBoxTemplateContext.getMainClasses(state);
const innerClasses = CheckBoxTemplateContext.getInnerClasses(state);
const context = {
ctr: state,
ariaReadonly: state.readOnly,
tabIndex: state.disabled ? undefined : "0",
classes: { main: mainClasses, inner: innerClasses },
styles: {
main: {},
},
};
return context;
}
static getMainClasses(state) {
return {
sapMCb: true,
sapMCbHasLabel: !!state.text,
sapMCbBgDis: state.disabled,
sapMCbRo: state.readOnly,
sapMCbErr: state.valueState === "Error",
sapMCbWarn: state.valueState === "Warning",
sapMCbWrapped: state.wrap,
};
}
static getInnerClasses(state) {
const hoverable = !state.disabled && !state.readOnly && isDesktop();
return {
sapMCbBg: true,
sapMCbHoverable: hoverable,
sapMCbMark: true,
sapMCbMarkChecked: !!state.checked,
};
}
}
export default CheckBoxTemplateContext;