funda-ui 4.4.35 → 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 (40) hide show
  1. package/Date/index.js +1078 -77
  2. package/EventCalendar/index.js +8 -2
  3. package/EventCalendarTimeline/index.js +32 -1
  4. package/Input/index.d.ts +7 -0
  5. package/Input/index.js +699 -57
  6. package/MasonryLayout/index.js +11 -1
  7. package/MultipleSelect/index.d.ts +1 -0
  8. package/MultipleSelect/index.js +7 -5
  9. package/RangeSlider/index.js +1078 -77
  10. package/Select/index.js +34 -2
  11. package/Textarea/index.d.ts +7 -0
  12. package/Textarea/index.js +707 -10
  13. package/Tree/index.js +2 -0
  14. package/Utils/inputsCalculation.d.ts +18 -1
  15. package/Utils/inputsCalculation.js +26 -0
  16. package/lib/cjs/Date/index.js +1078 -77
  17. package/lib/cjs/EventCalendar/index.js +8 -2
  18. package/lib/cjs/EventCalendarTimeline/index.js +32 -1
  19. package/lib/cjs/Input/index.d.ts +7 -0
  20. package/lib/cjs/Input/index.js +699 -57
  21. package/lib/cjs/MasonryLayout/index.js +11 -1
  22. package/lib/cjs/MultipleSelect/index.d.ts +1 -0
  23. package/lib/cjs/MultipleSelect/index.js +7 -5
  24. package/lib/cjs/RangeSlider/index.js +1078 -77
  25. package/lib/cjs/Select/index.js +34 -2
  26. package/lib/cjs/Textarea/index.d.ts +7 -0
  27. package/lib/cjs/Textarea/index.js +707 -10
  28. package/lib/cjs/Tree/index.js +2 -0
  29. package/lib/cjs/Utils/inputsCalculation.d.ts +18 -1
  30. package/lib/cjs/Utils/inputsCalculation.js +26 -0
  31. package/lib/esm/EventCalendar/index.tsx +8 -6
  32. package/lib/esm/EventCalendarTimeline/index.tsx +439 -403
  33. package/lib/esm/Input/index.tsx +299 -77
  34. package/lib/esm/MasonryLayout/index.tsx +9 -2
  35. package/lib/esm/MultipleSelect/index.tsx +6 -4
  36. package/lib/esm/Textarea/index.tsx +332 -39
  37. package/lib/esm/Tree/TreeList.tsx +4 -1
  38. package/lib/esm/Tree/index.tsx +1 -0
  39. package/lib/esm/Utils/libs/inputsCalculation.ts +60 -31
  40. package/package.json +1 -1
@@ -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
  /***/ 85:
229
458
  /***/ (function(module, exports, __webpack_require__) {
230
459
 
@@ -393,6 +622,198 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
393
622
 
394
623
  /***/ }),
395
624
 
