stargazer-ui 1.0.3 → 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.
@@ -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
  };