funda-ui 4.1.112 → 4.1.116

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 (56) hide show
  1. package/Accordion/index.js +103 -118
  2. package/BackToTop/index.js +103 -118
  3. package/CascadingSelect/index.js +100 -115
  4. package/CascadingSelectE2E/index.js +100 -115
  5. package/Date/index.js +100 -115
  6. package/DigitalClock/index.js +103 -118
  7. package/DropdownMenu/index.js +103 -118
  8. package/EventCalendarTimeline/index.js +100 -115
  9. package/LiveSearch/index.js +100 -115
  10. package/MasonryLayout/index.js +103 -118
  11. package/MultiFuncSelect/index.css +1 -1
  12. package/MultiFuncSelect/index.js +106 -115
  13. package/MultilevelDropdownMenu/index.js +103 -118
  14. package/MultipleCheckboxes/index.js +103 -118
  15. package/MultipleSelect/index.js +103 -118
  16. package/Radio/index.js +103 -118
  17. package/Scrollbar/index.js +103 -118
  18. package/Select/index.js +103 -118
  19. package/Table/index.js +99 -114
  20. package/TagInput/index.js +103 -118
  21. package/Textarea/index.js +103 -118
  22. package/Tooltip/index.js +103 -118
  23. package/Tree/index.js +100 -115
  24. package/Utils/index.d.ts +2 -2
  25. package/Utils/index.js +100 -115
  26. package/lib/cjs/Accordion/index.js +103 -118
  27. package/lib/cjs/BackToTop/index.js +103 -118
  28. package/lib/cjs/CascadingSelect/index.js +100 -115
  29. package/lib/cjs/CascadingSelectE2E/index.js +100 -115
  30. package/lib/cjs/Date/index.js +100 -115
  31. package/lib/cjs/DigitalClock/index.js +103 -118
  32. package/lib/cjs/DropdownMenu/index.js +103 -118
  33. package/lib/cjs/EventCalendarTimeline/index.js +100 -115
  34. package/lib/cjs/LiveSearch/index.js +100 -115
  35. package/lib/cjs/MasonryLayout/index.js +103 -118
  36. package/lib/cjs/MultiFuncSelect/index.js +106 -115
  37. package/lib/cjs/MultilevelDropdownMenu/index.js +103 -118
  38. package/lib/cjs/MultipleCheckboxes/index.js +103 -118
  39. package/lib/cjs/MultipleSelect/index.js +103 -118
  40. package/lib/cjs/Radio/index.js +103 -118
  41. package/lib/cjs/Scrollbar/index.js +103 -118
  42. package/lib/cjs/Select/index.js +103 -118
  43. package/lib/cjs/Table/index.js +99 -114
  44. package/lib/cjs/TagInput/index.js +103 -118
  45. package/lib/cjs/Textarea/index.js +103 -118
  46. package/lib/cjs/Tooltip/index.js +103 -118
  47. package/lib/cjs/Tree/index.js +100 -115
  48. package/lib/cjs/Utils/index.d.ts +2 -2
  49. package/lib/cjs/Utils/index.js +100 -115
  50. package/lib/css/MultiFuncSelect/index.css +1 -1
  51. package/lib/esm/MultiFuncSelect/index.scss +1 -1
  52. package/lib/esm/MultiFuncSelect/index.tsx +9 -4
  53. package/lib/esm/Table/TableRow.tsx +1 -1
  54. package/lib/esm/Utils/index.tsx +2 -2
  55. package/lib/esm/Utils/libs/inputs-calculation.ts +110 -114
  56. package/package.json +1 -1
@@ -434,8 +434,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
434
434
  return (/* reexport */_getSpecifiedDate
435
435
  );
436
436
  },