625
+ /***/ 702:
626
+ /***/ (function(module, exports, __webpack_require__) {
627
+
628
+ /* module decorator */ module = __webpack_require__.nmd(module);
629
+ 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); }
630
+ (function webpackUniversalModuleDefinition(root, factory) {
631
+ 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),
632
+ __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
633
+ (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
634
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));else {}
635
+ })(this, function (__WEBPACK_EXTERNAL_MODULE__787__) {
636
+ return (/******/function () {
637
+ // webpackBootstrap
638
+ /******/
639
+ "use strict";
640
+
641
+ /******/
642
+ var __webpack_modules__ = {
643
+ /***/787: /***/function _(module) {
644
+ module.exports = __WEBPACK_EXTERNAL_MODULE__787__;
645
+
646
+ /***/
647
+ }
648
+
649
+ /******/
650
+ };
651
+ /************************************************************************/
652
+ /******/ // The module cache
653
+ /******/
654
+ var __webpack_module_cache__ = {};
655
+ /******/
656
+ /******/ // The require function
657
+ /******/
658
+ function __nested_webpack_require_1465__(moduleId) {
659
+ /******/ // Check if module is in cache
660
+ /******/var cachedModule = __webpack_module_cache__[moduleId];
661
+ /******/
662
+ if (cachedModule !== undefined) {
663
+ /******/return cachedModule.exports;
664
+ /******/
665
+ }
666
+ /******/ // Create a new module (and put it into the cache)
667
+ /******/
668
+ var module = __webpack_module_cache__[moduleId] = {
669
+ /******/ // no module.id needed
670
+ /******/ // no module.loaded needed
671
+ /******/exports: {}
672
+ /******/
673
+ };
674
+ /******/
675
+ /******/ // Execute the module function
676
+ /******/
677
+ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_1465__);
678
+ /******/
679
+ /******/ // Return the exports of the module
680
+ /******/
681
+ return module.exports;
682
+ /******/
683
+ }
684
+ /******/
685
+ /************************************************************************/
686
+ /******/ /* webpack/runtime/compat get default export */
687
+ /******/
688
+ (function () {
689
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
690
+ /******/__nested_webpack_require_1465__.n = function (module) {
691
+ /******/var getter = module && module.__esModule ? /******/function () {
692
+ return module['default'];
693
+ } : /******/function () {
694
+ return module;
695
+ };
696
+ /******/
697
+ __nested_webpack_require_1465__.d(getter, {
698
+ a: getter
699
+ });
700
+ /******/
701
+ return getter;
702
+ /******/
703
+ };
704
+ /******/
705
+ })();
706
+ /******/
707
+ /******/ /* webpack/runtime/define property getters */
708
+ /******/
709
+ (function () {
710
+ /******/ // define getter functions for harmony exports
711
+ /******/__nested_webpack_require_1465__.d = function (exports, definition) {
712
+ /******/for (var key in definition) {
713
+ /******/if (__nested_webpack_require_1465__.o(definition, key) && !__nested_webpack_require_1465__.o(exports, key)) {
714
+ /******/Object.defineProperty(exports, key, {
715
+ enumerable: true,
716
+ get: definition[key]
717
+ });
718
+ /******/
719
+ }
720
+ /******/
721
+ }
722
+ /******/
723
+ };
724
+ /******/
725
+ })();
726
+ /******/
727
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
728
+ /******/
729
+ (function () {
730
+ /******/__nested_webpack_require_1465__.o = function (obj, prop) {
731
+ return Object.prototype.hasOwnProperty.call(obj, prop);
732
+ };
733
+ /******/
734
+ })();
735
+ /******/
736
+ /******/ /* webpack/runtime/make namespace object */
737
+ /******/
738
+ (function () {
739
+ /******/ // define __esModule on exports
740
+ /******/__nested_webpack_require_1465__.r = function (exports) {
741
+ /******/if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
742
+ /******/Object.defineProperty(exports, Symbol.toStringTag, {
743
+ value: 'Module'
744
+ });
745
+ /******/
746
+ }
747
+ /******/
748
+ Object.defineProperty(exports, '__esModule', {
749
+ value: true
750
+ });
751
+ /******/
752
+ };
753
+ /******/
754
+ })();
755
+ /******/
756
+ /************************************************************************/
757
+ var __webpack_exports__ = {};
758
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
759
+ (function () {
760
+ __nested_webpack_require_1465__.r(__webpack_exports__);
761
+ /* harmony export */
762
+ __nested_webpack_require_1465__.d(__webpack_exports__, {
763
+ /* harmony export */"default": function _default() {
764
+ return __WEBPACK_DEFAULT_EXPORT__;
765
+ }
766
+ /* harmony export */
767
+ });
768
+ /* harmony import */
769
+ var react__WEBPACK_IMPORTED_MODULE_0__ = __nested_webpack_require_1465__(787);
770
+ /* harmony import */
771
+ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nested_webpack_require_1465__.n(react__WEBPACK_IMPORTED_MODULE_0__);
772
+ /**
773
+ * Delay the execution of function or state update
774
+ *
775
+ * @usage:
776
+
777
+ const App = () => {
778
+ const [count, setCount] = useState(0);
779
+ const handleClick = useDebounce(() => setCount(count + 1), 500, [count]);
780
+
781
+ return (
782
+ <div className="app">
783
+ <button onClick={handleClick}>click</button>
784
+ <p>click {count} time</p>
785
+ </div>
786
+ );
787
+ };
788
+
789
+ */
790
+
791
+ var useDebounce = function useDebounce(fn, delay, dependence) {
792
+ var ref = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
793
+ return (0, react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
794
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
795
+ args[_key] = arguments[_key];
796
+ }
797
+ clearTimeout(ref.current);
798
+ ref.current = null;
799
+ ref.current = setTimeout(function () {
800
+ fn.apply(void 0, args);
801
+ }, delay);
802
+ }, dependence);
803
+ };
804
+ /* harmony default export */
805
+ var __WEBPACK_DEFAULT_EXPORT__ = useDebounce;
806
+ })();
807
+
808
+ /******/
809
+ return __webpack_exports__;
810
+ /******/
811
+ }()
812
+ );
813
+ });
814
+
815
+ /***/ }),
816
+
396
817
  /***/ 787:
