funda-ui 4.4.15 → 4.5.12

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.
Files changed (77) hide show
  1. package/Date/index.js +1078 -77
  2. package/EventCalendar/index.css +114 -114
  3. package/EventCalendar/index.d.ts +1 -0
  4. package/EventCalendar/index.js +124 -86
  5. package/EventCalendarTimeline/index.css +274 -270
  6. package/EventCalendarTimeline/index.d.ts +3 -0
  7. package/EventCalendarTimeline/index.js +673 -225
  8. package/Input/index.d.ts +7 -0
  9. package/Input/index.js +699 -57
  10. package/MasonryLayout/index.js +11 -1
  11. package/MultipleCheckboxes/index.js +11 -11
  12. package/MultipleSelect/index.d.ts +1 -0
  13. package/MultipleSelect/index.js +18 -16
  14. package/NativeSelect/index.js +11 -11
  15. package/Radio/index.js +11 -11
  16. package/RangeSlider/index.js +1078 -77
  17. package/Select/index.js +45 -13
  18. package/Table/index.css +1 -0
  19. package/Table/index.js +36 -7
  20. package/TagInput/index.d.ts +1 -0
  21. package/TagInput/index.js +20 -2
  22. package/Textarea/index.d.ts +7 -0
  23. package/Textarea/index.js +707 -10
  24. package/Tree/index.js +13 -11
  25. package/Utils/inputsCalculation.d.ts +18 -1
  26. package/Utils/inputsCalculation.js +26 -0
  27. package/Utils/object.js +11 -11
  28. package/Utils/os.d.ts +2 -0
  29. package/Utils/os.js +104 -0
  30. package/lib/cjs/Date/index.js +1078 -77
  31. package/lib/cjs/EventCalendar/index.d.ts +1 -0
  32. package/lib/cjs/EventCalendar/index.js +124 -86
  33. package/lib/cjs/EventCalendarTimeline/index.d.ts +3 -0
  34. package/lib/cjs/EventCalendarTimeline/index.js +673 -225
  35. package/lib/cjs/Input/index.d.ts +7 -0
  36. package/lib/cjs/Input/index.js +699 -57
  37. package/lib/cjs/MasonryLayout/index.js +11 -1
  38. package/lib/cjs/MultipleCheckboxes/index.js +11 -11
  39. package/lib/cjs/MultipleSelect/index.d.ts +1 -0
  40. package/lib/cjs/MultipleSelect/index.js +18 -16
  41. package/lib/cjs/NativeSelect/index.js +11 -11
  42. package/lib/cjs/Radio/index.js +11 -11
  43. package/lib/cjs/RangeSlider/index.js +1078 -77
  44. package/lib/cjs/Select/index.js +45 -13
  45. package/lib/cjs/Table/index.js +36 -7
  46. package/lib/cjs/TagInput/index.d.ts +1 -0
  47. package/lib/cjs/TagInput/index.js +20 -2
  48. package/lib/cjs/Textarea/index.d.ts +7 -0
  49. package/lib/cjs/Textarea/index.js +707 -10
  50. package/lib/cjs/Tree/index.js +13 -11
  51. package/lib/cjs/Utils/inputsCalculation.d.ts +18 -1
  52. package/lib/cjs/Utils/inputsCalculation.js +26 -0
  53. package/lib/cjs/Utils/object.js +11 -11
  54. package/lib/cjs/Utils/os.d.ts +2 -0
  55. package/lib/cjs/Utils/os.js +104 -0
  56. package/lib/css/EventCalendar/index.css +114 -114
  57. package/lib/css/EventCalendarTimeline/index.css +274 -270
  58. package/lib/css/Table/index.css +1 -0
  59. package/lib/esm/EventCalendar/index.scss +81 -81
  60. package/lib/esm/EventCalendar/index.tsx +144 -104
  61. package/lib/esm/EventCalendarTimeline/index.scss +226 -221
  62. package/lib/esm/EventCalendarTimeline/index.tsx +791 -517
  63. package/lib/esm/Input/index.tsx +299 -77
  64. package/lib/esm/MasonryLayout/index.tsx +9 -2
  65. package/lib/esm/ModalDialog/index.tsx +0 -1
  66. package/lib/esm/MultipleSelect/index.tsx +6 -4
  67. package/lib/esm/Table/Table.tsx +0 -1
  68. package/lib/esm/Table/index.scss +2 -0
  69. package/lib/esm/Table/utils/hooks/useTableDraggable.tsx +47 -6
  70. package/lib/esm/TagInput/index.tsx +23 -1
  71. package/lib/esm/Textarea/index.tsx +332 -39
  72. package/lib/esm/Tree/TreeList.tsx +4 -1
  73. package/lib/esm/Tree/index.tsx +1 -0
  74. package/lib/esm/Utils/libs/inputsCalculation.ts +60 -31
  75. package/lib/esm/Utils/libs/object.ts +67 -67
  76. package/lib/esm/Utils/libs/os.ts +63 -0
  77. package/package.json +1 -1
package/Textarea/index.js CHANGED
@@ -225,6 +225,235 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
225
225
 
226
226
  /***/ }),
227
227
 
