stargazer-ui 1.0.1 → 1.0.2
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/Button/index.js +6 -0
- package/dist/Card/index.js +32 -0
- package/dist/CloseButton/index.js +6 -0
- package/dist/Dropdown/index.js +182 -0
- package/dist/FloatingLabel/index.js +13 -0
- package/dist/Form/index.js +58 -0
- package/dist/InputGroup/index.js +7 -0
- package/dist/Modal/index.js +85 -0
- package/dist/Nav/index.js +14 -0
- package/dist/NavBar/index.js +16 -0
- package/dist/NavDropdown/index.js +850 -0
- package/dist/Overlay/index.js +125 -0
- package/dist/Popout/index.js +85 -0
- package/dist/Tabs/index.js +69 -0
- package/dist/ToggleButton/index.js +11 -0
- package/dist/main.js +30 -0
- package/dist/stylesheets/stargazerui.css +113 -62
- package/dist/stylesheets/stargazerui.css.map +1 -1
- package/package.json +12 -11
- package/dist/ui.es.js +0 -1983
- package/dist/ui.umd.js +0 -33
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as f } from "react";
|
|
3
|
+
const s = f(({ variant: o = "primary", children: r, className: t, ...n }, u) => /* @__PURE__ */ e("button", { ref: u, type: "button", className: `sg-button sg-button-${o}${t == null ? "" : " " + t}`, ...n, children: r }));
|
|
4
|
+
export {
|
|
5
|
+
s as default
|
|
6
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import c, { forwardRef as h } from "react";
|
|
3
|
+
const m = h(({ children: e, className: s, ...o }, r) => {
|
|
4
|
+
let n = Object.keys(m), t = [], l = e.length === void 0 ? e : e.filter((a) => a != null && a != "");
|
|
5
|
+
return n.forEach((a) => {
|
|
6
|
+
c.Children.forEach(l, (i) => i.type.name === a ? t.push(i) : null);
|
|
7
|
+
}), t.length === 0 && (t = [l]), /* @__PURE__ */ d("div", { ref: r, className: "sg-card " + s, ...o, children: t.map((a) => a) });
|
|
8
|
+
}), p = h(({ as: e, className: s, children: o, ...r }, n) => {
|
|
9
|
+
let l = ["div", "span", "h1", "h2", "h3", "h4", "h5", "h6"].find((a) => a === e) ? e : "div";
|
|
10
|
+
return /* @__PURE__ */ d(l, { ref: n, className: `sg-card-header ${s}`, ...r, children: o });
|
|
11
|
+
});
|
|
12
|
+
m.Header = p;
|
|
13
|
+
const u = ({ children: e, className: s, ...o }, r) => {
|
|
14
|
+
e = e.length ? e.filter((t) => t != null && t != "") : e;
|
|
15
|
+
let n = [];
|
|
16
|
+
return c.Children.forEach(e, (t) => {
|
|
17
|
+
n.push(t);
|
|
18
|
+
}), /* @__PURE__ */ d("div", { ref: r, className: `sg-card-body ${s}`, ...o, children: n.map((t) => t) });
|
|
19
|
+
};
|
|
20
|
+
m.Body = h(u);
|
|
21
|
+
const f = h(({ as: e, className: s, children: o, ...r }, n) => {
|
|
22
|
+
let l = ["h1", "h2", "h3", "h4", "h5", "h6"].find((a) => a === e) ? e : "h5";
|
|
23
|
+
return /* @__PURE__ */ d(l, { ref: n, className: s, ...r, children: o });
|
|
24
|
+
});
|
|
25
|
+
m.Title = f;
|
|
26
|
+
const v = ({ children: e, className: s, ...o }, r) => /* @__PURE__ */ d("p", { ref: r, className: `sg-card-text ${s}`, ...o, children: e });
|
|
27
|
+
m.Text = h(v);
|
|
28
|
+
const g = ({ children: e, className: s, ...o }, r) => /* @__PURE__ */ d("div", { ref: r, className: `sg-card-footer ${s}`, ...o, children: e });
|
|
29
|
+
m.Footer = h(g);
|
|
30
|
+
export {
|
|
31
|
+
m as default
|
|
32
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as a } from "react";
|
|
3
|
+
const c = a(({ className: e, variant: o = !1, ...l }, t) => /* @__PURE__ */ s("button", { ref: t, className: `sg-button-close${o ? " sg-button-close-white" : ""} ${e}`, ...l, children: /* @__PURE__ */ s("span", { className: "sg-close-visually-hidden-label", children: "Close" }) }));
|
|
4
|
+
export {
|
|
5
|
+
c as default
|
|
6
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { jsx as b } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as $, forwardRef as E, useState as C, useCallback as M, useMemo as P, useContext as S, useEffect as k, useLayoutEffect as A } from "react";
|
|
3
|
+
const L = (s, o, r = !1) => {
|
|
4
|
+
const i = r ? "top-end" : "top-start", u = r ? "top-start" : "top-end", c = r ? "bottom-end" : "bottom-start", v = r ? "bottom-start" : "bottom-end", f = r ? "right-start" : "left-start", d = r ? "right-end" : "left-end", g = r ? "left-start" : "right-start", m = r ? "left-end" : "right-end";
|
|
5
|
+
let n = s ? v : c;
|
|
6
|
+
return o === "up" ? n = s ? u : i : o === "end" ? n = s ? m : g : o === "start" ? n = s ? d : f : o === "down-centered" ? n = "bottom" : o === "up-centered" && (n = "top"), n;
|
|
7
|
+
}, x = (s, o = "") => {
|
|
8
|
+
let r = s.target, i = !0, u = !1;
|
|
9
|
+
for (; i; )
|
|
10
|
+
r.id != o + "-menu" ? r = r.parentElement : (u = !0, i = !1), r.id === "root" && (i = !1, u = !1);
|
|
11
|
+
return u;
|
|
12
|
+
}, I = $(null), O = ({ children: s, value: o, ...r }) => /* @__PURE__ */ b(I.Provider, { value: o, children: s }), y = E(({
|
|
13
|
+
children: s,
|
|
14
|
+
className: o,
|
|
15
|
+
onSelect: r,
|
|
16
|
+
onToggle: i,
|
|
17
|
+
controlID: u,
|
|
18
|
+
drop: c = "down",
|
|
19
|
+
align: v = "start",
|
|
20
|
+
autoClose: f = !0,
|
|
21
|
+
show: d = "default",
|
|
22
|
+
...g
|
|
23
|
+
}, m) => {
|
|
24
|
+
const [n, e] = C(d === "default" ? !1 : d), [p, w] = C({ case: "" }), l = M((B) => {
|
|
25
|
+
B.stopPropagation(), e((D) => !D);
|
|
26
|
+
}, []), a = L(v === "end", c), h = P(() => ({
|
|
27
|
+
align: v,
|
|
28
|
+
drop: c,
|
|
29
|
+
showInternal: d != "default" && i ? d : n,
|
|
30
|
+
handleToggle: d != "default" && i ? i : l,
|
|
31
|
+
placement: a,
|
|
32
|
+
directionClasses: {
|
|
33
|
+
down: "dropdown",
|
|
34
|
+
"down-centered": "dropdown-center",
|
|
35
|
+
up: "dropup",
|
|
36
|
+
"up-centered": "dropup-center dropup",
|
|
37
|
+
end: "dropend",
|
|
38
|
+
start: "dropstart"
|
|
39
|
+
},
|
|
40
|
+
controlID: u,
|
|
41
|
+
activeDescendant: p,
|
|
42
|
+
setActiveDescendant: w
|
|
43
|
+
}), [v, c, d, n, i, l, a, u, p, w]);
|
|
44
|
+
return /* @__PURE__ */ b("div", { id: u + "-wrapper", ref: m, className: `sg-dropdown${o ? " " + o : ""}`, ...g, children: /* @__PURE__ */ b(O, { value: h, children: s }) });
|
|
45
|
+
}), q = ({ children: s, className: o, navDropdown: r = !1, as: i = "button", variant: u = "primary", ...c }, v) => {
|
|
46
|
+
const { controlID: f, handleToggle: d, setActiveDescendant: g, showInternal: m } = S(I), n = i, e = (t) => {
|
|
47
|
+
let a = !1;
|
|
48
|
+
switch (t.key) {
|
|
49
|
+
case "ArrowDown":
|
|
50
|
+
a = !0, m ? g((h) => ({ case: "next" })) : (d(t), g((h) => ({ case: "first" })));
|
|
51
|
+
break;
|
|
52
|
+
case "ArrowUp":
|
|
53
|
+
a = !0, m ? g((h) => ({ case: "previous" })) : (d(t), g((h) => ({ case: "last" })));
|
|
54
|
+
break;
|
|
55
|
+
case "Home":
|
|
56
|
+
a = !0, m && g((h) => ({ case: "first" }));
|
|
57
|
+
break;
|
|
58
|
+
case "End":
|
|
59
|
+
a = !0, m && g((h) => ({ case: "last" }));
|
|
60
|
+
break;
|
|
61
|
+
case "Escape":
|
|
62
|
+
a = !0, m && d(t);
|
|
63
|
+
break;
|
|
64
|
+
case "Enter":
|
|
65
|
+
case " ":
|
|
66
|
+
if (m) {
|
|
67
|
+
a = !0, document.querySelector(".sg-dropdown-item-visual-focus").click(), d(t);
|
|
68
|
+
break;
|
|
69
|
+
} else {
|
|
70
|
+
g((h) => ({ case: "first" }));
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
a && (t.stopPropagation(), t.preventDefault());
|
|
75
|
+
}, p = (t) => {
|
|
76
|
+
m && t.target.id !== f && (x(t, f) ? x(t, f) && (d(t), document.getElementById(f).focus()) : d(t));
|
|
77
|
+
};
|
|
78
|
+
k(() => {
|
|
79
|
+
const t = document.getElementById(f);
|
|
80
|
+
return t.addEventListener("keydown", e, !0), document.addEventListener("mouseup", p, !0), function() {
|
|
81
|
+
t.removeEventListener("keydown", e, !0), document.removeEventListener("mouseup", p, !0);
|
|
82
|
+
};
|
|
83
|
+
}, [e, f]);
|
|
84
|
+
const w = (t) => {
|
|
85
|
+
d(t), m || g((a) => ({ case: "first" }));
|
|
86
|
+
};
|
|
87
|
+
let l = `sg-button sg-button${u ? "-" + u : "-primary"} sg-dropdown-toggle${o ? " " + o : ""}`;
|
|
88
|
+
return (n === "a" || r) && (l = `sg-nav-dropdown-toggle sg-dropdown-toggle${o ? " " + o : ""}`), /* @__PURE__ */ b(
|
|
89
|
+
n,
|
|
90
|
+
{
|
|
91
|
+
tabIndex: "0",
|
|
92
|
+
type: "button",
|
|
93
|
+
"aria-haspopup": "true",
|
|
94
|
+
"aria-controls": f + "-menu",
|
|
95
|
+
"aria-expanded": m,
|
|
96
|
+
id: f,
|
|
97
|
+
ref: v,
|
|
98
|
+
className: l,
|
|
99
|
+
onClick: (t) => w(t),
|
|
100
|
+
...c,
|
|
101
|
+
children: s
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
y.Toggle = E(q);
|
|
106
|
+
const H = ({ children: s, className: o, style: r = {}, ...i }, u) => {
|
|
107
|
+
const { controlID: c, showInternal: v, activeDescendant: f } = S(I), [d, g] = C(r);
|
|
108
|
+
A(() => {
|
|
109
|
+
if (v) {
|
|
110
|
+
const n = document.getElementById(c + "-menu");
|
|
111
|
+
console.log(n);
|
|
112
|
+
let e = {};
|
|
113
|
+
n.getBoundingClientRect().right > window.innerWidth ? e = { ...e, right: 0 } : n.getBoundingClientRect().left < 0 ? e = { ...e, left: 0 } : n.getBoundingClientRect().top < 0 ? e = { ...e, top: 0 } : n.getBoundingClientRect().bottom > window.innerHeight && (e = { ...e, bottom: 0 }), console.log(e), g((p) => ({ ...p, ...e }));
|
|
114
|
+
}
|
|
115
|
+
}, [v]), k(() => {
|
|
116
|
+
if (v) {
|
|
117
|
+
const n = document.getElementById(c + "-menu"), e = document.getElementById(c + "-menu").children, p = e.length - 1, w = document.querySelector(".sg-dropdown-item-visual-focus");
|
|
118
|
+
let l = 0, t = e[0].children[0];
|
|
119
|
+
if (w != null) {
|
|
120
|
+
for (let a = 0; a < e.length; a++)
|
|
121
|
+
e[a] === w.parentElement && (l = a);
|
|
122
|
+
w.classList.remove("sg-dropdown-item-visual-focus");
|
|
123
|
+
}
|
|
124
|
+
switch (f.case) {
|
|
125
|
+
case "first":
|
|
126
|
+
t = e[0].children[0], l = 0;
|
|
127
|
+
break;
|
|
128
|
+
case "last":
|
|
129
|
+
t = e[p].children[0], l = p;
|
|
130
|
+
break;
|
|
131
|
+
case "next":
|
|
132
|
+
l = l === p ? 0 : l + 1, t = e[l].children[0];
|
|
133
|
+
break;
|
|
134
|
+
case "previous":
|
|
135
|
+
l = l === 0 ? p : l - 1, t = e[l].children[0];
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
n.setAttribute("aria-activedescendant", t.id), e[l].children[0].classList.add("sg-dropdown-item-visual-focus");
|
|
139
|
+
} else
|
|
140
|
+
document.getElementById(c + "-menu").setAttribute("aria-activedescendant", "");
|
|
141
|
+
}, [c, v, f]);
|
|
142
|
+
const m = (n) => {
|
|
143
|
+
const e = n.target;
|
|
144
|
+
e.classList.contains("sg-dropdown-item-visual-focus") || (document.querySelector(".sg-dropdown-item-visual-focus").classList.remove("sg-dropdown-item-visual-focus"), e.classList.add("sg-dropdown-item-visual-focus"));
|
|
145
|
+
};
|
|
146
|
+
return k(() => {
|
|
147
|
+
const n = document.getElementById(c + "-menu");
|
|
148
|
+
for (let e of n.children)
|
|
149
|
+
e.addEventListener("mouseover", m, !0);
|
|
150
|
+
return function() {
|
|
151
|
+
for (let p of n.children)
|
|
152
|
+
p.removeEventListener("mouseover", m, !0);
|
|
153
|
+
};
|
|
154
|
+
}, []), /* @__PURE__ */ b(
|
|
155
|
+
"ul",
|
|
156
|
+
{
|
|
157
|
+
id: c + "-menu",
|
|
158
|
+
role: "menu",
|
|
159
|
+
tabIndex: "-1",
|
|
160
|
+
"aria-labelledby": c,
|
|
161
|
+
"aria-activedescendant": f,
|
|
162
|
+
ref: u,
|
|
163
|
+
className: `sg-dropdown-list${o ? " " + o : ""}${v ? " show" : ""}`,
|
|
164
|
+
style: d,
|
|
165
|
+
...i,
|
|
166
|
+
children: s
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
y.Menu = E(H);
|
|
171
|
+
const V = ({ children: s, as: o = "button", className: r, ...i }, u) => /* @__PURE__ */ b("li", { role: "none", children: /* @__PURE__ */ b(o, { role: "menuitem", tabIndex: "-1", ref: u, className: `sg-dropdown-item${r ? " " + r : ""}`, ...i, children: s }) });
|
|
172
|
+
y.Item = E(V);
|
|
173
|
+
const W = ({ className: s = "", ...o }, r) => /* @__PURE__ */ b("hr", { className: `.sg-dropdown-divider${s}`, ...o });
|
|
174
|
+
y.Divider = E(W);
|
|
175
|
+
export {
|
|
176
|
+
W as Divider,
|
|
177
|
+
I as DropdownContext,
|
|
178
|
+
V as Item,
|
|
179
|
+
H as Menu,
|
|
180
|
+
q as Toggle,
|
|
181
|
+
y as default
|
|
182
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as r, jsxs as n } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as s, useMemo as i } from "react";
|
|
3
|
+
import { FormContext as f } from "../Form/index.js";
|
|
4
|
+
const u = s(({ children: e, label: t, controlId: l, ...a }, m) => {
|
|
5
|
+
const o = i(() => ({ controlId: l }));
|
|
6
|
+
return /* @__PURE__ */ r(f.Provider, { value: o, children: /* @__PURE__ */ n("div", { className: "sg-form-floating", children: [
|
|
7
|
+
e,
|
|
8
|
+
/* @__PURE__ */ r("label", { ref: m, htmlFor: o.controlId, className: "sg-form-floating-label", ...a, children: t })
|
|
9
|
+
] }) });
|
|
10
|
+
});
|
|
11
|
+
export {
|
|
12
|
+
u as default
|
|
13
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as n, jsxs as v, Fragment as w } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as I, forwardRef as s, useContext as $, useMemo as j } from "react";
|
|
3
|
+
const x = I(!1), G = ({ children: t, value: e }) => /* @__PURE__ */ n(x.Provider, { value: e, children: t }), d = s(({ children: t, ...e }, r) => /* @__PURE__ */ n("form", { ref: r, ...e, children: t })), H = ({ as: t = "input", className: e = "", plaintext: r = !1, id: l = "", type: o = "text", autoFocus: c = !1, ...m }, u) => {
|
|
4
|
+
let i = ["input", "textarea"].find((p) => p === t) ? t : "input";
|
|
5
|
+
const { controlId: f } = $(x);
|
|
6
|
+
let a = f || l, h = (r ? "sg-form-control-plaintext" : "sg-form-control") + (e != "" ? " " + e : "") + (o == "color" ? " sg-form-control-color" : "");
|
|
7
|
+
return /* @__PURE__ */ n(i, { autoFocus: c, ref: u, id: a, type: o, className: h, ...m });
|
|
8
|
+
};
|
|
9
|
+
d.Control = s(H);
|
|
10
|
+
const P = ({ children: t, className: e, id: r, ...l }, o) => {
|
|
11
|
+
const { controlId: c } = $(x);
|
|
12
|
+
let m = c || r;
|
|
13
|
+
return /* @__PURE__ */ n("select", { ref: o, className: `sg-form-select${e ? " " + e : ""}`, id: m, ...l, children: t });
|
|
14
|
+
};
|
|
15
|
+
d.Select = s(P);
|
|
16
|
+
const S = ({ children: t, className: e, controlId: r, ...l }, o) => {
|
|
17
|
+
const c = j(() => ({ controlId: r }), [r]);
|
|
18
|
+
return /* @__PURE__ */ n("div", { ref: o, className: `sg-from-group${e ? " " + e : ""}`, ...l, children: /* @__PURE__ */ n(G, { value: c, children: t }) });
|
|
19
|
+
};
|
|
20
|
+
d.Group = s(S);
|
|
21
|
+
const T = ({ children: t, className: e, htmlFor: r }, l) => {
|
|
22
|
+
const { controlId: o } = $(x);
|
|
23
|
+
return /* @__PURE__ */ n("label", { ref: l, htmlFor: r || o, className: `sg-form-label${e ? " " + e : ""}`, children: t });
|
|
24
|
+
};
|
|
25
|
+
d.Label = s(T);
|
|
26
|
+
const y = ({
|
|
27
|
+
classNameContainer: t,
|
|
28
|
+
containerRef: e,
|
|
29
|
+
containerId: r,
|
|
30
|
+
style: l,
|
|
31
|
+
classNameLabel: o,
|
|
32
|
+
labelRef: c,
|
|
33
|
+
label: m,
|
|
34
|
+
labelId: u,
|
|
35
|
+
className: i,
|
|
36
|
+
type: f,
|
|
37
|
+
id: a,
|
|
38
|
+
controlId: h,
|
|
39
|
+
reverse: p = !1,
|
|
40
|
+
checkStyle: b,
|
|
41
|
+
...C
|
|
42
|
+
}, k) => {
|
|
43
|
+
let g = h || a, F = f === "switch" ? "checkbox" : f;
|
|
44
|
+
return /* @__PURE__ */ n("div", { ref: e, id: r, style: l, className: `sg-form-check${p ? "-reverse" : ""}${t ? " " + t : ""}${f === "switch" ? " sg-form-switch" : ""}`, children: p ? /* @__PURE__ */ v(w, { children: [
|
|
45
|
+
/* @__PURE__ */ n("input", { ref: k, type: F, id: g, className: `sg-form-check-input${i ? " " + i : ""}`, ...C }),
|
|
46
|
+
/* @__PURE__ */ n("label", { ref: c, id: u, htmlFor: g, className: `sg-form-check-label${o ? " " + o : ""}`, children: m })
|
|
47
|
+
] }) : /* @__PURE__ */ v(w, { children: [
|
|
48
|
+
/* @__PURE__ */ n("label", { ref: c, id: u, htmlFor: g, className: `sg-form-check-label${o ? " " + o : ""}`, children: m }),
|
|
49
|
+
/* @__PURE__ */ n("input", { ref: k, type: F, id: g, className: `sg-form-check-input${i ? " " + i : ""}`, style: b, ...C })
|
|
50
|
+
] }) });
|
|
51
|
+
};
|
|
52
|
+
d.Check = s(y);
|
|
53
|
+
const M = ({ children: t, className: e, ...r }, l) => /* @__PURE__ */ n("small", { className: `sg-form-text${e ? " " + e : ""}`, children: t });
|
|
54
|
+
d.Text = s(M);
|
|
55
|
+
export {
|
|
56
|
+
x as FormContext,
|
|
57
|
+
d as default
|
|
58
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as e } from "react";
|
|
3
|
+
const n = e(({ children: r, className: t, ...o }, p) => /* @__PURE__ */ u("div", { ref: p, className: `sg-input-group${t ? " " + t : ""}`, ...o, children: r })), s = ({ children: r, className: t, ...o }, p) => /* @__PURE__ */ u("span", { ref: p, className: `sg-input-group-text${t ? " " + t : ""}`, ...o, children: r });
|
|
4
|
+
n.Text = e(s);
|
|
5
|
+
export {
|
|
6
|
+
n as default
|
|
7
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
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",
|
|
10
|
+
show: o,
|
|
11
|
+
backdrop: l = "static",
|
|
12
|
+
onHide: a = "none",
|
|
13
|
+
className: r,
|
|
14
|
+
id: i,
|
|
15
|
+
...h
|
|
16
|
+
}, b) => {
|
|
17
|
+
const [f, c] = M(!1);
|
|
18
|
+
C(() => {
|
|
19
|
+
c(o);
|
|
20
|
+
}, [o]);
|
|
21
|
+
const p = A(null);
|
|
22
|
+
j(p);
|
|
23
|
+
let u = typeof o == "boolean" && typeof a == "function" ? void 0 : { show: typeof o == "boolean", onHide: typeof a == "function" };
|
|
24
|
+
u && console.error(
|
|
25
|
+
u.show ? null : "The variable 'show' must be used and must be a boolean used to decide when to show the modal!",
|
|
26
|
+
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
|
+
);
|
|
28
|
+
const x = () => {
|
|
29
|
+
a && a(), c(!1);
|
|
30
|
+
};
|
|
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 }) }),
|
|
45
|
+
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();
|
|
51
|
+
};
|
|
52
|
+
return /* @__PURE__ */ w(h, { ref: r, className: `sg-modal-header ${n}`, ...a, children: [
|
|
53
|
+
e,
|
|
54
|
+
o ? /* @__PURE__ */ s(k, { variant: !0, onClick: f }) : null
|
|
55
|
+
] });
|
|
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;
|
|
71
|
+
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))
|
|
74
|
+
return;
|
|
75
|
+
e.shiftKey ? document.activeElement === a && (i.focus(), e.preventDefault()) : document.activeElement === i && (a.focus(), e.preventDefault());
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
return document.addEventListener("keydown", n, !0), function() {
|
|
79
|
+
document.removeEventListener("keydown", n, !0);
|
|
80
|
+
};
|
|
81
|
+
}, [t]);
|
|
82
|
+
};
|
|
83
|
+
export {
|
|
84
|
+
d as default
|
|
85
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
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);
|
|
12
|
+
export {
|
|
13
|
+
l as default
|
|
14
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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);
|
|
13
|
+
export {
|
|
14
|
+
c as default,
|
|
15
|
+
m as navbarContext
|
|
16
|
+
};
|