@coinloger/dev-ui 0.0.6 → 0.0.8
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/cjs/components/Badge/Badge.cjs +1 -0
- package/dist/cjs/components/Button/Button.cjs +1 -0
- package/dist/cjs/components/Card/Card.cjs +1 -0
- package/dist/cjs/components/Checkbox/Checkbox.cjs +1 -0
- package/dist/cjs/components/Input/Input.cjs +1 -0
- package/dist/cjs/components/Modal/Modal.cjs +1 -0
- package/dist/cjs/components/Radio/Radio.cjs +1 -0
- package/dist/cjs/components/Select/Select.cjs +1 -0
- package/dist/cjs/components/Switch/Switch.cjs +1 -0
- package/dist/cjs/components/Table/Table.cjs +1 -0
- package/dist/cjs/components/Tabs/Tabs.cjs +1 -0
- package/dist/cjs/components/Typography/Heading.cjs +1 -0
- package/dist/cjs/components/Typography/Text.cjs +1 -0
- package/dist/{style.css → cjs/dev-ui.css} +1 -1
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/theme.cjs +1 -0
- package/dist/esm/components/Badge/Badge.d.ts +25 -0
- package/dist/esm/components/Badge/Badge.js +33 -0
- package/dist/esm/components/Button/Button.d.ts +50 -0
- package/dist/esm/components/Button/Button.js +31 -0
- package/dist/esm/components/Card/Card.d.ts +24 -0
- package/dist/esm/components/Card/Card.js +23 -0
- package/dist/esm/components/Checkbox/Checkbox.d.ts +35 -0
- package/dist/esm/components/Checkbox/Checkbox.js +63 -0
- package/dist/esm/components/Input/Input.d.ts +57 -0
- package/dist/esm/components/Input/Input.js +61 -0
- package/dist/esm/components/Modal/Modal.d.ts +123 -0
- package/dist/esm/components/Modal/Modal.js +123 -0
- package/dist/esm/components/Radio/Radio.d.ts +35 -0
- package/dist/esm/components/Radio/Radio.js +52 -0
- package/dist/esm/components/Select/Select.d.ts +76 -0
- package/dist/esm/components/Select/Select.js +110 -0
- package/dist/esm/components/Switch/Switch.d.ts +35 -0
- package/dist/esm/components/Switch/Switch.js +53 -0
- package/dist/esm/components/Table/Table.d.ts +29 -0
- package/dist/esm/components/Table/Table.js +29 -0
- package/dist/esm/components/Tabs/Tabs.d.ts +80 -0
- package/dist/esm/components/Tabs/Tabs.js +92 -0
- package/dist/esm/components/Typography/Heading.d.ts +25 -0
- package/dist/esm/components/Typography/Heading.js +39 -0
- package/dist/esm/components/Typography/Text.d.ts +38 -0
- package/dist/esm/components/Typography/Text.js +44 -0
- package/dist/esm/default-theme.d.ts +4 -0
- package/dist/esm/dev-ui.css +1 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.js +36 -0
- package/dist/esm/theme.d.ts +15 -0
- package/dist/esm/theme.js +32 -0
- package/dist/esm/types.d.ts +221 -0
- package/package.json +17 -21
- package/style.css +1 -0
- package/dist/index.d.ts +0 -410
- package/dist/index.js +0 -488
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsxs as g, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as c, useId as b } from "react";
|
|
3
|
+
import { clsx as r } from "clsx";
|
|
4
|
+
import * as e from "prop-types";
|
|
5
|
+
/* empty css */
|
|
6
|
+
const u = c(
|
|
7
|
+
({ className: p, label: t, error: i, helperText: o, fullWidth: l, size: a = "md", id: m, ...d }, f) => {
|
|
8
|
+
const s = m || b();
|
|
9
|
+
return /* @__PURE__ */ g("div", { className: r("ui-input-wrapper", l && "ui-input-wrapper-full"), children: [
|
|
10
|
+
t && /* @__PURE__ */ n("label", { htmlFor: s, className: "ui-label", children: t }),
|
|
11
|
+
/* @__PURE__ */ n(
|
|
12
|
+
"input",
|
|
13
|
+
{
|
|
14
|
+
ref: f,
|
|
15
|
+
id: s,
|
|
16
|
+
className: r(
|
|
17
|
+
"ui-input",
|
|
18
|
+
`ui-input-${a}`,
|
|
19
|
+
i && "ui-input-error",
|
|
20
|
+
p
|
|
21
|
+
),
|
|
22
|
+
...d
|
|
23
|
+
}
|
|
24
|
+
),
|
|
25
|
+
o && /* @__PURE__ */ n("span", { className: r("ui-helper-text", i && "ui-helper-text-error"), children: o })
|
|
26
|
+
] });
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
u.displayName = "Input";
|
|
30
|
+
u.propTypes = {
|
|
31
|
+
label: e.node,
|
|
32
|
+
error: e.bool,
|
|
33
|
+
helperText: e.string,
|
|
34
|
+
fullWidth: e.bool,
|
|
35
|
+
size: e.oneOf(["sm", "md", "lg", "xl"]),
|
|
36
|
+
value: e.oneOfType([e.string, e.number]),
|
|
37
|
+
defaultValue: e.oneOfType([e.string, e.number]),
|
|
38
|
+
onChange: e.func,
|
|
39
|
+
onBlur: e.func,
|
|
40
|
+
onFocus: e.func,
|
|
41
|
+
name: e.string,
|
|
42
|
+
id: e.string,
|
|
43
|
+
placeholder: e.string,
|
|
44
|
+
type: e.string,
|
|
45
|
+
disabled: e.bool,
|
|
46
|
+
readOnly: e.bool,
|
|
47
|
+
required: e.bool,
|
|
48
|
+
autoComplete: e.string,
|
|
49
|
+
autoFocus: e.bool,
|
|
50
|
+
min: e.oneOfType([e.string, e.number]),
|
|
51
|
+
max: e.oneOfType([e.string, e.number]),
|
|
52
|
+
step: e.oneOfType([e.string, e.number]),
|
|
53
|
+
minLength: e.number,
|
|
54
|
+
maxLength: e.number,
|
|
55
|
+
pattern: e.string,
|
|
56
|
+
inputMode: e.string,
|
|
57
|
+
className: e.string
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
u as Input
|
|
61
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import * as PropTypes from 'prop-types';
|
|
4
|
+
export declare const ModalHeader: {
|
|
5
|
+
({ children, className }: {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
displayName: string;
|
|
10
|
+
propTypes: {
|
|
11
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
12
|
+
className: PropTypes.Requireable<string>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare const ModalBody: {
|
|
16
|
+
({ children, className }: {
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
displayName: string;
|
|
21
|
+
propTypes: {
|
|
22
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
23
|
+
className: PropTypes.Requireable<string>;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export declare const ModalFooter: {
|
|
27
|
+
({ children, className }: {
|
|
28
|
+
children: ReactNode;
|
|
29
|
+
className?: string;
|
|
30
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
displayName: string;
|
|
32
|
+
propTypes: {
|
|
33
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
34
|
+
className: PropTypes.Requireable<string>;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Modal component properties.
|
|
39
|
+
*/
|
|
40
|
+
export interface ModalProps {
|
|
41
|
+
/**
|
|
42
|
+
* Controls the visibility of the modal.
|
|
43
|
+
*/
|
|
44
|
+
isOpen: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Callback fired when the modal requests to be closed (e.g., backdrop click, ESC key).
|
|
47
|
+
*/
|
|
48
|
+
onClose: () => void;
|
|
49
|
+
/**
|
|
50
|
+
* Content to be displayed in the modal header.
|
|
51
|
+
*/
|
|
52
|
+
title?: ReactNode;
|
|
53
|
+
/**
|
|
54
|
+
* The body content of the modal.
|
|
55
|
+
*/
|
|
56
|
+
children: ReactNode;
|
|
57
|
+
/**
|
|
58
|
+
* Content to be displayed in the modal footer.
|
|
59
|
+
*/
|
|
60
|
+
footer?: ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* The width size of the modal.
|
|
63
|
+
* @default 'md'
|
|
64
|
+
*/
|
|
65
|
+
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
66
|
+
/**
|
|
67
|
+
* Additional CSS classes.
|
|
68
|
+
*/
|
|
69
|
+
className?: string;
|
|
70
|
+
/**
|
|
71
|
+
* If true, clicking on the backdrop closes the modal.
|
|
72
|
+
* @default true
|
|
73
|
+
*/
|
|
74
|
+
closeOnBackdropClick?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export declare const Modal: {
|
|
77
|
+
({ isOpen, onClose, title, children, footer, size, className, closeOnBackdropClick, }: ModalProps): import('react').ReactPortal | null;
|
|
78
|
+
displayName: string;
|
|
79
|
+
propTypes: {
|
|
80
|
+
isOpen: PropTypes.Validator<boolean>;
|
|
81
|
+
onClose: PropTypes.Validator<(...args: any[]) => any>;
|
|
82
|
+
title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
83
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
84
|
+
footer: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
85
|
+
size: PropTypes.Requireable<string>;
|
|
86
|
+
className: PropTypes.Requireable<string>;
|
|
87
|
+
closeOnBackdropClick: PropTypes.Requireable<boolean>;
|
|
88
|
+
};
|
|
89
|
+
} & {
|
|
90
|
+
Header: {
|
|
91
|
+
({ children, className }: {
|
|
92
|
+
children: ReactNode;
|
|
93
|
+
className?: string;
|
|
94
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
95
|
+
displayName: string;
|
|
96
|
+
propTypes: {
|
|
97
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
98
|
+
className: PropTypes.Requireable<string>;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
Body: {
|
|
102
|
+
({ children, className }: {
|
|
103
|
+
children: ReactNode;
|
|
104
|
+
className?: string;
|
|
105
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
106
|
+
displayName: string;
|
|
107
|
+
propTypes: {
|
|
108
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
109
|
+
className: PropTypes.Requireable<string>;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
Footer: {
|
|
113
|
+
({ children, className }: {
|
|
114
|
+
children: ReactNode;
|
|
115
|
+
className?: string;
|
|
116
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
117
|
+
displayName: string;
|
|
118
|
+
propTypes: {
|
|
119
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
120
|
+
className: PropTypes.Requireable<string>;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx as r, jsxs as c, Fragment as C } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as E, useRef as B, useState as R, useEffect as h, useContext as T } from "react";
|
|
3
|
+
import { createPortal as j } from "react-dom";
|
|
4
|
+
import { clsx as l } from "clsx";
|
|
5
|
+
import * as o from "prop-types";
|
|
6
|
+
/* empty css */
|
|
7
|
+
const v = E(void 0), F = () => {
|
|
8
|
+
const e = T(v);
|
|
9
|
+
if (!e)
|
|
10
|
+
throw new Error("Modal compound components must be used within a Modal");
|
|
11
|
+
return e;
|
|
12
|
+
}, a = ({ children: e, className: d }) => {
|
|
13
|
+
const { onClose: n } = F();
|
|
14
|
+
return /* @__PURE__ */ c("div", { className: l("ui-modal-header", d), children: [
|
|
15
|
+
/* @__PURE__ */ r("h3", { className: "ui-modal-title", children: e }),
|
|
16
|
+
/* @__PURE__ */ r(
|
|
17
|
+
"button",
|
|
18
|
+
{
|
|
19
|
+
className: "ui-modal-close",
|
|
20
|
+
onClick: n,
|
|
21
|
+
"aria-label": "Close modal",
|
|
22
|
+
children: /* @__PURE__ */ c("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
23
|
+
/* @__PURE__ */ r("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
24
|
+
/* @__PURE__ */ r("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
25
|
+
] })
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
] });
|
|
29
|
+
}, i = ({ children: e, className: d }) => /* @__PURE__ */ r("div", { className: l("ui-modal-body", d), children: e }), s = ({ children: e, className: d }) => /* @__PURE__ */ r("div", { className: l("ui-modal-footer", d), children: e }), m = ({
|
|
30
|
+
isOpen: e,
|
|
31
|
+
onClose: d,
|
|
32
|
+
title: n,
|
|
33
|
+
children: u,
|
|
34
|
+
footer: y,
|
|
35
|
+
size: x = "md",
|
|
36
|
+
className: N,
|
|
37
|
+
closeOnBackdropClick: g = !0
|
|
38
|
+
}) => {
|
|
39
|
+
const p = B(null), [k, f] = R(e);
|
|
40
|
+
h(() => {
|
|
41
|
+
e && f(!0);
|
|
42
|
+
}, [e]);
|
|
43
|
+
const M = () => {
|
|
44
|
+
e || f(!1);
|
|
45
|
+
};
|
|
46
|
+
if (h(() => {
|
|
47
|
+
const t = (w) => {
|
|
48
|
+
w.key === "Escape" && d();
|
|
49
|
+
};
|
|
50
|
+
return e && (document.addEventListener("keydown", t), document.body.style.overflow = "hidden"), () => {
|
|
51
|
+
document.removeEventListener("keydown", t), document.body.style.overflow = "";
|
|
52
|
+
};
|
|
53
|
+
}, [e, d]), !k) return null;
|
|
54
|
+
const b = (t) => {
|
|
55
|
+
g && t.target === p.current && d();
|
|
56
|
+
};
|
|
57
|
+
return j(
|
|
58
|
+
/* @__PURE__ */ r(v.Provider, { value: { onClose: d }, children: /* @__PURE__ */ r(
|
|
59
|
+
"div",
|
|
60
|
+
{
|
|
61
|
+
className: l("ui-modal-overlay", !e && "ui-modal-closing"),
|
|
62
|
+
ref: p,
|
|
63
|
+
onClick: b,
|
|
64
|
+
onAnimationEnd: M,
|
|
65
|
+
children: /* @__PURE__ */ r(
|
|
66
|
+
"div",
|
|
67
|
+
{
|
|
68
|
+
className: l(
|
|
69
|
+
"ui-modal",
|
|
70
|
+
`ui-modal-${x}`,
|
|
71
|
+
!e && "ui-modal-closing",
|
|
72
|
+
N
|
|
73
|
+
),
|
|
74
|
+
role: "dialog",
|
|
75
|
+
"aria-modal": "true",
|
|
76
|
+
children: n ? /* @__PURE__ */ c(C, { children: [
|
|
77
|
+
/* @__PURE__ */ r(a, { children: n }),
|
|
78
|
+
/* @__PURE__ */ r(i, { children: u }),
|
|
79
|
+
y && /* @__PURE__ */ r(s, { children: y })
|
|
80
|
+
] }) : u
|
|
81
|
+
}
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
) }),
|
|
85
|
+
document.body
|
|
86
|
+
);
|
|
87
|
+
}, V = Object.assign(m, {
|
|
88
|
+
Header: a,
|
|
89
|
+
Body: i,
|
|
90
|
+
Footer: s
|
|
91
|
+
});
|
|
92
|
+
m.displayName = "Modal";
|
|
93
|
+
a.displayName = "ModalHeader";
|
|
94
|
+
i.displayName = "ModalBody";
|
|
95
|
+
s.displayName = "ModalFooter";
|
|
96
|
+
m.propTypes = {
|
|
97
|
+
isOpen: o.bool.isRequired,
|
|
98
|
+
onClose: o.func.isRequired,
|
|
99
|
+
title: o.node,
|
|
100
|
+
children: o.node,
|
|
101
|
+
footer: o.node,
|
|
102
|
+
size: o.oneOf(["sm", "md", "lg", "xl"]),
|
|
103
|
+
className: o.string,
|
|
104
|
+
closeOnBackdropClick: o.bool
|
|
105
|
+
};
|
|
106
|
+
a.propTypes = {
|
|
107
|
+
children: o.node,
|
|
108
|
+
className: o.string
|
|
109
|
+
};
|
|
110
|
+
i.propTypes = {
|
|
111
|
+
children: o.node,
|
|
112
|
+
className: o.string
|
|
113
|
+
};
|
|
114
|
+
s.propTypes = {
|
|
115
|
+
children: o.node,
|
|
116
|
+
className: o.string
|
|
117
|
+
};
|
|
118
|
+
export {
|
|
119
|
+
V as Modal,
|
|
120
|
+
i as ModalBody,
|
|
121
|
+
s as ModalFooter,
|
|
122
|
+
a as ModalHeader
|
|
123
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ReactNode, ForwardRefExoticComponent, RefAttributes, ChangeEventHandler } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Radio component properties.
|
|
5
|
+
*/
|
|
6
|
+
export interface RadioProps {
|
|
7
|
+
/**
|
|
8
|
+
* Label to display next to the radio button.
|
|
9
|
+
*/
|
|
10
|
+
label?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* If true, the radio will be styled with an error state.
|
|
13
|
+
*/
|
|
14
|
+
error?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The size of the radio button.
|
|
17
|
+
* @default 'md'
|
|
18
|
+
*/
|
|
19
|
+
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
20
|
+
/**
|
|
21
|
+
* The visual color variant.
|
|
22
|
+
* @default 'primary'
|
|
23
|
+
*/
|
|
24
|
+
variant?: 'primary' | 'success' | 'warning' | 'danger';
|
|
25
|
+
checked?: boolean;
|
|
26
|
+
defaultChecked?: boolean;
|
|
27
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
28
|
+
name?: string;
|
|
29
|
+
value?: string | number;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
required?: boolean;
|
|
32
|
+
id?: string;
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare const Radio: ForwardRefExoticComponent<RadioProps & RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsxs as p, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { clsx as c } from "clsx";
|
|
4
|
+
import * as r from "prop-types";
|
|
5
|
+
/* empty css */
|
|
6
|
+
const e = t(
|
|
7
|
+
({ className: s, label: a, error: u, disabled: i, size: d = "md", variant: n = "primary", ...l }, m) => /* @__PURE__ */ p(
|
|
8
|
+
"label",
|
|
9
|
+
{
|
|
10
|
+
className: c(
|
|
11
|
+
"ui-radio-label",
|
|
12
|
+
`ui-radio-${d}`,
|
|
13
|
+
`ui-radio-${n}`,
|
|
14
|
+
i && "ui-radio-disabled",
|
|
15
|
+
s
|
|
16
|
+
),
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ o(
|
|
19
|
+
"input",
|
|
20
|
+
{
|
|
21
|
+
type: "radio",
|
|
22
|
+
className: "ui-radio-input",
|
|
23
|
+
disabled: i,
|
|
24
|
+
ref: m,
|
|
25
|
+
...l
|
|
26
|
+
}
|
|
27
|
+
),
|
|
28
|
+
/* @__PURE__ */ o("span", { className: "ui-radio-custom", children: /* @__PURE__ */ o("span", { className: "ui-radio-dot" }) }),
|
|
29
|
+
a && /* @__PURE__ */ o("span", { className: "ui-radio-text", children: a })
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
e.displayName = "Radio";
|
|
35
|
+
e.propTypes = {
|
|
36
|
+
label: r.node,
|
|
37
|
+
error: r.bool,
|
|
38
|
+
size: r.oneOf(["sm", "md", "lg", "xl"]),
|
|
39
|
+
variant: r.oneOf(["primary", "success", "warning", "danger"]),
|
|
40
|
+
checked: r.bool,
|
|
41
|
+
defaultChecked: r.bool,
|
|
42
|
+
onChange: r.func,
|
|
43
|
+
name: r.string,
|
|
44
|
+
value: r.oneOfType([r.string, r.number]),
|
|
45
|
+
disabled: r.bool,
|
|
46
|
+
required: r.bool,
|
|
47
|
+
id: r.string,
|
|
48
|
+
className: r.string
|
|
49
|
+
};
|
|
50
|
+
export {
|
|
51
|
+
e as Radio
|
|
52
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as PropTypes from 'prop-types';
|
|
2
|
+
export interface SelectOption {
|
|
3
|
+
value: string | number;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Select component properties.
|
|
8
|
+
*/
|
|
9
|
+
export interface SelectProps {
|
|
10
|
+
/**
|
|
11
|
+
* Array of options to display.
|
|
12
|
+
*/
|
|
13
|
+
options: SelectOption[];
|
|
14
|
+
/**
|
|
15
|
+
* The value of the selected option.
|
|
16
|
+
*/
|
|
17
|
+
value?: string | number;
|
|
18
|
+
/**
|
|
19
|
+
* Callback fired when an option is selected.
|
|
20
|
+
*/
|
|
21
|
+
onChange?: (value: string | number) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Placeholder text displayed when no option is selected.
|
|
24
|
+
* @default "Select an option"
|
|
25
|
+
*/
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Label text displayed above the select.
|
|
29
|
+
*/
|
|
30
|
+
label?: string;
|
|
31
|
+
/**
|
|
32
|
+
* If true, the select will be styled with an error state.
|
|
33
|
+
*/
|
|
34
|
+
error?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Helper text displayed below the select.
|
|
37
|
+
*/
|
|
38
|
+
helperText?: string;
|
|
39
|
+
/**
|
|
40
|
+
* If true, the select is disabled.
|
|
41
|
+
*/
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* If true, the select will take up the full width of its container.
|
|
45
|
+
*/
|
|
46
|
+
fullWidth?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The size of the select trigger.
|
|
49
|
+
* @default 'md'
|
|
50
|
+
*/
|
|
51
|
+
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
52
|
+
className?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Select/Dropdown component for selecting a value from a list of options.
|
|
56
|
+
*/
|
|
57
|
+
export declare const Select: {
|
|
58
|
+
({ options, value, onChange, placeholder, label, error, helperText, disabled, fullWidth, size, className, }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
displayName: string;
|
|
60
|
+
propTypes: {
|
|
61
|
+
options: PropTypes.Validator<(PropTypes.InferProps<{
|
|
62
|
+
value: PropTypes.Validator<NonNullable<NonNullable<string | number | null | undefined>>>;
|
|
63
|
+
label: PropTypes.Validator<string>;
|
|
64
|
+
}> | null | undefined)[]>;
|
|
65
|
+
value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
66
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
67
|
+
placeholder: PropTypes.Requireable<string>;
|
|
68
|
+
label: PropTypes.Requireable<string>;
|
|
69
|
+
error: PropTypes.Requireable<boolean>;
|
|
70
|
+
helperText: PropTypes.Requireable<string>;
|
|
71
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
72
|
+
fullWidth: PropTypes.Requireable<boolean>;
|
|
73
|
+
size: PropTypes.Requireable<string>;
|
|
74
|
+
className: PropTypes.Requireable<string>;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsxs as d, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useState as w, useRef as T, useEffect as R } from "react";
|
|
3
|
+
import { clsx as r } from "clsx";
|
|
4
|
+
import * as e from "prop-types";
|
|
5
|
+
/* empty css */
|
|
6
|
+
const b = ({
|
|
7
|
+
options: i,
|
|
8
|
+
value: n,
|
|
9
|
+
onChange: m,
|
|
10
|
+
placeholder: y = "Select an option",
|
|
11
|
+
label: p,
|
|
12
|
+
error: f,
|
|
13
|
+
helperText: h,
|
|
14
|
+
disabled: o,
|
|
15
|
+
fullWidth: g,
|
|
16
|
+
size: v = "md",
|
|
17
|
+
className: x
|
|
18
|
+
}) => {
|
|
19
|
+
const [t, a] = w(!1), c = T(null), u = i.find((l) => l.value === n), N = () => {
|
|
20
|
+
o || a(!t);
|
|
21
|
+
}, k = (l) => {
|
|
22
|
+
m && m(l), a(!1);
|
|
23
|
+
};
|
|
24
|
+
return R(() => {
|
|
25
|
+
const l = (O) => {
|
|
26
|
+
c.current && !c.current.contains(O.target) && a(!1);
|
|
27
|
+
};
|
|
28
|
+
return t && document.addEventListener("mousedown", l), () => {
|
|
29
|
+
document.removeEventListener("mousedown", l);
|
|
30
|
+
};
|
|
31
|
+
}, [t]), /* @__PURE__ */ d(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
className: r("ui-select-wrapper", g && "ui-w-full", x),
|
|
35
|
+
ref: c,
|
|
36
|
+
style: { width: g ? "100%" : "auto" },
|
|
37
|
+
children: [
|
|
38
|
+
p && /* @__PURE__ */ s("label", { className: "ui-label", style: { marginBottom: "0.375rem", display: "block" }, children: p }),
|
|
39
|
+
/* @__PURE__ */ d(
|
|
40
|
+
"button",
|
|
41
|
+
{
|
|
42
|
+
type: "button",
|
|
43
|
+
className: r(
|
|
44
|
+
"ui-select-trigger",
|
|
45
|
+
`ui-select-${v}`,
|
|
46
|
+
f && "ui-select-error",
|
|
47
|
+
o && "ui-select-disabled",
|
|
48
|
+
t && "ui-select-open"
|
|
49
|
+
),
|
|
50
|
+
onClick: N,
|
|
51
|
+
disabled: o,
|
|
52
|
+
"aria-haspopup": "listbox",
|
|
53
|
+
"aria-expanded": t,
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ s("span", { className: r(!u && "ui-select-placeholder"), children: u ? u.label : y }),
|
|
56
|
+
/* @__PURE__ */ s(
|
|
57
|
+
"svg",
|
|
58
|
+
{
|
|
59
|
+
className: "ui-select-icon",
|
|
60
|
+
fill: "none",
|
|
61
|
+
stroke: "currentColor",
|
|
62
|
+
viewBox: "0 0 24 24",
|
|
63
|
+
children: /* @__PURE__ */ s("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" })
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
t && /* @__PURE__ */ d("ul", { className: "ui-select-menu", role: "listbox", children: [
|
|
70
|
+
i.map((l) => /* @__PURE__ */ s(
|
|
71
|
+
"li",
|
|
72
|
+
{
|
|
73
|
+
className: r(
|
|
74
|
+
"ui-select-option",
|
|
75
|
+
l.value === n && "ui-select-selected"
|
|
76
|
+
),
|
|
77
|
+
onClick: () => k(l.value),
|
|
78
|
+
role: "option",
|
|
79
|
+
"aria-selected": l.value === n,
|
|
80
|
+
children: l.label
|
|
81
|
+
},
|
|
82
|
+
l.value
|
|
83
|
+
)),
|
|
84
|
+
i.length === 0 && /* @__PURE__ */ s("li", { className: "ui-select-option", style: { color: "var(--ui-text-muted)", cursor: "default" }, children: "No options" })
|
|
85
|
+
] }),
|
|
86
|
+
h && /* @__PURE__ */ s("span", { className: r("ui-helper-text", f && "ui-helper-text-error"), style: { marginTop: "0.375rem", display: "block" }, children: h })
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
b.displayName = "Select";
|
|
92
|
+
b.propTypes = {
|
|
93
|
+
options: e.arrayOf(e.shape({
|
|
94
|
+
value: e.oneOfType([e.string, e.number]).isRequired,
|
|
95
|
+
label: e.string.isRequired
|
|
96
|
+
})).isRequired,
|
|
97
|
+
value: e.oneOfType([e.string, e.number]),
|
|
98
|
+
onChange: e.func,
|
|
99
|
+
placeholder: e.string,
|
|
100
|
+
label: e.string,
|
|
101
|
+
error: e.bool,
|
|
102
|
+
helperText: e.string,
|
|
103
|
+
disabled: e.bool,
|
|
104
|
+
fullWidth: e.bool,
|
|
105
|
+
size: e.oneOf(["sm", "md", "lg", "xl"]),
|
|
106
|
+
className: e.string
|
|
107
|
+
};
|
|
108
|
+
export {
|
|
109
|
+
b as Select
|
|
110
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ReactNode, ForwardRefExoticComponent, RefAttributes, ChangeEventHandler } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Switch toggle component properties.
|
|
5
|
+
*/
|
|
6
|
+
export interface SwitchProps {
|
|
7
|
+
/**
|
|
8
|
+
* Label to display next to the switch.
|
|
9
|
+
*/
|
|
10
|
+
label?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* If true, the switch will be styled with an error state.
|
|
13
|
+
*/
|
|
14
|
+
error?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The size of the switch.
|
|
17
|
+
* @default 'md'
|
|
18
|
+
*/
|
|
19
|
+
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
20
|
+
/**
|
|
21
|
+
* The visual color variant.
|
|
22
|
+
* @default 'primary'
|
|
23
|
+
*/
|
|
24
|
+
variant?: 'primary' | 'success' | 'warning' | 'danger';
|
|
25
|
+
checked?: boolean;
|
|
26
|
+
defaultChecked?: boolean;
|
|
27
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
28
|
+
name?: string;
|
|
29
|
+
value?: string | number;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
required?: boolean;
|
|
32
|
+
id?: string;
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare const Switch: ForwardRefExoticComponent<SwitchProps & RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsxs as m, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as p } from "react";
|
|
3
|
+
import { clsx as h } from "clsx";
|
|
4
|
+
import * as e from "prop-types";
|
|
5
|
+
/* empty css */
|
|
6
|
+
const a = p(
|
|
7
|
+
({ className: o, label: i, error: u, disabled: r, size: t = "md", variant: c = "primary", ...n }, l) => /* @__PURE__ */ m(
|
|
8
|
+
"label",
|
|
9
|
+
{
|
|
10
|
+
className: h(
|
|
11
|
+
"ui-switch-label",
|
|
12
|
+
`ui-switch-${t}`,
|
|
13
|
+
`ui-switch-${c}`,
|
|
14
|
+
r && "ui-switch-disabled",
|
|
15
|
+
o
|
|
16
|
+
),
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ s(
|
|
19
|
+
"input",
|
|
20
|
+
{
|
|
21
|
+
type: "checkbox",
|
|
22
|
+
className: "ui-switch-input",
|
|
23
|
+
disabled: r,
|
|
24
|
+
ref: l,
|
|
25
|
+
role: "switch",
|
|
26
|
+
...n
|
|
27
|
+
}
|
|
28
|
+
),
|
|
29
|
+
/* @__PURE__ */ s("span", { className: "ui-switch-track", children: /* @__PURE__ */ s("span", { className: "ui-switch-thumb" }) }),
|
|
30
|
+
i && /* @__PURE__ */ s("span", { className: "ui-switch-text", children: i })
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
a.displayName = "Switch";
|
|
36
|
+
a.propTypes = {
|
|
37
|
+
label: e.node,
|
|
38
|
+
error: e.bool,
|
|
39
|
+
size: e.oneOf(["sm", "md", "lg", "xl"]),
|
|
40
|
+
variant: e.oneOf(["primary", "success", "warning", "danger"]),
|
|
41
|
+
checked: e.bool,
|
|
42
|
+
defaultChecked: e.bool,
|
|
43
|
+
onChange: e.func,
|
|
44
|
+
name: e.string,
|
|
45
|
+
value: e.oneOfType([e.string, e.number]),
|
|
46
|
+
disabled: e.bool,
|
|
47
|
+
required: e.bool,
|
|
48
|
+
id: e.string,
|
|
49
|
+
className: e.string
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
a as Switch
|
|
53
|
+
};
|