cx 25.5.2 → 25.6.0
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 +741 -741
- package/dist/widgets.js +30 -24
- package/package.json +1 -1
- package/src/charts/LineGraph.js +1 -1
- package/src/charts/axis/NumericAxis.d.ts +46 -46
- package/src/charts/helpers/PointReducer.d.ts +9 -0
- package/src/charts/helpers/PointReducer.js +36 -22
- 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/StructuredDataAccessor.d.ts +7 -7
- package/src/data/SubscribableView.js +54 -54
- package/src/ui/createFunctionalComponent.d.ts +1 -1
- package/src/ui/index.d.ts +42 -42
- package/src/util/debounce.js +18 -18
- package/src/util/validatedDebounce.js +19 -19
- package/src/widgets/Button.js +118 -118
- package/src/widgets/form/Calendar.d.ts +86 -86
- package/src/widgets/form/Checkbox.js +203 -203
- 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
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import * as Cx from "../../core";
|
|
2
|
-
import { FieldProps } from "./Field";
|
|
3
|
-
|
|
4
|
-
interface DayInfo {
|
|
5
|
-
mod?: string;
|
|
6
|
-
className?: string;
|
|
7
|
-
style?: Cx.Record;
|
|
8
|
-
unselectable?: boolean;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface DayData {
|
|
13
|
-
[day: string]: DayInfo;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface CalendarProps extends FieldProps {
|
|
17
|
-
/** Selected date. This should be a `Date` object or a valid date string consumable by `Date.parse` function. */
|
|
18
|
-
value?: Cx.Prop<string | Date>;
|
|
19
|
-
|
|
20
|
-
/** View reference date. If no date is selected, this date is used to determine which month to show in the calendar. */
|
|
21
|
-
refDate?: Cx.Prop<string | Date>;
|
|
22
|
-
|
|
23
|
-
/** Minimum date value. This should be a `Date` object or a valid date string consumable by `Date.parse` function. */
|
|
24
|
-
minValue?: Cx.Prop<string | Date>;
|
|
25
|
-
|
|
26
|
-
/** Set to `true` to disallow the `minValue`. Default value is `false`. */
|
|
27
|
-
minExclusive?: Cx.BooleanProp;
|
|
28
|
-
|
|
29
|
-
/** Maximum date value. This should be a `Date` object or a valid date string consumable by `Date.parse` function. */
|
|
30
|
-
maxValue?: Cx.Prop<string | Date>;
|
|
31
|
-
|
|
32
|
-
/** Set to `true` to disallow the `maxValue`. Default value is `false`. */
|
|
33
|
-
maxExclusive?: Cx.BooleanProp;
|
|
34
|
-
|
|
35
|
-
/** Base CSS class to be applied to the calendar. Defaults to `calendar`. */
|
|
36
|
-
baseClass?: string;
|
|
37
|
-
|
|
38
|
-
/** Highlight today's date. Default is true. */
|
|
39
|
-
highlightToday?: boolean;
|
|
40
|
-
|
|
41
|
-
/** Maximum value error text. */
|
|
42
|
-
maxValueErrorText?: string;
|
|
43
|
-
|
|
44
|
-
/** Maximum exclusive value error text. */
|
|
45
|
-
maxExclusiveErrorText?: string;
|
|
46
|
-
|
|
47
|
-
/** Minimum value error text. */
|
|
48
|
-
minValueErrorText?: string;
|
|
49
|
-
|
|
50
|
-
/** Minimum exclusive value error text. */
|
|
51
|
-
minExclusiveErrorText?: string;
|
|
52
|
-
|
|
53
|
-
/** The function that will be used to convert Date objects before writing data to the store.
|
|
54
|
-
* Default implementation is Date.toISOString.
|
|
55
|
-
* See also Culture.setDefaultDateEncoding.
|
|
56
|
-
*/
|
|
57
|
-
encoding?: (date: Date) => any;
|
|
58
|
-
|
|
59
|
-
/** Set to true to show the button for quickly selecting today's date. */
|
|
60
|
-
showTodayButton?: boolean;
|
|
61
|
-
|
|
62
|
-
/** Localizable text for the todayButton. Defaults to `"Today"`. */
|
|
63
|
-
todayButtonText?: string;
|
|
64
|
-
|
|
65
|
-
/** Defines which days of week should be displayed as disabled, i.e. `[0, 6]` will make Sunday and Saturday unselectable. */
|
|
66
|
-
disabledDaysOfWeek?: number[];
|
|
67
|
-
|
|
68
|
-
/** Set to true to show weeks starting from Monday. */
|
|
69
|
-
startWithMonday?: boolean;
|
|
70
|
-
|
|
71
|
-
/** Map of days to additional day information such as style, className, mod, unselectable and disabled.
|
|
72
|
-
* Keys for the map should be created with date.toDateString().
|
|
73
|
-
* Example. {
|
|
74
|
-
* [new Date().toDateString()]: {
|
|
75
|
-
* style: "color: red",
|
|
76
|
-
* className: 'test-class',
|
|
77
|
-
* mod: 'holiday',
|
|
78
|
-
* unselectable: false,
|
|
79
|
-
* disabled: false
|
|
80
|
-
* }
|
|
81
|
-
* }
|
|
82
|
-
*/
|
|
83
|
-
dayData?: Cx.Prop<DayData>;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export class Calendar extends Cx.Widget<CalendarProps> {}
|
|
1
|
+
import * as Cx from "../../core";
|
|
2
|
+
import { FieldProps } from "./Field";
|
|
3
|
+
|
|
4
|
+
interface DayInfo {
|
|
5
|
+
mod?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: Cx.Record;
|
|
8
|
+
unselectable?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface DayData {
|
|
13
|
+
[day: string]: DayInfo;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface CalendarProps extends FieldProps {
|
|
17
|
+
/** Selected date. This should be a `Date` object or a valid date string consumable by `Date.parse` function. */
|
|
18
|
+
value?: Cx.Prop<string | Date>;
|
|
19
|
+
|
|
20
|
+
/** View reference date. If no date is selected, this date is used to determine which month to show in the calendar. */
|
|
21
|
+
refDate?: Cx.Prop<string | Date>;
|
|
22
|
+
|
|
23
|
+
/** Minimum date value. This should be a `Date` object or a valid date string consumable by `Date.parse` function. */
|
|
24
|
+
minValue?: Cx.Prop<string | Date>;
|
|
25
|
+
|
|
26
|
+
/** Set to `true` to disallow the `minValue`. Default value is `false`. */
|
|
27
|
+
minExclusive?: Cx.BooleanProp;
|
|
28
|
+
|
|
29
|
+
/** Maximum date value. This should be a `Date` object or a valid date string consumable by `Date.parse` function. */
|
|
30
|
+
maxValue?: Cx.Prop<string | Date>;
|
|
31
|
+
|
|
32
|
+
/** Set to `true` to disallow the `maxValue`. Default value is `false`. */
|
|
33
|
+
maxExclusive?: Cx.BooleanProp;
|
|
34
|
+
|
|
35
|
+
/** Base CSS class to be applied to the calendar. Defaults to `calendar`. */
|
|
36
|
+
baseClass?: string;
|
|
37
|
+
|
|
38
|
+
/** Highlight today's date. Default is true. */
|
|
39
|
+
highlightToday?: boolean;
|
|
40
|
+
|
|
41
|
+
/** Maximum value error text. */
|
|
42
|
+
maxValueErrorText?: string;
|
|
43
|
+
|
|
44
|
+
/** Maximum exclusive value error text. */
|
|
45
|
+
maxExclusiveErrorText?: string;
|
|
46
|
+
|
|
47
|
+
/** Minimum value error text. */
|
|
48
|
+
minValueErrorText?: string;
|
|
49
|
+
|
|
50
|
+
/** Minimum exclusive value error text. */
|
|
51
|
+
minExclusiveErrorText?: string;
|
|
52
|
+
|
|
53
|
+
/** The function that will be used to convert Date objects before writing data to the store.
|
|
54
|
+
* Default implementation is Date.toISOString.
|
|
55
|
+
* See also Culture.setDefaultDateEncoding.
|
|
56
|
+
*/
|
|
57
|
+
encoding?: (date: Date) => any;
|
|
58
|
+
|
|
59
|
+
/** Set to true to show the button for quickly selecting today's date. */
|
|
60
|
+
showTodayButton?: boolean;
|
|
61
|
+
|
|
62
|
+
/** Localizable text for the todayButton. Defaults to `"Today"`. */
|
|
63
|
+
todayButtonText?: string;
|
|
64
|
+
|
|
65
|
+
/** Defines which days of week should be displayed as disabled, i.e. `[0, 6]` will make Sunday and Saturday unselectable. */
|
|
66
|
+
disabledDaysOfWeek?: number[];
|
|
67
|
+
|
|
68
|
+
/** Set to true to show weeks starting from Monday. */
|
|
69
|
+
startWithMonday?: boolean;
|
|
70
|
+
|
|
71
|
+
/** Map of days to additional day information such as style, className, mod, unselectable and disabled.
|
|
72
|
+
* Keys for the map should be created with date.toDateString().
|
|
73
|
+
* Example. {
|
|
74
|
+
* [new Date().toDateString()]: {
|
|
75
|
+
* style: "color: red",
|
|
76
|
+
* className: 'test-class',
|
|
77
|
+
* mod: 'holiday',
|
|
78
|
+
* unselectable: false,
|
|
79
|
+
* disabled: false
|
|
80
|
+
* }
|
|
81
|
+
* }
|
|
82
|
+
*/
|
|
83
|
+
dayData?: Cx.Prop<DayData>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export class Calendar extends Cx.Widget<CalendarProps> {}
|
|
@@ -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
|
+
}
|
|
@@ -94,6 +94,11 @@ interface MonthFieldProps extends FieldProps {
|
|
|
94
94
|
/** A boolean flag that determines whether the `to` date is included in the range.
|
|
95
95
|
* When set to true the value stored in the to field would be the last day of the month, i.e. `2024-12-31`. */
|
|
96
96
|
inclusiveTo?: boolean;
|
|
97
|
+
|
|
98
|
+
/** Optional configuration options for the MonthPicker component rendered within the dropdown.
|
|
99
|
+
* You can pass any valid additional MonthPicker props here, such as `startYear`, `endYear`, etc.
|
|
100
|
+
* Refer to the MonthPicker component documentation for a full list of supported options. */
|
|
101
|
+
monthPickerOptions?: Cx.Config;
|
|
97
102
|
}
|
|
98
103
|
|
|
99
104
|
export class MonthField extends Cx.Widget<MonthFieldProps> {}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Cx from "../../core";
|
|
2
|
+
import { Instance } from "../../ui";
|
|
2
3
|
import { FieldProps } from "./Field";
|
|
3
4
|
|
|
4
5
|
interface MonthPickerProps extends FieldProps {
|
|
@@ -71,6 +72,18 @@ interface MonthPickerProps extends FieldProps {
|
|
|
71
72
|
/** A boolean flag that determines whether the `to` date is included in the range.
|
|
72
73
|
* When set to true the value stored in the to field would be the last day of the month, i.e. `2024-12-31`. */
|
|
73
74
|
inclusiveTo?: boolean;
|
|
75
|
+
|
|
76
|
+
/** Callback function that is called before writing data to the store. Return false to short-circuit updating the state. */
|
|
77
|
+
onBeforeSelect: (e: Event, instance: Instance, dateFrom?: Date, dateTo?: Date) => boolean;
|
|
78
|
+
|
|
79
|
+
/** Callback function that is called after value or date range has changed */
|
|
80
|
+
onSelect: (instance: Instance, dateFrom?: Date, dateTo?: Date) => void;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Optional parameter to hide the quarters period section on the picker.
|
|
84
|
+
* When true, the quarters section will not render.
|
|
85
|
+
*/
|
|
86
|
+
hideQuarters?: boolean;
|
|
74
87
|
}
|
|
75
88
|
|
|
76
89
|
export class MonthPicker extends Cx.Widget<MonthPickerProps> {}
|