228
+ /***/ 954:
229
+ /***/ (function(module, exports, __webpack_require__) {
230
+
231
+ /* module decorator */ module = __webpack_require__.nmd(module);
232
+ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;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); }
233
+ (function webpackUniversalModuleDefinition(root, factory) {
234
+ if (( false ? 0 : _typeof(exports)) === 'object' && ( false ? 0 : _typeof(module)) === 'object') module.exports = factory();else if (true) !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
235
+ __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
236
+ (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
237
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));else {}
238
+ })(this, function () {
239
+ return (/******/function () {
240
+ // webpackBootstrap
241
+ /******/
242
+ "use strict";
243
+
244
+ /******/ // The require scope
245
+ /******/
246
+ var __nested_webpack_require_987__ = {};
247
+ /******/
248
+ /************************************************************************/
249
+ /******/ /* webpack/runtime/define property getters */
250
+ /******/
251
+ (function () {
252
+ /******/ // define getter functions for harmony exports
253
+ /******/__nested_webpack_require_987__.d = function (exports, definition) {
254
+ /******/for (var key in definition) {
255
+ /******/if (__nested_webpack_require_987__.o(definition, key) && !__nested_webpack_require_987__.o(exports, key)) {
256
+ /******/Object.defineProperty(exports, key, {
257
+ enumerable: true,
258
+ get: definition[key]
259
+ });
260
+ /******/
261
+ }
262
+ /******/
263
+ }
264
+ /******/
265
+ };
266
+ /******/
267
+ })();
268
+ /******/
269
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
270
+ /******/
271
+ (function () {
272
+ /******/__nested_webpack_require_987__.o = function (obj, prop) {
273
+ return Object.prototype.hasOwnProperty.call(obj, prop);
274
+ };
275
+ /******/
276
+ })();
277
+ /******/
278
+ /******/ /* webpack/runtime/make namespace object */
279
+ /******/
280
+ (function () {
281
+ /******/ // define __esModule on exports
282
+ /******/__nested_webpack_require_987__.r = function (exports) {
283
+ /******/if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
284
+ /******/Object.defineProperty(exports, Symbol.toStringTag, {
285
+ value: 'Module'
286
+ });
287
+ /******/
288
+ }
289
+ /******/
290
+ Object.defineProperty(exports, '__esModule', {
291
+ value: true
292
+ });
293
+ /******/
294
+ };
295
+ /******/
296
+ })();
297
+ /******/
298
+ /************************************************************************/
299
+ var __webpack_exports__ = {};
300
+ __nested_webpack_require_987__.r(__webpack_exports__);
301
+ /* harmony export */
302
+ __nested_webpack_require_987__.d(__webpack_exports__, {
303
+ /* harmony export */"actualPropertyValue": function actualPropertyValue() {
304
+ return (/* binding */_actualPropertyValue
305
+ );
306
+ },
307
+ /* harmony export */"getTextTop": function getTextTop() {
308
+ return (/* binding */_getTextTop
309
+ );
310
+ },
311
+ /* harmony export */"getTextWidth": function getTextWidth() {
312
+ return (/* binding */_getTextWidth
313
+ );
314
+ }
315
+ /* harmony export */
316
+ });
317
+ /**
318
+ * Gets the relative upside of the text
319
+ * @param {Element} el - A DOM node containing one selector to match against.
320
+ * @returns {Number} - Returns a pure number.
321
+ */
322
+ function _getTextTop(el) {
323
+ var styles = window.getComputedStyle(el);
324
+ var fontSize = parseFloat(styles.fontSize);
325
+ var lineHeight = parseFloat(styles.lineHeight) || fontSize;
326
+ var paddingTop = parseFloat(styles.paddingTop);
327
+ var borderWidth = parseFloat(styles.borderWidth);
328
+ var textTop = paddingTop + (lineHeight - fontSize) / 2 - borderWidth * 2;
329
+ return textTop;
330
+ }
331
+
332
+ /**
333
+ * Get the actual value with user specific methed
334
+ * it can be 'width', 'height', 'outerWidth', 'outerHeight'
335
+ * @private
336
+ * @param {Element} el - A DOM node containing one selector to match against.
337
+ * @param {String} prop - A string naming the property of style.
338
+ * @param {?Json} config - Whether or not margin is included. The key `includeMargin`
339
+ takes effect when set to true
340
+ * @return {Number} - Returns a pure number.
341
+ */
342
+ function _actualPropertyValue(el, prop) {
343
+ var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
344
+ if (el === null) return 0;
345
+ var style = window.getComputedStyle ? window.getComputedStyle(el) : el.currentStyle,
346
+ display = style.display,
347
+ position = style.position,
348
+ visibility = style.visibility;
349
+ var marginWidth = 0;
350
+ var marginHeight = 0;
351
+ var maxVal;
352
+ var actualVal;
353
+ if (config && config.includeMargin === true) {
354
+ marginWidth = parseFloat(style.marginLeft) + parseFloat(style.marginRight);
355
+ marginHeight = parseFloat(style.marginTop) + parseFloat(style.marginBottom);
356
+ }
357
+ if (prop === 'fontSize') {
358
+ actualVal = parseFloat(style.fontSize);
359
+ }
360
+ if (prop === 'fontFamily') {
361
+ actualVal = style.fontFamily;
362
+ }
363
+ if (prop === 'letterSpacing') {
364
+ actualVal = style.letterSpacing;
365
+ }
366
+ if (prop === 'width') {
367
+ maxVal = parseFloat(style.maxWidth);
368
+
369
+ // if its not hidden we just return normal height
370
+ if (display !== 'none' && maxVal !== 0) {
371
+ return el.clientWidth;
372
+ }
373
+ }
374
+ if (prop === 'height') {
375
+ maxVal = parseFloat(style.maxHeight);
376
+ if (display !== 'none' && maxVal !== 0) {
377
+ return el.clientHeight;
378
+ }
379
+ }
380
+ if (prop === 'outerWidth') {
381
+ maxVal = parseFloat(style.maxWidth);
382
+ if (display !== 'none' && maxVal !== 0) {
383
+ return el.offsetWidth + marginWidth;
384
+ }
385
+ }
386
+ if (prop === 'outerHeight') {
387
+ maxVal = parseFloat(style.maxHeight);
388
+ if (display !== 'none' && maxVal !== 0) {
389
+ return el.offsetHeight + marginHeight;
390
+ }
391
+ }
392
+
393
+ // the element is hidden so:
394
+ // making the el block so we can meassure its height but still be hidden
395
+ el.style.position = 'absolute';
396
+ el.style.visibility = 'hidden';
397
+ el.style.display = 'block';
398
+ if (prop === 'width') actualVal = el.clientWidth;
399
+ if (prop === 'height') actualVal = el.clientHeight;
400
+ if (prop === 'outerWidth') actualVal = el.offsetWidth + marginWidth;
401
+ if (prop === 'outerHeight') actualVal = el.offsetHeight + marginHeight;
402
+
403
+ // reverting to the original values
404
+ el.style.display = display;
405
+ el.style.position = position;
406
+ el.style.visibility = visibility;
407
+ return actualVal;
408
+ }
409
+ function getElCSS(input, prop, isNumber) {
410
+ var _document$defaultView;
411
+ var val = (_document$defaultView = document.defaultView) === null || _document$defaultView === void 0 ? void 0 : _document$defaultView.getComputedStyle(input, null).getPropertyValue(prop);
412
+ return isNumber ? isNaN(parseFloat(val)) ? 0 : parseFloat(val) : val;
413
+ }
414
+
415
+ /**
416
+ * Get cursor or text position in pixels for input element
417
+ *
418
+ * @param {HTMLInputElement} input Required HTMLElement with `value` attribute
419
+ * @param {HTMLSpanElement} fauxContainer Container of faux.
420
+ * @param {HTMLElement} rawTextContainer The raw text container for the comparison
421
+ * @returns {Number}
422
+ */
423
+
424
+ function _getTextWidth(input, fauxContainer, rawTextContainer) {
425
+ if (input === null || fauxContainer === null || rawTextContainer === null) return 0;
426
+ var _off = input.selectionStart;
427
+ var _faux = fauxContainer;
428
+ var _fauxContainer = rawTextContainer;
429
+ if (_faux && _fauxContainer) {
430
+ // Styles to simulate a node in an input field
431
+ // use pre-wrap instead of wrap for white-space to support wrapping in textareas
432
+ var listOfModifiers = ['direction', 'font-family', 'font-size', 'font-size-adjust', 'font-variant', 'font-weight', 'font-style', 'letter-spacing', 'line-height', 'text-align', 'text-indent', 'text-transform', 'word-wrap', 'word-spacing'];
433
+
434
+ // default styles
435
+ _faux.style.setProperty('white-space', 'pre-wrap');
436
+ _faux.style.setProperty('padding', '0');
437
+ _faux.style.setProperty('margin', '0');
438
+ _faux.style.setProperty('display', 'none');
439
+ for (var i = 0; i < listOfModifiers.length; i++) {
440
+ var propertyValue = getElCSS(_fauxContainer, listOfModifiers[i], false);
441
+ _faux.style.setProperty(listOfModifiers[i], propertyValue);
442
+ }
443
+ _faux.textContent = input.value.substring(0, _off).replace(/\s/g, "\xA0");
444
+ return _actualPropertyValue(_faux, 'outerWidth');
445
+ }
446
+ }
447
+
448
+ /******/
449
+ return __webpack_exports__;
450
+ /******/
451
+ }()
452
+ );
453
+ });
454
+
455
+ /***/ }),
456
+
228
457
  /***/ 372:
