cx 26.1.13 → 26.2.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/build/charts/Marker.d.ts +1 -1
- package/build/charts/Marker.d.ts.map +1 -1
- package/build/charts/Marker.js +16 -6
- package/build/charts/MouseTracker.d.ts +2 -0
- package/build/charts/MouseTracker.d.ts.map +1 -1
- package/build/charts/helpers/PointReducer.d.ts +2 -2
- package/build/charts/helpers/PointReducer.d.ts.map +1 -1
- package/build/data/View.d.ts +5 -3
- package/build/data/View.d.ts.map +1 -1
- package/build/data/View.js +3 -1
- package/build/data/ops/findTreeNode.d.ts +20 -1
- package/build/data/ops/findTreeNode.d.ts.map +1 -1
- package/build/data/ops/findTreeNode.js +19 -0
- package/build/data/ops/findTreePath.d.ts +1 -1
- package/build/data/ops/findTreePath.d.ts.map +1 -1
- package/build/data/ops/findTreePath.js +1 -1
- package/build/data/ops/removeTreeNodes.d.ts +14 -1
- package/build/data/ops/removeTreeNodes.d.ts.map +1 -1
- package/build/data/ops/removeTreeNodes.js +13 -0
- package/build/data/ops/updateArray.d.ts +1 -1
- package/build/data/ops/updateArray.d.ts.map +1 -1
- package/build/data/ops/updateArray.js +1 -1
- package/build/data/ops/updateTree.d.ts +20 -1
- package/build/data/ops/updateTree.d.ts.map +1 -1
- package/build/data/ops/updateTree.js +19 -0
- package/build/jsx-runtime.d.ts +1 -0
- package/build/jsx-runtime.d.ts.map +1 -1
- package/build/jsx-runtime.js +3 -1
- package/build/svg/Rectangle.d.ts +6 -4
- package/build/svg/Rectangle.d.ts.map +1 -1
- package/build/svg/Rectangle.js +9 -7
- package/build/ui/Instance.d.ts +1 -1
- package/build/ui/Instance.d.ts.map +1 -1
- package/build/ui/Instance.js +18 -8
- package/build/ui/IsolatedScope.d.ts +2 -1
- package/build/ui/IsolatedScope.d.ts.map +1 -1
- package/build/ui/Prop.d.ts +1 -1
- package/build/ui/Prop.d.ts.map +1 -1
- package/build/ui/Widget.d.ts +2 -0
- package/build/ui/Widget.d.ts.map +1 -1
- package/build/ui/Widget.js +4 -0
- package/build/ui/adapter/GroupAdapter.d.ts +4 -4
- package/build/ui/adapter/GroupAdapter.d.ts.map +1 -1
- package/build/ui/adapter/GroupAdapter.js +4 -4
- package/build/ui/adapter/TreeAdapter.d.ts +5 -3
- package/build/ui/adapter/TreeAdapter.d.ts.map +1 -1
- package/build/ui/adapter/TreeAdapter.js +12 -5
- package/build/ui/app/startAppLoop.d.ts +2 -2
- package/build/ui/app/startAppLoop.d.ts.map +1 -1
- package/build/ui/app/startHotAppLoop.d.ts +4 -4
- package/build/ui/app/startHotAppLoop.d.ts.map +1 -1
- package/build/ui/app/startHotAppLoop.js +1 -1
- package/build/ui/batchUpdates.d.ts.map +1 -1
- package/build/ui/batchUpdates.js +3 -4
- package/build/widgets/Button.d.ts +0 -7
- package/build/widgets/Button.d.ts.map +1 -1
- package/build/widgets/HtmlElement.d.ts +2 -2
- package/build/widgets/HtmlElement.d.ts.map +1 -1
- package/build/widgets/form/Checkbox.d.ts +3 -3
- package/build/widgets/form/Checkbox.d.ts.map +1 -1
- package/build/widgets/form/Checkbox.js +11 -6
- package/build/widgets/form/DateTimeField.d.ts +4 -0
- package/build/widgets/form/DateTimeField.d.ts.map +1 -1
- package/build/widgets/form/TextField.d.ts +2 -2
- package/build/widgets/form/TextField.d.ts.map +1 -1
- package/build/widgets/grid/Grid.d.ts +20 -16
- package/build/widgets/grid/Grid.d.ts.map +1 -1
- package/build/widgets/grid/Grid.js +200 -86
- package/build/widgets/nav/Menu.d.ts +2 -0
- package/build/widgets/nav/Menu.d.ts.map +1 -1
- package/build/widgets/nav/Route.js +1 -1
- package/build/widgets/overlay/FlyweightTooltipTracker.d.ts +6 -4
- package/build/widgets/overlay/FlyweightTooltipTracker.d.ts.map +1 -1
- package/build/widgets/overlay/FlyweightTooltipTracker.js +3 -0
- package/build/widgets/overlay/Overlay.d.ts +2 -2
- package/build/widgets/overlay/Overlay.d.ts.map +1 -1
- package/dist/data.js +52 -1
- package/dist/jsx-runtime.js +4 -2
- package/dist/manifest.js +910 -904
- package/dist/svg.js +3 -0
- package/dist/ui.js +1548 -1544
- package/dist/widgets.css +1 -1
- package/dist/widgets.js +395 -4
- package/package.json +2 -2
- package/src/charts/Marker.tsx +448 -394
- package/src/charts/MouseTracker.tsx +3 -0
- package/src/charts/helpers/PointReducer.ts +2 -2
- package/src/data/View.ts +76 -19
- package/src/data/ops/findTreeNode.ts +20 -1
- package/src/data/ops/findTreePath.ts +7 -2
- package/src/data/ops/removeTreeNodes.ts +14 -1
- package/src/data/ops/updateArray.ts +4 -4
- package/src/data/ops/updateTree.ts +32 -6
- package/src/index.scss +6 -6
- package/src/jsx-runtime.spec.tsx +40 -0
- package/src/jsx-runtime.ts +87 -84
- package/src/svg/Rectangle.tsx +80 -73
- package/src/ui/DataProxy.ts +55 -55
- package/src/ui/Instance.ts +142 -45
- package/src/ui/IsolatedScope.ts +4 -2
- package/src/ui/Prop.ts +141 -141
- package/src/ui/Rescope.ts +50 -50
- package/src/ui/Widget.tsx +292 -234
- package/src/ui/adapter/ArrayAdapter.ts +229 -229
- package/src/ui/adapter/GroupAdapter.ts +8 -10
- package/src/ui/adapter/TreeAdapter.ts +75 -15
- package/src/ui/app/Url.spec.ts +1 -1
- package/src/ui/app/startAppLoop.tsx +56 -45
- package/src/ui/app/startHotAppLoop.ts +4 -4
- package/src/ui/batchUpdates.ts +16 -21
- package/src/ui/exprHelpers.ts +96 -96
- package/src/widgets/Button.tsx +0 -8
- package/src/widgets/HtmlElement.spec.tsx +100 -72
- package/src/widgets/HtmlElement.tsx +11 -10
- package/src/widgets/Sandbox.ts +104 -104
- package/src/widgets/Section.scss +55 -55
- package/src/widgets/drag-drop/DropZone.scss +74 -74
- package/src/widgets/form/Checkbox.tsx +296 -243
- package/src/widgets/form/DateTimeField.tsx +6 -0
- package/src/widgets/form/TextField.tsx +2 -2
- package/src/widgets/grid/Grid.scss +43 -10
- package/src/widgets/grid/Grid.tsx +4401 -3848
- package/src/widgets/nav/Menu.tsx +3 -0
- package/src/widgets/nav/Route.ts +1 -1
- package/src/widgets/overlay/FlyweightTooltipTracker.ts +15 -4
- package/src/widgets/overlay/Overlay.tsx +2 -1
- package/src/widgets/overlay/index.d.ts +11 -11
|
@@ -10,193 +10,234 @@ import CheckIcon from "../icons/check";
|
|
|
10
10
|
import SquareIcon from "../icons/square";
|
|
11
11
|
import { tooltipMouseLeave, tooltipMouseMove } from "../overlay/tooltip-ops";
|
|
12
12
|
import { Field, FieldConfig, getFieldTooltip, FieldInstance } from "./Field";
|
|
13
|
-
import { BooleanProp, StringProp } from "../../ui/Prop";
|
|
13
|
+
import { BooleanProp, Prop, StringProp } from "../../ui/Prop";
|
|
14
14
|
|
|
15
15
|
export interface CheckboxConfig extends FieldConfig {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
/** Value of the checkbox. */
|
|
17
|
+
value?: Prop<boolean | null>;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
/** Set to `true` to make the checkbox read-only. */
|
|
20
|
+
readOnly?: BooleanProp;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
/** Base CSS class to be applied to the element. Defaults to `checkbox`. */
|
|
23
|
+
baseClass?: string;
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
/** Use native checkbox HTML element. */
|
|
26
|
+
native?: boolean;
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
/** Set to `true` to display a square icon to indicate `null` or `undefined` value. */
|
|
29
|
+
indeterminate?: boolean;
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
/** Checked value alias for `value`. */
|
|
32
|
+
checked?: Prop<boolean | null>;
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
/** Text description. */
|
|
35
|
+
text?: StringProp;
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
/** Set to true to disable focusing on the checkbox. Used in grids to avoid conflicts. */
|
|
38
|
+
unfocusable?: boolean;
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
/** View mode text. */
|
|
41
|
+
viewText?: StringProp;
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
/** Custom validation function. */
|
|
44
|
+
onValidate?:
|
|
45
|
+
| string
|
|
46
|
+
| ((
|
|
47
|
+
value: boolean,
|
|
48
|
+
instance: Instance,
|
|
49
|
+
validationParams: Record<string, unknown>,
|
|
50
|
+
) => unknown);
|
|
45
51
|
}
|
|
46
52
|
|
|
47
53
|
export class Checkbox extends Field<CheckboxConfig> {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
54
|
+
declare public baseClass: string;
|
|
55
|
+
declare public checked?: unknown;
|
|
56
|
+
declare public value?: unknown;
|
|
57
|
+
declare public indeterminate?: boolean;
|
|
58
|
+
declare public unfocusable?: boolean;
|
|
59
|
+
declare public native?: boolean;
|
|
60
|
+
|
|
61
|
+
constructor(config?: CheckboxConfig) {
|
|
62
|
+
super(config);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
init(): void {
|
|
66
|
+
if (this.checked) this.value = this.checked;
|
|
67
|
+
|
|
68
|
+
super.init();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declareData(...args: Record<string, unknown>[]): void {
|
|
72
|
+
super.declareData(
|
|
73
|
+
{
|
|
74
|
+
value: !this.indeterminate ? false : undefined,
|
|
75
|
+
text: undefined,
|
|
76
|
+
readOnly: undefined,
|
|
77
|
+
disabled: undefined,
|
|
78
|
+
enabled: undefined,
|
|
79
|
+
required: undefined,
|
|
80
|
+
viewText: undefined,
|
|
81
|
+
},
|
|
82
|
+
...args,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
renderWrap(
|
|
87
|
+
context: RenderingContext,
|
|
88
|
+
instance: FieldInstance<Checkbox>,
|
|
89
|
+
key: string,
|
|
90
|
+
content: React.ReactNode,
|
|
91
|
+
): React.ReactElement {
|
|
92
|
+
let { data } = instance;
|
|
93
|
+
return (
|
|
94
|
+
<label
|
|
95
|
+
key={key}
|
|
96
|
+
className={data.classNames}
|
|
97
|
+
onMouseDown={(e) => {
|
|
98
|
+
e.stopPropagation();
|
|
99
|
+
if (this.unfocusable) e.preventDefault();
|
|
100
|
+
}}
|
|
101
|
+
onMouseMove={(e) => {
|
|
102
|
+
const tooltip = getFieldTooltip(instance);
|
|
103
|
+
if (Array.isArray(tooltip)) {
|
|
104
|
+
tooltipMouseMove(e, ...tooltip);
|
|
105
|
+
}
|
|
106
|
+
}}
|
|
107
|
+
onMouseLeave={(e) => {
|
|
108
|
+
const tooltip = getFieldTooltip(instance);
|
|
109
|
+
if (Array.isArray(tooltip)) {
|
|
110
|
+
tooltipMouseLeave(e, ...tooltip);
|
|
111
|
+
}
|
|
112
|
+
}}
|
|
113
|
+
onClick={(e) => {
|
|
114
|
+
this.handleClick(e, instance);
|
|
115
|
+
}}
|
|
116
|
+
style={data.style}
|
|
117
|
+
>
|
|
118
|
+
{content}
|
|
119
|
+
{this.labelPlacement &&
|
|
120
|
+
getContent(this.renderLabel(context, instance, "label"))}
|
|
121
|
+
</label>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
validateRequired(
|
|
126
|
+
context: RenderingContext,
|
|
127
|
+
instance: FieldInstance<Checkbox>,
|
|
128
|
+
): string | undefined {
|
|
129
|
+
let { data } = instance;
|
|
130
|
+
if (!data.value) return this.requiredText;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
renderNativeCheck(
|
|
134
|
+
context: RenderingContext,
|
|
135
|
+
instance: FieldInstance<Checkbox>,
|
|
136
|
+
): React.ReactElement {
|
|
137
|
+
let { CSS, baseClass } = this;
|
|
138
|
+
let { data } = instance;
|
|
139
|
+
return (
|
|
140
|
+
<input
|
|
141
|
+
key="input"
|
|
142
|
+
className={CSS.element(baseClass, "checkbox")}
|
|
143
|
+
id={data.id}
|
|
144
|
+
type="checkbox"
|
|
145
|
+
checked={data.value || false}
|
|
146
|
+
disabled={data.disabled}
|
|
147
|
+
{...data.inputAttrs}
|
|
148
|
+
onClick={stopPropagation}
|
|
149
|
+
onChange={(e) => {
|
|
150
|
+
this.handleChange(
|
|
151
|
+
e,
|
|
152
|
+
instance,
|
|
153
|
+
(e.target as HTMLInputElement).checked,
|
|
154
|
+
);
|
|
155
|
+
}}
|
|
156
|
+
/>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
renderCheck(
|
|
161
|
+
context: RenderingContext,
|
|
162
|
+
instance: FieldInstance<Checkbox>,
|
|
163
|
+
): React.ReactElement {
|
|
164
|
+
return <CheckboxCmp key="check" instance={instance} data={instance.data} />;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
renderInput(
|
|
168
|
+
context: RenderingContext,
|
|
169
|
+
instance: FieldInstance<Checkbox>,
|
|
170
|
+
key: string,
|
|
171
|
+
): React.ReactElement {
|
|
172
|
+
let { data } = instance;
|
|
173
|
+
let text = data.text || this.renderChildren?.(context, instance);
|
|
174
|
+
let { CSS, baseClass } = this;
|
|
175
|
+
return this.renderWrap(context, instance, key, [
|
|
176
|
+
this.native
|
|
177
|
+
? this.renderNativeCheck(context, instance)
|
|
178
|
+
: this.renderCheck(context, instance),
|
|
179
|
+
text ? (
|
|
180
|
+
<div key="text" className={CSS.element(baseClass, "text")}>
|
|
181
|
+
{text}
|
|
182
|
+
</div>
|
|
183
|
+
) : (
|
|
184
|
+
<span key="baseline" className={CSS.element(baseClass, "baseline")}>
|
|
185
|
+
|
|
186
|
+
</span>
|
|
187
|
+
),
|
|
188
|
+
]);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
renderValue(
|
|
192
|
+
context: RenderingContext,
|
|
193
|
+
instance: FieldInstance,
|
|
194
|
+
): React.ReactNode {
|
|
195
|
+
let { data } = instance;
|
|
196
|
+
if (!data.viewText) return super.renderValue(context, instance, undefined);
|
|
197
|
+
return (
|
|
198
|
+
<span className={this.CSS.element(this.baseClass, "view-text")}>
|
|
199
|
+
{data.viewText}
|
|
200
|
+
</span>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
formatValue(
|
|
205
|
+
context: RenderingContext,
|
|
206
|
+
instance: Instance,
|
|
207
|
+
): React.ReactNode | string {
|
|
208
|
+
let { data } = instance;
|
|
209
|
+
return (
|
|
210
|
+
data.value && (data.text || this.renderChildren?.(context, instance))
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
handleClick(e: React.MouseEvent, instance: Instance): void {
|
|
215
|
+
if (this.native) e.stopPropagation();
|
|
216
|
+
else {
|
|
217
|
+
var el = document.getElementById(instance.data.id);
|
|
218
|
+
if (el) el.focus();
|
|
219
|
+
if (!instance.data.viewMode) {
|
|
220
|
+
e.preventDefault();
|
|
221
|
+
e.stopPropagation();
|
|
222
|
+
this.handleChange(e, instance, !instance.data.value);
|
|
186
223
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
handleChange(
|
|
228
|
+
e: React.ChangeEvent<HTMLInputElement> | React.MouseEvent,
|
|
229
|
+
instance: Instance,
|
|
230
|
+
checked?: boolean,
|
|
231
|
+
): void {
|
|
232
|
+
let { data } = instance;
|
|
233
|
+
|
|
234
|
+
if (data.readOnly || data.disabled || data.viewMode) return;
|
|
235
|
+
|
|
236
|
+
instance.set(
|
|
237
|
+
"value",
|
|
238
|
+
checked != null ? checked : (e.target as HTMLInputElement).checked,
|
|
239
|
+
);
|
|
240
|
+
}
|
|
200
241
|
}
|
|
201
242
|
|
|
202
243
|
Checkbox.prototype.baseClass = "checkbox";
|
|
@@ -207,81 +248,93 @@ Checkbox.prototype.unfocusable = false;
|
|
|
207
248
|
Widget.alias("checkbox", Checkbox);
|
|
208
249
|
|
|
209
250
|
interface CheckboxCmpProps {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
251
|
+
key?: string;
|
|
252
|
+
instance: FieldInstance<Checkbox>;
|
|
253
|
+
data: Record<string, any>;
|
|
213
254
|
}
|
|
214
255
|
|
|
215
256
|
interface CheckboxCmpState {
|
|
216
|
-
|
|
257
|
+
value: unknown;
|
|
217
258
|
}
|
|
218
259
|
|
|
219
260
|
class CheckboxCmp extends VDOM.Component<CheckboxCmpProps, CheckboxCmpState> {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
261
|
+
constructor(props: CheckboxCmpProps) {
|
|
262
|
+
super(props);
|
|
263
|
+
this.state = {
|
|
264
|
+
value: props.data.value,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
UNSAFE_componentWillReceiveProps(props: CheckboxCmpProps) {
|
|
269
|
+
this.setState({
|
|
270
|
+
value: props.data.value,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
render(): React.ReactElement {
|
|
275
|
+
let { instance, data } = this.props;
|
|
276
|
+
let { widget } = instance;
|
|
277
|
+
let { baseClass, CSS } = widget;
|
|
278
|
+
|
|
279
|
+
let check: string | boolean = false;
|
|
280
|
+
|
|
281
|
+
if (this.state.value == null && widget.indeterminate)
|
|
282
|
+
check = "indeterminate";
|
|
283
|
+
else if (this.state.value) check = "check";
|
|
284
|
+
|
|
285
|
+
return (
|
|
286
|
+
<span
|
|
287
|
+
key="check"
|
|
288
|
+
tabIndex={
|
|
289
|
+
widget.unfocusable || data.disabled
|
|
290
|
+
? undefined
|
|
291
|
+
: (data.tabIndex as number) || 0
|
|
292
|
+
}
|
|
293
|
+
className={CSS.element(baseClass, "input", {
|
|
294
|
+
checked: check,
|
|
295
|
+
})}
|
|
296
|
+
style={CSS.parseStyle(data.inputStyle)}
|
|
297
|
+
id={data.id}
|
|
298
|
+
onClick={this.onClick.bind(this)}
|
|
299
|
+
onKeyDown={this.onKeyDown.bind(this)}
|
|
300
|
+
>
|
|
301
|
+
{check == "check" && (
|
|
302
|
+
<CheckIcon className={CSS.element(baseClass, "input-check")} />
|
|
303
|
+
)}
|
|
304
|
+
{check == "indeterminate" && (
|
|
305
|
+
<SquareIcon className={CSS.element(baseClass, "input-check")} />
|
|
306
|
+
)}
|
|
307
|
+
</span>
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
onClick(e: React.MouseEvent): void {
|
|
312
|
+
let { instance, data } = this.props;
|
|
313
|
+
let { widget } = instance;
|
|
314
|
+
if (!data.disabled && !data.readOnly) {
|
|
315
|
+
e.stopPropagation();
|
|
316
|
+
e.preventDefault();
|
|
317
|
+
this.setState({ value: !this.state.value });
|
|
318
|
+
widget.handleChange(e, instance, !this.state.value);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
onKeyDown(e: React.KeyboardEvent): void {
|
|
323
|
+
let { instance } = this.props;
|
|
324
|
+
const { widget } = instance;
|
|
325
|
+
if (
|
|
326
|
+
widget.handleKeyDown &&
|
|
327
|
+
widget.handleKeyDown(
|
|
328
|
+
e as unknown as React.KeyboardEvent<Element>,
|
|
329
|
+
instance,
|
|
330
|
+
) === false
|
|
331
|
+
)
|
|
332
|
+
return;
|
|
333
|
+
|
|
334
|
+
switch (e.keyCode) {
|
|
335
|
+
case KeyCode.space:
|
|
336
|
+
this.onClick(e as unknown as React.MouseEvent);
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
287
340
|
}
|
|
@@ -111,6 +111,12 @@ export interface DateTimeFieldConfig extends FieldConfig {
|
|
|
111
111
|
/** Additional configuration to be passed to the dropdown. */
|
|
112
112
|
dropdownOptions?: Partial<DropdownConfig>;
|
|
113
113
|
|
|
114
|
+
/** Type of picker to show. Can be `calendar`, `time`, `list`, or `auto`. Default is `auto`. */
|
|
115
|
+
picker?: "calendar" | "time" | "list" | "auto";
|
|
116
|
+
|
|
117
|
+
/** Time step in minutes for the time picker. */
|
|
118
|
+
step?: number;
|
|
119
|
+
|
|
114
120
|
/** Custom validation function. */
|
|
115
121
|
onValidate?:
|
|
116
122
|
| string
|
|
@@ -92,14 +92,14 @@ export interface TextFieldConfig extends FieldConfig {
|
|
|
92
92
|
| string
|
|
93
93
|
| ((e: KeyboardEvent, instance: Instance) => boolean | void);
|
|
94
94
|
|
|
95
|
-
/** Custom validation function. */
|
|
95
|
+
/** Custom validation function. Can return a Promise for async validation. */
|
|
96
96
|
onValidate?:
|
|
97
97
|
| string
|
|
98
98
|
| ((
|
|
99
99
|
value: string,
|
|
100
100
|
instance: Instance,
|
|
101
101
|
validationParams: any
|
|
102
|
-
) => string | undefined | false);
|
|
102
|
+
) => string | undefined | false | Promise<string | undefined | false>);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
// Legacy alias for backward compatibility
|