UNPKG

virtualdropdown-select

Version:

A component that allows us to use select and search for long select options.

1,251 lines (1,248 loc) 44.8 kB
import nt, { createElement as Te, PureComponent as Ct, useState as ie, useRef as Ie, useEffect as Ce, useMemo as Pt } from "react"; var ve = { exports: {} }, le = {}; /** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var Ke; function kt() { if (Ke) return le; Ke = 1; var o = nt, n = Symbol.for("react.element"), l = Symbol.for("react.fragment"), f = Object.prototype.hasOwnProperty, y = o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, W = { key: !0, ref: !0, __self: !0, __source: !0 }; function D(x, b, C) { var p, O = {}, P = null, k = null; C !== void 0 && (P = "" + C), b.key !== void 0 && (P = "" + b.key), b.ref !== void 0 && (k = b.ref); for (p in b) f.call(b, p) && !W.hasOwnProperty(p) && (O[p] = b[p]); if (x && x.defaultProps) for (p in b = x.defaultProps, b) O[p] === void 0 && (O[p] = b[p]); return { $$typeof: n, type: x, key: P, ref: k, props: O, _owner: y.current }; } return le.Fragment = l, le.jsx = D, le.jsxs = D, le; } var ce = {}; /** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var Je; function zt() { return Je || (Je = 1, process.env.NODE_ENV !== "production" && function() { var o = nt, n = Symbol.for("react.element"), l = Symbol.for("react.portal"), f = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), W = Symbol.for("react.profiler"), D = Symbol.for("react.provider"), x = Symbol.for("react.context"), b = Symbol.for("react.forward_ref"), C = Symbol.for("react.suspense"), p = Symbol.for("react.suspense_list"), O = Symbol.for("react.memo"), P = Symbol.for("react.lazy"), k = Symbol.for("react.offscreen"), R = Symbol.iterator, t = "@@iterator"; function c(e) { if (e === null || typeof e != "object") return null; var r = R && e[R] || e[t]; return typeof r == "function" ? r : null; } var a = o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; function s(e) { { for (var r = arguments.length, i = new Array(r > 1 ? r - 1 : 0), u = 1; u < r; u++) i[u - 1] = arguments[u]; v("error", e, i); } } function v(e, r, i) { { var u = a.ReactDebugCurrentFrame, w = u.getStackAddendum(); w !== "" && (r += "%s", i = i.concat([w])); var E = i.map(function(g) { return String(g); }); E.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, E); } } var S = !1, h = !1, _ = !1, I = !1, M = !1, N; N = Symbol.for("react.module.reference"); function K(e) { return !!(typeof e == "string" || typeof e == "function" || e === f || e === W || M || e === y || e === C || e === p || I || e === k || S || h || _ || typeof e == "object" && e !== null && (e.$$typeof === P || e.$$typeof === O || e.$$typeof === D || e.$$typeof === x || e.$$typeof === b || // This needs to include all possible module reference object // types supported by any Flight configuration anywhere since // we don't know which Flight build this will end up being used // with. e.$$typeof === N || e.getModuleId !== void 0)); } function X(e, r, i) { var u = e.displayName; if (u) return u; var w = r.displayName || r.name || ""; return w !== "" ? i + "(" + w + ")" : i; } function J(e) { return e.displayName || "Context"; } function U(e) { if (e == null) return null; if (typeof e.tag == "number" && s("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function") return e.displayName || e.name || null; if (typeof e == "string") return e; switch (e) { case f: return "Fragment"; case l: return "Portal"; case W: return "Profiler"; case y: return "StrictMode"; case C: return "Suspense"; case p: return "SuspenseList"; } if (typeof e == "object") switch (e.$$typeof) { case x: var r = e; return J(r) + ".Consumer"; case D: var i = e; return J(i._context) + ".Provider"; case b: return X(e, e.render, "ForwardRef"); case O: var u = e.displayName || null; return u !== null ? u : U(e.type) || "Memo"; case P: { var w = e, E = w._payload, g = w._init; try { return U(g(E)); } catch { return null; } } } return null; } var B = Object.assign, G = 0, te, d, T, z, F, L, q; function Q() { } Q.__reactDisabledLog = !0; function Z() { { if (G === 0) { te = console.log, d = console.info, T = console.warn, z = console.error, F = console.group, L = console.groupCollapsed, q = console.groupEnd; var e = { configurable: !0, enumerable: !0, value: Q, writable: !0 }; Object.defineProperties(console, { info: e, log: e, warn: e, error: e, group: e, groupCollapsed: e, groupEnd: e }); } G++; } } function ue() { { if (G--, G === 0) { var e = { configurable: !0, enumerable: !0, writable: !0 }; Object.defineProperties(console, { log: B({}, e, { value: te }), info: B({}, e, { value: d }), warn: B({}, e, { value: T }), error: B({}, e, { value: z }), group: B({}, e, { value: F }), groupCollapsed: B({}, e, { value: L }), groupEnd: B({}, e, { value: q }) }); } G < 0 && s("disabledDepth fell below zero. This is a bug in React. Please file an issue."); } } var ye = a.ReactCurrentDispatcher, be; function fe(e, r, i) { { if (be === void 0) try { throw Error(); } catch (w) { var u = w.stack.trim().match(/\n( *(at )?)/); be = u && u[1] || ""; } return ` ` + be + e; } } var Se = !1, de; { var it = typeof WeakMap == "function" ? WeakMap : Map; de = new it(); } function Ae(e, r) { if (!e || Se) return ""; { var i = de.get(e); if (i !== void 0) return i; } var u; Se = !0; var w = Error.prepareStackTrace; Error.prepareStackTrace = void 0; var E; E = ye.current, ye.current = null, Z(); try { if (r) { var g = function() { throw Error(); }; if (Object.defineProperty(g.prototype, "props", { set: function() { throw Error(); } }), typeof Reflect == "object" && Reflect.construct) { try { Reflect.construct(g, []); } catch (Y) { u = Y; } Reflect.construct(e, [], g); } else { try { g.call(); } catch (Y) { u = Y; } e.call(g.prototype); } } else { try { throw Error(); } catch (Y) { u = Y; } e(); } } catch (Y) { if (Y && u && typeof Y.stack == "string") { for (var m = Y.stack.split(` `), $ = u.stack.split(` `), j = m.length - 1, A = $.length - 1; j >= 1 && A >= 0 && m[j] !== $[A]; ) A--; for (; j >= 1 && A >= 0; j--, A--) if (m[j] !== $[A]) { if (j !== 1 || A !== 1) do if (j--, A--, A < 0 || m[j] !== $[A]) { var H = ` ` + m[j].replace(" at new ", " at "); return e.displayName && H.includes("<anonymous>") && (H = H.replace("<anonymous>", e.displayName)), typeof e == "function" && de.set(e, H), H; } while (j >= 1 && A >= 0); break; } } } finally { Se = !1, ye.current = E, ue(), Error.prepareStackTrace = w; } var ne = e ? e.displayName || e.name : "", ee = ne ? fe(ne) : ""; return typeof e == "function" && de.set(e, ee), ee; } function ot(e, r, i) { return Ae(e, !1); } function at(e) { var r = e.prototype; return !!(r && r.isReactComponent); } function pe(e, r, i) { if (e == null) return ""; if (typeof e == "function") return Ae(e, at(e)); if (typeof e == "string") return fe(e); switch (e) { case C: return fe("Suspense"); case p: return fe("SuspenseList"); } if (typeof e == "object") switch (e.$$typeof) { case b: return ot(e.render); case O: return pe(e.type, r, i); case P: { var u = e, w = u._payload, E = u._init; try { return pe(E(w), r, i); } catch { } } } return ""; } var ae = Object.prototype.hasOwnProperty, De = {}, We = a.ReactDebugCurrentFrame; function he(e) { if (e) { var r = e._owner, i = pe(e.type, e._source, r ? r.type : null); We.setExtraStackFrame(i); } else We.setExtraStackFrame(null); } function st(e, r, i, u, w) { { var E = Function.call.bind(ae); for (var g in e) if (E(e, g)) { var m = void 0; try { if (typeof e[g] != "function") { var $ = Error((u || "React class") + ": " + i + " type `" + g + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[g] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); throw $.name = "Invariant Violation", $; } m = e[g](r, g, u, i, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); } catch (j) { m = j; } m && !(m instanceof Error) && (he(w), s("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", u || "React class", i, g, typeof m), he(null)), m instanceof Error && !(m.message in De) && (De[m.message] = !0, he(w), s("Failed %s type: %s", i, m.message), he(null)); } } } var lt = Array.isArray; function _e(e) { return lt(e); } function ct(e) { { var r = typeof Symbol == "function" && Symbol.toStringTag, i = r && e[Symbol.toStringTag] || e.constructor.name || "Object"; return i; } } function ut(e) { try { return Fe(e), !1; } catch { return !0; } } function Fe(e) { return "" + e; } function Me(e) { if (ut(e)) return s("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", ct(e)), Fe(e); } var se = a.ReactCurrentOwner, ft = { key: !0, ref: !0, __self: !0, __source: !0 }, Ne, Le, we; we = {}; function dt(e) { if (ae.call(e, "ref")) { var r = Object.getOwnPropertyDescriptor(e, "ref").get; if (r && r.isReactWarning) return !1; } return e.ref !== void 0; } function pt(e) { if (ae.call(e, "key")) { var r = Object.getOwnPropertyDescriptor(e, "key").get; if (r && r.isReactWarning) return !1; } return e.key !== void 0; } function ht(e, r) { if (typeof e.ref == "string" && se.current && r && se.current.stateNode !== r) { var i = U(se.current.type); we[i] || (s('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', U(se.current.type), e.ref), we[i] = !0); } } function vt(e, r) { { var i = function() { Ne || (Ne = !0, s("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r)); }; i.isReactWarning = !0, Object.defineProperty(e, "key", { get: i, configurable: !0 }); } } function mt(e, r) { { var i = function() { Le || (Le = !0, s("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r)); }; i.isReactWarning = !0, Object.defineProperty(e, "ref", { get: i, configurable: !0 }); } } var gt = function(e, r, i, u, w, E, g) { var m = { // This tag allows us to uniquely identify this as a React Element $$typeof: n, // Built-in properties that belong on the element type: e, key: r, ref: i, props: g, // Record the component responsible for creating this element. _owner: E }; return m._store = {}, Object.defineProperty(m._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: !1 }), Object.defineProperty(m, "_self", { configurable: !1, enumerable: !1, writable: !1, value: u }), Object.defineProperty(m, "_source", { configurable: !1, enumerable: !1, writable: !1, value: w }), Object.freeze && (Object.freeze(m.props), Object.freeze(m)), m; }; function yt(e, r, i, u, w) { { var E, g = {}, m = null, $ = null; i !== void 0 && (Me(i), m = "" + i), pt(r) && (Me(r.key), m = "" + r.key), dt(r) && ($ = r.ref, ht(r, w)); for (E in r) ae.call(r, E) && !ft.hasOwnProperty(E) && (g[E] = r[E]); if (e && e.defaultProps) { var j = e.defaultProps; for (E in j) g[E] === void 0 && (g[E] = j[E]); } if (m || $) { var A = typeof e == "function" ? e.displayName || e.name || "Unknown" : e; m && vt(g, A), $ && mt(g, A); } return gt(e, m, $, w, u, se.current, g); } } var xe = a.ReactCurrentOwner, $e = a.ReactDebugCurrentFrame; function re(e) { if (e) { var r = e._owner, i = pe(e.type, e._source, r ? r.type : null); $e.setExtraStackFrame(i); } else $e.setExtraStackFrame(null); } var Re; Re = !1; function Ee(e) { return typeof e == "object" && e !== null && e.$$typeof === n; } function Ve() { { if (xe.current) { var e = U(xe.current.type); if (e) return ` Check the render method of \`` + e + "`."; } return ""; } } function bt(e) { return ""; } var Ue = {}; function St(e) { { var r = Ve(); if (!r) { var i = typeof e == "string" ? e : e.displayName || e.name; i && (r = ` Check the top-level render call using <` + i + ">."); } return r; } } function Ye(e, r) { { if (!e._store || e._store.validated || e.key != null) return; e._store.validated = !0; var i = St(r); if (Ue[i]) return; Ue[i] = !0; var u = ""; e && e._owner && e._owner !== xe.current && (u = " It was passed a child from " + U(e._owner.type) + "."), re(e), s('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', i, u), re(null); } } function qe(e, r) { { if (typeof e != "object") return; if (_e(e)) for (var i = 0; i < e.length; i++) { var u = e[i]; Ee(u) && Ye(u, r); } else if (Ee(e)) e._store && (e._store.validated = !0); else if (e) { var w = c(e); if (typeof w == "function" && w !== e.entries) for (var E = w.call(e), g; !(g = E.next()).done; ) Ee(g.value) && Ye(g.value, r); } } } function _t(e) { { var r = e.type; if (r == null || typeof r == "string") return; var i; if (typeof r == "function") i = r.propTypes; else if (typeof r == "object" && (r.$$typeof === b || // Note: Memo only checks outer props here. // Inner props are checked in the reconciler. r.$$typeof === O)) i = r.propTypes; else return; if (i) { var u = U(r); st(i, e.props, "prop", u, e); } else if (r.PropTypes !== void 0 && !Re) { Re = !0; var w = U(r); s("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", w || "Unknown"); } typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && s("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); } } function wt(e) { { for (var r = Object.keys(e.props), i = 0; i < r.length; i++) { var u = r[i]; if (u !== "children" && u !== "key") { re(e), s("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", u), re(null); break; } } e.ref !== null && (re(e), s("Invalid attribute `ref` supplied to `React.Fragment`."), re(null)); } } var Be = {}; function He(e, r, i, u, w, E) { { var g = K(e); if (!g) { var m = ""; (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (m += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); var $ = bt(); $ ? m += $ : m += Ve(); var j; e === null ? j = "null" : _e(e) ? j = "array" : e !== void 0 && e.$$typeof === n ? (j = "<" + (U(e.type) || "Unknown") + " />", m = " Did you accidentally export a JSX literal instead of a component?") : j = typeof e, s("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", j, m); } var A = yt(e, r, i, w, E); if (A == null) return A; if (g) { var H = r.children; if (H !== void 0) if (u) if (_e(H)) { for (var ne = 0; ne < H.length; ne++) qe(H[ne], e); Object.freeze && Object.freeze(H); } else s("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); else qe(H, e); } if (ae.call(r, "key")) { var ee = U(e), Y = Object.keys(r).filter(function(It) { return It !== "key"; }), Oe = Y.length > 0 ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}"; if (!Be[ee + Oe]) { var Tt = Y.length > 0 ? "{" + Y.join(": ..., ") + ": ...}" : "{}"; s(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`, Oe, ee, Tt, ee), Be[ee + Oe] = !0; } } return e === f ? wt(A) : _t(A), A; } } function xt(e, r, i) { return He(e, r, i, !0); } function Rt(e, r, i) { return He(e, r, i, !1); } var Et = Rt, Ot = xt; ce.Fragment = f, ce.jsx = Et, ce.jsxs = Ot; }()), ce; } var Ge; function jt() { return Ge || (Ge = 1, process.env.NODE_ENV === "production" ? ve.exports = kt() : ve.exports = zt()), ve.exports; } var V = jt(); function ze() { return ze = Object.assign ? Object.assign.bind() : function(o) { for (var n = 1; n < arguments.length; n++) { var l = arguments[n]; for (var f in l) ({}).hasOwnProperty.call(l, f) && (o[f] = l[f]); } return o; }, ze.apply(null, arguments); } function Xe(o) { if (o === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return o; } function je(o, n) { return je = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(l, f) { return l.__proto__ = f, l; }, je(o, n); } function At(o, n) { o.prototype = Object.create(n.prototype), o.prototype.constructor = o, je(o, n); } var Qe = Number.isNaN || function(n) { return typeof n == "number" && n !== n; }; function Dt(o, n) { return !!(o === n || Qe(o) && Qe(n)); } function Wt(o, n) { if (o.length !== n.length) return !1; for (var l = 0; l < o.length; l++) if (!Dt(o[l], n[l])) return !1; return !0; } function Pe(o, n) { n === void 0 && (n = Wt); var l, f = [], y, W = !1; function D() { for (var x = [], b = 0; b < arguments.length; b++) x[b] = arguments[b]; return W && l === this && n(x, f) || (y = o.apply(this, x), W = !0, l = this, f = x), y; } return D; } var Ft = typeof performance == "object" && typeof performance.now == "function", Ze = Ft ? function() { return performance.now(); } : function() { return Date.now(); }; function et(o) { cancelAnimationFrame(o.id); } function Mt(o, n) { var l = Ze(); function f() { Ze() - l >= n ? o.call(null) : y.id = requestAnimationFrame(f); } var y = { id: requestAnimationFrame(f) }; return y; } var ke = -1; function tt(o) { if (o === void 0 && (o = !1), ke === -1 || o) { var n = document.createElement("div"), l = n.style; l.width = "50px", l.height = "50px", l.overflow = "scroll", document.body.appendChild(n), ke = n.offsetWidth - n.clientWidth, document.body.removeChild(n); } return ke; } var oe = null; function rt(o) { if (o === void 0 && (o = !1), oe === null || o) { var n = document.createElement("div"), l = n.style; l.width = "50px", l.height = "50px", l.overflow = "scroll", l.direction = "rtl"; var f = document.createElement("div"), y = f.style; return y.width = "100px", y.height = "100px", n.appendChild(f), document.body.appendChild(n), n.scrollLeft > 0 ? oe = "positive-descending" : (n.scrollLeft = 1, n.scrollLeft === 0 ? oe = "negative" : oe = "positive-ascending"), document.body.removeChild(n), oe; } return oe; } process.env.NODE_ENV; var Nt = 150, Lt = function(n, l) { return n; }, me = null, ge = null; process.env.NODE_ENV !== "production" && typeof window < "u" && typeof window.WeakSet < "u" && (me = /* @__PURE__ */ new WeakSet(), ge = /* @__PURE__ */ new WeakSet()); function $t(o) { var n, l = o.getItemOffset, f = o.getEstimatedTotalSize, y = o.getItemSize, W = o.getOffsetForIndexAndAlignment, D = o.getStartIndexForOffset, x = o.getStopIndexForStartIndex, b = o.initInstanceProps, C = o.shouldResetStyleCacheOnItemSizeChange, p = o.validateProps; return n = /* @__PURE__ */ function(O) { At(P, O); function P(R) { var t; return t = O.call(this, R) || this, t._instanceProps = b(t.props, Xe(t)), t._outerRef = void 0, t._resetIsScrollingTimeoutId = null, t.state = { instance: Xe(t), isScrolling: !1, scrollDirection: "forward", scrollOffset: typeof t.props.initialScrollOffset == "number" ? t.props.initialScrollOffset : 0, scrollUpdateWasRequested: !1 }, t._callOnItemsRendered = void 0, t._callOnItemsRendered = Pe(function(c, a, s, v) { return t.props.onItemsRendered({ overscanStartIndex: c, overscanStopIndex: a, visibleStartIndex: s, visibleStopIndex: v }); }), t._callOnScroll = void 0, t._callOnScroll = Pe(function(c, a, s) { return t.props.onScroll({ scrollDirection: c, scrollOffset: a, scrollUpdateWasRequested: s }); }), t._getItemStyle = void 0, t._getItemStyle = function(c) { var a = t.props, s = a.direction, v = a.itemSize, S = a.layout, h = t._getItemStyleCache(C && v, C && S, C && s), _; if (h.hasOwnProperty(c)) _ = h[c]; else { var I = l(t.props, c, t._instanceProps), M = y(t.props, c, t._instanceProps), N = s === "horizontal" || S === "horizontal", K = s === "rtl", X = N ? I : 0; h[c] = _ = { position: "absolute", left: K ? void 0 : X, right: K ? X : void 0, top: N ? 0 : I, height: N ? "100%" : M, width: N ? M : "100%" }; } return _; }, t._getItemStyleCache = void 0, t._getItemStyleCache = Pe(function(c, a, s) { return {}; }), t._onScrollHorizontal = function(c) { var a = c.currentTarget, s = a.clientWidth, v = a.scrollLeft, S = a.scrollWidth; t.setState(function(h) { if (h.scrollOffset === v) return null; var _ = t.props.direction, I = v; if (_ === "rtl") switch (rt()) { case "negative": I = -v; break; case "positive-descending": I = S - s - v; break; } return I = Math.max(0, Math.min(I, S - s)), { isScrolling: !0, scrollDirection: h.scrollOffset < I ? "forward" : "backward", scrollOffset: I, scrollUpdateWasRequested: !1 }; }, t._resetIsScrollingDebounced); }, t._onScrollVertical = function(c) { var a = c.currentTarget, s = a.clientHeight, v = a.scrollHeight, S = a.scrollTop; t.setState(function(h) { if (h.scrollOffset === S) return null; var _ = Math.max(0, Math.min(S, v - s)); return { isScrolling: !0, scrollDirection: h.scrollOffset < _ ? "forward" : "backward", scrollOffset: _, scrollUpdateWasRequested: !1 }; }, t._resetIsScrollingDebounced); }, t._outerRefSetter = function(c) { var a = t.props.outerRef; t._outerRef = c, typeof a == "function" ? a(c) : a != null && typeof a == "object" && a.hasOwnProperty("current") && (a.current = c); }, t._resetIsScrollingDebounced = function() { t._resetIsScrollingTimeoutId !== null && et(t._resetIsScrollingTimeoutId), t._resetIsScrollingTimeoutId = Mt(t._resetIsScrolling, Nt); }, t._resetIsScrolling = function() { t._resetIsScrollingTimeoutId = null, t.setState({ isScrolling: !1 }, function() { t._getItemStyleCache(-1, null); }); }, t; } P.getDerivedStateFromProps = function(t, c) { return Vt(t, c), p(t), null; }; var k = P.prototype; return k.scrollTo = function(t) { t = Math.max(0, t), this.setState(function(c) { return c.scrollOffset === t ? null : { scrollDirection: c.scrollOffset < t ? "forward" : "backward", scrollOffset: t, scrollUpdateWasRequested: !0 }; }, this._resetIsScrollingDebounced); }, k.scrollToItem = function(t, c) { c === void 0 && (c = "auto"); var a = this.props, s = a.itemCount, v = a.layout, S = this.state.scrollOffset; t = Math.max(0, Math.min(t, s - 1)); var h = 0; if (this._outerRef) { var _ = this._outerRef; v === "vertical" ? h = _.scrollWidth > _.clientWidth ? tt() : 0 : h = _.scrollHeight > _.clientHeight ? tt() : 0; } this.scrollTo(W(this.props, t, c, S, this._instanceProps, h)); }, k.componentDidMount = function() { var t = this.props, c = t.direction, a = t.initialScrollOffset, s = t.layout; if (typeof a == "number" && this._outerRef != null) { var v = this._outerRef; c === "horizontal" || s === "horizontal" ? v.scrollLeft = a : v.scrollTop = a; } this._callPropsCallbacks(); }, k.componentDidUpdate = function() { var t = this.props, c = t.direction, a = t.layout, s = this.state, v = s.scrollOffset, S = s.scrollUpdateWasRequested; if (S && this._outerRef != null) { var h = this._outerRef; if (c === "horizontal" || a === "horizontal") if (c === "rtl") switch (rt()) { case "negative": h.scrollLeft = -v; break; case "positive-ascending": h.scrollLeft = v; break; default: var _ = h.clientWidth, I = h.scrollWidth; h.scrollLeft = I - _ - v; break; } else h.scrollLeft = v; else h.scrollTop = v; } this._callPropsCallbacks(); }, k.componentWillUnmount = function() { this._resetIsScrollingTimeoutId !== null && et(this._resetIsScrollingTimeoutId); }, k.render = function() { var t = this.props, c = t.children, a = t.className, s = t.direction, v = t.height, S = t.innerRef, h = t.innerElementType, _ = t.innerTagName, I = t.itemCount, M = t.itemData, N = t.itemKey, K = N === void 0 ? Lt : N, X = t.layout, J = t.outerElementType, U = t.outerTagName, B = t.style, G = t.useIsScrolling, te = t.width, d = this.state.isScrolling, T = s === "horizontal" || X === "horizontal", z = T ? this._onScrollHorizontal : this._onScrollVertical, F = this._getRangeToRender(), L = F[0], q = F[1], Q = []; if (I > 0) for (var Z = L; Z <= q; Z++) Q.push(Te(c, { data: M, key: K(Z, M), index: Z, isScrolling: G ? d : void 0, style: this._getItemStyle(Z) })); var ue = f(this.props, this._instanceProps); return Te(J || U || "div", { className: a, onScroll: z, ref: this._outerRefSetter, style: ze({ position: "relative", height: v, width: te, overflow: "auto", WebkitOverflowScrolling: "touch", willChange: "transform", direction: s }, B) }, Te(h || _ || "div", { children: Q, ref: S, style: { height: T ? "100%" : ue, pointerEvents: d ? "none" : void 0, width: T ? ue : "100%" } })); }, k._callPropsCallbacks = function() { if (typeof this.props.onItemsRendered == "function") { var t = this.props.itemCount; if (t > 0) { var c = this._getRangeToRender(), a = c[0], s = c[1], v = c[2], S = c[3]; this._callOnItemsRendered(a, s, v, S); } } if (typeof this.props.onScroll == "function") { var h = this.state, _ = h.scrollDirection, I = h.scrollOffset, M = h.scrollUpdateWasRequested; this._callOnScroll(_, I, M); } }, k._getRangeToRender = function() { var t = this.props, c = t.itemCount, a = t.overscanCount, s = this.state, v = s.isScrolling, S = s.scrollDirection, h = s.scrollOffset; if (c === 0) return [0, 0, 0, 0]; var _ = D(this.props, h, this._instanceProps), I = x(this.props, _, h, this._instanceProps), M = !v || S === "backward" ? Math.max(1, a) : 1, N = !v || S === "forward" ? Math.max(1, a) : 1; return [Math.max(0, _ - M), Math.max(0, Math.min(c - 1, I + N)), _, I]; }, P; }(Ct), n.defaultProps = { direction: "ltr", itemData: void 0, layout: "vertical", overscanCount: 2, useIsScrolling: !1 }, n; } var Vt = function(n, l) { var f = n.children, y = n.direction, W = n.height, D = n.layout, x = n.innerTagName, b = n.outerTagName, C = n.width, p = l.instance; if (process.env.NODE_ENV !== "production") { (x != null || b != null) && ge && !ge.has(p) && (ge.add(p), console.warn("The innerTagName and outerTagName props have been deprecated. Please use the innerElementType and outerElementType props instead.")); var O = y === "horizontal" || D === "horizontal"; switch (y) { case "horizontal": case "vertical": me && !me.has(p) && (me.add(p), console.warn('The direction prop should be either "ltr" (default) or "rtl". Please use the layout prop to specify "vertical" (default) or "horizontal" orientation.')); break; case "ltr": case "rtl": break; default: throw Error('An invalid "direction" prop has been specified. Value should be either "ltr" or "rtl". ' + ('"' + y + '" was specified.')); } switch (D) { case "horizontal": case "vertical": break; default: throw Error('An invalid "layout" prop has been specified. Value should be either "horizontal" or "vertical". ' + ('"' + D + '" was specified.')); } if (f == null) throw Error('An invalid "children" prop has been specified. Value should be a React component. ' + ('"' + (f === null ? "null" : typeof f) + '" was specified.')); if (O && typeof C != "number") throw Error('An invalid "width" prop has been specified. Horizontal lists must specify a number for width. ' + ('"' + (C === null ? "null" : typeof C) + '" was specified.')); if (!O && typeof W != "number") throw Error('An invalid "height" prop has been specified. Vertical lists must specify a number for height. ' + ('"' + (W === null ? "null" : typeof W) + '" was specified.')); } }, Ut = /* @__PURE__ */ $t({ getItemOffset: function(n, l) { var f = n.itemSize; return l * f; }, getItemSize: function(n, l) { var f = n.itemSize; return f; }, getEstimatedTotalSize: function(n) { var l = n.itemCount, f = n.itemSize; return f * l; }, getOffsetForIndexAndAlignment: function(n, l, f, y, W, D) { var x = n.direction, b = n.height, C = n.itemCount, p = n.itemSize, O = n.layout, P = n.width, k = x === "horizontal" || O === "horizontal", R = k ? P : b, t = Math.max(0, C * p - R), c = Math.min(t, l * p), a = Math.max(0, l * p - R + p + D); switch (f === "smart" && (y >= a - R && y <= c + R ? f = "auto" : f = "center"), f) { case "start": return c; case "end": return a; case "center": { var s = Math.round(a + (c - a) / 2); return s < Math.ceil(R / 2) ? 0 : s > t + Math.floor(R / 2) ? t : s; } case "auto": default: return y >= a && y <= c ? y : y < a ? a : c; } }, getStartIndexForOffset: function(n, l) { var f = n.itemCount, y = n.itemSize; return Math.max(0, Math.min(f - 1, Math.floor(l / y))); }, getStopIndexForStartIndex: function(n, l, f) { var y = n.direction, W = n.height, D = n.itemCount, x = n.itemSize, b = n.layout, C = n.width, p = y === "horizontal" || b === "horizontal", O = l * x, P = p ? C : W, k = Math.ceil((P + f - O) / x); return Math.max(0, Math.min( D - 1, l + k - 1 // -1 is because stop index is inclusive )); }, initInstanceProps: function(n) { }, shouldResetStyleCacheOnItemSizeChange: !0, validateProps: function(n) { var l = n.itemSize; if (process.env.NODE_ENV !== "production" && typeof l != "number") throw Error('An invalid "itemSize" prop has been specified. Value should be a number. ' + ('"' + (l === null ? "null" : typeof l) + '" was specified.')); } }); function qt({ fullData: o, chunkSize: n = 100, itemHeight: l = 35, displayKey: f = "customer", inputWidth: y = "100%", inputHeight: W = "35px", inputColor: D = "#ccc", multipleSelect: x = !0, dropdownWidth: b = "350px", maxDropdownHeight: C = 300, onChange: p, keyField: O = "id" // New prop to allow users to specify the key field }) { const [P, k] = ie(""), [R, t] = ie(!1), [c, a] = ie({ width: parseInt(b) || 350, height: C }), [s, v] = ie([]), [S, h] = ie([]), [_, I] = ie([]), M = Ie(null), N = Ie(null), K = Ie(null), X = _.length < o.length; Ce(() => { I(o.slice(0, n)); }, [o, n]), Ce(() => { const d = (T) => { R && N.current && !N.current.contains(T.target) && !K.current.contains(T.target) && (t(!1), k("")); }; return document.addEventListener("mousedown", d), () => { document.removeEventListener("mousedown", d); }; }, [R]), Ce(() => { const d = () => { if (M.current) { const T = window.innerHeight, z = M.current.getBoundingClientRect(), F = T - z.bottom - 20, L = M.current.offsetWidth; a({ width: L, height: Math.max(Math.min(F, C), 200) }); } }; return d(), window.addEventListener("resize", d), () => window.removeEventListener("resize", d); }, [R, C]); const J = Pt(() => { if (!P) return _; const d = P.toLowerCase(); return o.filter( (T) => Object.values(T).some((z) => String(z).toLowerCase().includes(d)) ); }, [o, _, P]), U = () => { t(!R); }, B = (d, T, z) => { if (x) { const F = z ? [...S, T] : S.filter((L) => L[O] !== d); h(F), v(F.map((L) => L[O])), p == null || p(F); } else { const F = z ? [T] : []; h(F), v(z ? [d] : []), k(""), t(!1), p == null || p(F); } }, G = (d) => { d ? (v(o.map((T) => T[O])), h(o), p == null || p(o)) : (v([]), h([]), p == null || p([])); }, te = () => { const d = _.length, T = o.slice(d, d + n); I((z) => [...z, ...T]); }; return /* @__PURE__ */ V.jsxs("div", { style: { position: "relative", width: b }, ref: M, children: [ /* @__PURE__ */ V.jsx("div", { style: { position: "relative" }, children: /* @__PURE__ */ V.jsxs("div", { style: { position: "relative", display: "flex", alignItems: "center", border: `1px solid ${D}`, borderRadius: "4px", minHeight: W, padding: "4px 8px", boxSizing: "border-box", gap: "8px", cursor: "text", width: y // Add this }, onClick: () => { var d; (d = K.current) == null || d.focus(); }, children: [ /* @__PURE__ */ V.jsx( "input", { ref: K, type: "text", placeholder: S.length === 0 ? "Search..." : "", style: { height: "100%", border: "none", outline: "none", padding: "0", flex: "1", fontSize: "14px", minWidth: "50px", backgroundColor: "transparent", width: "100%" // This ensures input takes available space }, value: x ? P : P || S[0] && f.split(".").reduce((d, T) => d == null ? void 0 : d[T], S[0]) || "", onChange: (d) => { k(d.target.value), R || t(!0), x || (h([]), v([])); }, onClick: (d) => { d.stopPropagation(), U(); } } ), x && S.length > 0 && /* @__PURE__ */ V.jsxs("div", { style: { backgroundColor: "#e3e3e3", borderRadius: "16px", padding: "2px 8px", fontSize: "12px", color: "#666", display: "flex", alignItems: "center", gap: "4px", whiteSpace: "nowrap" }, children: [ /* @__PURE__ */ V.jsxs("span", { children: [ S.length, " ", S.length === 1 ? "item" : "items", " selected" ] }), /* @__PURE__ */ V.jsx( "button", { onClick: (d) => { d.stopPropagation(), h([]), v([]); }, style: { border: "none", background: "none", padding: "0", cursor: "pointer", fontSize: "14px", color: "#666", display: "flex", alignItems: "center" }, children: "×" } ) ] }) ] }) }), R && /* @__PURE__ */ V.jsxs( "div", { ref: N, style: { position: "absolute", top: "calc(100% + 8px)", left: 0, width: "100%", backgroundColor: "#fff", border: "1px solid #e1e4e8", borderRadius: "4px", boxShadow: "0 2px 5px rgba(0, 0, 0, 0.3)", zIndex: 1e3, boxSizing: "border-box" }, children: [ x && /* @__PURE__ */ V.jsxs("div", { style: { display: "flex", alignItems: "center", padding: "8px 12px", borderBottom: "1px solid #e1e4e8" }, children: [ /* @__PURE__ */ V.jsx( "input", { type: "checkbox", onChange: (d) => G(d.target.checked), checked: s.length > 0 && s.length === o.length, style: { marginRight: "8px" } } ), /* @__PURE__ */ V.jsx("span", { style: { fontSize: "14px" }, children: "Select All" }) ] }), /* @__PURE__ */ V.jsx( Ut, { height: c.height, itemCount: J.length, itemSize: l, width: c.width, onItemsRendered: ({ visibleStopIndex: d }) => { X && d >= J.length - 1 && te(); }, style: { padding: "4px 0", overflowX: "hidden" }, children: ({ index: d, style: T }) => { const z = J[d], F = f.split(".").reduce((q, Q) => q == null ? void 0 : q[Q], z), L = s.includes(z[O]); return /* @__PURE__ */ V.jsxs( "div", { style: { ...T, display: "flex", alignItems: "center", padding: "0 12px", fontSize: "14px", backgroundColor: x ? L ? "#f1f8ff" : "transparent" : L ? "#e6f3ff" : "transparent", cursor: "pointer" }, onClick: (q) => { q.target.type !== "checkbox" && B(z[O], z, !L); }, children: [ x && /* @__PURE__ */ V.jsx( "input", { type: "checkbox", checked: L, onChange: (q) => { q.stopPropagation(), B(z[O], z, q.target.checked); }, style: { marginRight: "8px" } } ), F ] } ); } } ), J.length === 0 && /* @__PURE__ */ V.jsx("div", { style: { padding: "12px", textAlign: "center", color: "#666", fontSize: "14px" }, children: "No results found" }) ] } ) ] }); } export { qt as default };