229
458
  /***/ (function(module, exports, __webpack_require__) {
230
459
 
@@ -683,6 +912,198 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
683
912
 
684
913
  /***/ }),
685
914
 
915
+ /***/ 702:
916
+ /***/ (function(module, exports, __webpack_require__) {
917
+
918
+ /* module decorator */ module = __webpack_require__.nmd(module);
919
+ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;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); }
920
+ (function webpackUniversalModuleDefinition(root, factory) {
921
+ if (( false ? 0 : _typeof(exports)) === 'object' && ( false ? 0 : _typeof(module)) === 'object') module.exports = factory(__webpack_require__(787));else if (true) !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(787)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
922
+ __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
923
+ (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
924
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));else {}
925
+ })(this, function (__WEBPACK_EXTERNAL_MODULE__787__) {
926
+ return (/******/function () {
927
+ // webpackBootstrap
928
+ /******/
929
+ "use strict";
930
+
931
+ /******/
932
+ var __webpack_modules__ = {
933
+ /***/787: /***/function _(module) {
934
+ module.exports = __WEBPACK_EXTERNAL_MODULE__787__;
935
+
936
+ /***/
937
+ }
938
+
939
+ /******/
940
+ };
941
+ /************************************************************************/
942
+ /******/ // The module cache
943
+ /******/
944
+ var __webpack_module_cache__ = {};
945
+ /******/
946
+ /******/ // The require function
947
+ /******/
948
+ function __nested_webpack_require_1465__(moduleId) {
949
+ /******/ // Check if module is in cache
950
+ /******/var cachedModule = __webpack_module_cache__[moduleId];
951
+ /******/
952
+ if (cachedModule !== undefined) {
953
+ /******/return cachedModule.exports;
954
+ /******/
955
+ }
956
+ /******/ // Create a new module (and put it into the cache)
957
+ /******/
958
+ var module = __webpack_module_cache__[moduleId] = {
959
+ /******/ // no module.id needed
960
+ /******/ // no module.loaded needed
961
+ /******/exports: {}
962
+ /******/
963
+ };
964
+ /******/
965
+ /******/ // Execute the module function
966
+ /******/
967
+ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_1465__);
968
+ /******/
969
+ /******/ // Return the exports of the module
970
+ /******/
971
+ return module.exports;
972
+ /******/
973
+ }
974
+ /******/
975
+ /************************************************************************/
976
+ /******/ /* webpack/runtime/compat get default export */
977
+ /******/
978
+ (function () {
979
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
980
+ /******/__nested_webpack_require_1465__.n = function (module) {
981
+ /******/var getter = module && module.__esModule ? /******/function () {
982
+ return module['default'];
983
+ } : /******/function () {
984
+ return module;
985
+ };
986
+ /******/
987
+ __nested_webpack_require_1465__.d(getter, {
988
+ a: getter
989
+ });
990
+ /******/
991
+ return getter;
992
+ /******/
993
+ };
994
+ /******/
995
+ })();
996
+ /******/
997
+ /******/ /* webpack/runtime/define property getters */
998
+ /******/
999
+ (function () {
1000
+ /******/ // define getter functions for harmony exports
1001
+ /******/__nested_webpack_require_1465__.d = function (exports, definition) {
1002
+ /******/for (var key in definition) {
1003
+ /******/if (__nested_webpack_require_1465__.o(definition, key) && !__nested_webpack_require_1465__.o(exports, key)) {
1004
+ /******/Object.defineProperty(exports, key, {
1005
+ enumerable: true,
1006
+ get: definition[key]
1007
+ });
1008
+ /******/
1009
+ }
1010
+ /******/
1011
+ }
1012
+ /******/
1013
+ };
1014
+ /******/
1015
+ })();
1016
+ /******/
1017
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
1018
+ /******/
1019
+ (function () {
1020
+ /******/__nested_webpack_require_1465__.o = function (obj, prop) {
1021
+ return Object.prototype.hasOwnProperty.call(obj, prop);
1022
+ };
1023
+ /******/
1024
+ })();
1025
+ /******/
1026
+ /******/ /* webpack/runtime/make namespace object */
1027
+ /******/
1028
+ (function () {
1029
+ /******/ // define __esModule on exports
1030
+ /******/__nested_webpack_require_1465__.r = function (exports) {
1031
+ /******/if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1032
+ /******/Object.defineProperty(exports, Symbol.toStringTag, {
1033
+ value: 'Module'
1034
+ });
1035
+ /******/
1036
+ }
1037
+ /******/
1038
+ Object.defineProperty(exports, '__esModule', {
1039
+ value: true
1040
+ });
1041
+ /******/
1042
+ };
1043
+ /******/
1044
+ })();
1045
+ /******/
1046
+ /************************************************************************/
1047
+ var __webpack_exports__ = {};
1048
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
1049
+ (function () {
1050
+ __nested_webpack_require_1465__.r(__webpack_exports__);
1051
+ /* harmony export */
1052
+ __nested_webpack_require_1465__.d(__webpack_exports__, {
1053
+ /* harmony export */"default": function _default() {
1054
+ return __WEBPACK_DEFAULT_EXPORT__;
1055
+ }
1056
+ /* harmony export */
1057
+ });
1058
+ /* harmony import */
1059
+ var react__WEBPACK_IMPORTED_MODULE_0__ = __nested_webpack_require_1465__(787);
1060
+ /* harmony import */
1061
+ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nested_webpack_require_1465__.n(react__WEBPACK_IMPORTED_MODULE_0__);
1062
+ /**
1063
+ * Delay the execution of function or state update
1064
+ *
1065
+ * @usage:
1066
+
1067
+ const App = () => {
1068
+ const [count, setCount] = useState(0);
1069
+ const handleClick = useDebounce(() => setCount(count + 1), 500, [count]);
1070
+
1071
+ return (
1072
+ <div className="app">
1073
+ <button onClick={handleClick}>click</button>
1074
+ <p>click {count} time</p>
1075
+ </div>
1076
+ );
1077
+ };
1078
+
1079
+ */
1080
+
1081
+ var useDebounce = function useDebounce(fn, delay, dependence) {
1082
+ var ref = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
1083
+ return (0, react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
1084
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1085
+ args[_key] = arguments[_key];
1086
+ }
1087
+ clearTimeout(ref.current);
1088
+ ref.current = null;
1089
+ ref.current = setTimeout(function () {
1090
+ fn.apply(void 0, args);
1091
+ }, delay);
1092
+ }, dependence);
1093
+ };
1094
+ /* harmony default export */
1095
+ var __WEBPACK_DEFAULT_EXPORT__ = useDebounce;
1096
+ })();
1097
+
1098
+ /******/
1099
+ return __webpack_exports__;
1100
+ /******/
1101
+ }()
1102
+ );
1103
+ });
1104
+
1105
+ /***/ }),
1106
+
686
1107
  /***/ 787:
