cx 22.1.3 → 22.3.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/manifest.js +623 -623
- package/dist/ui.js +2 -6
- package/dist/widgets.js +61 -44
- package/package.json +1 -1
- package/src/ui/FocusManager.js +9 -22
- package/src/ui/adapter/TreeAdapter.js +27 -34
- package/src/widgets/form/Checkbox.d.ts +22 -18
- package/src/widgets/form/Checkbox.js +6 -0
- package/src/widgets/form/LookupField.d.ts +0 -3
- package/src/widgets/form/LookupField.js +12 -25
- package/src/widgets/nav/MenuItem.d.ts +0 -2
- package/src/widgets/nav/MenuItem.js +8 -15
- package/src/widgets/overlay/Dropdown.d.ts +3 -0
- package/src/widgets/overlay/Dropdown.js +23 -11
- package/src/widgets/overlay/Overlay.js +9 -11
- package/src/widgets/overlay/Tooltip.js +13 -10
package/dist/ui.js
CHANGED
|
@@ -1629,8 +1629,7 @@ function unfocusElement(target, forceBlur) {
|
|
|
1629
1629
|
}
|
|
1630
1630
|
|
|
1631
1631
|
var activeElement = getActiveElement();
|
|
1632
|
-
if (!target) target = activeElement;
|
|
1633
|
-
else if (target != activeElement && !target.contains(activeElement)) return; //find the closest focusable parent of the target element and focus it instead
|
|
1632
|
+
if (!target) target = activeElement; //find the closest focusable parent of the target element and focus it instead
|
|
1634
1633
|
|
|
1635
1634
|
var focusableParent =
|
|
1636
1635
|
(!forceBlur &&
|
|
@@ -5023,14 +5022,11 @@ var TreeAdapter = /*#__PURE__*/ (function(_ArrayAdapter) {
|
|
|
5023
5022
|
_proto.processList = function processList(context, instance, level, parentKey, nodes, result) {
|
|
5024
5023
|
var _this = this;
|
|
5025
5024
|
|
|
5026
|
-
var nonLeafs = [],
|
|
5027
|
-
leafs = [];
|
|
5028
5025
|
nodes.forEach(function(record) {
|
|
5029
5026
|
record.key = parentKey + record.key;
|
|
5030
5027
|
|
|
5031
|
-
_this.processNode(context, instance, level,
|
|
5028
|
+
_this.processNode(context, instance, level, result, record);
|
|
5032
5029
|
});
|
|
5033
|
-
result.push.apply(result, nonLeafs.concat(leafs));
|
|
5034
5030
|
};
|
|
5035
5031
|
|
|
5036
5032
|
_proto.processNode = function processNode(context, instance, level, result, record) {
|
package/dist/widgets.js
CHANGED
|
@@ -3337,7 +3337,7 @@ var Overlay = /*#__PURE__*/ (function(_Container) {
|
|
|
3337
3337
|
};
|
|
3338
3338
|
|
|
3339
3339
|
_proto.initInstance = function initInstance(context, instance) {
|
|
3340
|
-
instance.
|
|
3340
|
+
instance.positionChangeSubscribers = new SubscriberList();
|
|
3341
3341
|
|
|
3342
3342
|
_Container.prototype.initInstance.call(this, context, instance);
|
|
3343
3343
|
};
|
|
@@ -3366,7 +3366,7 @@ var Overlay = /*#__PURE__*/ (function(_Container) {
|
|
|
3366
3366
|
}
|
|
3367
3367
|
|
|
3368
3368
|
if (instance.cache("dismiss", instance.dismiss)) instance.markShouldUpdate(context);
|
|
3369
|
-
context.push("parentPositionChangeEvent", instance.
|
|
3369
|
+
context.push("parentPositionChangeEvent", instance.positionChangeSubscribers);
|
|
3370
3370
|
|
|
3371
3371
|
_Container.prototype.explore.call(this, context, instance);
|
|
3372
3372
|
};
|
|
@@ -3481,7 +3481,7 @@ var Overlay = /*#__PURE__*/ (function(_Container) {
|
|
|
3481
3481
|
});
|
|
3482
3482
|
}
|
|
3483
3483
|
|
|
3484
|
-
instance.
|
|
3484
|
+
instance.positionChangeSubscribers.notify();
|
|
3485
3485
|
};
|
|
3486
3486
|
|
|
3487
3487
|
_proto.handleResize = function handleResize(e, instance, component) {
|
|
@@ -3501,7 +3501,7 @@ var Overlay = /*#__PURE__*/ (function(_Container) {
|
|
|
3501
3501
|
});
|
|
3502
3502
|
}
|
|
3503
3503
|
|
|
3504
|
-
instance.
|
|
3504
|
+
instance.positionChangeSubscribers.notify();
|
|
3505
3505
|
};
|
|
3506
3506
|
|
|
3507
3507
|
return Overlay;
|
|
@@ -4119,6 +4119,7 @@ var Dropdown = /*#__PURE__*/ (function(_Overlay) {
|
|
|
4119
4119
|
return _this.updateDropdownPosition(instance, component);
|
|
4120
4120
|
};
|
|
4121
4121
|
|
|
4122
|
+
instance.initialScreenPosition = null;
|
|
4122
4123
|
var el = instance.relatedElement.parentElement;
|
|
4123
4124
|
|
|
4124
4125
|
while (el) {
|
|
@@ -4158,10 +4159,18 @@ var Dropdown = /*#__PURE__*/ (function(_Overlay) {
|
|
|
4158
4159
|
if (this.pipeValidateDropdownPosition) instance.invoke("pipeValidateDropdownPosition", null, instance);
|
|
4159
4160
|
if (component.offParentPositionChange) component.offParentPositionChange();
|
|
4160
4161
|
delete component.parentBounds;
|
|
4162
|
+
delete component.initialScreenPosition;
|
|
4163
|
+
};
|
|
4164
|
+
|
|
4165
|
+
_proto.dismissAfterScroll = function dismissAfterScroll(data, instance, component) {
|
|
4166
|
+
if (this.onDismissAfterScroll && instance.invoke("onDismissAfterScroll", data, instance, component) === false)
|
|
4167
|
+
return;
|
|
4168
|
+
if (instance.dismiss) instance.dismiss();
|
|
4161
4169
|
};
|
|
4162
4170
|
|
|
4163
4171
|
_proto.updateDropdownPosition = function updateDropdownPosition(instance, component) {
|
|
4164
|
-
var el = component.el
|
|
4172
|
+
var el = component.el,
|
|
4173
|
+
initialScreenPosition = component.initialScreenPosition;
|
|
4165
4174
|
var data = instance.data,
|
|
4166
4175
|
relatedElement = instance.relatedElement;
|
|
4167
4176
|
var parentBounds = (component.parentBounds = getTopLevelBoundingClientRect(relatedElement)); //getBoundingClientRect() will return an empty rect if the element is hidden or removed
|
|
@@ -4217,13 +4226,20 @@ var Dropdown = /*#__PURE__*/ (function(_Overlay) {
|
|
|
4217
4226
|
}
|
|
4218
4227
|
}
|
|
4219
4228
|
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
parentBounds
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4229
|
+
if (!initialScreenPosition) initialScreenPosition = component.initialScreenPosition = parentBounds;
|
|
4230
|
+
if (
|
|
4231
|
+
Math.abs(parentBounds.top - initialScreenPosition.top) > this.closeOnScrollDistance ||
|
|
4232
|
+
Math.abs(parentBounds.left - initialScreenPosition.left) > this.closeOnScrollDistance
|
|
4233
|
+
)
|
|
4234
|
+
this.dismissAfterScroll(
|
|
4235
|
+
{
|
|
4236
|
+
parentBounds: parentBounds,
|
|
4237
|
+
initialScreenPosition: initialScreenPosition
|
|
4238
|
+
},
|
|
4239
|
+
instance,
|
|
4240
|
+
component
|
|
4241
|
+
);
|
|
4242
|
+
instance.positionChangeSubscribers.notify();
|
|
4227
4243
|
};
|
|
4228
4244
|
|
|
4229
4245
|
_proto.applyFixedPositioningPlacementStyles = function applyFixedPositioningPlacementStyles(
|
|
@@ -4680,6 +4696,7 @@ Dropdown.prototype.touchFriendly = false;
|
|
|
4680
4696
|
Dropdown.prototype.arrow = false;
|
|
4681
4697
|
Dropdown.prototype.pad = false;
|
|
4682
4698
|
Dropdown.prototype.elementExplode = 0;
|
|
4699
|
+
Dropdown.prototype.closeOnScrollDistance = 50;
|
|
4683
4700
|
Dropdown.prototype.screenPadding = 5;
|
|
4684
4701
|
Dropdown.prototype.firstChildDefinesHeight = false;
|
|
4685
4702
|
Dropdown.prototype.firstChildDefinesWidth = false;
|
|
@@ -4831,16 +4848,19 @@ var Tooltip = /*#__PURE__*/ (function(_Dropdown) {
|
|
|
4831
4848
|
};
|
|
4832
4849
|
|
|
4833
4850
|
_proto.dismissTooltip = function dismissTooltip(instance) {
|
|
4834
|
-
if (instance
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4851
|
+
if (!instance || !instance.dismissTooltip) return;
|
|
4852
|
+
if (
|
|
4853
|
+
instance.data &&
|
|
4854
|
+
instance.data.alwaysVisible &&
|
|
4855
|
+
this.relatedElement.ownerDocument.body.contains(this.relatedElement)
|
|
4856
|
+
)
|
|
4857
|
+
return;
|
|
4858
|
+
instance.dismissTooltip();
|
|
4859
|
+
instance.dismissTooltip = null;
|
|
4860
|
+
};
|
|
4861
|
+
|
|
4862
|
+
_proto.dismissAfterScroll = function dismissAfterScroll(data, instance) {
|
|
4863
|
+
this.dismissTooltip(instance);
|
|
4844
4864
|
};
|
|
4845
4865
|
|
|
4846
4866
|
_proto.checkVisible = function checkVisible(context, instance, data) {
|
|
@@ -6139,7 +6159,6 @@ MenuItem.prototype.checkedIcon = "check";
|
|
|
6139
6159
|
MenuItem.prototype.uncheckedIcon = "dummy";
|
|
6140
6160
|
MenuItem.prototype.keyboardShortcut = false;
|
|
6141
6161
|
MenuItem.prototype.openOnFocus = true;
|
|
6142
|
-
MenuItem.prototype.closeDropdownOnScrollDistance = 100;
|
|
6143
6162
|
Widget.alias("submenu", MenuItem);
|
|
6144
6163
|
Localization.registerPrototype("cx/widgets/MenuItem", MenuItem);
|
|
6145
6164
|
|
|
@@ -6195,15 +6214,10 @@ var MenuItemComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
6195
6214
|
pipeValidateDropdownPosition: function pipeValidateDropdownPosition(cb) {
|
|
6196
6215
|
_this2.validateDropdownPosition = cb;
|
|
6197
6216
|
},
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
if (
|
|
6203
|
-
Math.abs(parentBounds.top - initialScreenPosition.top) > widget.closeDropdownOnScrollDistance ||
|
|
6204
|
-
Math.abs(parentBounds.left - initialScreenPosition.left) > widget.closeDropdownOnScrollDistance
|
|
6205
|
-
)
|
|
6206
|
-
_this2.closeDropdown();
|
|
6217
|
+
onDismissAfterScroll: function onDismissAfterScroll() {
|
|
6218
|
+
_this2.closeDropdown();
|
|
6219
|
+
|
|
6220
|
+
return false;
|
|
6207
6221
|
}
|
|
6208
6222
|
}
|
|
6209
6223
|
)
|
|
@@ -8314,7 +8328,8 @@ var Checkbox = /*#__PURE__*/ (function(_Field) {
|
|
|
8314
8328
|
readOnly: undefined,
|
|
8315
8329
|
disabled: undefined,
|
|
8316
8330
|
enabled: undefined,
|
|
8317
|
-
required: undefined
|
|
8331
|
+
required: undefined,
|
|
8332
|
+
viewText: undefined
|
|
8318
8333
|
}
|
|
8319
8334
|
].concat(Array.prototype.slice.call(arguments))
|
|
8320
8335
|
);
|
|
@@ -8419,6 +8434,15 @@ var Checkbox = /*#__PURE__*/ (function(_Field) {
|
|
|
8419
8434
|
]);
|
|
8420
8435
|
};
|
|
8421
8436
|
|
|
8437
|
+
_proto.renderValue = function renderValue(context, _ref) {
|
|
8438
|
+
var data = _ref.data;
|
|
8439
|
+
if (!data.viewText) return _Field.prototype.renderValue.apply(this, arguments);
|
|
8440
|
+
return /*#__PURE__*/ jsx("span", {
|
|
8441
|
+
className: this.CSS.element(this.baseClass, "view-text"),
|
|
8442
|
+
children: data.viewText
|
|
8443
|
+
});
|
|
8444
|
+
};
|
|
8445
|
+
|
|
8422
8446
|
_proto.formatValue = function formatValue(context, instance) {
|
|
8423
8447
|
var data = instance.data;
|
|
8424
8448
|
return data.value && (data.text || this.renderChildren(context, instance));
|
|
@@ -10014,7 +10038,6 @@ LookupField.prototype.submitOnEnterKey = false;
|
|
|
10014
10038
|
LookupField.prototype.submitOnDropdownEnterKey = false;
|
|
10015
10039
|
LookupField.prototype.pageSize = 100;
|
|
10016
10040
|
LookupField.prototype.infinite = false;
|
|
10017
|
-
LookupField.prototype.closeDropdownOnScrollDistance = 100;
|
|
10018
10041
|
LookupField.prototype.quickSelectAll = false;
|
|
10019
10042
|
Localization.registerPrototype("cx/widgets/LookupField", LookupField);
|
|
10020
10043
|
Widget.alias("lookupfield", LookupField);
|
|
@@ -10233,15 +10256,10 @@ var LookupComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
10233
10256
|
};
|
|
10234
10257
|
}
|
|
10235
10258
|
},
|
|
10236
|
-
|
|
10237
|
-
|
|
10238
|
-
|
|
10239
|
-
|
|
10240
|
-
if (
|
|
10241
|
-
Math.abs(parentBounds.top - initialScreenPosition.top) > widget.closeDropdownOnScrollDistance ||
|
|
10242
|
-
Math.abs(parentBounds.left - initialScreenPosition.left) > widget.closeDropdownOnScrollDistance
|
|
10243
|
-
)
|
|
10244
|
-
_this7.closeDropdown(null, true);
|
|
10259
|
+
onDismissAfterScroll: function onDismissAfterScroll() {
|
|
10260
|
+
_this7.closeDropdown(null, true);
|
|
10261
|
+
|
|
10262
|
+
return false;
|
|
10245
10263
|
}
|
|
10246
10264
|
}
|
|
10247
10265
|
);
|
|
@@ -10895,7 +10913,6 @@ var LookupComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
10895
10913
|
} //delete results valid only while the dropdown is open
|
|
10896
10914
|
|
|
10897
10915
|
delete this.tmpCachedResult;
|
|
10898
|
-
delete this.initialScreenPosition;
|
|
10899
10916
|
};
|
|
10900
10917
|
|
|
10901
10918
|
_proto3.openDropdown = function openDropdown(e) {
|
package/package.json
CHANGED
package/src/ui/FocusManager.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isSelfOrDescendant,
|
|
3
|
-
findFirst,
|
|
4
|
-
findFirstChild,
|
|
5
|
-
isFocusable,
|
|
6
|
-
closestParent,
|
|
7
|
-
} from "../util/DOM";
|
|
1
|
+
import { isSelfOrDescendant, findFirst, findFirstChild, isFocusable, closestParent } from "../util/DOM";
|
|
8
2
|
import { batchUpdates } from "./batchUpdates";
|
|
9
3
|
import { SubscriberList } from "../util/SubscriberList";
|
|
10
4
|
import { isTouchEvent } from "../util/isTouchEvent";
|
|
11
5
|
import { getActiveElement } from "../util/getActiveElement";
|
|
12
6
|
|
|
13
7
|
/*
|
|
14
|
-
* Purpose of FocusManager is to provide focusout notifications.
|
|
15
|
-
* IE and Firefox do not provide relatedTarget info in blur events which makes it impossible
|
|
16
|
-
* to determine if focus went outside or stayed inside the component.
|
|
17
|
-
*/
|
|
8
|
+
* Purpose of FocusManager is to provide focusout notifications.
|
|
9
|
+
* IE and Firefox do not provide relatedTarget info in blur events which makes it impossible
|
|
10
|
+
* to determine if focus went outside or stayed inside the component.
|
|
11
|
+
*/
|
|
18
12
|
|
|
19
13
|
let subscribers = new SubscriberList(),
|
|
20
14
|
timerInterval = 300,
|
|
@@ -53,10 +47,7 @@ export class FocusManager {
|
|
|
53
47
|
}
|
|
54
48
|
|
|
55
49
|
static nudge() {
|
|
56
|
-
if (
|
|
57
|
-
typeof document !== "undefined" &&
|
|
58
|
-
getActiveElement() !== lastActiveElement
|
|
59
|
-
) {
|
|
50
|
+
if (typeof document !== "undefined" && getActiveElement() !== lastActiveElement) {
|
|
60
51
|
if (!pending) {
|
|
61
52
|
pending = true;
|
|
62
53
|
setTimeout(function () {
|
|
@@ -160,17 +151,13 @@ export function preventFocusOnTouch(e, force = false) {
|
|
|
160
151
|
|
|
161
152
|
export function unfocusElement(target = null, forceBlur = true) {
|
|
162
153
|
const activeElement = getActiveElement();
|
|
163
|
-
|
|
164
154
|
if (!target) target = activeElement;
|
|
165
|
-
else if (target != activeElement && !target.contains(activeElement))
|
|
166
|
-
return;
|
|
167
155
|
|
|
168
156
|
//find the closest focusable parent of the target element and focus it instead
|
|
169
|
-
let focusableParent = !forceBlur &&
|
|
170
|
-
|
|
171
|
-
document.body;
|
|
157
|
+
let focusableParent = (!forceBlur && closestParent(target, (el) => isFocusable(el))) || document.body;
|
|
158
|
+
|
|
172
159
|
if (focusableParent === document.body) activeElement.blur();
|
|
173
160
|
else focusableParent.focus();
|
|
174
161
|
|
|
175
162
|
FocusManager.nudge();
|
|
176
|
-
}
|
|
163
|
+
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {getAccessor} from "../../data/getAccessor";
|
|
1
|
+
import { getAccessor } from "../../data/getAccessor";
|
|
2
|
+
import { isArray } from "../../util/isArray";
|
|
3
|
+
import { ArrayAdapter } from "./ArrayAdapter";
|
|
5
4
|
|
|
6
5
|
export class TreeAdapter extends ArrayAdapter {
|
|
7
|
-
|
|
8
6
|
init() {
|
|
9
7
|
super.init();
|
|
10
8
|
this.childrenAccessor = getAccessor({ bind: `${this.recordName}.${this.childrenField}` });
|
|
@@ -13,68 +11,63 @@ export class TreeAdapter extends ArrayAdapter {
|
|
|
13
11
|
mapRecords(context, instance, data, parentStore, recordsAccessor) {
|
|
14
12
|
let nodes = super.mapRecords(context, instance, data, parentStore, recordsAccessor);
|
|
15
13
|
let result = [];
|
|
16
|
-
this.processList(context, instance, 0,
|
|
14
|
+
this.processList(context, instance, 0, "", nodes, result);
|
|
17
15
|
return result;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
processList(context, instance, level, parentKey, nodes, result) {
|
|
21
|
-
|
|
22
|
-
nodes.forEach(record => {
|
|
19
|
+
nodes.forEach((record) => {
|
|
23
20
|
record.key = parentKey + record.key;
|
|
24
|
-
this.processNode(context, instance, level,
|
|
21
|
+
this.processNode(context, instance, level, result, record);
|
|
25
22
|
});
|
|
26
|
-
result.push(...nonLeafs, ...leafs);
|
|
27
23
|
}
|
|
28
24
|
|
|
29
25
|
processNode(context, instance, level, result, record) {
|
|
30
26
|
result.push(record);
|
|
31
|
-
let {data, store} = record;
|
|
27
|
+
let { data, store } = record;
|
|
32
28
|
data.$level = level;
|
|
33
29
|
if (!data[this.leafField]) {
|
|
34
30
|
if (data[this.expandedField]) {
|
|
35
31
|
if (data[this.childrenField]) {
|
|
36
|
-
let childNodes = super.mapRecords(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
let childNodes = super.mapRecords(
|
|
33
|
+
context,
|
|
34
|
+
instance,
|
|
35
|
+
data[this.childrenField],
|
|
36
|
+
store,
|
|
37
|
+
this.childrenAccessor
|
|
38
|
+
);
|
|
39
|
+
this.processList(context, instance, level + 1, record.key + ":", childNodes, result);
|
|
40
|
+
} else if (this.load && !data[this.loadedField] && !data[this.loadingField]) {
|
|
40
41
|
store.set(`${this.recordName}.${this.loadingField}`, true);
|
|
41
42
|
let response = this.load(context, instance, data);
|
|
42
43
|
Promise.resolve(response)
|
|
43
|
-
.then(children => {
|
|
44
|
+
.then((children) => {
|
|
44
45
|
store.set(`${this.recordName}.${this.childrenField}`, children);
|
|
45
46
|
store.set(`${this.recordName}.${this.loadedField}`, true);
|
|
46
47
|
store.set(`${this.recordName}.${this.loadingField}`, false);
|
|
47
48
|
})
|
|
48
|
-
.catch(response => {
|
|
49
|
+
.catch((response) => {
|
|
49
50
|
store.set(`${this.recordName}.${this.loadingField}`, false);
|
|
50
|
-
if (this.onLoadError)
|
|
51
|
-
this.onLoadError(response);
|
|
51
|
+
if (this.onLoadError) this.onLoadError(response);
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
} else
|
|
55
|
-
data[this.expandedField] = false;
|
|
54
|
+
} else data[this.expandedField] = false;
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
sort(sorters) {
|
|
60
59
|
if (this.foldersFirst) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
sorters = [
|
|
65
|
-
{field: this.leafField, direction: "ASC"},
|
|
66
|
-
...sorters
|
|
67
|
-
];
|
|
60
|
+
if (!sorters || !isArray(sorters)) sorters = [];
|
|
61
|
+
sorters = [{ field: this.leafField, direction: "ASC" }, ...sorters];
|
|
68
62
|
}
|
|
69
|
-
|
|
70
63
|
super.sort(sorters);
|
|
71
64
|
}
|
|
72
65
|
}
|
|
73
66
|
|
|
74
|
-
TreeAdapter.prototype.childrenField =
|
|
75
|
-
TreeAdapter.prototype.expandedField =
|
|
76
|
-
TreeAdapter.prototype.leafField =
|
|
77
|
-
TreeAdapter.prototype.loadingField =
|
|
78
|
-
TreeAdapter.prototype.loadedField =
|
|
67
|
+
TreeAdapter.prototype.childrenField = "$children";
|
|
68
|
+
TreeAdapter.prototype.expandedField = "$expanded";
|
|
69
|
+
TreeAdapter.prototype.leafField = "$leaf";
|
|
70
|
+
TreeAdapter.prototype.loadingField = "$loading";
|
|
71
|
+
TreeAdapter.prototype.loadedField = "$loaded";
|
|
79
72
|
TreeAdapter.prototype.foldersFirst = true;
|
|
80
73
|
TreeAdapter.prototype.isTreeAdapter = true;
|
|
@@ -1,39 +1,43 @@
|
|
|
1
|
-
import * as Cx from
|
|
2
|
-
import { FieldProps } from
|
|
1
|
+
import * as Cx from "../../core";
|
|
2
|
+
import { FieldProps } from "./Field";
|
|
3
3
|
|
|
4
4
|
interface CheckboxProps extends FieldProps {
|
|
5
|
-
|
|
6
5
|
/** Value of the checkbox. `true` makes the checkbox checked. */
|
|
7
|
-
value?: Cx.BooleanProp
|
|
6
|
+
value?: Cx.BooleanProp;
|
|
8
7
|
|
|
9
8
|
/** efaults to `false`. Used to make the field read-only. */
|
|
10
|
-
readOnly?: Cx.BooleanProp
|
|
9
|
+
readOnly?: Cx.BooleanProp;
|
|
11
10
|
|
|
12
11
|
/** Base CSS class to be applied to the field. Defaults to `checkbox`. */
|
|
13
|
-
baseClass?: string
|
|
12
|
+
baseClass?: string;
|
|
14
13
|
|
|
15
|
-
/**
|
|
16
|
-
* Use native checkbox HTML element (`<input type="checkbox"/>`). Default is `false`.
|
|
17
|
-
* Native checkboxes are difficult to style.
|
|
14
|
+
/**
|
|
15
|
+
* Use native checkbox HTML element (`<input type="checkbox"/>`). Default is `false`.
|
|
16
|
+
* Native checkboxes are difficult to style.
|
|
18
17
|
*/
|
|
19
|
-
native?: boolean
|
|
18
|
+
native?: boolean;
|
|
20
19
|
|
|
21
|
-
/**
|
|
22
|
-
* Set to true to instruct the widget to indicate indeterminate state
|
|
23
|
-
* (null or undefined value) with a square icon instead of appearing unchecked.
|
|
20
|
+
/**
|
|
21
|
+
* Set to true to instruct the widget to indicate indeterminate state
|
|
22
|
+
* (null or undefined value) with a square icon instead of appearing unchecked.
|
|
24
23
|
*/
|
|
25
|
-
indeterminate?: boolean
|
|
24
|
+
indeterminate?: boolean;
|
|
26
25
|
|
|
27
26
|
/** Value of the checkbox. `true` makes the checkbox checked. */
|
|
28
|
-
checked?: Cx.BooleanProp
|
|
27
|
+
checked?: Cx.BooleanProp;
|
|
29
28
|
|
|
30
29
|
/** Text property. */
|
|
31
|
-
text?: Cx.StringProp
|
|
30
|
+
text?: Cx.StringProp;
|
|
32
31
|
|
|
33
32
|
/** Prevent moving focus on the checkbox. This is useful when checkboxes are found
|
|
34
33
|
inside other focusable elements, such as grids or lists. */
|
|
35
|
-
unfocusable?: boolean
|
|
36
|
-
|
|
34
|
+
unfocusable?: boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Text to be displayed when checkobx is in the view mode.
|
|
38
|
+
* Useful to describe state of the checkbox in `viewMode` in a form of text, i.e. `Active/Inactive`.
|
|
39
|
+
*/
|
|
40
|
+
viewText?: Cx.StringProp;
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
export class Checkbox extends Cx.Widget<CheckboxProps> {}
|
|
@@ -22,6 +22,7 @@ export class Checkbox extends Field {
|
|
|
22
22
|
disabled: undefined,
|
|
23
23
|
enabled: undefined,
|
|
24
24
|
required: undefined,
|
|
25
|
+
viewText: undefined,
|
|
25
26
|
},
|
|
26
27
|
...arguments
|
|
27
28
|
);
|
|
@@ -94,6 +95,11 @@ export class Checkbox extends Field {
|
|
|
94
95
|
]);
|
|
95
96
|
}
|
|
96
97
|
|
|
98
|
+
renderValue(context, { data }) {
|
|
99
|
+
if (!data.viewText) return super.renderValue(...arguments);
|
|
100
|
+
return <span className={this.CSS.element(this.baseClass, "view-text")}>{data.viewText}</span>;
|
|
101
|
+
}
|
|
102
|
+
|
|
97
103
|
formatValue(context, instance) {
|
|
98
104
|
let { data } = instance;
|
|
99
105
|
return data.value && (data.text || this.renderChildren(context, instance));
|
|
@@ -152,9 +152,6 @@ interface LookupFieldProps extends FieldProps {
|
|
|
152
152
|
/** Number of additional items to be loaded in `infinite` mode. Default is 100. */
|
|
153
153
|
pageSize?: number;
|
|
154
154
|
|
|
155
|
-
/** The dropdown will be automatically closed if the page is scrolled a certain distance. */
|
|
156
|
-
closeDropdownOnScrollDistance?: number;
|
|
157
|
-
|
|
158
155
|
/** Set to `true` to allow quick selection of all displayed lookup items on `ctrl + a` keys combination. */
|
|
159
156
|
quickSelectAll?: boolean;
|
|
160
157
|
}
|
|
@@ -236,7 +236,6 @@ LookupField.prototype.submitOnEnterKey = false;
|
|
|
236
236
|
LookupField.prototype.submitOnDropdownEnterKey = false;
|
|
237
237
|
LookupField.prototype.pageSize = 100;
|
|
238
238
|
LookupField.prototype.infinite = false;
|
|
239
|
-
LookupField.prototype.closeDropdownOnScrollDistance = 100;
|
|
240
239
|
LookupField.prototype.quickSelectAll = false;
|
|
241
240
|
|
|
242
241
|
Localization.registerPrototype("cx/widgets/LookupField", LookupField);
|
|
@@ -371,16 +370,9 @@ class LookupComponent extends VDOM.Component {
|
|
|
371
370
|
};
|
|
372
371
|
}
|
|
373
372
|
},
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
if (!initialScreenPosition) initialScreenPosition = this.initialScreenPosition = params.parentBounds;
|
|
378
|
-
|
|
379
|
-
if (
|
|
380
|
-
Math.abs(parentBounds.top - initialScreenPosition.top) > widget.closeDropdownOnScrollDistance ||
|
|
381
|
-
Math.abs(parentBounds.left - initialScreenPosition.left) > widget.closeDropdownOnScrollDistance
|
|
382
|
-
)
|
|
383
|
-
this.closeDropdown(null, true);
|
|
373
|
+
onDismissAfterScroll: () => {
|
|
374
|
+
this.closeDropdown(null, true);
|
|
375
|
+
return false;
|
|
384
376
|
},
|
|
385
377
|
};
|
|
386
378
|
|
|
@@ -543,7 +535,6 @@ class LookupComponent extends VDOM.Component {
|
|
|
543
535
|
!data.disabled &&
|
|
544
536
|
!data.empty &&
|
|
545
537
|
(widget.alwaysShowClear || (!data.required && !this.props.multiple) || multipleEntries)
|
|
546
|
-
|
|
547
538
|
) {
|
|
548
539
|
insideButton = (
|
|
549
540
|
<div
|
|
@@ -720,15 +711,13 @@ class LookupComponent extends VDOM.Component {
|
|
|
720
711
|
let newRecords = reset ? [] : [...(records || [])];
|
|
721
712
|
let singleSelect = itemsData.length == 1;
|
|
722
713
|
let optionKey = null;
|
|
723
|
-
if (singleSelect)
|
|
724
|
-
optionKey = this.getOptionKey(itemsData[0]);
|
|
714
|
+
if (singleSelect) optionKey = this.getOptionKey(itemsData[0]);
|
|
725
715
|
|
|
726
716
|
// deselect
|
|
727
717
|
if (singleSelect && selectedKeys.find((k) => areKeysEqual(optionKey, k))) {
|
|
728
718
|
newRecords = records.filter((v) => !areKeysEqual(optionKey, this.getLocalKey({ $value: v })));
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
itemsData.forEach(itemData => {
|
|
719
|
+
} else {
|
|
720
|
+
itemsData.forEach((itemData) => {
|
|
732
721
|
let valueData = {
|
|
733
722
|
$value: {},
|
|
734
723
|
};
|
|
@@ -787,8 +776,8 @@ class LookupComponent extends VDOM.Component {
|
|
|
787
776
|
let { quickSelectAll, multiple } = this.props.instance.widget;
|
|
788
777
|
if (!quickSelectAll || !multiple) return;
|
|
789
778
|
|
|
790
|
-
let optionsToSelect = this.state.options.map(o => ({
|
|
791
|
-
$option: o
|
|
779
|
+
let optionsToSelect = this.state.options.map((o) => ({
|
|
780
|
+
$option: o,
|
|
792
781
|
}));
|
|
793
782
|
this.select(e, optionsToSelect, true);
|
|
794
783
|
e.stopPropagation();
|
|
@@ -798,7 +787,6 @@ class LookupComponent extends VDOM.Component {
|
|
|
798
787
|
default:
|
|
799
788
|
if (this.listKeyDown) this.listKeyDown(e);
|
|
800
789
|
break;
|
|
801
|
-
|
|
802
790
|
}
|
|
803
791
|
}
|
|
804
792
|
|
|
@@ -896,7 +884,6 @@ class LookupComponent extends VDOM.Component {
|
|
|
896
884
|
|
|
897
885
|
//delete results valid only while the dropdown is open
|
|
898
886
|
delete this.tmpCachedResult;
|
|
899
|
-
delete this.initialScreenPosition;
|
|
900
887
|
}
|
|
901
888
|
|
|
902
889
|
openDropdown(e) {
|
|
@@ -968,10 +955,10 @@ class LookupComponent extends VDOM.Component {
|
|
|
968
955
|
let params = !widget.infinite
|
|
969
956
|
? query
|
|
970
957
|
: {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
958
|
+
query,
|
|
959
|
+
page: 1,
|
|
960
|
+
pageSize,
|
|
961
|
+
};
|
|
975
962
|
|
|
976
963
|
if (!result) result = instance.invoke("onQuery", params, instance);
|
|
977
964
|
|
|
@@ -19,8 +19,6 @@ export interface MenuItemProps extends Cx.HtmlElementProps {
|
|
|
19
19
|
keyboardShortcut?: KeyboardShortcut;
|
|
20
20
|
tooltip?: string | Cx.Config;
|
|
21
21
|
openOnFocus?: boolean;
|
|
22
|
-
/** The dropdown will be automatically closed if the page is scrolled a certain distance. */
|
|
23
|
-
closeDropdownOnScrollDistance?: number;
|
|
24
22
|
|
|
25
23
|
/**
|
|
26
24
|
* Click handler.
|
|
@@ -109,7 +109,6 @@ MenuItem.prototype.checkedIcon = "check";
|
|
|
109
109
|
MenuItem.prototype.uncheckedIcon = "dummy";
|
|
110
110
|
MenuItem.prototype.keyboardShortcut = false;
|
|
111
111
|
MenuItem.prototype.openOnFocus = true;
|
|
112
|
-
MenuItem.prototype.closeDropdownOnScrollDistance = 100;
|
|
113
112
|
|
|
114
113
|
Widget.alias("submenu", MenuItem);
|
|
115
114
|
Localization.registerPrototype("cx/widgets/MenuItem", MenuItem);
|
|
@@ -145,19 +144,10 @@ class MenuItemComponent extends VDOM.Component {
|
|
|
145
144
|
pipeValidateDropdownPosition: (cb) => {
|
|
146
145
|
this.validateDropdownPosition = cb;
|
|
147
146
|
},
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (!initialScreenPosition)
|
|
153
|
-
initialScreenPosition = this.initialScreenPosition = params.parentBounds;
|
|
154
|
-
|
|
155
|
-
if (
|
|
156
|
-
Math.abs(parentBounds.top - initialScreenPosition.top) > widget.closeDropdownOnScrollDistance ||
|
|
157
|
-
Math.abs(parentBounds.left - initialScreenPosition.left) > widget.closeDropdownOnScrollDistance
|
|
158
|
-
)
|
|
159
|
-
this.closeDropdown();
|
|
160
|
-
}
|
|
147
|
+
onDismissAfterScroll: () => {
|
|
148
|
+
this.closeDropdown();
|
|
149
|
+
return false;
|
|
150
|
+
},
|
|
161
151
|
});
|
|
162
152
|
}
|
|
163
153
|
return this.dropdown;
|
|
@@ -261,7 +251,10 @@ class MenuItemComponent extends VDOM.Component {
|
|
|
261
251
|
onDropdownKeyDown(e) {
|
|
262
252
|
debug(menuFlag, "MenuItem", "dropdownKeyDown");
|
|
263
253
|
let { horizontal } = this.props.instance;
|
|
264
|
-
if (
|
|
254
|
+
if (
|
|
255
|
+
e.keyCode == KeyCode.esc ||
|
|
256
|
+
(!isTextInputElement(e.target) && (horizontal ? e.keyCode == KeyCode.up : e.keyCode == KeyCode.left))
|
|
257
|
+
) {
|
|
265
258
|
FocusManager.focus(this.el);
|
|
266
259
|
e.preventDefault();
|
|
267
260
|
e.stopPropagation();
|
|
@@ -18,6 +18,9 @@ export interface DropdownProps extends OverlayProps {
|
|
|
18
18
|
firstChildDefinesHeight?: boolean;
|
|
19
19
|
firstChildDefinesWidth?: boolean;
|
|
20
20
|
|
|
21
|
+
/** The dropdown will be automatically closed if the page is scrolled a certain distance. */
|
|
22
|
+
closeOnScrollDistance?: number;
|
|
23
|
+
|
|
21
24
|
onResolveRelatedElement?(beaconEl: Element, instance: any);
|
|
22
25
|
}
|
|
23
26
|
|