funda-ui 2.5.105 → 2.6.105

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.
@@ -1,4 +1,11 @@
1
1
  import React from 'react';
2
+ interface OptionConfig {
3
+ disabled?: boolean;
4
+ label: any;
5
+ listItemLabel?: any;
6
+ value: any;
7
+ queryString: string | number;
8
+ }
2
9
  declare type LiveSearchProps = {
3
10
  wrapperClassName?: string;
4
11
  controlClassName?: string;
@@ -9,9 +16,11 @@ declare type LiveSearchProps = {
9
16
  label?: React.ReactNode | string;
10
17
  name?: string;
11
18
  maxLength?: any;
19
+ readOnly?: any;
12
20
  disabled?: any;
13
21
  required?: any;
14
22
  placeholder?: string;
23
+ options?: OptionConfig[] | string;
15
24
  winWidth?: string | Function;
16
25
  icon?: React.ReactNode | string;
17
26
  btnId?: string;
@@ -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", "appearance", "isSearchInput", "disabled", "required", "placeholder", "value", "label", "name", "btnId", "id", "maxLength", "icon", "autoComplete", "style", "tabIndex", "onClick", "onSubmit", "onChange", "onBlur", "onFocus"];
550
+ var _excluded = ["wrapperClassName", "controlClassName", "appearance", "isSearchInput", "readOnly", "disabled", "required", "placeholder", "value", "label", "name", "btnId", "id", "maxLength", "icon", "autoComplete", "style", "tabIndex", "onClick", "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++) {
@@ -643,6 +643,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
643
643
  controlClassName = props.controlClassName,
644
644
  appearance = props.appearance,
645
645
  isSearchInput = props.isSearchInput,
646
+ readOnly = props.readOnly,
646
647
  disabled = props.disabled,
647
648
  required = props.required,
648
649
  placeholder = props.placeholder,
@@ -757,6 +758,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
757
758
  onCompositionUpdate: handleComposition,
758
759
  onCompositionEnd: handleComposition,
759
760
  disabled: disabled || null,
761
+ readOnly: readOnly || null,
760
762
  required: required || null,
761
763
  style: style
762
764
  }, attributes)), 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", {
@@ -953,16 +955,16 @@ var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs);
953
955
  var dist_cjs = __webpack_require__(962);
954
956
  var dist_cjs_default = /*#__PURE__*/__webpack_require__.n(dist_cjs);
955
957
  ;// CONCATENATED MODULE: ./src/index.tsx
956
- var _excluded = ["wrapperClassName", "controlClassName", "exceededSidePosOffset", "appearance", "isSearchInput", "disabled", "required", "placeholder", "value", "label", "name", "id", "icon", "btnId", "fetchTrigger", "hideIcon", "depth", "maxLength", "style", "winWidth", "tabIndex", "data", "fetchAutoShow", "fetchNoneInfo", "fetchUpdate", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "fetchCallback", "onFetch", "onChange", "onBlur"];
958
+ var _excluded = ["wrapperClassName", "controlClassName", "exceededSidePosOffset", "appearance", "isSearchInput", "readOnly", "disabled", "required", "placeholder", "options", "value", "label", "name", "id", "icon", "btnId", "fetchTrigger", "hideIcon", "depth", "maxLength", "style", "winWidth", "tabIndex", "data", "fetchAutoShow", "fetchNoneInfo", "fetchUpdate", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "fetchCallback", "onFetch", "onChange", "onBlur"];
957
959
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
958
960
  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."); }
959
961
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
960
962
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
961
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
962
963
  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); }
963
964
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
964
965
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
965
966
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
967
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
966
968
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
967
969
  function _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."); }