687
1108
  /***/ ((module) => {
688
1109
 
@@ -787,8 +1208,20 @@ __webpack_require__.r(__webpack_exports__);
787
1208
  /* harmony import */ var funda_utils_dist_cjs_useAutosizeTextArea__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_useAutosizeTextArea__WEBPACK_IMPORTED_MODULE_2__);
788
1209
  /* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(188);
789
1210
  /* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__);
790
- var _excluded = ["contentRef", "wrapperClassName", "controlClassName", "controlExClassName", "controlGroupWrapperClassName", "controlGroupTextClassName", "cols", "rows", "disabled", "required", "placeholder", "autoSize", "iconLeft", "iconRight", "readOnly", "defaultValue", "value", "requiredLabel", "label", "name", "id", "minLength", "maxLength", "style", "tabIndex", "onChangeCallback", "onInputCallback", "onKeyPressedCallback", "onChange", "onBlur", "onFocus", "onPressEnter", "onResize"];
1211
+ /* harmony import */ var funda_utils_dist_cjs_inputsCalculation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(954);
1212
+ /* harmony import */ var funda_utils_dist_cjs_inputsCalculation__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_inputsCalculation__WEBPACK_IMPORTED_MODULE_4__);
1213
+ /* harmony import */ var funda_utils_dist_cjs_useDebounce__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(702);
1214
+ /* harmony import */ var funda_utils_dist_cjs_useDebounce__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_useDebounce__WEBPACK_IMPORTED_MODULE_5__);
1215
+ var _excluded = ["contentRef", "wrapperClassName", "controlClassName", "controlExClassName", "controlGroupWrapperClassName", "controlGroupTextClassName", "cols", "rows", "disabled", "required", "placeholder", "autoSize", "iconLeft", "iconRight", "aiPredict", "aiPredictRemainingTextRGB", "aiPredictConfirmKey", "aiPredictFetchFuncAsync", "aiPredictFetchFuncMethod", "aiPredictFetchFuncMethodParams", "aiPredictFetchCallback", "readOnly", "defaultValue", "value", "requiredLabel", "label", "name", "id", "minLength", "maxLength", "style", "tabIndex", "onChangeCallback", "onInputCallback", "onKeyPressedCallback", "onChange", "onBlur", "onFocus", "onPressEnter", "onResize"];
1216
+ 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; }
1217
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
1218
+ 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."); }
1219
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
1220
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
1221
+ 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); }
791
1222
  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); }