397
818
  /***/ ((module) => {
398
819
 
@@ -495,8 +916,20 @@ __webpack_require__.r(__webpack_exports__);
495
916
  /* harmony import */ var funda_utils_dist_cjs_useComId__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_useComId__WEBPACK_IMPORTED_MODULE_1__);
496
917
  /* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(188);
497
918
  /* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__);
498
- var _excluded = ["contentRef", "wrapperClassName", "controlClassName", "controlExClassName", "controlGroupWrapperClassName", "controlGroupTextClassName", "type", "disabled", "required", "placeholder", "pattern", "readOnly", "defaultValue", "value", "requiredLabel", "label", "units", "name", "step", "min", "max", "src", "size", "minLength", "maxLength", "alt", "inputMode", "id", "appendControl", "iconLeft", "iconRight", "autoComplete", "autoCapitalize", "spellCheck", "style", "tabIndex", "onChangeCallback", "onInputCallback", "onKeyPressedCallback", "onChange", "onBlur", "onFocus", "onPressEnter"];
919
+ /* harmony import */ var funda_utils_dist_cjs_inputsCalculation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(954);
920
+ /* harmony import */ var funda_utils_dist_cjs_inputsCalculation__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_inputsCalculation__WEBPACK_IMPORTED_MODULE_3__);
921
+ /* harmony import */ var funda_utils_dist_cjs_useDebounce__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(702);
922
+ /* harmony import */ var funda_utils_dist_cjs_useDebounce__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_useDebounce__WEBPACK_IMPORTED_MODULE_4__);
923
+ var _excluded = ["contentRef", "wrapperClassName", "controlClassName", "controlExClassName", "controlGroupWrapperClassName", "controlGroupTextClassName", "type", "disabled", "required", "placeholder", "pattern", "readOnly", "defaultValue", "value", "requiredLabel", "label", "units", "name", "step", "min", "max", "src", "size", "minLength", "maxLength", "alt", "inputMode", "id", "appendControl", "aiPredict", "aiPredictRemainingTextRGB", "aiPredictConfirmKey", "aiPredictFetchFuncAsync", "aiPredictFetchFuncMethod", "aiPredictFetchFuncMethodParams", "aiPredictFetchCallback", "iconLeft", "iconRight", "autoComplete", "autoCapitalize", "spellCheck", "style", "tabIndex", "onChangeCallback", "onInputCallback", "onKeyPressedCallback", "onChange", "onBlur", "onFocus", "onPressEnter"];
924
+ 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; }
925
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
926
+ 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."); }
927
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
928
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
929
+ 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); }
499
930
  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); }