968
970
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -983,9 +985,11 @@ var LiveSearch = function LiveSearch(props) {
983
985
  exceededSidePosOffset = props.exceededSidePosOffset,
984
986
  appearance = props.appearance,
985
987
  isSearchInput = props.isSearchInput,
988
+ readOnly = props.readOnly,
986
989
  disabled = props.disabled,
987
990
  required = props.required,
988
991
  placeholder = props.placeholder,
992
+ options = props.options,
989
993
  value = props.value,
990
994
  label = props.label,
991
995
  name = props.name,
@@ -1021,14 +1025,18 @@ var LiveSearch = function LiveSearch(props) {
1021
1025
  var inputRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
1022
1026
  var listRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
1023
1027
  var listContentRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
1028
+ var optionsRes = options ? isJSON(options) ? JSON.parse(options) : options : [];
1024
1029
  var windowScrollUpdate = (0,performance.debounce)(handleScrollEvent, 500);
1025
1030
 
1031
+ // return a array of options
1032
+ var staticOptionsData = optionsRes;
1033
+
1026
1034
  //
1027
1035
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
1028
1036
  _useState2 = _slicedToArray(_useState, 2),
1029
1037
  firstFetch = _useState2[0],
1030
1038
  setFirstFetch = _useState2[1];
1031
- var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
1039
+ var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(staticOptionsData),
1032
1040
  _useState4 = _slicedToArray(_useState3, 2),
1033
1041
  dataInit = _useState4[0],
1034
1042
  setOrginalDataInit = _useState4[1];
@@ -1058,6 +1066,27 @@ var LiveSearch = function LiveSearch(props) {
1058
1066
  handleChange(e);
1059
1067
  }, 350, [dataInit]);
1060
1068
 
1069
+ // Determine whether it is in JSON format
1070
+ function isJSON(str) {
1071
+ if (typeof str === 'string' && str.length > 0) {
1072
+ if (str.replace(/\"\"/g, '').replace(/\,/g, '') == '[{}]') {
1073
+ return false;
1074
+ } else {
1075
+ if (/^[\],:{}\s]*$/.test(str.replace(/\\["\\\/bfnrtu]/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
1076
+ return true;
1077
+ } else {
1078
+ return false;
1079
+ }
1080
+ }
1081
+ } else {
1082
+ if (_typeof(str) === 'object' && Object.prototype.toString.call(str) === '[object Object]' && !str.length) {
1083
+ return true;
1084
+ } else {
1085
+ return false;
1086
+ }
1087
+ }
1088
+ }
1089
+
1061
1090
  /**
1062
1091
  * Check if an element is in the viewport
1063
1092
  * @param {HTMLElement} elem
@@ -1384,32 +1413,33 @@ var LiveSearch = function LiveSearch(props) {
1384
1413
  _data = JSON.parse(dataInput);
1385
1414
  onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, orginalData, _data);
1386
1415
  setChangedVal(_data.label);
1387
- _context4.next = 21;
1416
+ _context4.next = 22;
1388
1417
  break;
1389
1418
  case 9:
1390
1419
  _curData = typeof el.target !== 'undefined' ? el.target.dataset.itemdata : el.dataset.itemdata;
1420
+ console.log('****', _curData);
1391
1421
  _data2 = JSON.parse(_curData);
1392
1422
  res = [];
1393
1423
  if (!INPUT_MATCH_ENABLED) {
1394
- _context4.next = 18;
1424
+ _context4.next = 19;
1395
1425
  break;
1396
1426
  }
1397
- _context4.next = 15;
1427
+ _context4.next = 16;
1398
1428
  return matchData(inputRef.current.value, false);
1399
- case 15:
1429
+ case 16:
1400
1430
  res = _context4.sent;
1401
- _context4.next = 19;
1431
+ _context4.next = 20;
1402
1432
  break;
1403
- case 18:
1404
- res = dataInit;
1405
1433
  case 19:
1434
+ res = dataInit;
1435
+ case 20:
1406
1436
  onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, res, _data2);
1407
1437
  setChangedVal(_data2.label);
1408
- case 21:
1438
+ case 22:
1409
1439
  // cancel
1410
1440
  setIsOpen(false);
1411
1441
  cancel();
1412
- case 23:
1442
+ case 24:
1413
1443
  case "end":
1414
1444
  return _context4.stop();
1415
1445
  }
@@ -1545,7 +1575,7 @@ var LiveSearch = function LiveSearch(props) {
1545
1575
  //--------------
1546
1576
  var listener = /*#__PURE__*/function () {
1547
1577
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
1548
- var res, currentData, options;
1578
+ var res, currentData, _options;
1549
1579
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1550
1580
  while (1) switch (_context.prev = _context.next) {
1551
1581
  case 0:
@@ -1566,13 +1596,13 @@ var LiveSearch = function LiveSearch(props) {
1566
1596
  handleSelect(null, currentData);
1567
1597
 
1568
1598
  //
1569
- options = [].slice.call(listRef.current.querySelectorAll('.list-group-item:not(.no-match)'));
1570
- options.forEach(function (node) {
1599
+ _options = [].slice.call(listRef.current.querySelectorAll('.list-group-item:not(.no-match)'));
1600
+ _options.forEach(function (node) {
1571
1601
  node.classList.remove('active');
1572
1602
  });
1573
1603
 
1574
1604
  //
1575
- onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, options.map(function (node) {
1605
+ onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, _options.map(function (node) {
1576
1606
  return JSON.parse(node.dataset.itemdata);
1577
1607
  }), JSON.parse(currentData));
1578
1608
  }
@@ -1667,6 +1697,7 @@ var LiveSearch = function LiveSearch(props) {
1667
1697
  maxLength: maxLength,
1668
1698
  disabled: disabled,
1669
1699
  required: required,
1700
+ readOnly: readOnly,
1670
1701
  style: style,
1671
1702
  appearance: appearance,
1672
1703
  onChange: function onChange(e) {
@@ -13,6 +13,7 @@ declare type SearchBarProps = {
13
13
  label?: React.ReactNode | string;
14
14
  name?: string;
15
15
  maxLength?: any;
16
+ readOnly?: any;
16
17
  disabled?: any;
17
18
  required?: any;
18
19
  placeholder?: string;
@@ -96,7 +96,7 @@ __webpack_require__.r(__webpack_exports__);
96
96
  /* harmony export */ });
97
97
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(787);
98
98
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
99
- var _excluded = ["wrapperClassName", "controlClassName", "appearance", "isSearchInput", "disabled", "required", "placeholder", "value", "label", "name", "btnId", "id", "maxLength", "icon", "autoComplete", "style", "tabIndex", "onClick", "onSubmit", "onChange", "onBlur", "onFocus"];
99
+ var _excluded = ["wrapperClassName", "controlClassName", "appearance", "isSearchInput", "readOnly", "disabled", "required", "placeholder", "value", "label", "name", "btnId", "id", "maxLength", "icon", "autoComplete", "style", "tabIndex", "onClick", "onSubmit", "onChange", "onBlur", "onFocus"];
100
100
  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); }
101
101
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
102
102
  function _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."); }
@@ -112,6 +112,7 @@ var SearchBar = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(f
112
112
  controlClassName = props.controlClassName,
113
113
  appearance = props.appearance,
114
114
  isSearchInput = props.isSearchInput,
115
+ readOnly = props.readOnly,
115
116
  disabled = props.disabled,
116
117
  required = props.required,
117
118
  placeholder = props.placeholder,
@@ -226,6 +227,7 @@ var SearchBar = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(f
226
227
  onCompositionUpdate: handleComposition,
227
228
  onCompositionEnd: handleComposition,
228
229
  disabled: disabled || null,
230
+ readOnly: readOnly || null,
229
231
  required: required || null,
230
232
  style: style
231
233
  }, attributes)), 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", {
@@ -1,4 +1,11 @@
1
1
  import React from 'react';
2
+ interface OptionConfig {
3
+ disabled?: boolean;
4
+ label: any;
5
+ listItemLabel?: any;
6
+ value: any;
7
+ queryString: string | number;
8
+ }
2
9
  declare type LiveSearchProps = {
3
10
  wrapperClassName?: string;
4
11
  controlClassName?: string;
@@ -9,9 +16,11 @@ declare type LiveSearchProps = {
9
16
  label?: React.ReactNode | string;
10
17
  name?: string;
11
18
  maxLength?: any;
19
+ readOnly?: any;
12
20
  disabled?: any;
13
21
  required?: any;
14
22
  placeholder?: string;
23
+ options?: OptionConfig[] | string;
15
24
  winWidth?: string | Function;
16
25
  icon?: React.ReactNode | string;
17
26
  btnId?: string;
@@ -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", "appearance", "isSearchInput", "disabled", "required", "placeholder", "value", "label", "name", "btnId", "id", "maxLength", "icon", "autoComplete", "style", "tabIndex", "onClick", "onSubmit", "onChange", "onBlur", "onFocus"];
550
+ var _excluded = ["wrapperClassName", "controlClassName", "appearance", "isSearchInput", "readOnly", "disabled", "required", "placeholder", "value", "label", "name", "btnId", "id", "maxLength", "icon", "autoComplete", "style", "tabIndex", "onClick", "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++) {
@@ -643,6 +643,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
643
643
  controlClassName = props.controlClassName,
644
644
  appearance = props.appearance,
645
645
  isSearchInput = props.isSearchInput,
646
+ readOnly = props.readOnly,
646
647
  disabled = props.disabled,
647
648
  required = props.required,
648
649
  placeholder = props.placeholder,
@@ -757,6 +758,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
757
758
  onCompositionUpdate: handleComposition,
758
759
  onCompositionEnd: handleComposition,
759
760
  disabled: disabled || null,
761
+ readOnly: readOnly || null,
760
762
  required: required || null,
761
763
  style: style
762
764
  }, attributes)), 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", {
@@ -953,16 +955,16 @@ var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs);
953
955
  var dist_cjs = __webpack_require__(962);
954
956
  var dist_cjs_default = /*#__PURE__*/__webpack_require__.n(dist_cjs);
955
957
  ;// CONCATENATED MODULE: ./src/index.tsx
956
- var _excluded = ["wrapperClassName", "controlClassName", "exceededSidePosOffset", "appearance", "isSearchInput", "disabled", "required", "placeholder", "value", "label", "name", "id", "icon", "btnId", "fetchTrigger", "hideIcon", "depth", "maxLength", "style", "winWidth", "tabIndex", "data", "fetchAutoShow", "fetchNoneInfo", "fetchUpdate", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "fetchCallback", "onFetch", "onChange", "onBlur"];
958
+ var _excluded = ["wrapperClassName", "controlClassName", "exceededSidePosOffset", "appearance", "isSearchInput", "readOnly", "disabled", "required", "placeholder", "options", "value", "label", "name", "id", "icon", "btnId", "fetchTrigger", "hideIcon", "depth", "maxLength", "style", "winWidth", "tabIndex", "data", "fetchAutoShow", "fetchNoneInfo", "fetchUpdate", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "fetchCallback", "onFetch", "onChange", "onBlur"];
957
959
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
958
960
  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."); }
959
961
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
960
962
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
961
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
962
963
  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); }
963
964
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
964
965
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
965
966
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
967
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
966
968
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
967
969
  function _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."); }
968
970
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -983,9 +985,11 @@ var LiveSearch = function LiveSearch(props) {
983
985
  exceededSidePosOffset = props.exceededSidePosOffset,
984
986
  appearance = props.appearance,
985
987
  isSearchInput = props.isSearchInput,
988
+ readOnly = props.readOnly,
986
989
  disabled = props.disabled,
987
990
  required = props.required,
988
991
  placeholder = props.placeholder,
992
+ options = props.options,
989
993
  value = props.value,
990
994
  label = props.label,
991
995
  name = props.name,
@@ -1021,14 +1025,18 @@ var LiveSearch = function LiveSearch(props) {
1021
1025
  var inputRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
1022
1026
  var listRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
1023
1027
  var listContentRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
1028
+ var optionsRes = options ? isJSON(options) ? JSON.parse(options) : options : [];
1024
1029
  var windowScrollUpdate = (0,performance.debounce)(handleScrollEvent, 500);
1025
1030
 
1031
+ // return a array of options
1032
+ var staticOptionsData = optionsRes;
1033
+
1026
1034
  //
1027
1035
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
1028
1036
  _useState2 = _slicedToArray(_useState, 2),
1029
1037
  firstFetch = _useState2[0],
1030
1038
  setFirstFetch = _useState2[1];
1031
- var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
1039
+ var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(staticOptionsData),
1032
1040
  _useState4 = _slicedToArray(_useState3, 2),
1033
1041
  dataInit = _useState4[0],
1034
1042
  setOrginalDataInit = _useState4[1];
@@ -1058,6 +1066,27 @@ var LiveSearch = function LiveSearch(props) {
1058
1066
  handleChange(e);
1059
1067
  }, 350, [dataInit]);
1060
1068
 
1069
+ // Determine whether it is in JSON format
1070
+ function isJSON(str) {
1071
+ if (typeof str === 'string' && str.length > 0) {
1072
+ if (str.replace(/\"\"/g, '').replace(/\,/g, '') == '[{}]') {
1073
+ return false;
1074
+ } else {
1075
+ if (/^[\],:{}\s]*$/.test(str.replace(/\\["\\\/bfnrtu]/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
1076
+ return true;
1077
+ } else {
1078
+ return false;
1079
+ }
1080
+ }
1081
+ } else {
1082
+ if (_typeof(str) === 'object' && Object.prototype.toString.call(str) === '[object Object]' && !str.length) {
1083
+ return true;
1084
+ } else {
1085
+ return false;
1086
+ }
1087
+ }
1088
+ }
1089
+
1061
1090
  /**
1062
1091
  * Check if an element is in the viewport
1063
1092
  * @param {HTMLElement} elem
@@ -1384,32 +1413,33 @@ var LiveSearch = function LiveSearch(props) {
1384
1413
  _data = JSON.parse(dataInput);
1385
1414
  onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, orginalData, _data);
1386
1415
  setChangedVal(_data.label);
1387
- _context4.next = 21;
1416
+ _context4.next = 22;
1388
1417
  break;
1389
1418
  case 9:
1390
1419
  _curData = typeof el.target !== 'undefined' ? el.target.dataset.itemdata : el.dataset.itemdata;
1420
+ console.log('****', _curData);
1391
1421
  _data2 = JSON.parse(_curData);
1392
1422
  res = [];
1393
1423
  if (!INPUT_MATCH_ENABLED) {
1394
- _context4.next = 18;
1424
+ _context4.next = 19;
1395
1425
  break;
1396
1426
  }
1397
- _context4.next = 15;
1427
+ _context4.next = 16;
1398
1428
  return matchData(inputRef.current.value, false);
1399
- case 15:
1429
+ case 16:
1400
1430
  res = _context4.sent;
1401
- _context4.next = 19;
1431
+ _context4.next = 20;
1402
1432
  break;
1403
- case 18:
1404
- res = dataInit;
1405
1433
  case 19:
1434
+ res = dataInit;
1435
+ case 20:
1406
1436
  onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, res, _data2);
1407
1437
  setChangedVal(_data2.label);
1408
- case 21:
1438
+ case 22:
1409
1439
  // cancel
1410
1440
  setIsOpen(false);
1411
1441
  cancel();
1412
- case 23:
1442
+ case 24:
1413
1443
  case "end":
1414
1444
  return _context4.stop();
1415
1445
  }
@@ -1545,7 +1575,7 @@ var LiveSearch = function LiveSearch(props) {
1545
1575
  //--------------
1546
1576
  var listener = /*#__PURE__*/function () {
1547
1577
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
1548
- var res, currentData, options;
1578
+ var res, currentData, _options;
1549
1579
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1550
1580
  while (1) switch (_context.prev = _context.next) {
1551
1581
  case 0:
@@ -1566,13 +1596,13 @@ var LiveSearch = function LiveSearch(props) {
1566
1596
  handleSelect(null, currentData);
1567
1597
 
1568
1598
  //
1569
- options = [].slice.call(listRef.current.querySelectorAll('.list-group-item:not(.no-match)'));
1570
- options.forEach(function (node) {
1599
+ _options = [].slice.call(listRef.current.querySelectorAll('.list-group-item:not(.no-match)'));
1600
+ _options.forEach(function (node) {
1571
1601
  node.classList.remove('active');
1572
1602
  });
1573
1603
 
1574
1604
  //
1575
- onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, options.map(function (node) {
1605
+ onChange === null || onChange === void 0 ? void 0 : onChange(inputRef.current, _options.map(function (node) {
1576
1606
  return JSON.parse(node.dataset.itemdata);
1577
1607
  }), JSON.parse(currentData));
1578
1608
  }
@@ -1667,6 +1697,7 @@ var LiveSearch = function LiveSearch(props) {
1667
1697
  maxLength: maxLength,
1668
1698
  disabled: disabled,
1669
1699
  required: required,
1700
+ readOnly: readOnly,
1670
1701
  style: style,
1671
1702
  appearance: appearance,
1672
1703
  onChange: function onChange(e) {
@@ -13,6 +13,7 @@ declare type SearchBarProps = {
13
13
  label?: React.ReactNode | string;
14
14
  name?: string;
15
15
  maxLength?: any;
16
+ readOnly?: any;
16
17
  disabled?: any;
17
18
  required?: any;
18
19
  placeholder?: string;
@@ -96,7 +96,7 @@ __webpack_require__.r(__webpack_exports__);
96
96
  /* harmony export */ });
97
97
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(787);
98
98
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
99
- var _excluded = ["wrapperClassName", "controlClassName", "appearance", "isSearchInput", "disabled", "required", "placeholder", "value", "label", "name", "btnId", "id", "maxLength", "icon", "autoComplete", "style", "tabIndex", "onClick", "onSubmit", "onChange", "onBlur", "onFocus"];
99
+ var _excluded = ["wrapperClassName", "controlClassName", "appearance", "isSearchInput", "readOnly", "disabled", "required", "placeholder", "value", "label", "name", "btnId", "id", "maxLength", "icon", "autoComplete", "style", "tabIndex", "onClick", "onSubmit", "onChange", "onBlur", "onFocus"];
100
100
  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); }
101
101
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
102
102
  function _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."); }
@@ -112,6 +112,7 @@ var SearchBar = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(f
112
112
  controlClassName = props.controlClassName,
113
113
  appearance = props.appearance,
114
114
  isSearchInput = props.isSearchInput,
115
+ readOnly = props.readOnly,
115
116
  disabled = props.disabled,
116
117
  required = props.required,
117
118
  placeholder = props.placeholder,
@@ -226,6 +227,7 @@ var SearchBar = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(f
226
227
  onCompositionUpdate: handleComposition,
227
228
  onCompositionEnd: handleComposition,
228
229
  disabled: disabled || null,
230
+ readOnly: readOnly || null,
229
231
  required: required || null,
230
232
  style: style
231
233
  }, attributes)), 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", {
@@ -8,6 +8,14 @@ import { getAbsolutePositionOfStage } from './utils/get-element-property';
8
8
  import RootPortal from 'funda-root-portal';
9
9
  import SearchBar from 'funda-searchbar';
10
10
 
11
+ interface OptionConfig {
12
+ disabled?: boolean;
13
+ label: any;
14
+ listItemLabel?: any;
15
+ value: any;
16
+ queryString: string | number;
17
+ }
18
+
11
19
 
12
20
  type LiveSearchProps = {
13
21
  wrapperClassName?: string;
@@ -19,9 +27,11 @@ type LiveSearchProps = {
19
27
  label?: React.ReactNode | string;
20
28
  name?: string;
21
29
  maxLength?: any;
30
+ readOnly?: any;
22
31
  disabled?: any;
23
32
  required?: any;
24
33
  placeholder?: string;
34
+ options?: OptionConfig[] | string;
25
35
  winWidth?: string | Function;
26
36
  icon?: React.ReactNode | string;
27
37
  btnId?: string;
@@ -57,9 +67,11 @@ const LiveSearch = (props: LiveSearchProps) => {
57
67
  exceededSidePosOffset,
58
68
  appearance,
59
69
  isSearchInput,
70
+ readOnly,
60
71
  disabled,
61
72
  required,
62
73
  placeholder,
74
+ options,
63
75
  value,
64
76
  label,
65
77
  name,
@@ -98,13 +110,15 @@ const LiveSearch = (props: LiveSearchProps) => {
98
110
  const inputRef = useRef<any>(null);
99
111
  const listRef = useRef<any>(null);
100
112
  const listContentRef = useRef<any>(null);
113
+ const optionsRes = options ? (isJSON(options) ? JSON.parse(options as string) : options) : [];
101
114
  const windowScrollUpdate = debounce(handleScrollEvent, 500);
102
115
 
103
-
116
+ // return a array of options
117
+ let staticOptionsData: OptionConfig[] = optionsRes;
104
118
 
105
119
  //
106
120
  const [firstFetch, setFirstFetch] = useState<boolean>(false);
107
- const [dataInit, setOrginalDataInit] = useState<any[]>([]);
121
+ const [dataInit, setOrginalDataInit] = useState<any[]>(staticOptionsData);
108
122
  const [orginalData, setOrginalData] = useState<any[]>([]);
109
123
  const [changedVal, setChangedVal] = useState<string>(value || '');
110
124
  const [isOpen, setIsOpen] = useState<boolean>(false);
@@ -118,7 +132,42 @@ const LiveSearch = (props: LiveSearchProps) => {
118
132
  }, 350, [dataInit]);
119
133
 
120
134
 
135
+ // Determine whether it is in JSON format
136
+ function isJSON(str: any) {
137
+
138
+ if (typeof (str) === 'string' && str.length > 0) {
139
+
140
+ if (str.replace(/\"\"/g, '').replace(/\,/g, '') == '[{}]') {
141
+ return false;
142
+ } else {
143
+
144
+ if (/^[\],:{}\s]*$/.test(str.replace(/\\["\\\/bfnrtu]/g, '@').
145
+ replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
146
+ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
147
+
148
+ return true;
121
149
 
150
+ } else {
151
+ return false;
152
+ }
153
+
154
+ }
155
+
156
+ } else {
157
+
158
+ if (
159
+ typeof (str) === 'object' &&
160
+ Object.prototype.toString.call(str) === '[object Object]' &&
161
+ !str.length
162
+ ) {
163
+ return true;
164
+ } else {
165
+ return false;
166
+ }
167
+
168
+ }
169
+
170
+ }
122
171
 
123
172
  /**
124
173
  * Check if an element is in the viewport
@@ -472,6 +521,8 @@ const LiveSearch = (props: LiveSearchProps) => {
472
521
 
473
522
  } else {
474
523
  const _curData = typeof el.target !== 'undefined' ? el.target.dataset.itemdata : el.dataset.itemdata;
524
+ console.log('****', _curData);
525
+
475
526
  const _data = JSON.parse(_curData);
476
527
 
477
528
  let res: any = [];
@@ -741,6 +792,7 @@ const LiveSearch = (props: LiveSearchProps) => {
741
792
  maxLength={maxLength}
742
793
  disabled={disabled}
743
794
  required={required}
795
+ readOnly={readOnly}
744
796
  style={style}
745
797
  appearance={appearance}
746
798
  onChange={(e: any) => {
@@ -15,6 +15,7 @@ type SearchBarProps = {
15
15
  label?: React.ReactNode | string;
16
16
  name?: string;
17
17
  maxLength?: any;
18
+ readOnly?: any;
18
19
  disabled?: any;
19
20
  required?: any;
20
21
  placeholder?: string;
@@ -39,6 +40,7 @@ const SearchBar = forwardRef((props: SearchBarProps, ref: any) => {
39
40
  controlClassName,
40
41
  appearance,
41
42
  isSearchInput,
43
+ readOnly,
42
44
  disabled,
43
45
  required,
44
46
  placeholder,
@@ -162,6 +164,7 @@ const SearchBar = forwardRef((props: SearchBarProps, ref: any) => {
162
164
  onCompositionUpdate={handleComposition}
163
165
  onCompositionEnd={handleComposition}
164
166
  disabled={disabled || null}
167
+ readOnly={readOnly || null}
165
168
  required={required || null}
166
169
  style={style}
167
170
  {...attributes}
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": "2.5.105",
5
+ "version": "2.6.105",
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",