stargazer-ui 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/BaseTypes.d.ts +19 -0
  2. package/dist/BaseTypes.js +1 -0
  3. package/dist/Button/index.d.ts +9 -0
  4. package/dist/Button/index.js +1 -1
  5. package/dist/Card/index.d.ts +92 -0
  6. package/dist/Card/index.js +15 -29
  7. package/dist/CloseButton/index.d.ts +8 -0
  8. package/dist/Dropdown/index.d.ts +124 -0
  9. package/dist/Dropdown/index.js +140 -117
  10. package/dist/FloatingLabel/index.d.ts +11 -0
  11. package/dist/FloatingLabel/index.js +9 -9
  12. package/dist/Form/index.d.ts +65 -0
  13. package/dist/Form/index.js +56 -51
  14. package/dist/Grid/Col.js +19 -0
  15. package/dist/Grid/Container.js +9 -0
  16. package/dist/Grid/Row.js +17 -0
  17. package/dist/InputGroup/index.d.ts +14 -0
  18. package/dist/InputGroup/index.js +6 -5
  19. package/dist/Modal/index.d.ts +70 -0
  20. package/dist/Modal/index.js +78 -64
  21. package/dist/Nav/index.d.ts +46 -0
  22. package/dist/Nav/index.js +11 -12
  23. package/dist/NavBar/index.d.ts +46 -0
  24. package/dist/NavBar/index.js +15 -14
  25. package/dist/NavDropdown/index.d.ts +39 -0
  26. package/dist/NavDropdown/index.js +226 -218
  27. package/dist/OffCanvas/OffCanvas.js +2266 -0
  28. package/dist/Overlay/index.js +36 -36
  29. package/dist/Popout/index.d.ts +56 -0
  30. package/dist/Popout/index.js +55 -68
  31. package/dist/Spinner/index.d.ts +10 -0
  32. package/dist/Spinner/index.js +9 -0
  33. package/dist/Table/index.d.ts +9 -0
  34. package/dist/Table/index.js +9 -0
  35. package/dist/Tabs/index.d.ts +42 -0
  36. package/dist/Tabs/index.js +60 -52
  37. package/dist/stylesheets/stargazerui.css +1160 -17
  38. package/dist/stylesheets/stargazerui.css.map +1 -1
  39. package/dist/vite-env.d.js +1 -0
  40. package/package.json +14 -2
@@ -1,32 +1,32 @@
1
1
  import { jsxs as M, Fragment as U, jsx as N } from "react/jsx-runtime";
2
- import { forwardRef as X, useRef as P, useState as w, useEffect as $, cloneElement as Y } from "react";
2
+ import { forwardRef as X, useRef as S, useState as w, useEffect as $, cloneElement as Y } from "react";
3
3
  import { createPortal as Z } from "react-dom";