931
+ 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); } }
932
+ 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); }); }; }
500
933
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
501
934
  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."); }
502
935
  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); }
@@ -508,6 +941,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
508
941
 
509
942
 
510
943
 
944
+
945
+
511
946
  var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(function (props, externalRef) {
512
947
  var contentRef = props.contentRef,
513
948
  wrapperClassName = props.wrapperClassName,
@@ -538,6 +973,16 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
538
973
  inputMode = props.inputMode,
539
974
  id = props.id,
540
975
  appendControl = props.appendControl,
976
+ _props$aiPredict = props.aiPredict,
977
+ aiPredict = _props$aiPredict === void 0 ? false : _props$aiPredict,
978
+ _props$aiPredictRemai = props.aiPredictRemainingTextRGB,
979
+ aiPredictRemainingTextRGB = _props$aiPredictRemai === void 0 ? [153, 153, 153] : _props$aiPredictRemai,
980
+ _props$aiPredictConfi = props.aiPredictConfirmKey,
981
+ aiPredictConfirmKey = _props$aiPredictConfi === void 0 ? [['Enter'], ['Tab'], ['Shift', ' ']] : _props$aiPredictConfi,
982
+ aiPredictFetchFuncAsync = props.aiPredictFetchFuncAsync,
983
+ aiPredictFetchFuncMethod = props.aiPredictFetchFuncMethod,
984
+ aiPredictFetchFuncMethodParams = props.aiPredictFetchFuncMethodParams,
985
+ aiPredictFetchCallback = props.aiPredictFetchCallback,
541
986
  iconLeft = props.iconLeft,
542
987
  iconRight = props.iconRight,
543
988
  autoComplete = props.autoComplete,
@@ -567,6 +1012,183 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
567
1012
  changedVal = _useState4[0],
568
1013
  setChangedVal = _useState4[1];
569
1014
 
1015
+ //================================================================
1016
+ // AI Predict
1017
+ //================================================================
1018
+ var _useState5 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(''),
1019
+ _useState6 = _slicedToArray(_useState5, 2),
1020
+ currentSuggestion = _useState6[0],
1021
+ setCurrentSuggestion = _useState6[1];
1022
+ var _useState7 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]),
1023
+ _useState8 = _slicedToArray(_useState7, 2),
1024
+ tempMatchedSuggestion = _useState8[0],
1025
+ setTempMatchedSuggestion = _useState8[1];
1026
+ var _useState9 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(0),
1027
+ _useState10 = _slicedToArray(_useState9, 2),
1028
+ textWidth = _useState10[0],
1029
+ setTextWidth = _useState10[1];
1030
+ var aiInputRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
1031
+ var originInputComputedStyle = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)({
1032
+ fontSize: 16,
1033
+ fontFamily: 'inherit',
1034
+ letterSpacing: 'normal',
1035
+ textTop: 10
1036
+ });
1037
+ var _useState11 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
1038
+ _useState12 = _slicedToArray(_useState11, 2),
1039
+ hasErr = _useState12[0],
1040
+ setHasErr = _useState12[1];
1041
+ var currentSuggestionIndex = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(0);
1042
+
1043
+ // A list of suggestions
1044
+ //----------------
1045
+ var _useState13 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]),
1046
+ _useState14 = _slicedToArray(_useState13, 2),
1047
+ suggestions = _useState14[0],
1048
+ setSuggestions = _useState14[1];
1049
+
1050
+ //performance
1051
+ var handleChangeSuggestionsFetchSafe = funda_utils_dist_cjs_useDebounce__WEBPACK_IMPORTED_MODULE_4___default()(function (e, curVal) {
1052
+ var _oparams = aiPredictFetchFuncMethodParams || [];
1053
+ var _params = _oparams.map(function (item) {
1054
+ return item !== '$QUERY_STRING' ? item : curVal;
1055
+ });
1056
+ fetchSuggestionsData(_params.join(',')).then(function (resSuggestions) {
1057
+ handleInputAiPredictChange(curVal, resSuggestions);
1058
+ });
1059
+ }, 350, []);
1060
+ function fetchSuggestionsData(_x2) {
1061
+ return _fetchSuggestionsData.apply(this, arguments);
1062
+ } // Calculates the width of the input text
1063
+ //----------------
1064
+ function _fetchSuggestionsData() {
1065
+ _fetchSuggestionsData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
1066
+ var response, _ORGIN_DATA;
1067
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1068
+ while (1) switch (_context.prev = _context.next) {
1069
+ case 0:
1070
+ if (!(_typeof(aiPredictFetchFuncAsync) === 'object')) {
1071
+ _context.next = 11;
1072
+ break;
1073
+ }
1074
+ _context.next = 3;
1075
+ return aiPredictFetchFuncAsync["".concat(aiPredictFetchFuncMethod)].apply(aiPredictFetchFuncAsync, _toConsumableArray(params.split(',')));
1076
+ case 3:
1077
+ response = _context.sent;
1078
+ _ORGIN_DATA = response.data; // reset data structure
1079
+ if (typeof aiPredictFetchCallback === 'function') {
1080
+ _ORGIN_DATA = aiPredictFetchCallback(_ORGIN_DATA);
1081
+ }
1082
+
1083
+ // Determine whether the data structure matches
1084
+ if (!Array.isArray(_ORGIN_DATA)) {
1085
+ console.warn('The data structure does not match, please refer to the example in the component documentation.');
1086
+ setHasErr(true);
1087
+ _ORGIN_DATA = [];
1088
+ }
1089
+
1090
+ //
1091
+ setSuggestions(_ORGIN_DATA);
1092
+ return _context.abrupt("return", _ORGIN_DATA);
1093
+ case 11:
1094
+ return _context.abrupt("return", []);
1095
+ case 12:
1096
+ case "end":
1097
+ return _context.stop();
1098
+ }
1099
+ }, _callee);
1100
+ }));
1101
+ return _fetchSuggestionsData.apply(this, arguments);
1102
+ }
1103
+ var calculateTextWidth = function calculateTextWidth(text) {
1104
+ if (valRef.current) {
1105
+ var canvas = document.createElement('canvas');
1106
+ var context = canvas.getContext('2d');
1107
+ context.font = "".concat(originInputComputedStyle.current.fontSize, "px ").concat(originInputComputedStyle.current.fontFamily);
1108
+ return context.measureText(text).width;
1109
+ }
1110
+ return 0;
1111
+ };
1112
+
1113
+ // Get the rest of the suggested text
1114
+ //----------------
1115
+ var getRemainingText = function getRemainingText(fullSuggestion) {
1116
+ if (!changedVal || !fullSuggestion) return '';
1117
+
1118
+ // Only the parts of the suggested text that were not entered are returned
1119
+ var lastInputChar = changedVal[changedVal.length - 1];
1120
+ var lastCharIndex = fullSuggestion.toLowerCase().lastIndexOf(lastInputChar.toLowerCase());
1121
+ return fullSuggestion.slice(lastCharIndex + 1);
1122
+ };
1123
+
1124
+ // Match exactly from the start
1125
+ //----------------
1126
+ var preciseMatch = function preciseMatch(input, suggestions) {
1127
+ if (!input) return '';
1128
+ var filtered = suggestions.filter(function (s) {
1129
+ return s.toLowerCase().startsWith(input.toLowerCase());
1130
+ });
1131
+ setTempMatchedSuggestion(filtered);
1132
+ return filtered;
1133
+ };
1134
+
1135
+ // Fuzzy matching
1136
+ //----------------
1137
+ var fuzzyMatch = function fuzzyMatch(input, suggestions) {
1138
+ if (!input) return '';
1139
+
1140
+ // Convert input to a regular expression pattern with support for arbitrary position matching
1141
+ var pattern = input.split('').map(function (_char) {
1142
+ return _char.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1143
+ }).join('.*');
1144
+ var regex = new RegExp(pattern, 'i');
1145
+
1146
+ // Find the first matching suggestion (multiple matches)
1147
+ var filtered = suggestions.filter(function (suggestion) {
1148
+ return regex.test(suggestion);
1149
+ });
1150
+ setTempMatchedSuggestion(filtered);
1151
+ return filtered;
1152
+ };
1153
+
1154
+ // Handle input variations
1155
+ //----------------
1156
+ var handleInputAiPredictChange = function handleInputAiPredictChange(newValue, curSuggestions) {
1157
+ setTextWidth(calculateTextWidth(newValue));
1158
+
1159
+ // Match results
1160
+ var matchedSuggestion = fuzzyMatch(newValue, curSuggestions);
1161
+ setCurrentSuggestion(matchedSuggestion[0] || '');
1162
+ };
1163
+
1164
+ // Calculate the color shade of the prompt text
1165
+ //----------------
1166
+ var calculateOpacity = function calculateOpacity() {
1167
+ // Transparency is calculated based on the input length
1168
+ var baseOpacity = 0.5;
1169
+ var inputLength = changedVal.length;
1170
+ return Math.max(0.2, baseOpacity - inputLength * 0.05);
1171
+ };
1172
+
1173
+ // Confirm
1174
+ //----------------
1175
+ var handleAiPredictKeyDown = function handleAiPredictKeyDown(e) {
1176
+ // Prevents the default behavior of the enter key
1177
+ e.preventDefault();
1178
+ var remainingText = getRemainingText(currentSuggestion);
1179
+ if (remainingText) {
1180
+ // Only the second half of the text is added
1181
+ setChangedVal(changedVal + remainingText);
1182
+ setCurrentSuggestion('');
1183
+ }
1184
+ };
1185
+
1186
+ //
1187
+ var remainingText = getRemainingText(currentSuggestion);
1188
+
1189
+ //================================================================
1190
+ // General
1191
+ //================================================================
570
1192
  // exposes the following methods
