cx 23.5.1 → 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/widgets.js
CHANGED
|
@@ -6517,7 +6517,8 @@ var Label = /*#__PURE__*/ (function (_HtmlElement) {
|
|
|
6517
6517
|
data._disabled,
|
|
6518
6518
|
context.parentDisabled
|
|
6519
6519
|
);
|
|
6520
|
-
|
|
6520
|
+
data.asterisk = context.parentAsterisk || this.asterisk;
|
|
6521
|
+
if (instance.cache("disabled", data.disabled) || instance.cache("asterisk", data.asterisk)) {
|
|
6521
6522
|
instance.markShouldUpdate(context);
|
|
6522
6523
|
this.prepareCSS(context, instance);
|
|
6523
6524
|
}
|
|
@@ -6544,7 +6545,7 @@ var Label = /*#__PURE__*/ (function (_HtmlElement) {
|
|
|
6544
6545
|
};
|
|
6545
6546
|
}
|
|
6546
6547
|
if (!props.id && data.htmlFor) props.id = data.htmlFor + "-label";
|
|
6547
|
-
if (
|
|
6548
|
+
if (data.required && data.asterisk) {
|
|
6548
6549
|
if (!isArray(props.children)) props.children = [props.children];
|
|
6549
6550
|
props.children.push(" ");
|
|
6550
6551
|
props.children.push(
|
|
@@ -10530,6 +10531,7 @@ var ValidationGroup = /*#__PURE__*/ (function (_PureContainer) {
|
|
|
10530
10531
|
isolated: undefined,
|
|
10531
10532
|
visited: undefined,
|
|
10532
10533
|
strict: undefined,
|
|
10534
|
+
asterisk: undefined,
|
|
10533
10535
|
},
|
|
10534
10536
|
])
|
|
10535
10537
|
);
|
|
@@ -10545,6 +10547,7 @@ var ValidationGroup = /*#__PURE__*/ (function (_PureContainer) {
|
|
|
10545
10547
|
context.push("parentViewMode", coalesce(instance.data.viewMode, context.parentViewMode));
|
|
10546
10548
|
context.push("parentTabOnEnterKey", coalesce(instance.data.tabOnEnterKey, context.parentTabOnEnterKey));
|
|
10547
10549
|
context.push("parentVisited", coalesce(instance.data.visited, context.parentVisited));
|
|
10550
|
+
context.push("parentAsterisk", coalesce(instance.data.asterisk, context.parentAsterisk));
|
|
10548
10551
|
context.push("validation", instance.validation);
|
|
10549
10552
|
_PureContainer.prototype.explore.call(this, context, instance);
|
|
10550
10553
|
};
|
|
@@ -10557,6 +10560,7 @@ var ValidationGroup = /*#__PURE__*/ (function (_PureContainer) {
|
|
|
10557
10560
|
context.pop("parentViewMode");
|
|
10558
10561
|
context.pop("parentTabOnEnterKey");
|
|
10559
10562
|
context.pop("parentStrict");
|
|
10563
|
+
context.pop("parentAsterisk");
|
|
10560
10564
|
instance.valid = instance.validation.errors.length == 0;
|
|
10561
10565
|
if (!instance.valid && !this.isolated && context.validation)
|
|
10562
10566
|
(_context$validation$e = context.validation.errors).push.apply(_context$validation$e, instance.validation.errors);
|
package/package.json
CHANGED
|
@@ -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)
|