1223
+ 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); } }
1224
+ 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); }); }; }
792
1225
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
793
1226
  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."); }
794
1227
  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); }
@@ -801,6 +1234,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
801
1234
 
802
1235
 
803
1236
 
1237
+
1238
+
804
1239
  var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(function (props, externalRef) {
805
1240
  var contentRef = props.contentRef,
806
1241
  wrapperClassName = props.wrapperClassName,
@@ -816,6 +1251,16 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
816
1251
  autoSize = props.autoSize,
817
1252
  iconLeft = props.iconLeft,
818
1253
  iconRight = props.iconRight,
1254
+ _props$aiPredict = props.aiPredict,
1255
+ aiPredict = _props$aiPredict === void 0 ? false : _props$aiPredict,
1256
+ _props$aiPredictRemai = props.aiPredictRemainingTextRGB,
1257
+ aiPredictRemainingTextRGB = _props$aiPredictRemai === void 0 ? [153, 153, 153] : _props$aiPredictRemai,
1258
+ _props$aiPredictConfi = props.aiPredictConfirmKey,
1259
+ aiPredictConfirmKey = _props$aiPredictConfi === void 0 ? [['Enter'], ['Tab'], ['Shift', ' ']] : _props$aiPredictConfi,
1260
+ aiPredictFetchFuncAsync = props.aiPredictFetchFuncAsync,
1261
+ aiPredictFetchFuncMethod = props.aiPredictFetchFuncMethod,
1262
+ aiPredictFetchFuncMethodParams = props.aiPredictFetchFuncMethodParams,
1263
+ aiPredictFetchCallback = props.aiPredictFetchCallback,
819
1264
  readOnly = props.readOnly,
820
1265
  defaultValue = props.defaultValue,
821
1266
  value = props.value,
@@ -845,6 +1290,183 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
845
1290
  changedVal = _useState2[0],
846
1291
  setChangedVal = _useState2[1];
847
1292
 
1293
+ //================================================================
1294
+ // AI Predict
1295
+ //================================================================
1296
+ var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(''),
1297
+ _useState4 = _slicedToArray(_useState3, 2),
1298
+ currentSuggestion = _useState4[0],
1299
+ setCurrentSuggestion = _useState4[1];
1300
+ var _useState5 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]),
1301
+ _useState6 = _slicedToArray(_useState5, 2),
1302
+ tempMatchedSuggestion = _useState6[0],
1303
+ setTempMatchedSuggestion = _useState6[1];
1304
+ var _useState7 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(0),
1305
+ _useState8 = _slicedToArray(_useState7, 2),
1306
+ textWidth = _useState8[0],
1307
+ setTextWidth = _useState8[1];
1308
+ var aiInputRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
1309
+ var originInputComputedStyle = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)({
1310
+ fontSize: 16,
1311
+ fontFamily: 'inherit',
1312
+ letterSpacing: 'normal',
1313
+ textTop: 10
1314
+ });
1315
+ var _useState9 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
1316
+ _useState10 = _slicedToArray(_useState9, 2),
1317
+ hasErr = _useState10[0],
1318
+ setHasErr = _useState10[1];
1319
+ var currentSuggestionIndex = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(0);
1320
+
1321
+ // A list of suggestions
1322
+ //----------------
1323
+ var _useState11 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]),
1324
+ _useState12 = _slicedToArray(_useState11, 2),
1325
+ suggestions = _useState12[0],
1326
+ setSuggestions = _useState12[1];
1327
+
1328
+ //performance
1329
+ var handleChangeSuggestionsFetchSafe = funda_utils_dist_cjs_useDebounce__WEBPACK_IMPORTED_MODULE_5___default()(function (e, curVal) {
1330
+ var _oparams = aiPredictFetchFuncMethodParams || [];
1331
+ var _params = _oparams.map(function (item) {
1332
+ return item !== '$QUERY_STRING' ? item : curVal;
1333
+ });
1334
+ fetchSuggestionsData(_params.join(',')).then(function (resSuggestions) {
1335
+ handleInputAiPredictChange(curVal, resSuggestions);
1336
+ });
1337
+ }, 350, []);
1338
+ function fetchSuggestionsData(_x2) {
1339
+ return _fetchSuggestionsData.apply(this, arguments);
1340
+ } // Calculates the width of the input text
1341
+ //----------------
1342
+ function _fetchSuggestionsData() {
1343
+ _fetchSuggestionsData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
1344
+ var response, _ORGIN_DATA;
1345
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1346
+ while (1) switch (_context.prev = _context.next) {
1347
+ case 0:
1348
+ if (!(_typeof(aiPredictFetchFuncAsync) === 'object')) {
1349
+ _context.next = 11;
1350
+ break;
1351
+ }
1352
+ _context.next = 3;
1353
+ return aiPredictFetchFuncAsync["".concat(aiPredictFetchFuncMethod)].apply(aiPredictFetchFuncAsync, _toConsumableArray(params.split(',')));
1354
+ case 3:
1355
+ response = _context.sent;
1356
+ _ORGIN_DATA = response.data; // reset data structure
1357
+ if (typeof aiPredictFetchCallback === 'function') {
1358
+ _ORGIN_DATA = aiPredictFetchCallback(_ORGIN_DATA);
1359
+ }
1360
+
1361
+ // Determine whether the data structure matches
1362
+ if (!Array.isArray(_ORGIN_DATA)) {
1363
+ console.warn('The data structure does not match, please refer to the example in the component documentation.');
1364
+ setHasErr(true);
1365
+ _ORGIN_DATA = [];
1366
+ }
1367
+
1368
+ //
1369
+ setSuggestions(_ORGIN_DATA);
1370
+ return _context.abrupt("return", _ORGIN_DATA);
1371
+ case 11:
1372
+ return _context.abrupt("return", []);
1373
+ case 12:
1374
+ case "end":
1375
+ return _context.stop();
1376
+ }
1377
+ }, _callee);
1378
+ }));
1379
+ return _fetchSuggestionsData.apply(this, arguments);
1380
+ }
1381
+ var calculateTextWidth = function calculateTextWidth(text) {
1382
+ if (valRef.current) {
1383
+ var canvas = document.createElement('canvas');
1384
+ var context = canvas.getContext('2d');
1385
+ context.font = "".concat(originInputComputedStyle.current.fontSize, "px ").concat(originInputComputedStyle.current.fontFamily);
1386
+ return context.measureText(text).width;
1387
+ }
1388
+ return 0;
1389
+ };
1390
+
1391
+ // Get the rest of the suggested text
1392
+ //----------------
1393
+ var getRemainingText = function getRemainingText(fullSuggestion) {
1394
+ if (!changedVal || !fullSuggestion) return '';
1395
+
1396
+ // Only the parts of the suggested text that were not entered are returned
1397
+ var lastInputChar = changedVal[changedVal.length - 1];
1398
+ var lastCharIndex = fullSuggestion.toLowerCase().lastIndexOf(lastInputChar.toLowerCase());
1399
+ return fullSuggestion.slice(lastCharIndex + 1);
1400
+ };
1401
+
1402
+ // Match exactly from the start
1403
+ //----------------
1404
+ var preciseMatch = function preciseMatch(input, suggestions) {
1405
+ if (!input) return '';
1406
+ var filtered = suggestions.filter(function (s) {
1407
+ return s.toLowerCase().startsWith(input.toLowerCase());
1408
+ });
1409
+ setTempMatchedSuggestion(filtered);
1410
+ return filtered;
1411
+ };
1412
+
1413
+ // Fuzzy matching
1414
+ //----------------
1415
+ var fuzzyMatch = function fuzzyMatch(input, suggestions) {
1416
+ if (!input) return '';
1417
+
1418
+ // Convert input to a regular expression pattern with support for arbitrary position matching
1419
+ var pattern = input.split('').map(function (_char) {
1420
+ return _char.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1421
+ }).join('.*');
1422
+ var regex = new RegExp(pattern, 'i');
1423
+
1424
+ // Find the first matching suggestion (multiple matches)
1425
+ var filtered = suggestions.filter(function (suggestion) {
1426
+ return regex.test(suggestion);
1427
+ });
1428
+ setTempMatchedSuggestion(filtered);
1429
+ return filtered;
1430
+ };
1431
+
1432
+ // Handle input variations
1433
+ //----------------
1434
+ var handleInputAiPredictChange = function handleInputAiPredictChange(newValue, curSuggestions) {
1435
+ setTextWidth(calculateTextWidth(newValue));
1436
+
1437
+ // Match results
1438
+ var matchedSuggestion = fuzzyMatch(newValue, curSuggestions);
1439
+ setCurrentSuggestion(matchedSuggestion[0] || '');
1440
+ };
1441
+
1442
+ // Calculate the color shade of the prompt text
1443
+ //----------------
1444
+ var calculateOpacity = function calculateOpacity() {
1445
+ // Transparency is calculated based on the input length
1446
+ var baseOpacity = 0.5;
1447
+ var inputLength = changedVal.length;
1448
+ return Math.max(0.2, baseOpacity - inputLength * 0.05);
1449
+ };
1450
+
1451
+ // Confirm
1452
+ //----------------
1453
+ var handleAiPredictKeyDown = function handleAiPredictKeyDown(e) {
1454
+ // Prevents the default behavior of the enter key
1455
+ e.preventDefault();
1456
+ var remainingText = getRemainingText(currentSuggestion);
1457
+ if (remainingText) {
1458
+ // Only the second half of the text is added
1459
+ setChangedVal(changedVal + remainingText);
1460
+ setCurrentSuggestion('');
1461
+ }
1462
+ };
1463
+
1464
+ //
1465
+ var remainingText = getRemainingText(currentSuggestion);
1466
+
1467
+ //================================================================
1468
+ // General
1469
+ //================================================================
848
1470
  // exposes the following methods
