funda-ui 4.7.275 → 4.7.335
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/LiveSearch/index.d.ts +0 -1
- package/LiveSearch/index.js +25 -4
- package/Select/index.css +5 -0
- package/Select/index.js +87 -53
- package/lib/cjs/LiveSearch/index.d.ts +0 -1
- package/lib/cjs/LiveSearch/index.js +25 -4
- package/lib/cjs/Select/index.js +87 -53
- package/lib/css/Select/index.css +5 -0
- package/lib/esm/LiveSearch/index.tsx +26 -6
- package/lib/esm/SearchBar/index.tsx +0 -2
- package/lib/esm/Select/index.scss +8 -0
- package/lib/esm/Select/index.tsx +67 -51
- package/package.json +1 -1
package/LiveSearch/index.d.ts
CHANGED
package/LiveSearch/index.js
CHANGED
|
@@ -2802,7 +2802,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2802
2802
|
/* harmony import */ var funda_utils_dist_cjs_getElementProperty__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_getElementProperty__WEBPACK_IMPORTED_MODULE_8__);
|
|
2803
2803
|
/* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(188);
|
|
2804
2804
|
/* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_9__);
|
|
2805
|
-
var _excluded = ["contentRef", "popupRef", "wrapperClassName", "controlClassName", "controlExClassName", "optionsExClassName", "controlGroupWrapperClassName", "controlGroupTextClassName", "exceededSidePosOffset", "appearance", "isSearchInput", "
|
|
2805
|
+
var _excluded = ["contentRef", "popupRef", "wrapperClassName", "controlClassName", "controlExClassName", "optionsExClassName", "controlGroupWrapperClassName", "controlGroupTextClassName", "exceededSidePosOffset", "appearance", "isSearchInput", "loader", "readOnly", "disabled", "required", "placeholder", "noMatchPopup", "options", "value", "label", "name", "units", "iconLeft", "iconRight", "minLength", "maxLength", "id", "autoComplete", "autoCapitalize", "spellCheck", "icon", "btnId", "fetchTrigger", "hideIcon", "renderOption", "depth", "style", "winWidth", "tabIndex", "data", "autoShowOptions", "fetchNoneInfo", "fetchUpdate", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "fetchCallback", "onClick", "onFetch", "onChange", "onKeyboardInput", "onBlur", "onPressEnter"];
|
|
2806
2806
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2807
2807
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
2808
2808
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -2842,7 +2842,6 @@ var LiveSearch = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(
|
|
|
2842
2842
|
exceededSidePosOffset = props.exceededSidePosOffset,
|
|
2843
2843
|
appearance = props.appearance,
|
|
2844
2844
|
isSearchInput = props.isSearchInput,
|
|
2845
|
-
allowSpacingRetrive = props.allowSpacingRetrive,
|
|
2846
2845
|
loader = props.loader,
|
|
2847
2846
|
readOnly = props.readOnly,
|
|
2848
2847
|
disabled = props.disabled,
|
|
@@ -3002,6 +3001,11 @@ var LiveSearch = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(
|
|
|
3002
3001
|
}
|
|
3003
3002
|
}, [isOpen, rootRef, listRef]);
|
|
3004
3003
|
|
|
3004
|
+
// Only single symbols such as , #, and @ are allowed, and , a, a, , etc. are not allowed.
|
|
3005
|
+
var isSingleSpecialChar = function isSingleSpecialChar(str) {
|
|
3006
|
+
return typeof str === 'string' && /^[^\w\s]$/.test(str);
|
|
3007
|
+
};
|
|
3008
|
+
|
|
3005
3009
|
// Add function to the element that should be used as the scrollable area.
|
|
3006
3010
|
var _useWindowScroll = funda_utils_dist_cjs_useWindowScroll__WEBPACK_IMPORTED_MODULE_5___default()({
|
|
3007
3011
|
performance: ['debounce', 500],
|
|
@@ -3173,12 +3177,29 @@ var LiveSearch = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(
|
|
|
3173
3177
|
// Avoid fatal errors causing page crashes
|
|
3174
3178
|
var _queryString = typeof item.queryString !== 'undefined' && item.queryString !== null ? item.queryString : '';
|
|
3175
3179
|
var _val = typeof val !== 'undefined' && val !== null ? val : '';
|
|
3176
|
-
|
|
3180
|
+
|
|
3181
|
+
// STEP 1
|
|
3182
|
+
//========
|
|
3183
|
+
if (emptyValShowAll && _val === '') {
|
|
3177
3184
|
return true;
|
|
3178
3185
|
}
|
|
3179
|
-
|
|
3186
|
+
|
|
3187
|
+
// STEP 2
|
|
3188
|
+
//========
|
|
3189
|
+
// @@@ This code is triggered only if a custom request is used to update "options" @@@
|
|
3190
|
+
if (query && _val == ' ') {
|
|
3180
3191
|
return true;
|
|
3181
3192
|
}
|
|
3193
|
+
|
|
3194
|
+
// STEP 3
|
|
3195
|
+
//========
|
|
3196
|
+
// @@@ This code is triggered only if a custom request is used to update "options" @@@
|
|
3197
|
+
if (query && _val != '' && isSingleSpecialChar(_val)) {
|
|
3198
|
+
return true;
|
|
3199
|
+
}
|
|
3200
|
+
|
|
3201
|
+
// STEP 4
|
|
3202
|
+
//========
|
|
3182
3203
|
if ((_queryString.split(',').some(function (l) {
|
|
3183
3204
|
return l.charAt(0) === _val.toLowerCase();
|
|
3184
3205
|
}) || _queryString.split(',').some(function (l) {
|
package/Select/index.css
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
--cus-sel-searchbtn-hover-fill: #333;
|
|
17
17
|
--cus-sel-removebtn-fill: #000;
|
|
18
18
|
--cus-sel-removebtn-hover-fill: #f00;
|
|
19
|
+
--cus-sel-selected-color:#b1d0ff;
|
|
19
20
|
position: relative; /* Required */
|
|
20
21
|
/*------ Placeholder for input ------*/
|
|
21
22
|
/*------ Arrow ------*/
|
|
@@ -85,11 +86,15 @@
|
|
|
85
86
|
display: inline-block;
|
|
86
87
|
color: var(--cus-sel-placeholder-color);
|
|
87
88
|
width: 100%;
|
|
89
|
+
/* Select all highlights (for "Single selection") */
|
|
88
90
|
/* Text preview */
|
|
89
91
|
}
|
|
90
92
|
.custom-select__wrapper .custom-select-multi__control-blinking-cursor.animated {
|
|
91
93
|
animation: 1s mf-sel-blink step-end infinite;
|
|
92
94
|
}
|
|
95
|
+
.custom-select__wrapper .custom-select-multi__control-blinking-cursor.selected > span {
|
|
96
|
+
background-color: var(--cus-sel-selected-color);
|
|
97
|
+
}
|
|
93
98
|
.custom-select__wrapper .custom-select-multi__control-blinking-cursor.control-placeholder {
|
|
94
99
|
color: var(--cus-sel-input-placeholder-color);
|
|
95
100
|
}
|
package/Select/index.js
CHANGED
|
@@ -3771,6 +3771,12 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3771
3771
|
setBlinkingPosStart = _useState24[1];
|
|
3772
3772
|
var blinkingPosFauxRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
|
|
3773
3773
|
var blinkingCursorPosDivRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
|
|
3774
|
+
|
|
3775
|
+
// Select All status (for "Single selection")
|
|
3776
|
+
var _useState25 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
|
|
3777
|
+
_useState26 = _slicedToArray(_useState25, 2),
|
|
3778
|
+
userInputboxIsAllSelected = _useState26[0],
|
|
3779
|
+
setUserInputboxIsAllSelected = _useState26[1];
|
|
3774
3780
|
var selectedSign = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);
|
|
3775
3781
|
var MULTI_SEL_VALID = multiSelect ? multiSelect.valid : false;
|
|
3776
3782
|
var MULTI_SEL_ENTIRE_AREA_TRIGGER = typeof multiSelectEntireAreaTrigger === 'undefined' ? true : multiSelectEntireAreaTrigger;
|
|
@@ -3781,16 +3787,21 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3781
3787
|
allItemsLabel: 'All Content ({num})',
|
|
3782
3788
|
noneLabel: 'No items selected'
|
|
3783
3789
|
};
|
|
3784
|
-
var
|
|
3790
|
+
var _useState27 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({
|
|
3785
3791
|
labels: [],
|
|
3786
3792
|
values: []
|
|
3787
3793
|
}),
|
|
3788
|
-
|
|
3789
|
-
controlArr =
|
|
3790
|
-
setControlArr =
|
|
3791
|
-
|
|
3794
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
|
3795
|
+
controlArr = _useState28[0],
|
|
3796
|
+
setControlArr = _useState28[1];
|
|
3797
|
+
|
|
3798
|
+
// Only single symbols such as , #, and @ are allowed, and , a, a, , etc. are not allowed.
|
|
3799
|
+
var isSingleSpecialChar = function isSingleSpecialChar(str) {
|
|
3800
|
+
return typeof str === 'string' && /^[^\w\s]$/.test(str);
|
|
3801
|
+
};
|
|
3802
|
+
var chkValueExist = function chkValueExist(v) {
|
|
3792
3803
|
return typeof v !== 'undefined' && v !== '';
|
|
3793
|
-
}
|
|
3804
|
+
};
|
|
3794
3805
|
var listContainerHeightLimit = function listContainerHeightLimit(num) {
|
|
3795
3806
|
var res = num;
|
|
3796
3807
|
if (res > LIST_CONTAINER_MAX_HEIGHT) res = LIST_CONTAINER_MAX_HEIGHT;
|
|
@@ -3835,19 +3846,22 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3835
3846
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(contentRef, function () {
|
|
3836
3847
|
return {
|
|
3837
3848
|
active: function active() {
|
|
3849
|
+
var _selectInputRef$curre;
|
|
3838
3850
|
handleShowList();
|
|
3839
|
-
selectInputRef.current.select();
|
|
3851
|
+
(_selectInputRef$curre = selectInputRef.current) === null || _selectInputRef$curre === void 0 ? void 0 : _selectInputRef$curre.select();
|
|
3840
3852
|
},
|
|
3841
3853
|
focus: function focus() {
|
|
3842
|
-
|
|
3854
|
+
var _selectInputRef$curre2;
|
|
3855
|
+
(_selectInputRef$curre2 = selectInputRef.current) === null || _selectInputRef$curre2 === void 0 ? void 0 : _selectInputRef$curre2.select();
|
|
3843
3856
|
},
|
|
3844
3857
|
clear: function clear(cb) {
|
|
3858
|
+
var _selectInputRef$curre3;
|
|
3845
3859
|
if (MULTI_SEL_VALID) {
|
|
3846
3860
|
updateOptionCheckboxes('remove');
|
|
3847
3861
|
} else {
|
|
3848
3862
|
handleClearValue();
|
|
3849
3863
|
}
|
|
3850
|
-
selectInputRef.current.blur();
|
|
3864
|
+
(_selectInputRef$curre3 = selectInputRef.current) === null || _selectInputRef$curre3 === void 0 ? void 0 : _selectInputRef$curre3.blur();
|
|
3851
3865
|
cb === null || cb === void 0 ? void 0 : cb();
|
|
3852
3866
|
},
|
|
3853
3867
|
/*
|
|
@@ -3870,7 +3884,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3870
3884
|
cb === null || cb === void 0 ? void 0 : cb();
|
|
3871
3885
|
}
|
|
3872
3886
|
};
|
|
3873
|
-
}, [contentRef]);
|
|
3887
|
+
}, [contentRef, selectInputRef]);
|
|
3874
3888
|
|
|
3875
3889
|
// click outside
|
|
3876
3890
|
useClickOutside_default()({
|
|
@@ -3929,35 +3943,12 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3929
3943
|
|
|
3930
3944
|
//performance
|
|
3931
3945
|
var handleChangeFetchSafe = useDebounce_default()(function (val) {
|
|
3932
|
-
var _orginalData = [];
|
|
3933
|
-
var update = function update(inputData) {
|
|
3934
|
-
var filterRes = function filterRes() {
|
|
3935
|
-
return inputData.filter(function (item) {
|
|
3936
|
-
// Avoid fatal errors causing page crashes
|
|
3937
|
-
var _queryString = typeof item.queryString !== 'undefined' && item.queryString !== null ? item.queryString : '';
|
|
3938
|
-
var _val = typeof val !== 'undefined' && val !== null ? val : '';
|
|
3939
|
-
if ((_queryString.split(',').some(function (l) {
|
|
3940
|
-
return l.charAt(0) === _val.toLowerCase();
|
|
3941
|
-
}) || _queryString.split(',').some(function (l) {
|
|
3942
|
-
return l.replace(/ /g, '').indexOf(_val.toLowerCase()) >= 0;
|
|
3943
|
-
}) || item.label.toLowerCase().indexOf(_val.toLowerCase()) >= 0) && _val != '') {
|
|
3944
|
-
return true;
|
|
3945
|
-
} else {
|
|
3946
|
-
return false;
|
|
3947
|
-
}
|
|
3948
|
-
});
|
|
3949
|
-
};
|
|
3950
|
-
return filterRes();
|
|
3951
|
-
};
|
|
3952
3946
|
if (fetchUpdate) {
|
|
3953
3947
|
// update filter status
|
|
3954
3948
|
setFilterItemsHasNoMatchData(false);
|
|
3955
3949
|
|
|
3956
3950
|
// Make a request
|
|
3957
3951
|
handleFetch(val).then(function (response) {
|
|
3958
|
-
_orginalData = response;
|
|
3959
|
-
var _filterRes = update(_orginalData);
|
|
3960
|
-
|
|
3961
3952
|
// pop win initalization
|
|
3962
3953
|
setTimeout(function () {
|
|
3963
3954
|
popwinPosInit();
|
|
@@ -3965,9 +3956,6 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3965
3956
|
}, 0);
|
|
3966
3957
|
});
|
|
3967
3958
|
} else {
|
|
3968
|
-
_orginalData = orginalData;
|
|
3969
|
-
var _filterRes = update(_orginalData);
|
|
3970
|
-
|
|
3971
3959
|
// pop win initalization
|
|
3972
3960
|
setTimeout(function () {
|
|
3973
3961
|
popwinPosInit();
|
|
@@ -3990,7 +3978,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3990
3978
|
_currentData,
|
|
3991
3979
|
_defaultValues,
|
|
3992
3980
|
_defaultLabels,
|
|
3993
|
-
|
|
3981
|
+
_filterRes,
|
|
3994
3982
|
_filterResQueryValue,
|
|
3995
3983
|
_filterResQueryLabel,
|
|
3996
3984
|
_currentData2,
|
|
@@ -4132,19 +4120,19 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4132
4120
|
|
|
4133
4121
|
// STEP 3: ===========
|
|
4134
4122
|
// If the default value is label, match value
|
|
4135
|
-
|
|
4123
|
+
_filterRes = [];
|
|
4136
4124
|
_filterResQueryValue = staticOptionsData.filter(function (item) {
|
|
4137
4125
|
return item.value == defaultValue;
|
|
4138
4126
|
});
|
|
4139
4127
|
_filterResQueryLabel = staticOptionsData.filter(function (item) {
|
|
4140
4128
|
return item.label == defaultValue;
|
|
4141
4129
|
});
|
|
4142
|
-
|
|
4143
|
-
if (_filterResQueryValue.length === 0)
|
|
4130
|
+
_filterRes = _filterResQueryValue;
|
|
4131
|
+
if (_filterResQueryValue.length === 0) _filterRes = _filterResQueryLabel;
|
|
4144
4132
|
|
|
4145
4133
|
// if the default value is Object
|
|
4146
|
-
if (isObject(inputDefault) &&
|
|
4147
|
-
|
|
4134
|
+
if (isObject(inputDefault) && _filterRes.length === 0) {
|
|
4135
|
+
_filterRes = [inputDefault];
|
|
4148
4136
|
}
|
|
4149
4137
|
|
|
4150
4138
|
// STEP 4: ===========
|
|
@@ -4156,9 +4144,9 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4156
4144
|
setControlValue('');
|
|
4157
4145
|
setControlLabel('');
|
|
4158
4146
|
} else {
|
|
4159
|
-
if (
|
|
4160
|
-
setControlValue(
|
|
4161
|
-
setControlLabel(formatIndentVal(
|
|
4147
|
+
if (_filterRes.length > 0) {
|
|
4148
|
+
setControlValue(_filterRes[0].value);
|
|
4149
|
+
setControlLabel(formatIndentVal(_filterRes[0].label, INDENT_LAST_PLACEHOLDER));
|
|
4162
4150
|
}
|
|
4163
4151
|
}
|
|
4164
4152
|
|
|
@@ -4426,6 +4414,25 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4426
4414
|
// Avoid fatal errors causing page crashes
|
|
4427
4415
|
var _queryString = typeof node.dataset.querystring !== 'undefined' && node.dataset.querystring !== null ? node.dataset.querystring : '';
|
|
4428
4416
|
var _val = typeof val !== 'undefined' && val !== null ? val : '';
|
|
4417
|
+
|
|
4418
|
+
// STEP 1
|
|
4419
|
+
//========
|
|
4420
|
+
// @@@ This code is triggered only if a custom request is used to update "options" @@@
|
|
4421
|
+
// If the condition is true, skip the loop and move on to the next node.
|
|
4422
|
+
if (fetchUpdate && _val == ' ') {
|
|
4423
|
+
return;
|
|
4424
|
+
}
|
|
4425
|
+
|
|
4426
|
+
// STEP 2
|
|
4427
|
+
//========
|
|
4428
|
+
// @@@ This code is triggered only if a custom request is used to update "options" @@@
|
|
4429
|
+
// If the condition is true, skip the loop and move on to the next node.
|
|
4430
|
+
if (fetchUpdate && _val != '' && isSingleSpecialChar(_val)) {
|
|
4431
|
+
return;
|
|
4432
|
+
}
|
|
4433
|
+
|
|
4434
|
+
// STEP 3
|
|
4435
|
+
//========
|
|
4429
4436
|
if ((_queryString.split(',').some(function (l) {
|
|
4430
4437
|
return l.charAt(0) === _val.toLowerCase();
|
|
4431
4438
|
}) || _queryString.split(',').some(function (l) {
|
|
@@ -4523,6 +4530,9 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4523
4530
|
// update filter status
|
|
4524
4531
|
setFilterItemsHasNoMatchData(false);
|
|
4525
4532
|
|
|
4533
|
+
// reset Select All status (for "Single selection")
|
|
4534
|
+
setUserInputboxIsAllSelected(false);
|
|
4535
|
+
|
|
4526
4536
|
// Unlocks the page
|
|
4527
4537
|
if (LOCK_BODY_SCROLL) (0,bodyScrollLock.enableBodyScroll)(document.querySelector('body'));
|
|
4528
4538
|
}
|
|
@@ -4621,6 +4631,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4621
4631
|
$el,
|
|
4622
4632
|
_selected,
|
|
4623
4633
|
_selectedVal,
|
|
4634
|
+
_selectInputRef$curre4,
|
|
4624
4635
|
_curItem$callback,
|
|
4625
4636
|
_value2,
|
|
4626
4637
|
_label2,
|
|
@@ -4629,6 +4640,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4629
4640
|
_$el,
|
|
4630
4641
|
_selected2,
|
|
4631
4642
|
_selectedVal2,
|
|
4643
|
+
_selectInputRef$curre5,
|
|
4632
4644
|
_args3 = arguments;
|
|
4633
4645
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
4634
4646
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -4769,7 +4781,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4769
4781
|
return onChange === null || onChange === void 0 ? void 0 : onChange(selectInputRef.current, valueInputRef.current, !MULTI_SEL_VALID ? curItem : multipleSelectionCallback(currentControlValueArr, currentControlLabelArr));
|
|
4770
4782
|
case 25:
|
|
4771
4783
|
//
|
|
4772
|
-
selectInputRef.current.blur();
|
|
4784
|
+
(_selectInputRef$curre4 = selectInputRef.current) === null || _selectInputRef$curre4 === void 0 ? void 0 : _selectInputRef$curre4.blur();
|
|
4773
4785
|
case 26:
|
|
4774
4786
|
_context3.next = 42;
|
|
4775
4787
|
break;
|
|
@@ -4877,7 +4889,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4877
4889
|
return onChange === null || onChange === void 0 ? void 0 : onChange(selectInputRef.current, valueInputRef.current, !MULTI_SEL_VALID ? curItem : multipleSelectionCallback(_currentControlValueArr, _currentControlLabelArr));
|
|
4878
4890
|
case 41:
|
|
4879
4891
|
//
|
|
4880
|
-
selectInputRef.current.blur();
|
|
4892
|
+
(_selectInputRef$curre5 = selectInputRef.current) === null || _selectInputRef$curre5 === void 0 ? void 0 : _selectInputRef$curre5.blur();
|
|
4881
4893
|
case 42:
|
|
4882
4894
|
// Fixed an out-of-focus issue
|
|
4883
4895
|
fixFocusStatus();
|
|
@@ -5013,7 +5025,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5013
5025
|
}
|
|
5014
5026
|
function _handleMultiControlItemRemove() {
|
|
5015
5027
|
_handleMultiControlItemRemove = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(event) {
|
|
5016
|
-
var valueToRemove, getCurrentIndex, currentControlValueArr, currentControlLabelArr, _value, _label;
|
|
5028
|
+
var valueToRemove, getCurrentIndex, currentControlValueArr, currentControlLabelArr, _value, _label, _selectInputRef$curre6;
|
|
5017
5029
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
5018
5030
|
while (1) switch (_context5.prev = _context5.next) {
|
|
5019
5031
|
case 0:
|
|
@@ -5050,7 +5062,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5050
5062
|
return onChange === null || onChange === void 0 ? void 0 : onChange(selectInputRef.current, valueInputRef.current, multipleSelectionCallback(currentControlValueArr, currentControlLabelArr));
|
|
5051
5063
|
case 15:
|
|
5052
5064
|
//
|
|
5053
|
-
selectInputRef.current.blur();
|
|
5065
|
+
(_selectInputRef$curre6 = selectInputRef.current) === null || _selectInputRef$curre6 === void 0 ? void 0 : _selectInputRef$curre6.blur();
|
|
5054
5066
|
case 16:
|
|
5055
5067
|
case "end":
|
|
5056
5068
|
return _context5.stop();
|
|
@@ -5239,7 +5251,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5239
5251
|
}
|
|
5240
5252
|
function _handleKeyPressed() {
|
|
5241
5253
|
_handleKeyPressed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(event) {
|
|
5242
|
-
var key, res, currentIndex, currentData, currentControlValueArr, currentControlLabelArr, htmlOptions;
|
|
5254
|
+
var key, res, currentIndex, currentData, currentControlValueArr, currentControlLabelArr, htmlOptions, _selectInputRef$curre7;
|
|
5243
5255
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
5244
5256
|
while (1) switch (_context8.prev = _context8.next) {
|
|
5245
5257
|
case 0:
|
|
@@ -5307,7 +5319,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5307
5319
|
return onChange === null || onChange === void 0 ? void 0 : onChange(selectInputRef.current, valueInputRef.current, !MULTI_SEL_VALID ? currentData : multipleSelectionCallback(currentControlValueArr, currentControlLabelArr));
|
|
5308
5320
|
case 25:
|
|
5309
5321
|
//
|
|
5310
|
-
selectInputRef.current.blur();
|
|
5322
|
+
(_selectInputRef$curre7 = selectInputRef.current) === null || _selectInputRef$curre7 === void 0 ? void 0 : _selectInputRef$curre7.blur();
|
|
5311
5323
|
case 26:
|
|
5312
5324
|
if (!(key === 'ArrowUp')) {
|
|
5313
5325
|
_context8.next = 30;
|
|
@@ -5498,6 +5510,15 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5498
5510
|
};
|
|
5499
5511
|
}, [orginalData]); // Avoid the issue that `setOptionsData(orginalData)` sets the original value to empty on the first entry
|
|
5500
5512
|
|
|
5513
|
+
// Select all detection functions in the input box (for "Single selection")
|
|
5514
|
+
function checkUserInputboxIsAllSelected(e) {
|
|
5515
|
+
var input = e.target;
|
|
5516
|
+
if (input && typeof input.selectionStart === 'number' && typeof input.selectionEnd === 'number') {
|
|
5517
|
+
setUserInputboxIsAllSelected(input.selectionStart === 0 && input.selectionEnd === input.value.length && input.value.length > 0);
|
|
5518
|
+
} else {
|
|
5519
|
+
setUserInputboxIsAllSelected(false);
|
|
5520
|
+
}
|
|
5521
|
+
}
|
|
5501
5522
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, label ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
5502
5523
|
className: "custom-select__label"
|
|
5503
5524
|
}, typeof label === 'string' ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("label", {
|
|
@@ -5612,7 +5633,18 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5612
5633
|
autoComplete: typeof autoComplete === 'undefined' ? 'off' : autoComplete,
|
|
5613
5634
|
autoCapitalize: typeof autoCapitalize === 'undefined' ? 'off' : autoCapitalize,
|
|
5614
5635
|
spellCheck: typeof spellCheck === 'undefined' ? false : spellCheck
|
|
5615
|
-
}, attributes
|
|
5636
|
+
}, attributes, {
|
|
5637
|
+
// Select all detection (for "Single selection")
|
|
5638
|
+
onSelect: function onSelect(e) {
|
|
5639
|
+
checkUserInputboxIsAllSelected(e);
|
|
5640
|
+
},
|
|
5641
|
+
onKeyUp: function onKeyUp(e) {
|
|
5642
|
+
checkUserInputboxIsAllSelected(e);
|
|
5643
|
+
},
|
|
5644
|
+
onMouseUp: function onMouseUp(e) {
|
|
5645
|
+
checkUserInputboxIsAllSelected(e);
|
|
5646
|
+
}
|
|
5647
|
+
})))) : null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("input", _extends({
|
|
5616
5648
|
ref: valueInputRef,
|
|
5617
5649
|
tabIndex: -1,
|
|
5618
5650
|
type: "hidden",
|
|
@@ -5642,7 +5674,9 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5642
5674
|
}), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
5643
5675
|
ref: blinkingCursorPosDivRef,
|
|
5644
5676
|
className: (0,cls.combinedCls)('custom-select-multi__control-blinking-cursor', {
|
|
5645
|
-
'animated': generateInputFocusStr() === BLINKING_CURSOR_STR
|
|
5677
|
+
'animated': generateInputFocusStr() === BLINKING_CURSOR_STR,
|
|
5678
|
+
// Select all highlights (for "Single selection")
|
|
5679
|
+
'selected': userInputboxIsAllSelected
|
|
5646
5680
|
})
|
|
5647
5681
|
}, controlTempValue || controlTempValue === '' ? controlTempValue.length === 0 ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
5648
5682
|
className: "".concat(!hideBlinkingCursor() ? 'control-placeholder' : '')
|
|
@@ -2802,7 +2802,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2802
2802
|
/* harmony import */ var funda_utils_dist_cjs_getElementProperty__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_getElementProperty__WEBPACK_IMPORTED_MODULE_8__);
|
|
2803
2803
|
/* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(188);
|
|
2804
2804
|
/* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_9__);
|
|
2805
|
-
var _excluded = ["contentRef", "popupRef", "wrapperClassName", "controlClassName", "controlExClassName", "optionsExClassName", "controlGroupWrapperClassName", "controlGroupTextClassName", "exceededSidePosOffset", "appearance", "isSearchInput", "
|
|
2805
|
+
var _excluded = ["contentRef", "popupRef", "wrapperClassName", "controlClassName", "controlExClassName", "optionsExClassName", "controlGroupWrapperClassName", "controlGroupTextClassName", "exceededSidePosOffset", "appearance", "isSearchInput", "loader", "readOnly", "disabled", "required", "placeholder", "noMatchPopup", "options", "value", "label", "name", "units", "iconLeft", "iconRight", "minLength", "maxLength", "id", "autoComplete", "autoCapitalize", "spellCheck", "icon", "btnId", "fetchTrigger", "hideIcon", "renderOption", "depth", "style", "winWidth", "tabIndex", "data", "autoShowOptions", "fetchNoneInfo", "fetchUpdate", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "fetchCallback", "onClick", "onFetch", "onChange", "onKeyboardInput", "onBlur", "onPressEnter"];
|
|
2806
2806
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2807
2807
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
2808
2808
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -2842,7 +2842,6 @@ var LiveSearch = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(
|
|
|
2842
2842
|
exceededSidePosOffset = props.exceededSidePosOffset,
|
|
2843
2843
|
appearance = props.appearance,
|
|
2844
2844
|
isSearchInput = props.isSearchInput,
|
|
2845
|
-
allowSpacingRetrive = props.allowSpacingRetrive,
|
|
2846
2845
|
loader = props.loader,
|
|
2847
2846
|
readOnly = props.readOnly,
|
|
2848
2847
|
disabled = props.disabled,
|
|
@@ -3002,6 +3001,11 @@ var LiveSearch = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(
|
|
|
3002
3001
|
}
|
|
3003
3002
|
}, [isOpen, rootRef, listRef]);
|
|
3004
3003
|
|
|
3004
|
+
// Only single symbols such as , #, and @ are allowed, and , a, a, , etc. are not allowed.
|
|
3005
|
+
var isSingleSpecialChar = function isSingleSpecialChar(str) {
|
|
3006
|
+
return typeof str === 'string' && /^[^\w\s]$/.test(str);
|
|
3007
|
+
};
|
|
3008
|
+
|
|
3005
3009
|
// Add function to the element that should be used as the scrollable area.
|
|
3006
3010
|
var _useWindowScroll = funda_utils_dist_cjs_useWindowScroll__WEBPACK_IMPORTED_MODULE_5___default()({
|
|
3007
3011
|
performance: ['debounce', 500],
|
|
@@ -3173,12 +3177,29 @@ var LiveSearch = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(
|
|
|
3173
3177
|
// Avoid fatal errors causing page crashes
|
|
3174
3178
|
var _queryString = typeof item.queryString !== 'undefined' && item.queryString !== null ? item.queryString : '';
|
|
3175
3179
|
var _val = typeof val !== 'undefined' && val !== null ? val : '';
|
|
3176
|
-
|
|
3180
|
+
|
|
3181
|
+
// STEP 1
|
|
3182
|
+
//========
|
|
3183
|
+
if (emptyValShowAll && _val === '') {
|
|
3177
3184
|
return true;
|
|
3178
3185
|
}
|
|
3179
|
-
|
|
3186
|
+
|
|
3187
|
+
// STEP 2
|
|
3188
|
+
//========
|
|
3189
|
+
// @@@ This code is triggered only if a custom request is used to update "options" @@@
|
|
3190
|
+
if (query && _val == ' ') {
|
|
3180
3191
|
return true;
|
|
3181
3192
|
}
|
|
3193
|
+
|
|
3194
|
+
// STEP 3
|
|
3195
|
+
//========
|
|
3196
|
+
// @@@ This code is triggered only if a custom request is used to update "options" @@@
|
|
3197
|
+
if (query && _val != '' && isSingleSpecialChar(_val)) {
|
|
3198
|
+
return true;
|
|
3199
|
+
}
|
|
3200
|
+
|
|
3201
|
+
// STEP 4
|
|
3202
|
+
//========
|
|
3182
3203
|
if ((_queryString.split(',').some(function (l) {
|
|
3183
3204
|
return l.charAt(0) === _val.toLowerCase();
|
|
3184
3205
|
}) || _queryString.split(',').some(function (l) {
|
package/lib/cjs/Select/index.js
CHANGED
|
@@ -3771,6 +3771,12 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3771
3771
|
setBlinkingPosStart = _useState24[1];
|
|
3772
3772
|
var blinkingPosFauxRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
|
|
3773
3773
|
var blinkingCursorPosDivRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
|
|
3774
|
+
|
|
3775
|
+
// Select All status (for "Single selection")
|
|
3776
|
+
var _useState25 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
|
|
3777
|
+
_useState26 = _slicedToArray(_useState25, 2),
|
|
3778
|
+
userInputboxIsAllSelected = _useState26[0],
|
|
3779
|
+
setUserInputboxIsAllSelected = _useState26[1];
|
|
3774
3780
|
var selectedSign = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);
|
|
3775
3781
|
var MULTI_SEL_VALID = multiSelect ? multiSelect.valid : false;
|
|
3776
3782
|
var MULTI_SEL_ENTIRE_AREA_TRIGGER = typeof multiSelectEntireAreaTrigger === 'undefined' ? true : multiSelectEntireAreaTrigger;
|
|
@@ -3781,16 +3787,21 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3781
3787
|
allItemsLabel: 'All Content ({num})',
|
|
3782
3788
|
noneLabel: 'No items selected'
|
|
3783
3789
|
};
|
|
3784
|
-
var
|
|
3790
|
+
var _useState27 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({
|
|
3785
3791
|
labels: [],
|
|
3786
3792
|
values: []
|
|
3787
3793
|
}),
|
|
3788
|
-
|
|
3789
|
-
controlArr =
|
|
3790
|
-
setControlArr =
|
|
3791
|
-
|
|
3794
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
|
3795
|
+
controlArr = _useState28[0],
|
|
3796
|
+
setControlArr = _useState28[1];
|
|
3797
|
+
|
|
3798
|
+
// Only single symbols such as , #, and @ are allowed, and , a, a, , etc. are not allowed.
|
|
3799
|
+
var isSingleSpecialChar = function isSingleSpecialChar(str) {
|
|
3800
|
+
return typeof str === 'string' && /^[^\w\s]$/.test(str);
|
|
3801
|
+
};
|
|
3802
|
+
var chkValueExist = function chkValueExist(v) {
|
|
3792
3803
|
return typeof v !== 'undefined' && v !== '';
|
|
3793
|
-
}
|
|
3804
|
+
};
|
|
3794
3805
|
var listContainerHeightLimit = function listContainerHeightLimit(num) {
|
|
3795
3806
|
var res = num;
|
|
3796
3807
|
if (res > LIST_CONTAINER_MAX_HEIGHT) res = LIST_CONTAINER_MAX_HEIGHT;
|
|
@@ -3835,19 +3846,22 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3835
3846
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(contentRef, function () {
|
|
3836
3847
|
return {
|
|
3837
3848
|
active: function active() {
|
|
3849
|
+
var _selectInputRef$curre;
|
|
3838
3850
|
handleShowList();
|
|
3839
|
-
selectInputRef.current.select();
|
|
3851
|
+
(_selectInputRef$curre = selectInputRef.current) === null || _selectInputRef$curre === void 0 ? void 0 : _selectInputRef$curre.select();
|
|
3840
3852
|
},
|
|
3841
3853
|
focus: function focus() {
|
|
3842
|
-
|
|
3854
|
+
var _selectInputRef$curre2;
|
|
3855
|
+
(_selectInputRef$curre2 = selectInputRef.current) === null || _selectInputRef$curre2 === void 0 ? void 0 : _selectInputRef$curre2.select();
|
|
3843
3856
|
},
|
|
3844
3857
|
clear: function clear(cb) {
|
|
3858
|
+
var _selectInputRef$curre3;
|
|
3845
3859
|
if (MULTI_SEL_VALID) {
|
|
3846
3860
|
updateOptionCheckboxes('remove');
|
|
3847
3861
|
} else {
|
|
3848
3862
|
handleClearValue();
|
|
3849
3863
|
}
|
|
3850
|
-
selectInputRef.current.blur();
|
|
3864
|
+
(_selectInputRef$curre3 = selectInputRef.current) === null || _selectInputRef$curre3 === void 0 ? void 0 : _selectInputRef$curre3.blur();
|
|
3851
3865
|
cb === null || cb === void 0 ? void 0 : cb();
|
|
3852
3866
|
},
|
|
3853
3867
|
/*
|
|
@@ -3870,7 +3884,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3870
3884
|
cb === null || cb === void 0 ? void 0 : cb();
|
|
3871
3885
|
}
|
|
3872
3886
|
};
|
|
3873
|
-
}, [contentRef]);
|
|
3887
|
+
}, [contentRef, selectInputRef]);
|
|
3874
3888
|
|
|
3875
3889
|
// click outside
|
|
3876
3890
|
useClickOutside_default()({
|
|
@@ -3929,35 +3943,12 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3929
3943
|
|
|
3930
3944
|
//performance
|
|
3931
3945
|
var handleChangeFetchSafe = useDebounce_default()(function (val) {
|
|
3932
|
-
var _orginalData = [];
|
|
3933
|
-
var update = function update(inputData) {
|
|
3934
|
-
var filterRes = function filterRes() {
|
|
3935
|
-
return inputData.filter(function (item) {
|
|
3936
|
-
// Avoid fatal errors causing page crashes
|
|
3937
|
-
var _queryString = typeof item.queryString !== 'undefined' && item.queryString !== null ? item.queryString : '';
|
|
3938
|
-
var _val = typeof val !== 'undefined' && val !== null ? val : '';
|
|
3939
|
-
if ((_queryString.split(',').some(function (l) {
|
|
3940
|
-
return l.charAt(0) === _val.toLowerCase();
|
|
3941
|
-
}) || _queryString.split(',').some(function (l) {
|
|
3942
|
-
return l.replace(/ /g, '').indexOf(_val.toLowerCase()) >= 0;
|
|
3943
|
-
}) || item.label.toLowerCase().indexOf(_val.toLowerCase()) >= 0) && _val != '') {
|
|
3944
|
-
return true;
|
|
3945
|
-
} else {
|
|
3946
|
-
return false;
|
|
3947
|
-
}
|
|
3948
|
-
});
|
|
3949
|
-
};
|
|
3950
|
-
return filterRes();
|
|
3951
|
-
};
|
|
3952
3946
|
if (fetchUpdate) {
|
|
3953
3947
|
// update filter status
|
|
3954
3948
|
setFilterItemsHasNoMatchData(false);
|
|
3955
3949
|
|
|
3956
3950
|
// Make a request
|
|
3957
3951
|
handleFetch(val).then(function (response) {
|
|
3958
|
-
_orginalData = response;
|
|
3959
|
-
var _filterRes = update(_orginalData);
|
|
3960
|
-
|
|
3961
3952
|
// pop win initalization
|
|
3962
3953
|
setTimeout(function () {
|
|
3963
3954
|
popwinPosInit();
|
|
@@ -3965,9 +3956,6 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3965
3956
|
}, 0);
|
|
3966
3957
|
});
|
|
3967
3958
|
} else {
|
|
3968
|
-
_orginalData = orginalData;
|
|
3969
|
-
var _filterRes = update(_orginalData);
|
|
3970
|
-
|
|
3971
3959
|
// pop win initalization
|
|
3972
3960
|
setTimeout(function () {
|
|
3973
3961
|
popwinPosInit();
|
|
@@ -3990,7 +3978,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3990
3978
|
_currentData,
|
|
3991
3979
|
_defaultValues,
|
|
3992
3980
|
_defaultLabels,
|
|
3993
|
-
|
|
3981
|
+
_filterRes,
|
|
3994
3982
|
_filterResQueryValue,
|
|
3995
3983
|
_filterResQueryLabel,
|
|
3996
3984
|
_currentData2,
|
|
@@ -4132,19 +4120,19 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4132
4120
|
|
|
4133
4121
|
// STEP 3: ===========
|
|
4134
4122
|
// If the default value is label, match value
|
|
4135
|
-
|
|
4123
|
+
_filterRes = [];
|
|
4136
4124
|
_filterResQueryValue = staticOptionsData.filter(function (item) {
|
|
4137
4125
|
return item.value == defaultValue;
|
|
4138
4126
|
});
|
|
4139
4127
|
_filterResQueryLabel = staticOptionsData.filter(function (item) {
|
|
4140
4128
|
return item.label == defaultValue;
|
|
4141
4129
|
});
|
|
4142
|
-
|
|
4143
|
-
if (_filterResQueryValue.length === 0)
|
|
4130
|
+
_filterRes = _filterResQueryValue;
|
|
4131
|
+
if (_filterResQueryValue.length === 0) _filterRes = _filterResQueryLabel;
|
|
4144
4132
|
|
|
4145
4133
|
// if the default value is Object
|
|
4146
|
-
if (isObject(inputDefault) &&
|
|
4147
|
-
|
|
4134
|
+
if (isObject(inputDefault) && _filterRes.length === 0) {
|
|
4135
|
+
_filterRes = [inputDefault];
|
|
4148
4136
|
}
|
|
4149
4137
|
|
|
4150
4138
|
// STEP 4: ===========
|
|
@@ -4156,9 +4144,9 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4156
4144
|
setControlValue('');
|
|
4157
4145
|
setControlLabel('');
|
|
4158
4146
|
} else {
|
|
4159
|
-
if (
|
|
4160
|
-
setControlValue(
|
|
4161
|
-
setControlLabel(formatIndentVal(
|
|
4147
|
+
if (_filterRes.length > 0) {
|
|
4148
|
+
setControlValue(_filterRes[0].value);
|
|
4149
|
+
setControlLabel(formatIndentVal(_filterRes[0].label, INDENT_LAST_PLACEHOLDER));
|
|
4162
4150
|
}
|
|
4163
4151
|
}
|
|
4164
4152
|
|
|
@@ -4426,6 +4414,25 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4426
4414
|
// Avoid fatal errors causing page crashes
|
|
4427
4415
|
var _queryString = typeof node.dataset.querystring !== 'undefined' && node.dataset.querystring !== null ? node.dataset.querystring : '';
|
|
4428
4416
|
var _val = typeof val !== 'undefined' && val !== null ? val : '';
|
|
4417
|
+
|
|
4418
|
+
// STEP 1
|
|
4419
|
+
//========
|
|
4420
|
+
// @@@ This code is triggered only if a custom request is used to update "options" @@@
|
|
4421
|
+
// If the condition is true, skip the loop and move on to the next node.
|
|
4422
|
+
if (fetchUpdate && _val == ' ') {
|
|
4423
|
+
return;
|
|
4424
|
+
}
|
|
4425
|
+
|
|
4426
|
+
// STEP 2
|
|
4427
|
+
//========
|
|
4428
|
+
// @@@ This code is triggered only if a custom request is used to update "options" @@@
|
|
4429
|
+
// If the condition is true, skip the loop and move on to the next node.
|
|
4430
|
+
if (fetchUpdate && _val != '' && isSingleSpecialChar(_val)) {
|
|
4431
|
+
return;
|
|
4432
|
+
}
|
|
4433
|
+
|
|
4434
|
+
// STEP 3
|
|
4435
|
+
//========
|
|
4429
4436
|
if ((_queryString.split(',').some(function (l) {
|
|
4430
4437
|
return l.charAt(0) === _val.toLowerCase();
|
|
4431
4438
|
}) || _queryString.split(',').some(function (l) {
|
|
@@ -4523,6 +4530,9 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4523
4530
|
// update filter status
|
|
4524
4531
|
setFilterItemsHasNoMatchData(false);
|
|
4525
4532
|
|
|
4533
|
+
// reset Select All status (for "Single selection")
|
|
4534
|
+
setUserInputboxIsAllSelected(false);
|
|
4535
|
+
|
|
4526
4536
|
// Unlocks the page
|
|
4527
4537
|
if (LOCK_BODY_SCROLL) (0,bodyScrollLock.enableBodyScroll)(document.querySelector('body'));
|
|
4528
4538
|
}
|
|
@@ -4621,6 +4631,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4621
4631
|
$el,
|
|
4622
4632
|
_selected,
|
|
4623
4633
|
_selectedVal,
|
|
4634
|
+
_selectInputRef$curre4,
|
|
4624
4635
|
_curItem$callback,
|
|
4625
4636
|
_value2,
|
|
4626
4637
|
_label2,
|
|
@@ -4629,6 +4640,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4629
4640
|
_$el,
|
|
4630
4641
|
_selected2,
|
|
4631
4642
|
_selectedVal2,
|
|
4643
|
+
_selectInputRef$curre5,
|
|
4632
4644
|
_args3 = arguments;
|
|
4633
4645
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
4634
4646
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -4769,7 +4781,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4769
4781
|
return onChange === null || onChange === void 0 ? void 0 : onChange(selectInputRef.current, valueInputRef.current, !MULTI_SEL_VALID ? curItem : multipleSelectionCallback(currentControlValueArr, currentControlLabelArr));
|
|
4770
4782
|
case 25:
|
|
4771
4783
|
//
|
|
4772
|
-
selectInputRef.current.blur();
|
|
4784
|
+
(_selectInputRef$curre4 = selectInputRef.current) === null || _selectInputRef$curre4 === void 0 ? void 0 : _selectInputRef$curre4.blur();
|
|
4773
4785
|
case 26:
|
|
4774
4786
|
_context3.next = 42;
|
|
4775
4787
|
break;
|
|
@@ -4877,7 +4889,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4877
4889
|
return onChange === null || onChange === void 0 ? void 0 : onChange(selectInputRef.current, valueInputRef.current, !MULTI_SEL_VALID ? curItem : multipleSelectionCallback(_currentControlValueArr, _currentControlLabelArr));
|
|
4878
4890
|
case 41:
|
|
4879
4891
|
//
|
|
4880
|
-
selectInputRef.current.blur();
|
|
4892
|
+
(_selectInputRef$curre5 = selectInputRef.current) === null || _selectInputRef$curre5 === void 0 ? void 0 : _selectInputRef$curre5.blur();
|
|
4881
4893
|
case 42:
|
|
4882
4894
|
// Fixed an out-of-focus issue
|
|
4883
4895
|
fixFocusStatus();
|
|
@@ -5013,7 +5025,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5013
5025
|
}
|
|
5014
5026
|
function _handleMultiControlItemRemove() {
|
|
5015
5027
|
_handleMultiControlItemRemove = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(event) {
|
|
5016
|
-
var valueToRemove, getCurrentIndex, currentControlValueArr, currentControlLabelArr, _value, _label;
|
|
5028
|
+
var valueToRemove, getCurrentIndex, currentControlValueArr, currentControlLabelArr, _value, _label, _selectInputRef$curre6;
|
|
5017
5029
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
5018
5030
|
while (1) switch (_context5.prev = _context5.next) {
|
|
5019
5031
|
case 0:
|
|
@@ -5050,7 +5062,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5050
5062
|
return onChange === null || onChange === void 0 ? void 0 : onChange(selectInputRef.current, valueInputRef.current, multipleSelectionCallback(currentControlValueArr, currentControlLabelArr));
|
|
5051
5063
|
case 15:
|
|
5052
5064
|
//
|
|
5053
|
-
selectInputRef.current.blur();
|
|
5065
|
+
(_selectInputRef$curre6 = selectInputRef.current) === null || _selectInputRef$curre6 === void 0 ? void 0 : _selectInputRef$curre6.blur();
|
|
5054
5066
|
case 16:
|
|
5055
5067
|
case "end":
|
|
5056
5068
|
return _context5.stop();
|
|
@@ -5239,7 +5251,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5239
5251
|
}
|
|
5240
5252
|
function _handleKeyPressed() {
|
|
5241
5253
|
_handleKeyPressed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(event) {
|
|
5242
|
-
var key, res, currentIndex, currentData, currentControlValueArr, currentControlLabelArr, htmlOptions;
|
|
5254
|
+
var key, res, currentIndex, currentData, currentControlValueArr, currentControlLabelArr, htmlOptions, _selectInputRef$curre7;
|
|
5243
5255
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
5244
5256
|
while (1) switch (_context8.prev = _context8.next) {
|
|
5245
5257
|
case 0:
|
|
@@ -5307,7 +5319,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5307
5319
|
return onChange === null || onChange === void 0 ? void 0 : onChange(selectInputRef.current, valueInputRef.current, !MULTI_SEL_VALID ? currentData : multipleSelectionCallback(currentControlValueArr, currentControlLabelArr));
|
|
5308
5320
|
case 25:
|
|
5309
5321
|
//
|
|
5310
|
-
selectInputRef.current.blur();
|
|
5322
|
+
(_selectInputRef$curre7 = selectInputRef.current) === null || _selectInputRef$curre7 === void 0 ? void 0 : _selectInputRef$curre7.blur();
|
|
5311
5323
|
case 26:
|
|
5312
5324
|
if (!(key === 'ArrowUp')) {
|
|
5313
5325
|
_context8.next = 30;
|
|
@@ -5498,6 +5510,15 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5498
5510
|
};
|
|
5499
5511
|
}, [orginalData]); // Avoid the issue that `setOptionsData(orginalData)` sets the original value to empty on the first entry
|
|
5500
5512
|
|
|
5513
|
+
// Select all detection functions in the input box (for "Single selection")
|
|
5514
|
+
function checkUserInputboxIsAllSelected(e) {
|
|
5515
|
+
var input = e.target;
|
|
5516
|
+
if (input && typeof input.selectionStart === 'number' && typeof input.selectionEnd === 'number') {
|
|
5517
|
+
setUserInputboxIsAllSelected(input.selectionStart === 0 && input.selectionEnd === input.value.length && input.value.length > 0);
|
|
5518
|
+
} else {
|
|
5519
|
+
setUserInputboxIsAllSelected(false);
|
|
5520
|
+
}
|
|
5521
|
+
}
|
|
5501
5522
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, label ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
5502
5523
|
className: "custom-select__label"
|
|
5503
5524
|
}, typeof label === 'string' ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("label", {
|
|
@@ -5612,7 +5633,18 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5612
5633
|
autoComplete: typeof autoComplete === 'undefined' ? 'off' : autoComplete,
|
|
5613
5634
|
autoCapitalize: typeof autoCapitalize === 'undefined' ? 'off' : autoCapitalize,
|
|
5614
5635
|
spellCheck: typeof spellCheck === 'undefined' ? false : spellCheck
|
|
5615
|
-
}, attributes
|
|
5636
|
+
}, attributes, {
|
|
5637
|
+
// Select all detection (for "Single selection")
|
|
5638
|
+
onSelect: function onSelect(e) {
|
|
5639
|
+
checkUserInputboxIsAllSelected(e);
|
|
5640
|
+
},
|
|
5641
|
+
onKeyUp: function onKeyUp(e) {
|
|
5642
|
+
checkUserInputboxIsAllSelected(e);
|
|
5643
|
+
},
|
|
5644
|
+
onMouseUp: function onMouseUp(e) {
|
|
5645
|
+
checkUserInputboxIsAllSelected(e);
|
|
5646
|
+
}
|
|
5647
|
+
})))) : null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("input", _extends({
|
|
5616
5648
|
ref: valueInputRef,
|
|
5617
5649
|
tabIndex: -1,
|
|
5618
5650
|
type: "hidden",
|
|
@@ -5642,7 +5674,9 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5642
5674
|
}), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
5643
5675
|
ref: blinkingCursorPosDivRef,
|
|
5644
5676
|
className: (0,cls.combinedCls)('custom-select-multi__control-blinking-cursor', {
|
|
5645
|
-
'animated': generateInputFocusStr() === BLINKING_CURSOR_STR
|
|
5677
|
+
'animated': generateInputFocusStr() === BLINKING_CURSOR_STR,
|
|
5678
|
+
// Select all highlights (for "Single selection")
|
|
5679
|
+
'selected': userInputboxIsAllSelected
|
|
5646
5680
|
})
|
|
5647
5681
|
}, controlTempValue || controlTempValue === '' ? controlTempValue.length === 0 ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
5648
5682
|
className: "".concat(!hideBlinkingCursor() ? 'control-placeholder' : '')
|
package/lib/css/Select/index.css
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
--cus-sel-searchbtn-hover-fill: #333;
|
|
17
17
|
--cus-sel-removebtn-fill: #000;
|
|
18
18
|
--cus-sel-removebtn-hover-fill: #f00;
|
|
19
|
+
--cus-sel-selected-color:#b1d0ff;
|
|
19
20
|
position: relative; /* Required */
|
|
20
21
|
/*------ Placeholder for input ------*/
|
|
21
22
|
/*------ Arrow ------*/
|
|
@@ -85,11 +86,15 @@
|
|
|
85
86
|
display: inline-block;
|
|
86
87
|
color: var(--cus-sel-placeholder-color);
|
|
87
88
|
width: 100%;
|
|
89
|
+
/* Select all highlights (for "Single selection") */
|
|
88
90
|
/* Text preview */
|
|
89
91
|
}
|
|
90
92
|
.custom-select__wrapper .custom-select-multi__control-blinking-cursor.animated {
|
|
91
93
|
animation: 1s mf-sel-blink step-end infinite;
|
|
92
94
|
}
|
|
95
|
+
.custom-select__wrapper .custom-select-multi__control-blinking-cursor.selected > span {
|
|
96
|
+
background-color: var(--cus-sel-selected-color);
|
|
97
|
+
}
|
|
93
98
|
.custom-select__wrapper .custom-select-multi__control-blinking-cursor.control-placeholder {
|
|
94
99
|
color: var(--cus-sel-input-placeholder-color);
|
|
95
100
|
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
|
|
20
21
|
export interface OptionConfig {
|
|
21
22
|
disabled?: boolean;
|
|
22
23
|
label: any;
|
|
@@ -38,7 +39,6 @@ export type LiveSearchProps = {
|
|
|
38
39
|
exceededSidePosOffset?: number;
|
|
39
40
|
appearance?: string;
|
|
40
41
|
isSearchInput?: boolean;
|
|
41
|
-
allowSpacingRetrive?: boolean;
|
|
42
42
|
loader?: React.ReactNode;
|
|
43
43
|
value?: string;
|
|
44
44
|
label?: React.ReactNode | string;
|
|
@@ -101,7 +101,6 @@ const LiveSearch = forwardRef((props: LiveSearchProps, externalRef: any) => {
|
|
|
101
101
|
exceededSidePosOffset,
|
|
102
102
|
appearance,
|
|
103
103
|
isSearchInput,
|
|
104
|
-
allowSpacingRetrive,
|
|
105
104
|
loader,
|
|
106
105
|
readOnly,
|
|
107
106
|
disabled,
|
|
@@ -253,6 +252,10 @@ const LiveSearch = forwardRef((props: LiveSearchProps, externalRef: any) => {
|
|
|
253
252
|
|
|
254
253
|
|
|
255
254
|
|
|
255
|
+
// Only single symbols such as , #, and @ are allowed, and , a, a, , etc. are not allowed.
|
|
256
|
+
const isSingleSpecialChar = (str: string) => {
|
|
257
|
+
return typeof str === 'string' && /^[^\w\s]$/.test(str);
|
|
258
|
+
};
|
|
256
259
|
|
|
257
260
|
|
|
258
261
|
// Add function to the element that should be used as the scrollable area.
|
|
@@ -435,6 +438,7 @@ const LiveSearch = forwardRef((props: LiveSearchProps, externalRef: any) => {
|
|
|
435
438
|
//
|
|
436
439
|
async function matchData(val: string = '', query: boolean = false, emptyValShowAll: boolean = false) {
|
|
437
440
|
|
|
441
|
+
|
|
438
442
|
let res: any[] = [];
|
|
439
443
|
let filterRes = (data: any[]) => {
|
|
440
444
|
return data.filter((item: any) => {
|
|
@@ -443,15 +447,31 @@ const LiveSearch = forwardRef((props: LiveSearchProps, externalRef: any) => {
|
|
|
443
447
|
const _queryString = typeof item.queryString !== 'undefined' && item.queryString !== null ? item.queryString : '';
|
|
444
448
|
const _val = typeof val !== 'undefined' && val !== null ? val : '';
|
|
445
449
|
|
|
446
|
-
|
|
447
|
-
|
|
450
|
+
// STEP 1
|
|
451
|
+
//========
|
|
452
|
+
if (emptyValShowAll && _val === '') {
|
|
448
453
|
return true;
|
|
449
454
|
}
|
|
450
455
|
|
|
451
|
-
|
|
456
|
+
|
|
457
|
+
// STEP 2
|
|
458
|
+
//========
|
|
459
|
+
// @@@ This code is triggered only if a custom request is used to update "options" @@@
|
|
460
|
+
if (query && _val == ' ') {
|
|
452
461
|
return true;
|
|
453
462
|
}
|
|
454
|
-
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
// STEP 3
|
|
466
|
+
//========
|
|
467
|
+
// @@@ This code is triggered only if a custom request is used to update "options" @@@
|
|
468
|
+
if (query && _val != '' && isSingleSpecialChar(_val)) {
|
|
469
|
+
return true;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
// STEP 4
|
|
474
|
+
//========
|
|
455
475
|
if (
|
|
456
476
|
(
|
|
457
477
|
_queryString.split(',').some((l: any) => l.charAt(0) === _val.toLowerCase()) ||
|
|
@@ -3,8 +3,6 @@ import React, { useState, useEffect, useRef, ChangeEvent, MouseEvent, Compositio
|
|
|
3
3
|
import useComId from 'funda-utils/dist/cjs/useComId';
|
|
4
4
|
import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
6
|
export type SearchBarProps = {
|
|
9
7
|
wrapperClassName?: string;
|
|
10
8
|
controlClassName?: string;
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
--cus-sel-searchbtn-hover-fill: #333;
|
|
19
19
|
--cus-sel-removebtn-fill: #000;
|
|
20
20
|
--cus-sel-removebtn-hover-fill: #f00;
|
|
21
|
+
--cus-sel-selected-color:#b1d0ff;
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
position: relative; /* Required */
|
|
@@ -115,6 +116,13 @@
|
|
|
115
116
|
animation: 1s mf-sel-blink step-end infinite;
|
|
116
117
|
}
|
|
117
118
|
|
|
119
|
+
|
|
120
|
+
/* Select all highlights (for "Single selection") */
|
|
121
|
+
&.selected > span {
|
|
122
|
+
background-color: var(--cus-sel-selected-color);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
118
126
|
&.control-placeholder {
|
|
119
127
|
color: var(--cus-sel-input-placeholder-color);
|
|
120
128
|
}
|
package/lib/esm/Select/index.tsx
CHANGED
|
@@ -2,7 +2,6 @@ import React, { useEffect, useState, useRef, KeyboardEvent, forwardRef, useImper
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
formatIndentVal,
|
|
5
|
-
unique,
|
|
6
5
|
removeItemOnce,
|
|
7
6
|
optionsCustomSelectFlat,
|
|
8
7
|
isObject
|
|
@@ -19,9 +18,6 @@ import {
|
|
|
19
18
|
import useDebounce from 'funda-utils/dist/cjs/useDebounce';
|
|
20
19
|
import useClickOutside from 'funda-utils/dist/cjs/useClickOutside';
|
|
21
20
|
import useWindowScroll from 'funda-utils/dist/cjs/useWindowScroll';
|
|
22
|
-
import {
|
|
23
|
-
extractContentsOfBrackets
|
|
24
|
-
} from 'funda-utils/dist/cjs/extract';
|
|
25
21
|
import {
|
|
26
22
|
convertArrToValByBrackets
|
|
27
23
|
} from 'funda-utils/dist/cjs/convert';
|
|
@@ -52,7 +48,6 @@ import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
|
52
48
|
|
|
53
49
|
|
|
54
50
|
|
|
55
|
-
|
|
56
51
|
export interface MultiSelectValue {
|
|
57
52
|
items: { label: string; value: string }[];
|
|
58
53
|
labels: string[];
|
|
@@ -308,6 +303,9 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
308
303
|
const blinkingPosFauxRef = useRef<any>(null);
|
|
309
304
|
const blinkingCursorPosDivRef = useRef<any>(null);
|
|
310
305
|
|
|
306
|
+
// Select All status (for "Single selection")
|
|
307
|
+
const [userInputboxIsAllSelected, setUserInputboxIsAllSelected] = useState(false);
|
|
308
|
+
|
|
311
309
|
|
|
312
310
|
|
|
313
311
|
const selectedSign = useRef<boolean>(false);
|
|
@@ -326,9 +324,17 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
326
324
|
values: []
|
|
327
325
|
});
|
|
328
326
|
|
|
329
|
-
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
// Only single symbols such as , #, and @ are allowed, and , a, a, , etc. are not allowed.
|
|
330
|
+
const isSingleSpecialChar = (str: string) => {
|
|
331
|
+
return typeof str === 'string' && /^[^\w\s]$/.test(str);
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
const chkValueExist = (v: any) => {
|
|
330
336
|
return typeof v !== 'undefined' && v !== '';
|
|
331
|
-
}
|
|
337
|
+
};
|
|
332
338
|
|
|
333
339
|
|
|
334
340
|
const listContainerHeightLimit = (num: number) => {
|
|
@@ -385,11 +391,11 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
385
391
|
() => ({
|
|
386
392
|
active: () => {
|
|
387
393
|
handleShowList();
|
|
388
|
-
selectInputRef.current
|
|
394
|
+
selectInputRef.current?.select();
|
|
389
395
|
},
|
|
390
396
|
|
|
391
397
|
focus: () => {
|
|
392
|
-
selectInputRef.current
|
|
398
|
+
selectInputRef.current?.select();
|
|
393
399
|
},
|
|
394
400
|
clear: (cb?: any) => {
|
|
395
401
|
|
|
@@ -399,7 +405,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
399
405
|
handleClearValue();
|
|
400
406
|
}
|
|
401
407
|
|
|
402
|
-
selectInputRef.current
|
|
408
|
+
selectInputRef.current?.blur();
|
|
403
409
|
|
|
404
410
|
cb?.();
|
|
405
411
|
},
|
|
@@ -422,7 +428,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
422
428
|
cb?.();
|
|
423
429
|
}
|
|
424
430
|
}),
|
|
425
|
-
[contentRef],
|
|
431
|
+
[contentRef, selectInputRef],
|
|
426
432
|
);
|
|
427
433
|
|
|
428
434
|
|
|
@@ -475,34 +481,6 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
475
481
|
//performance
|
|
476
482
|
const handleChangeFetchSafe = useDebounce((val: any) => {
|
|
477
483
|
|
|
478
|
-
let _orginalData: OptionConfig[] = [];
|
|
479
|
-
const update = (inputData: any) => {
|
|
480
|
-
const filterRes = () => {
|
|
481
|
-
|
|
482
|
-
return inputData.filter((item: any) => {
|
|
483
|
-
|
|
484
|
-
// Avoid fatal errors causing page crashes
|
|
485
|
-
const _queryString = typeof item.queryString !== 'undefined' && item.queryString !== null ? item.queryString : '';
|
|
486
|
-
const _val = typeof val !== 'undefined' && val !== null ? val : '';
|
|
487
|
-
|
|
488
|
-
if (
|
|
489
|
-
(
|
|
490
|
-
_queryString.split(',').some((l: any) => l.charAt(0) === _val.toLowerCase()) ||
|
|
491
|
-
_queryString.split(',').some((l: any) => l.replace(/ /g, '').indexOf(_val.toLowerCase()) >= 0) ||
|
|
492
|
-
item.label.toLowerCase().indexOf(_val.toLowerCase()) >= 0
|
|
493
|
-
) &&
|
|
494
|
-
_val != ''
|
|
495
|
-
) {
|
|
496
|
-
return true;
|
|
497
|
-
} else {
|
|
498
|
-
return false;
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
return filterRes();
|
|
504
|
-
};
|
|
505
|
-
|
|
506
484
|
if (fetchUpdate) {
|
|
507
485
|
|
|
508
486
|
// update filter status
|
|
@@ -511,9 +489,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
511
489
|
|
|
512
490
|
// Make a request
|
|
513
491
|
handleFetch(val).then((response: any) => {
|
|
514
|
-
|
|
515
|
-
const _filterRes = update(_orginalData);
|
|
516
|
-
|
|
492
|
+
|
|
517
493
|
// pop win initalization
|
|
518
494
|
setTimeout(() => {
|
|
519
495
|
popwinPosInit();
|
|
@@ -521,9 +497,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
521
497
|
}, 0);
|
|
522
498
|
});
|
|
523
499
|
} else {
|
|
524
|
-
|
|
525
|
-
const _filterRes = update(_orginalData);
|
|
526
|
-
|
|
500
|
+
|
|
527
501
|
// pop win initalization
|
|
528
502
|
setTimeout(() => {
|
|
529
503
|
popwinPosInit();
|
|
@@ -1048,6 +1022,27 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
1048
1022
|
const _queryString = typeof node.dataset.querystring !== 'undefined' && node.dataset.querystring !== null ? node.dataset.querystring : '';
|
|
1049
1023
|
const _val = typeof val !== 'undefined' && val !== null ? val : '';
|
|
1050
1024
|
|
|
1025
|
+
|
|
1026
|
+
// STEP 1
|
|
1027
|
+
//========
|
|
1028
|
+
// @@@ This code is triggered only if a custom request is used to update "options" @@@
|
|
1029
|
+
// If the condition is true, skip the loop and move on to the next node.
|
|
1030
|
+
if (fetchUpdate && _val == ' ') {
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
// STEP 2
|
|
1036
|
+
//========
|
|
1037
|
+
// @@@ This code is triggered only if a custom request is used to update "options" @@@
|
|
1038
|
+
// If the condition is true, skip the loop and move on to the next node.
|
|
1039
|
+
if (fetchUpdate && _val != '' && isSingleSpecialChar(_val)) {
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
// STEP 3
|
|
1045
|
+
//========
|
|
1051
1046
|
if (
|
|
1052
1047
|
(
|
|
1053
1048
|
_queryString.split(',').some((l: any) => l.charAt(0) === _val.toLowerCase()) ||
|
|
@@ -1173,6 +1168,10 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
1173
1168
|
setFilterItemsHasNoMatchData(false);
|
|
1174
1169
|
|
|
1175
1170
|
|
|
1171
|
+
// reset Select All status (for "Single selection")
|
|
1172
|
+
setUserInputboxIsAllSelected(false);
|
|
1173
|
+
|
|
1174
|
+
|
|
1176
1175
|
// Unlocks the page
|
|
1177
1176
|
if (LOCK_BODY_SCROLL) enableBodyScroll(document.querySelector('body'));
|
|
1178
1177
|
}
|
|
@@ -1271,7 +1270,6 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
1271
1270
|
|
|
1272
1271
|
if (typeof el === 'undefined') return;
|
|
1273
1272
|
|
|
1274
|
-
|
|
1275
1273
|
const curItem: any = el === null ? (isObject(dataInput) ? dataInput : JSON.parse(dataInput)) : optionsData[Number(el.currentTarget.dataset.index)];
|
|
1276
1274
|
|
|
1277
1275
|
|
|
@@ -1437,7 +1435,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
1437
1435
|
|
|
1438
1436
|
|
|
1439
1437
|
//
|
|
1440
|
-
selectInputRef.current
|
|
1438
|
+
selectInputRef.current?.blur();
|
|
1441
1439
|
}
|
|
1442
1440
|
|
|
1443
1441
|
|
|
@@ -1582,7 +1580,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
1582
1580
|
|
|
1583
1581
|
|
|
1584
1582
|
//
|
|
1585
|
-
selectInputRef.current
|
|
1583
|
+
selectInputRef.current?.blur();
|
|
1586
1584
|
}
|
|
1587
1585
|
}
|
|
1588
1586
|
|
|
@@ -1767,7 +1765,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
1767
1765
|
|
|
1768
1766
|
|
|
1769
1767
|
//
|
|
1770
|
-
selectInputRef.current
|
|
1768
|
+
selectInputRef.current?.blur();
|
|
1771
1769
|
}
|
|
1772
1770
|
|
|
1773
1771
|
}
|
|
@@ -2006,7 +2004,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
2006
2004
|
|
|
2007
2005
|
|
|
2008
2006
|
//
|
|
2009
|
-
selectInputRef.current
|
|
2007
|
+
selectInputRef.current?.blur();
|
|
2010
2008
|
}
|
|
2011
2009
|
|
|
2012
2010
|
}
|
|
@@ -2207,6 +2205,16 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
2207
2205
|
}, [orginalData]); // Avoid the issue that `setOptionsData(orginalData)` sets the original value to empty on the first entry
|
|
2208
2206
|
|
|
2209
2207
|
|
|
2208
|
+
// Select all detection functions in the input box (for "Single selection")
|
|
2209
|
+
function checkUserInputboxIsAllSelected(e: any) {
|
|
2210
|
+
const input = e.target;
|
|
2211
|
+
if (input && typeof input.selectionStart === 'number' && typeof input.selectionEnd === 'number') {
|
|
2212
|
+
setUserInputboxIsAllSelected(input.selectionStart === 0 && input.selectionEnd === input.value.length && input.value.length > 0);
|
|
2213
|
+
} else {
|
|
2214
|
+
setUserInputboxIsAllSelected(false);
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2210
2218
|
|
|
2211
2219
|
return (
|
|
2212
2220
|
<>
|
|
@@ -2316,6 +2324,11 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
2316
2324
|
autoCapitalize={typeof autoCapitalize === 'undefined' ? 'off' : autoCapitalize}
|
|
2317
2325
|
spellCheck={typeof spellCheck === 'undefined' ? false : spellCheck}
|
|
2318
2326
|
{...attributes}
|
|
2327
|
+
|
|
2328
|
+
// Select all detection (for "Single selection")
|
|
2329
|
+
onSelect={(e) => { checkUserInputboxIsAllSelected(e); }}
|
|
2330
|
+
onKeyUp={(e) => { checkUserInputboxIsAllSelected(e); }}
|
|
2331
|
+
onMouseUp={(e) => { checkUserInputboxIsAllSelected(e); }}
|
|
2319
2332
|
/>
|
|
2320
2333
|
|
|
2321
2334
|
</div>
|
|
@@ -2377,7 +2390,10 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
2377
2390
|
<span ref={blinkingCursorPosDivRef} className={combinedCls(
|
|
2378
2391
|
'custom-select-multi__control-blinking-cursor',
|
|
2379
2392
|
{
|
|
2380
|
-
'animated': generateInputFocusStr() === BLINKING_CURSOR_STR
|
|
2393
|
+
'animated': generateInputFocusStr() === BLINKING_CURSOR_STR,
|
|
2394
|
+
|
|
2395
|
+
// Select all highlights (for "Single selection")
|
|
2396
|
+
'selected': userInputboxIsAllSelected
|
|
2381
2397
|
}
|
|
2382
2398
|
)}>
|
|
2383
2399
|
{controlTempValue || controlTempValue === '' ? (controlTempValue.length === 0 ? <span className={`${!hideBlinkingCursor() ? 'control-placeholder' : ''}`}>{generateInputFocusStr()}</span> : <span>{controlTempValue}</span>) : (stripTagsAndContent(controlLabel as never).length === 0 ? <span className={`${!hideBlinkingCursor() ? 'control-placeholder' : ''}`}>{generateInputFocusStr()}</span> : <span>{stripTagsAndContent(controlLabel as never)}</span>)}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "UIUX Lab",
|
|
3
3
|
"email": "uiuxlab@gmail.com",
|
|
4
4
|
"name": "funda-ui",
|
|
5
|
-
"version": "4.7.
|
|
5
|
+
"version": "4.7.335",
|
|
6
6
|
"description": "React components using pure Bootstrap 5+ which does not contain any external style and script libraries.",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|