571
1193
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useImperativeHandle)(contentRef, function () {
572
1194
  return {
@@ -653,6 +1275,39 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
653
1275
  // DO NOT USE "preventDefault()"
654
1276
  onPressEnter === null || onPressEnter === void 0 ? void 0 : onPressEnter(event, valRef.current);
655
1277
  }
1278
+
1279
+ // AI Predict
1280
+ //----
1281
+ if (aiPredict && currentSuggestion !== '') {
1282
+ var keyBindings = aiPredictConfirmKey;
1283
+ // The parameter 'registerKeyEvents' is an array, and each element is an object
1284
+ // eg. { keys: ["Control", "S"], action: () => { console.log("Ctrl+S"); } }
1285
+ var registerKeyEvents = keyBindings.map(function (s) {
1286
+ return {
1287
+ keys: s,
1288
+ action: function action() {
1289
+ handleAiPredictKeyDown(event);
1290
+ }
1291
+ };
1292
+ });
1293
+ registerKeyEvents.forEach(function (binding) {
1294
+ var keysPressed = binding.keys.every(function (key) {
1295
+ return key === "Shift" ? event.shiftKey : key === "Control" ? event.ctrlKey : key === "Alt" ? event.altKey : key === "Meta" ? event.metaKey : event.key === key;
1296
+ });
1297
+ if (keysPressed) {
1298
+ binding.action();
1299
+ }
1300
+ });
1301
+
1302
+ // switch result of suggestions
1303
+ if (event.code === 'ArrowUp') {
1304
+ currentSuggestionIndex.current = (currentSuggestionIndex.current - 1 + tempMatchedSuggestion.length) % tempMatchedSuggestion.length;
1305
+ }
1306
+ if (event.code === 'ArrowDown') {
1307
+ currentSuggestionIndex.current = (currentSuggestionIndex.current + 1) % tempMatchedSuggestion.length;
1308
+ }
1309
+ setCurrentSuggestion(tempMatchedSuggestion[currentSuggestionIndex.current] || '');
1310
+ }
656
1311
  }
657
1312
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
658
1313
  // update default value
@@ -668,6 +1323,17 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
668
1323
  //REQUIRED
669
1324
  setChangedVal("".concat(defaultValue)); // Avoid displaying the number 0
670
1325
  }