849
1471
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useImperativeHandle)(contentRef, function () {
850
1472
  return {
@@ -870,6 +1492,9 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
870
1492
  onResize === null || onResize === void 0 ? void 0 : onResize(valRef.current, res);
871
1493
  }
872
1494
  });
1495
+ var propExist = function propExist(p) {
1496
+ return typeof p !== 'undefined' && p !== null && p !== '';
1497
+ };
873
1498
  function handleFocus(event) {
874
1499
  var _rootRef$current;
875
1500
  var el = event.target;
@@ -930,6 +1555,39 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
930
1555
  // DO NOT USE "preventDefault()"
931
1556
  onPressEnter === null || onPressEnter === void 0 ? void 0 : onPressEnter(event, valRef.current);
932
1557
  }
1558
+
1559
+ // AI Predict
1560
+ //----
1561
+ if (aiPredict && currentSuggestion !== '') {
1562
+ var keyBindings = aiPredictConfirmKey;
1563
+ // The parameter 'registerKeyEvents' is an array, and each element is an object
1564
+ // eg. { keys: ["Control", "S"], action: () => { console.log("Ctrl+S"); } }
1565
+ var registerKeyEvents = keyBindings.map(function (s) {
1566
+ return {
1567
+ keys: s,
1568
+ action: function action() {
1569
+ handleAiPredictKeyDown(event);
1570
+ }
1571
+ };
1572
+ });
1573
+ registerKeyEvents.forEach(function (binding) {
1574
+ var keysPressed = binding.keys.every(function (key) {
1575
+ return key === "Shift" ? event.shiftKey : key === "Control" ? event.ctrlKey : key === "Alt" ? event.altKey : key === "Meta" ? event.metaKey : event.key === key;
1576
+ });
1577
+ if (keysPressed) {
1578
+ binding.action();
1579
+ }
1580
+ });
1581
+
1582
+ // switch result of suggestions
1583
+ if (event.code === 'ArrowUp') {
1584
+ currentSuggestionIndex.current = (currentSuggestionIndex.current - 1 + tempMatchedSuggestion.length) % tempMatchedSuggestion.length;
1585
+ }
1586
+ if (event.code === 'ArrowDown') {
1587
+ currentSuggestionIndex.current = (currentSuggestionIndex.current + 1) % tempMatchedSuggestion.length;
1588
+ }
1589
+ setCurrentSuggestion(tempMatchedSuggestion[currentSuggestionIndex.current] || '');
1590
+ }
933
1591
  }
