funda-ui 3.8.325 → 3.8.555
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/Date/index.d.ts +1 -0
- package/Date/index.js +69 -63
- package/LiveSearch/index.d.ts +14 -4
- package/LiveSearch/index.js +96 -44
- package/SearchBar/index.d.ts +7 -0
- package/SearchBar/index.js +30 -5
- package/lib/cjs/Date/index.d.ts +1 -0
- package/lib/cjs/Date/index.js +69 -63
- package/lib/cjs/LiveSearch/index.d.ts +14 -4
- package/lib/cjs/LiveSearch/index.js +96 -44
- package/lib/cjs/SearchBar/index.d.ts +7 -0
- package/lib/cjs/SearchBar/index.js +30 -5
- package/lib/esm/Date/index.tsx +52 -61
- package/lib/esm/LiveSearch/index.tsx +79 -48
- package/lib/esm/SearchBar/index.tsx +38 -2
- package/package.json +1 -1
package/Date/index.d.ts
CHANGED
package/Date/index.js
CHANGED
|
@@ -1654,7 +1654,7 @@ var zh_CN_default = /*#__PURE__*/__webpack_require__.n(zh_CN);
|
|
|
1654
1654
|
// EXTERNAL MODULE: ./src/utils/performance.js
|
|
1655
1655
|
var performance = __webpack_require__(342);
|
|
1656
1656
|
;// CONCATENATED MODULE: ./src/index.tsx
|
|
1657
|
-
var _excluded = ["popupRef", "triggerClassName", "popupClassName", "wrapperClassName", "controlClassName", "controlGroupWrapperClassName", "controlGroupTextClassName", "delimiter", "offset", "exceededSidePosOffset", "localization", "type", "onlyTime", "truncateSeconds", "valueUseSlash", "disabled", "required", "readOnly", "value", "min", "max", "placeholder", "label", "units", "name", "alt", "id", "iconLeft", "iconRight", "autoComplete", "style", "tabIndex", "onLoad", "onChange", "onBlur", "onFocus", "onOpenPopup", "onClosePopup", "onChangeDate", "onChangeMonth", "onChangeYear", "onChangeToday", "onChangeHours", "onChangeMinutes", "onChangeSeconds", "langHoursTitle", "langMinutesTitle", "langSecondsTitle", "langWeek", "langWeekFull", "langMonths", "langMonthsFull", "langToday"];
|
|
1657
|
+
var _excluded = ["popupRef", "triggerClassName", "popupClassName", "wrapperClassName", "controlClassName", "controlGroupWrapperClassName", "controlGroupTextClassName", "delimiter", "offset", "exceededSidePosOffset", "localization", "type", "onlyTime", "truncateSeconds", "valueUseSlash", "disabled", "required", "readOnly", "value", "clickInitValue", "min", "max", "placeholder", "label", "units", "name", "alt", "id", "iconLeft", "iconRight", "autoComplete", "style", "tabIndex", "onLoad", "onChange", "onBlur", "onFocus", "onOpenPopup", "onClosePopup", "onChangeDate", "onChangeMonth", "onChangeYear", "onChangeToday", "onChangeHours", "onChangeMinutes", "onChangeSeconds", "langHoursTitle", "langMinutesTitle", "langSecondsTitle", "langWeek", "langWeekFull", "langMonths", "langMonthsFull", "langToday"];
|
|
1658
1658
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
1659
1659
|
function src_slicedToArray(arr, i) { return src_arrayWithHoles(arr) || src_iterableToArrayLimit(arr, i) || src_unsupportedIterableToArray(arr, i) || src_nonIterableRest(); }
|
|
1660
1660
|
function src_nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -1694,6 +1694,7 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
1694
1694
|
required = props.required,
|
|
1695
1695
|
readOnly = props.readOnly,
|
|
1696
1696
|
value = props.value,
|
|
1697
|
+
clickInitValue = props.clickInitValue,
|
|
1697
1698
|
min = props.min,
|
|
1698
1699
|
max = props.max,
|
|
1699
1700
|
placeholder = props.placeholder,
|
|
@@ -1793,26 +1794,30 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
1793
1794
|
_useState2 = src_slicedToArray(_useState, 2),
|
|
1794
1795
|
dateDefaultValueExist = _useState2[0],
|
|
1795
1796
|
setDateDefaultValueExist = _useState2[1];
|
|
1796
|
-
var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(
|
|
1797
|
+
var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
|
|
1797
1798
|
_useState4 = src_slicedToArray(_useState3, 2),
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
var _useState5 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(
|
|
1799
|
+
initSplitClickEvOk = _useState4[0],
|
|
1800
|
+
setInitSplitClickEvOk = _useState4[1];
|
|
1801
|
+
var _useState5 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(['0000', '00', '00', '00', '00', '00']),
|
|
1801
1802
|
_useState6 = src_slicedToArray(_useState5, 2),
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
var _useState7 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(
|
|
1803
|
+
splitVals = _useState6[0],
|
|
1804
|
+
setSplitVals = _useState6[1];
|
|
1805
|
+
var _useState7 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(value || ''),
|
|
1805
1806
|
_useState8 = src_slicedToArray(_useState7, 2),
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
var _useState9 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(
|
|
1807
|
+
changedVal = _useState8[0],
|
|
1808
|
+
setChangedVal = _useState8[1];
|
|
1809
|
+
var _useState9 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
|
|
1809
1810
|
_useState10 = src_slicedToArray(_useState9, 2),
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
var _useState11 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(
|
|
1811
|
+
isShow = _useState10[0],
|
|
1812
|
+
setIsShow = _useState10[1];
|
|
1813
|
+
var _useState11 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(''),
|
|
1813
1814
|
_useState12 = src_slicedToArray(_useState11, 2),
|
|
1814
|
-
|
|
1815
|
-
|
|
1815
|
+
dateVal = _useState12[0],
|
|
1816
|
+
setDateVal = _useState12[1];
|
|
1817
|
+
var _useState13 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(['00', '00', '00']),
|
|
1818
|
+
_useState14 = src_slicedToArray(_useState13, 2),
|
|
1819
|
+
timeVal = _useState14[0],
|
|
1820
|
+
setTimeVal = _useState14[1];
|
|
1816
1821
|
var hoursArr = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'];
|
|
1817
1822
|
var msArr = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59'];
|
|
1818
1823
|
|
|
@@ -2016,10 +2021,32 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2016
2021
|
|
|
2017
2022
|
e.target.select();
|
|
2018
2023
|
resetDefauleValueExist();
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2024
|
+
|
|
2025
|
+
// update default value when splitting control clicked
|
|
2026
|
+
var noTargetVal = typeof clickInitValue === 'undefined' || clickInitValue === null || clickInitValue === 'null' || clickInitValue === '';
|
|
2027
|
+
var _targetVal = noTargetVal ? getNow() : clickInitValue;
|
|
2028
|
+
if (noTargetVal) {
|
|
2029
|
+
if (!dateDefaultValueExist) {
|
|
2030
|
+
var _initValue = initValue(_targetVal),
|
|
2031
|
+
_initValue2 = src_slicedToArray(_initValue, 2),
|
|
2032
|
+
a = _initValue2[0],
|
|
2033
|
+
b = _initValue2[1];
|
|
2034
|
+
var _full = getFullTimeData(b).res;
|
|
2035
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), isValidDate(_full));
|
|
2036
|
+
setChangedVal(_full);
|
|
2037
|
+
}
|
|
2038
|
+
} else {
|
|
2039
|
+
if (!initSplitClickEvOk) {
|
|
2040
|
+
var _initValue3 = initValue(_targetVal),
|
|
2041
|
+
_initValue4 = src_slicedToArray(_initValue3, 2),
|
|
2042
|
+
_a = _initValue4[0],
|
|
2043
|
+
_b = _initValue4[1];
|
|
2044
|
+
var _full2 = getFullTimeData(_b).res;
|
|
2045
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full2), isValidDate(_full2));
|
|
2046
|
+
|
|
2047
|
+
//
|
|
2048
|
+
setInitSplitClickEvOk(true);
|
|
2049
|
+
}
|
|
2023
2050
|
}
|
|
2024
2051
|
}
|
|
2025
2052
|
function clearAll() {
|
|
@@ -2163,14 +2190,12 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2163
2190
|
}
|
|
2164
2191
|
return res;
|
|
2165
2192
|
}
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
//
|
|
2173
|
-
var _getFullTimeData = getFullTimeData(getNow()),
|
|
2193
|
+
function initValue(v) {
|
|
2194
|
+
var _dVal = onlyTime ? "".concat(getFullTimeData(getNow()).date, " ").concat(v) : v;
|
|
2195
|
+
var _res = valueResConverter(_dVal);
|
|
2196
|
+
setChangedVal(_res);
|
|
2197
|
+
if (isValidDate(_dVal)) {
|
|
2198
|
+
var _getFullTimeData = getFullTimeData(_dVal),
|
|
2174
2199
|
date = _getFullTimeData.date,
|
|
2175
2200
|
year = _getFullTimeData.year,
|
|
2176
2201
|
month = _getFullTimeData.month,
|
|
@@ -2178,43 +2203,24 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2178
2203
|
hours = _getFullTimeData.hours,
|
|
2179
2204
|
minutes = _getFullTimeData.minutes,
|
|
2180
2205
|
seconds = _getFullTimeData.seconds;
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
setDateVal(MIN.date);
|
|
2193
|
-
setTimeVal([MIN.hours, MIN.minutes, MIN.seconds]);
|
|
2194
|
-
setSplitVals([MIN.year, MIN.month, MIN.day, MIN.hours, MIN.minutes, MIN.seconds]);
|
|
2195
|
-
}
|
|
2196
|
-
}
|
|
2206
|
+
setDateVal(date);
|
|
2207
|
+
setTimeVal([hours, minutes, seconds]);
|
|
2208
|
+
setSplitVals([year, month, day, hours, minutes, seconds]);
|
|
2209
|
+
}
|
|
2210
|
+
return [_res, _dVal];
|
|
2211
|
+
}
|
|
2212
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
2213
|
+
// update default value
|
|
2214
|
+
//--------------
|
|
2215
|
+
if (typeof value === 'undefined' || value === null || value === 'null' || value === '') {
|
|
2216
|
+
setDateDefaultValueExist(false);
|
|
2197
2217
|
} else {
|
|
2198
2218
|
setDateDefaultValueExist(true);
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
if (isValidDate(_dVal)) {
|
|
2205
|
-
var _getFullTimeData2 = getFullTimeData(_dVal),
|
|
2206
|
-
_date2 = _getFullTimeData2.date,
|
|
2207
|
-
_year = _getFullTimeData2.year,
|
|
2208
|
-
_month = _getFullTimeData2.month,
|
|
2209
|
-
_day = _getFullTimeData2.day,
|
|
2210
|
-
_hours = _getFullTimeData2.hours,
|
|
2211
|
-
_minutes = _getFullTimeData2.minutes,
|
|
2212
|
-
_seconds = _getFullTimeData2.seconds;
|
|
2213
|
-
setDateVal(_date2);
|
|
2214
|
-
setTimeVal([_hours, _minutes, _seconds]);
|
|
2215
|
-
setSplitVals([_year, _month, _day, _hours, _minutes, _seconds]);
|
|
2216
|
-
}
|
|
2217
|
-
onLoad === null || onLoad === void 0 ? void 0 : onLoad(_res, getFullTimeData(_dVal));
|
|
2219
|
+
var _initValue5 = initValue(value),
|
|
2220
|
+
_initValue6 = src_slicedToArray(_initValue5, 2),
|
|
2221
|
+
a = _initValue6[0],
|
|
2222
|
+
b = _initValue6[1];
|
|
2223
|
+
onLoad === null || onLoad === void 0 ? void 0 : onLoad(a, getFullTimeData(b));
|
|
2218
2224
|
}
|
|
2219
2225
|
|
|
2220
2226
|
//--------------
|
package/LiveSearch/index.d.ts
CHANGED
|
@@ -10,12 +10,20 @@ declare type LiveSearchProps = {
|
|
|
10
10
|
popupRef?: React.RefObject<any>;
|
|
11
11
|
wrapperClassName?: string;
|
|
12
12
|
controlClassName?: string;
|
|
13
|
+
controlExClassName?: string;
|
|
14
|
+
controlGroupWrapperClassName?: string;
|
|
15
|
+
controlGroupTextClassName?: string;
|
|
13
16
|
exceededSidePosOffset?: number;
|
|
14
17
|
appearance?: string;
|
|
15
18
|
isSearchInput?: boolean;
|
|
19
|
+
allowSpacingRetrive?: boolean;
|
|
16
20
|
value?: string;
|
|
17
21
|
label?: React.ReactNode | string;
|
|
18
22
|
name?: string;
|
|
23
|
+
units?: React.ReactNode | string;
|
|
24
|
+
iconLeft?: React.ReactNode | string;
|
|
25
|
+
iconRight?: React.ReactNode | string;
|
|
26
|
+
minLength?: any;
|
|
19
27
|
maxLength?: any;
|
|
20
28
|
readOnly?: any;
|
|
21
29
|
disabled?: any;
|
|
@@ -37,7 +45,7 @@ declare type LiveSearchProps = {
|
|
|
37
45
|
style?: React.CSSProperties;
|
|
38
46
|
tabIndex?: number;
|
|
39
47
|
[key: `data-${string}`]: string | undefined;
|
|
40
|
-
|
|
48
|
+
autoShowOptions?: boolean;
|
|
41
49
|
fetchNoneInfo?: string;
|
|
42
50
|
fetchUpdate?: boolean;
|
|
43
51
|
fetchFuncAsync?: any;
|
|
@@ -45,8 +53,10 @@ declare type LiveSearchProps = {
|
|
|
45
53
|
fetchFuncMethodParams?: any[];
|
|
46
54
|
fetchCallback?: (data: any) => void;
|
|
47
55
|
onFetch?: (data: any) => void;
|
|
48
|
-
|
|
49
|
-
|
|
56
|
+
onClick?: (inputEl: any, popupEl: any) => void;
|
|
57
|
+
onChange?: (inputEl: any, data: any, selectedData: any, popupEl: any) => void;
|
|
58
|
+
onKeyboardInput?: (e: any, inputEl: any, popupEl: any) => void;
|
|
59
|
+
onBlur?: (inputEl: any, popupEl: any) => void;
|
|
50
60
|
};
|
|
51
|
-
declare const LiveSearch:
|
|
61
|
+
declare const LiveSearch: React.ForwardRefExoticComponent<LiveSearchProps & React.RefAttributes<unknown>>;
|
|
52
62
|
export default LiveSearch;
|
package/LiveSearch/index.js
CHANGED
|
@@ -547,7 +547,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
547
547
|
var react__WEBPACK_IMPORTED_MODULE_0__ = __nested_webpack_require_1465__(787);
|
|
548
548
|
/* harmony import */
|
|
549
549
|
var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nested_webpack_require_1465__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
550
|
-
var _excluded = ["wrapperClassName", "controlClassName", "controlExClassName", "appearance", "isSearchInput", "readOnly", "disabled", "required", "placeholder", "value", "label", "name", "
|
|
550
|
+
var _excluded = ["wrapperClassName", "controlClassName", "controlExClassName", "controlGroupWrapperClassName", "controlGroupTextClassName", "appearance", "isSearchInput", "readOnly", "disabled", "required", "placeholder", "value", "label", "name", "units", "iconLeft", "iconRight", "minLength", "maxLength", "btnId", "id", "icon", "autoComplete", "style", "tabIndex", "onClick", "onKeyPressedCallback", "onSubmit", "onChange", "onBlur", "onFocus"];
|
|
551
551
|
function _extends() {
|
|
552
552
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
553
553
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -642,6 +642,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
642
642
|
var wrapperClassName = props.wrapperClassName,
|
|
643
643
|
controlClassName = props.controlClassName,
|
|
644
644
|
controlExClassName = props.controlExClassName,
|
|
645
|
+
controlGroupWrapperClassName = props.controlGroupWrapperClassName,
|
|
646
|
+
controlGroupTextClassName = props.controlGroupTextClassName,
|
|
645
647
|
appearance = props.appearance,
|
|
646
648
|
isSearchInput = props.isSearchInput,
|
|
647
649
|
readOnly = props.readOnly,
|
|
@@ -651,14 +653,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
651
653
|
value = props.value,
|
|
652
654
|
label = props.label,
|
|
653
655
|
name = props.name,
|
|
656
|
+
units = props.units,
|
|
657
|
+
iconLeft = props.iconLeft,
|
|
658
|
+
iconRight = props.iconRight,
|
|
659
|
+
minLength = props.minLength,
|
|
660
|
+
maxLength = props.maxLength,
|
|
654
661
|
btnId = props.btnId,
|
|
655
662
|
id = props.id,
|
|
656
|
-
maxLength = props.maxLength,
|
|
657
663
|
icon = props.icon,
|
|
658
664
|
autoComplete = props.autoComplete,
|
|
659
665
|
style = props.style,
|
|
660
666
|
tabIndex = props.tabIndex,
|
|
661
667
|
onClick = props.onClick,
|
|
668
|
+
onKeyPressedCallback = props.onKeyPressedCallback,
|
|
662
669
|
onSubmit = props.onSubmit,
|
|
663
670
|
onChange = props.onChange,
|
|
664
671
|
onBlur = props.onBlur,
|
|
@@ -675,6 +682,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
675
682
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
676
683
|
onComposition = _useState4[0],
|
|
677
684
|
setOnComposition = _useState4[1];
|
|
685
|
+
var propExist = function propExist(p) {
|
|
686
|
+
return typeof p !== 'undefined' && p !== null && p !== '';
|
|
687
|
+
};
|
|
678
688
|
function handleComposition(event) {
|
|
679
689
|
if (event.type === 'compositionstart') {
|
|
680
690
|
setOnComposition(true);
|
|
@@ -721,6 +731,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
721
731
|
//
|
|
722
732
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event, onComposition);
|
|
723
733
|
}
|
|
734
|
+
function handleKeyPressed(event) {
|
|
735
|
+
if (typeof onKeyPressedCallback === 'function') {
|
|
736
|
+
var newData = onKeyPressedCallback(event);
|
|
737
|
+
if (newData) setChangedVal(newData); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
724
741
|
(0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
725
742
|
// update default value
|
|
726
743
|
//--------------
|
|
@@ -739,8 +756,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
739
756
|
htmlFor: idRes,
|
|
740
757
|
className: "form-label"
|
|
741
758
|
}, label)) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
742
|
-
className: "input-group"
|
|
743
|
-
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("
|
|
759
|
+
className: "".concat(controlGroupWrapperClassName || "input-group", " position-relative ").concat(propExist(iconLeft) ? 'has-left-content' : '', " ").concat(propExist(iconRight) || propExist(units) ? 'has-right-content' : '')
|
|
760
|
+
}, propExist(iconLeft) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(react__WEBPACK_IMPORTED_MODULE_0___default().Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
761
|
+
className: controlGroupTextClassName || "input-group-text"
|
|
762
|
+
}, iconLeft)) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", _extends({
|
|
744
763
|
ref: ref,
|
|
745
764
|
tabIndex: tabIndex || 0,
|
|
746
765
|
type: isSearchInput ? 'search' : 'text',
|
|
@@ -749,12 +768,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
749
768
|
name: name,
|
|
750
769
|
placeholder: placeholder || '',
|
|
751
770
|
value: changedVal,
|
|
771
|
+
minLength: minLength || null,
|
|
752
772
|
maxLength: maxLength || null,
|
|
753
773
|
autoComplete: typeof autoComplete === 'undefined' ? 'off' : autoComplete,
|
|
754
774
|
onFocus: handleFocus,
|
|
755
775
|
onBlur: handleBlur,
|
|
756
776
|
onChange: handleChange,
|
|
757
777
|
onClick: handleClick,
|
|
778
|
+
onKeyDown: handleKeyPressed,
|
|
758
779
|
onCompositionStart: handleComposition,
|
|
759
780
|
onCompositionUpdate: handleComposition,
|
|
760
781
|
onCompositionEnd: handleComposition,
|
|
@@ -762,7 +783,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
762
783
|
readOnly: readOnly || null,
|
|
763
784
|
required: required || null,
|
|
764
785
|
style: style
|
|
765
|
-
}, attributes)),
|
|
786
|
+
}, attributes)), propExist(units) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(react__WEBPACK_IMPORTED_MODULE_0___default().Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
787
|
+
className: controlGroupTextClassName || "input-group-text"
|
|
788
|
+
}, units)) : null, propExist(iconRight) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(react__WEBPACK_IMPORTED_MODULE_0___default().Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
789
|
+
className: controlGroupTextClassName || "input-group-text"
|
|
790
|
+
}, iconRight)) : null, icon || icon !== '' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(react__WEBPACK_IMPORTED_MODULE_0___default().Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
766
791
|
className: appearance === 'pill' ? 'position-absolute end-0' : 'input-group-text m-0 p-0 border-start-0',
|
|
767
792
|
style: appearance === 'pill' ? {
|
|
768
793
|
zIndex: 5
|
|
@@ -956,7 +981,7 @@ var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs);
|
|
|
956
981
|
var dist_cjs = __webpack_require__(962);
|
|
957
982
|
var dist_cjs_default = /*#__PURE__*/__webpack_require__.n(dist_cjs);
|
|
958
983
|
;// CONCATENATED MODULE: ./src/index.tsx
|
|
959
|
-
var _excluded = ["popupRef", "wrapperClassName", "controlClassName", "exceededSidePosOffset", "appearance", "isSearchInput", "readOnly", "disabled", "required", "placeholder", "options", "value", "label", "name", "id", "icon", "btnId", "fetchTrigger", "hideIcon", "depth", "
|
|
984
|
+
var _excluded = ["popupRef", "wrapperClassName", "controlClassName", "controlExClassName", "controlGroupWrapperClassName", "controlGroupTextClassName", "exceededSidePosOffset", "appearance", "isSearchInput", "allowSpacingRetrive", "readOnly", "disabled", "required", "placeholder", "options", "value", "label", "name", "units", "iconLeft", "iconRight", "minLength", "maxLength", "id", "icon", "btnId", "fetchTrigger", "hideIcon", "depth", "style", "winWidth", "tabIndex", "data", "autoShowOptions", "fetchNoneInfo", "fetchUpdate", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "fetchCallback", "onClick", "onFetch", "onChange", "onKeyboardInput", "onBlur"];
|
|
960
985
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
961
986
|
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."); }
|
|
962
987
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -980,13 +1005,17 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
980
1005
|
|
|
981
1006
|
|
|
982
1007
|
|
|
983
|
-
var LiveSearch = function
|
|
1008
|
+
var LiveSearch = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.forwardRef)(function (props, _ref2) {
|
|
984
1009
|
var popupRef = props.popupRef,
|
|
985
1010
|
wrapperClassName = props.wrapperClassName,
|
|
986
1011
|
controlClassName = props.controlClassName,
|
|
1012
|
+
controlExClassName = props.controlExClassName,
|
|
1013
|
+
controlGroupWrapperClassName = props.controlGroupWrapperClassName,
|
|
1014
|
+
controlGroupTextClassName = props.controlGroupTextClassName,
|
|
987
1015
|
exceededSidePosOffset = props.exceededSidePosOffset,
|
|
988
1016
|
appearance = props.appearance,
|
|
989
1017
|
isSearchInput = props.isSearchInput,
|
|
1018
|
+
allowSpacingRetrive = props.allowSpacingRetrive,
|
|
990
1019
|
readOnly = props.readOnly,
|
|
991
1020
|
disabled = props.disabled,
|
|
992
1021
|
required = props.required,
|
|
@@ -995,32 +1024,38 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
995
1024
|
value = props.value,
|
|
996
1025
|
label = props.label,
|
|
997
1026
|
name = props.name,
|
|
1027
|
+
units = props.units,
|
|
1028
|
+
iconLeft = props.iconLeft,
|
|
1029
|
+
iconRight = props.iconRight,
|
|
1030
|
+
minLength = props.minLength,
|
|
1031
|
+
maxLength = props.maxLength,
|
|
998
1032
|
id = props.id,
|
|
999
1033
|
icon = props.icon,
|
|
1000
1034
|
btnId = props.btnId,
|
|
1001
1035
|
fetchTrigger = props.fetchTrigger,
|
|
1002
1036
|
hideIcon = props.hideIcon,
|
|
1003
1037
|
depth = props.depth,
|
|
1004
|
-
maxLength = props.maxLength,
|
|
1005
1038
|
style = props.style,
|
|
1006
1039
|
winWidth = props.winWidth,
|
|
1007
1040
|
tabIndex = props.tabIndex,
|
|
1008
1041
|
data = props.data,
|
|
1009
|
-
|
|
1042
|
+
autoShowOptions = props.autoShowOptions,
|
|
1010
1043
|
fetchNoneInfo = props.fetchNoneInfo,
|
|
1011
1044
|
fetchUpdate = props.fetchUpdate,
|
|
1012
1045
|
fetchFuncAsync = props.fetchFuncAsync,
|
|
1013
1046
|
fetchFuncMethod = props.fetchFuncMethod,
|
|
1014
1047
|
fetchFuncMethodParams = props.fetchFuncMethodParams,
|
|
1015
1048
|
fetchCallback = props.fetchCallback,
|
|
1049
|
+
onClick = props.onClick,
|
|
1016
1050
|
onFetch = props.onFetch,
|
|
1017
1051
|
onChange = props.onChange,
|
|
1052
|
+
onKeyboardInput = props.onKeyboardInput,
|
|
1018
1053
|
onBlur = props.onBlur,
|
|
1019
1054
|
attributes = _objectWithoutProperties(props, _excluded);
|
|
1020
1055
|
var DEPTH = depth || 1055; // the default value same as bootstrap
|
|
1021
1056
|
var POS_OFFSET = 0;
|
|
1022
1057
|
var EXCEEDED_SIDE_POS_OFFSET = Number(exceededSidePosOffset) || 15;
|
|
1023
|
-
var
|
|
1058
|
+
var EMPTY_FOR_FETCH = typeof autoShowOptions === 'undefined' || autoShowOptions === false ? false : true;
|
|
1024
1059
|
var WIN_WIDTH = typeof winWidth === 'function' ? winWidth() : winWidth ? winWidth : 'auto';
|
|
1025
1060
|
var uniqueID = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useId)().replace(/\:/g, "-");
|
|
1026
1061
|
var idRes = id || uniqueID;
|
|
@@ -1246,6 +1281,7 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
1246
1281
|
_matchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1247
1282
|
var val,
|
|
1248
1283
|
query,
|
|
1284
|
+
emptyValShowAll,
|
|
1249
1285
|
res,
|
|
1250
1286
|
filterRes,
|
|
1251
1287
|
_oparams,
|
|
@@ -1257,12 +1293,19 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
1257
1293
|
case 0:
|
|
1258
1294
|
val = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : '';
|
|
1259
1295
|
query = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : false;
|
|
1296
|
+
emptyValShowAll = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : false;
|
|
1260
1297
|
res = [];
|
|
1261
1298
|
filterRes = function filterRes(data) {
|
|
1262
1299
|
return data.filter(function (item) {
|
|
1263
1300
|
// Avoid fatal errors causing page crashes
|
|
1264
1301
|
var _queryString = typeof item.queryString !== 'undefined' && item.queryString !== null ? item.queryString : '';
|
|
1265
1302
|
var _val = typeof val !== 'undefined' && val !== null ? val : '';
|
|
1303
|
+
if (emptyValShowAll && val === '') {
|
|
1304
|
+
return true;
|
|
1305
|
+
}
|
|
1306
|
+
if (allowSpacingRetrive && val == ' ') {
|
|
1307
|
+
return true;
|
|
1308
|
+
}
|
|
1266
1309
|
if ((_queryString.split(',').some(function (l) {
|
|
1267
1310
|
return l.charAt(0) === _val.toLowerCase();
|
|
1268
1311
|
}) || _queryString.split(',').some(function (l) {
|
|
@@ -1275,23 +1318,23 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
1275
1318
|
});
|
|
1276
1319
|
};
|
|
1277
1320
|
if (!query) {
|
|
1278
|
-
_context2.next =
|
|
1321
|
+
_context2.next = 15;
|
|
1279
1322
|
break;
|
|
1280
1323
|
}
|
|
1281
1324
|
_oparams = fetchFuncMethodParams || [];
|
|
1282
1325
|
_params = _oparams.map(function (item) {
|
|
1283
1326
|
return item !== '$QUERY_STRING' ? item : val;
|
|
1284
1327
|
});
|
|
1285
|
-
_context2.next =
|
|
1328
|
+
_context2.next = 10;
|
|
1286
1329
|
return fetchData(_params.join(','));
|
|
1287
|
-
case
|
|
1330
|
+
case 10:
|
|
1288
1331
|
response = _context2.sent;
|
|
1289
1332
|
res = filterRes(response);
|
|
1290
1333
|
return _context2.abrupt("return", res);
|
|
1291
|
-
case
|
|
1334
|
+
case 15:
|
|
1292
1335
|
res = filterRes(dataInit);
|
|
1293
1336
|
return _context2.abrupt("return", res);
|
|
1294
|
-
case
|
|
1337
|
+
case 17:
|
|
1295
1338
|
case "end":
|
|
1296
1339
|
return _context2.stop();
|
|
1297
1340
|
}
|
|
@@ -1302,35 +1345,26 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
1302
1345
|
function handleChange(e) {
|
|
1303
1346
|
var val = e.target.value;
|
|
1304
1347
|
setChangedVal(val);
|
|
1305
|
-
if (INPUT_MATCH_ENABLED) {
|
|
1306
|
-
//
|
|
1307
|
-
if (!fetchTrigger) {
|
|
1308
|
-
matchData(val, fetchUpdate).then(function (response) {
|
|
1309
|
-
setOrginalData(response);
|
|
1310
1348
|
|
|
1311
|
-
|
|
1312
|
-
|
|
1349
|
+
//
|
|
1350
|
+
if (!fetchTrigger) {
|
|
1351
|
+
matchData(val, fetchUpdate, EMPTY_FOR_FETCH).then(function (response) {
|
|
1352
|
+
setOrginalData(response);
|
|
1313
1353
|
|
|
1314
|
-
|
|
1315
|
-
|
|
1354
|
+
//
|
|
1355
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, response, '', listRef.current);
|
|
1316
1356
|
|
|
1317
|
-
// window position
|
|
1318
|
-
setTimeout(function () {
|
|
1319
|
-
popwinPosInit();
|
|
1320
|
-
}, 0);
|
|
1321
|
-
});
|
|
1322
|
-
} else {
|
|
1323
1357
|
//
|
|
1324
|
-
|
|
1358
|
+
setIsOpen(true);
|
|
1325
1359
|
|
|
1326
1360
|
// window position
|
|
1327
1361
|
setTimeout(function () {
|
|
1328
1362
|
popwinPosInit();
|
|
1329
1363
|
}, 0);
|
|
1330
|
-
}
|
|
1364
|
+
});
|
|
1331
1365
|
} else {
|
|
1332
1366
|
//
|
|
1333
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, orginalData, '');
|
|
1367
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, orginalData, '', listRef.current);
|
|
1334
1368
|
|
|
1335
1369
|
// window position
|
|
1336
1370
|
setTimeout(function () {
|
|
@@ -1421,7 +1455,7 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
1421
1455
|
break;
|
|
1422
1456
|
}
|
|
1423
1457
|
_data = JSON.parse(dataInput);
|
|
1424
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, orginalData, _data);
|
|
1458
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, orginalData, _data, listRef.current);
|
|
1425
1459
|
setChangedVal(_data.label);
|
|
1426
1460
|
_context4.next = 21;
|
|
1427
1461
|
break;
|
|
@@ -1429,12 +1463,12 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
1429
1463
|
_curData = typeof el.target !== 'undefined' ? el.target.dataset.itemdata : el.dataset.itemdata;
|
|
1430
1464
|
_data2 = JSON.parse(_curData);
|
|
1431
1465
|
res = [];
|
|
1432
|
-
if (
|
|
1466
|
+
if (EMPTY_FOR_FETCH) {
|
|
1433
1467
|
_context4.next = 18;
|
|
1434
1468
|
break;
|
|
1435
1469
|
}
|
|
1436
1470
|
_context4.next = 15;
|
|
1437
|
-
return matchData(inputRef.current.value, false);
|
|
1471
|
+
return matchData(inputRef.current.value, false, EMPTY_FOR_FETCH);
|
|
1438
1472
|
case 15:
|
|
1439
1473
|
res = _context4.sent;
|
|
1440
1474
|
_context4.next = 19;
|
|
@@ -1442,7 +1476,7 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
1442
1476
|
case 18:
|
|
1443
1477
|
res = dataInit;
|
|
1444
1478
|
case 19:
|
|
1445
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, res, _data2);
|
|
1479
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, res, _data2, listRef.current);
|
|
1446
1480
|
setChangedVal(_data2.label);
|
|
1447
1481
|
case 21:
|
|
1448
1482
|
// cancel
|
|
@@ -1470,7 +1504,7 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
1470
1504
|
break;
|
|
1471
1505
|
}
|
|
1472
1506
|
_context5.next = 3;
|
|
1473
|
-
return matchData(changedVal, fetchUpdate);
|
|
1507
|
+
return matchData(changedVal, fetchUpdate, EMPTY_FOR_FETCH);
|
|
1474
1508
|
case 3:
|
|
1475
1509
|
res = _context5.sent;
|
|
1476
1510
|
setOrginalData(res);
|
|
@@ -1491,7 +1525,7 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
1491
1525
|
return _handleFetch.apply(this, arguments);
|
|
1492
1526
|
}
|
|
1493
1527
|
function handleClick() {
|
|
1494
|
-
if (
|
|
1528
|
+
if (EMPTY_FOR_FETCH) {
|
|
1495
1529
|
setOrginalData(dataInit);
|
|
1496
1530
|
setIsOpen(true);
|
|
1497
1531
|
}
|
|
@@ -1500,13 +1534,14 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
1500
1534
|
setTimeout(function () {
|
|
1501
1535
|
popwinPosInit();
|
|
1502
1536
|
}, 0);
|
|
1537
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(inputRef.current, listRef.current);
|
|
1503
1538
|
}
|
|
1504
1539
|
function handleBlur(e) {
|
|
1505
1540
|
setIsOpen(false);
|
|
1506
1541
|
if (!fetchTrigger) {
|
|
1507
1542
|
setTimeout(function () {
|
|
1508
1543
|
//
|
|
1509
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur(inputRef.current);
|
|
1544
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(inputRef.current, listRef.current);
|
|
1510
1545
|
|
|
1511
1546
|
//
|
|
1512
1547
|
cancel();
|
|
@@ -1613,7 +1648,7 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
1613
1648
|
//
|
|
1614
1649
|
onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, _options.map(function (node) {
|
|
1615
1650
|
return JSON.parse(node.dataset.itemdata);
|
|
1616
|
-
}), JSON.parse(currentData));
|
|
1651
|
+
}), JSON.parse(currentData), listRef.current);
|
|
1617
1652
|
}
|
|
1618
1653
|
}
|
|
1619
1654
|
return _context.abrupt("return");
|
|
@@ -1697,13 +1732,27 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
1697
1732
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((dist_cjs_default()), _extends({
|
|
1698
1733
|
wrapperClassName: "",
|
|
1699
1734
|
controlClassName: controlClassName,
|
|
1700
|
-
|
|
1735
|
+
controlExClassName: controlExClassName,
|
|
1736
|
+
controlGroupWrapperClassName: controlGroupWrapperClassName,
|
|
1737
|
+
controlGroupTextClassName: controlGroupTextClassName,
|
|
1738
|
+
ref: function ref(node) {
|
|
1739
|
+
inputRef.current = node;
|
|
1740
|
+
if (typeof _ref2 === 'function') {
|
|
1741
|
+
_ref2(node);
|
|
1742
|
+
} else if (_ref2) {
|
|
1743
|
+
_ref2.current = node;
|
|
1744
|
+
}
|
|
1745
|
+
},
|
|
1701
1746
|
value: changedVal,
|
|
1702
1747
|
label: "",
|
|
1703
1748
|
tabIndex: tabIndex,
|
|
1704
1749
|
id: idRes,
|
|
1705
1750
|
name: name,
|
|
1706
1751
|
placeholder: placeholder,
|
|
1752
|
+
units: units,
|
|
1753
|
+
iconLeft: iconLeft,
|
|
1754
|
+
iconRight: iconRight,
|
|
1755
|
+
minLength: minLength,
|
|
1707
1756
|
maxLength: maxLength,
|
|
1708
1757
|
disabled: disabled,
|
|
1709
1758
|
required: required,
|
|
@@ -1719,7 +1768,10 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
1719
1768
|
icon: hideIcon ? '' : !fetchTrigger ? '' : icon,
|
|
1720
1769
|
btnId: btnId,
|
|
1721
1770
|
autoComplete: "off",
|
|
1722
|
-
isSearchInput: isSearchInput
|
|
1771
|
+
isSearchInput: isSearchInput,
|
|
1772
|
+
onKeyPressedCallback: function onKeyPressedCallback(e) {
|
|
1773
|
+
onKeyboardInput === null || onKeyboardInput === void 0 ? void 0 : onKeyboardInput(e, inputRef.current, listRef.current);
|
|
1774
|
+
}
|
|
1723
1775
|
}, attributes)), orginalData && !hasErr ? /*#__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((cjs_default()), {
|
|
1724
1776
|
show: true,
|
|
1725
1777
|
containerClassName: "LiveSearch"
|
|
@@ -1784,7 +1836,7 @@ var LiveSearch = function LiveSearch(props) {
|
|
|
1784
1836
|
d: "M12.027 9.92L16 13.95 14 16l-4.075-3.976A6.465 6.465 0 0 1 6.5 13C2.91 13 0 10.083 0 6.5 0 2.91 2.917 0 6.5 0 10.09 0 13 2.917 13 6.5a6.463 6.463 0 0 1-.973 3.42zM1.997 6.452c0 2.48 2.014 4.5 4.5 4.5 2.48 0 4.5-2.015 4.5-4.5 0-2.48-2.015-4.5-4.5-4.5-2.48 0-4.5 2.014-4.5 4.5z",
|
|
1785
1837
|
fillRule: "evenodd"
|
|
1786
1838
|
}))))) : null)));
|
|
1787
|
-
};
|
|
1839
|
+
});
|
|
1788
1840
|
/* harmony default export */ const src = (LiveSearch);
|
|
1789
1841
|
})();
|
|
1790
1842
|
|