1326
+
1327
+ // AI Predict initalization
1328
+ //--------------
1329
+ if (aiPredict && valRef.current !== null) {
1330
+ originInputComputedStyle.current = {
1331
+ fontSize: (0,funda_utils_dist_cjs_inputsCalculation__WEBPACK_IMPORTED_MODULE_3__.actualPropertyValue)(valRef.current, 'fontSize'),
1332
+ fontFamily: (0,funda_utils_dist_cjs_inputsCalculation__WEBPACK_IMPORTED_MODULE_3__.actualPropertyValue)(valRef.current, 'fontFamily'),
1333
+ letterSpacing: (0,funda_utils_dist_cjs_inputsCalculation__WEBPACK_IMPORTED_MODULE_3__.actualPropertyValue)(valRef.current, 'letterSpacing'),
1334
+ textTop: (0,funda_utils_dist_cjs_inputsCalculation__WEBPACK_IMPORTED_MODULE_3__.getTextTop)(valRef.current)
1335
+ };
1336
+ }
671
1337
  }, []);
672
1338
  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", {
673
1339
  className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(wrapperClassName, 'mb-3 position-relative'),
@@ -682,60 +1348,15 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
682
1348
  htmlFor: idRes,
683
1349
  className: "form-label"
684
1350
  }, label)) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