934
1592
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
935
1593
  // update default value
@@ -966,6 +1624,17 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
966
1624
  setChangedVal("".concat(defaultValue)); // Avoid displaying the number 0
967
1625
  }
968
1626
  }
1627
+
1628
+ // AI Predict initalization
1629
+ //--------------
1630
+ if (aiPredict && valRef.current !== null) {
1631
+ originInputComputedStyle.current = {
1632
+ fontSize: (0,funda_utils_dist_cjs_inputsCalculation__WEBPACK_IMPORTED_MODULE_4__.actualPropertyValue)(valRef.current, 'fontSize'),
1633
+ fontFamily: (0,funda_utils_dist_cjs_inputsCalculation__WEBPACK_IMPORTED_MODULE_4__.actualPropertyValue)(valRef.current, 'fontFamily'),
1634
+ letterSpacing: (0,funda_utils_dist_cjs_inputsCalculation__WEBPACK_IMPORTED_MODULE_4__.actualPropertyValue)(valRef.current, 'letterSpacing'),
1635
+ textTop: (0,funda_utils_dist_cjs_inputsCalculation__WEBPACK_IMPORTED_MODULE_4__.getTextTop)(valRef.current)
1636
+ };
1637
+ }
969
1638
  }, []);
970
1639
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
971
1640
  className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__.clsWrite)(wrapperClassName, 'mb-3 position-relative'),
