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.
@@ -1,85 +1,99 @@
1
- import { jsx as s, jsxs as w, Fragment as E } from "react/jsx-runtime";
2
- import { createContext as T, forwardRef as m, useState as M, useEffect as C, useRef as A, useContext as B } from "react";
3
- import { createPortal as F } from "react-dom";
4
- import k from "../CloseButton/index.js";
5
- import P from "../Button/index.js";
6
- const g = T(!1), H = ({ children: t, value: n }) => /* @__PURE__ */ s(g.Provider, { value: n, children: t }), N = () => B(g), d = m(({
7
- children: t,
8
- centered: n = !1,
9
- size: e = "md",
1
+ import { jsxs as p, jsx as s, Fragment as A } from "react/jsx-runtime";
2
+ import { createContext as D, forwardRef as b, useContext as P, useState as B, useEffect as w, useRef as F } from "react";
3
+ import { createPortal as K } from "react-dom";
4
+ import L from "../CloseButton/index.js";
5
+ import N from "../Button/index.js";
6
+ const g = D(null), $ = ({ children: e, value: t }) => /* @__PURE__ */ s(g.Provider, { value: t, children: e }), S = () => {
7
+ const e = P(g);
8
+ if (!e)
9
+ throw new Error(
10
+ "useModalContext has to be used within ModalContextProvider!"
11
+ );
12
+ return e;
13
+ }, j = ({
14
+ children: e,
15
+ centered: t = !1,
16
+ size: n = "md",
10
17
  show: o,
11
18
  backdrop: l = "static",
12
- onHide: a = "none",
13
- className: r,
19
+ onHide: a,
20
+ className: d,
14
21
  id: i,
15
- ...h
16
- }, b) => {
17
- const [f, c] = M(!1);
18
- C(() => {
19
- c(o);
22
+ ...m
23
+ }) => {
24
+ const [h, f] = B(o);
25
+ w(() => {
26
+ f(o);
20
27
  }, [o]);
21
- const p = A(null);
22
- j(p);
28
+ const r = F(null);
29
+ H(r);
23
30
  let u = typeof o == "boolean" && typeof a == "function" ? void 0 : { show: typeof o == "boolean", onHide: typeof a == "function" };
24
31
  u && console.error(
25
32
  u.show ? null : "The variable 'show' must be used and must be a boolean used to decide when to show the modal!",
26
33
  u.onHide ? null : "The variable 'onHide' must be used and must be a function which is used to set 'show' as the modal gets closed!"
27
34
  );
28
- const x = () => {
29
- a && a(), c(!1);
35
+ const y = () => {
36
+ a && a(), f(!1);
30
37
  };
31
- C(() => {
32
- const y = p.current;
33
- y && (f ? y.showModal() : y.close());
34
- }, [f]);
35
- let v = `sg-modal-tag sg-modal-${e}`;
36
- return r && (v += " " + r), (l === "static" || l === "true") && (v += " sg-modal-static"), f ? F(
37
- /* @__PURE__ */ s("dialog", { ref: p, className: v, children: /* @__PURE__ */ s(H, { value: a, children: u ? /* @__PURE__ */ w(E, { children: [
38
- /* @__PURE__ */ s(d.Header, { closeButton: !0, children: /* @__PURE__ */ s(d.Title, { children: "An Error ocurred!" }) }),
39
- /* @__PURE__ */ s(d.Body, { children: /* @__PURE__ */ w("p", { children: [
40
- u.show ? null : "The variable 'show' must be used and must be a boolean used to decide when to show the modal!",
41
- u.onHide ? null : "The variable 'onHide' must be used and must be a function which is used to set 'show' as the modal gets closed!"
42
- ] }) }),
43
- /* @__PURE__ */ s(d.Footer, { children: /* @__PURE__ */ s(P, { variant: "danger", type: "button", onClick: x, children: "Close" }) })
44
- ] }) : t }) }),
38
+ w(() => {
39
+ const c = r.current;
40
+ c && (h ? (c.classList.remove("close"), c.showModal()) : c.close());
41
+ }, [h]);
42
+ let v = `sg-modal-tag sg-modal-${n}`;
43
+ d && (v += " " + d), (l === "static" || l === "true") && (v += " sg-modal-static");
44
+ const k = (c) => {
45
+ if (c.key != "Escape")
46
+ return;
47
+ c.preventDefault();
48
+ const C = r.current;
49
+ C.classList.add("close"), C.addEventListener("animationend", () => {
50
+ y();
51
+ }, { once: !0 });
52
+ };
53
+ return K(
54
+ /* @__PURE__ */ s("dialog", { ref: r, className: v, onKeyDown: (c) => k(c), ...m, children: /* @__PURE__ */ s($, { value: a, children: u ? /* @__PURE__ */ s(q, { typeCheck: u, closeModal: y }) : e }) }),
45
55
  document.body
46
- ) : null;
47
- }), $ = m(({ as: t = "", className: n = "", children: e, closeButton: o = !1, onClick: l = "none", ...a }, r) => {
48
- let h = ["div", "span", "h1", "h2", "h3", "h4", "h5", "h6"].find((c) => c === t) ? t : "div";
49
- const b = N(), f = (c) => {
50
- l != "none" && l(c), b != "none" && b();
56
+ );
57
+ }, x = b(({ children: e, as: t = "", className: n = "", closeButton: o = !1, onClick: l, ...a }, d) => {
58
+ let m = ["div", "span", "h1", "h2", "h3", "h4", "h5", "h6"].find((r) => r === t) ? t : "div";
59
+ const h = S(), f = (r) => {
60
+ l && l(r), h();
51
61
  };
52
- return /* @__PURE__ */ w(h, { ref: r, className: `sg-modal-header ${n}`, ...a, children: [
62
+ return /* @__PURE__ */ p(m, { ref: d, className: `sg-modal-header ${n}`, ...a, children: [
53
63
  e,
54
- o ? /* @__PURE__ */ s(k, { variant: !0, onClick: f }) : null
64
+ o ? /* @__PURE__ */ s(L, { variant: !0, onClick: (r) => f(r) }) : null
55
65
  ] });
56
- });
57
- d.Header = $;
58
- const S = ({ children: t, as: n = "h4", className: e, ...o }, l) => {
59
- let r = ["div", "span", "h1", "h2", "h3", "h4", "h5", "h6"].find((i) => i === n) ? n : "h4";
60
- return /* @__PURE__ */ s(r, { ref: l, className: `sg-modal-title ${e}`, ...o, children: t });
61
- };
62
- d.Title = m(S);
63
- const D = ({ children: t, className: n, ...e }, o) => /* @__PURE__ */ s("div", { ref: o, className: `sg-modal-body ${n}`, ...e, children: t });
64
- d.Body = m(D);
65
- const K = ({ children: t, className: n, ...e }, o) => /* @__PURE__ */ s("div", { ref: o, className: `sg-modal-footer ${n}`, ...e, children: t });
66
- d.Footer = m(K);
67
- const j = function(t) {
68
- C(() => {
69
- const n = (e) => {
70
- const o = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])', l = t.current;
66
+ }), E = b(({ children: e, as: t = "h4", className: n, ...o }, l) => {
67
+ let d = ["div", "span", "h1", "h2", "h3", "h4", "h5", "h6"].find((i) => i === t) ? t : "h4";
68
+ return /* @__PURE__ */ s(d, { ref: l, className: `sg-modal-title ${n}`, ...o, children: e });
69
+ }), M = b(({ children: e, className: t, ...n }, o) => /* @__PURE__ */ s("div", { ref: o, className: `sg-modal-body ${t}`, ...n, children: e })), T = b(({ children: e, className: t, ...n }, o) => /* @__PURE__ */ s("div", { ref: o, className: `sg-modal-footer ${t}`, ...n, children: e })), Q = Object.assign(j, {
70
+ Header: x,
71
+ Title: E,
72
+ Body: M,
73
+ Footer: T
74
+ }), H = function(e) {
75
+ w(() => {
76
+ const t = (n) => {
77
+ const o = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])', l = e.current;
71
78
  if (l) {
72
- const a = l.querySelectorAll(o)[0], r = l.querySelectorAll(o), i = r[r.length - 1];
73
- if (!(e.key === "Tab" || e.keyCode === 9))
79
+ const a = l.querySelectorAll(o)[0], d = l.querySelectorAll(o), i = d[d.length - 1];
80
+ if (!(n.key === "Tab"))
74
81
  return;
75
- e.shiftKey ? document.activeElement === a && (i.focus(), e.preventDefault()) : document.activeElement === i && (a.focus(), e.preventDefault());
82
+ n.shiftKey ? document.activeElement === a && (i.focus(), n.preventDefault()) : document.activeElement === i && (a.focus(), n.preventDefault());
76
83
  }
77
84
  };
78
- return document.addEventListener("keydown", n, !0), function() {
79
- document.removeEventListener("keydown", n, !0);
85
+ return document.addEventListener("keydown", t, !0), function() {
86
+ document.removeEventListener("keydown", t, !0);
80
87
  };
81
- }, [t]);
82
- };
88
+ }, [e]);
89
+ }, q = ({ typeCheck: e, closeModal: t }) => /* @__PURE__ */ p(A, { children: [
90
+ /* @__PURE__ */ s(x, { closeButton: !0, children: /* @__PURE__ */ s(E, { children: "An Error ocurred!" }) }),
91
+ /* @__PURE__ */ s(M, { children: /* @__PURE__ */ p("p", { children: [
92
+ e.show ? null : "The variable 'show' must be used and must be a boolean used to decide when to show the modal!",
93
+ e.onHide ? null : "The variable 'onHide' must be used and must be a function which is used to set 'show' as the modal gets closed!"
94
+ ] }) }),
95
+ /* @__PURE__ */ s(T, { children: /* @__PURE__ */ s(N, { variant: "danger", type: "button", onClick: () => t(), children: "Close" }) })
96
+ ] });
83
97
  export {
84
- d as default
98
+ Q as default
85
99
  };
@@ -0,0 +1,46 @@
1
+ import React from "react";
2
+ import { BaseAnchorType, BaseElementType, BaseLItemType, BaseUListType } from "../BaseTypes";
3
+ export type NavType = {
4
+ children: React.ReactNode;
5
+ className?: string;
6
+ as?: React.ElementType;
7
+ } & (BaseUListType | BaseElementType);
8
+ export type NavItemType = {
9
+ children: React.ReactNode;
10
+ className?: string;
11
+ as?: React.ElementType;
12
+ } & (BaseLItemType | BaseElementType);
13
+ export type NavLinkType = {
14
+ children: React.ReactNode;
15
+ className?: string;
16
+ as?: React.ElementType;
17
+ } & (BaseAnchorType | BaseElementType);
18
+ declare const _default: React.ForwardRefExoticComponent<(Omit<{
19
+ children: React.ReactNode;
20
+ className?: string | undefined;
21
+ as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
22
+ } & React.ClassAttributes<HTMLUListElement> & React.HTMLAttributes<HTMLUListElement>, "ref"> | Omit<{
23
+ children: React.ReactNode;
24
+ className?: string | undefined;
25
+ as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
26
+ } & React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement>, "ref">) & React.RefAttributes<HTMLElement>> & {
27
+ Item: React.ForwardRefExoticComponent<(Omit<{
28
+ children: React.ReactNode;
29
+ className?: string | undefined;
30
+ as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
31
+ } & React.ClassAttributes<HTMLLIElement> & React.LiHTMLAttributes<HTMLLIElement>, "ref"> | Omit<{
32
+ children: React.ReactNode;
33
+ className?: string | undefined;
34
+ as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
35
+ } & React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement>, "ref">) & React.RefAttributes<HTMLElement>>;
36
+ Link: React.ForwardRefExoticComponent<(Omit<{
37
+ children: React.ReactNode;
38
+ className?: string | undefined;
39
+ as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
40
+ } & React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement>, "ref"> | Omit<{
41
+ children: React.ReactNode;
42
+ className?: string | undefined;
43
+ as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
44
+ } & React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement>, "ref">) & React.RefAttributes<HTMLElement>>;
45
+ };
46
+ export default _default;
package/dist/Nav/index.js CHANGED
@@ -1,14 +1,13 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { forwardRef as s } from "react";
3
- import { navbarContext as u } from "../NavBar/index.js";
4
- const l = s(({ children: o, className: n, fill: e, justify: r, as: t = "ul", ...m }, f) => {
5
- const p = t;
6
- let i = "";
7
- return u && (i = "sg-navbar-"), /* @__PURE__ */ a(p, { role: "menubar", ref: f, className: `${n} ${i}nav`, ...m, children: o });
8
- }), c = ({ children: o, className: n, as: e = "li", ...r }, t) => /* @__PURE__ */ a(e, { role: "none", ref: t, className: `sg-nav-item${n ? " " + n : ""}`, ...r, children: o });
9
- l.Item = s(c);
10
- const v = ({ children: o, className: n, as: e = "a", ...r }, t) => /* @__PURE__ */ a(e, { role: "menuitem", ref: t, className: `sg-nav-link${n ? " " + n : ""}`, ...r, children: o });
11
- l.Link = s(v);
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { forwardRef as m } from "react";
3
+ import { useNavbarContext as c } from "../NavBar/index.js";
4
+ const p = m(({ children: o, className: n, as: t = "ul", ...e }, r) => {
5
+ const a = t, i = c();
6
+ return /* @__PURE__ */ s(a, { ref: r, className: `${n} ${i || "sg-navbar-"}nav`, ...e, children: o });
7
+ }), v = m(({ children: o, className: n, as: t = "li", ...e }, r) => /* @__PURE__ */ s(t, { role: "none", ref: r, className: `sg-nav-item${n ? " " + n : ""}`, ...e, children: o })), f = m(({ children: o, className: n, as: t = "a", ...e }, r) => /* @__PURE__ */ s(t, { role: "menuitem", ref: r, className: `sg-nav-link${n ? " " + n : ""}`, ...e, children: o })), b = Object.assign(p, {
8
+ Item: v,
9
+ Link: f
10
+ });
12
11
  export {
13
- l as default
12
+ b as default
14
13
  };
@@ -0,0 +1,46 @@
1
+ import React from "react";
2
+ import { BaseAnchorType, BaseElementType, BaseNavType } from "../BaseTypes";
3
+ export type NavbarContextType = string | null;
4
+ export declare const NavbarContext: React.Context<NavbarContextType>;
5
+ export declare const useNavbarContext: () => NavbarContextType;
6
+ export type NavbarType = {
7
+ children: React.ReactNode;
8
+ className?: string;
9
+ navbarPrefix?: string;
10
+ } & BaseNavType;
11
+ export type NavbarBrandType = {
12
+ children: React.ReactNode;
13
+ className?: string;
14
+ as?: React.ElementType;
15
+ href?: string;
16
+ } & (BaseAnchorType | BaseElementType);
17
+ export type NavbarTextType = {
18
+ children: React.ReactNode;
19
+ className?: string;
20
+ as?: React.ElementType;
21
+ } & BaseElementType;
22
+ declare const _default: React.ForwardRefExoticComponent<Omit<NavbarType, "ref"> & React.RefAttributes<HTMLElement>> & {
23
+ Brand: React.ForwardRefExoticComponent<(Omit<{
24
+ children: React.ReactNode;
25
+ className?: string | undefined;
26
+ as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
27
+ href?: string | undefined;
28
+ } & React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement>, "ref"> | Omit<{
29
+ children: React.ReactNode;
30
+ className?: string | undefined;
31
+ as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
32
+ href?: string | undefined;
33
+ } & React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement>, "ref">) & React.RefAttributes<BaseAnchorType | BaseElementType>>;
34
+ Text: React.ForwardRefExoticComponent<(Omit<{
35
+ children: React.ReactNode;
36
+ className?: string | undefined;
37
+ as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
38
+ href?: string | undefined;
39
+ } & React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement>, "ref"> | Omit<{
40
+ children: React.ReactNode;
41
+ className?: string | undefined;
42
+ as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
43
+ href?: string | undefined;
44
+ } & React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement>, "ref">) & React.RefAttributes<HTMLElement>>;
45
+ };
46
+ export default _default;
@@ -1,16 +1,17 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { createContext as b, forwardRef as v, useMemo as d } from "react";
3
- const m = b(null), p = ({ children: t, value: n }) => /* @__PURE__ */ e(m.Provider, { value: n, children: t }), c = v(({ children: t, className: n, navbarPrefix: r = "sg-navbar-", ...o }, a) => {
4
- const s = d(() => r, [r]);
5
- return /* @__PURE__ */ e("nav", { ref: a, className: `sg-navbar${n ? " " + n : ""}`, ...o, children: /* @__PURE__ */ e(p, { value: s, children: t }) });
6
- }), x = ({ children: t, className: n, href: r = "#", as: o = "a", ...a }, s) => {
7
- const u = o || (r && o != "Link" ? "a" : "span");
8
- return /* @__PURE__ */ e(u, { ref: s, href: r, className: `sg-navbar-brand${n ? " " + n : ""}`, ...a, children: t });
9
- };
10
- c.Brand = v(x);
11
- const C = ({ children: t, className: n, as: r = "span", ...o }, a) => /* @__PURE__ */ e(r, { ref: a, className: `sg-navbar-text${n ? " " + n : ""}`, ...o, children: t });
12
- c.Text = v(C);
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { createContext as x, forwardRef as c, useMemo as b, useContext as C } from "react";
3
+ const u = x(null), d = ({ children: t, value: n }) => /* @__PURE__ */ a(u.Provider, { value: n, children: t }), N = () => C(u), m = c(({ children: t, className: n, navbarPrefix: o = "sg-navbar-", ...r }, e) => {
4
+ const s = b(() => o, [o]);
5
+ return /* @__PURE__ */ a("nav", { ref: e, className: `sg-navbar${n ? " " + n : ""}`, ...r, children: /* @__PURE__ */ a(d, { value: s, children: t }) });
6
+ }), p = c(({ children: t, className: n, href: o = "#", as: r = "a", ...e }, s) => {
7
+ const v = r || (o && r != "Link" ? "a" : "span");
8
+ return /* @__PURE__ */ a(v, { ref: s, href: o, className: `sg-navbar-brand${n ? " " + n : ""}`, ...e, children: t });
9
+ }), i = c(({ children: t, className: n, as: o = "span", ...r }, e) => /* @__PURE__ */ a(o, { ref: e, className: `sg-navbar-text${n ? " " + n : ""}`, ...r, children: t })), f = Object.assign(m, {
10
+ Brand: p,
11
+ Text: i
12
+ });
13
13
  export {
14
- c as default,
15
- m as navbarContext
14
+ u as NavbarContext,
15
+ f as default,
16
+ N as useNavbarContext
16
17
  };
@@ -0,0 +1,39 @@
1
+ /// <reference types="react" />
2
+ import { DropdownType } from "../Dropdown";
3
+ export type NavDropdownType = {
4
+ toggleProps?: any;
5
+ menuProps?: any;
6
+ } & DropdownType;
7
+ declare const _default: import("react").ForwardRefExoticComponent<Omit<NavDropdownType, "ref"> & import("react").RefAttributes<HTMLDivElement>> & {
8
+ Toggle: import("react").ForwardRefExoticComponent<(Omit<{
9
+ children: import("react").ReactNode;
10
+ className?: string | undefined;
11
+ navDropdown?: boolean | undefined;
12
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
13
+ variant?: string | undefined;
14
+ } & import("react").ClassAttributes<HTMLAnchorElement> & import("react").AnchorHTMLAttributes<HTMLAnchorElement>, "ref"> | Omit<{
15
+ children: import("react").ReactNode;
16
+ className?: string | undefined;
17
+ navDropdown?: boolean | undefined;
18
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
19
+ variant?: string | undefined;
20
+ } & import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement>, "ref"> | Omit<{
21
+ children: import("react").ReactNode;
22
+ className?: string | undefined;
23
+ navDropdown?: boolean | undefined;
24
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
25
+ variant?: string | undefined;
26
+ } & import("react").ClassAttributes<HTMLElement> & import("react").HTMLAttributes<HTMLElement>, "ref">) & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
27
+ Menu: import("react").ForwardRefExoticComponent<Omit<import("../Dropdown").DropdownMenuType, "ref"> & import("react").RefAttributes<HTMLUListElement>>;
28
+ Item: import("react").ForwardRefExoticComponent<(Omit<{
29
+ children: import("react").ReactNode;
30
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
31
+ className?: string | undefined;
32
+ } & import("react").ClassAttributes<HTMLAnchorElement> & import("react").AnchorHTMLAttributes<HTMLAnchorElement>, "ref"> | Omit<{
33
+ children: import("react").ReactNode;
34
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
35
+ className?: string | undefined;
36
+ } & import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement>, "ref">) & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
37
+ Divider: import("react").ForwardRefExoticComponent<Omit<import("../Dropdown").DropdownDividerType, "ref"> & import("react").RefAttributes<HTMLHRElement>>;
38
+ };
39
+ export default _default;