cx 22.1.3 → 22.1.4
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 +618 -618
- package/dist/ui.js +1 -2
- package/dist/widgets.js +50 -43
- package/package.json +1 -1
- package/src/ui/FocusManager.js +9 -22
- 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 &&
|
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
|
)
|
|
@@ -10014,7 +10028,6 @@ LookupField.prototype.submitOnEnterKey = false;
|
|
|
10014
10028
|
LookupField.prototype.submitOnDropdownEnterKey = false;
|
|
10015
10029
|
LookupField.prototype.pageSize = 100;
|
|
10016
10030
|
LookupField.prototype.infinite = false;
|
|
10017
|
-
LookupField.prototype.closeDropdownOnScrollDistance = 100;
|
|
10018
10031
|
LookupField.prototype.quickSelectAll = false;
|
|
10019
10032
|
Localization.registerPrototype("cx/widgets/LookupField", LookupField);
|
|
10020
10033
|
Widget.alias("lookupfield", LookupField);
|
|
@@ -10233,15 +10246,10 @@ var LookupComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
10233
10246
|
};
|
|
10234
10247
|
}
|
|
10235
10248
|
},
|
|
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);
|
|
10249
|
+
onDismissAfterScroll: function onDismissAfterScroll() {
|
|
10250
|
+
_this7.closeDropdown(null, true);
|
|
10251
|
+
|
|
10252
|
+
return false;
|
|
10245
10253
|
}
|
|
10246
10254
|
}
|
|
10247
10255
|
);
|
|
@@ -10895,7 +10903,6 @@ var LookupComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
10895
10903
|
} //delete results valid only while the dropdown is open
|
|
10896
10904
|
|
|
10897
10905
|
delete this.tmpCachedResult;
|
|
10898
|
-
delete this.initialScreenPosition;
|
|
10899
10906
|
};
|
|
10900
10907
|
|
|
10901
10908
|
_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
|
+
}
|
|
@@ -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
|
|
|
@@ -19,8 +19,7 @@ export class Dropdown extends Overlay {
|
|
|
19
19
|
this.trackMouseX = true;
|
|
20
20
|
this.trackMouseY = true;
|
|
21
21
|
}
|
|
22
|
-
if (this.autoFocus && !this.hasOwnProperty(this.focusable))
|
|
23
|
-
this.focusable = true;
|
|
22
|
+
if (this.autoFocus && !this.hasOwnProperty(this.focusable)) this.focusable = true;
|
|
24
23
|
super.init();
|
|
25
24
|
}
|
|
26
25
|
|
|
@@ -51,6 +50,8 @@ export class Dropdown extends Overlay {
|
|
|
51
50
|
var scrollableParents = (component.scrollableParents = [window]);
|
|
52
51
|
component.updateDropdownPosition = (e) => this.updateDropdownPosition(instance, component);
|
|
53
52
|
|
|
53
|
+
instance.initialScreenPosition = null;
|
|
54
|
+
|
|
54
55
|
var el = instance.relatedElement.parentElement;
|
|
55
56
|
while (el) {
|
|
56
57
|
scrollableParents.push(el);
|
|
@@ -67,7 +68,9 @@ export class Dropdown extends Overlay {
|
|
|
67
68
|
instance.invoke("pipeValidateDropdownPosition", component.updateDropdownPosition, instance);
|
|
68
69
|
|
|
69
70
|
if (instance.parentPositionChangeEvent)
|
|
70
|
-
component.offParentPositionChange = instance.parentPositionChangeEvent.subscribe(
|
|
71
|
+
component.offParentPositionChange = instance.parentPositionChangeEvent.subscribe(
|
|
72
|
+
component.updateDropdownPosition
|
|
73
|
+
);
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
overlayDidUpdate(instance, component) {
|
|
@@ -90,10 +93,17 @@ export class Dropdown extends Overlay {
|
|
|
90
93
|
if (component.offParentPositionChange) component.offParentPositionChange();
|
|
91
94
|
|
|
92
95
|
delete component.parentBounds;
|
|
96
|
+
delete component.initialScreenPosition;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
dismissAfterScroll(data, instance, component) {
|
|
100
|
+
if (this.onDismissAfterScroll && instance.invoke("onDismissAfterScroll", data, instance, component) === false)
|
|
101
|
+
return;
|
|
102
|
+
if (instance.dismiss) instance.dismiss();
|
|
93
103
|
}
|
|
94
104
|
|
|
95
105
|
updateDropdownPosition(instance, component) {
|
|
96
|
-
var { el } = component;
|
|
106
|
+
var { el, initialScreenPosition } = component;
|
|
97
107
|
var { data, relatedElement } = instance;
|
|
98
108
|
var parentBounds = (component.parentBounds = getTopLevelBoundingClientRect(relatedElement));
|
|
99
109
|
|
|
@@ -150,13 +160,15 @@ export class Dropdown extends Overlay {
|
|
|
150
160
|
}
|
|
151
161
|
}
|
|
152
162
|
|
|
153
|
-
|
|
154
|
-
style, placement, parentBounds
|
|
155
|
-
};
|
|
163
|
+
if (!initialScreenPosition) initialScreenPosition = component.initialScreenPosition = parentBounds;
|
|
156
164
|
|
|
157
|
-
if (
|
|
165
|
+
if (
|
|
166
|
+
Math.abs(parentBounds.top - initialScreenPosition.top) > this.closeOnScrollDistance ||
|
|
167
|
+
Math.abs(parentBounds.left - initialScreenPosition.left) > this.closeOnScrollDistance
|
|
168
|
+
)
|
|
169
|
+
this.dismissAfterScroll({ parentBounds, initialScreenPosition }, instance, component);
|
|
158
170
|
|
|
159
|
-
instance.
|
|
171
|
+
instance.positionChangeSubscribers.notify();
|
|
160
172
|
}
|
|
161
173
|
|
|
162
174
|
applyFixedPositioningPlacementStyles(style, placement, contentSize, rel, el, noAuto) {
|
|
@@ -534,8 +546,7 @@ export class Dropdown extends Overlay {
|
|
|
534
546
|
//if relatedElement is not provided, a beacon is rendered to and used to resolve a nearby element as a target
|
|
535
547
|
//if onResolveTarget doesn't provide another element, the beacon itself is used as a target
|
|
536
548
|
let beacon = null;
|
|
537
|
-
if (this.relatedElement)
|
|
538
|
-
instance.relatedElement = this.relatedElement;
|
|
549
|
+
if (this.relatedElement) instance.relatedElement = this.relatedElement;
|
|
539
550
|
|
|
540
551
|
if (!this.relatedElement || instance.needsBeacon) {
|
|
541
552
|
beacon = (
|
|
@@ -571,6 +582,7 @@ Dropdown.prototype.touchFriendly = false;
|
|
|
571
582
|
Dropdown.prototype.arrow = false;
|
|
572
583
|
Dropdown.prototype.pad = false;
|
|
573
584
|
Dropdown.prototype.elementExplode = 0;
|
|
585
|
+
Dropdown.prototype.closeOnScrollDistance = 50;
|
|
574
586
|
Dropdown.prototype.screenPadding = 5;
|
|
575
587
|
Dropdown.prototype.firstChildDefinesHeight = false;
|
|
576
588
|
Dropdown.prototype.firstChildDefinesWidth = false;
|
|
@@ -26,8 +26,7 @@ import { KeyCode } from "../../util/KeyCode";
|
|
|
26
26
|
|
|
27
27
|
export class Overlay extends Container {
|
|
28
28
|
init() {
|
|
29
|
-
if (this.center)
|
|
30
|
-
this.centerX = this.centerY = this.center;
|
|
29
|
+
if (this.center) this.centerX = this.centerY = this.center;
|
|
31
30
|
|
|
32
31
|
super.init();
|
|
33
32
|
}
|
|
@@ -60,7 +59,7 @@ export class Overlay extends Container {
|
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
initInstance(context, instance) {
|
|
63
|
-
instance.
|
|
62
|
+
instance.positionChangeSubscribers = new SubscriberList();
|
|
64
63
|
super.initInstance(context, instance);
|
|
65
64
|
}
|
|
66
65
|
|
|
@@ -83,7 +82,7 @@ export class Overlay extends Container {
|
|
|
83
82
|
|
|
84
83
|
if (instance.cache("dismiss", instance.dismiss)) instance.markShouldUpdate(context);
|
|
85
84
|
|
|
86
|
-
context.push("parentPositionChangeEvent", instance.
|
|
85
|
+
context.push("parentPositionChangeEvent", instance.positionChangeSubscribers);
|
|
87
86
|
|
|
88
87
|
super.explore(context, instance);
|
|
89
88
|
}
|
|
@@ -112,15 +111,14 @@ export class Overlay extends Container {
|
|
|
112
111
|
|
|
113
112
|
overlayDidMount(instance, component) {
|
|
114
113
|
let { el } = component;
|
|
115
|
-
if (this.centerX)
|
|
116
|
-
if (!el.style.left) el.style.left = `${(window.innerWidth - el.offsetWidth) / 2}px`;
|
|
114
|
+
if (this.centerX) if (!el.style.left) el.style.left = `${(window.innerWidth - el.offsetWidth) / 2}px`;
|
|
117
115
|
if (this.centerY)
|
|
118
116
|
if (!el.style.top) el.style.top = `${Math.max(0, (window.innerHeight - el.offsetHeight) / 2)}px`;
|
|
119
117
|
}
|
|
120
118
|
|
|
121
|
-
overlayDidUpdate(instance, component) {
|
|
119
|
+
overlayDidUpdate(instance, component) {}
|
|
122
120
|
|
|
123
|
-
overlayWillUnmount(instance, component) {
|
|
121
|
+
overlayWillUnmount(instance, component) {}
|
|
124
122
|
|
|
125
123
|
handleFocusOut(instance, component) {
|
|
126
124
|
if (this.onFocusOut) instance.invoke("onFocusOut", instance, component);
|
|
@@ -193,7 +191,7 @@ export class Overlay extends Container {
|
|
|
193
191
|
}
|
|
194
192
|
});
|
|
195
193
|
}
|
|
196
|
-
instance.
|
|
194
|
+
instance.positionChangeSubscribers.notify();
|
|
197
195
|
}
|
|
198
196
|
|
|
199
197
|
handleResize(e, instance, component) {
|
|
@@ -209,7 +207,7 @@ export class Overlay extends Container {
|
|
|
209
207
|
}
|
|
210
208
|
});
|
|
211
209
|
}
|
|
212
|
-
instance.
|
|
210
|
+
instance.positionChangeSubscribers.notify();
|
|
213
211
|
}
|
|
214
212
|
}
|
|
215
213
|
|
|
@@ -373,7 +371,7 @@ export class OverlayComponent extends VDOM.Component {
|
|
|
373
371
|
FocusManager.nudge();
|
|
374
372
|
}
|
|
375
373
|
|
|
376
|
-
onFocusIn() {
|
|
374
|
+
onFocusIn() {}
|
|
377
375
|
|
|
378
376
|
onFocusOut() {
|
|
379
377
|
let { widget } = this.props.instance;
|
|
@@ -107,16 +107,19 @@ export class Tooltip extends Dropdown {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
dismissTooltip(instance) {
|
|
110
|
-
if (instance
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
110
|
+
if (!instance || !instance.dismissTooltip) return;
|
|
111
|
+
if (
|
|
112
|
+
instance.data &&
|
|
113
|
+
instance.data.alwaysVisible &&
|
|
114
|
+
this.relatedElement.ownerDocument.body.contains(this.relatedElement)
|
|
115
|
+
)
|
|
116
|
+
return;
|
|
117
|
+
instance.dismissTooltip();
|
|
118
|
+
instance.dismissTooltip = null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
dismissAfterScroll(data, instance) {
|
|
122
|
+
this.dismissTooltip(instance);
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
checkVisible(context, instance, data) {
|