@@ -980,10 +1649,15 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
980
1649
  htmlFor: idRes,
981
1650
  className: "form-label"
982
1651
  }, label)) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
983
- className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__.clsWrite)(controlGroupWrapperClassName, 'input-group')
984
- }, typeof iconLeft !== 'undefined' && iconLeft !== null && 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", {
1652
+ className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__.combinedCls)('position-relative z-1', (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__.clsWrite)(controlGroupWrapperClassName, 'input-group'), {
1653
+ 'has-left-content': propExist(iconLeft),
1654
+ 'has-right-content': propExist(iconRight)
1655
+ })
1656
+ }, 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", {
985
1657
  className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__.clsWrite)(controlGroupTextClassName, 'input-group-text')
986
- }, iconLeft)) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("textarea", _extends({
1658
+ }, iconLeft)) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
1659
+ className: "input-group-control-container flex-fill position-relative"
1660
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("textarea", _extends({
987
1661
  ref: function ref(node) {
988
1662
  valRef.current = node;
989
1663
  if (typeof externalRef === 'function') {
@@ -993,7 +1667,11 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
993
1667
  }
994
1668
  },
995
1669
  tabIndex: tabIndex || 0,
996
- className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__.combinedCls)((0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__.clsWrite)(controlClassName, 'form-control'), controlExClassName),
1670
+ className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__.combinedCls)((0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__.clsWrite)(controlClassName, 'form-control'), controlExClassName, {
1671
+ 'rounded': !propExist(iconLeft) && !propExist(iconRight),
1672
+ 'rounded-start-0': propExist(iconLeft),
1673
+ 'rounded-end-0': propExist(iconRight)
1674
+ }),
997
1675
  id: idRes,
998
1676
  name: name,
999
1677
  placeholder: placeholder || '',
@@ -1003,7 +1681,14 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
1003
1681
  maxLength: maxLength || null,
1004
1682
  onFocus: handleFocus,
1005
1683
  onBlur: handleBlur,
1006
- onChange: handleChange,
1684
+ onChange: function onChange(e) {
1685
+ handleChange(e);
1686
+
1687
+ // AI Predict
1688
+ if (aiPredict) {
1689
+ handleChangeSuggestionsFetchSafe(e, e.target.value);
1690
+ }
1691
+ },
1007
1692
  onKeyDown: handleKeyPressed,
1008
1693
  disabled: disabled || null,
1009
1694
  required: required || null,
@@ -1011,13 +1696,25 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
1011
1696
  cols: cols || 20,
1012
1697
  rows: rows || 2,
1013
1698
  style: style
1014
- }, attributes)), typeof iconRight !== 'undefined' && iconRight !== null && 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", {
1015
- className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__.clsWrite)(controlGroupTextClassName, 'input-group-text')
1016
- }, iconRight)) : null), required ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, requiredLabel || requiredLabel === '' ? requiredLabel : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
1699
+ }, attributes)), aiPredict && remainingText && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
1700
+ ref: aiInputRef,
1701
+ className: "position-absolute z-1",
1702
+ style: {
1703
+ left: "".concat(originInputComputedStyle.current.fontSize + textWidth, "px"),
1704
+ top: originInputComputedStyle.current.textTop + 'px',
1705
+ color: "rgba(".concat(aiPredictRemainingTextRGB[0], ", ").concat(aiPredictRemainingTextRGB[1], ", ").concat(aiPredictRemainingTextRGB[2], ", ").concat(calculateOpacity(), ")"),
1706
+ pointerEvents: 'none',
1707
+ fontSize: originInputComputedStyle.current.fontSize + 'px',
1708
+ fontFamily: originInputComputedStyle.current.fontFamily,
1709
+ letterSpacing: originInputComputedStyle.current.letterSpacing
1710
+ }
1711
+ }, remainingText), required ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, requiredLabel || requiredLabel === '' ? requiredLabel : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
1017
1712
  className: "position-absolute end-0 top-0 my-2 mx-2"
1018
1713
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
1019
1714
  className: "text-danger"
1020
- }, "*"))) : ''));
1715
+ }, "*"))) : ''), 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", {
1716
+ className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__.clsWrite)(controlGroupTextClassName, 'input-group-text')
1717
+ }, iconRight)) : null)));
1021
1718
  });
1022
1719
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Textarea);
1023
1720
  })();