UNPKG

@lanaco/lnc-react-ui

Version:

React component library

702 lines (694 loc) 26.2 kB
import { jsxs as ie, jsx as L } from "react/jsx-runtime"; import { P as v } from "./index-S5Cd7WrG.js"; import B, { forwardRef as oe, useState as ne, useCallback as se } from "react"; import { d as fe } from "./index-CkWvbrVT.js"; import { n as G } from "./emotion-styled.browser.esm-CjCaF13H.js"; import { d as M, b as R, a as le, e as ue, h as W, c as ce } from "./utils-DtRLzzTZ.js"; import { u as pe } from "./emotion-element-f0de968e.browser.esm-CkCiQliQ.js"; function E() { } function de() { return !0; } function I(a) { return !!(a || "").match(/\d/); } function Z(a) { return a == null; } function _(a) { return a.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&"); } function me(a) { switch (a) { case "lakh": return /(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g; case "wan": return /(\d)(?=(\d{4})+(?!\d))/g; case "thousand": default: return /(\d)(?=(\d{3})+(?!\d))/g; } } function he(a, f, u) { var e = me(u), t = a.search(/[1-9]/); return t = t === -1 ? a.length : t, a.substring(0, t) + a.substring(t, a.length).replace(e, "$1" + f); } function z(a, f) { f === void 0 && (f = !0); var u = a[0] === "-", e = u && f; a = a.replace("-", ""); var t = a.split("."), r = t[0], o = t[1] || ""; return { beforeDecimal: r, afterDecimal: o, hasNagation: u, addNegation: e }; } function ge(a) { if (!a) return a; var f = a[0] === "-"; f && (a = a.substring(1, a.length)); var u = a.split("."), e = u[0].replace(/^0+/, "") || "0", t = u[1] || ""; return (f ? "-" : "") + e + (t ? "." + t : ""); } function Q(a, f, u) { for (var e = "", t = u ? "0" : "", r = 0; r <= f - 1; r++) e += a[r] || t; return e; } function q(a, f) { return Array(f + 1).join(a); } function ve(a) { a += ""; var f = a[0] === "-" ? "-" : ""; f && (a = a.substring(1)); var u = a.split(/[eE]/g), e = u[0], t = u[1]; if (t = Number(t), !t) return f + e; e = e.replace(".", ""); var r = 1 + t, o = e.length; return r < 0 ? e = "0." + q("0", Math.abs(r)) + e : r >= o ? e = e + q("0", r - o) : e = (e.substring(0, r) || "0") + "." + e.substring(r), f + e; } function Se(a, f, u) { if (["", "-"].indexOf(a) !== -1) return a; var e = a.indexOf(".") !== -1 && f, t = z(a), r = t.beforeDecimal, o = t.afterDecimal, s = t.hasNagation, i = parseFloat("0." + (o || "0")), n = o.length <= f ? "0." + o : i.toFixed(f), l = n.split("."), p = r.split("").reverse().reduce(function(m, S, x) { return m.length > x ? (Number(m[0]) + Number(S)).toString() + m.substring(1, m.length) : S + m; }, l[0]), c = Q( l[1] || "", Math.min(f, o.length), u ), d = s ? "-" : "", h = e ? "." : ""; return "" + d + p + h + c; } function H(a, f) { if (a.value = a.value, a !== null) { if (a.createTextRange) { var u = a.createTextRange(); return u.move("character", f), u.select(), !0; } return a.selectionStart || a.selectionStart === 0 ? (a.focus(), a.setSelectionRange(f, f), !0) : (a.focus(), !1); } } function ye(a, f) { for (var u = 0, e = 0, t = a.length, r = f.length; a[u] === f[u] && u < t; ) u++; for (; a[t - 1 - e] === f[r - 1 - e] && r - e > u && t - e > u; ) e++; return { start: u, end: t - e }; } function K(a, f, u) { return Math.min(Math.max(a, f), u); } function J(a) { return Math.max(a.selectionStart, a.selectionEnd); } function xe(a) { return a || typeof navigator < "u" && !(navigator.platform && /iPhone|iPod/.test(navigator.platform)); } function be(a, f) { var u = {}; for (var e in a) Object.prototype.hasOwnProperty.call(a, e) && f.indexOf(e) === -1 && (u[e] = a[e]); return u; } var Ne = { displayType: "input", decimalSeparator: ".", thousandsGroupStyle: "thousand", fixedDecimalScale: !1, prefix: "", suffix: "", allowNegative: !0, allowEmptyFormatting: !1, allowLeadingZeros: !1, isNumericString: !1, type: "text", onValueChange: E, onChange: E, onKeyDown: E, onMouseUp: E, onFocus: E, onBlur: E, isAllowed: de }, X = /* @__PURE__ */ function(a) { function f(u) { a.call(this, u); var e = u.defaultValue; this.validateProps(); var t = this.formatValueProp(e); this.state = { value: t, numAsString: this.removeFormatting(t), mounted: !1 }, this.selectionBeforeInput = { selectionStart: 0, selectionEnd: 0 }, this.onChange = this.onChange.bind(this), this.onKeyDown = this.onKeyDown.bind(this), this.onMouseUp = this.onMouseUp.bind(this), this.onFocus = this.onFocus.bind(this), this.onBlur = this.onBlur.bind(this); } return a && (f.__proto__ = a), f.prototype = Object.create(a && a.prototype), f.prototype.constructor = f, f.prototype.componentDidMount = function() { this.setState({ mounted: !0 }); }, f.prototype.componentDidUpdate = function(e) { this.updateValueIfRequired(e); }, f.prototype.componentWillUnmount = function() { clearTimeout(this.focusTimeout), clearTimeout(this.caretPositionTimeout); }, f.prototype.updateValueIfRequired = function(e) { var t = this, r = t.props, o = t.state, s = t.focusedElm, i = o.value, n = o.numAsString; if (n === void 0 && (n = ""), e !== r) { this.validateProps(); var l = this.formatNumString(n), p = Z(r.value) ? l : this.formatValueProp(), c = this.removeFormatting(p), d = parseFloat(c), h = parseFloat(n); //while typing set state only when float value changes ((!isNaN(d) || !isNaN(h)) && d !== h || //can also set state when float value is same and the format props changes l !== i || //set state always when not in focus and formatted value is changed s === null && p !== i) && this.updateValue({ formattedValue: p, numAsString: c, input: s, source: "prop", event: null }); } }, f.prototype.getFloatString = function(e) { e === void 0 && (e = ""); var t = this.props, r = t.decimalScale, o = this.getSeparators(), s = o.decimalSeparator, i = this.getNumberRegex(!0), n = e[0] === "-"; n && (e = e.replace("-", "")), s && r === 0 && (e = e.split(s)[0]), e = (e.match(i) || []).join("").replace(s, "."); var l = e.indexOf("."); return l !== -1 && (e = e.substring(0, l) + "." + e.substring(l + 1, e.length).replace(new RegExp(_(s), "g"), "")), n && (e = "-" + e), e; }, f.prototype.getNumberRegex = function(e, t) { var r = this.props, o = r.format, s = r.decimalScale, i = r.customNumerals, n = this.getSeparators(), l = n.decimalSeparator; return new RegExp( "[0-9" + (i ? i.join("") : "") + "]" + (l && s !== 0 && !t && !o ? "|" + _(l) : ""), e ? "g" : void 0 ); }, f.prototype.getSeparators = function() { var e = this.props, t = e.decimalSeparator, r = this.props, o = r.thousandSeparator, s = r.allowedDecimalSeparators; return o === !0 && (o = ","), s || (s = [t, "."]), { decimalSeparator: t, thousandSeparator: o, allowedDecimalSeparators: s }; }, f.prototype.getMaskAtIndex = function(e) { var t = this.props, r = t.mask; return r === void 0 && (r = " "), typeof r == "string" ? r : r[e] || " "; }, f.prototype.getValueObject = function(e, t) { var r = parseFloat(t); return { formattedValue: e, value: t, floatValue: isNaN(r) ? void 0 : r }; }, f.prototype.validateProps = function() { var e = this.props, t = e.mask, r = this.getSeparators(), o = r.decimalSeparator, s = r.thousandSeparator; if (o === s) throw new Error(` Decimal separator can't be same as thousand separator. thousandSeparator: ` + s + ` (thousandSeparator = {true} is same as thousandSeparator = ",") decimalSeparator: ` + o + ` (default value for decimalSeparator is .) `); if (t) { var i = t === "string" ? t : t.toString(); if (i.match(/\d/g)) throw new Error(` Mask ` + t + ` should not contain numeric character; `); } }, f.prototype.setPatchedCaretPosition = function(e, t, r) { H(e, t), this.caretPositionTimeout = setTimeout(function() { e.value === r && H(e, t); }, 0); }, f.prototype.correctCaretPosition = function(e, t, r) { var o = this.props, s = o.prefix, i = o.suffix, n = o.format; if (e === "") return 0; if (t = K(t, 0, e.length), !n) { var l = e[0] === "-"; return K(t, s.length + (l ? 1 : 0), e.length - i.length); } if (typeof n == "function" || n[t] === "#" && I(e[t]) || n[t - 1] === "#" && I(e[t - 1])) return t; var p = n.indexOf("#"), c = n.lastIndexOf("#"); t = K(t, p, c + 1); for (var d = n.substring(t, n.length).indexOf("#"), h = t, m = t + (d === -1 ? 0 : d); h > p && (n[h] !== "#" || !I(e[h])); ) h -= 1; var S = !I(e[m]) || r === "left" && t !== p || t - h < m - t; return S ? I(e[h]) ? h + 1 : h : m; }, f.prototype.getCaretPosition = function(e, t, r) { var o = this.props, s = o.format, i = this.state.value, n = this.getNumberRegex(!0), l = (e.match(n) || []).join(""), p = (t.match(n) || []).join(""), c, d; for (c = 0, d = 0; d < r; d++) { var h = e[d] || "", m = t[c] || ""; if (!(!h.match(n) && h !== m) && !(h === "0" && m.match(n) && m !== "0" && l.length !== p.length)) { for (; h !== t[c] && c < t.length; ) c++; c++; } } return typeof s == "string" && !i && (c = t.length), c = this.correctCaretPosition(t, c), c; }, f.prototype.removePrefixAndSuffix = function(e) { var t = this.props, r = t.format, o = t.prefix, s = t.suffix; if (!r && e) { var i = e[0] === "-"; i && (e = e.substring(1, e.length)), e = o && e.indexOf(o) === 0 ? e.substring(o.length, e.length) : e; var n = e.lastIndexOf(s); e = s && n !== -1 && n === e.length - s.length ? e.substring(0, n) : e, i && (e = "-" + e); } return e; }, f.prototype.removePatternFormatting = function(e) { for (var t = this.props, r = t.format, o = r.split("#").filter(function(d) { return d !== ""; }), s = 0, i = "", n = 0, l = o.length; n <= l; n++) { var p = o[n] || "", c = n === l ? e.length : e.indexOf(p, s); if (c === -1) { i = e; break; } else i += e.substring(s, c), s = c + p.length; } return (i.match(this.getNumberRegex(!0)) || []).join(""); }, f.prototype.removeFormatting = function(e) { var t = this.props, r = t.format, o = t.removeFormatting; return e && (r ? typeof r == "string" ? e = this.removePatternFormatting(e) : typeof o == "function" ? e = o(e) : e = (e.match(this.getNumberRegex(!0)) || []).join("") : (e = this.removePrefixAndSuffix(e), e = this.getFloatString(e)), e); }, f.prototype.formatWithPattern = function(e) { for (var t = this.props, r = t.format, o = 0, s = r.split(""), i = 0, n = r.length; i < n; i++) r[i] === "#" && (s[i] = e[o] || this.getMaskAtIndex(o), o += 1); return s.join(""); }, f.prototype.formatAsNumber = function(e) { var t = this.props, r = t.decimalScale, o = t.fixedDecimalScale, s = t.prefix, i = t.suffix, n = t.allowNegative, l = t.thousandsGroupStyle, p = this.getSeparators(), c = p.thousandSeparator, d = p.decimalSeparator, h = e.indexOf(".") !== -1 || r && o, m = z(e, n), S = m.beforeDecimal, x = m.afterDecimal, b = m.addNegation; return r !== void 0 && (x = Q(x, r, o)), c && (S = he(S, c, l)), s && (S = s + S), i && (x = x + i), b && (S = "-" + S), e = S + (h && d || "") + x, e; }, f.prototype.formatNumString = function(e) { e === void 0 && (e = ""); var t = this.props, r = t.format, o = t.allowEmptyFormatting, s = t.customNumerals, i = e; if (s && s.length === 10) { var n = new RegExp("[" + s.join("") + "]", "g"); i = e.replace( n, function(l) { return s.indexOf(l).toString(); } ); } return e === "" && !o ? i = "" : e === "-" && !r ? i = "-" : typeof r == "string" ? i = this.formatWithPattern(i) : typeof r == "function" ? i = r(i) : i = this.formatAsNumber(i), i; }, f.prototype.formatValueProp = function(e) { var t = this.props, r = t.format, o = t.decimalScale, s = t.fixedDecimalScale, i = t.allowEmptyFormatting, n = this.props, l = n.value, p = n.isNumericString; l = Z(l) ? e : l; var c = !l && l !== 0; if (c && i && (l = ""), c && !i) return ""; typeof l == "number" && (l = ve(l), p = !0), l === "Infinity" && p && (l = ""), p && !r && typeof o == "number" && (l = Se(l, o, s)); var d = p ? this.formatNumString(l) : this.formatInput(l); return d; }, f.prototype.formatNegation = function(e) { e === void 0 && (e = ""); var t = this.props, r = t.allowNegative, o = new RegExp("(-)"), s = new RegExp("(-)(.)*(-)"), i = o.test(e), n = s.test(e); return e = e.replace(/-/g, ""), i && !n && r && (e = "-" + e), e; }, f.prototype.formatInput = function(e) { e === void 0 && (e = ""); var t = this.props, r = t.format; return r || (e = this.removePrefixAndSuffix(e), e = this.formatNegation(e)), e = this.removeFormatting(e), this.formatNumString(e); }, f.prototype.isCharacterAFormat = function(e, t) { var r = this.props, o = r.format, s = r.prefix, i = r.suffix, n = r.decimalScale, l = r.fixedDecimalScale, p = this.getSeparators(), c = p.decimalSeparator; return !!(typeof o == "string" && o[e] !== "#" || !o && (e < s.length || e >= t.length - i.length || n && l && t[e] === c)); }, f.prototype.correctInputValue = function(e, t, r) { var o = this, s = this.props, i = s.format, n = s.allowNegative, l = s.prefix, p = s.suffix, c = s.decimalScale, d = this.getSeparators(), h = d.allowedDecimalSeparators, m = d.decimalSeparator, S = this.state.numAsString || "", x = this.selectionBeforeInput, b = x.selectionStart, w = x.selectionEnd, P = ye(t, r), g = P.start, N = P.end; if (!i && g === N && h.indexOf(r[b]) !== -1) { var F = c === 0 ? "" : m; return r.substr(0, b) + F + r.substr(b + 1, r.length); } var T = i ? 0 : l.length, $ = t.length - (i ? 0 : p.length); if ( // don't do anything if something got added r.length > t.length || // or if the new value is an empty string !r.length || // or if nothing has changed, in which case start will be same as end g === N || // or in case if whole input is selected and new value is typed b === 0 && w === t.length || // or in case if the whole content is replaced by browser, example (autocomplete) g === 0 && N === t.length || // or if charcters between prefix and suffix is selected. // For numeric inputs we apply the format so, prefix and suffix can be ignored b === T && w === $ ) return r; var O = t.substr(g, N - g), j = !![].concat(O).find( function(C, V) { return o.isCharacterAFormat(V + g, t); } ); if (j) { var k = t.substr(g), A = {}, y = []; [].concat(k).forEach(function(C, V) { o.isCharacterAFormat(V + g, t) ? A[V] = C : V > O.length - 1 && y.push(C); }), Object.keys(A).forEach(function(C) { y.length > C ? y.splice(C, 0, A[C]) : y.push(A[C]); }), r = t.substr(0, g) + y.join(""); } if (!i) { var D = this.removeFormatting(r), U = z( D, n ), ee = U.beforeDecimal, te = U.afterDecimal, re = U.addNegation, ae = e < r.indexOf(m) + 1; if (D.length < S.length && ae && ee === "" && !parseFloat(te)) return re ? "-" : ""; } return r; }, f.prototype.updateValue = function(e) { var t = e.formattedValue, r = e.input, o = e.setCaretPosition; o === void 0 && (o = !0); var s = e.source, i = e.event, n = e.numAsString, l = e.caretPos, p = this.props, c = p.onValueChange, d = this.state, h = d.value; if (r) { if (l === void 0 && o) { var m = e.inputValue || r.value, S = J(r); r.value = t, l = this.getCaretPosition(m, t, S); } r.value = t, o && this.setPatchedCaretPosition(r, l, t); } n === void 0 && (n = this.removeFormatting(t)), t !== h && (this.setState({ value: t, numAsString: n }), c(this.getValueObject(t, n), { event: i, source: s })); }, f.prototype.onChange = function(e) { var t = e.target, r = t.value, o = this, s = o.state, i = o.props, n = i.isAllowed, l = s.value || "", p = J(t); r = this.correctInputValue(p, l, r); var c = this.formatInput(r) || "", d = this.removeFormatting(c), h = this.getValueObject(c, d), m = n(h); m || (c = l), this.updateValue({ formattedValue: c, numAsString: d, inputValue: r, input: t, event: e, source: "event" }), m && i.onChange(e); }, f.prototype.onBlur = function(e) { var t = this, r = t.props, o = t.state, s = r.format, i = r.onBlur, n = r.allowLeadingZeros, l = o.numAsString, p = o.value; if (this.focusedElm = null, clearTimeout(this.focusTimeout), clearTimeout(this.caretPositionTimeout), !s) { isNaN(parseFloat(l)) && (l = ""), n || (l = ge(l)); var c = this.formatNumString(l); if (c !== p) { this.updateValue({ formattedValue: c, numAsString: l, input: e.target, setCaretPosition: !1, event: e, source: "event" }), i(e); return; } } i(e); }, f.prototype.onKeyDown = function(e) { var t = e.target, r = e.key, o = t.selectionStart, s = t.selectionEnd, i = t.value; i === void 0 && (i = ""); var n, l = this.props, p = l.decimalScale, c = l.fixedDecimalScale, d = l.prefix, h = l.suffix, m = l.format, S = l.onKeyDown, x = p !== void 0 && c, b = this.getNumberRegex(!1, x), w = new RegExp("-"), P = typeof m == "string"; if (this.selectionBeforeInput = { selectionStart: o, selectionEnd: s }, r === "ArrowLeft" || r === "Backspace" ? n = o - 1 : r === "ArrowRight" ? n = o + 1 : r === "Delete" && (n = o), n === void 0 || o !== s) { S(e); return; } var g = n, N = P ? m.indexOf("#") : d.length, F = P ? m.lastIndexOf("#") + 1 : i.length - h.length; if (r === "ArrowLeft" || r === "ArrowRight") { var T = r === "ArrowLeft" ? "left" : "right"; g = this.correctCaretPosition(i, n, T); } else if (r === "Delete" && !b.test(i[n]) && !w.test(i[n])) for (; !b.test(i[g]) && g < F; ) g++; else if (r === "Backspace" && !b.test(i[n])) { if (o <= N + 1 && i[0] === "-" && typeof m > "u") { var $ = i.substring(1); this.updateValue({ formattedValue: $, caretPos: g, input: t, event: e, source: "event" }); } else if (!w.test(i[n])) { for (; !b.test(i[g - 1]) && g > N; ) g--; g = this.correctCaretPosition(i, g, "left"); } } (g !== n || n < N || n > F) && (e.preventDefault(), this.setPatchedCaretPosition(t, g, i)), e.isUnitTestRun && this.setPatchedCaretPosition(t, g, i), S(e); }, f.prototype.onMouseUp = function(e) { var t = e.target, r = t.selectionStart, o = t.selectionEnd, s = t.value; if (s === void 0 && (s = ""), r === o) { var i = this.correctCaretPosition(s, r); i !== r && this.setPatchedCaretPosition(t, i, s); } this.props.onMouseUp(e); }, f.prototype.onFocus = function(e) { var t = this; e.persist(), this.focusedElm = e.target, this.focusTimeout = setTimeout(function() { var r = e.target, o = r.selectionStart, s = r.selectionEnd, i = r.value; i === void 0 && (i = ""); var n = t.correctCaretPosition(i, o); n !== o && !(o === 0 && s === i.length) && t.setPatchedCaretPosition(r, n, i), t.props.onFocus(e); }, 0); }, f.prototype.render = function() { var e = this.props, t = e.type, r = e.displayType, o = e.customInput, s = e.renderText, i = e.getInputRef, n = e.format; e.thousandSeparator, e.decimalSeparator, e.allowedDecimalSeparators, e.thousandsGroupStyle, e.decimalScale, e.fixedDecimalScale, e.prefix, e.suffix, e.removeFormatting, e.mask, e.defaultValue, e.isNumericString, e.allowNegative, e.allowEmptyFormatting, e.allowLeadingZeros, e.onValueChange, e.isAllowed, e.customNumerals, e.onChange, e.onKeyDown, e.onMouseUp, e.onFocus, e.onBlur, e.value; var l = be(e, ["type", "displayType", "customInput", "renderText", "getInputRef", "format", "thousandSeparator", "decimalSeparator", "allowedDecimalSeparators", "thousandsGroupStyle", "decimalScale", "fixedDecimalScale", "prefix", "suffix", "removeFormatting", "mask", "defaultValue", "isNumericString", "allowNegative", "allowEmptyFormatting", "allowLeadingZeros", "onValueChange", "isAllowed", "customNumerals", "onChange", "onKeyDown", "onMouseUp", "onFocus", "onBlur", "value"]), p = l, c = this.state, d = c.value, h = c.mounted, m = h && xe(n) ? "numeric" : void 0, S = Object.assign({ inputMode: m }, p, { type: t, value: d, onChange: this.onChange, onKeyDown: this.onKeyDown, onMouseUp: this.onMouseUp, onFocus: this.onFocus, onBlur: this.onBlur }); if (r === "text") return s ? s(d, p) || null : B.createElement( "span", Object.assign({}, p, { ref: i }), d ); if (o) { var x = o; return B.createElement(x, Object.assign({}, S, { ref: i })); } return B.createElement("input", Object.assign({}, S, { ref: i })); }, f; }(B.Component); X.defaultProps = Ne; const we = G.div` display: flex; align-items: center; min-height: ${(a) => M(a.theme, a.size)}; max-height: ${(a) => M(a.theme, a.size)}; background-color: ${(a) => R( a.theme, "Input", a.color, "enabled", "background" )}; border: 1px solid ${(a) => R( a.theme, "Input", a.focused === !0 ? "primary" : a.color, "enabled", "border" )}; border-radius: ${(a) => le(a.theme, "regular")}; ${(a) => a.focused === !0 && a.readOnly !== !0 ? ue(a.theme) : ""} ${(a) => a.isDisabled === !0 ? W(a.theme) : ""} ${(a) => a.isDisabled === !0 ? "border: 1px solid " + R( a.theme, "Input", a.color, "disabled", "border" ) : ""} & input { background: none; border: none; outline: none; padding-top: 0.625rem; padding-bottom: 0.625rem; width: 100%; ${(a) => ce(a.theme, "Input", a.size, "enabled")} min-height: ${(a) => M(a.theme, a.size)}; max-height: ${(a) => M(a.theme, a.size)}; color: ${(a) => R( a.theme, "Input", a.focused === !0 ? "primary" : a.color, "enabled", "text" )}; caret-color: ${(a) => R(a.theme, "Input", a.color, "enabled", "caret")}; padding-right: ${(a) => a.suffix ? "0" : "0.75rem"}; padding-left: ${(a) => a.prefix ? "0" : "0.75rem"}; } & input:disabled { ${(a) => W(a.theme)} background: none; } & input:read-only { cursor: default; } & input::placeholder { color: ${(a) => R( a.theme, "Input", a.color, "enabled", "placeholder" )}; } `, Y = G.span` padding: 0 12px; color: ${(a) => R( a.theme, "Input", a.focused === !0 ? "primary" : a.color, "enabled", "prefix" )}; `, De = G(Y)``, Ce = oe((a, f) => { const { disabled: u, readOnly: e, debounceTime: t = 0, prefix: r, suffix: o, thousandSeparator: s = ".", decimalSeparator: i = ",", decimalScale: n = 2, fixedDecimalScale: l = !0, allowNegative: p = !0, //---------------- onChange: c, onBlur: d, onFocus: h, onInputChange: m, //---------------- className: S = "", style: x = {}, size: b = "small", color: w = "primary", ...P } = a, g = pe(), [N, F] = ne(!1), T = se( fe((y, D) => $(y, D), t), [c] ), $ = (y, D) => { c && (c == null || c(y, D)), m == null || m(y, D); }, O = (y, D) => { T(D.event, y == null ? void 0 : y.floatValue); }, j = () => n < 0 ? 0 : n > 17 ? 17 : n, k = (y) => { F(!0), h == null || h(y); }, A = (y) => { F(!1), d == null || d(y); }; return /* @__PURE__ */ ie( we, { style: x, className: S, theme: g, color: w, size: b, prefix: r, suffix: o, focused: N, disabled: u, readOnly: e, children: [ r && /* @__PURE__ */ L( Y, { theme: g, color: w, focused: N, className: "lnc-input-prefix", children: r } ), /* @__PURE__ */ L( X, { getInputRef: f, className: "lnc-decimal-input", disabled: u, readOnly: e, thousandSeparator: s, decimalSeparator: i, decimalScale: j(), fixedDecimalScale: l, allowNegative: p, onFocus: k, onBlur: A, onValueChange: O, ...P } ), o && /* @__PURE__ */ L( De, { theme: g, color: w, focused: N, className: "lnc-input-suffix", children: o } ) ] } ); }); Ce.propTypes = { id: v.string, value: v.any, defaultValue: v.any, disabled: v.bool, readOnly: v.bool, debounceTime: v.number, /** * Reserved space before input. Intented to be used with plain text or `Icon` component. */ prefix: v.oneOfType([v.string, v.element]), /** * Reserved space after input. Intented to be used with plain text or `Icon` component. */ suffix: v.oneOfType([v.string, v.element]), thousandSeparator: v.oneOf([".", ",", " "]), decimalSeparator: v.oneOf([".", ","]), decimalScale: v.number, fixedDecimalScale: v.bool, allowNegative: v.bool, //---------------- /** * `(event, value) => void` */ onChange: v.func, /** * `(event, value) => void` */ onInputChange: v.func, /** * `(event) => void` */ onBlur: v.func, /** * `(event) => void` */ onFocus: v.func, //---------------- className: v.string, style: v.object, size: v.oneOf(["small", "medium", "large"]), color: v.oneOf([ "primary", "secondary", "success", "danger", "warning", "information", "neutral", "gray" ]) }; export { Ce as default };