cx 23.5.0 → 23.5.2
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/manifest.js +806 -806
- package/dist/ui.js +7 -2
- package/dist/widgets.js +14 -6
- package/package.json +1 -1
- package/src/data/StringTemplate.spec.js +105 -95
- package/src/ui/FocusManager.js +171 -171
- package/src/widgets/form/Field.js +15 -8
- package/src/widgets/form/Label.js +88 -86
- package/src/widgets/form/ValidationGroup.d.ts +3 -0
- package/src/widgets/form/ValidationGroup.js +3 -0
- package/src/widgets/grid/Grid.js +3273 -3266
|
@@ -41,7 +41,7 @@ export class Field extends PureContainer {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
init() {
|
|
44
|
-
if (this.validationMode ==
|
|
44
|
+
if (this.validationMode == "tooltip" && isUndefined(this.errorTooltip)) {
|
|
45
45
|
this.errorTooltip = {
|
|
46
46
|
text: { bind: "$error" },
|
|
47
47
|
mod: "error",
|
|
@@ -243,7 +243,11 @@ export class Field extends PureContainer {
|
|
|
243
243
|
if (!data.error) {
|
|
244
244
|
if (state.inputError) data.error = state.inputError;
|
|
245
245
|
else if (state.validating && !empty) data.error = this.validatingText;
|
|
246
|
-
else if (
|
|
246
|
+
else if (
|
|
247
|
+
state.validationError &&
|
|
248
|
+
data.value === state.lastValidatedValue &&
|
|
249
|
+
shallowEquals(data.validationParams, state.lastValidationParams)
|
|
250
|
+
)
|
|
247
251
|
data.error = state.validationError;
|
|
248
252
|
else if (data.required) data.error = this.validateRequired(context, instance);
|
|
249
253
|
}
|
|
@@ -253,7 +257,9 @@ export class Field extends PureContainer {
|
|
|
253
257
|
!state.validating &&
|
|
254
258
|
!data.error &&
|
|
255
259
|
this.onValidate &&
|
|
256
|
-
(!state.previouslyValidated ||
|
|
260
|
+
(!state.previouslyValidated ||
|
|
261
|
+
data.value != state.lastValidatedValue ||
|
|
262
|
+
data.validationParams != state.lastValidationParams)
|
|
257
263
|
) {
|
|
258
264
|
let result = instance.invoke("onValidate", data.value, instance, data.validationParams);
|
|
259
265
|
if (isPromise(result)) {
|
|
@@ -262,14 +268,16 @@ export class Field extends PureContainer {
|
|
|
262
268
|
validating: true,
|
|
263
269
|
lastValidatedValue: data.value,
|
|
264
270
|
previouslyValidated: true,
|
|
265
|
-
lastValidationParams: data.validationParams
|
|
271
|
+
lastValidationParams: data.validationParams,
|
|
266
272
|
});
|
|
267
273
|
result
|
|
268
274
|
.then((r) => {
|
|
269
275
|
let { data, state } = instance;
|
|
270
|
-
let error =
|
|
271
|
-
|
|
272
|
-
|
|
276
|
+
let error =
|
|
277
|
+
data.value == state.lastValidatedValue &&
|
|
278
|
+
shallowEquals(data.validationParams, state.lastValidationParams)
|
|
279
|
+
? r
|
|
280
|
+
: this.validatingText; //parameters changed, this will be revalidated
|
|
273
281
|
|
|
274
282
|
instance.setState({
|
|
275
283
|
validating: false,
|
|
@@ -416,4 +424,3 @@ export function getFieldTooltip(instance) {
|
|
|
416
424
|
];
|
|
417
425
|
return [instance, widget.tooltip];
|
|
418
426
|
}
|
|
419
|
-
|
|
@@ -1,86 +1,88 @@
|
|
|
1
|
-
import { Widget, VDOM } from "../../ui/Widget";
|
|
2
|
-
import { HtmlElement } from "../HtmlElement";
|
|
3
|
-
import { FocusManager } from "../../ui/FocusManager";
|
|
4
|
-
import { isArray } from "../../util/isArray";
|
|
5
|
-
import { coalesce } from "../../util/coalesce";
|
|
6
|
-
|
|
7
|
-
export class Label extends HtmlElement {
|
|
8
|
-
declareData() {
|
|
9
|
-
super.declareData(...arguments, {
|
|
10
|
-
required: undefined,
|
|
11
|
-
disabled: undefined,
|
|
12
|
-
htmlFor: undefined,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
prepareData(context, instance) {
|
|
17
|
-
let { data } = instance;
|
|
18
|
-
data.stateMods = {
|
|
19
|
-
...data.stateMods,
|
|
20
|
-
disabled: data.disabled,
|
|
21
|
-
};
|
|
22
|
-
data._disabled = data.disabled;
|
|
23
|
-
super.prepareData(context, instance);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
explore(context, instance) {
|
|
27
|
-
let { data } = instance;
|
|
28
|
-
|
|
29
|
-
if (!data.htmlFor) data.htmlFor = context.lastFieldId;
|
|
30
|
-
|
|
31
|
-
data.disabled = data.stateMods.disabled = coalesce(
|
|
32
|
-
context.parentStrict ? context.parentDisabled : null,
|
|
33
|
-
data._disabled,
|
|
34
|
-
context.parentDisabled
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
props.children.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
Label.prototype.
|
|
1
|
+
import { Widget, VDOM } from "../../ui/Widget";
|
|
2
|
+
import { HtmlElement } from "../HtmlElement";
|
|
3
|
+
import { FocusManager } from "../../ui/FocusManager";
|
|
4
|
+
import { isArray } from "../../util/isArray";
|
|
5
|
+
import { coalesce } from "../../util/coalesce";
|
|
6
|
+
|
|
7
|
+
export class Label extends HtmlElement {
|
|
8
|
+
declareData() {
|
|
9
|
+
super.declareData(...arguments, {
|
|
10
|
+
required: undefined,
|
|
11
|
+
disabled: undefined,
|
|
12
|
+
htmlFor: undefined,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
prepareData(context, instance) {
|
|
17
|
+
let { data } = instance;
|
|
18
|
+
data.stateMods = {
|
|
19
|
+
...data.stateMods,
|
|
20
|
+
disabled: data.disabled,
|
|
21
|
+
};
|
|
22
|
+
data._disabled = data.disabled;
|
|
23
|
+
super.prepareData(context, instance);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
explore(context, instance) {
|
|
27
|
+
let { data } = instance;
|
|
28
|
+
|
|
29
|
+
if (!data.htmlFor) data.htmlFor = context.lastFieldId;
|
|
30
|
+
|
|
31
|
+
data.disabled = data.stateMods.disabled = coalesce(
|
|
32
|
+
context.parentStrict ? context.parentDisabled : null,
|
|
33
|
+
data._disabled,
|
|
34
|
+
context.parentDisabled
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
data.asterisk = context.parentAsterisk || this.asterisk;
|
|
38
|
+
|
|
39
|
+
if (instance.cache("disabled", data.disabled) || instance.cache("asterisk", data.asterisk)) {
|
|
40
|
+
instance.markShouldUpdate(context);
|
|
41
|
+
this.prepareCSS(context, instance);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
super.explore(context, instance);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
isValidHtmlAttribute(attrName) {
|
|
48
|
+
switch (attrName) {
|
|
49
|
+
case "asterisk":
|
|
50
|
+
case "required":
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return super.isValidHtmlAttribute(attrName);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
attachProps(context, instance, props) {
|
|
57
|
+
super.attachProps(context, instance, props);
|
|
58
|
+
|
|
59
|
+
let { data } = instance;
|
|
60
|
+
|
|
61
|
+
if (data.htmlFor) {
|
|
62
|
+
props.htmlFor = data.htmlFor;
|
|
63
|
+
|
|
64
|
+
if (!props.onClick)
|
|
65
|
+
props.onClick = () => {
|
|
66
|
+
//additional focus for LookupFields which are not input based
|
|
67
|
+
let el = document.getElementById(instance.data.htmlFor);
|
|
68
|
+
if (el) FocusManager.focusFirst(el);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!props.id && data.htmlFor) props.id = `${data.htmlFor}-label`;
|
|
73
|
+
|
|
74
|
+
if (data.required && data.asterisk) {
|
|
75
|
+
if (!isArray(props.children)) props.children = [props.children];
|
|
76
|
+
props.children.push(" ");
|
|
77
|
+
props.children.push(
|
|
78
|
+
<span key="asterisk" className={this.CSS.element(this.baseClass, "asterisk")}>
|
|
79
|
+
*
|
|
80
|
+
</span>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
Label.prototype.baseClass = "label";
|
|
87
|
+
Label.prototype.tag = "label";
|
|
88
|
+
Label.prototype.asterisk = false;
|
|
@@ -33,6 +33,9 @@ export interface ValidationGroupProps extends Cx.PureContainerProps {
|
|
|
33
33
|
|
|
34
34
|
/** Set to `true` to force children to respect disabled, readOnly, viewMode and visited flags set on the group level. */
|
|
35
35
|
strict?: Cx.BooleanProp;
|
|
36
|
+
|
|
37
|
+
/** Set to `true` to add red asterisk for all required fields inside the group. */
|
|
38
|
+
asterisk?: boolean;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
export class ValidationGroup extends Cx.Widget<ValidationGroupProps> {}
|
|
@@ -18,6 +18,7 @@ export class ValidationGroup extends PureContainer {
|
|
|
18
18
|
isolated: undefined,
|
|
19
19
|
visited: undefined,
|
|
20
20
|
strict: undefined,
|
|
21
|
+
asterisk: undefined,
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -34,6 +35,7 @@ export class ValidationGroup extends PureContainer {
|
|
|
34
35
|
context.push("parentViewMode", coalesce(instance.data.viewMode, context.parentViewMode));
|
|
35
36
|
context.push("parentTabOnEnterKey", coalesce(instance.data.tabOnEnterKey, context.parentTabOnEnterKey));
|
|
36
37
|
context.push("parentVisited", coalesce(instance.data.visited, context.parentVisited));
|
|
38
|
+
context.push("parentAsterisk", coalesce(instance.data.asterisk, context.parentAsterisk));
|
|
37
39
|
context.push("validation", instance.validation);
|
|
38
40
|
|
|
39
41
|
super.explore(context, instance);
|
|
@@ -47,6 +49,7 @@ export class ValidationGroup extends PureContainer {
|
|
|
47
49
|
context.pop("parentViewMode");
|
|
48
50
|
context.pop("parentTabOnEnterKey");
|
|
49
51
|
context.pop("parentStrict");
|
|
52
|
+
context.pop("parentAsterisk");
|
|
50
53
|
|
|
51
54
|
instance.valid = instance.validation.errors.length == 0;
|
|
52
55
|
if (!instance.valid && !this.isolated && context.validation)
|