cx 25.5.2 → 25.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts.js +40 -21
- package/dist/manifest.js +686 -686
- package/dist/widgets.js +30 -24
- package/package.json +2 -2
- package/src/charts/Legend.d.ts +45 -45
- package/src/charts/LegendEntry.js +128 -128
- package/src/charts/LegendEntry.scss +27 -27
- package/src/charts/LineGraph.js +1 -1
- package/src/charts/PieChart.d.ts +92 -92
- package/src/charts/RangeMarker.js +159 -159
- package/src/charts/axis/Axis.d.ts +113 -113
- package/src/charts/axis/Axis.js +280 -280
- package/src/charts/axis/CategoryAxis.d.ts +30 -30
- package/src/charts/axis/CategoryAxis.js +241 -241
- package/src/charts/axis/NumericAxis.d.ts +46 -46
- package/src/charts/axis/NumericAxis.js +351 -351
- package/src/charts/axis/Stack.js +55 -55
- package/src/charts/axis/TimeAxis.js +611 -611
- package/src/charts/helpers/PointReducer.d.ts +9 -0
- package/src/charts/helpers/PointReducer.js +36 -22
- package/src/charts/helpers/SnapPointFinder.js +69 -69
- package/src/data/Binding.spec.js +69 -69
- package/src/data/Expression.js +229 -229
- package/src/data/Expression.spec.js +229 -229
- package/src/data/Ref.d.ts +24 -24
- package/src/data/Ref.spec.js +79 -79
- package/src/data/StoreRef.spec.js +24 -24
- package/src/data/StringTemplate.js +92 -92
- package/src/data/StringTemplate.spec.js +132 -132
- package/src/data/StructuredDataAccessor.d.ts +7 -7
- package/src/data/StructuredSelector.js +132 -132
- package/src/data/SubscribableView.js +54 -54
- package/src/data/getAccessor.spec.js +11 -11
- package/src/data/getSelector.js +49 -49
- package/src/hooks/createLocalStorageRef.d.ts +3 -3
- package/src/hooks/createLocalStorageRef.js +20 -20
- package/src/index.scss +6 -6
- package/src/ui/Culture.d.ts +57 -57
- package/src/ui/Culture.js +139 -139
- package/src/ui/FocusManager.js +171 -171
- package/src/ui/Format.js +108 -108
- package/src/ui/HoverSync.js +147 -147
- package/src/ui/Repeater.d.ts +61 -61
- package/src/ui/createFunctionalComponent.d.ts +1 -1
- package/src/ui/layout/ContentPlaceholder.d.ts +19 -19
- package/src/ui/layout/ContentPlaceholder.js +105 -105
- package/src/ui/layout/ContentPlaceholder.spec.js +579 -579
- package/src/ui/layout/LabelsTopLayout.js +134 -134
- package/src/util/Format.js +270 -270
- package/src/util/date/encodeDate.d.ts +1 -1
- package/src/util/date/encodeDate.js +8 -8
- package/src/util/date/encodeDateWithTimezoneOffset.d.ts +1 -1
- package/src/util/date/index.d.ts +11 -11
- package/src/util/date/index.js +11 -11
- package/src/util/date/parseDateInvariant.d.ts +3 -3
- package/src/util/date/parseDateInvariant.js +20 -20
- package/src/util/debounce.js +18 -18
- package/src/util/getSearchQueryPredicate.js +59 -59
- package/src/util/index.d.ts +51 -51
- package/src/util/index.js +54 -54
- package/src/util/isValidIdentifierName.d.ts +1 -1
- package/src/util/isValidIdentifierName.js +5 -5
- package/src/util/isValidIdentifierName.spec.js +33 -33
- package/src/util/scss/add-rules.scss +38 -38
- package/src/util/validatedDebounce.js +19 -19
- package/src/widgets/Button.js +118 -118
- package/src/widgets/CxCredit.scss +37 -37
- package/src/widgets/HighlightedSearchText.js +36 -36
- package/src/widgets/HighlightedSearchText.scss +18 -18
- package/src/widgets/List.scss +91 -91
- package/src/widgets/drag-drop/DropZone.js +214 -214
- package/src/widgets/form/Calendar.d.ts +86 -86
- package/src/widgets/form/Calendar.js +618 -618
- package/src/widgets/form/Calendar.scss +196 -196
- package/src/widgets/form/Checkbox.js +203 -203
- package/src/widgets/form/Checkbox.scss +127 -127
- package/src/widgets/form/ColorField.js +397 -397
- package/src/widgets/form/ColorField.scss +96 -96
- package/src/widgets/form/ColorPicker.scss +283 -283
- package/src/widgets/form/DateTimeField.js +576 -576
- package/src/widgets/form/DateTimePicker.js +392 -392
- package/src/widgets/form/LookupField.d.ts +179 -179
- package/src/widgets/form/LookupField.scss +219 -219
- package/src/widgets/form/MonthField.d.ts +5 -0
- package/src/widgets/form/MonthField.js +1 -0
- package/src/widgets/form/MonthPicker.d.ts +13 -0
- package/src/widgets/form/MonthPicker.js +25 -21
- package/src/widgets/form/MonthPicker.scss +118 -118
- package/src/widgets/form/NumberField.js +459 -459
- package/src/widgets/form/NumberField.scss +61 -61
- package/src/widgets/form/Radio.scss +121 -121
- package/src/widgets/form/Select.scss +99 -99
- package/src/widgets/form/Slider.scss +118 -118
- package/src/widgets/form/Switch.scss +140 -140
- package/src/widgets/form/TextArea.scss +43 -43
- package/src/widgets/form/TextField.js +290 -290
- package/src/widgets/form/TextField.scss +55 -55
- package/src/widgets/form/UploadButton.d.ts +34 -34
- package/src/widgets/form/variables.scss +353 -353
- package/src/widgets/grid/Grid.d.ts +442 -442
- package/src/widgets/grid/GridRow.js +228 -228
- package/src/widgets/grid/TreeNode.d.ts +23 -23
- package/src/widgets/grid/TreeNode.scss +88 -88
- package/src/widgets/grid/variables.scss +133 -133
- package/src/widgets/nav/LinkButton.js +128 -128
- package/src/widgets/nav/Menu.scss +74 -74
- package/src/widgets/overlay/Dropdown.js +612 -612
- package/src/widgets/overlay/FlyweightTooltipTracker.js +39 -39
- package/src/widgets/overlay/Overlay.d.ts +73 -73
- package/src/widgets/overlay/Window.js +202 -202
- package/src/widgets/overlay/captureMouse.js +124 -124
- package/src/widgets/overlay/createHotPromiseWindowFactory.d.ts +18 -18
- package/src/widgets/overlay/createHotPromiseWindowFactory.js +56 -56
- package/src/widgets/overlay/index.d.ts +11 -11
- package/src/widgets/overlay/index.js +11 -11
- package/src/widgets/variables.scss +144 -144
|
@@ -1,203 +1,203 @@
|
|
|
1
|
-
import { Widget, VDOM, getContent } from "../../ui/Widget";
|
|
2
|
-
import { Field, getFieldTooltip } from "./Field";
|
|
3
|
-
import { tooltipMouseMove, tooltipMouseLeave } from "../overlay/tooltip-ops";
|
|
4
|
-
import { stopPropagation } from "../../util/eventCallbacks";
|
|
5
|
-
import { KeyCode } from "../../util/KeyCode";
|
|
6
|
-
import CheckIcon from "../icons/check";
|
|
7
|
-
import SquareIcon from "../icons/square";
|
|
8
|
-
|
|
9
|
-
export class Checkbox extends Field {
|
|
10
|
-
init() {
|
|
11
|
-
if (this.checked) this.value = this.checked;
|
|
12
|
-
|
|
13
|
-
super.init();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declareData() {
|
|
17
|
-
super.declareData(
|
|
18
|
-
{
|
|
19
|
-
value: !this.indeterminate ? false : undefined,
|
|
20
|
-
text: undefined,
|
|
21
|
-
readOnly: undefined,
|
|
22
|
-
disabled: undefined,
|
|
23
|
-
enabled: undefined,
|
|
24
|
-
required: undefined,
|
|
25
|
-
viewText: undefined,
|
|
26
|
-
},
|
|
27
|
-
...arguments,
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
renderWrap(context, instance, key, content) {
|
|
32
|
-
let { data } = instance;
|
|
33
|
-
return (
|
|
34
|
-
<label
|
|
35
|
-
key={key}
|
|
36
|
-
className={data.classNames}
|
|
37
|
-
onMouseDown={(e) => {
|
|
38
|
-
e.stopPropagation();
|
|
39
|
-
if (this.unfocusable) e.preventDefault();
|
|
40
|
-
}}
|
|
41
|
-
onMouseMove={(e) => tooltipMouseMove(e, ...getFieldTooltip(instance))}
|
|
42
|
-
onMouseLeave={(e) => tooltipMouseLeave(e, ...getFieldTooltip(instance))}
|
|
43
|
-
onClick={(e) => {
|
|
44
|
-
this.handleClick(e, instance);
|
|
45
|
-
}}
|
|
46
|
-
style={data.style}
|
|
47
|
-
>
|
|
48
|
-
{content}
|
|
49
|
-
{this.labelPlacement && getContent(this.renderLabel(context, instance, "label"))}
|
|
50
|
-
</label>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
validateRequired(context, instance) {
|
|
55
|
-
let { data } = instance;
|
|
56
|
-
if (!data.value) return this.requiredText;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
renderNativeCheck(context, instance) {
|
|
60
|
-
let { CSS, baseClass } = this;
|
|
61
|
-
let { data } = instance;
|
|
62
|
-
return (
|
|
63
|
-
<input
|
|
64
|
-
key="input"
|
|
65
|
-
className={CSS.element(baseClass, "checkbox")}
|
|
66
|
-
id={data.id}
|
|
67
|
-
type="checkbox"
|
|
68
|
-
checked={data.value || false}
|
|
69
|
-
disabled={data.disabled}
|
|
70
|
-
{...data.inputAttrs}
|
|
71
|
-
onClick={stopPropagation}
|
|
72
|
-
onChange={(e) => {
|
|
73
|
-
this.handleChange(e, instance);
|
|
74
|
-
}}
|
|
75
|
-
/>
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
renderCheck(context, instance) {
|
|
80
|
-
return <CheckboxCmp key="check" instance={instance} data={instance.data} />;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
renderInput(context, instance, key) {
|
|
84
|
-
let { data } = instance;
|
|
85
|
-
let text = data.text || this.renderChildren(context, instance);
|
|
86
|
-
let { CSS, baseClass } = this;
|
|
87
|
-
return this.renderWrap(context, instance, key, [
|
|
88
|
-
this.native ? this.renderNativeCheck(context, instance) : this.renderCheck(context, instance),
|
|
89
|
-
text ? (
|
|
90
|
-
<div key="text" className={CSS.element(baseClass, "text")}>
|
|
91
|
-
{text}
|
|
92
|
-
</div>
|
|
93
|
-
) : (
|
|
94
|
-
<span key="baseline" className={CSS.element(baseClass, "baseline")}>
|
|
95
|
-
|
|
96
|
-
</span>
|
|
97
|
-
),
|
|
98
|
-
]);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
renderValue(context, { data }) {
|
|
102
|
-
if (!data.viewText) return super.renderValue(...arguments);
|
|
103
|
-
return <span className={this.CSS.element(this.baseClass, "view-text")}>{data.viewText}</span>;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
formatValue(context, instance) {
|
|
107
|
-
let { data } = instance;
|
|
108
|
-
return data.value && (data.text || this.renderChildren(context, instance));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
handleClick(e, instance) {
|
|
112
|
-
if (this.native) e.stopPropagation();
|
|
113
|
-
else {
|
|
114
|
-
var el = document.getElementById(instance.data.id);
|
|
115
|
-
if (el) el.focus();
|
|
116
|
-
if (!instance.data.viewMode) {
|
|
117
|
-
e.preventDefault();
|
|
118
|
-
e.stopPropagation();
|
|
119
|
-
this.handleChange(e, instance, !instance.data.value);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
handleChange(e, instance, checked) {
|
|
125
|
-
let { data } = instance;
|
|
126
|
-
|
|
127
|
-
if (data.readOnly || data.disabled || data.viewMode) return;
|
|
128
|
-
|
|
129
|
-
instance.set("value", checked != null ? checked : e.target.checked);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
Checkbox.prototype.baseClass = "checkbox";
|
|
134
|
-
Checkbox.prototype.native = false;
|
|
135
|
-
Checkbox.prototype.indeterminate = false;
|
|
136
|
-
Checkbox.prototype.unfocusable = false;
|
|
137
|
-
|
|
138
|
-
Widget.alias("checkbox", Checkbox);
|
|
139
|
-
|
|
140
|
-
class CheckboxCmp extends VDOM.Component {
|
|
141
|
-
constructor(props) {
|
|
142
|
-
super(props);
|
|
143
|
-
this.state = {
|
|
144
|
-
value: props.data.value,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
UNSAFE_componentWillReceiveProps(props) {
|
|
149
|
-
this.setState({
|
|
150
|
-
value: props.data.value,
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
render() {
|
|
155
|
-
let { instance, data } = this.props;
|
|
156
|
-
let { widget } = instance;
|
|
157
|
-
let { baseClass, CSS } = widget;
|
|
158
|
-
|
|
159
|
-
let check = false;
|
|
160
|
-
|
|
161
|
-
if (this.state.value == null && widget.indeterminate) check = "indeterminate";
|
|
162
|
-
else if (this.state.value) check = "check";
|
|
163
|
-
|
|
164
|
-
return (
|
|
165
|
-
<span
|
|
166
|
-
key="check"
|
|
167
|
-
tabIndex={widget.unfocusable || data.disabled ? null : data.tabIndex || 0}
|
|
168
|
-
className={CSS.element(baseClass, "input", {
|
|
169
|
-
checked: check,
|
|
170
|
-
})}
|
|
171
|
-
style={CSS.parseStyle(data.inputStyle)}
|
|
172
|
-
id={data.id}
|
|
173
|
-
onClick={this.onClick.bind(this)}
|
|
174
|
-
onKeyDown={this.onKeyDown.bind(this)}
|
|
175
|
-
>
|
|
176
|
-
{check == "check" && <CheckIcon className={CSS.element(baseClass, "input-check")} />}
|
|
177
|
-
{check == "indeterminate" && <SquareIcon className={CSS.element(baseClass, "input-check")} />}
|
|
178
|
-
</span>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
onClick(e) {
|
|
183
|
-
let { instance, data } = this.props;
|
|
184
|
-
let { widget } = instance;
|
|
185
|
-
if (!data.disabled && !data.readOnly) {
|
|
186
|
-
e.stopPropagation();
|
|
187
|
-
e.preventDefault();
|
|
188
|
-
this.setState({ value: !this.state.value });
|
|
189
|
-
widget.handleChange(e, instance, !this.state.value);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
onKeyDown(e) {
|
|
194
|
-
let { instance } = this.props;
|
|
195
|
-
if (instance.widget.handleKeyDown(e, instance) === false) return;
|
|
196
|
-
|
|
197
|
-
switch (e.keyCode) {
|
|
198
|
-
case KeyCode.space:
|
|
199
|
-
this.onClick(e);
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
1
|
+
import { Widget, VDOM, getContent } from "../../ui/Widget";
|
|
2
|
+
import { Field, getFieldTooltip } from "./Field";
|
|
3
|
+
import { tooltipMouseMove, tooltipMouseLeave } from "../overlay/tooltip-ops";
|
|
4
|
+
import { stopPropagation } from "../../util/eventCallbacks";
|
|
5
|
+
import { KeyCode } from "../../util/KeyCode";
|
|
6
|
+
import CheckIcon from "../icons/check";
|
|
7
|
+
import SquareIcon from "../icons/square";
|
|
8
|
+
|
|
9
|
+
export class Checkbox extends Field {
|
|
10
|
+
init() {
|
|
11
|
+
if (this.checked) this.value = this.checked;
|
|
12
|
+
|
|
13
|
+
super.init();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declareData() {
|
|
17
|
+
super.declareData(
|
|
18
|
+
{
|
|
19
|
+
value: !this.indeterminate ? false : undefined,
|
|
20
|
+
text: undefined,
|
|
21
|
+
readOnly: undefined,
|
|
22
|
+
disabled: undefined,
|
|
23
|
+
enabled: undefined,
|
|
24
|
+
required: undefined,
|
|
25
|
+
viewText: undefined,
|
|
26
|
+
},
|
|
27
|
+
...arguments,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
renderWrap(context, instance, key, content) {
|
|
32
|
+
let { data } = instance;
|
|
33
|
+
return (
|
|
34
|
+
<label
|
|
35
|
+
key={key}
|
|
36
|
+
className={data.classNames}
|
|
37
|
+
onMouseDown={(e) => {
|
|
38
|
+
e.stopPropagation();
|
|
39
|
+
if (this.unfocusable) e.preventDefault();
|
|
40
|
+
}}
|
|
41
|
+
onMouseMove={(e) => tooltipMouseMove(e, ...getFieldTooltip(instance))}
|
|
42
|
+
onMouseLeave={(e) => tooltipMouseLeave(e, ...getFieldTooltip(instance))}
|
|
43
|
+
onClick={(e) => {
|
|
44
|
+
this.handleClick(e, instance);
|
|
45
|
+
}}
|
|
46
|
+
style={data.style}
|
|
47
|
+
>
|
|
48
|
+
{content}
|
|
49
|
+
{this.labelPlacement && getContent(this.renderLabel(context, instance, "label"))}
|
|
50
|
+
</label>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
validateRequired(context, instance) {
|
|
55
|
+
let { data } = instance;
|
|
56
|
+
if (!data.value) return this.requiredText;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
renderNativeCheck(context, instance) {
|
|
60
|
+
let { CSS, baseClass } = this;
|
|
61
|
+
let { data } = instance;
|
|
62
|
+
return (
|
|
63
|
+
<input
|
|
64
|
+
key="input"
|
|
65
|
+
className={CSS.element(baseClass, "checkbox")}
|
|
66
|
+
id={data.id}
|
|
67
|
+
type="checkbox"
|
|
68
|
+
checked={data.value || false}
|
|
69
|
+
disabled={data.disabled}
|
|
70
|
+
{...data.inputAttrs}
|
|
71
|
+
onClick={stopPropagation}
|
|
72
|
+
onChange={(e) => {
|
|
73
|
+
this.handleChange(e, instance);
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
renderCheck(context, instance) {
|
|
80
|
+
return <CheckboxCmp key="check" instance={instance} data={instance.data} />;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
renderInput(context, instance, key) {
|
|
84
|
+
let { data } = instance;
|
|
85
|
+
let text = data.text || this.renderChildren(context, instance);
|
|
86
|
+
let { CSS, baseClass } = this;
|
|
87
|
+
return this.renderWrap(context, instance, key, [
|
|
88
|
+
this.native ? this.renderNativeCheck(context, instance) : this.renderCheck(context, instance),
|
|
89
|
+
text ? (
|
|
90
|
+
<div key="text" className={CSS.element(baseClass, "text")}>
|
|
91
|
+
{text}
|
|
92
|
+
</div>
|
|
93
|
+
) : (
|
|
94
|
+
<span key="baseline" className={CSS.element(baseClass, "baseline")}>
|
|
95
|
+
|
|
96
|
+
</span>
|
|
97
|
+
),
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
renderValue(context, { data }) {
|
|
102
|
+
if (!data.viewText) return super.renderValue(...arguments);
|
|
103
|
+
return <span className={this.CSS.element(this.baseClass, "view-text")}>{data.viewText}</span>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
formatValue(context, instance) {
|
|
107
|
+
let { data } = instance;
|
|
108
|
+
return data.value && (data.text || this.renderChildren(context, instance));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
handleClick(e, instance) {
|
|
112
|
+
if (this.native) e.stopPropagation();
|
|
113
|
+
else {
|
|
114
|
+
var el = document.getElementById(instance.data.id);
|
|
115
|
+
if (el) el.focus();
|
|
116
|
+
if (!instance.data.viewMode) {
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
e.stopPropagation();
|
|
119
|
+
this.handleChange(e, instance, !instance.data.value);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
handleChange(e, instance, checked) {
|
|
125
|
+
let { data } = instance;
|
|
126
|
+
|
|
127
|
+
if (data.readOnly || data.disabled || data.viewMode) return;
|
|
128
|
+
|
|
129
|
+
instance.set("value", checked != null ? checked : e.target.checked);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
Checkbox.prototype.baseClass = "checkbox";
|
|
134
|
+
Checkbox.prototype.native = false;
|
|
135
|
+
Checkbox.prototype.indeterminate = false;
|
|
136
|
+
Checkbox.prototype.unfocusable = false;
|
|
137
|
+
|
|
138
|
+
Widget.alias("checkbox", Checkbox);
|
|
139
|
+
|
|
140
|
+
class CheckboxCmp extends VDOM.Component {
|
|
141
|
+
constructor(props) {
|
|
142
|
+
super(props);
|
|
143
|
+
this.state = {
|
|
144
|
+
value: props.data.value,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
UNSAFE_componentWillReceiveProps(props) {
|
|
149
|
+
this.setState({
|
|
150
|
+
value: props.data.value,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
render() {
|
|
155
|
+
let { instance, data } = this.props;
|
|
156
|
+
let { widget } = instance;
|
|
157
|
+
let { baseClass, CSS } = widget;
|
|
158
|
+
|
|
159
|
+
let check = false;
|
|
160
|
+
|
|
161
|
+
if (this.state.value == null && widget.indeterminate) check = "indeterminate";
|
|
162
|
+
else if (this.state.value) check = "check";
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<span
|
|
166
|
+
key="check"
|
|
167
|
+
tabIndex={widget.unfocusable || data.disabled ? null : data.tabIndex || 0}
|
|
168
|
+
className={CSS.element(baseClass, "input", {
|
|
169
|
+
checked: check,
|
|
170
|
+
})}
|
|
171
|
+
style={CSS.parseStyle(data.inputStyle)}
|
|
172
|
+
id={data.id}
|
|
173
|
+
onClick={this.onClick.bind(this)}
|
|
174
|
+
onKeyDown={this.onKeyDown.bind(this)}
|
|
175
|
+
>
|
|
176
|
+
{check == "check" && <CheckIcon className={CSS.element(baseClass, "input-check")} />}
|
|
177
|
+
{check == "indeterminate" && <SquareIcon className={CSS.element(baseClass, "input-check")} />}
|
|
178
|
+
</span>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
onClick(e) {
|
|
183
|
+
let { instance, data } = this.props;
|
|
184
|
+
let { widget } = instance;
|
|
185
|
+
if (!data.disabled && !data.readOnly) {
|
|
186
|
+
e.stopPropagation();
|
|
187
|
+
e.preventDefault();
|
|
188
|
+
this.setState({ value: !this.state.value });
|
|
189
|
+
widget.handleChange(e, instance, !this.state.value);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
onKeyDown(e) {
|
|
194
|
+
let { instance } = this.props;
|
|
195
|
+
if (instance.widget.handleKeyDown(e, instance) === false) return;
|
|
196
|
+
|
|
197
|
+
switch (e.keyCode) {
|
|
198
|
+
case KeyCode.space:
|
|
199
|
+
this.onClick(e);
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
@mixin cx-checkbox(
|
|
2
|
-
$name: "checkbox",
|
|
3
|
-
$state-style-map: $cx-checkbox-state-style-map,
|
|
4
|
-
$width: $cx-default-input-width,
|
|
5
|
-
$empty-text: $cx-empty-text,
|
|
6
|
-
$besm: $cx-besm,
|
|
7
|
-
$size: $cx-default-checkbox-size
|
|
8
|
-
) {
|
|
9
|
-
$block: map-get($besm, block);
|
|
10
|
-
$element: map-get($besm, element);
|
|
11
|
-
$state: map-get($besm, state);
|
|
12
|
-
|
|
13
|
-
$padding: cx-get-state-rule($state-style-map, default, padding);
|
|
14
|
-
$border-width: cx-get-state-rule($state-style-map, default, border-width);
|
|
15
|
-
|
|
16
|
-
$outer-styles: cx-deep-map-merge(
|
|
17
|
-
$state-style-map,
|
|
18
|
-
(
|
|
19
|
-
default: (
|
|
20
|
-
border-width: cx-top($cx-default-box-border-width) 0 cx-bottom($cx-default-box-border-width) 0,
|
|
21
|
-
),
|
|
22
|
-
)
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
.#{$block}#{$name} {
|
|
26
|
-
min-width: $size;
|
|
27
|
-
@include cxb-field($besm, $outer-styles, $input: false, $box: true);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.#{$element}#{$name}-checkbox {
|
|
31
|
-
padding: 0;
|
|
32
|
-
margin: 0 !important;
|
|
33
|
-
width: $size;
|
|
34
|
-
height: $size;
|
|
35
|
-
top: calc(50% - #{$size * 0.5});
|
|
36
|
-
left: 0;
|
|
37
|
-
display: inline-block;
|
|
38
|
-
position: absolute;
|
|
39
|
-
//-webkit-appearance: none;
|
|
40
|
-
|
|
41
|
-
&::-moz-focus-inner {
|
|
42
|
-
border: 0;
|
|
43
|
-
padding: 0;
|
|
44
|
-
margin: -1px;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
&:focus {
|
|
48
|
-
box-shadow:
|
|
49
|
-
inset 0 0 1px 1px rgba(77, 144, 254, 0.8),
|
|
50
|
-
0 0 2px 2px rgba(77, 144, 254, 0.8);
|
|
51
|
-
background: rgba(77, 144, 254, 0.8);
|
|
52
|
-
outline: 0;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.#{$element}#{$name}-text {
|
|
57
|
-
display: inline-block;
|
|
58
|
-
margin-left: $size;
|
|
59
|
-
user-select: none;
|
|
60
|
-
|
|
61
|
-
.#{$state}disabled > & {
|
|
62
|
-
opacity: 0.5;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.#{$element}#{$name}-baseline {
|
|
67
|
-
user-select: none;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.#{$element}#{$name}-empty-text {
|
|
71
|
-
@include cxe-field-empty-text($empty-text);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
//non-native implementation
|
|
75
|
-
.#{$element}#{$name}-input {
|
|
76
|
-
width: $size;
|
|
77
|
-
height: $size;
|
|
78
|
-
top: calc(50% - #{$size * 0.5});
|
|
79
|
-
left: 0;
|
|
80
|
-
display: inline-block;
|
|
81
|
-
position: absolute;
|
|
82
|
-
|
|
83
|
-
@include cxe-field-input(
|
|
84
|
-
$besm,
|
|
85
|
-
$state-style-map,
|
|
86
|
-
$input: false,
|
|
87
|
-
$overrides: (
|
|
88
|
-
default: (
|
|
89
|
-
padding: 0,
|
|
90
|
-
margin: 0 !important,
|
|
91
|
-
)
|
|
92
|
-
)
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
&.#{$state}checked {
|
|
96
|
-
@include cx-add-state-rules($state-style-map, checked);
|
|
97
|
-
|
|
98
|
-
&:focus {
|
|
99
|
-
@include cx-add-state-rules($state-style-map, checked-focus);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.#{$state}disabled > & {
|
|
103
|
-
@include cx-add-state-rules($state-style-map, disabled-checked);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.#{$element}#{$name}-input-check {
|
|
109
|
-
width: 100%;
|
|
110
|
-
height: 100%;
|
|
111
|
-
visibility: hidden;
|
|
112
|
-
position: absolute;
|
|
113
|
-
display: block;
|
|
114
|
-
left: 0;
|
|
115
|
-
top: 0;
|
|
116
|
-
right: 0;
|
|
117
|
-
bottom: 0;
|
|
118
|
-
|
|
119
|
-
.#{$state}checked > & {
|
|
120
|
-
visibility: visible;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
@if (cx-should-include("cx/widgets/Checkbox")) {
|
|
126
|
-
@include cx-checkbox();
|
|
127
|
-
}
|
|
1
|
+
@mixin cx-checkbox(
|
|
2
|
+
$name: "checkbox",
|
|
3
|
+
$state-style-map: $cx-checkbox-state-style-map,
|
|
4
|
+
$width: $cx-default-input-width,
|
|
5
|
+
$empty-text: $cx-empty-text,
|
|
6
|
+
$besm: $cx-besm,
|
|
7
|
+
$size: $cx-default-checkbox-size
|
|
8
|
+
) {
|
|
9
|
+
$block: map-get($besm, block);
|
|
10
|
+
$element: map-get($besm, element);
|
|
11
|
+
$state: map-get($besm, state);
|
|
12
|
+
|
|
13
|
+
$padding: cx-get-state-rule($state-style-map, default, padding);
|
|
14
|
+
$border-width: cx-get-state-rule($state-style-map, default, border-width);
|
|
15
|
+
|
|
16
|
+
$outer-styles: cx-deep-map-merge(
|
|
17
|
+
$state-style-map,
|
|
18
|
+
(
|
|
19
|
+
default: (
|
|
20
|
+
border-width: cx-top($cx-default-box-border-width) 0 cx-bottom($cx-default-box-border-width) 0,
|
|
21
|
+
),
|
|
22
|
+
)
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
.#{$block}#{$name} {
|
|
26
|
+
min-width: $size;
|
|
27
|
+
@include cxb-field($besm, $outer-styles, $input: false, $box: true);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.#{$element}#{$name}-checkbox {
|
|
31
|
+
padding: 0;
|
|
32
|
+
margin: 0 !important;
|
|
33
|
+
width: $size;
|
|
34
|
+
height: $size;
|
|
35
|
+
top: calc(50% - #{$size * 0.5});
|
|
36
|
+
left: 0;
|
|
37
|
+
display: inline-block;
|
|
38
|
+
position: absolute;
|
|
39
|
+
//-webkit-appearance: none;
|
|
40
|
+
|
|
41
|
+
&::-moz-focus-inner {
|
|
42
|
+
border: 0;
|
|
43
|
+
padding: 0;
|
|
44
|
+
margin: -1px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&:focus {
|
|
48
|
+
box-shadow:
|
|
49
|
+
inset 0 0 1px 1px rgba(77, 144, 254, 0.8),
|
|
50
|
+
0 0 2px 2px rgba(77, 144, 254, 0.8);
|
|
51
|
+
background: rgba(77, 144, 254, 0.8);
|
|
52
|
+
outline: 0;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.#{$element}#{$name}-text {
|
|
57
|
+
display: inline-block;
|
|
58
|
+
margin-left: $size;
|
|
59
|
+
user-select: none;
|
|
60
|
+
|
|
61
|
+
.#{$state}disabled > & {
|
|
62
|
+
opacity: 0.5;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.#{$element}#{$name}-baseline {
|
|
67
|
+
user-select: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.#{$element}#{$name}-empty-text {
|
|
71
|
+
@include cxe-field-empty-text($empty-text);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//non-native implementation
|
|
75
|
+
.#{$element}#{$name}-input {
|
|
76
|
+
width: $size;
|
|
77
|
+
height: $size;
|
|
78
|
+
top: calc(50% - #{$size * 0.5});
|
|
79
|
+
left: 0;
|
|
80
|
+
display: inline-block;
|
|
81
|
+
position: absolute;
|
|
82
|
+
|
|
83
|
+
@include cxe-field-input(
|
|
84
|
+
$besm,
|
|
85
|
+
$state-style-map,
|
|
86
|
+
$input: false,
|
|
87
|
+
$overrides: (
|
|
88
|
+
default: (
|
|
89
|
+
padding: 0,
|
|
90
|
+
margin: 0 !important,
|
|
91
|
+
)
|
|
92
|
+
)
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
&.#{$state}checked {
|
|
96
|
+
@include cx-add-state-rules($state-style-map, checked);
|
|
97
|
+
|
|
98
|
+
&:focus {
|
|
99
|
+
@include cx-add-state-rules($state-style-map, checked-focus);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.#{$state}disabled > & {
|
|
103
|
+
@include cx-add-state-rules($state-style-map, disabled-checked);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.#{$element}#{$name}-input-check {
|
|
109
|
+
width: 100%;
|
|
110
|
+
height: 100%;
|
|
111
|
+
visibility: hidden;
|
|
112
|
+
position: absolute;
|
|
113
|
+
display: block;
|
|
114
|
+
left: 0;
|
|
115
|
+
top: 0;
|
|
116
|
+
right: 0;
|
|
117
|
+
bottom: 0;
|
|
118
|
+
|
|
119
|
+
.#{$state}checked > & {
|
|
120
|
+
visibility: visible;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@if (cx-should-include("cx/widgets/Checkbox")) {
|
|
126
|
+
@include cx-checkbox();
|
|
127
|
+
}
|