437
- "getTextBoundingRect": function getTextBoundingRect() {
438
- return (/* reexport */_getTextBoundingRect
437
+ "getTextWidth": function getTextWidth() {
438
+ return (/* reexport */_getTextWidth
439
439
  );
440
440
  },
441
441
  "getTodayDate": function getTodayDate() {
@@ -2732,125 +2732,110 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
2732
2732
  }
2733
2733
  ; // CONCATENATED MODULE: ./src/libs/inputs-calculation.ts
2734
2734
  /**
2735
- * Get cursor or text position in pixels for input element
2736
- *
2737
- * @param {HTMLElement} input Required HTMLElement with `value` attribute
2738
- * @param {Number} selectionStart Optional number: Start offset. Default 0
2739
- * @param {Number} selectionEnd Optional number: End offset. Default selectionStart
2740
- * @param {Boolean} debug Optional boolean. If true, the created test layer will not be removed.
2741
- * @returns {JSON}
2742
- * such as:
2743
- {"x":14,"y":42.5,"width":36.1875,"height":19,"top":42.5,"right":50.1875,"bottom":61.5,"left":14}
2744
- */
2745
-
2746
- // Local functions for readability of the previous code
2747
- function appendPart(text, cssDefaultStyles, fakeClone, start, end) {
2748
- var span = document.createElement("span"),
2749
- tmpText = text.substring(start, end);
2750
- span.style.cssText = cssDefaultStyles; //Force styles to prevent unexpected results
2751
- // add a space if it ends in a newline
2752
- if (/[\n\r]$/.test(tmpText)) {
2753
- tmpText += ' ';
2754
- }
2755
- span.textContent = tmpText;
2756
- fakeClone.appendChild(span);
2757
- return span;
2758
- }
2759
- // Computing offset position
2760
- function getInputOffset(input) {
2761
- var body = document.body,
2762
- win = document.defaultView,
2763
- docElem = document.documentElement,
2764
- box = document.createElement('div');
2765
- box.style.paddingLeft = box.style.width = "1px";
2766
- body.appendChild(box);
2767
- var isBoxModel = box.offsetWidth == 2;
2768
- body.removeChild(box);
2769
- box = input.getBoundingClientRect();
2770
- var clientTop = docElem.clientTop || body.clientTop || 0,
2771
- clientLeft = docElem.clientLeft || body.clientLeft || 0,
2772
- scrollTop = win.pageYOffset || isBoxModel && docElem.scrollTop || body.scrollTop,
2773
- scrollLeft = win.pageXOffset || isBoxModel && docElem.scrollLeft || body.scrollLeft;
2774
- return {
2775
- top: box.top + scrollTop - clientTop,
2776
- left: box.left + scrollLeft - clientLeft
2777
- };
2735
+ * Get the actual value with user specific methed
2736
+ * it can be 'width', 'height', 'outerWidth', 'outerHeight'
2737
+ * @private
2738
+ * @param {Element} el - A DOM node containing one selector to match against.
2739
+ * @param {String} prop - A string naming the property of style.
2740
+ * @param {?Json} config - Whether or not margin is included. The key `includeMargin`
2741
+ takes effect when set to true
2742
+ * @return {Number} - Returns a pure number.
2743
+ */
2744
+ function actualPropertyValue(el, prop) {
2745
+ var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
2746
+ if (el === null) return 0;
2747
+ var style = window.getComputedStyle ? window.getComputedStyle(el) : el.currentStyle,
2748
+ display = style.display,
2749
+ position = style.position,
2750
+ visibility = style.visibility;
2751
+ var marginWidth = 0;
2752
+ var marginHeight = 0;
2753
+ var maxVal;
2754
+ var actualVal;
2755
+ if (config && config.includeMargin === true) {
2756
+ marginWidth = parseFloat(style.marginLeft) + parseFloat(style.marginRight);
2757
+ marginHeight = parseFloat(style.marginTop) + parseFloat(style.marginBottom);
2758
+ }
2759
+ if (prop === 'width') {
2760
+ maxVal = parseFloat(style.maxWidth);
2761
+
2762
+ // if its not hidden we just return normal height
2763
+ if (display !== 'none' && maxVal !== 0) {
2764
+ return el.clientWidth;
2765
+ }
2766
+ }
2767
+ if (prop === 'height') {
2768
+ maxVal = parseFloat(style.maxHeight);
2769
+ if (display !== 'none' && maxVal !== 0) {
2770
+ return el.clientHeight;
2771
+ }
2772
+ }
2773
+ if (prop === 'outerWidth') {
2774
+ maxVal = parseFloat(style.maxWidth);
2775
+ if (display !== 'none' && maxVal !== 0) {
2776
+ return el.offsetWidth + marginWidth;
2777
+ }
2778
+ }
2779
+ if (prop === 'outerHeight') {
2780
+ maxVal = parseFloat(style.maxHeight);
2781
+ if (display !== 'none' && maxVal !== 0) {
2782
+ return el.offsetHeight + marginHeight;
2783
+ }
2784
+ }
2785
+
2786
+ // the element is hidden so:
2787
+ // making the el block so we can meassure its height but still be hidden
2788
+ el.style.position = 'absolute';
2789
+ el.style.visibility = 'hidden';
2790
+ el.style.display = 'block';
2791
+ if (prop === 'width') actualVal = el.clientWidth;
2792
+ if (prop === 'height') actualVal = el.clientHeight;
2793
+ if (prop === 'outerWidth') actualVal = el.offsetWidth + marginWidth;
2794
+ if (prop === 'outerHeight') actualVal = el.offsetHeight + marginHeight;
2795
+
2796
+ // reverting to the original values
2797
+ el.style.display = display;
2798
+ el.style.position = position;
2799
+ el.style.visibility = visibility;
2800
+ return actualVal;
2778
2801
  }
2779
- function getInputCSS(input, prop, isnumber) {
2802
+ function getElCSS(input, prop, isNumber) {
2780
2803
  var _document$defaultView;
2781
2804
  var val = (_document$defaultView = document.defaultView) === null || _document$defaultView === void 0 ? void 0 : _document$defaultView.getComputedStyle(input, null).getPropertyValue(prop);
2782
- return isnumber ? parseFloat(val) : val;
2783
- }
2784
- function _getTextBoundingRect(input, selectionStart, selectionEnd) {
2785
- var _fakeClone$parentNode;
2786
- var debug = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
2787
- if (input === null) return 0;
2788
-
2789
- // Basic parameter validation
2790
- if (!input || !('value' in input)) return input;
2791
- if (typeof selectionStart == "string") selectionStart = parseFloat(selectionStart);
2792
- if (typeof selectionStart != "number" || isNaN(selectionStart)) {
2793
- selectionStart = 0;
2794
- }
2795
- if (selectionStart < 0) selectionStart = 0;else selectionStart = Math.min(input.value.length, selectionStart);
2796
- if (typeof selectionEnd == "string") selectionEnd = parseFloat(selectionEnd);
2797
- if (typeof selectionEnd != "number" || isNaN(selectionEnd) || selectionEnd < selectionStart) {
2798
- selectionEnd = selectionStart;
2799
- }
2800
- if (selectionEnd < 0) selectionEnd = 0;else selectionEnd = Math.min(input.value.length, selectionEnd);
2801
-
2802
- // If available (thus IE), use the createTextRange method
2803
- if (typeof input.createTextRange == "function") {
2804
- var range = input.createTextRange();
2805
- range.collapse(true);
2806
- range.moveStart('character', selectionStart);
2807
- range.moveEnd('character', selectionEnd - selectionStart);
2808
- return range.getBoundingClientRect();
2809
- }
2810
- // createTextRange is not supported, create a fake text range
2811
- var offset = getInputOffset(input),
2812
- topPos = offset.top,
2813
- leftPos = offset.left,
2814
- width = getInputCSS(input, 'width', true),
2815
- height = getInputCSS(input, 'height', true);
2816
-
2817
- // Styles to simulate a node in an input field
2818
- // use pre-wrap instead of wrap for white-space to support wrapping in textareas
2819
- var cssDefaultStyles = "white-space:pre-wrap;padding:0;margin:0;",
2820
- 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'];
2821
- topPos += getInputCSS(input, 'padding-top', true);
2822
- topPos += getInputCSS(input, 'border-top-width', true);
2823
- leftPos += getInputCSS(input, 'padding-left', true);
2824
- leftPos += getInputCSS(input, 'border-left-width', true);
2825
- leftPos += 1; //Seems to be necessary
2826
-
2827
- for (var i = 0; i < listOfModifiers.length; i++) {
2828
- var property = listOfModifiers[i];
2829
- cssDefaultStyles += property + ':' + getInputCSS(input, property, false) + ';';
2830
- }
2831
- // End of CSS variable checks
2832
-
2833
- var text = input.value,
2834
- textLen = text.length,
2835
- fakeClone = document.createElement("div");
2836
- if (selectionStart > 0) appendPart(text, cssDefaultStyles, fakeClone, 0, selectionStart);
2837
- var fakeRange = appendPart(text, cssDefaultStyles, fakeClone, selectionStart, selectionEnd);
2838
- if (textLen > selectionEnd) appendPart(text, cssDefaultStyles, fakeClone, selectionEnd, textLen);
2839
-
2840
- // Styles to inherit the font styles of the element
2841
- fakeClone.style.cssText = cssDefaultStyles;
2842
-
2843
- // Styles to position the text node at the desired position
2844
- fakeClone.style.position = "absolute";
2845
- fakeClone.style.top = topPos + "px";
2846
- fakeClone.style.left = leftPos + "px";
2847
- fakeClone.style.width = width + "px";
2848
- fakeClone.style.height = height + "px";
2849
- document.body.appendChild(fakeClone);
2850
- var returnValue = fakeRange.getBoundingClientRect(); //Get rect
2851
-
2852
- if (!debug) (_fakeClone$parentNode = fakeClone.parentNode) === null || _fakeClone$parentNode === void 0 ? void 0 : _fakeClone$parentNode.removeChild(fakeClone); //Remove temp
2853
- return returnValue;
2805
+ return isNumber ? isNaN(parseFloat(val)) ? 0 : parseFloat(val) : val;
2806
+ }
2807
+
2808
+ /**
2809
+ * Get cursor or text position in pixels for input element
2810
+ *
2811
+ * @param {HTMLInputElement} input Required HTMLElement with `value` attribute
2812
+ * @param {HTMLSpanElement} fauxContainer Container of faux.
2813
+ * @param {HTMLElement} rawTextContainer The raw text container for the comparison
2814
+ * @returns {Number}
2815
+ */
2816
+
2817
+ function _getTextWidth(input, fauxContainer, rawTextContainer) {
2818
+ if (input === null || fauxContainer === null || rawTextContainer === null) return 0;
2819
+ var _off = input.selectionStart;
2820
+ var _faux = fauxContainer;
2821
+ var _fauxContainer = rawTextContainer;
2822
+ if (_faux && _fauxContainer) {
2823
+ // Styles to simulate a node in an input field
2824
+ // use pre-wrap instead of wrap for white-space to support wrapping in textareas
2825
+ 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'];
2826
+
2827
+ // default styles
2828
+ _faux.style.setProperty('white-space', 'pre-wrap');
2829
+ _faux.style.setProperty('padding', '0');
2830
+ _faux.style.setProperty('margin', '0');
2831
+ _faux.style.setProperty('display', 'none');
2832
+ for (var i = 0; i < listOfModifiers.length; i++) {
2833
+ var propertyValue = getElCSS(_fauxContainer, listOfModifiers[i], false);
2834
+ _faux.style.setProperty(listOfModifiers[i], propertyValue);
2835
+ }
2836
+ _faux.textContent = input.value.substring(0, _off).replace(/\s/g, "\xA0");
2837
+ return actualPropertyValue(_faux, 'outerWidth');
2838
+ }
2854
2839
  }
2855
2840
 
2856
2841
  // EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"}
@@ -434,8 +434,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
434
434
  return (/* reexport */_getSpecifiedDate
435
435
  );
436
436
  },
437
- "getTextBoundingRect": function getTextBoundingRect() {
438
- return (/* reexport */_getTextBoundingRect
437
+ "getTextWidth": function getTextWidth() {
438
+ return (/* reexport */_getTextWidth
439
439
  );
440
440
  },
441
441
  "getTodayDate": function getTodayDate() {
@@ -2732,125 +2732,110 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
2732
2732
  }
2733
2733
  ; // CONCATENATED MODULE: ./src/libs/inputs-calculation.ts
2734
2734
  /**
2735
- * Get cursor or text position in pixels for input element
2736
- *
2737
- * @param {HTMLElement} input Required HTMLElement with `value` attribute
2738
- * @param {Number} selectionStart Optional number: Start offset. Default 0
2739
- * @param {Number} selectionEnd Optional number: End offset. Default selectionStart
2740
- * @param {Boolean} debug Optional boolean. If true, the created test layer will not be removed.
2741
- * @returns {JSON}
2742
- * such as:
2743
- {"x":14,"y":42.5,"width":36.1875,"height":19,"top":42.5,"right":50.1875,"bottom":61.5,"left":14}
2744
- */
2745
-
2746
- // Local functions for readability of the previous code
2747
- function appendPart(text, cssDefaultStyles, fakeClone, start, end) {
2748
- var span = document.createElement("span"),
2749
- tmpText = text.substring(start, end);
2750
- span.style.cssText = cssDefaultStyles; //Force styles to prevent unexpected results
2751
- // add a space if it ends in a newline
2752
- if (/[\n\r]$/.test(tmpText)) {
2753
- tmpText += ' ';
2754
- }
2755
- span.textContent = tmpText;
2756
- fakeClone.appendChild(span);
2757
- return span;
2758
- }
2759
- // Computing offset position
2760
- function getInputOffset(input) {
2761
- var body = document.body,
2762
- win = document.defaultView,
2763
- docElem = document.documentElement,
2764
- box = document.createElement('div');
2765
- box.style.paddingLeft = box.style.width = "1px";
2766
- body.appendChild(box);
2767
- var isBoxModel = box.offsetWidth == 2;
2768
- body.removeChild(box);
2769
- box = input.getBoundingClientRect();
2770
- var clientTop = docElem.clientTop || body.clientTop || 0,
2771
- clientLeft = docElem.clientLeft || body.clientLeft || 0,
2772
- scrollTop = win.pageYOffset || isBoxModel && docElem.scrollTop || body.scrollTop,
2773
- scrollLeft = win.pageXOffset || isBoxModel && docElem.scrollLeft || body.scrollLeft;
2774
- return {
2775
- top: box.top + scrollTop - clientTop,
2776
- left: box.left + scrollLeft - clientLeft
2777
- };
2735
+ * Get the actual value with user specific methed
2736
+ * it can be 'width', 'height', 'outerWidth', 'outerHeight'
2737
+ * @private
2738
+ * @param {Element} el - A DOM node containing one selector to match against.
2739
+ * @param {String} prop - A string naming the property of style.
2740
+ * @param {?Json} config - Whether or not margin is included. The key `includeMargin`
2741
+ takes effect when set to true
2742
+ * @return {Number} - Returns a pure number.
2743
+ */
2744
+ function actualPropertyValue(el, prop) {
2745
+ var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
2746
+ if (el === null) return 0;
2747
+ var style = window.getComputedStyle ? window.getComputedStyle(el) : el.currentStyle,
2748
+ display = style.display,
2749
+ position = style.position,
2750
+ visibility = style.visibility;
2751
+ var marginWidth = 0;
2752
+ var marginHeight = 0;
2753
+ var maxVal;
2754
+ var actualVal;
2755
+ if (config && config.includeMargin === true) {
2756
+ marginWidth = parseFloat(style.marginLeft) + parseFloat(style.marginRight);
2757
+ marginHeight = parseFloat(style.marginTop) + parseFloat(style.marginBottom);
2758
+ }
2759
+ if (prop === 'width') {
2760
+ maxVal = parseFloat(style.maxWidth);
2761
+
2762
+ // if its not hidden we just return normal height
2763
+ if (display !== 'none' && maxVal !== 0) {
2764
+ return el.clientWidth;
2765
+ }
2766
+ }
2767
+ if (prop === 'height') {
2768
+ maxVal = parseFloat(style.maxHeight);
2769
+ if (display !== 'none' && maxVal !== 0) {
2770
+ return el.clientHeight;
2771
+ }
2772
+ }
2773
+ if (prop === 'outerWidth') {
2774
+ maxVal = parseFloat(style.maxWidth);
2775
+ if (display !== 'none' && maxVal !== 0) {
2776
+ return el.offsetWidth + marginWidth;
2777
+ }
2778
+ }
2779
+ if (prop === 'outerHeight') {
2780
+ maxVal = parseFloat(style.maxHeight);
2781
+ if (display !== 'none' && maxVal !== 0) {
2782
+ return el.offsetHeight + marginHeight;
2783
+ }
2784
+ }
2785
+
2786
+ // the element is hidden so:
2787
+ // making the el block so we can meassure its height but still be hidden
2788
+ el.style.position = 'absolute';
2789
+ el.style.visibility = 'hidden';
2790
+ el.style.display = 'block';
2791
+ if (prop === 'width') actualVal = el.clientWidth;
2792
+ if (prop === 'height') actualVal = el.clientHeight;
2793
+ if (prop === 'outerWidth') actualVal = el.offsetWidth + marginWidth;
2794
+ if (prop === 'outerHeight') actualVal = el.offsetHeight + marginHeight;
2795
+
2796
+ // reverting to the original values
2797
+ el.style.display = display;
2798
+ el.style.position = position;
2799
+ el.style.visibility = visibility;
2800
+ return actualVal;
2778
2801
  }
2779
- function getInputCSS(input, prop, isnumber) {
2802
+ function getElCSS(input, prop, isNumber) {
2780
2803
  var _document$defaultView;
2781
2804
  var val = (_document$defaultView = document.defaultView) === null || _document$defaultView === void 0 ? void 0 : _document$defaultView.getComputedStyle(input, null).getPropertyValue(prop);
2782
- return isnumber ? parseFloat(val) : val;
2783
- }
2784
- function _getTextBoundingRect(input, selectionStart, selectionEnd) {
2785
- var _fakeClone$parentNode;
2786
- var debug = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
2787
- if (input === null) return 0;
2788
-
2789
- // Basic parameter validation
2790
- if (!input || !('value' in input)) return input;
2791
- if (typeof selectionStart == "string") selectionStart = parseFloat(selectionStart);
2792
- if (typeof selectionStart != "number" || isNaN(selectionStart)) {
2793
- selectionStart = 0;
2794
- }
2795
- if (selectionStart < 0) selectionStart = 0;else selectionStart = Math.min(input.value.length, selectionStart);
2796
- if (typeof selectionEnd == "string") selectionEnd = parseFloat(selectionEnd);
2797
- if (typeof selectionEnd != "number" || isNaN(selectionEnd) || selectionEnd < selectionStart) {
2798
- selectionEnd = selectionStart;
2799
- }
2800
- if (selectionEnd < 0) selectionEnd = 0;else selectionEnd = Math.min(input.value.length, selectionEnd);
2801
-
2802
- // If available (thus IE), use the createTextRange method
2803
- if (typeof input.createTextRange == "function") {
2804
- var range = input.createTextRange();
2805
- range.collapse(true);
2806
- range.moveStart('character', selectionStart);
2807
- range.moveEnd('character', selectionEnd - selectionStart);
2808
- return range.getBoundingClientRect();
2809
- }
2810
- // createTextRange is not supported, create a fake text range
2811
- var offset = getInputOffset(input),
2812
- topPos = offset.top,
2813
- leftPos = offset.left,
2814
- width = getInputCSS(input, 'width', true),
2815
- height = getInputCSS(input, 'height', true);
2816
-
2817
- // Styles to simulate a node in an input field
2818
- // use pre-wrap instead of wrap for white-space to support wrapping in textareas
2819
- var cssDefaultStyles = "white-space:pre-wrap;padding:0;margin:0;",
2820
- 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'];
2821
- topPos += getInputCSS(input, 'padding-top', true);
2822
- topPos += getInputCSS(input, 'border-top-width', true);
2823
- leftPos += getInputCSS(input, 'padding-left', true);
2824
- leftPos += getInputCSS(input, 'border-left-width', true);
2825
- leftPos += 1; //Seems to be necessary
2826
-
2827
- for (var i = 0; i < listOfModifiers.length; i++) {
2828
- var property = listOfModifiers[i];
2829
- cssDefaultStyles += property + ':' + getInputCSS(input, property, false) + ';';
2830
- }
2831
- // End of CSS variable checks
2832
-
2833
- var text = input.value,
2834
- textLen = text.length,
2835
- fakeClone = document.createElement("div");
2836
- if (selectionStart > 0) appendPart(text, cssDefaultStyles, fakeClone, 0, selectionStart);
2837
- var fakeRange = appendPart(text, cssDefaultStyles, fakeClone, selectionStart, selectionEnd);
2838
- if (textLen > selectionEnd) appendPart(text, cssDefaultStyles, fakeClone, selectionEnd, textLen);
2839
-
2840
- // Styles to inherit the font styles of the element
2841
- fakeClone.style.cssText = cssDefaultStyles;
2842
-
2843
- // Styles to position the text node at the desired position
2844
- fakeClone.style.position = "absolute";
2845
- fakeClone.style.top = topPos + "px";
2846
- fakeClone.style.left = leftPos + "px";
2847
- fakeClone.style.width = width + "px";
2848
- fakeClone.style.height = height + "px";
2849
- document.body.appendChild(fakeClone);
2850
- var returnValue = fakeRange.getBoundingClientRect(); //Get rect
2851
-
2852
- if (!debug) (_fakeClone$parentNode = fakeClone.parentNode) === null || _fakeClone$parentNode === void 0 ? void 0 : _fakeClone$parentNode.removeChild(fakeClone); //Remove temp
2853
- return returnValue;
2805
+ return isNumber ? isNaN(parseFloat(val)) ? 0 : parseFloat(val) : val;
2806
+ }
2807
+
2808
+ /**
2809
+ * Get cursor or text position in pixels for input element
2810
+ *
2811
+ * @param {HTMLInputElement} input Required HTMLElement with `value` attribute
2812
+ * @param {HTMLSpanElement} fauxContainer Container of faux.
2813
+ * @param {HTMLElement} rawTextContainer The raw text container for the comparison
2814
+ * @returns {Number}
2815
+ */
2816
+
2817
+ function _getTextWidth(input, fauxContainer, rawTextContainer) {
2818
+ if (input === null || fauxContainer === null || rawTextContainer === null) return 0;
2819
+ var _off = input.selectionStart;
2820
+ var _faux = fauxContainer;
2821
+ var _fauxContainer = rawTextContainer;
2822
+ if (_faux && _fauxContainer) {
2823
+ // Styles to simulate a node in an input field
2824
+ // use pre-wrap instead of wrap for white-space to support wrapping in textareas
2825
+ 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'];
2826
+
2827
+ // default styles
2828
+ _faux.style.setProperty('white-space', 'pre-wrap');
2829
+ _faux.style.setProperty('padding', '0');
2830
+ _faux.style.setProperty('margin', '0');
2831
+ _faux.style.setProperty('display', 'none');
2832
+ for (var i = 0; i < listOfModifiers.length; i++) {
2833
+ var propertyValue = getElCSS(_fauxContainer, listOfModifiers[i], false);
2834
+ _faux.style.setProperty(listOfModifiers[i], propertyValue);
2835
+ }
2836
+ _faux.textContent = input.value.substring(0, _off).replace(/\s/g, "\xA0");
2837
+ return actualPropertyValue(_faux, 'outerWidth');
2838
+ }
2854
2839
  }
2855
2840
 
2856
2841
  // EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"}