cx 22.1.1 → 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 +567 -567
- package/dist/ui.js +13 -9
- package/dist/widgets.css +8 -0
- package/dist/widgets.js +194 -151
- package/package.json +1 -1
- package/src/ui/FocusManager.d.ts +12 -10
- package/src/ui/FocusManager.js +9 -22
- package/src/ui/app/History.d.ts +4 -2
- package/src/ui/app/History.js +50 -51
- package/src/widgets/form/LookupField.d.ts +0 -3
- package/src/widgets/form/LookupField.js +12 -25
- package/src/widgets/grid/Grid.d.ts +3 -0
- package/src/widgets/grid/Grid.js +147 -115
- package/src/widgets/grid/Grid.scss +9 -0
- package/src/widgets/nav/MenuItem.d.ts +0 -2
- package/src/widgets/nav/MenuItem.js +8 -15
- package/src/widgets/nav/Tab.js +34 -35
- 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
|
@@ -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();
|
package/src/widgets/nav/Tab.js
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
import {Widget, VDOM} from
|
|
2
|
-
import {HtmlElement} from
|
|
3
|
-
import {preventFocusOnTouch} from
|
|
4
|
-
import {isUndefined} from
|
|
1
|
+
import { Widget, VDOM } from "../../ui/Widget";
|
|
2
|
+
import { HtmlElement } from "../HtmlElement";
|
|
3
|
+
import { preventFocusOnTouch } from "../../ui/FocusManager";
|
|
4
|
+
import { isUndefined } from "../../util/isUndefined";
|
|
5
5
|
|
|
6
6
|
export class Tab extends HtmlElement {
|
|
7
|
-
|
|
8
7
|
declareData() {
|
|
9
|
-
super.declareData(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
super.declareData(
|
|
9
|
+
{
|
|
10
|
+
tab: undefined,
|
|
11
|
+
value: undefined,
|
|
12
|
+
disabled: undefined,
|
|
13
|
+
text: undefined,
|
|
14
|
+
},
|
|
15
|
+
...arguments
|
|
16
|
+
);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
prepareData(context, instance) {
|
|
18
|
-
let {data} = instance;
|
|
20
|
+
let { data } = instance;
|
|
19
21
|
data.stateMods = {
|
|
20
22
|
active: data.tab == data.value,
|
|
21
23
|
disabled: data.disabled,
|
|
22
|
-
shape: this.shape
|
|
24
|
+
shape: this.shape,
|
|
23
25
|
};
|
|
24
|
-
if (this.default && isUndefined(data.value))
|
|
25
|
-
instance.set('value', data.tab);
|
|
26
|
+
if (this.default && isUndefined(data.value)) instance.set("value", data.tab);
|
|
26
27
|
super.prepareData(context, instance);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
isValidHtmlAttribute(attrName) {
|
|
30
31
|
switch (attrName) {
|
|
31
|
-
case
|
|
32
|
-
case
|
|
33
|
-
case
|
|
34
|
-
case
|
|
35
|
-
case
|
|
32
|
+
case "value":
|
|
33
|
+
case "tab":
|
|
34
|
+
case "text":
|
|
35
|
+
case "disabled":
|
|
36
|
+
case "default":
|
|
36
37
|
return false;
|
|
37
38
|
|
|
38
39
|
default:
|
|
@@ -43,41 +44,39 @@ export class Tab extends HtmlElement {
|
|
|
43
44
|
attachProps(context, instance, props) {
|
|
44
45
|
super.attachProps(context, instance, props);
|
|
45
46
|
|
|
46
|
-
let {data} = instance;
|
|
47
|
+
let { data } = instance;
|
|
47
48
|
if (!data.disabled) {
|
|
48
|
-
props.href =
|
|
49
|
+
props.href = "#";
|
|
49
50
|
delete props.value;
|
|
50
51
|
|
|
51
|
-
props.onMouseDown = e => {
|
|
52
|
-
if (this.onMouseDown)
|
|
53
|
-
instance.invoke('onMouseDown', e, instance);
|
|
52
|
+
props.onMouseDown = (e) => {
|
|
53
|
+
if (this.onMouseDown) instance.invoke("onMouseDown", e, instance);
|
|
54
54
|
preventFocusOnTouch(e);
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
props.onClick = e => this.handleClick(e, instance);
|
|
57
|
+
props.onClick = (e) => this.handleClick(e, instance);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
handleClick(e, instance) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
if (this.onClick && instance.invoke("onClick", e, instance) === false) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
65
|
|
|
66
66
|
e.preventDefault();
|
|
67
67
|
e.stopPropagation();
|
|
68
68
|
|
|
69
|
-
let {data} = instance;
|
|
69
|
+
let { data } = instance;
|
|
70
70
|
|
|
71
|
-
if (data.disabled)
|
|
72
|
-
return;
|
|
71
|
+
if (data.disabled) return;
|
|
73
72
|
|
|
74
|
-
instance.set(
|
|
73
|
+
instance.set("value", data.tab);
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
Tab.prototype.baseClass = "tab";
|
|
79
|
-
Tab.prototype.tag =
|
|
78
|
+
Tab.prototype.tag = "a";
|
|
80
79
|
Tab.prototype.focusOnMouseDown = false;
|
|
81
80
|
Tab.prototype.default = false;
|
|
82
81
|
|
|
83
|
-
Widget.alias(
|
|
82
|
+
Widget.alias("tab", Tab);
|
|
@@ -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) {
|