bkui-vue 1.0.3-beta.58 → 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 +35 -35
- package/dist/index.esm.js +7918 -7901
- package/dist/index.umd.js +35 -35
- package/dist/style.css +1 -1
- package/dist/style.variable.css +1 -1
- package/lib/search-select/index.d.ts +18 -6
- package/lib/search-select/index.js +334 -238
- package/lib/search-select/input.d.ts +3 -1
- package/lib/search-select/search-select.css +1 -0
- package/lib/search-select/search-select.d.ts +6 -2
- package/lib/search-select/search-select.less +1 -0
- package/lib/search-select/search-select.variable.css +1 -0
- package/lib/search-select/selected.d.ts +6 -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,39 +1620,35 @@ 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;
|
1623
1647
|
if (!((_popoverRef$value = popoverRef.value) !== null && _popoverRef$value !== void 0 && _popoverRef$value.contains(e.target)) && (_props$clickOutside = props.clickOutside) !== null && _props$clickOutside !== void 0 && _props$clickOutside.call(props, e.target, popoverRef.value)) {
|
1624
1648
|
if (props.mode === SearchInputMode.EDIT || usingItem.value) {
|
1625
|
-
usingItem.value && handleKeyEnter()
|
1649
|
+
usingItem.value && handleKeyEnter().then(function (v) {
|
1650
|
+
return v && clearInput();
|
1651
|
+
});
|
1626
1652
|
if (!usingItem.value) {
|
1627
1653
|
emit('focus', false);
|
1628
1654
|
}
|
@@ -1636,15 +1662,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1636
1662
|
function handleInputFocus() {
|
1637
1663
|
showNoSelectValueError.value = false;
|
1638
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;
|
1639
1667
|
var range = document.createRange();
|
1640
1668
|
var selection = window.getSelection();
|
1641
|
-
var nodeList = [];
|
1642
|
-
if (usingItem.value.values.length) {
|
1643
|
-
nodeList = Array.from(inputRef.value.querySelectorAll('[data-type="value"]'));
|
1644
|
-
} else {
|
1645
|
-
nodeList = Array.from(inputRef.value.querySelectorAll("[data-type=\"".concat(usingItem.value.type, "\"]")));
|
1646
|
-
}
|
1647
|
-
if (!nodeList.length) return;
|
1648
1669
|
range.selectNodeContents(nodeList.at(-1));
|
1649
1670
|
selection === null || selection === void 0 || selection.removeAllRanges();
|
1650
1671
|
selection.addRange(range); // 注意这里会触发focu事件
|
@@ -1656,11 +1677,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1656
1677
|
}
|
1657
1678
|
function handleInputPaste(event) {
|
1658
1679
|
event.preventDefault();
|
1659
|
-
var
|
1660
|
-
var pastedData = clipboardData.getData('text');
|
1661
|
-
var tempDiv = document.createElement('div');
|
1662
|
-
tempDiv.innerHTML = pastedData;
|
1663
|
-
var formattedText = (tempDiv.textContent || tempDiv.innerText || '').trim();
|
1680
|
+
var formattedText = event.clipboardData.getData('text').trim();
|
1664
1681
|
if (!usingItem.value) {
|
1665
1682
|
var formateItem = str2SeletedItem(formattedText);
|
1666
1683
|
if (formateItem) {
|
@@ -1668,9 +1685,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1668
1685
|
setInputFocus(true, true);
|
1669
1686
|
return;
|
1670
1687
|
}
|
1671
|
-
keyword.value = formattedText.split(
|
1672
|
-
return
|
1673
|
-
}).join(valueLoagic.value);
|
1688
|
+
keyword.value = formattedText.split(ValueSplitRegex).filter(function (v) {
|
1689
|
+
return v.trim() && !ValueSplitTestRegex.test(v);
|
1690
|
+
}).join(" ".concat(valueLoagic.value, " "));
|
1674
1691
|
inputRef.value.innerText = keyword.value;
|
1675
1692
|
setInputFocus();
|
1676
1693
|
debounceSetMenuList();
|
@@ -1680,13 +1697,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1680
1697
|
debounceSetMenuList();
|
1681
1698
|
}
|
1682
1699
|
function handleInputChange(event) {
|
1683
|
-
var text = event.target.innerText;
|
1700
|
+
var text = event.target.innerText.trim();
|
1684
1701
|
if (!usingItem.value) {
|
1685
1702
|
keyword.value = text;
|
1686
1703
|
debounceSetMenuList();
|
1687
1704
|
return;
|
1688
1705
|
}
|
1689
|
-
keyword.value = usingItem.value.isSpecialType() ? text
|
1706
|
+
keyword.value = usingItem.value.isSpecialType() ? text : text.replace(usingItem.value.name, '').replace(':', '').trim();
|
1690
1707
|
debounceSetMenuList();
|
1691
1708
|
}
|
1692
1709
|
function handleInputKeyup(event) {
|
@@ -1712,20 +1729,20 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1712
1729
|
}
|
1713
1730
|
function _handleKeyEnter() {
|
1714
1731
|
_handleKeyEnter = _asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee(event) {
|
1715
|
-
var
|
1716
|
-
var
|
1732
|
+
var _usingItem$value4, _usingItem$value5;
|
1733
|
+
var isValid;
|
1717
1734
|
return regenerator_default().wrap(function _callee$(_context) {
|
1718
1735
|
while (1) switch (_context.prev = _context.next) {
|
1719
1736
|
case 0:
|
1720
1737
|
event === null || event === void 0 || event.preventDefault();
|
1721
|
-
//
|
1738
|
+
// 异步延迟解决确保响应时机问题
|
1722
1739
|
_context.next = 3;
|
1723
|
-
return new Promise(function (
|
1724
|
-
return setTimeout(
|
1740
|
+
return new Promise(function (resolve) {
|
1741
|
+
return setTimeout(resolve, 0);
|
1725
1742
|
});
|
1726
1743
|
case 3:
|
1727
1744
|
if (usingItem.value) {
|
1728
|
-
_context.next =
|
1745
|
+
_context.next = 9;
|
1729
1746
|
break;
|
1730
1747
|
}
|
1731
1748
|
if (!(!keyword.value || props.valueBehavior === ValueBehavior.NEEDKEY)) {
|
@@ -1734,95 +1751,40 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1734
1751
|
}
|
1735
1752
|
return _context.abrupt("return");
|
1736
1753
|
case 6:
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
return Promise.all(valueList.map(function (item) {
|
1744
|
-
return validateUsingItemValues(item);
|
1745
|
-
})).then(function () {
|
1746
|
-
return true;
|
1747
|
-
})["catch"](function () {
|
1748
|
-
return false;
|
1749
|
-
});
|
1750
|
-
case 10:
|
1751
|
-
_res = _context.sent;
|
1752
|
-
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) {
|
1753
1760
|
_context.next = 13;
|
1754
1761
|
break;
|
1755
1762
|
}
|
1756
|
-
|
1763
|
+
_context.next = 12;
|
1764
|
+
return enterExistingItemSelected();
|
1765
|
+
case 12:
|
1766
|
+
return _context.abrupt("return", _context.sent);
|
1757
1767
|
case 13:
|
1758
|
-
|
1759
|
-
|
1760
|
-
setMenuList();
|
1761
|
-
return _context.abrupt("return", true);
|
1762
|
-
case 17:
|
1763
|
-
if (!((_keyword$value = keyword.value) !== null && _keyword$value !== void 0 && _keyword$value.length)) {
|
1764
|
-
_context.next = 32;
|
1765
|
-
break;
|
1766
|
-
}
|
1767
|
-
_valueList = [];
|
1768
|
-
if (usingItem.value.isSpecialType()) {
|
1769
|
-
_formatItem = str2SeletedItem(keyword.value);
|
1770
|
-
if (_formatItem) {
|
1771
|
-
usingItem.value = _formatItem;
|
1772
|
-
_valueList = _formatItem.values;
|
1773
|
-
}
|
1774
|
-
}
|
1775
|
-
if (!_valueList.length) {
|
1776
|
-
_valueList = usingItem.value.str2Values(keyword.value);
|
1777
|
-
}
|
1778
|
-
_context.next = 23;
|
1779
|
-
return Promise.all(_valueList.map(function (item) {
|
1780
|
-
return validateUsingItemValues(item);
|
1781
|
-
})).then(function () {
|
1782
|
-
return true;
|
1783
|
-
})["catch"](function () {
|
1784
|
-
return false;
|
1785
|
-
});
|
1786
|
-
case 23:
|
1787
|
-
_res2 = _context.sent;
|
1788
|
-
if (_res2) {
|
1789
|
-
_context.next = 26;
|
1790
|
-
break;
|
1791
|
-
}
|
1792
|
-
return _context.abrupt("return");
|
1793
|
-
case 26:
|
1794
|
-
if (usingItem.value.type === 'text') {
|
1795
|
-
usingItem.value.name = keyword.value;
|
1796
|
-
usingItem.value.id = keyword.value;
|
1797
|
-
} else {
|
1798
|
-
usingItem.value.values = _valueList;
|
1799
|
-
}
|
1800
|
-
emit('add', usingItem.value);
|
1801
|
-
keyword.value = '';
|
1802
|
-
usingItem.value = null;
|
1803
|
-
setInputFocus(true);
|
1804
|
-
return _context.abrupt("return", true);
|
1805
|
-
case 32:
|
1806
|
-
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)) {
|
1807
|
-
_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;
|
1808
1770
|
break;
|
1809
1771
|
}
|
1810
1772
|
showNoSelectValueError.value = !showNoSelectValueError.value;
|
1811
1773
|
return _context.abrupt("return", false);
|
1812
|
-
case
|
1813
|
-
_context.next =
|
1774
|
+
case 16:
|
1775
|
+
_context.next = 18;
|
1814
1776
|
return validateUsingItemValues();
|
1815
|
-
case
|
1816
|
-
|
1817
|
-
if (
|
1818
|
-
_context.next =
|
1777
|
+
case 18:
|
1778
|
+
isValid = _context.sent;
|
1779
|
+
if (isValid) {
|
1780
|
+
_context.next = 21;
|
1819
1781
|
break;
|
1820
1782
|
}
|
1821
1783
|
return _context.abrupt("return", false);
|
1822
|
-
case
|
1784
|
+
case 21:
|
1823
1785
|
setSelectedItem();
|
1824
1786
|
return _context.abrupt("return", false);
|
1825
|
-
case
|
1787
|
+
case 23:
|
1826
1788
|
case "end":
|
1827
1789
|
return _context.stop();
|
1828
1790
|
}
|
@@ -1839,8 +1801,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1839
1801
|
return;
|
1840
1802
|
}
|
1841
1803
|
if ((_usingItem$value2 = usingItem.value) !== null && _usingItem$value2 !== void 0 && _usingItem$value2.values.length) {
|
1842
|
-
|
1843
|
-
|
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;
|
1844
1806
|
event.preventDefault();
|
1845
1807
|
var selection = window.getSelection();
|
1846
1808
|
if ((selection === null || selection === void 0 ? void 0 : selection.rangeCount) > 0) {
|
@@ -1869,89 +1831,78 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1869
1831
|
}
|
1870
1832
|
function _handleSelectItem() {
|
1871
1833
|
_handleSelectItem = _asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee2(item, type) {
|
1872
|
-
var _item$value, _usingItem$value6, _usingItem$
|
1873
|
-
var _item$
|
1834
|
+
var _item$value, _usingItem$value6, _usingItem$value9;
|
1835
|
+
var _item$realId, selectedItem, _usingItem$value7, _usingItem$value8, isCondition;
|
1874
1836
|
return regenerator_default().wrap(function _callee2$(_context2) {
|
1875
1837
|
while (1) switch (_context2.prev = _context2.next) {
|
1876
1838
|
case 0:
|
1877
1839
|
if (!((_item$value = item.value) !== null && _item$value !== void 0 && _item$value.id)) {
|
1878
|
-
_context2.next =
|
1879
|
-
break;
|
1880
|
-
}
|
1881
|
-
if (!(props.valueBehavior === ValueBehavior.NEEDKEY && item.value || !props.validateValues)) {
|
1882
|
-
_context2.next = 8;
|
1840
|
+
_context2.next = 18;
|
1883
1841
|
break;
|
1884
1842
|
}
|
1885
|
-
|
1843
|
+
selectedItem = new SelectedItem(_objectSpread(_objectSpread({}, item), {}, {
|
1886
1844
|
id: (_item$realId = item.realId) !== null && _item$realId !== void 0 ? _item$realId : item.id
|
1887
1845
|
}), type);
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1846
|
+
selectedItem.addValues(item.value.name, false);
|
1847
|
+
if (!(props.valueBehavior === ValueBehavior.NEEDKEY && menuHoverId.value)) {
|
1848
|
+
_context2.next = 8;
|
1849
|
+
break;
|
1892
1850
|
}
|
1851
|
+
setSelectedItem(selectedItem);
|
1852
|
+
setInputFocus(true);
|
1893
1853
|
menuHoverId.value = '';
|
1894
1854
|
return _context2.abrupt("return");
|
1895
1855
|
case 8:
|
1896
|
-
usingItem.value =
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
_context2.
|
1901
|
-
|
1902
|
-
return validateUsingItemValues(v);
|
1903
|
-
}));
|
1904
|
-
case 12:
|
1905
|
-
_res3 = _context2.sent;
|
1906
|
-
if (_res3) {
|
1907
|
-
_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;
|
1908
1862
|
break;
|
1909
1863
|
}
|
1910
1864
|
usingItem.value = null;
|
1911
1865
|
return _context2.abrupt("return");
|
1912
|
-
case
|
1866
|
+
case 14:
|
1913
1867
|
setSelectedItem(usingItem.value);
|
1914
|
-
menuHoverId.value = '';
|
1915
1868
|
setInputFocus(true);
|
1869
|
+
menuHoverId.value = '';
|
1916
1870
|
return _context2.abrupt("return");
|
1917
|
-
case
|
1918
|
-
if (usingItem.value) {
|
1919
|
-
_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;
|
1920
1874
|
break;
|
1921
1875
|
}
|
1922
|
-
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);
|
1923
1877
|
keyword.value = '';
|
1924
|
-
isCondition = type === 'condition';
|
1925
|
-
|
1878
|
+
isCondition = ((_usingItem$value8 = usingItem.value) === null || _usingItem$value8 === void 0 ? void 0 : _usingItem$value8.type) === 'condition';
|
1879
|
+
if (isCondition) {
|
1880
|
+
setSelectedItem();
|
1881
|
+
}
|
1926
1882
|
showPopover.value = isCondition || !!usingItem.value.children.length;
|
1927
1883
|
setInputFocus(props.valueBehavior === ValueBehavior.NEEDKEY && !!menuHoverId.value);
|
1928
1884
|
return _context2.abrupt("return");
|
1929
|
-
case
|
1930
|
-
if (
|
1931
|
-
|
1932
|
-
|
1885
|
+
case 26:
|
1886
|
+
if (usingItem.value) {
|
1887
|
+
usingItem.value.addValue(item);
|
1888
|
+
(0,external_vue_namespaceObject.nextTick)(deleteInputTextNode);
|
1933
1889
|
}
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
keyword.value = '';
|
1940
|
-
_context2.next = 36;
|
1941
|
-
return validateUsingItemValues(item);
|
1942
|
-
case 36:
|
1943
|
-
res = _context2.sent;
|
1944
|
-
if (res) {
|
1945
|
-
_context2.next = 39;
|
1890
|
+
_context2.next = 29;
|
1891
|
+
return validateUsingItemValues(usingItem.value.values);
|
1892
|
+
case 29:
|
1893
|
+
if (_context2.sent) {
|
1894
|
+
_context2.next = 31;
|
1946
1895
|
break;
|
1947
1896
|
}
|
1948
1897
|
return _context2.abrupt("return");
|
1949
|
-
case
|
1950
|
-
if (!usingItem.value.multiple)
|
1951
|
-
|
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) {
|
1952
1903
|
setInputFocus();
|
1953
1904
|
}
|
1954
|
-
case
|
1905
|
+
case 33:
|
1955
1906
|
case "end":
|
1956
1907
|
return _context2.stop();
|
1957
1908
|
}
|
@@ -1976,90 +1927,104 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
1976
1927
|
break;
|
1977
1928
|
}
|
1978
1929
|
}
|
1930
|
+
function handleLogicalChange(logical) {
|
1931
|
+
if (!usingItem.value) return;
|
1932
|
+
usingItem.value.logical = logical;
|
1933
|
+
}
|
1979
1934
|
// functions
|
1980
|
-
function
|
1981
|
-
return
|
1935
|
+
function validateValues(_x4, _x5) {
|
1936
|
+
return _validateValues.apply(this, arguments);
|
1982
1937
|
}
|
1983
|
-
function
|
1984
|
-
|
1985
|
-
var
|
1938
|
+
function _validateValues() {
|
1939
|
+
_validateValues = _asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee3(searchItem, value) {
|
1940
|
+
var validateStr;
|
1986
1941
|
return regenerator_default().wrap(function _callee3$(_context3) {
|
1987
1942
|
while (1) switch (_context3.prev = _context3.next) {
|
1988
1943
|
case 0:
|
1989
|
-
if (
|
1990
|
-
_context3.next =
|
1944
|
+
if (!(typeof props.validateValues === 'function')) {
|
1945
|
+
_context3.next = 14;
|
1991
1946
|
break;
|
1992
1947
|
}
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
1996
|
-
return
|
1997
|
-
case
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
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;
|
2001
1963
|
break;
|
2002
1964
|
}
|
2003
|
-
|
2004
|
-
return
|
2005
|
-
case
|
2006
|
-
return _context3.abrupt("return", _context3.sent);
|
2007
|
-
case 9:
|
1965
|
+
onValidate(validateStr || '校验错误');
|
1966
|
+
return _context3.abrupt("return", false);
|
1967
|
+
case 14:
|
2008
1968
|
onValidate('');
|
2009
1969
|
return _context3.abrupt("return", true);
|
2010
|
-
case
|
1970
|
+
case 16:
|
2011
1971
|
case "end":
|
2012
1972
|
return _context3.stop();
|
2013
1973
|
}
|
2014
|
-
}, _callee3);
|
1974
|
+
}, _callee3, null, [[2, 8]]);
|
2015
1975
|
}));
|
2016
|
-
return _validateUsingItemValues.apply(this, arguments);
|
2017
|
-
}
|
2018
|
-
function validateValues(_x5, _x6) {
|
2019
1976
|
return _validateValues.apply(this, arguments);
|
2020
1977
|
}
|
2021
|
-
function
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
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;
|
2025
1984
|
return regenerator_default().wrap(function _callee4$(_context4) {
|
2026
1985
|
while (1) switch (_context4.prev = _context4.next) {
|
2027
1986
|
case 0:
|
2028
|
-
|
2029
|
-
|
2030
|
-
return false;
|
2031
|
-
});
|
2032
|
-
case 2:
|
2033
|
-
validateStr = _context4.sent;
|
2034
|
-
if (!(typeof validateStr === 'string' || validateStr === false)) {
|
2035
|
-
_context4.next = 6;
|
1987
|
+
if (usingItem.value) {
|
1988
|
+
_context4.next = 4;
|
2036
1989
|
break;
|
2037
1990
|
}
|
2038
|
-
|
2039
|
-
return
|
2040
|
-
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:
|
2041
2006
|
onValidate('');
|
2042
2007
|
return _context4.abrupt("return", true);
|
2043
|
-
case
|
2008
|
+
case 11:
|
2044
2009
|
case "end":
|
2045
2010
|
return _context4.stop();
|
2046
2011
|
}
|
2047
2012
|
}, _callee4);
|
2048
2013
|
}));
|
2049
|
-
return
|
2014
|
+
return _validateUsingItemValues.apply(this, arguments);
|
2050
2015
|
}
|
2051
2016
|
function setMenuList() {
|
2052
2017
|
return _setMenuList.apply(this, arguments);
|
2053
2018
|
}
|
2054
2019
|
function _setMenuList() {
|
2055
2020
|
_setMenuList = _asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee5() {
|
2056
|
-
var _usingItem$
|
2021
|
+
var _props$data, _usingItem$value$sear, _usingItem$value$valu;
|
2057
2022
|
var list, _usingItem$value11, _keyword$value2, hoverItem;
|
2058
2023
|
return regenerator_default().wrap(function _callee5$(_context5) {
|
2059
2024
|
while (1) switch (_context5.prev = _context5.next) {
|
2060
2025
|
case 0:
|
2061
2026
|
list = [];
|
2062
|
-
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)))) {
|
2063
2028
|
_context5.next = 9;
|
2064
2029
|
break;
|
2065
2030
|
}
|
@@ -2151,6 +2116,89 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
2151
2116
|
}));
|
2152
2117
|
return _setMenuList.apply(this, arguments);
|
2153
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
|
+
}
|
2154
2202
|
function setCursorToEnd() {
|
2155
2203
|
if (!inputRef.value) return;
|
2156
2204
|
var range = document.createRange();
|
@@ -2181,11 +2229,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
2181
2229
|
}
|
2182
2230
|
function clearInput() {
|
2183
2231
|
if (!inputRef.value) return;
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
usingItem.value.logical = logical;
|
2232
|
+
keyword.value = '';
|
2233
|
+
(0,external_vue_namespaceObject.nextTick)(function () {
|
2234
|
+
return inputRef.value.innerText = '';
|
2235
|
+
});
|
2189
2236
|
}
|
2190
2237
|
function str2SeletedItem(str) {
|
2191
2238
|
var _str$split = str.split(':'),
|
@@ -2204,19 +2251,58 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
2204
2251
|
}
|
2205
2252
|
return undefined;
|
2206
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
|
+
}
|
2207
2267
|
function inputFocusForWrapper() {
|
2208
2268
|
var _inputRef$value2;
|
2209
2269
|
(_inputRef$value2 = inputRef.value) === null || _inputRef$value2 === void 0 || _inputRef$value2.focus();
|
2210
2270
|
}
|
2211
2271
|
function inputEnterForWrapper() {
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
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);
|
2293
|
+
}
|
2294
|
+
function inputClearForWrapper() {
|
2295
|
+
keyword.value = '';
|
2296
|
+
showNoSelectValueError.value = false;
|
2297
|
+
showPopover.value = false;
|
2298
|
+
usingItem.value = null;
|
2299
|
+
(0,external_vue_namespaceObject.nextTick)(clearInput);
|
2215
2300
|
}
|
2216
2301
|
// expose
|
2217
2302
|
expose({
|
2218
2303
|
inputFocusForWrapper: inputFocusForWrapper,
|
2219
2304
|
inputEnterForWrapper: inputEnterForWrapper,
|
2305
|
+
inputClearForWrapper: inputClearForWrapper,
|
2220
2306
|
handleInputFocus: handleInputFocus,
|
2221
2307
|
isFocus: isFocus
|
2222
2308
|
});
|
@@ -2246,6 +2332,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
2246
2332
|
resolveClassName: resolveClassName,
|
2247
2333
|
inputFocusForWrapper: inputFocusForWrapper,
|
2248
2334
|
inputEnterForWrapper: inputEnterForWrapper,
|
2335
|
+
inputClearForWrapper: inputClearForWrapper,
|
2336
|
+
deleteInputTextNode: deleteInputTextNode,
|
2249
2337
|
t: t
|
2250
2338
|
};
|
2251
2339
|
},
|
@@ -2592,6 +2680,13 @@ var SearchSelectProps = {
|
|
2592
2680
|
return [ValueBehavior.ALL, ValueBehavior.NEEDKEY].includes(v);
|
2593
2681
|
}
|
2594
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
|
+
// },
|
2595
2690
|
};
|
2596
2691
|
/* harmony default export */ const search_select = ((0,external_vue_namespaceObject.defineComponent)({
|
2597
2692
|
name: 'SearchSelect',
|
@@ -2769,6 +2864,7 @@ var SearchSelectProps = {
|
|
2769
2864
|
function handleClearAll() {
|
2770
2865
|
selectedList.value = [];
|
2771
2866
|
overflowIndex.value = -1;
|
2867
|
+
inputRef.value.inputClearForWrapper();
|
2772
2868
|
emit('update:modelValue', []);
|
2773
2869
|
}
|
2774
2870
|
function handleInputOutside(target) {
|