bkui-vue 1.0.3-beta.59 → 1.0.3-beta.60
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/index.cjs.js +34 -34
- package/dist/index.esm.js +7745 -7733
- package/dist/index.umd.js +34 -34
- package/lib/search-select/index.d.ts +12 -6
- package/lib/search-select/index.js +320 -237
- package/lib/search-select/input.d.ts +2 -1
- package/lib/search-select/search-select.d.ts +4 -2
- package/lib/search-select/selected.d.ts +4 -2
- package/lib/search-select/utils.d.ts +6 -0
- package/lib/upload/index.d.ts +12 -0
- package/lib/upload/index.js +21 -30
- package/lib/upload/props.d.ts +3 -0
- package/lib/upload/upload-trigger.d.ts +6 -0
- package/lib/upload/upload.d.ts +6 -0
- package/package.json +1 -1
@@ -927,6 +927,27 @@ const radio_namespaceObject = radio_x({ ["default"]: () => __WEBPACK_EXTERNAL_MO
|
|
927
927
|
var radio_less_x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
|
928
928
|
var radio_less_y = x => () => x
|
929
929
|
const radio_less_namespaceObject = radio_less_x({ });
|
930
|
+
;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
|
931
|
+
|
932
|
+
function _arrayWithoutHoles(arr) {
|
933
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
934
|
+
}
|
935
|
+
;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/iterableToArray.js
|
936
|
+
function _iterableToArray(iter) {
|
937
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
938
|
+
}
|
939
|
+
;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
|
940
|
+
function _nonIterableSpread() {
|
941
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
942
|
+
}
|
943
|
+
;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
|
944
|
+
|
945
|
+
|
946
|
+
|
947
|
+
|
948
|
+
function _toConsumableArray(arr) {
|
949
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
950
|
+
}
|
930
951
|
;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/classCallCheck.js
|
931
952
|
function _classCallCheck(instance, Constructor) {
|
932
953
|
if (!(instance instanceof Constructor)) {
|
@@ -956,6 +977,7 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
956
977
|
|
957
978
|
|
958
979
|
|
980
|
+
|
959
981
|
/*
|
960
982
|
* Tencent is pleased to support the open source community by making
|
961
983
|
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
|
@@ -994,6 +1016,11 @@ var ValueBehavior;
|
|
994
1016
|
ValueBehavior["ALL"] = "all";
|
995
1017
|
ValueBehavior["NEEDKEY"] = "need-key";
|
996
1018
|
})(ValueBehavior || (ValueBehavior = {}));
|
1019
|
+
var DeleteBehavior;
|
1020
|
+
(function (DeleteBehavior) {
|
1021
|
+
DeleteBehavior["CHAR"] = "delete-char";
|
1022
|
+
DeleteBehavior["VALUE"] = "delete-value";
|
1023
|
+
})(DeleteBehavior || (DeleteBehavior = {}));
|
997
1024
|
var SEARCH_SLECT_PROVIDER_KEY = Symbol('SEARCH_SLECT_PROVIDER_KEY');
|
998
1025
|
var useSearchSelectProvider = function useSearchSelectProvider(data) {
|
999
1026
|
(0,external_vue_namespaceObject.provide)(SEARCH_SLECT_PROVIDER_KEY, data);
|
@@ -1006,6 +1033,8 @@ var SearchInputMode;
|
|
1006
1033
|
SearchInputMode["DEFAULT"] = "default";
|
1007
1034
|
SearchInputMode["EDIT"] = "edit";
|
1008
1035
|
})(SearchInputMode || (SearchInputMode = {}));
|
1036
|
+
var ValueSplitRegex = /(\||,|、|\/|\r\n|\n)/gm;
|
1037
|
+
var ValueSplitTestRegex = /^(\||,|、|\/|\r\n|\n)$/;
|
1009
1038
|
var SearchLogical;
|
1010
1039
|
(function (SearchLogical) {
|
1011
1040
|
SearchLogical["AND"] = "&";
|
@@ -1117,7 +1146,7 @@ var SelectedItem = /*#__PURE__*/function () {
|
|
1117
1146
|
});
|
1118
1147
|
};
|
1119
1148
|
if (!this.multiple) {
|
1120
|
-
var val = list.join(this.logical).trim();
|
1149
|
+
var val = list.join(" ".concat(this.logical, " ")).trim();
|
1121
1150
|
var item = findChildByName(val);
|
1122
1151
|
return [{
|
1123
1152
|
id: item ? item.id : val,
|
@@ -1143,14 +1172,17 @@ var SelectedItem = /*#__PURE__*/function () {
|
|
1143
1172
|
key: "addValues",
|
1144
1173
|
value: function addValues(str) {
|
1145
1174
|
var mergeValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
1146
|
-
var
|
1147
|
-
return
|
1148
|
-
})
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1175
|
+
var valuesFromStr = str.split(ValueSplitRegex).filter(function (v) {
|
1176
|
+
return v.trim() && !ValueSplitTestRegex.test(v);
|
1177
|
+
});
|
1178
|
+
var currentValues = mergeValues ? this.values.map(function (item) {
|
1179
|
+
return item.name;
|
1180
|
+
}) : [];
|
1181
|
+
var combinedValues = [].concat(_toConsumableArray(valuesFromStr), _toConsumableArray(currentValues));
|
1182
|
+
var logicalString = combinedValues.filter(function (v) {
|
1183
|
+
return v.trim();
|
1184
|
+
}).join(this.logical);
|
1185
|
+
this.values = this.str2Values(logicalString);
|
1154
1186
|
}
|
1155
1187
|
}, {
|
1156
1188
|
key: "getValue",
|
@@ -1550,17 +1582,15 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1550
1582
|
// );
|
1551
1583
|
(0,external_vue_namespaceObject.watch)([menuList, showPopover], function () {
|
1552
1584
|
var _menuList$value;
|
1553
|
-
|
1585
|
+
var shouldBindEvent = showPopover.value && ((_menuList$value = menuList.value) === null || _menuList$value === void 0 ? void 0 : _menuList$value.some(function (item) {
|
1554
1586
|
return !item.disabled;
|
1555
|
-
})
|
1587
|
+
}));
|
1588
|
+
if (shouldBindEvent) {
|
1556
1589
|
if (!isBindEvent) {
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
} else {
|
1562
|
-
menuHoverId.value = '';
|
1563
|
-
}
|
1590
|
+
var _menuList$value$find;
|
1591
|
+
menuHoverId.value = props.valueBehavior === ValueBehavior.NEEDKEY ? ((_menuList$value$find = menuList.value.find(function (item) {
|
1592
|
+
return !item.disabled;
|
1593
|
+
})) === null || _menuList$value$find === void 0 ? void 0 : _menuList$value$find.id) || '' : '';
|
1564
1594
|
isBindEvent = true;
|
1565
1595
|
document.addEventListener('keydown', handleDocumentKeydown);
|
1566
1596
|
}
|
@@ -1590,33 +1620,27 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1590
1620
|
e.preventDefault();
|
1591
1621
|
(_inputRef$value = inputRef.value) === null || _inputRef$value === void 0 || _inputRef$value.blur();
|
1592
1622
|
var len = menuList.value.length;
|
1593
|
-
var i = len;
|
1594
1623
|
var index = menuList.value.findIndex(function (set) {
|
1595
1624
|
return set.id === menuHoverId.value;
|
1596
1625
|
});
|
1597
|
-
|
1598
|
-
index = e.code === 'ArrowDown' ?
|
1599
|
-
// eslint-disable-next-line no-nested-ternary
|
1600
|
-
index = index > len - 1 ? 0 : index < 0 ? len - 1 : index;
|
1626
|
+
for (var tries = 0; tries < len; tries++) {
|
1627
|
+
index = (index + (e.code === 'ArrowDown' ? 1 : -1) + len) % len;
|
1601
1628
|
var item = menuList.value[index];
|
1602
1629
|
if (item && !item.disabled) {
|
1603
|
-
i = -1;
|
1604
1630
|
var dom = document.getElementById(item.id);
|
1605
1631
|
dom === null || dom === void 0 || dom.focus();
|
1606
1632
|
menuHoverId.value = item.id;
|
1607
|
-
|
1633
|
+
break;
|
1608
1634
|
}
|
1609
|
-
i -= 1;
|
1610
1635
|
}
|
1611
1636
|
}
|
1612
1637
|
function documentEnterEvent(e) {
|
1613
|
-
if (isBindEvent)
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
}
|
1638
|
+
if (!isBindEvent) return;
|
1639
|
+
e.preventDefault();
|
1640
|
+
var item = menuList.value.find(function (item) {
|
1641
|
+
return item.id === menuHoverId.value;
|
1642
|
+
});
|
1643
|
+
item && handleSelectItem(item);
|
1620
1644
|
}
|
1621
1645
|
function handleClickOutside(e) {
|
1622
1646
|
var _popoverRef$value, _props$clickOutside;
|
@@ -1638,15 +1662,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1638
1662
|
function handleInputFocus() {
|
1639
1663
|
showNoSelectValueError.value = false;
|
1640
1664
|
if (props.mode === SearchInputMode.EDIT && usingItem.value && !isFocus.value) {
|
1665
|
+
var nodeList = Array.from(inputRef.value.querySelectorAll("[data-type=\"".concat(usingItem.value.values.length ? 'value' : usingItem.value.type, "\"]")));
|
1666
|
+
if (!nodeList.length) return;
|
1641
1667
|
var range = document.createRange();
|
1642
1668
|
var selection = window.getSelection();
|
1643
|
-
var nodeList = [];
|
1644
|
-
if (usingItem.value.values.length) {
|
1645
|
-
nodeList = Array.from(inputRef.value.querySelectorAll('[data-type="value"]'));
|
1646
|
-
} else {
|
1647
|
-
nodeList = Array.from(inputRef.value.querySelectorAll("[data-type=\"".concat(usingItem.value.type, "\"]")));
|
1648
|
-
}
|
1649
|
-
if (!nodeList.length) return;
|
1650
1669
|
range.selectNodeContents(nodeList.at(-1));
|
1651
1670
|
selection === null || selection === void 0 || selection.removeAllRanges();
|
1652
1671
|
selection.addRange(range); // 注意这里会触发focu事件
|
@@ -1658,11 +1677,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1658
1677
|
}
|
1659
1678
|
function handleInputPaste(event) {
|
1660
1679
|
event.preventDefault();
|
1661
|
-
var
|
1662
|
-
var pastedData = clipboardData.getData('text');
|
1663
|
-
var tempDiv = document.createElement('div');
|
1664
|
-
tempDiv.innerHTML = pastedData;
|
1665
|
-
var formattedText = (tempDiv.textContent || tempDiv.innerText || '').trim();
|
1680
|
+
var formattedText = event.clipboardData.getData('text').trim();
|
1666
1681
|
if (!usingItem.value) {
|
1667
1682
|
var formateItem = str2SeletedItem(formattedText);
|
1668
1683
|
if (formateItem) {
|
@@ -1670,9 +1685,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1670
1685
|
setInputFocus(true, true);
|
1671
1686
|
return;
|
1672
1687
|
}
|
1673
|
-
keyword.value = formattedText.split(
|
1674
|
-
return
|
1675
|
-
}).join(valueLoagic.value);
|
1688
|
+
keyword.value = formattedText.split(ValueSplitRegex).filter(function (v) {
|
1689
|
+
return v.trim() && !ValueSplitTestRegex.test(v);
|
1690
|
+
}).join(" ".concat(valueLoagic.value, " "));
|
1676
1691
|
inputRef.value.innerText = keyword.value;
|
1677
1692
|
setInputFocus();
|
1678
1693
|
debounceSetMenuList();
|
@@ -1682,13 +1697,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1682
1697
|
debounceSetMenuList();
|
1683
1698
|
}
|
1684
1699
|
function handleInputChange(event) {
|
1685
|
-
var text = event.target.innerText;
|
1700
|
+
var text = event.target.innerText.trim();
|
1686
1701
|
if (!usingItem.value) {
|
1687
1702
|
keyword.value = text;
|
1688
1703
|
debounceSetMenuList();
|
1689
1704
|
return;
|
1690
1705
|
}
|
1691
|
-
keyword.value = usingItem.value.isSpecialType() ? text
|
1706
|
+
keyword.value = usingItem.value.isSpecialType() ? text : text.replace(usingItem.value.name, '').replace(':', '').trim();
|
1692
1707
|
debounceSetMenuList();
|
1693
1708
|
}
|
1694
1709
|
function handleInputKeyup(event) {
|
@@ -1714,20 +1729,20 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1714
1729
|
}
|
1715
1730
|
function _handleKeyEnter() {
|
1716
1731
|
_handleKeyEnter = _asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee(event) {
|
1717
|
-
var
|
1718
|
-
var
|
1732
|
+
var _usingItem$value4, _usingItem$value5;
|
1733
|
+
var isValid;
|
1719
1734
|
return regenerator_default().wrap(function _callee$(_context) {
|
1720
1735
|
while (1) switch (_context.prev = _context.next) {
|
1721
1736
|
case 0:
|
1722
1737
|
event === null || event === void 0 || event.preventDefault();
|
1723
|
-
//
|
1738
|
+
// 异步延迟解决确保响应时机问题
|
1724
1739
|
_context.next = 3;
|
1725
|
-
return new Promise(function (
|
1726
|
-
return setTimeout(
|
1740
|
+
return new Promise(function (resolve) {
|
1741
|
+
return setTimeout(resolve, 0);
|
1727
1742
|
});
|
1728
1743
|
case 3:
|
1729
1744
|
if (usingItem.value) {
|
1730
|
-
_context.next =
|
1745
|
+
_context.next = 9;
|
1731
1746
|
break;
|
1732
1747
|
}
|
1733
1748
|
if (!(!keyword.value || props.valueBehavior === ValueBehavior.NEEDKEY)) {
|
@@ -1736,95 +1751,40 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1736
1751
|
}
|
1737
1752
|
return _context.abrupt("return");
|
1738
1753
|
case 6:
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
return Promise.all(valueList.map(function (item) {
|
1746
|
-
return validateUsingItemValues(item);
|
1747
|
-
})).then(function () {
|
1748
|
-
return true;
|
1749
|
-
})["catch"](function () {
|
1750
|
-
return false;
|
1751
|
-
});
|
1752
|
-
case 10:
|
1753
|
-
_res = _context.sent;
|
1754
|
-
if (_res) {
|
1754
|
+
_context.next = 8;
|
1755
|
+
return enterNewItemSelected();
|
1756
|
+
case 8:
|
1757
|
+
return _context.abrupt("return", _context.sent);
|
1758
|
+
case 9:
|
1759
|
+
if (!keyword.value) {
|
1755
1760
|
_context.next = 13;
|
1756
1761
|
break;
|
1757
1762
|
}
|
1758
|
-
|
1763
|
+
_context.next = 12;
|
1764
|
+
return enterExistingItemSelected();
|
1765
|
+
case 12:
|
1766
|
+
return _context.abrupt("return", _context.sent);
|
1759
1767
|
case 13:
|
1760
|
-
|
1761
|
-
|
1762
|
-
setMenuList();
|
1763
|
-
return _context.abrupt("return", true);
|
1764
|
-
case 17:
|
1765
|
-
if (!((_keyword$value = keyword.value) !== null && _keyword$value !== void 0 && _keyword$value.length)) {
|
1766
|
-
_context.next = 32;
|
1767
|
-
break;
|
1768
|
-
}
|
1769
|
-
_valueList = [];
|
1770
|
-
if (usingItem.value.isSpecialType()) {
|
1771
|
-
_formatItem = str2SeletedItem(keyword.value);
|
1772
|
-
if (_formatItem) {
|
1773
|
-
usingItem.value = _formatItem;
|
1774
|
-
_valueList = _formatItem.values;
|
1775
|
-
}
|
1776
|
-
}
|
1777
|
-
if (!_valueList.length) {
|
1778
|
-
_valueList = usingItem.value.str2Values(keyword.value);
|
1779
|
-
}
|
1780
|
-
_context.next = 23;
|
1781
|
-
return Promise.all(_valueList.map(function (item) {
|
1782
|
-
return validateUsingItemValues(item);
|
1783
|
-
})).then(function () {
|
1784
|
-
return true;
|
1785
|
-
})["catch"](function () {
|
1786
|
-
return false;
|
1787
|
-
});
|
1788
|
-
case 23:
|
1789
|
-
_res2 = _context.sent;
|
1790
|
-
if (_res2) {
|
1791
|
-
_context.next = 26;
|
1792
|
-
break;
|
1793
|
-
}
|
1794
|
-
return _context.abrupt("return");
|
1795
|
-
case 26:
|
1796
|
-
if (usingItem.value.type === 'text') {
|
1797
|
-
usingItem.value.name = keyword.value;
|
1798
|
-
usingItem.value.id = keyword.value;
|
1799
|
-
} else {
|
1800
|
-
usingItem.value.values = _valueList;
|
1801
|
-
}
|
1802
|
-
emit('add', usingItem.value);
|
1803
|
-
keyword.value = '';
|
1804
|
-
usingItem.value = null;
|
1805
|
-
setInputFocus(true);
|
1806
|
-
return _context.abrupt("return", true);
|
1807
|
-
case 32:
|
1808
|
-
if (!(!((_usingItem$value4 = usingItem.value) !== null && _usingItem$value4 !== void 0 && _usingItem$value4.isSpecialType()) && ((_usingItem$value5 = usingItem.value) === null || _usingItem$value5 === void 0 || (_usingItem$value5 = _usingItem$value5.values) === null || _usingItem$value5 === void 0 ? void 0 : _usingItem$value5.length) < 1)) {
|
1809
|
-
_context.next = 35;
|
1768
|
+
if (!(!((_usingItem$value4 = usingItem.value) !== null && _usingItem$value4 !== void 0 && _usingItem$value4.isSpecialType()) && ((_usingItem$value5 = usingItem.value) === null || _usingItem$value5 === void 0 ? void 0 : _usingItem$value5.values.length) < 1)) {
|
1769
|
+
_context.next = 16;
|
1810
1770
|
break;
|
1811
1771
|
}
|
1812
1772
|
showNoSelectValueError.value = !showNoSelectValueError.value;
|
1813
1773
|
return _context.abrupt("return", false);
|
1814
|
-
case
|
1815
|
-
_context.next =
|
1774
|
+
case 16:
|
1775
|
+
_context.next = 18;
|
1816
1776
|
return validateUsingItemValues();
|
1817
|
-
case
|
1818
|
-
|
1819
|
-
if (
|
1820
|
-
_context.next =
|
1777
|
+
case 18:
|
1778
|
+
isValid = _context.sent;
|
1779
|
+
if (isValid) {
|
1780
|
+
_context.next = 21;
|
1821
1781
|
break;
|
1822
1782
|
}
|
1823
1783
|
return _context.abrupt("return", false);
|
1824
|
-
case
|
1784
|
+
case 21:
|
1825
1785
|
setSelectedItem();
|
1826
1786
|
return _context.abrupt("return", false);
|
1827
|
-
case
|
1787
|
+
case 23:
|
1828
1788
|
case "end":
|
1829
1789
|
return _context.stop();
|
1830
1790
|
}
|
@@ -1841,8 +1801,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1841
1801
|
return;
|
1842
1802
|
}
|
1843
1803
|
if ((_usingItem$value2 = usingItem.value) !== null && _usingItem$value2 !== void 0 && _usingItem$value2.values.length) {
|
1844
|
-
|
1845
|
-
|
1804
|
+
var _usingItem$value$chil;
|
1805
|
+
if (usingItem.value.type === 'text' || !((_usingItem$value$chil = usingItem.value.children) !== null && _usingItem$value$chil !== void 0 && _usingItem$value$chil.length)) return;
|
1846
1806
|
event.preventDefault();
|
1847
1807
|
var selection = window.getSelection();
|
1848
1808
|
if ((selection === null || selection === void 0 ? void 0 : selection.rangeCount) > 0) {
|
@@ -1871,89 +1831,78 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1871
1831
|
}
|
1872
1832
|
function _handleSelectItem() {
|
1873
1833
|
_handleSelectItem = _asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee2(item, type) {
|
1874
|
-
var _item$value, _usingItem$value6, _usingItem$
|
1875
|
-
var _item$
|
1834
|
+
var _item$value, _usingItem$value6, _usingItem$value9;
|
1835
|
+
var _item$realId, selectedItem, _usingItem$value7, _usingItem$value8, isCondition;
|
1876
1836
|
return regenerator_default().wrap(function _callee2$(_context2) {
|
1877
1837
|
while (1) switch (_context2.prev = _context2.next) {
|
1878
1838
|
case 0:
|
1879
1839
|
if (!((_item$value = item.value) !== null && _item$value !== void 0 && _item$value.id)) {
|
1880
|
-
_context2.next =
|
1881
|
-
break;
|
1882
|
-
}
|
1883
|
-
if (!(props.valueBehavior === ValueBehavior.NEEDKEY && item.value || !props.validateValues)) {
|
1884
|
-
_context2.next = 8;
|
1840
|
+
_context2.next = 18;
|
1885
1841
|
break;
|
1886
1842
|
}
|
1887
|
-
|
1843
|
+
selectedItem = new SelectedItem(_objectSpread(_objectSpread({}, item), {}, {
|
1888
1844
|
id: (_item$realId = item.realId) !== null && _item$realId !== void 0 ? _item$realId : item.id
|
1889
1845
|
}), type);
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1846
|
+
selectedItem.addValues(item.value.name, false);
|
1847
|
+
if (!(props.valueBehavior === ValueBehavior.NEEDKEY && menuHoverId.value)) {
|
1848
|
+
_context2.next = 8;
|
1849
|
+
break;
|
1894
1850
|
}
|
1851
|
+
setSelectedItem(selectedItem);
|
1852
|
+
setInputFocus(true);
|
1895
1853
|
menuHoverId.value = '';
|
1896
1854
|
return _context2.abrupt("return");
|
1897
1855
|
case 8:
|
1898
|
-
usingItem.value =
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
_context2.
|
1903
|
-
|
1904
|
-
return validateUsingItemValues(v);
|
1905
|
-
}));
|
1906
|
-
case 12:
|
1907
|
-
_res3 = _context2.sent;
|
1908
|
-
if (_res3) {
|
1909
|
-
_context2.next = 16;
|
1856
|
+
usingItem.value = selectedItem;
|
1857
|
+
_context2.next = 11;
|
1858
|
+
return validateUsingItemValues(usingItem.value.values);
|
1859
|
+
case 11:
|
1860
|
+
if (_context2.sent) {
|
1861
|
+
_context2.next = 14;
|
1910
1862
|
break;
|
1911
1863
|
}
|
1912
1864
|
usingItem.value = null;
|
1913
1865
|
return _context2.abrupt("return");
|
1914
|
-
case
|
1866
|
+
case 14:
|
1915
1867
|
setSelectedItem(usingItem.value);
|
1916
|
-
menuHoverId.value = '';
|
1917
1868
|
setInputFocus(true);
|
1869
|
+
menuHoverId.value = '';
|
1918
1870
|
return _context2.abrupt("return");
|
1919
|
-
case
|
1920
|
-
if (usingItem.value) {
|
1921
|
-
_context2.next =
|
1871
|
+
case 18:
|
1872
|
+
if (!(!usingItem.value || ((_usingItem$value6 = usingItem.value) === null || _usingItem$value6 === void 0 ? void 0 : _usingItem$value6.type) === 'condition')) {
|
1873
|
+
_context2.next = 26;
|
1922
1874
|
break;
|
1923
1875
|
}
|
1924
|
-
usingItem.value = new SelectedItem(item, type);
|
1876
|
+
usingItem.value = new SelectedItem(item, type !== null && type !== void 0 ? type : (_usingItem$value7 = usingItem.value) === null || _usingItem$value7 === void 0 ? void 0 : _usingItem$value7.type);
|
1925
1877
|
keyword.value = '';
|
1926
|
-
isCondition = type === 'condition';
|
1927
|
-
|
1878
|
+
isCondition = ((_usingItem$value8 = usingItem.value) === null || _usingItem$value8 === void 0 ? void 0 : _usingItem$value8.type) === 'condition';
|
1879
|
+
if (isCondition) {
|
1880
|
+
setSelectedItem();
|
1881
|
+
}
|
1928
1882
|
showPopover.value = isCondition || !!usingItem.value.children.length;
|
1929
1883
|
setInputFocus(props.valueBehavior === ValueBehavior.NEEDKEY && !!menuHoverId.value);
|
1930
1884
|
return _context2.abrupt("return");
|
1931
|
-
case
|
1932
|
-
if (
|
1933
|
-
|
1934
|
-
|
1885
|
+
case 26:
|
1886
|
+
if (usingItem.value) {
|
1887
|
+
usingItem.value.addValue(item);
|
1888
|
+
(0,external_vue_namespaceObject.nextTick)(deleteInputTextNode);
|
1935
1889
|
}
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
keyword.value = '';
|
1942
|
-
_context2.next = 36;
|
1943
|
-
return validateUsingItemValues(item);
|
1944
|
-
case 36:
|
1945
|
-
res = _context2.sent;
|
1946
|
-
if (res) {
|
1947
|
-
_context2.next = 39;
|
1890
|
+
_context2.next = 29;
|
1891
|
+
return validateUsingItemValues(usingItem.value.values);
|
1892
|
+
case 29:
|
1893
|
+
if (_context2.sent) {
|
1894
|
+
_context2.next = 31;
|
1948
1895
|
break;
|
1949
1896
|
}
|
1950
1897
|
return _context2.abrupt("return");
|
1951
|
-
case
|
1952
|
-
if (!usingItem.value.multiple)
|
1953
|
-
|
1898
|
+
case 31:
|
1899
|
+
if (!usingItem.value.multiple) {
|
1900
|
+
setSelectedItem();
|
1901
|
+
}
|
1902
|
+
if (props.valueBehavior === ValueBehavior.NEEDKEY && (_usingItem$value9 = usingItem.value) !== null && _usingItem$value9 !== void 0 && _usingItem$value9.multiple) {
|
1954
1903
|
setInputFocus();
|
1955
1904
|
}
|
1956
|
-
case
|
1905
|
+
case 33:
|
1957
1906
|
case "end":
|
1958
1907
|
return _context2.stop();
|
1959
1908
|
}
|
@@ -1978,90 +1927,104 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1978
1927
|
break;
|
1979
1928
|
}
|
1980
1929
|
}
|
1930
|
+
function handleLogicalChange(logical) {
|
1931
|
+
if (!usingItem.value) return;
|
1932
|
+
usingItem.value.logical = logical;
|
1933
|
+
}
|
1981
1934
|
// functions
|
1982
|
-
function
|
1983
|
-
return
|
1935
|
+
function validateValues(_x4, _x5) {
|
1936
|
+
return _validateValues.apply(this, arguments);
|
1984
1937
|
}
|
1985
|
-
function
|
1986
|
-
|
1987
|
-
var
|
1938
|
+
function _validateValues() {
|
1939
|
+
_validateValues = _asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee3(searchItem, value) {
|
1940
|
+
var validateStr;
|
1988
1941
|
return regenerator_default().wrap(function _callee3$(_context3) {
|
1989
1942
|
while (1) switch (_context3.prev = _context3.next) {
|
1990
1943
|
case 0:
|
1991
|
-
if (
|
1992
|
-
_context3.next =
|
1944
|
+
if (!(typeof props.validateValues === 'function')) {
|
1945
|
+
_context3.next = 14;
|
1993
1946
|
break;
|
1994
1947
|
}
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
return
|
1999
|
-
case
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
1948
|
+
validateStr = '';
|
1949
|
+
_context3.prev = 2;
|
1950
|
+
_context3.next = 5;
|
1951
|
+
return props.validateValues(searchItem !== null && searchItem !== void 0 ? searchItem : null, value);
|
1952
|
+
case 5:
|
1953
|
+
validateStr = _context3.sent;
|
1954
|
+
_context3.next = 11;
|
1955
|
+
break;
|
1956
|
+
case 8:
|
1957
|
+
_context3.prev = 8;
|
1958
|
+
_context3.t0 = _context3["catch"](2);
|
1959
|
+
validateStr = false;
|
1960
|
+
case 11:
|
1961
|
+
if (!(typeof validateStr === 'string' || validateStr === false)) {
|
1962
|
+
_context3.next = 14;
|
2003
1963
|
break;
|
2004
1964
|
}
|
2005
|
-
|
2006
|
-
return
|
2007
|
-
case
|
2008
|
-
return _context3.abrupt("return", _context3.sent);
|
2009
|
-
case 9:
|
1965
|
+
onValidate(validateStr || '校验错误');
|
1966
|
+
return _context3.abrupt("return", false);
|
1967
|
+
case 14:
|
2010
1968
|
onValidate('');
|
2011
1969
|
return _context3.abrupt("return", true);
|
2012
|
-
case
|
1970
|
+
case 16:
|
2013
1971
|
case "end":
|
2014
1972
|
return _context3.stop();
|
2015
1973
|
}
|
2016
|
-
}, _callee3);
|
1974
|
+
}, _callee3, null, [[2, 8]]);
|
2017
1975
|
}));
|
2018
|
-
return _validateUsingItemValues.apply(this, arguments);
|
2019
|
-
}
|
2020
|
-
function validateValues(_x5, _x6) {
|
2021
1976
|
return _validateValues.apply(this, arguments);
|
2022
1977
|
}
|
2023
|
-
function
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
1978
|
+
function validateUsingItemValues(_x6) {
|
1979
|
+
return _validateUsingItemValues.apply(this, arguments);
|
1980
|
+
}
|
1981
|
+
function _validateUsingItemValues() {
|
1982
|
+
_validateUsingItemValues = _asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee4(preValues) {
|
1983
|
+
var _usingItem$value10, searchItem, validate, values;
|
2027
1984
|
return regenerator_default().wrap(function _callee4$(_context4) {
|
2028
1985
|
while (1) switch (_context4.prev = _context4.next) {
|
2029
1986
|
case 0:
|
2030
|
-
|
2031
|
-
|
2032
|
-
return false;
|
2033
|
-
});
|
2034
|
-
case 2:
|
2035
|
-
validateStr = _context4.sent;
|
2036
|
-
if (!(typeof validateStr === 'string' || validateStr === false)) {
|
2037
|
-
_context4.next = 6;
|
1987
|
+
if (usingItem.value) {
|
1988
|
+
_context4.next = 4;
|
2038
1989
|
break;
|
2039
1990
|
}
|
2040
|
-
|
2041
|
-
return
|
2042
|
-
case
|
1991
|
+
_context4.next = 3;
|
1992
|
+
return validateValues(null, preValues);
|
1993
|
+
case 3:
|
1994
|
+
return _context4.abrupt("return", _context4.sent);
|
1995
|
+
case 4:
|
1996
|
+
_usingItem$value10 = usingItem.value, searchItem = _usingItem$value10.searchItem, validate = _usingItem$value10.validate, values = _usingItem$value10.values;
|
1997
|
+
if (!(validate && typeof props.validateValues === 'function')) {
|
1998
|
+
_context4.next = 9;
|
1999
|
+
break;
|
2000
|
+
}
|
2001
|
+
_context4.next = 8;
|
2002
|
+
return validateValues(searchItem, preValues !== null && preValues !== void 0 ? preValues : values);
|
2003
|
+
case 8:
|
2004
|
+
return _context4.abrupt("return", _context4.sent);
|
2005
|
+
case 9:
|
2043
2006
|
onValidate('');
|
2044
2007
|
return _context4.abrupt("return", true);
|
2045
|
-
case
|
2008
|
+
case 11:
|
2046
2009
|
case "end":
|
2047
2010
|
return _context4.stop();
|
2048
2011
|
}
|
2049
2012
|
}, _callee4);
|
2050
2013
|
}));
|
2051
|
-
return
|
2014
|
+
return _validateUsingItemValues.apply(this, arguments);
|
2052
2015
|
}
|
2053
2016
|
function setMenuList() {
|
2054
2017
|
return _setMenuList.apply(this, arguments);
|
2055
2018
|
}
|
2056
2019
|
function _setMenuList() {
|
2057
2020
|
_setMenuList = _asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee5() {
|
2058
|
-
var _usingItem$
|
2021
|
+
var _props$data, _usingItem$value$sear, _usingItem$value$valu;
|
2059
2022
|
var list, _usingItem$value11, _keyword$value2, hoverItem;
|
2060
2023
|
return regenerator_default().wrap(function _callee5$(_context5) {
|
2061
2024
|
while (1) switch (_context5.prev = _context5.next) {
|
2062
2025
|
case 0:
|
2063
2026
|
list = [];
|
2064
|
-
if (!(typeof props.getMenuList === 'function' && (
|
2027
|
+
if (!(typeof props.getMenuList === 'function' && (!((_props$data = props.data) !== null && _props$data !== void 0 && _props$data.length) && !usingItem.value || usingItem.value && (((_usingItem$value$sear = usingItem.value.searchItem) === null || _usingItem$value$sear === void 0 ? void 0 : _usingItem$value$sear.async) === undefined || usingItem.value.searchItem.async === true)))) {
|
2065
2028
|
_context5.next = 9;
|
2066
2029
|
break;
|
2067
2030
|
}
|
@@ -2153,6 +2116,89 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
2153
2116
|
}));
|
2154
2117
|
return _setMenuList.apply(this, arguments);
|
2155
2118
|
}
|
2119
|
+
function enterNewItemSelected() {
|
2120
|
+
return _enterNewItemSelected.apply(this, arguments);
|
2121
|
+
}
|
2122
|
+
function _enterNewItemSelected() {
|
2123
|
+
_enterNewItemSelected = _asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee6() {
|
2124
|
+
var formatItem, valueList, res;
|
2125
|
+
return regenerator_default().wrap(function _callee6$(_context6) {
|
2126
|
+
while (1) switch (_context6.prev = _context6.next) {
|
2127
|
+
case 0:
|
2128
|
+
formatItem = str2SeletedItem(keyword.value);
|
2129
|
+
valueList = (formatItem === null || formatItem === void 0 ? void 0 : formatItem.values) || [{
|
2130
|
+
id: keyword.value,
|
2131
|
+
name: keyword.value
|
2132
|
+
}];
|
2133
|
+
_context6.next = 4;
|
2134
|
+
return validateUsingItemValues(valueList);
|
2135
|
+
case 4:
|
2136
|
+
res = _context6.sent;
|
2137
|
+
if (res) {
|
2138
|
+
_context6.next = 7;
|
2139
|
+
break;
|
2140
|
+
}
|
2141
|
+
return _context6.abrupt("return");
|
2142
|
+
case 7:
|
2143
|
+
emit('add', formatItem || new SelectedItem(_objectSpread({}, valueList[0]), 'text'));
|
2144
|
+
keyword.value = '';
|
2145
|
+
setMenuList();
|
2146
|
+
return _context6.abrupt("return", true);
|
2147
|
+
case 11:
|
2148
|
+
case "end":
|
2149
|
+
return _context6.stop();
|
2150
|
+
}
|
2151
|
+
}, _callee6);
|
2152
|
+
}));
|
2153
|
+
return _enterNewItemSelected.apply(this, arguments);
|
2154
|
+
}
|
2155
|
+
function enterExistingItemSelected() {
|
2156
|
+
return _enterExistingItemSelected.apply(this, arguments);
|
2157
|
+
}
|
2158
|
+
function _enterExistingItemSelected() {
|
2159
|
+
_enterExistingItemSelected = _asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee7() {
|
2160
|
+
var valueList, formatItem, isValid;
|
2161
|
+
return regenerator_default().wrap(function _callee7$(_context7) {
|
2162
|
+
while (1) switch (_context7.prev = _context7.next) {
|
2163
|
+
case 0:
|
2164
|
+
valueList = [];
|
2165
|
+
if (usingItem.value.isSpecialType()) {
|
2166
|
+
formatItem = str2SeletedItem(keyword.value);
|
2167
|
+
if (formatItem) {
|
2168
|
+
usingItem.value = formatItem;
|
2169
|
+
valueList = formatItem.values;
|
2170
|
+
}
|
2171
|
+
}
|
2172
|
+
valueList = valueList.length ? valueList : usingItem.value.str2Values(keyword.value);
|
2173
|
+
_context7.next = 5;
|
2174
|
+
return validateUsingItemValues(valueList);
|
2175
|
+
case 5:
|
2176
|
+
isValid = _context7.sent;
|
2177
|
+
if (isValid) {
|
2178
|
+
_context7.next = 8;
|
2179
|
+
break;
|
2180
|
+
}
|
2181
|
+
return _context7.abrupt("return");
|
2182
|
+
case 8:
|
2183
|
+
if (usingItem.value.type === 'text') {
|
2184
|
+
usingItem.value.name = keyword.value;
|
2185
|
+
usingItem.value.id = keyword.value;
|
2186
|
+
} else {
|
2187
|
+
usingItem.value.values = valueList;
|
2188
|
+
}
|
2189
|
+
emit('add', usingItem.value);
|
2190
|
+
keyword.value = '';
|
2191
|
+
usingItem.value = null;
|
2192
|
+
setInputFocus(true);
|
2193
|
+
return _context7.abrupt("return", true);
|
2194
|
+
case 14:
|
2195
|
+
case "end":
|
2196
|
+
return _context7.stop();
|
2197
|
+
}
|
2198
|
+
}, _callee7);
|
2199
|
+
}));
|
2200
|
+
return _enterExistingItemSelected.apply(this, arguments);
|
2201
|
+
}
|
2156
2202
|
function setCursorToEnd() {
|
2157
2203
|
if (!inputRef.value) return;
|
2158
2204
|
var range = document.createRange();
|
@@ -2184,11 +2230,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
2184
2230
|
function clearInput() {
|
2185
2231
|
if (!inputRef.value) return;
|
2186
2232
|
keyword.value = '';
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
if (!usingItem.value) return;
|
2191
|
-
usingItem.value.logical = logical;
|
2233
|
+
(0,external_vue_namespaceObject.nextTick)(function () {
|
2234
|
+
return inputRef.value.innerText = '';
|
2235
|
+
});
|
2192
2236
|
}
|
2193
2237
|
function str2SeletedItem(str) {
|
2194
2238
|
var _str$split = str.split(':'),
|
@@ -2207,14 +2251,45 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
2207
2251
|
}
|
2208
2252
|
return undefined;
|
2209
2253
|
}
|
2254
|
+
function deleteInputTextNode() {
|
2255
|
+
var _keyword$value;
|
2256
|
+
if ((_keyword$value = keyword.value) !== null && _keyword$value !== void 0 && _keyword$value.length) {
|
2257
|
+
keyword.value = '';
|
2258
|
+
var nodes = Array.from(inputRef.value.childNodes);
|
2259
|
+
nodes.forEach(function (node) {
|
2260
|
+
var _node$textContent;
|
2261
|
+
if (node.nodeType === Node.TEXT_NODE && (_node$textContent = node.textContent) !== null && _node$textContent !== void 0 && _node$textContent.trim()) {
|
2262
|
+
inputRef.value.removeChild(node);
|
2263
|
+
}
|
2264
|
+
});
|
2265
|
+
}
|
2266
|
+
}
|
2210
2267
|
function inputFocusForWrapper() {
|
2211
2268
|
var _inputRef$value2;
|
2212
2269
|
(_inputRef$value2 = inputRef.value) === null || _inputRef$value2 === void 0 || _inputRef$value2.focus();
|
2213
2270
|
}
|
2214
2271
|
function inputEnterForWrapper() {
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2272
|
+
return _inputEnterForWrapper.apply(this, arguments);
|
2273
|
+
}
|
2274
|
+
function _inputEnterForWrapper() {
|
2275
|
+
_inputEnterForWrapper = _asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee8() {
|
2276
|
+
return regenerator_default().wrap(function _callee8$(_context8) {
|
2277
|
+
while (1) switch (_context8.prev = _context8.next) {
|
2278
|
+
case 0:
|
2279
|
+
_context8.next = 2;
|
2280
|
+
return handleKeyEnter().then(function (v) {
|
2281
|
+
return v && clearInput();
|
2282
|
+
});
|
2283
|
+
case 2:
|
2284
|
+
showPopover.value = false;
|
2285
|
+
inputRef.value.blur();
|
2286
|
+
case 4:
|
2287
|
+
case "end":
|
2288
|
+
return _context8.stop();
|
2289
|
+
}
|
2290
|
+
}, _callee8);
|
2291
|
+
}));
|
2292
|
+
return _inputEnterForWrapper.apply(this, arguments);
|
2218
2293
|
}
|
2219
2294
|
function inputClearForWrapper() {
|
2220
2295
|
keyword.value = '';
|
@@ -2258,6 +2333,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
2258
2333
|
inputFocusForWrapper: inputFocusForWrapper,
|
2259
2334
|
inputEnterForWrapper: inputEnterForWrapper,
|
2260
2335
|
inputClearForWrapper: inputClearForWrapper,
|
2336
|
+
deleteInputTextNode: deleteInputTextNode,
|
2261
2337
|
t: t
|
2262
2338
|
};
|
2263
2339
|
},
|
@@ -2604,6 +2680,13 @@ var SearchSelectProps = {
|
|
2604
2680
|
return [ValueBehavior.ALL, ValueBehavior.NEEDKEY].includes(v);
|
2605
2681
|
}
|
2606
2682
|
}
|
2683
|
+
// deleteBehavior: {
|
2684
|
+
// type: String as PropType<`${DeleteBehavior}`>,
|
2685
|
+
// default: DeleteBehavior.CHAR,
|
2686
|
+
// validator(v: DeleteBehavior) {
|
2687
|
+
// return [DeleteBehavior.CHAR, DeleteBehavior.VALUE].includes(v);
|
2688
|
+
// },
|
2689
|
+
// },
|
2607
2690
|
};
|
2608
2691
|
/* harmony default export */ const search_select = ((0,external_vue_namespaceObject.defineComponent)({
|
2609
2692
|
name: 'SearchSelect',
|