@commander-services/cmd-dropdown-portal 1.6.1 → 1.7.0

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.
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare interface CmdDropdownPortalProps {
9
9
  handleOpen: (value: boolean) => void;
10
10
  target?: HTMLElement;
11
11
  keepWidth?: boolean;
12
+ maxDropdownHeight?: number;
12
13
  }
13
14
 
14
15
  export { }
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as ke from "react";
1
+ import * as xe from "react";
2
2
  import A, { useState as fr } from "react";
3
3
  import dr from "react-dom";
4
4
  var K = { exports: {} }, L = {};
@@ -15,15 +15,15 @@ var Ce;
15
15
  function vr() {
16
16
  if (Ce) return L;
17
17
  Ce = 1;
18
- var v = A, f = Symbol.for("react.element"), y = Symbol.for("react.fragment"), h = Object.prototype.hasOwnProperty, x = v.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, j = { key: !0, ref: !0, __self: !0, __source: !0 };
19
- function C(w, d, R) {
18
+ var f = A, d = Symbol.for("react.element"), h = Symbol.for("react.fragment"), y = Object.prototype.hasOwnProperty, k = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, j = { key: !0, ref: !0, __self: !0, __source: !0 };
19
+ function C(w, v, R) {
20
20
  var c, m = {}, p = null, T = null;
21
- R !== void 0 && (p = "" + R), d.key !== void 0 && (p = "" + d.key), d.ref !== void 0 && (T = d.ref);
22
- for (c in d) h.call(d, c) && !j.hasOwnProperty(c) && (m[c] = d[c]);
23
- if (w && w.defaultProps) for (c in d = w.defaultProps, d) m[c] === void 0 && (m[c] = d[c]);
24
- return { $$typeof: f, type: w, key: p, ref: T, props: m, _owner: x.current };
21
+ R !== void 0 && (p = "" + R), v.key !== void 0 && (p = "" + v.key), v.ref !== void 0 && (T = v.ref);
22
+ for (c in v) y.call(v, c) && !j.hasOwnProperty(c) && (m[c] = v[c]);
23
+ if (w && w.defaultProps) for (c in v = w.defaultProps, v) m[c] === void 0 && (m[c] = v[c]);
24
+ return { $$typeof: d, type: w, key: p, ref: T, props: m, _owner: k.current };
25
25
  }
26
- return L.Fragment = y, L.jsx = C, L.jsxs = C, L;
26
+ return L.Fragment = h, L.jsx = C, L.jsxs = C, L;
27
27
  }
28
28
  var W = {};
29
29
  /**
@@ -38,22 +38,22 @@ var W = {};
38
38
  var Pe;
39
39
  function pr() {
40
40
  return Pe || (Pe = 1, process.env.NODE_ENV !== "production" && function() {
41
- var v = A, f = Symbol.for("react.element"), y = Symbol.for("react.portal"), h = Symbol.for("react.fragment"), x = Symbol.for("react.strict_mode"), j = Symbol.for("react.profiler"), C = Symbol.for("react.provider"), w = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), R = Symbol.for("react.suspense"), c = Symbol.for("react.suspense_list"), m = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), T = Symbol.for("react.offscreen"), $ = Symbol.iterator, V = "@@iterator";
41
+ var f = A, d = Symbol.for("react.element"), h = Symbol.for("react.portal"), y = Symbol.for("react.fragment"), k = Symbol.for("react.strict_mode"), j = Symbol.for("react.profiler"), C = Symbol.for("react.provider"), w = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), R = Symbol.for("react.suspense"), c = Symbol.for("react.suspense_list"), m = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), T = Symbol.for("react.offscreen"), $ = Symbol.iterator, V = "@@iterator";
42
42
  function J(e) {
43
43
  if (e === null || typeof e != "object")
44
44
  return null;
45
45
  var r = $ && e[$] || e[V];
46
46
  return typeof r == "function" ? r : null;
47
47
  }
48
- var O = v.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
48
+ var O = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
49
49
  function E(e) {
50
50
  {
51
51
  for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
52
52
  t[n - 1] = arguments[n];
53
- xe("error", e, t);
53
+ ke("error", e, t);
54
54
  }
55
55
  }
56
- function xe(e, r, t) {
56
+ function ke(e, r, t) {
57
57
  {
58
58
  var n = O.ReactDebugCurrentFrame, i = n.getStackAddendum();
59
59
  i !== "" && (r += "%s", t = t.concat([i]));
@@ -66,7 +66,7 @@ function pr() {
66
66
  var je = !1, De = !1, Fe = !1, Ae = !1, Ie = !1, re;
67
67
  re = Symbol.for("react.module.reference");
68
68
  function Ye(e) {
69
- return !!(typeof e == "string" || typeof e == "function" || e === h || e === j || Ie || e === x || e === R || e === c || Ae || e === T || je || De || Fe || typeof e == "object" && e !== null && (e.$$typeof === p || e.$$typeof === m || e.$$typeof === C || e.$$typeof === w || e.$$typeof === d || // This needs to include all possible module reference object
69
+ return !!(typeof e == "string" || typeof e == "function" || e === y || e === j || Ie || e === k || e === R || e === c || Ae || e === T || je || De || Fe || typeof e == "object" && e !== null && (e.$$typeof === p || e.$$typeof === m || e.$$typeof === C || e.$$typeof === w || e.$$typeof === v || // This needs to include all possible module reference object
70
70
  // types supported by any Flight configuration anywhere since
71
71
  // we don't know which Flight build this will end up being used
72
72
  // with.
@@ -90,13 +90,13 @@ function pr() {
90
90
  if (typeof e == "string")
91
91
  return e;
92
92
  switch (e) {
93
- case h:
94
- return "Fragment";
95
93
  case y:
94
+ return "Fragment";
95
+ case h:
96
96
  return "Portal";
97
97
  case j:
98
98
  return "Profiler";
99
- case x:
99
+ case k:
100
100
  return "StrictMode";
101
101
  case R:
102
102
  return "Suspense";
@@ -111,7 +111,7 @@ function pr() {
111
111
  case C:
112
112
  var t = e;
113
113
  return te(t._context) + ".Provider";
114
- case d:
114
+ case v:
115
115
  return Le(e, e.render, "ForwardRef");
116
116
  case m:
117
117
  var n = e.displayName || null;
@@ -203,13 +203,13 @@ function pr() {
203
203
  ` + z + e;
204
204
  }
205
205
  }
206
- var G = !1, B;
206
+ var H = !1, B;
207
207
  {
208
208
  var Ve = typeof WeakMap == "function" ? WeakMap : Map;
209
209
  B = new Ve();
210
210
  }
211
211
  function fe(e, r) {
212
- if (!e || G)
212
+ if (!e || H)
213
213
  return "";
214
214
  {
215
215
  var t = B.get(e);
@@ -217,7 +217,7 @@ function pr() {
217
217
  return t;
218
218
  }
219
219
  var n;
220
- G = !0;
220
+ H = !0;
221
221
  var i = Error.prepareStackTrace;
222
222
  Error.prepareStackTrace = void 0;
223
223
  var u;
@@ -274,10 +274,10 @@ function pr() {
274
274
  }
275
275
  }
276
276
  } finally {
277
- G = !1, q.current = u, $e(), Error.prepareStackTrace = i;
277
+ H = !1, q.current = u, $e(), Error.prepareStackTrace = i;
278
278
  }
279
- var F = e ? e.displayName || e.name : "", k = F ? M(F) : "";
280
- return typeof e == "function" && B.set(e, k), k;
279
+ var F = e ? e.displayName || e.name : "", x = F ? M(F) : "";
280
+ return typeof e == "function" && B.set(e, x), x;
281
281
  }
282
282
  function Me(e, r, t) {
283
283
  return fe(e, !1);
@@ -301,7 +301,7 @@ function pr() {
301
301
  }
302
302
  if (typeof e == "object")
303
303
  switch (e.$$typeof) {
304
- case d:
304
+ case v:
305
305
  return Me(e.render);
306
306
  case m:
307
307
  return U(e.type, r, t);
@@ -343,7 +343,7 @@ function pr() {
343
343
  }
344
344
  }
345
345
  var Ne = Array.isArray;
346
- function H(e) {
346
+ function G(e) {
347
347
  return Ne(e);
348
348
  }
349
349
  function Ke(e) {
@@ -380,7 +380,7 @@ function pr() {
380
380
  }
381
381
  return e.ref !== void 0;
382
382
  }
383
- function Ge(e) {
383
+ function He(e) {
384
384
  if (Y.call(e, "key")) {
385
385
  var r = Object.getOwnPropertyDescriptor(e, "key").get;
386
386
  if (r && r.isReactWarning)
@@ -388,7 +388,7 @@ function pr() {
388
388
  }
389
389
  return e.key !== void 0;
390
390
  }
391
- function He(e, r) {
391
+ function Ge(e, r) {
392
392
  typeof e.ref == "string" && Ee.current;
393
393
  }
394
394
  function Xe(e, r) {
@@ -416,7 +416,7 @@ function pr() {
416
416
  var Qe = function(e, r, t, n, i, u, o) {
417
417
  var a = {
418
418
  // This tag allows us to uniquely identify this as a React Element
419
- $$typeof: f,
419
+ $$typeof: d,
420
420
  // Built-in properties that belong on the element
421
421
  type: e,
422
422
  key: r,
@@ -445,7 +445,7 @@ function pr() {
445
445
  function er(e, r, t, n, i) {
446
446
  {
447
447
  var u, o = {}, a = null, g = null;
448
- t !== void 0 && (me(t), a = "" + t), Ge(r) && (me(r.key), a = "" + r.key), ze(r) && (g = r.ref, He(r, i));
448
+ t !== void 0 && (me(t), a = "" + t), He(r) && (me(r.key), a = "" + r.key), ze(r) && (g = r.ref, Ge(r, i));
449
449
  for (u in r)
450
450
  Y.call(r, u) && !qe.hasOwnProperty(u) && (o[u] = r[u]);
451
451
  if (e && e.defaultProps) {
@@ -460,20 +460,20 @@ function pr() {
460
460
  return Qe(e, a, g, i, n, Ee.current, o);
461
461
  }
462
462
  }
463
- var X = O.ReactCurrentOwner, ye = O.ReactDebugCurrentFrame;
463
+ var X = O.ReactCurrentOwner, he = O.ReactDebugCurrentFrame;
464
464
  function D(e) {
465
465
  if (e) {
466
466
  var r = e._owner, t = U(e.type, e._source, r ? r.type : null);
467
- ye.setExtraStackFrame(t);
467
+ he.setExtraStackFrame(t);
468
468
  } else
469
- ye.setExtraStackFrame(null);
469
+ he.setExtraStackFrame(null);
470
470
  }
471
471
  var Z;
472
472
  Z = !1;
473
473
  function Q(e) {
474
- return typeof e == "object" && e !== null && e.$$typeof === f;
474
+ return typeof e == "object" && e !== null && e.$$typeof === d;
475
475
  }
476
- function he() {
476
+ function ye() {
477
477
  {
478
478
  if (X.current) {
479
479
  var e = P(X.current.type);
@@ -491,7 +491,7 @@ Check the render method of \`` + e + "`.";
491
491
  var Re = {};
492
492
  function tr(e) {
493
493
  {
494
- var r = he();
494
+ var r = ye();
495
495
  if (!r) {
496
496
  var t = typeof e == "string" ? e : e.displayName || e.name;
497
497
  t && (r = `
@@ -518,7 +518,7 @@ Check the top-level render call using <` + t + ">.");
518
518
  {
519
519
  if (typeof e != "object")
520
520
  return;
521
- if (H(e))
521
+ if (G(e))
522
522
  for (var t = 0; t < e.length; t++) {
523
523
  var n = e[t];
524
524
  Q(n) && _e(n, r);
@@ -541,7 +541,7 @@ Check the top-level render call using <` + t + ">.");
541
541
  var t;
542
542
  if (typeof r == "function")
543
543
  t = r.propTypes;
544
- else if (typeof r == "object" && (r.$$typeof === d || // Note: Memo only checks outer props here.
544
+ else if (typeof r == "object" && (r.$$typeof === v || // Note: Memo only checks outer props here.
545
545
  // Inner props are checked in the reconciler.
546
546
  r.$$typeof === m))
547
547
  t = r.propTypes;
@@ -578,9 +578,9 @@ Check the top-level render call using <` + t + ">.");
578
578
  var a = "";
579
579
  (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
580
580
  var g = rr();
581
- g ? a += g : a += he();
581
+ g ? a += g : a += ye();
582
582
  var s;
583
- e === null ? s = "null" : H(e) ? s = "array" : e !== void 0 && e.$$typeof === f ? (s = "<" + (P(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : s = typeof e, E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", s, a);
583
+ e === null ? s = "null" : G(e) ? s = "array" : e !== void 0 && e.$$typeof === d ? (s = "<" + (P(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : s = typeof e, E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", s, a);
584
584
  }
585
585
  var l = er(e, r, t, i, u);
586
586
  if (l == null)
@@ -589,7 +589,7 @@ Check the top-level render call using <` + t + ">.");
589
589
  var _ = r.children;
590
590
  if (_ !== void 0)
591
591
  if (n)
592
- if (H(_)) {
592
+ if (G(_)) {
593
593
  for (var F = 0; F < _.length; F++)
594
594
  we(_[F], e);
595
595
  Object.freeze && Object.freeze(_);
@@ -599,20 +599,20 @@ Check the top-level render call using <` + t + ">.");
599
599
  we(_, e);
600
600
  }
601
601
  if (Y.call(r, "key")) {
602
- var k = P(e), b = Object.keys(r).filter(function(cr) {
602
+ var x = P(e), b = Object.keys(r).filter(function(cr) {
603
603
  return cr !== "key";
604
604
  }), ee = b.length > 0 ? "{key: someKey, " + b.join(": ..., ") + ": ...}" : "{key: someKey}";
605
- if (!Te[k + ee]) {
605
+ if (!Te[x + ee]) {
606
606
  var lr = b.length > 0 ? "{" + b.join(": ..., ") + ": ...}" : "{}";
607
607
  E(`A props object containing a "key" prop is being spread into JSX:
608
608
  let props = %s;
609
609
  <%s {...props} />
610
610
  React keys must be passed directly to JSX without using spread:
611
611
  let props = %s;
612
- <%s key={someKey} {...props} />`, ee, k, lr, k), Te[k + ee] = !0;
612
+ <%s key={someKey} {...props} />`, ee, x, lr, x), Te[x + ee] = !0;
613
613
  }
614
614
  }
615
- return e === h ? ar(l) : nr(l), l;
615
+ return e === y ? ar(l) : nr(l), l;
616
616
  }
617
617
  }
618
618
  function or(e, r, t) {
@@ -622,7 +622,7 @@ React keys must be passed directly to JSX without using spread:
622
622
  return Oe(e, r, t, !1);
623
623
  }
624
624
  var ur = ir, sr = or;
625
- W.Fragment = h, W.jsx = ur, W.jsxs = sr;
625
+ W.Fragment = y, W.jsx = ur, W.jsxs = sr;
626
626
  }()), W;
627
627
  }
628
628
  var Se;
@@ -630,77 +630,77 @@ function mr() {
630
630
  return Se || (Se = 1, process.env.NODE_ENV === "production" ? K.exports = vr() : K.exports = pr()), K.exports;
631
631
  }
632
632
  var Er = mr();
633
- const gr = (v, f) => {
634
- const y = (h) => {
635
- v.current && !v.current.contains(h.target) && f(h);
633
+ const gr = (f, d) => {
634
+ const h = (y) => {
635
+ f.current && !f.current.contains(y.target) && d(y);
636
636
  };
637
- ke.useEffect(() => (document.addEventListener("click", y, { capture: !0 }), () => {
638
- document.removeEventListener("click", y, { capture: !0 });
637
+ xe.useEffect(() => (document.addEventListener("click", h, { capture: !0 }), () => {
638
+ document.removeEventListener("click", h, { capture: !0 });
639
639
  }));
640
- }, br = "Escape", yr = (v, f) => {
641
- const y = ({ key: h }) => {
642
- h === v && f();
640
+ }, br = "Escape", hr = (f, d) => {
641
+ const h = ({ key: y }) => {
642
+ y === f && d();
643
643
  };
644
- ke.useEffect(() => (document.addEventListener("keyup", y), () => {
645
- document.removeEventListener("keyup", y);
644
+ xe.useEffect(() => (document.addEventListener("keyup", h), () => {
645
+ document.removeEventListener("keyup", h);
646
646
  }), []);
647
- }, hr = () => ({ useOutsideClick: gr, useKeyPress: yr, ESCAPE_KEY: br }), Rr = hr;
648
- function Tr(v) {
649
- const [f, y] = fr(null), { useOutsideClick: h, useKeyPress: x, ESCAPE_KEY: j } = Rr(), C = A.useRef(), w = () => {
647
+ }, yr = () => ({ useOutsideClick: gr, useKeyPress: hr, ESCAPE_KEY: br }), Rr = yr;
648
+ function Tr(f) {
649
+ const [d, h] = fr(null), { useOutsideClick: y, useKeyPress: k, ESCAPE_KEY: j } = Rr(), C = A.useRef(), w = () => {
650
650
  setTimeout(function() {
651
- v.handleOpen(!1);
651
+ f.handleOpen(!1);
652
652
  }, 50);
653
653
  };
654
- h(C, () => {
654
+ y(C, () => {
655
655
  w();
656
- }), x(j, () => {
656
+ }), k(j, () => {
657
657
  w();
658
658
  });
659
- const d = (c, m) => {
659
+ const v = (c, m) => {
660
660
  const p = c.getBoundingClientRect(), T = m.getBoundingClientRect();
661
661
  return p.bottom >= T.top && p.bottom <= T.bottom;
662
662
  }, R = A.useCallback(() => {
663
- const c = document.getElementById(v.elementId), m = document.getElementById("cmd-modal-body");
664
- if (c && (!m || d(c, m))) {
665
- const p = c.getBoundingClientRect(), T = 260, $ = window.innerHeight - p.bottom, V = p.left, J = p.bottom, O = p.width;
666
- $ >= T || !m ? y({
663
+ const c = document.getElementById(f.elementId), m = document.getElementById("cmd-modal-body");
664
+ if (c && (!m || v(c, m))) {
665
+ const p = c.getBoundingClientRect(), T = f.maxDropdownHeight || 286, $ = window.innerHeight - p.bottom, V = p.left, J = p.bottom, O = p.width;
666
+ $ >= T || !m ? h({
667
667
  // top: rect.bottom + window.scrollY,
668
668
  top: J,
669
669
  left: V,
670
670
  width: O,
671
671
  bottom: void 0
672
- }) : y({
672
+ }) : h({
673
673
  bottom: window.innerHeight - p.top - window.scrollY + 3,
674
674
  left: V,
675
675
  width: O,
676
676
  top: void 0
677
677
  });
678
678
  } else
679
- y(null);
679
+ h(null);
680
680
  }, []);
681
681
  return A.useEffect(() => (window.addEventListener("scroll", R, { capture: !0 }), window.addEventListener("resize", R, { capture: !0 }), () => {
682
682
  window.removeEventListener("scroll", R, { capture: !0 }), window.removeEventListener("resize", R, { capture: !0 });
683
683
  }), [R]), A.useEffect(() => {
684
684
  R();
685
- }, [v.elementId]), f ? dr.createPortal(
685
+ }, [f.elementId]), d ? dr.createPortal(
686
686
  /* @__PURE__ */ Er.jsx(
687
687
  "div",
688
688
  {
689
689
  className: "font-poppins",
690
- id: `cmd-dropdown-portal-${v.elementId}`,
690
+ id: `cmd-dropdown-portal-${f.elementId}`,
691
691
  ref: C,
692
692
  style: {
693
693
  position: "absolute",
694
- left: f.left,
694
+ left: d.left,
695
695
  zIndex: 999999,
696
- ...f.top !== void 0 ? { top: f.top } : {},
697
- ...f.bottom !== void 0 ? { bottom: f.bottom } : {},
698
- ...v.keepWidth ? {} : { width: f.width }
696
+ ...d.top !== void 0 ? { top: d.top } : {},
697
+ ...d.bottom !== void 0 ? { bottom: d.bottom } : {},
698
+ ...f.keepWidth ? {} : { width: d.width }
699
699
  },
700
- children: v.children
700
+ children: f.children
701
701
  }
702
702
  ),
703
- v.target || document.body
703
+ f.target || document.body
704
704
  ) : null;
705
705
  }
706
706
  export {