685
- className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.combinedCls)('position-relative', (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(controlGroupWrapperClassName, 'input-group'), {
1351
+ className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.combinedCls)('position-relative z-1', (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(controlGroupWrapperClassName, 'input-group'), {
686
1352
  'has-left-content': propExist(iconLeft),
687
1353
  'has-right-content': propExist(iconRight) || propExist(units)
688
1354
  })
689
1355
  }, 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", {
690
1356
  className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(controlGroupTextClassName, 'input-group-text')
691
- }, iconLeft)) : null, appendControl && 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("div", {
692
- className: "input-group-control-container w-100 position-relative"
1357
+ }, iconLeft)) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
1358
+ className: "input-group-control-container flex-fill position-relative"
693
1359
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", _extends({
694
- ref: function ref(node) {
695
- valRef.current = node;
696
- if (typeof externalRef === 'function') {
697
- externalRef(node);
698
- } else if (externalRef) {
699
- externalRef.current = node;
700
- }
701
- },
702
- tabIndex: tabIndex || 0,
703
- type: typeRes,
704
- className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.combinedCls)(propExist(iconLeft) ? 'rounded-start-0' : 'rounded', (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(controlClassName, 'form-control ')),
705
- id: idRes,
706
- name: name,
707
- step: step || null,
708
- min: min || null,
709
- max: max || null,
710
- src: src || null,
711
- size: size || null,
712
- alt: alt || null,
713
- inputMode: inputMode || 'text',
714
- pattern: pattern || null,
715
- placeholder: placeholder || '',
716
- defaultValue: defaultValue,
717
- value: changedVal,
718
- minLength: minLength || null,
719
- maxLength: maxLength || null,
720
- autoComplete: typeof autoComplete === 'undefined' ? 'on' : autoComplete,
721
- autoCapitalize: typeof autoCapitalize === 'undefined' ? 'off' : autoCapitalize,
722
- spellCheck: typeof spellCheck === 'undefined' ? false : spellCheck,
723
- onFocus: handleFocus,
724
- onBlur: handleBlur,
725
- onChange: handleChange,
726
- onKeyDown: handleKeyPressed,
727
- onCompositionStart: handleComposition,
728
- onCompositionUpdate: handleComposition,
729
- onCompositionEnd: handleComposition,
730
- disabled: disabled || null,
731
- required: required || null,
732
- readOnly: readOnly || null,
733
- style: style
734
- }, attributes)), appendControl || '', propExist(units) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
735
- className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(controlGroupTextClassName, 'input-group-text')
736
- }, units)) : null, propExist(iconRight) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
737
- className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(controlGroupTextClassName, 'input-group-text')
738
- }, iconRight)) : null)) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", _extends({
739
1360
  ref: function ref(node) {
740
1361
  valRef.current = node;
741
1362
  if (typeof externalRef === 'function') {
@@ -747,7 +1368,9 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
747
1368
  tabIndex: tabIndex || 0,
748
1369
  type: typeRes,
749
1370
  className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.combinedCls)((0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(controlClassName, 'form-control'), controlExClassName, {
750
- 'rounded': !propExist(iconLeft) && !propExist(iconRight) && !propExist(units)
1371
+ 'rounded': !propExist(iconLeft) && !propExist(iconRight) && !propExist(units),
1372
+ 'rounded-start-0': propExist(iconLeft),
1373
+ 'rounded-end-0': propExist(iconRight) || propExist(units)
751
1374
  }),
752
1375
  id: idRes,
753
1376
  name: name,
@@ -768,7 +1391,14 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
768
1391
  spellCheck: typeof spellCheck === 'undefined' ? false : spellCheck,
769
1392
  onFocus: handleFocus,
770
1393
  onBlur: handleBlur,
771
- onChange: handleChange,
1394
+ onChange: function onChange(e) {
1395
+ handleChange(e);
1396
+
1397
+ // AI Predict
1398
+ if (aiPredict) {
1399
+ handleChangeSuggestionsFetchSafe(e, e.target.value);
1400
+ }
1401
+ },
772
1402
  onKeyDown: handleKeyPressed,
773
1403
  onCompositionStart: handleComposition,
774
1404
  onCompositionUpdate: handleComposition,
@@ -777,15 +1407,27 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
777
1407
  required: required || null,
778
1408
  readOnly: readOnly || null,
779
1409
  style: style
780
- }, attributes)), appendControl || '', propExist(units) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
781
- className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(controlGroupTextClassName, 'input-group-text')
782
- }, units)) : null, propExist(iconRight) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
783
- className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(controlGroupTextClassName, 'input-group-text')
784
- }, 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", {
1410
+ }, attributes)), appendControl || '', aiPredict && remainingText && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
1411
+ ref: aiInputRef,
1412
+ className: "position-absolute z-1",
1413
+ style: {
1414
+ left: "".concat(originInputComputedStyle.current.fontSize + textWidth, "px"),
1415
+ top: originInputComputedStyle.current.textTop + 'px',
1416
+ color: "rgba(".concat(aiPredictRemainingTextRGB[0], ", ").concat(aiPredictRemainingTextRGB[1], ", ").concat(aiPredictRemainingTextRGB[2], ", ").concat(calculateOpacity(), ")"),
1417
+ pointerEvents: 'none',
1418
+ fontSize: originInputComputedStyle.current.fontSize + 'px',
1419
+ fontFamily: originInputComputedStyle.current.fontFamily,
1420
+ letterSpacing: originInputComputedStyle.current.letterSpacing
1421
+ }
1422
+ }, 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", {
785
1423
  className: "position-absolute end-0 top-0 my-2 mx-2"
786
1424
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
787
1425
  className: "text-danger"
788
- }, "*"))) : ''));
1426
+ }, "*"))) : ''), propExist(units) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
1427
+ className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(controlGroupTextClassName, 'input-group-text')
1428
+ }, units)) : null, propExist(iconRight) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
1429
+ className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(controlGroupTextClassName, 'input-group-text')
1430
+ }, iconRight)) : null)));
789
1431
  });
790
1432
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Input);
791
1433
  })();