4
- const q = (l, g, u, c, i = !1) => {
5
- let f = document.body, o = l.current, a = g.current, e = getComputedStyle(o).position, n = o.getBoundingClientRect().top - (e != "fixed" ? f.getBoundingClientRect().top : 0), d = o.offsetHeight, h = o.getBoundingClientRect().left - (e != "fixed" ? f.getBoundingClientRect().left : 0), R = o.offsetWidth, m = a.clientHeight, y = a.clientWidth;
6
- const p = (v, S, B) => a.getBoundingClientRect()[v] <= B ? S : r[v];
7
- let x = 0, C = 0;
8
- i || (C = c.clientHeight - 1, x = c.clientWidth - 1);
4
+ const q = (l, a, u, c, i = !1) => {
5
+ let f = document.body, o = l.current, g = a.current, e = getComputedStyle(o).position, n = o.getBoundingClientRect().top - (e != "fixed" ? f.getBoundingClientRect().top : 0), d = o.offsetHeight, h = o.getBoundingClientRect().left - (e != "fixed" ? f.getBoundingClientRect().left : 0), x = o.offsetWidth, m = g.clientHeight, y = g.clientWidth;
6
+ const p = (C, R, B) => g.getBoundingClientRect()[C] <= B ? R : r[C];
7
+ let H = 0, v = 0;
8
+ i || (v = c.clientHeight - 1, H = c.clientWidth - 1);
9
9
  let r;
10
10
  switch (u) {
11
11
  case "top":
12
- return r = { top: n - m - C, left: h + R / 2 - y / 2 }, r.right = p("right", 12, 0), r.left = p("left", 0, 0), r;
12
+ return r = { top: n - m - v, left: h + x / 2 - y / 2 }, r.right = p("right", 12, 0), r.left = p("left", 0, 0), r;
13
13
  case "right":
14
- return r = { top: n + d / 2 - m / 2, left: h + o.offsetWidth + x }, r;
14
+ return r = { top: n + d / 2 - m / 2, left: h + o.offsetWidth + H }, r;
15
15
  case "bottom":
16
- return r = { top: n + d + C, left: h + R / 2 - y / 2 }, r.right = p("right", 12, 0), r.left = p("left", 0, 0), r;
16
+ return r = { top: n + d + v, left: h + x / 2 - y / 2 }, r.right = p("right", 12, 0), r.left = p("left", 0, 0), r;
17
17
  case "left":
18
- return r = { top: n + d / 2 - m / 2, left: h - y - x }, r;
18
+ return r = { top: n + d / 2 - m / 2, left: h - y - H }, r;
19
19
  default:
20
- return { top: n - m, left: h + R / 2 - y / 2 };
20
+ return { top: n - m, left: h + x / 2 - y / 2 };
21
21
  }
22
- }, G = (l, g, u, c) => {
23
- let i = g.current.getBoundingClientRect().top, f = window.innerHeight - g.current.getBoundingClientRect().bottom, o = g.current.getBoundingClientRect().left, a = window.innerWidth - g.current.getBoundingClientRect().right, e = u.current.clientWidth + c.current.clientWidth + 48, n = u.current.clientHeight + c.current.clientHeight + 48;
22
+ }, G = (l, a, u, c) => {
23
+ let i = a.current.getBoundingClientRect().top, f = window.innerHeight - a.current.getBoundingClientRect().bottom, o = a.current.getBoundingClientRect().left, g = window.innerWidth - a.current.getBoundingClientRect().right, e = u.current.clientWidth + c.current.clientWidth + 48, n = u.current.clientHeight + c.current.clientHeight + 48;
24
24
  if (l.current === "top") {
25
25
  if (i <= n)
26
- return a <= e ? "left" : o <= e ? "right" : "top";
26
+ return g <= e ? "left" : o <= e ? "right" : "top";
27
27
  } else if (l.current === "bottom") {
28
28
  if (f <= n)
29
- return a <= e ? "left" : o <= e ? "right" : "bottom";
29
+ return g <= e ? "left" : o <= e ? "right" : "bottom";
30
30
  } else if (l.current === "left" || l.current === "right") {
31
31
  if (i >= n)
32
32
  return "top";
@@ -36,20 +36,20 @@ const q = (l, g, u, c, i = !1) => {
36
36
  return l.current === "left" ? "left" : "right";
37
37
  }
38
38
  return l.current;
39
- }, et = X(({ children: l, overlay: g, show: u, onToggle: c, position: i = "auto", trigger: f = "click", defaultShow: o = !1 }, a) => {
40
- const e = P(), n = P(), d = P(), [h, R] = w(""), [m, y] = w(""), [p, x] = w(o), C = P(p), r = (t) => {
41
- C.current = t, x(t);
42
- }, [v, S] = w(i === "auto" ? "top" : i), B = P(v), W = (t) => {
43
- B.current = t, S(t);
44
- }, [k, A] = w(!1), [L, O] = w(!1), [J, F] = w(!0), H = Array.isArray(f) ? f : [f], E = (t, s, b) => {
45
- s.current && (y(q(t, s, B.current, b.current)), R(q(t, b, B.current, b.current, !0)));
39
+ }, et = X(({ children: l, overlay: a, show: u, onToggle: c, position: i = "auto", trigger: f = "click", defaultShow: o = !1 }, g) => {
40
+ const e = S(), n = S(), d = S(), [h, x] = w(""), [m, y] = w(""), [p, H] = w(o), v = S(p), r = (t) => {
41
+ v.current = t, H(t);
42
+ }, [C, R] = w(i === "auto" ? "top" : i), B = S(C), W = (t) => {
43
+ B.current = t, R(t);
44
+ }, [k, A] = w(!1), [L, O] = w(!1), [J, F] = w(!0), P = Array.isArray(f) ? f : [f], E = (t, s, b) => {
45
+ s.current && (y(q(t, s, B.current, b.current)), x(q(t, b, B.current, b.current, !0)));
46
46
  }, I = () => {
47
- if (C.current && i === "auto") {
47
+ if (v.current && i === "auto") {
48
48
  let t = G(B, e, n, d);
49
49
  W(t);
50
50
  }
51
51
  }, z = () => {
52
- E(e, n, d), C.current;
52
+ E(e, n, d), v.current;
53
53
  }, K = (t) => {
54
54
  if (L && J) {
55
55
  F(!1);
@@ -64,36 +64,36 @@ const q = (l, g, u, c, i = !1) => {
64
64
  k ? A(!1) : L && (O(!1), F(!0)), r(!1), c(!1);
65
65
  };
66
66
  $(() => {
67
- if (console.log(e.current.getBoundingClientRect()), n.current && u && (E(e, n, d), i === "auto")) {
67
+ if (n.current && u && (E(e, n, d), i === "auto")) {
68
68
  let t = G(B, e, n, d);
69
69
  W(t);
70
70
  }
71
71
  if (e.current) {
72
72
  let t = document.body, s = getComputedStyle(e.current).position;
73
- console.log(e.current.getBoundingClientRect()), y({
73
+ y({
74
74
  top: e.current.getBoundingClientRect().top - (s != "fixed" ? t.getBoundingClientRect().top : 0),
75
75
  left: e.current.getBoundingClientRect().left - (s != "fixed" ? t.getBoundingClientRect().left : 0)
76
- }), R({
76
+ }), x({
77
77
  top: e.current.getBoundingClientRect().top - (s != "fixed" ? t.getBoundingClientRect().top : 0),
78
78
  left: e.current.getBoundingClientRect().left - (s != "fixed" ? t.getBoundingClientRect().left : 0)
79
79
  });
80
80
  }
81
81
  r(u);
82
- }, [u, n, e, v]), $(() => (window.addEventListener("scroll", I), window.addEventListener("resize", z), function() {
82
+ }, [u, n, e, C]), $(() => (window.addEventListener("scroll", I), window.addEventListener("resize", z), function() {
83
83
  window.removeEventListener("scroll", I), window.removeEventListener("resize", z);
84
84
  }), []);
85
85
  const j = (t) => {
86
86
  let s = getComputedStyle(t.current).position;
87
87
  return s === "fixed" ? "fixed" : s === "sticky" ? "sticky" : "absolute";
88
88
  };
89
- return /* @__PURE__ */ M("div", { ref: a, style: { display: "static" }, children: [
89
+ return /* @__PURE__ */ M("div", { ref: g, style: { display: "static" }, children: [
90
90
  Y(l, {
91
91
  ref: e,
92
- onClick: H.find((t) => t === "click") ? K : null,
93
- onMouseOver: H.find((t) => t === "hover") ? Q : null,
94
- onMouseLeave: H.find((t) => t === "hover") ? D : null,
95
- onFocus: H.find((t) => t === "focus") ? T : null,
96
- onBlur: H.find((t) => t === "focus") ? D : null
92
+ onClick: P.find((t) => t === "click") ? K : null,
93
+ onMouseOver: P.find((t) => t === "hover") ? Q : null,
94
+ onMouseLeave: P.find((t) => t === "hover") ? D : null,
95
+ onFocus: P.find((t) => t === "focus") ? T : null,
96
+ onBlur: P.find((t) => t === "focus") ? D : null
97
97
  }),
98
98
  u ? Z(
99
99
  /* @__PURE__ */ M(U, { children: [
@@ -102,7 +102,7 @@ const q = (l, g, u, c, i = !1) => {
102
102
  {
103
103
  ref: n,
104
104
  style: { maxWidth: "100%", maxHeight: "100%", position: j(e), top: m.top, left: m.left, zIndex: "1010" },
105
- children: g
105
+ children: a
106
106
  }
107
107
  ),
108
108
  /* @__PURE__ */ N(
@@ -111,7 +111,7 @@ const q = (l, g, u, c, i = !1) => {
111
111
  id: "sg-overlay-arrow",
112
112
  ref: d,
113
113
  "aria-hidden": !0,
114
- className: `sg-overlay-arrow${v ? " overlay-position-" + v : ""}`,
114
+ className: `sg-overlay-arrow${C ? " overlay-position-" + C : ""}`,
115
115
  style: { position: j(e), top: h.top, left: h.left }
116
116
  }
117
117
  )
@@ -0,0 +1,56 @@
1
+ import React from "react";
2
+ import { BaseDialogType, BaseDivType, BaseHeadingType, BaseParagraphType, BaseSpanType } from "../BaseTypes";
3
+ export type PopoutType = {
4
+ children: React.ReactNode;
5
+ initialPosition?: {
6
+ top?: number;
7
+ bottom?: number;
8
+ right?: number;
9
+ left?: number;
10
+ };
11
+ id?: string;
12
+ resize?: boolean;
13
+ move?: boolean;
14
+ } & BaseDialogType;
15
+ export type PopoutHeaderType = {
16
+ children: React.ReactNode;
17
+ className?: string;
18
+ as?: React.ElementType;
19
+ } & (BaseDivType | BaseHeadingType | BaseSpanType);
20
+ export type PopoutTitleType = {
21
+ children: React.ReactNode;
22
+ className?: string;
23
+ as?: React.ElementType;
24
+ } & BaseHeadingType;
25
+ export type PopoutBodyType = {
26
+ children: React.ReactNode;
27
+ className?: string;
28
+ } & BaseDivType;
29
+ export type PopoutTextType = {
30
+ children: React.ReactNode;
31
+ className?: string;
32
+ } & BaseParagraphType;
33
+ export type PopoutFooterType = {
34
+ children: React.ReactNode;
35
+ className?: string;
36
+ } & BaseDivType;
37
+ declare const _default: React.ForwardRefExoticComponent<Omit<PopoutType, "ref"> & React.RefAttributes<HTMLDialogElement>> & {
38
+ Header: React.ForwardRefExoticComponent<(Omit<{
39
+ children: React.ReactNode;
40
+ className?: string | undefined;
41
+ as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
42
+ } & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement>, "ref"> | Omit<{
43
+ children: React.ReactNode;
44
+ className?: string | undefined;
45
+ as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
46
+ } & React.ClassAttributes<HTMLHeadingElement> & React.HTMLAttributes<HTMLHeadingElement>, "ref"> | Omit<{
47
+ children: React.ReactNode;
48
+ className?: string | undefined;
49
+ as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
50
+ } & React.ClassAttributes<HTMLSpanElement> & React.HTMLAttributes<HTMLSpanElement>, "ref">) & React.RefAttributes<HTMLDivElement | HTMLHeadingElement | HTMLSpanElement>>;
51
+ Title: React.ForwardRefExoticComponent<Omit<PopoutTitleType, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
52
+ Body: React.ForwardRefExoticComponent<Omit<PopoutBodyType, "ref"> & React.RefAttributes<HTMLDivElement>>;
53
+ Text: React.ForwardRefExoticComponent<Omit<PopoutTextType, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
54
+ Footer: React.ForwardRefExoticComponent<Omit<PopoutFooterType, "ref"> & React.RefAttributes<HTMLDivElement>>;
55
+ };
56
+ export default _default;
@@ -1,85 +1,72 @@
1
1
  import { jsx as c } from "react/jsx-runtime";
2
- import { createPortal as $ } from "react-dom";
3
- import A, { forwardRef as p, useState as L, useRef as T, useEffect as N } from "react";
4
- const B = (e, o, s, r) => {
5
- const t = r ? r.element : document.body;
6
- N(() => {
7
- if (t)
8
- return t.addEventListener(e, o, s), function() {
9
- t.removeEventListener(e, o, s);
10
- };
11
- }, [o, t]);
12
- }, a = p(({ children: e, initialPosition: o, id: s, resize: r = !1, move: t = !1, ...i }, u) => {
13
- const [n, C] = L({ offSetTop: 0, offSetLeft: 0, ...o });
14
- console.log(n);
15
- const b = r ? "true" : "false", M = t ? "true" : "false", l = T(u || null), [h, S] = L(!1), y = T(h);
16
- N(() => {
17
- y.current = h;
2
+ import { createPortal as A } from "react-dom";
3
+ import { forwardRef as u, useState as M, useRef as y, useEffect as R } from "react";
4
+ const W = u(({ children: e, initialPosition: n = { top: 0, left: 0 }, id: o, resize: s = !1, move: f = !1, className: a, style: l, ...p }, N) => {
5
+ const [r, C] = M({ offSetTop: 0, offSetLeft: 0, ...n }), P = s ? "true" : "false", $ = f ? "true" : "false", x = y(N), i = y(null), [h, T] = M(!1), b = y(h);
6
+ R(() => {
7
+ b.current = h;
18
8
  }, [h]);
19
- const R = (f) => {
20
- if (t && f.target.className.includes("sg-popout-title") || f.target.className.includes("sg-popout-header")) {
21
- const { top: d, left: g } = l.current.getBoundingClientRect();
22
- C((m) => ({
23
- ...m,
24
- offSetTop: f.clientY - d,
25
- offSetLeft: f.clientX - g
26
- })), l.current.style.setProperty("user-select", "none"), l.current.setPointerCapture("moveable-popup-" + s), S((m) => !0);
9
+ const D = (t) => {
10
+ const d = t.target;
11
+ if (f && d.className.includes("sg-popout-title") || d.className.includes("sg-popout-header")) {
12
+ const { top: m, left: g } = i.current.getBoundingClientRect();
13
+ C((w) => ({
14
+ ...w,
15
+ offSetTop: t.clientY - m,
16
+ offSetLeft: t.clientX - g
17
+ })), i.current.style.setProperty("user-select", "none"), i.current.setPointerCapture(t.pointerId), T(!0);
27
18
  }
28
- }, H = (f) => {
29
- t && (l.current.style.removeProperty("user-select"), S((d) => !1));
30
- }, P = (f) => {
31
- if (t && y.current) {
32
- const d = f.clientY - n.offSetTop < 0, g = window.innerHeight - (f.clientY - n.offSetTop + l.current.offsetHeight) < 0, m = f.clientX - n.offSetLeft < 0, x = window.innerWidth - (f.clientX - n.offSetLeft + l.current.offsetWidth) < 0;
33
- let v = d ? 0 : f.clientY - n.offSetTop;
34
- v = g ? window.innerHeight - l.current.offsetHeight : v;
35
- let w = m ? 0 : f.clientX - n.offSetLeft;
36
- w = x ? window.innerWidth - l.current.offsetWidth : w, C((E) => ({
37
- ...E,
19
+ }, L = () => {
20
+ f && (i.current.style.removeProperty("user-select"), T(!1));
21
+ }, H = (t) => {
22
+ if (f && b.current && i.current) {
23
+ const d = t.clientY - r.offSetTop < 0, m = window.innerHeight - (t.clientY - r.offSetTop + i.current.offsetHeight) < 0, g = t.clientX - r.offSetLeft < 0, w = window.innerWidth - (t.clientX - r.offSetLeft + i.current.offsetWidth) < 0;
24
+ let v = d ? 0 : t.clientY - r.offSetTop;
25
+ v = m ? window.innerHeight - i.current.offsetHeight : v;
26
+ let S = g ? 0 : t.clientX - r.offSetLeft;
27
+ S = w ? window.innerWidth - i.current.offsetWidth : S, C((O) => ({
28
+ ...O,
38
29
  top: v,
39
- left: w
30
+ left: S
40
31
  }));
41
32
  }
42
33
  };
43
- return B("pointerup", H, !0, { element: document.body }), $(
34
+ return R(() => (document.body.addEventListener("pointerup", () => L(), !0), function() {
35
+ document.body.removeEventListener("pointerup", () => L(), !0);
36
+ }), []), A(
44
37
  /* @__PURE__ */ c(
45
38
  "dialog",
46
39
  {
47
- "data-resize": b,
48
- "data-move": M,
49
- ref: l,
50
- id: s,
51
- className: "moveable-popout",
52
- style: { top: n.top, left: n.left, bottom: n.bottom, right: n.right },
53
- onMouseDown: R,
54
- onMouseMove: P,
40
+ "data-resize": P,
41
+ "data-move": $,
42
+ "data-passedRef": x,
43
+ ref: i,
44
+ id: o,
45
+ className: `sg-moveable-popout${a ? " " + a : ""}`,
46
+ style: { ...l, top: r.top, left: r.left, bottom: r.bottom, right: r.right },
47
+ onPointerDown: D,
48
+ onPointerMove: (t) => H(t),
49
+ ...p,
55
50
  children: e
56
51
  }
57
52
  ),
58
53
  document.body
59
54
  );
60
- }), D = ({ as: e, className: o, children: s, ...r }, t) => {
61
- let u = ["div", "span", "h1", "h2", "h3", "h4", "h5", "h6"].find((n) => n === e) ? e : "div";
62
- return /* @__PURE__ */ c(u, { ref: t, className: `sg-popout-header ${o}`, ...r, children: s });
63
- };
64
- a.Header = p(D);
65
- const W = ({ children: e, className: o, ...s }, r) => {
66
- e = e.length ? e.filter((i) => i != null && i != "") : e;
67
- let t = [];
68
- return A.Children.forEach(e, (i) => {
69
- t.push(i);
70
- }), /* @__PURE__ */ c("div", { ref: r, className: `sg-popout-body ${o}`, ...s, children: t.map((i) => i) });
71
- };
72
- a.Body = p(W);
73
- const X = ({ as: e, className: o, children: s, ...r }, t) => {
74
- let u = ["h1", "h2", "h3", "h4", "h5", "h6"].find((n) => n === e) ? e : "h5";
75
- return /* @__PURE__ */ c(u, { ref: t, className: `sg-popout-title ${o}`, ...r, children: s });
76
- };
77
- a.Title = p(X);
78
- const Y = ({ children: e, className: o, ...s }, r) => /* @__PURE__ */ c("p", { ref: r, className: `sg-popout-text ${o}`, ...s, children: e });
79
- a.Text = p(Y);
80
- const O = ({ children: e, className: o, ...s }, r) => /* @__PURE__ */ c("div", { ref: r, className: `sg-popout-footer ${o}`, ...s, children: e });
81
- a.Footer = p(O);
55
+ }), X = u(
56
+ ({ children: e, className: n, as: o = "div", ...s }, f) => {
57
+ let l = ["div", "span", "h1", "h2", "h3", "h4", "h5", "h6"].find((p) => p === o) ? o : "div";
58
+ return /* @__PURE__ */ c(l, { ref: f, className: `sg-popout-header ${n}`, ...s, children: e });
59
+ }
60
+ ), Y = u(({ as: e = "h4", className: n, children: o, ...s }, f) => {
61
+ let l = ["h1", "h2", "h3", "h4", "h5", "h6"].find((p) => p === e) ? e : "h5";
62
+ return /* @__PURE__ */ c(l, { ref: f, className: `sg-popout-title ${n}`, ...s, children: o });
63
+ }), B = u(({ children: e, className: n, ...o }, s) => /* @__PURE__ */ c("div", { ref: s, className: `sg-popout-body ${n}`, ...o, children: e })), E = u(({ children: e, className: n, ...o }, s) => /* @__PURE__ */ c("p", { ref: s, className: `sg-popout-text ${n}`, ...o, children: e })), j = u(({ children: e, className: n, ...o }, s) => /* @__PURE__ */ c("div", { ref: s, className: `sg-popout-footer ${n}`, ...o, children: e })), U = Object.assign(W, {
64
+ Header: X,
65
+ Title: Y,
66
+ Body: B,
67
+ Text: E,
68
+ Footer: j
69
+ });
82
70
  export {
83
- a as default,
84
- B as useEventListener
71
+ U as default
85
72
  };
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ export type SpinnerType = {
3
+ label: string;
4
+ size?: string;
5
+ color?: string;
6
+ className?: string;
7
+ controlId?: string;
8
+ };
9
+ declare const Spinner: import("react").ForwardRefExoticComponent<SpinnerType & import("react").RefAttributes<HTMLDivElement>>;
10
+ export default Spinner;
@@ -0,0 +1,9 @@
1
+ import { jsxs as n, Fragment as o, jsx as l } from "react/jsx-runtime";
2
+ import { forwardRef as h } from "react";
3
+ const p = h(({ size: e = "1em", color: s = "white", label: a, className: r, controlId: i, ...t }, d) => /* @__PURE__ */ n(o, { children: [
4
+ /* @__PURE__ */ l("div", { "aria-labelledby": i, role: "status", ref: d, className: `sg-spinner${r ? " " + r : ""}`, style: { width: e, height: e, borderColor: s }, ...t }),
5
+ /* @__PURE__ */ l("label", { id: i, className: "sg-visually-hidden", children: a })
6
+ ] }));
7
+ export {
8
+ p as default
9
+ };
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { BaseTableType } from "../BaseTypes";
3
+ export type TableType = {
4
+ children: React.ReactNode;
5
+ size?: string;
6
+ className?: string;
7
+ } & BaseTableType;
8
+ declare const Table: React.ForwardRefExoticComponent<Omit<TableType, "ref"> & React.RefAttributes<HTMLTableElement>>;
9
+ export default Table;
@@ -0,0 +1,9 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { forwardRef as m } from "react";
3
+ const p = m(({ children: t, size: s = "lg", className: e, ...r }, a) => {
4
+ let l = `sg-table${e ? " " + e : ""}${s === "sm" ? " sg-table-sm" : ""}`;
5
+ return /* @__PURE__ */ o("table", { ref: a, className: l, ...r, children: t });
6
+ });
7
+ export {
8
+ p as default
9
+ };
@@ -0,0 +1,42 @@
1
+ /// <reference types="react" />
2
+ import { BaseButtonType, BaseDivType } from "../BaseTypes";
3
+ export type TabsContextType = {
4
+ activeTab: string;
5
+ setActiveTab: React.Dispatch<React.SetStateAction<string>>;
6
+ controlId: string;
7
+ activeClass: string;
8
+ };
9
+ export type TabsContext = {
10
+ children: React.ReactNode;
11
+ className?: string;
12
+ controlId: string;
13
+ activeClassName?: string;
14
+ defaultActive: string;
15
+ } & BaseDivType;
16
+ export type TabsControlsType = {
17
+ children: React.ReactNode;
18
+ className?: string;
19
+ } & BaseDivType;
20
+ export type TabsButtonType = {
21
+ children: React.ReactNode;
22
+ className?: string;
23
+ onClick?: Function;
24
+ tabId: string;
25
+ id?: string;
26
+ } & BaseButtonType;
27
+ export type TabsContentType = {
28
+ children: React.ReactNode;
29
+ className?: string;
30
+ } & BaseDivType;
31
+ export type TabsPageType = {
32
+ children: React.ReactNode;
33
+ className?: string;
34
+ tabId: string;
35
+ } & BaseDivType;
36
+ declare const _default: import("react").ForwardRefExoticComponent<Omit<TabsContext, "ref"> & import("react").RefAttributes<HTMLDivElement>> & {
37
+ Controls: import("react").ForwardRefExoticComponent<Omit<TabsControlsType, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
38
+ Button: import("react").ForwardRefExoticComponent<Omit<TabsButtonType, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
39
+ Content: import("react").ForwardRefExoticComponent<Omit<TabsContentType, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
40
+ Page: import("react").ForwardRefExoticComponent<Omit<TabsPageType, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
41
+ };
42
+ export default _default;
@@ -1,69 +1,77 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import { createContext as x, forwardRef as v, useState as h, useMemo as T, useContext as m } from "react";
3
- const C = x(null), w = ({ children: s, value: t }) => /* @__PURE__ */ u(C.Provider, { value: t, children: s }), p = v(({ children: s, className: t, controlId: e, activeClassName: n, defaultActive: l = 0, ...i }, b) => {
4
- const [a, c] = h(l), o = n || "sg-active", r = T(() => ({
5
- activeTab: a,
1
+ import { jsx as d } from "react/jsx-runtime";
2
+ import { createContext as m, forwardRef as C, useState as p, useMemo as T, useContext as w } from "react";
3
+ const h = m(null), y = ({ children: e, value: t }) => /* @__PURE__ */ d(h.Provider, { value: t, children: e }), f = () => {
4
+ const e = w(h);
5
+ if (!e)
6
+ throw new Error(
7
+ "useTabContext has to be used within a TabContextProvider!"
8
+ );
9
+ return e;
10
+ }, A = C(({ children: e, className: t, controlId: n, activeClassName: o, defaultActive: r, ...i }, l) => {
11
+ const [s, c] = p(r), v = o || "sg-active", a = T(() => ({
12
+ activeTab: s,
6
13
  setActiveTab: c,
7
- controlId: e,
8
- activeClass: o
9
- }), [a, c, e]);
10
- return /* @__PURE__ */ u(w, { value: r, children: /* @__PURE__ */ u("div", { ref: b, id: e + "-tab-wrapper", className: `sg-tabs${t ? " " + t : ""}`, ...i, children: s }) });
11
- }), y = ({ children: s, className: t, ...e }, n) => {
12
- const { controlId: l, activeClass: i } = m(C);
13
- return /* @__PURE__ */ u("div", { onKeyDown: (a) => {
14
- const c = a.key, o = Array.from(document.getElementById(l + "-tab-controls").children);
15
- if (c === "ArrowRight" || c === "ArrowLeft") {
16
- a.preventDefault();
17
- const r = document.querySelector(".sg-tabs-button." + i), d = o.indexOf(r), g = c === "ArrowRight" ? 1 : -1, f = d + g < 0 ? o.length - 1 : d + g >= o.length ? 0 : d + g;
18
- o[f].focus(), o[f].click();
19
- } else if (c === "Home" || c === "End") {
20
- a.preventDefault();
21
- const r = c === "Home" ? 0 : o.length - 1;
22
- o[r].focus(), o[r].click();
14
+ controlId: n,
15
+ activeClass: v
16
+ }), [s, c, n]);
17
+ return /* @__PURE__ */ d(y, { value: a, children: /* @__PURE__ */ d("div", { ref: l, id: n + "-tab-wrapper", className: `sg-tabs${t ? " " + t : ""}`, ...i, children: e }) });
18
+ }), k = C(({ children: e, className: t, ...n }, o) => {
19
+ const { controlId: r, activeClass: i } = f(), l = (s) => {
20
+ const c = s.key, v = document.getElementById(r + "-tab-controls");
21
+ if (v) {
22
+ const a = Array.from(v.children);
23
+ if (c === "ArrowRight" || c === "ArrowLeft") {
24
+ s.preventDefault();
25
+ const u = document.querySelector(".sg-tabs-button." + i), g = a.indexOf(u), b = c === "ArrowRight" ? 1 : -1, x = g + b < 0 ? a.length - 1 : g + b >= a.length ? 0 : g + b;
26
+ a[x].focus(), a[x].click();
27
+ } else if (c === "Home" || c === "End") {
28
+ s.preventDefault();
29
+ const u = c === "Home" ? 0 : a.length - 1;
30
+ a[u].focus(), a[u].click();
31
+ }
23
32
  }
24
- }, role: "tablist", id: l + "-tab-controls", ref: n, className: `sg-tabs-controls${t ? " " + t : ""}`, ...e, children: s });
25
- };
26
- p.Controls = v(y);
27
- const A = ({ children: s, className: t, onClick: e, tabId: n, id: l, ...i }, b) => {
28
- const { activeTab: a, setActiveTab: c, activeClass: o } = m(C), r = "sg-tabs-button" + (t ? " " + t : "") + (a === n ? " " + o : ""), d = a === n, g = (f) => {
29
- c(n), e && e(f);
30
33
  };
31
- return /* @__PURE__ */ u(
34
+ return /* @__PURE__ */ d("div", { onKeyDown: (s) => l(s), role: "tablist", id: r + "-tab-controls", ref: o, className: `sg-tabs-controls${t ? " " + t : ""}`, ...n, children: e });
35
+ }), D = C(({ children: e, className: t, onClick: n, tabId: o, id: r, ...i }, l) => {
36
+ const { activeTab: s, setActiveTab: c, activeClass: v } = f(), a = "sg-tabs-button" + (t ? " " + t : "") + (s === o ? " " + v : ""), u = s === o, g = (b) => {
37
+ c(o), n && n(b);
38
+ };
39
+ return /* @__PURE__ */ d(
32
40
  "button",
33
41
  {
34
42
  role: "tab",
35
43
  type: "button",
36
- id: n + "-button",
37
- ref: b,
38
- onClick: g,
39
- className: r,
44
+ id: o + "-button",
45
+ ref: l,
46
+ onClick: (b) => g(b),
47
+ className: a,
40
48
  ...i,
41
- tabIndex: d ? "0" : "-1",
42
- "aria-selected": d ? "true" : "false",
43
- "aria-controls": n + "-page",
44
- children: s
49
+ tabIndex: u ? 0 : -1,
50
+ "aria-selected": u ? "true" : "false",
51
+ "aria-controls": o + "-page",
52
+ children: e
45
53
  }
46
54
  );
47
- };
48
- p.Button = v(A);
49
- const k = ({ children: s, className: t, ...e }, n) => (m(C), /* @__PURE__ */ u("div", { role: "none", ref: n, className: `sg-tabs-content${t ? " " + t : ""}`, ...e, children: s }));
50
- p.Content = v(k);
51
- const D = ({ children: s, className: t, tabId: e, ...n }, l) => {
52
- const { activeTab: i, activeClass: b } = m(C), a = "sg-tabs-page" + (t ? " " + t : "") + (i === e ? " " + b : "");
53
- return /* @__PURE__ */ u(
55
+ }), P = C(({ children: e, className: t, ...n }, o) => /* @__PURE__ */ d("div", { role: "none", ref: o, className: `sg-tabs-content${t ? " " + t : ""}`, ...n, children: e })), E = C(({ children: e, className: t, tabId: n, ...o }, r) => {
56
+ const { activeTab: i, activeClass: l } = f(), s = "sg-tabs-page" + (t ? " " + t : "") + (i === n ? " " + l : "");
57
+ return /* @__PURE__ */ d(
54
58
  "div",
55
59
  {
56
60
  role: "tabpanel",
57
- id: e + "-page",
58
- "aria-labelledby": e + "-button",
59
- ref: l,
60
- className: a,
61
- ...n,
62
- children: s
61
+ id: n + "-page",
62
+ "aria-labelledby": n + "-button",
63
+ ref: r,
64
+ className: s,
65
+ ...o,
66
+ children: e
63
67
  }
64
68
  );
65
- };
66
- p.Page = v(D);
69
+ }), j = Object.assign(A, {
70
+ Controls: k,
71
+ Button: D,
72
+ Content: P,
73
+ Page: E
74
+ });
67
75
  export {
68
- p as default
76
+ j as default
69
77
  };