stargazer-ui 1.0.2 → 1.0.3
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/BaseTypes.d.ts +15 -0
- package/dist/BaseTypes.js +1 -0
- package/dist/Button/index.d.ts +9 -0
- package/dist/Button/index.js +1 -1
- package/dist/Card/index.d.ts +92 -0
- package/dist/Card/index.js +15 -29
- package/dist/CloseButton/index.d.ts +8 -0
- package/dist/Dropdown/index.d.ts +108 -0
- package/dist/Dropdown/index.js +139 -117
- package/dist/Form/index.d.ts +61 -0
- package/dist/Form/index.js +55 -51
- package/dist/Overlay/index.js +36 -36
- package/dist/vite-env.d.js +1 -0
- package/package.json +11 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type BaseAnchorType = React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
|
|
3
|
+
export type BaseButtonType = React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
|
|
4
|
+
export type BaseDivType = React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
5
|
+
export type BaseFormType = React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;
|
|
6
|
+
export type BaseHeadingType = React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
|
7
|
+
export type BaseInputType = React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
8
|
+
export type BaseHrType = React.DetailedHTMLProps<React.HTMLAttributes<HTMLHRElement>, HTMLHRElement>;
|
|
9
|
+
export type BaseLabelType = React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>;
|
|
10
|
+
export type BaseLItemType = React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;
|
|
11
|
+
export type BaseParagraphType = React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>;
|
|
12
|
+
export type BaseSelectType = React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>;
|
|
13
|
+
export type BaseSmallType = React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
14
|
+
export type BaseSpanType = React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
|
|
15
|
+
export type BaseUListType = React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseButtonType } from "../BaseTypes";
|
|
3
|
+
export type ButtonType = {
|
|
4
|
+
children: typeof React.Children;
|
|
5
|
+
variant?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
} & BaseButtonType;
|
|
8
|
+
declare const Button: React.ForwardRefExoticComponent<Omit<ButtonType, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
export default Button;
|
package/dist/Button/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as f } from "react";
|
|
3
|
-
const s = f(({
|
|
3
|
+
const s = f(({ children: o, variant: r = "primary", className: t, ...n }, u) => /* @__PURE__ */ e("button", { ref: u, type: "button", className: `sg-button sg-button-${r}${t == null ? "" : " " + t}`, ...n, children: o }));
|
|
4
4
|
export {
|
|
5
5
|
s as default
|
|
6
6
|
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseDivType, BaseHeadingType, BaseSpanType, BaseParagraphType } from "../BaseTypes";
|
|
3
|
+
export type CardType = {
|
|
4
|
+
children: typeof React.Children;
|
|
5
|
+
className?: string;
|
|
6
|
+
} & BaseDivType;
|
|
7
|
+
export type CardHeaderPossible = BaseDivType | BaseSpanType | BaseHeadingType;
|
|
8
|
+
export type CardHeaderType = {
|
|
9
|
+
children: typeof React.Children;
|
|
10
|
+
className?: string;
|
|
11
|
+
as?: React.ElementType;
|
|
12
|
+
} & CardHeaderPossible;
|
|
13
|
+
export type CardBodyType = {
|
|
14
|
+
children: typeof React.Children;
|
|
15
|
+
className?: string;
|
|
16
|
+
} & BaseDivType;
|
|
17
|
+
export type CardTextType = {
|
|
18
|
+
children: typeof React.Children;
|
|
19
|
+
className?: string;
|
|
20
|
+
} & BaseParagraphType;
|
|
21
|
+
export type CardFooterType = {
|
|
22
|
+
children: typeof React.Children;
|
|
23
|
+
className?: string;
|
|
24
|
+
} & BaseDivType;
|
|
25
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<CardType, "ref"> & React.RefAttributes<HTMLDivElement>> & {
|
|
26
|
+
Header: React.ForwardRefExoticComponent<(Omit<{
|
|
27
|
+
children: {
|
|
28
|
+
map<T, C>(children: C | readonly C[], fn: (child: C, index: number) => T): C extends null | undefined ? C : Exclude<T, boolean | null | undefined>[];
|
|
29
|
+
forEach<C_1>(children: C_1 | readonly C_1[], fn: (child: C_1, index: number) => void): void;
|
|
30
|
+
count(children: any): number;
|
|
31
|
+
only<C_2>(children: C_2): C_2 extends any[] ? never : C_2;
|
|
32
|
+
toArray(children: React.ReactNode | React.ReactNode[]): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal)[];
|
|
33
|
+
};
|
|
34
|
+
className?: string | undefined;
|
|
35
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
36
|
+
} & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement>, "ref"> | Omit<{
|
|
37
|
+
children: {
|
|
38
|
+
map<T, C>(children: C | readonly C[], fn: (child: C, index: number) => T): C extends null | undefined ? C : Exclude<T, boolean | null | undefined>[];
|
|
39
|
+
forEach<C_1>(children: C_1 | readonly C_1[], fn: (child: C_1, index: number) => void): void;
|
|
40
|
+
count(children: any): number;
|
|
41
|
+
only<C_2>(children: C_2): C_2 extends any[] ? never : C_2;
|
|
42
|
+
toArray(children: React.ReactNode | React.ReactNode[]): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal)[];
|
|
43
|
+
};
|
|
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: {
|
|
48
|
+
map<T, C>(children: C | readonly C[], fn: (child: C, index: number) => T): C extends null | undefined ? C : Exclude<T, boolean | null | undefined>[];
|
|
49
|
+
forEach<C_1>(children: C_1 | readonly C_1[], fn: (child: C_1, index: number) => void): void;
|
|
50
|
+
count(children: any): number;
|
|
51
|
+
only<C_2>(children: C_2): C_2 extends any[] ? never : C_2;
|
|
52
|
+
toArray(children: React.ReactNode | React.ReactNode[]): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal)[];
|
|
53
|
+
};
|
|
54
|
+
className?: string | undefined;
|
|
55
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
56
|
+
} & React.ClassAttributes<HTMLSpanElement> & React.HTMLAttributes<HTMLSpanElement>, "ref">) & React.RefAttributes<HTMLDivElement | HTMLHeadingElement | HTMLSpanElement>>;
|
|
57
|
+
Body: React.ForwardRefExoticComponent<Omit<CardBodyType, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
58
|
+
Title: React.ForwardRefExoticComponent<(Omit<{
|
|
59
|
+
children: {
|
|
60
|
+
map<T, C>(children: C | readonly C[], fn: (child: C, index: number) => T): C extends null | undefined ? C : Exclude<T, boolean | null | undefined>[];
|
|
61
|
+
forEach<C_1>(children: C_1 | readonly C_1[], fn: (child: C_1, index: number) => void): void;
|
|
62
|
+
count(children: any): number;
|
|
63
|
+
only<C_2>(children: C_2): C_2 extends any[] ? never : C_2;
|
|
64
|
+
toArray(children: React.ReactNode | React.ReactNode[]): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal)[];
|
|
65
|
+
};
|
|
66
|
+
className?: string | undefined;
|
|
67
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
68
|
+
} & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement>, "ref"> | Omit<{
|
|
69
|
+
children: {
|
|
70
|
+
map<T, C>(children: C | readonly C[], fn: (child: C, index: number) => T): C extends null | undefined ? C : Exclude<T, boolean | null | undefined>[];
|
|
71
|
+
forEach<C_1>(children: C_1 | readonly C_1[], fn: (child: C_1, index: number) => void): void;
|
|
72
|
+
count(children: any): number;
|
|
73
|
+
only<C_2>(children: C_2): C_2 extends any[] ? never : C_2;
|
|
74
|
+
toArray(children: React.ReactNode | React.ReactNode[]): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal)[];
|
|
75
|
+
};
|
|
76
|
+
className?: string | undefined;
|
|
77
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
78
|
+
} & React.ClassAttributes<HTMLHeadingElement> & React.HTMLAttributes<HTMLHeadingElement>, "ref"> | Omit<{
|
|
79
|
+
children: {
|
|
80
|
+
map<T, C>(children: C | readonly C[], fn: (child: C, index: number) => T): C extends null | undefined ? C : Exclude<T, boolean | null | undefined>[];
|
|
81
|
+
forEach<C_1>(children: C_1 | readonly C_1[], fn: (child: C_1, index: number) => void): void;
|
|
82
|
+
count(children: any): number;
|
|
83
|
+
only<C_2>(children: C_2): C_2 extends any[] ? never : C_2;
|
|
84
|
+
toArray(children: React.ReactNode | React.ReactNode[]): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal)[];
|
|
85
|
+
};
|
|
86
|
+
className?: string | undefined;
|
|
87
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
88
|
+
} & React.ClassAttributes<HTMLSpanElement> & React.HTMLAttributes<HTMLSpanElement>, "ref">) & React.RefAttributes<HTMLHeadingElement>>;
|
|
89
|
+
Text: React.ForwardRefExoticComponent<Omit<CardTextType, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
90
|
+
Footer: React.ForwardRefExoticComponent<Omit<CardFooterType, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
91
|
+
};
|
|
92
|
+
export default _default;
|
package/dist/Card/index.js
CHANGED
|
@@ -1,32 +1,18 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
const
|
|
4
|
-
let n =
|
|
5
|
-
return n
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as d } from "react";
|
|
3
|
+
const h = d(({ children: e, className: t, ...r }, s) => /* @__PURE__ */ a("div", { ref: s, className: "sg-card " + t, ...r, children: e })), l = d(({ as: e = "div", className: t, children: r, ...s }, o) => {
|
|
4
|
+
let n = ["div", "span", "h1", "h2", "h3", "h4", "h5", "h6"].find((c) => c === e) ? e : "div";
|
|
5
|
+
return /* @__PURE__ */ a(n, { ref: o, className: `sg-card-header ${t}`, ...s, children: r });
|
|
6
|
+
}), m = d(({ as: e = "h5", className: t, children: r, ...s }, o) => {
|
|
7
|
+
let n = ["h1", "h2", "h3", "h4", "h5", "h6"].find((c) => c === e) ? e : "h5";
|
|
8
|
+
return /* @__PURE__ */ a(n, { ref: o, className: t, ...s, children: r });
|
|
9
|
+
}), v = d(({ children: e, className: t, ...r }, s) => /* @__PURE__ */ a("div", { ref: s, className: `sg-card-body ${t}`, ...r, children: e })), f = d(({ children: e, className: t, ...r }, s) => /* @__PURE__ */ a("p", { ref: s, className: `sg-card-text ${t}`, ...r, children: e })), p = d(({ children: e, className: t, ...r }, s) => /* @__PURE__ */ a("div", { ref: s, className: `sg-card-footer ${t}`, ...r, children: e })), x = Object.assign(h, {
|
|
10
|
+
Header: l,
|
|
11
|
+
Body: v,
|
|
12
|
+
Title: m,
|
|
13
|
+
Text: f,
|
|
14
|
+
Footer: p
|
|
11
15
|
});
|
|
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
16
|
export {
|
|
31
|
-
|
|
17
|
+
x as default
|
|
32
18
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseButtonType } from "../BaseTypes";
|
|
3
|
+
export type CloseButtonType = {
|
|
4
|
+
className?: string;
|
|
5
|
+
variant?: boolean;
|
|
6
|
+
} & BaseButtonType;
|
|
7
|
+
declare const CloseButton: import("react").ForwardRefExoticComponent<Omit<CloseButtonType, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
8
|
+
export default CloseButton;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseDivType, BaseAnchorType, BaseButtonType, BaseUListType, BaseHrType } from "../BaseTypes";
|
|
3
|
+
export type DropdownContextType = {
|
|
4
|
+
align: string;
|
|
5
|
+
drop: string;
|
|
6
|
+
showInternal: boolean;
|
|
7
|
+
handleToggle: Function;
|
|
8
|
+
placement: string;
|
|
9
|
+
directionClasses?: {
|
|
10
|
+
down?: string;
|
|
11
|
+
'down-centered'?: string;
|
|
12
|
+
up?: string;
|
|
13
|
+
'up-centered'?: string;
|
|
14
|
+
end?: string;
|
|
15
|
+
start?: string;
|
|
16
|
+
};
|
|
17
|
+
controlId: string;
|
|
18
|
+
activeDescendant: {
|
|
19
|
+
case: string;
|
|
20
|
+
};
|
|
21
|
+
setActiveDescendant: React.Dispatch<React.SetStateAction<{
|
|
22
|
+
case: string;
|
|
23
|
+
}>>;
|
|
24
|
+
};
|
|
25
|
+
export declare const DropdownContext: React.Context<DropdownContextType | null>;
|
|
26
|
+
export declare const useDropdownContext: () => DropdownContextType;
|
|
27
|
+
export type DropdownType = {
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
className?: string;
|
|
30
|
+
onSelect?: Function;
|
|
31
|
+
onToggle?: Function;
|
|
32
|
+
controlId: string;
|
|
33
|
+
drop?: string;
|
|
34
|
+
align?: string;
|
|
35
|
+
autoClose?: boolean;
|
|
36
|
+
show?: boolean;
|
|
37
|
+
} & BaseDivType;
|
|
38
|
+
export type DropdownToggleType = {
|
|
39
|
+
children: React.ReactNode;
|
|
40
|
+
className?: string;
|
|
41
|
+
navDropdown?: boolean;
|
|
42
|
+
as?: React.ElementType;
|
|
43
|
+
variant?: string;
|
|
44
|
+
} & (BaseAnchorType | BaseButtonType);
|
|
45
|
+
export declare const Toggle: React.ForwardRefExoticComponent<(Omit<{
|
|
46
|
+
children: React.ReactNode;
|
|
47
|
+
className?: string | undefined;
|
|
48
|
+
navDropdown?: boolean | undefined;
|
|
49
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
50
|
+
variant?: string | undefined;
|
|
51
|
+
} & React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement>, "ref"> | Omit<{
|
|
52
|
+
children: React.ReactNode;
|
|
53
|
+
className?: string | undefined;
|
|
54
|
+
navDropdown?: boolean | undefined;
|
|
55
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
56
|
+
variant?: string | undefined;
|
|
57
|
+
} & React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement>, "ref">) & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
|
58
|
+
export type DropdownMenuType = {
|
|
59
|
+
children: React.ReactNode;
|
|
60
|
+
className?: string;
|
|
61
|
+
style?: React.CSSProperties | undefined;
|
|
62
|
+
} & BaseUListType;
|
|
63
|
+
export declare const Menu: React.ForwardRefExoticComponent<Omit<DropdownMenuType, "ref"> & React.RefAttributes<HTMLUListElement>>;
|
|
64
|
+
export type DropdownItemType = {
|
|
65
|
+
children: React.ReactNode;
|
|
66
|
+
as?: React.ElementType;
|
|
67
|
+
className?: string;
|
|
68
|
+
} & (BaseAnchorType | BaseButtonType);
|
|
69
|
+
export declare const Item: React.ForwardRefExoticComponent<(Omit<{
|
|
70
|
+
children: React.ReactNode;
|
|
71
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
72
|
+
className?: string | undefined;
|
|
73
|
+
} & React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement>, "ref"> | Omit<{
|
|
74
|
+
children: React.ReactNode;
|
|
75
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
76
|
+
className?: string | undefined;
|
|
77
|
+
} & React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement>, "ref">) & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
|
78
|
+
export type DropdownDividerType = {
|
|
79
|
+
className?: string;
|
|
80
|
+
} & BaseHrType;
|
|
81
|
+
export declare const Divider: React.ForwardRefExoticComponent<Omit<DropdownDividerType, "ref"> & React.RefAttributes<HTMLHRElement>>;
|
|
82
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<DropdownType, "ref"> & React.RefAttributes<HTMLDivElement>> & {
|
|
83
|
+
Toggle: React.ForwardRefExoticComponent<(Omit<{
|
|
84
|
+
children: React.ReactNode;
|
|
85
|
+
className?: string | undefined;
|
|
86
|
+
navDropdown?: boolean | undefined;
|
|
87
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
88
|
+
variant?: string | undefined;
|
|
89
|
+
} & React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement>, "ref"> | Omit<{
|
|
90
|
+
children: React.ReactNode;
|
|
91
|
+
className?: string | undefined;
|
|
92
|
+
navDropdown?: boolean | undefined;
|
|
93
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
94
|
+
variant?: string | undefined;
|
|
95
|
+
} & React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement>, "ref">) & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
|
96
|
+
Menu: React.ForwardRefExoticComponent<Omit<DropdownMenuType, "ref"> & React.RefAttributes<HTMLUListElement>>;
|
|
97
|
+
Item: React.ForwardRefExoticComponent<(Omit<{
|
|
98
|
+
children: React.ReactNode;
|
|
99
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
100
|
+
className?: string | undefined;
|
|
101
|
+
} & React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement>, "ref"> | Omit<{
|
|
102
|
+
children: React.ReactNode;
|
|
103
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
104
|
+
className?: string | undefined;
|
|
105
|
+
} & React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement>, "ref">) & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
|
106
|
+
Divider: React.ForwardRefExoticComponent<Omit<DropdownDividerType, "ref"> & React.RefAttributes<HTMLHRElement>>;
|
|
107
|
+
};
|
|
108
|
+
export default _default;
|
package/dist/Dropdown/index.js
CHANGED
|
@@ -1,34 +1,41 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
const L = (
|
|
4
|
-
const
|
|
5
|
-
let n =
|
|
6
|
-
return o === "up" ? n =
|
|
7
|
-
},
|
|
8
|
-
let r =
|
|
9
|
-
for (;
|
|
10
|
-
r.id != o + "-menu" ? r = r.parentElement : (
|
|
11
|
-
return
|
|
12
|
-
}, I =
|
|
13
|
-
|
|
1
|
+
import { jsx as v } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as D, forwardRef as E, useState as y, useMemo as $, useEffect as C, useLayoutEffect as A, useContext as P } from "react";
|
|
3
|
+
const L = (d, o, r = !1) => {
|
|
4
|
+
const u = r ? "top-end" : "top-start", m = r ? "top-start" : "top-end", i = r ? "bottom-end" : "bottom-start", h = r ? "bottom-start" : "bottom-end", g = r ? "right-start" : "left-start", a = r ? "right-end" : "left-end", w = r ? "left-start" : "right-start", l = r ? "left-end" : "right-end";
|
|
5
|
+
let n = d ? h : i;
|
|
6
|
+
return o === "up" ? n = d ? m : u : o === "end" ? n = d ? l : w : o === "start" ? n = d ? a : g : o === "down-centered" ? n = "bottom" : o === "up-centered" && (n = "top"), n;
|
|
7
|
+
}, k = (d, o = "") => {
|
|
8
|
+
let r = d.target, u = !0, m = !1;
|
|
9
|
+
for (; u; )
|
|
10
|
+
r.id != o + "-menu" ? r = r.parentElement : (m = !0, u = !1), r.id === "root" && (u = !1, m = !1);
|
|
11
|
+
return m;
|
|
12
|
+
}, I = D(null), M = ({ children: d, value: o }) => /* @__PURE__ */ v(I.Provider, { value: o, children: d }), x = () => {
|
|
13
|
+
const d = P(I);
|
|
14
|
+
if (!d)
|
|
15
|
+
throw new Error(
|
|
16
|
+
"useDropdownContext has to be used within DropdownContextProvider!"
|
|
17
|
+
);
|
|
18
|
+
return d;
|
|
19
|
+
}, O = E(({
|
|
20
|
+
children: d,
|
|
14
21
|
className: o,
|
|
15
22
|
onSelect: r,
|
|
16
|
-
onToggle:
|
|
17
|
-
|
|
18
|
-
drop:
|
|
19
|
-
align:
|
|
20
|
-
autoClose:
|
|
21
|
-
show:
|
|
22
|
-
...
|
|
23
|
-
},
|
|
24
|
-
const [n, e] =
|
|
25
|
-
B.stopPropagation(), e((
|
|
26
|
-
},
|
|
27
|
-
align:
|
|
28
|
-
drop:
|
|
29
|
-
showInternal:
|
|
30
|
-
handleToggle:
|
|
31
|
-
placement:
|
|
23
|
+
onToggle: u,
|
|
24
|
+
controlId: m,
|
|
25
|
+
drop: i = "down",
|
|
26
|
+
align: h = "start",
|
|
27
|
+
autoClose: g = !0,
|
|
28
|
+
show: a = "default",
|
|
29
|
+
...w
|
|
30
|
+
}, l) => {
|
|
31
|
+
const [n, e] = y(a && !1), [f, b] = y({ case: "" }), c = (B) => {
|
|
32
|
+
B.stopPropagation(), e((S) => !S);
|
|
33
|
+
}, s = L(h === "end", i), p = $(() => ({
|
|
34
|
+
align: h,
|
|
35
|
+
drop: i,
|
|
36
|
+
showInternal: a != "default" && u ? a : n,
|
|
37
|
+
handleToggle: a != "default" && u ? u : c,
|
|
38
|
+
placement: s,
|
|
32
39
|
directionClasses: {
|
|
33
40
|
down: "dropdown",
|
|
34
41
|
"down-centered": "dropdown-center",
|
|
@@ -37,146 +44,161 @@ const L = (s, o, r = !1) => {
|
|
|
37
44
|
end: "dropend",
|
|
38
45
|
start: "dropstart"
|
|
39
46
|
},
|
|
40
|
-
|
|
41
|
-
activeDescendant:
|
|
42
|
-
setActiveDescendant:
|
|
43
|
-
}), [
|
|
44
|
-
return /* @__PURE__ */
|
|
45
|
-
}), q = ({ children:
|
|
46
|
-
const {
|
|
47
|
-
let
|
|
48
|
-
switch (t.key) {
|
|
47
|
+
controlId: m,
|
|
48
|
+
activeDescendant: f,
|
|
49
|
+
setActiveDescendant: b
|
|
50
|
+
}), [h, i, a, n, u, s, m, f, b]);
|
|
51
|
+
return /* @__PURE__ */ v("div", { id: m + "-wrapper", ref: l, className: `sg-dropdown${o ? " " + o : ""}`, ...w, children: /* @__PURE__ */ v(M, { value: p, children: d }) });
|
|
52
|
+
}), q = E(({ children: d, className: o, navDropdown: r = !1, as: u = "button", variant: m = "primary", ...i }, h) => {
|
|
53
|
+
const { controlId: g, handleToggle: a, setActiveDescendant: w, showInternal: l } = x(), n = u, e = (t) => {
|
|
54
|
+
let s = !1;
|
|
55
|
+
switch (console.log(t.key), t.key) {
|
|
49
56
|
case "ArrowDown":
|
|
50
|
-
|
|
57
|
+
s = !0, l ? w((p) => ({ ...p, case: "next" })) : (a(t), w((p) => ({ ...p, case: "first" })));
|
|
51
58
|
break;
|
|
52
59
|
case "ArrowUp":
|
|
53
|
-
|
|
60
|
+
s = !0, l ? w((p) => ({ ...p, case: "previous" })) : (a(t), w((p) => ({ ...p, case: "last" })));
|
|
54
61
|
break;
|
|
55
62
|
case "Home":
|
|
56
|
-
|
|
63
|
+
s = !0, l && w((p) => ({ ...p, case: "first" }));
|
|
57
64
|
break;
|
|
58
65
|
case "End":
|
|
59
|
-
|
|
66
|
+
s = !0, l && w((p) => ({ ...p, case: "last" }));
|
|
67
|
+
break;
|
|
68
|
+
case "Tab":
|
|
69
|
+
l && a(t);
|
|
60
70
|
break;
|
|
61
71
|
case "Escape":
|
|
62
|
-
|
|
72
|
+
s = !0, l && a(t);
|
|
63
73
|
break;
|
|
64
74
|
case "Enter":
|
|
65
75
|
case " ":
|
|
66
|
-
if (
|
|
67
|
-
|
|
76
|
+
if (l) {
|
|
77
|
+
s = !0, document.querySelector(".sg-dropdown-item-visual-focus").click(), a(t);
|
|
68
78
|
break;
|
|
69
79
|
} else {
|
|
70
|
-
|
|
80
|
+
w((p) => ({ ...p, case: "first" }));
|
|
71
81
|
break;
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
|
|
84
|
+
s && (t.stopPropagation(), t.preventDefault());
|
|
85
|
+
}, f = (t) => {
|
|
86
|
+
if (l && t.target.id !== g) {
|
|
87
|
+
if (!k(t, g))
|
|
88
|
+
a(t);
|
|
89
|
+
else if (k(t, g)) {
|
|
90
|
+
a(t);
|
|
91
|
+
const s = document.getElementById(g);
|
|
92
|
+
s == null || s.focus();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
77
95
|
};
|
|
78
|
-
|
|
79
|
-
const t = document.getElementById(
|
|
80
|
-
return t.addEventListener("keydown", e, !0), document.addEventListener("mouseup",
|
|
81
|
-
t.removeEventListener("keydown", e, !0), document.removeEventListener("mouseup",
|
|
96
|
+
C(() => {
|
|
97
|
+
const t = document.getElementById(g);
|
|
98
|
+
return t.addEventListener("keydown", e, !0), document.addEventListener("mouseup", f, !0), function() {
|
|
99
|
+
t.removeEventListener("keydown", e, !0), document.removeEventListener("mouseup", f, !0);
|
|
82
100
|
};
|
|
83
|
-
}, [e,
|
|
84
|
-
const
|
|
85
|
-
|
|
101
|
+
}, [e, g]);
|
|
102
|
+
const b = (t) => {
|
|
103
|
+
a(t), l || w((s) => ({ ...s, case: "first" }));
|
|
86
104
|
};
|
|
87
|
-
let
|
|
88
|
-
return (n === "a" || r) && (
|
|
105
|
+
let c = `sg-button sg-button${m ? "-" + m : "-primary"} sg-dropdown-toggle${o ? " " + o : ""}`;
|
|
106
|
+
return (n === "a" || r) && (c = `sg-nav-dropdown-toggle sg-dropdown-toggle${o ? " " + o : ""}`), /* @__PURE__ */ v(
|
|
89
107
|
n,
|
|
90
108
|
{
|
|
91
109
|
tabIndex: "0",
|
|
92
110
|
type: "button",
|
|
93
111
|
"aria-haspopup": "true",
|
|
94
|
-
"aria-controls":
|
|
95
|
-
"aria-expanded":
|
|
96
|
-
id:
|
|
97
|
-
ref:
|
|
98
|
-
className:
|
|
99
|
-
onClick: (t) =>
|
|
100
|
-
...
|
|
101
|
-
children:
|
|
112
|
+
"aria-controls": g + "-menu",
|
|
113
|
+
"aria-expanded": l,
|
|
114
|
+
id: g,
|
|
115
|
+
ref: h,
|
|
116
|
+
className: c,
|
|
117
|
+
onClick: (t) => b(t),
|
|
118
|
+
...i,
|
|
119
|
+
children: d
|
|
102
120
|
}
|
|
103
121
|
);
|
|
104
|
-
}
|
|
105
|
-
|
|
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);
|
|
122
|
+
}), j = E(({ children: d, className: o, style: r = {}, ...u }, m) => {
|
|
123
|
+
const { controlId: i, showInternal: h, activeDescendant: g } = x(), [a, w] = y(r);
|
|
108
124
|
A(() => {
|
|
109
|
-
if (
|
|
110
|
-
const n = document.getElementById(
|
|
111
|
-
console.log(n);
|
|
125
|
+
if (h) {
|
|
126
|
+
const n = document.getElementById(i + "-menu");
|
|
112
127
|
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 }),
|
|
128
|
+
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 }), w((f) => ({ ...f, ...e }));
|
|
114
129
|
}
|
|
115
|
-
}, [
|
|
116
|
-
if (
|
|
117
|
-
const n = document.getElementById(
|
|
118
|
-
let
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
130
|
+
}, [h]), C(() => {
|
|
131
|
+
if (h) {
|
|
132
|
+
const n = document.getElementById(i + "-menu"), e = document.getElementById(i + "-menu").children, f = e.length - 1, b = document.querySelector(".sg-dropdown-item-visual-focus");
|
|
133
|
+
let c = 0, t = e[0].children[0];
|
|
134
|
+
if (b != null) {
|
|
135
|
+
b.classList.remove("sg-dropdown-item-visual-focus");
|
|
136
|
+
for (let s = 0; s < e.length; s++)
|
|
137
|
+
if (e[s] === b.parentElement) {
|
|
138
|
+
c = s;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
123
141
|
}
|
|
124
|
-
switch (
|
|
142
|
+
switch (g.case) {
|
|
125
143
|
case "first":
|
|
126
|
-
t = e[0].children[0],
|
|
144
|
+
t = e[0].children[0], c = 0;
|
|
127
145
|
break;
|
|
128
146
|
case "last":
|
|
129
|
-
t = e[
|
|
147
|
+
t = e[f].children[0], c = f;
|
|
130
148
|
break;
|
|
131
149
|
case "next":
|
|
132
|
-
|
|
150
|
+
c = c === f ? 0 : c + 1, t = e[c].children[0];
|
|
133
151
|
break;
|
|
134
152
|
case "previous":
|
|
135
|
-
|
|
153
|
+
c = c === 0 ? f : c - 1, t = e[c].children[0];
|
|
136
154
|
break;
|
|
137
155
|
}
|
|
138
|
-
n.setAttribute("aria-activedescendant", t.id), e[
|
|
156
|
+
n.setAttribute("aria-activedescendant", t.id), e[c].children[0].classList.add("sg-dropdown-item-visual-focus");
|
|
139
157
|
} else
|
|
140
|
-
document.getElementById(
|
|
141
|
-
}, [
|
|
142
|
-
const
|
|
158
|
+
document.getElementById(i + "-menu").setAttribute("aria-activedescendant", "");
|
|
159
|
+
}, [i, h, g]);
|
|
160
|
+
const l = (n) => {
|
|
161
|
+
var c;
|
|
143
162
|
const e = n.target;
|
|
144
|
-
|
|
163
|
+
let f = e.classList.contains("sg-dropdown-item-visual-focus");
|
|
164
|
+
const b = document.getElementById(i + "-menu");
|
|
165
|
+
f || ((c = document.querySelector(".sg-dropdown-item-visual-focus")) == null || c.classList.remove("sg-dropdown-item-visual-focus"), b.setAttribute("aria-activedescendant", ""), e.classList.add("sg-dropdown-item-visual-focus"), b.setAttribute("aria-activedescendant", e.id));
|
|
145
166
|
};
|
|
146
|
-
return
|
|
147
|
-
const n = document.getElementById(
|
|
167
|
+
return C(() => {
|
|
168
|
+
const n = document.getElementById(i + "-menu");
|
|
148
169
|
for (let e of n.children)
|
|
149
|
-
e.addEventListener("mouseover",
|
|
170
|
+
e.addEventListener("mouseover", l, !0);
|
|
150
171
|
return function() {
|
|
151
|
-
for (let
|
|
152
|
-
|
|
172
|
+
for (let f of n.children)
|
|
173
|
+
f.removeEventListener("mouseover", l, !0);
|
|
153
174
|
};
|
|
154
|
-
}, []), /* @__PURE__ */
|
|
175
|
+
}, []), /* @__PURE__ */ v(
|
|
155
176
|
"ul",
|
|
156
177
|
{
|
|
157
|
-
id:
|
|
178
|
+
id: i + "-menu",
|
|
158
179
|
role: "menu",
|
|
159
|
-
tabIndex:
|
|
160
|
-
"aria-labelledby":
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
children: s
|
|
180
|
+
tabIndex: -1,
|
|
181
|
+
"aria-labelledby": i,
|
|
182
|
+
ref: m,
|
|
183
|
+
className: `sg-dropdown-list${o ? " " + o : ""}${h ? " show" : ""}`,
|
|
184
|
+
style: a,
|
|
185
|
+
...u,
|
|
186
|
+
children: d
|
|
167
187
|
}
|
|
168
188
|
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
189
|
+
}), H = E(({ children: d, as: o = "button", className: r, ...u }, m) => /* @__PURE__ */ v("li", { role: "none", children: /* @__PURE__ */ v(o, { ref: m, role: "menuitem", tabIndex: "-1", className: `sg-dropdown-item${r ? " " + r : ""}`, ...u, children: d }) })), V = E(({ className: d = "", ...o }, r) => /* @__PURE__ */ v("hr", { ref: r, className: `.sg-dropdown-divider${d}`, ...o })), K = Object.assign(O, {
|
|
190
|
+
Toggle: q,
|
|
191
|
+
Menu: j,
|
|
192
|
+
Item: H,
|
|
193
|
+
//Text: Text,
|
|
194
|
+
Divider: V
|
|
195
|
+
});
|
|
175
196
|
export {
|
|
176
|
-
|
|
197
|
+
V as Divider,
|
|
177
198
|
I as DropdownContext,
|
|
178
|
-
|
|
179
|
-
|
|
199
|
+
H as Item,
|
|
200
|
+
j as Menu,
|
|
180
201
|
q as Toggle,
|
|
181
|
-
|
|
202
|
+
K as default,
|
|
203
|
+
x as useDropdownContext
|
|
182
204
|
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseDivType, BaseFormType, BaseInputType, BaseLabelType, BaseSelectType, BaseSmallType } from "../BaseTypes";
|
|
3
|
+
export type FormContextType = {
|
|
4
|
+
controlId: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const FormContext: React.Context<FormContextType | null>;
|
|
7
|
+
export declare const useFormContext: () => FormContextType;
|
|
8
|
+
export type FormType = {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
} & BaseFormType;
|
|
11
|
+
export type FormControlType = {
|
|
12
|
+
as?: React.ElementType;
|
|
13
|
+
className?: string;
|
|
14
|
+
plaintext?: boolean;
|
|
15
|
+
id?: string;
|
|
16
|
+
type?: string;
|
|
17
|
+
autoFocus?: boolean;
|
|
18
|
+
} & BaseInputType;
|
|
19
|
+
export type FormSelectType = {
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
className?: string;
|
|
22
|
+
id?: string;
|
|
23
|
+
} & BaseSelectType;
|
|
24
|
+
export type FormGroupType = {
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
className?: string;
|
|
27
|
+
controlId: string;
|
|
28
|
+
} & BaseDivType;
|
|
29
|
+
export type FormLabelType = {
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
className?: string;
|
|
32
|
+
htmlFor?: string;
|
|
33
|
+
} & BaseLabelType;
|
|
34
|
+
export type FormCheckType = {
|
|
35
|
+
classNameContainer?: string;
|
|
36
|
+
containerRef?: React.LegacyRef<HTMLDivElement>;
|
|
37
|
+
containerId?: string;
|
|
38
|
+
style?: React.CSSProperties;
|
|
39
|
+
classNameLabel?: string;
|
|
40
|
+
labelRef?: React.LegacyRef<HTMLLabelElement>;
|
|
41
|
+
label?: string;
|
|
42
|
+
labelId?: string;
|
|
43
|
+
className?: string;
|
|
44
|
+
type?: string;
|
|
45
|
+
controlId?: string;
|
|
46
|
+
reverse?: boolean;
|
|
47
|
+
checkStyle?: React.CSSProperties;
|
|
48
|
+
} & BaseInputType;
|
|
49
|
+
export type FormTextType = {
|
|
50
|
+
children: React.ReactNode;
|
|
51
|
+
className?: string;
|
|
52
|
+
} & BaseSmallType;
|
|
53
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<FormType, "ref"> & React.RefAttributes<HTMLFormElement>> & {
|
|
54
|
+
Control: React.ForwardRefExoticComponent<Omit<FormControlType, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
55
|
+
Select: React.ForwardRefExoticComponent<Omit<FormSelectType, "ref"> & React.RefAttributes<HTMLSelectElement>>;
|
|
56
|
+
Group: React.ForwardRefExoticComponent<Omit<FormGroupType, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
57
|
+
Label: React.ForwardRefExoticComponent<Omit<FormLabelType, "ref"> & React.RefAttributes<HTMLLabelElement>>;
|
|
58
|
+
Check: React.ForwardRefExoticComponent<Omit<FormCheckType, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
59
|
+
Text: React.ForwardRefExoticComponent<Omit<FormTextType, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
60
|
+
};
|
|
61
|
+
export default _default;
|
package/dist/Form/index.js
CHANGED
|
@@ -1,58 +1,62 @@
|
|
|
1
|
-
import { jsx as n, jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
return /* @__PURE__ */ n("
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
labelRef: c,
|
|
1
|
+
import { jsx as n, jsxs as $, Fragment as k } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as b, forwardRef as l, useMemo as j, useContext as I } from "react";
|
|
3
|
+
const w = b(null), H = ({ children: e, value: t }) => /* @__PURE__ */ n(w.Provider, { value: t, children: e }), g = () => {
|
|
4
|
+
const e = I(w);
|
|
5
|
+
if (!e)
|
|
6
|
+
throw new Error(
|
|
7
|
+
"useFormContext has to be used within a FormContextProvider!"
|
|
8
|
+
);
|
|
9
|
+
return e;
|
|
10
|
+
}, P = l(({ children: e, ...t }, o) => /* @__PURE__ */ n("form", { ref: o, ...t, children: e })), y = l(({ as: e = "input", className: t = "", plaintext: o = !1, id: c = "", type: r = "text", autoFocus: s = !1, ...m }, u) => {
|
|
11
|
+
let i = e;
|
|
12
|
+
const { controlId: d } = g();
|
|
13
|
+
let x = d || c, f = (o ? "sg-form-control-plaintext" : "sg-form-control") + (t != "" ? " " + t : "") + (r == "color" ? " sg-form-control-color" : "");
|
|
14
|
+
return /* @__PURE__ */ n(i, { autoFocus: s, ref: u, id: x, type: r, className: f, ...m });
|
|
15
|
+
}), E = l(({ children: e, className: t, id: o, ...c }, r) => {
|
|
16
|
+
const { controlId: s } = g();
|
|
17
|
+
let m = s || o;
|
|
18
|
+
return /* @__PURE__ */ n("select", { ref: r, className: `sg-form-select${t ? " " + t : ""}`, id: m, ...c, children: e });
|
|
19
|
+
}), G = l(({ children: e, className: t, controlId: o, ...c }, r) => {
|
|
20
|
+
const s = j(() => ({ controlId: o }), [o]);
|
|
21
|
+
return /* @__PURE__ */ n("div", { ref: r, className: `sg-from-group${t ? " " + t : ""}`, ...c, children: /* @__PURE__ */ n(H, { value: s, children: e }) });
|
|
22
|
+
}), M = l(({ children: e, className: t, htmlFor: o }, c) => {
|
|
23
|
+
const { controlId: r } = g();
|
|
24
|
+
return /* @__PURE__ */ n("label", { ref: c, htmlFor: o || r, className: `sg-form-label${t ? " " + t : ""}`, children: e });
|
|
25
|
+
}), O = l(({
|
|
26
|
+
classNameContainer: e,
|
|
27
|
+
containerRef: t,
|
|
28
|
+
containerId: o,
|
|
29
|
+
style: c,
|
|
30
|
+
classNameLabel: r,
|
|
31
|
+
labelRef: s,
|
|
33
32
|
label: m,
|
|
34
33
|
labelId: u,
|
|
35
34
|
className: i,
|
|
36
|
-
type:
|
|
37
|
-
id:
|
|
38
|
-
controlId:
|
|
35
|
+
type: d,
|
|
36
|
+
id: x,
|
|
37
|
+
controlId: f,
|
|
39
38
|
reverse: p = !1,
|
|
40
|
-
checkStyle:
|
|
41
|
-
...
|
|
42
|
-
},
|
|
43
|
-
let
|
|
44
|
-
return /* @__PURE__ */ n("div", { ref:
|
|
45
|
-
/* @__PURE__ */ n("input", { ref:
|
|
46
|
-
/* @__PURE__ */ n("label", { ref:
|
|
47
|
-
] }) : /* @__PURE__ */
|
|
48
|
-
/* @__PURE__ */ n("label", { ref:
|
|
49
|
-
/* @__PURE__ */ n("input", { ref:
|
|
39
|
+
checkStyle: v,
|
|
40
|
+
...a
|
|
41
|
+
}, C) => {
|
|
42
|
+
let h = f || x, F = d === "switch" ? "checkbox" : d;
|
|
43
|
+
return /* @__PURE__ */ n("div", { ref: t, id: o, style: c, className: `sg-form-check${p ? "-reverse" : ""}${e ? " " + e : ""}${d === "switch" ? " sg-form-switch" : ""}`, children: p ? /* @__PURE__ */ $(k, { children: [
|
|
44
|
+
/* @__PURE__ */ n("input", { ref: C, type: F, id: h, className: `sg-form-check-input${i ? " " + i : ""}`, ...a }),
|
|
45
|
+
/* @__PURE__ */ n("label", { ref: s, id: u, htmlFor: h, className: `sg-form-check-label${r ? " " + r : ""}`, children: m })
|
|
46
|
+
] }) : /* @__PURE__ */ $(k, { children: [
|
|
47
|
+
/* @__PURE__ */ n("label", { ref: s, id: u, htmlFor: h, className: `sg-form-check-label${r ? " " + r : ""}`, children: m }),
|
|
48
|
+
/* @__PURE__ */ n("input", { ref: C, type: F, id: h, className: `sg-form-check-input${i ? " " + i : ""}`, style: v, ...a })
|
|
50
49
|
] }) });
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
}), S = l(({ children: e, className: t, ...o }, c) => /* @__PURE__ */ n("small", { ref: c, className: `sg-form-text${t ? " " + t : ""}`, ...o, children: e })), z = Object.assign(P, {
|
|
51
|
+
Control: y,
|
|
52
|
+
Select: E,
|
|
53
|
+
Group: G,
|
|
54
|
+
Label: M,
|
|
55
|
+
Check: O,
|
|
56
|
+
Text: S
|
|
57
|
+
});
|
|
55
58
|
export {
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
w as FormContext,
|
|
60
|
+
z as default,
|
|
61
|
+
g as useFormContext
|
|
58
62
|
};
|
package/dist/Overlay/index.js
CHANGED
|
@@ -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
|
|
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,
|
|
5
|
-
let f = document.body, o = l.current,
|
|
6
|
-
const p = (
|
|
7
|
-
let
|
|
8
|
-
i || (
|
|
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 -
|
|
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 +
|
|
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 +
|
|
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 -
|
|
18
|
+
return r = { top: n + d / 2 - m / 2, left: h - y - H }, r;
|
|
19
19
|
default:
|
|
20
|
-
return { top: n - m, left: h +
|
|
20
|
+
return { top: n - m, left: h + x / 2 - y / 2 };
|
|
21
21
|
}
|
|
22
|
-
}, G = (l,
|
|
23
|
-
let i =
|
|
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
|
|
26
|
+
return g <= e ? "left" : o <= e ? "right" : "top";
|
|
27
27
|
} else if (l.current === "bottom") {
|
|
28
28
|
if (f <= n)
|
|
29
|
-
return
|
|
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:
|
|
40
|
-
const e =
|
|
41
|
-
|
|
42
|
-
}, [
|
|
43
|
-
B.current = t,
|
|
44
|
-
}, [k, A] = w(!1), [L, O] = w(!1), [J, F] = w(!0),
|
|
45
|
-
s.current && (y(q(t, s, B.current, b.current)),
|
|
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 (
|
|
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),
|
|
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 (
|
|
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
|
-
|
|
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
|
-
}),
|
|
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,
|
|
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:
|
|
89
|
+
return /* @__PURE__ */ M("div", { ref: g, style: { display: "static" }, children: [
|
|
90
90
|
Y(l, {
|
|
91
91
|
ref: e,
|
|
92
|
-
onClick:
|
|
93
|
-
onMouseOver:
|
|
94
|
-
onMouseLeave:
|
|
95
|
-
onFocus:
|
|
96
|
-
onBlur:
|
|
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:
|
|
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${
|
|
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 @@
|
|
|
1
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stargazer-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "React component library made by Stargazer Works",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"files": [
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "\"echo \\\"Error: no test specified\\\" && exit 1\"",
|
|
11
11
|
"dev": "vite --config vite.config.js --port 5000",
|
|
12
|
-
"build": "vite build --config vite.config.js"
|
|
12
|
+
"build": "tsc && vite build --config vite.config.js"
|
|
13
13
|
},
|
|
14
14
|
"type": "module",
|
|
15
15
|
"engines": {
|
|
@@ -39,11 +39,20 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@reduxjs/toolkit": "^2.2.1",
|
|
42
|
+
"@types/node": "^20.8.10",
|
|
43
|
+
"@types/react": "^18.2.35",
|
|
44
|
+
"@types/react-dom": "^18.2.14",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
|
46
|
+
"@typescript-eslint/parser": "^6.9.1",
|
|
42
47
|
"@vitejs/plugin-react": "^4.2.1",
|
|
48
|
+
"eslint": "^8.53.0",
|
|
49
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
50
|
+
"eslint-plugin-react-refresh": "^0.4.4",
|
|
43
51
|
"ally.js": "^1.4.1",
|
|
44
52
|
"glob": "^10.3.10",
|
|
45
53
|
"react": ">=17.0.0",
|
|
46
54
|
"react-dom": ">=17.0.0",
|
|
55
|
+
"typescript": "^5.2.2",
|
|
47
56
|
"vite": "^5.1.4",
|
|
48
57
|
"vite-plugin-dts": "^3.7.3"
|
|
49
58
|
}
|