cx 21.12.2 → 21.12.3
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 +674 -674
- package/dist/widgets.js +39 -33
- package/package.json +1 -1
- package/src/widgets/form/LookupField.js +34 -26
package/dist/widgets.js
CHANGED
|
@@ -10616,7 +10616,7 @@ var LookupComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
10616
10616
|
|
|
10617
10617
|
_proto3.onItemClick = function onItemClick(e, _ref2) {
|
|
10618
10618
|
var store = _ref2.store;
|
|
10619
|
-
this.select(e, store.getData());
|
|
10619
|
+
this.select(e, [store.getData()]);
|
|
10620
10620
|
if (!this.props.instance.widget.submitOnEnterKey || e.type != "keydown") e.stopPropagation();
|
|
10621
10621
|
if (e.keyCode != KeyCode.tab) e.preventDefault();
|
|
10622
10622
|
};
|
|
@@ -10672,7 +10672,7 @@ var LookupComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
10672
10672
|
instance.set("values", []);
|
|
10673
10673
|
};
|
|
10674
10674
|
|
|
10675
|
-
_proto3.select = function select(e, itemsData) {
|
|
10675
|
+
_proto3.select = function select(e, itemsData, reset) {
|
|
10676
10676
|
var _this11 = this;
|
|
10677
10677
|
|
|
10678
10678
|
var instance = this.props.instance;
|
|
@@ -10685,17 +10685,26 @@ var LookupComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
10685
10685
|
if (widget.multiple) {
|
|
10686
10686
|
var selectedKeys = data.selectedKeys,
|
|
10687
10687
|
records = data.records;
|
|
10688
|
-
var newRecords = [].concat(records || []);
|
|
10689
|
-
var
|
|
10688
|
+
var newRecords = reset ? [] : [].concat(records || []);
|
|
10689
|
+
var singleSelect = itemsData.length == 1;
|
|
10690
10690
|
var optionKey = null;
|
|
10691
|
-
if (
|
|
10691
|
+
if (singleSelect) optionKey = this.getOptionKey(itemsData[0]); // deselect
|
|
10692
10692
|
|
|
10693
10693
|
if (
|
|
10694
|
-
|
|
10695
|
-
|
|
10694
|
+
singleSelect &&
|
|
10695
|
+
selectedKeys.find(function(k) {
|
|
10696
10696
|
return areKeysEqual(optionKey, k);
|
|
10697
10697
|
})
|
|
10698
10698
|
) {
|
|
10699
|
+
newRecords = records.filter(function(v) {
|
|
10700
|
+
return !areKeysEqual(
|
|
10701
|
+
optionKey,
|
|
10702
|
+
_this11.getLocalKey({
|
|
10703
|
+
$value: v
|
|
10704
|
+
})
|
|
10705
|
+
);
|
|
10706
|
+
});
|
|
10707
|
+
} else {
|
|
10699
10708
|
itemsData.forEach(function(itemData) {
|
|
10700
10709
|
var valueData = {
|
|
10701
10710
|
$value: {}
|
|
@@ -10705,15 +10714,6 @@ var LookupComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
10705
10714
|
});
|
|
10706
10715
|
newRecords.push(valueData.$value);
|
|
10707
10716
|
});
|
|
10708
|
-
} else {
|
|
10709
|
-
newRecords = records.filter(function(v) {
|
|
10710
|
-
return !areKeysEqual(
|
|
10711
|
-
optionKey,
|
|
10712
|
-
_this11.getLocalKey({
|
|
10713
|
-
$value: v
|
|
10714
|
-
})
|
|
10715
|
-
);
|
|
10716
|
-
});
|
|
10717
10717
|
}
|
|
10718
10718
|
|
|
10719
10719
|
instance.set("records", newRecords);
|
|
@@ -10749,21 +10749,15 @@ var LookupComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
10749
10749
|
};
|
|
10750
10750
|
|
|
10751
10751
|
_proto3.onDropdownKeyPress = function onDropdownKeyPress(e) {
|
|
10752
|
-
if (e.keyCode == KeyCode.esc) {
|
|
10753
|
-
this.closeDropdown(e);
|
|
10754
|
-
this.dom.input.focus();
|
|
10755
|
-
}
|
|
10756
|
-
|
|
10757
|
-
if (this.listKeyDown) this.listKeyDown(e); // if next focusable element is disabled, recalculate and update the dom before switching focus
|
|
10758
|
-
|
|
10759
|
-
if (e.keyCode == KeyCode.tab) this.props.forceUpdate();
|
|
10760
|
-
};
|
|
10761
|
-
|
|
10762
|
-
_proto3.onKeyDown = function onKeyDown(e) {
|
|
10763
10752
|
switch (e.keyCode) {
|
|
10764
|
-
case KeyCode.
|
|
10765
|
-
|
|
10766
|
-
|
|
10753
|
+
case KeyCode.esc:
|
|
10754
|
+
this.closeDropdown(e);
|
|
10755
|
+
this.dom.input.focus();
|
|
10756
|
+
break;
|
|
10757
|
+
|
|
10758
|
+
case KeyCode.tab:
|
|
10759
|
+
// if next focusable element is disabled, recalculate and update the dom before switching focus
|
|
10760
|
+
this.props.forceUpdate();
|
|
10767
10761
|
break;
|
|
10768
10762
|
|
|
10769
10763
|
case KeyCode.a:
|
|
@@ -10772,16 +10766,28 @@ var LookupComponent = /*#__PURE__*/ (function(_VDOM$Component) {
|
|
|
10772
10766
|
quickSelectAll = _this$props$instance$2.quickSelectAll,
|
|
10773
10767
|
multiple = _this$props$instance$2.multiple;
|
|
10774
10768
|
if (!quickSelectAll || !multiple) return;
|
|
10775
|
-
var
|
|
10776
|
-
var optionsToSelect = options.map(function(o) {
|
|
10769
|
+
var optionsToSelect = this.state.options.map(function(o) {
|
|
10777
10770
|
return {
|
|
10778
10771
|
$option: o
|
|
10779
10772
|
};
|
|
10780
10773
|
});
|
|
10781
|
-
this.select(e, optionsToSelect);
|
|
10774
|
+
this.select(e, optionsToSelect, true);
|
|
10782
10775
|
e.stopPropagation();
|
|
10783
10776
|
e.preventDefault();
|
|
10784
10777
|
break;
|
|
10778
|
+
|
|
10779
|
+
default:
|
|
10780
|
+
if (this.listKeyDown) this.listKeyDown(e);
|
|
10781
|
+
break;
|
|
10782
|
+
}
|
|
10783
|
+
};
|
|
10784
|
+
|
|
10785
|
+
_proto3.onKeyDown = function onKeyDown(e) {
|
|
10786
|
+
switch (e.keyCode) {
|
|
10787
|
+
case KeyCode.pageDown:
|
|
10788
|
+
case KeyCode.pageUp:
|
|
10789
|
+
if (this.state.dropdownOpen) e.preventDefault();
|
|
10790
|
+
break;
|
|
10785
10791
|
}
|
|
10786
10792
|
};
|
|
10787
10793
|
|
package/package.json
CHANGED
|
@@ -670,7 +670,7 @@ class LookupComponent extends VDOM.Component {
|
|
|
670
670
|
}
|
|
671
671
|
|
|
672
672
|
onItemClick(e, { store }) {
|
|
673
|
-
this.select(e, store.getData());
|
|
673
|
+
this.select(e, [store.getData()]);
|
|
674
674
|
if (!this.props.instance.widget.submitOnEnterKey || e.type != "keydown") e.stopPropagation();
|
|
675
675
|
if (e.keyCode != KeyCode.tab) e.preventDefault();
|
|
676
676
|
}
|
|
@@ -709,7 +709,7 @@ class LookupComponent extends VDOM.Component {
|
|
|
709
709
|
instance.set("values", []);
|
|
710
710
|
}
|
|
711
711
|
|
|
712
|
-
select(e, itemsData) {
|
|
712
|
+
select(e, itemsData, reset) {
|
|
713
713
|
let { instance } = this.props;
|
|
714
714
|
let { store, data, widget } = instance;
|
|
715
715
|
let { bindings, keyBindings } = widget;
|
|
@@ -717,14 +717,17 @@ class LookupComponent extends VDOM.Component {
|
|
|
717
717
|
if (widget.multiple) {
|
|
718
718
|
let { selectedKeys, records } = data;
|
|
719
719
|
|
|
720
|
-
let newRecords = [...(records || [])];
|
|
721
|
-
let
|
|
720
|
+
let newRecords = reset ? [] : [...(records || [])];
|
|
721
|
+
let singleSelect = itemsData.length == 1;
|
|
722
722
|
let optionKey = null;
|
|
723
|
-
if (
|
|
723
|
+
if (singleSelect)
|
|
724
724
|
optionKey = this.getOptionKey(itemsData[0]);
|
|
725
725
|
|
|
726
|
-
//
|
|
727
|
-
if (
|
|
726
|
+
// deselect
|
|
727
|
+
if (singleSelect && selectedKeys.find((k) => areKeysEqual(optionKey, k))) {
|
|
728
|
+
newRecords = records.filter((v) => !areKeysEqual(optionKey, this.getLocalKey({ $value: v })));
|
|
729
|
+
}
|
|
730
|
+
else {
|
|
728
731
|
itemsData.forEach(itemData => {
|
|
729
732
|
let valueData = {
|
|
730
733
|
$value: {},
|
|
@@ -734,8 +737,6 @@ class LookupComponent extends VDOM.Component {
|
|
|
734
737
|
});
|
|
735
738
|
newRecords.push(valueData.$value);
|
|
736
739
|
});
|
|
737
|
-
} else {
|
|
738
|
-
newRecords = records.filter((v) => !areKeysEqual(optionKey, this.getLocalKey({ $value: v })));
|
|
739
740
|
}
|
|
740
741
|
|
|
741
742
|
instance.set("records", newRecords);
|
|
@@ -767,21 +768,15 @@ class LookupComponent extends VDOM.Component {
|
|
|
767
768
|
}
|
|
768
769
|
|
|
769
770
|
onDropdownKeyPress(e) {
|
|
770
|
-
if (e.keyCode == KeyCode.esc) {
|
|
771
|
-
this.closeDropdown(e);
|
|
772
|
-
this.dom.input.focus();
|
|
773
|
-
}
|
|
774
|
-
if (this.listKeyDown) this.listKeyDown(e);
|
|
775
|
-
|
|
776
|
-
// if next focusable element is disabled, recalculate and update the dom before switching focus
|
|
777
|
-
if (e.keyCode == KeyCode.tab) this.props.forceUpdate();
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
onKeyDown(e) {
|
|
781
771
|
switch (e.keyCode) {
|
|
782
|
-
case KeyCode.
|
|
783
|
-
|
|
784
|
-
|
|
772
|
+
case KeyCode.esc:
|
|
773
|
+
this.closeDropdown(e);
|
|
774
|
+
this.dom.input.focus();
|
|
775
|
+
break;
|
|
776
|
+
|
|
777
|
+
case KeyCode.tab:
|
|
778
|
+
// if next focusable element is disabled, recalculate and update the dom before switching focus
|
|
779
|
+
this.props.forceUpdate();
|
|
785
780
|
break;
|
|
786
781
|
|
|
787
782
|
case KeyCode.a:
|
|
@@ -790,14 +785,27 @@ class LookupComponent extends VDOM.Component {
|
|
|
790
785
|
let { quickSelectAll, multiple } = this.props.instance.widget;
|
|
791
786
|
if (!quickSelectAll || !multiple) return;
|
|
792
787
|
|
|
793
|
-
let
|
|
794
|
-
let optionsToSelect = options.map(o => ({
|
|
788
|
+
let optionsToSelect = this.state.options.map(o => ({
|
|
795
789
|
$option: o
|
|
796
790
|
}));
|
|
797
|
-
this.select(e, optionsToSelect);
|
|
791
|
+
this.select(e, optionsToSelect, true);
|
|
798
792
|
e.stopPropagation();
|
|
799
793
|
e.preventDefault();
|
|
800
794
|
break;
|
|
795
|
+
|
|
796
|
+
default:
|
|
797
|
+
if (this.listKeyDown) this.listKeyDown(e);
|
|
798
|
+
break;
|
|
799
|
+
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
onKeyDown(e) {
|
|
804
|
+
switch (e.keyCode) {
|
|
805
|
+
case KeyCode.pageDown:
|
|
806
|
+
case KeyCode.pageUp:
|
|
807
|
+
if (this.state.dropdownOpen) e.preventDefault();
|
|
808
|
+
break;
|
|
801
809
|
}
|
|
802
810
|
}
|
|
803
811
|
|