@coinloger/dev-ui 0.1.1 → 0.1.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/cjs/components/Badge/Badge.cjs +1 -1
- package/dist/cjs/components/Button/Button.cjs +1 -1
- package/dist/cjs/components/Card/Card.cjs +1 -1
- package/dist/cjs/components/Checkbox/Checkbox.cjs +1 -1
- package/dist/cjs/components/Container/Container.cjs +1 -1
- package/dist/cjs/components/Flex/Flex.cjs +1 -1
- package/dist/cjs/components/Flex/FlexItem.cjs +1 -1
- package/dist/cjs/components/Input/Input.cjs +1 -1
- package/dist/cjs/components/Modal/Modal.cjs +1 -1
- package/dist/cjs/components/Radio/Radio.cjs +1 -1
- package/dist/cjs/components/Select/Select.cjs +1 -1
- package/dist/cjs/components/Switch/Switch.cjs +1 -1
- package/dist/cjs/components/Table/Table.cjs +1 -1
- package/dist/cjs/components/Tabs/Tabs.cjs +1 -1
- package/dist/cjs/components/Typography/Heading.cjs +1 -1
- package/dist/cjs/components/Typography/Text.cjs +1 -1
- package/dist/cjs/theme.cjs +1 -1
- package/dist/esm/components/Badge/Badge.js +14 -22
- package/dist/esm/components/Button/Button.js +12 -24
- package/dist/esm/components/Card/Card.js +10 -18
- package/dist/esm/components/Checkbox/Checkbox.js +17 -33
- package/dist/esm/components/Container/Container.js +11 -18
- package/dist/esm/components/Flex/Flex.js +26 -44
- package/dist/esm/components/Flex/FlexItem.js +24 -38
- package/dist/esm/components/Input/Input.js +16 -46
- package/dist/esm/components/Modal/Modal.d.ts +0 -35
- package/dist/esm/components/Modal/Modal.js +60 -83
- package/dist/esm/components/Radio/Radio.js +16 -32
- package/dist/esm/components/Select/Select.d.ts +1 -17
- package/dist/esm/components/Select/Select.js +62 -79
- package/dist/esm/components/Switch/Switch.js +18 -34
- package/dist/esm/components/Table/Table.js +13 -22
- package/dist/esm/components/Tabs/Tabs.d.ts +0 -25
- package/dist/esm/components/Tabs/Tabs.js +45 -70
- package/dist/esm/components/Typography/Heading.js +15 -25
- package/dist/esm/components/Typography/Text.js +19 -32
- package/dist/esm/theme.d.ts +0 -5
- package/dist/esm/theme.js +11 -16
- package/package.json +15 -5
|
@@ -1,61 +1,31 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsxs as c, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as d, useId as f } from "react";
|
|
3
3
|
import { clsx as r } from "clsx";
|
|
4
|
-
import * as e from "prop-types";
|
|
5
4
|
/* empty css */
|
|
6
|
-
const
|
|
7
|
-
({ className:
|
|
8
|
-
const
|
|
9
|
-
return /* @__PURE__ */
|
|
10
|
-
|
|
11
|
-
/* @__PURE__ */
|
|
5
|
+
const h = d(
|
|
6
|
+
({ className: s, label: p, error: t, helperText: u, fullWidth: n, size: a = "md", id: l, ...m }, o) => {
|
|
7
|
+
const e = l || f();
|
|
8
|
+
return /* @__PURE__ */ c("div", { className: r("ui-input-wrapper", n && "ui-input-wrapper-full"), children: [
|
|
9
|
+
p && /* @__PURE__ */ i("label", { htmlFor: e, className: "ui-label", children: p }),
|
|
10
|
+
/* @__PURE__ */ i(
|
|
12
11
|
"input",
|
|
13
12
|
{
|
|
14
|
-
ref:
|
|
15
|
-
id:
|
|
13
|
+
ref: o,
|
|
14
|
+
id: e,
|
|
16
15
|
className: r(
|
|
17
16
|
"ui-input",
|
|
18
17
|
`ui-input-${a}`,
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
t && "ui-input-error",
|
|
19
|
+
s
|
|
21
20
|
),
|
|
22
|
-
...
|
|
21
|
+
...m
|
|
23
22
|
}
|
|
24
23
|
),
|
|
25
|
-
|
|
24
|
+
u && /* @__PURE__ */ i("span", { className: r("ui-helper-text", t && "ui-helper-text-error"), children: u })
|
|
26
25
|
] });
|
|
27
26
|
}
|
|
28
27
|
);
|
|
29
|
-
|
|
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
|
-
};
|
|
28
|
+
h.displayName = "Input";
|
|
59
29
|
export {
|
|
60
|
-
|
|
30
|
+
h as Input
|
|
61
31
|
};
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
import * as PropTypes from 'prop-types';
|
|
4
3
|
export declare const ModalHeader: {
|
|
5
4
|
({ children, className }: {
|
|
6
5
|
children: ReactNode;
|
|
7
6
|
className?: string;
|
|
8
7
|
}): import("react/jsx-runtime").JSX.Element;
|
|
9
8
|
displayName: string;
|
|
10
|
-
propTypes: {
|
|
11
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
12
|
-
className: PropTypes.Requireable<string>;
|
|
13
|
-
};
|
|
14
9
|
};
|
|
15
10
|
export declare const ModalBody: {
|
|
16
11
|
({ children, className }: {
|
|
@@ -18,10 +13,6 @@ export declare const ModalBody: {
|
|
|
18
13
|
className?: string;
|
|
19
14
|
}): import("react/jsx-runtime").JSX.Element;
|
|
20
15
|
displayName: string;
|
|
21
|
-
propTypes: {
|
|
22
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
23
|
-
className: PropTypes.Requireable<string>;
|
|
24
|
-
};
|
|
25
16
|
};
|
|
26
17
|
export declare const ModalFooter: {
|
|
27
18
|
({ children, className }: {
|
|
@@ -29,10 +20,6 @@ export declare const ModalFooter: {
|
|
|
29
20
|
className?: string;
|
|
30
21
|
}): import("react/jsx-runtime").JSX.Element;
|
|
31
22
|
displayName: string;
|
|
32
|
-
propTypes: {
|
|
33
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
34
|
-
className: PropTypes.Requireable<string>;
|
|
35
|
-
};
|
|
36
23
|
};
|
|
37
24
|
/**
|
|
38
25
|
* Modal component properties.
|
|
@@ -76,16 +63,6 @@ export interface ModalProps {
|
|
|
76
63
|
export declare const Modal: {
|
|
77
64
|
({ isOpen, onClose, title, children, footer, size, className, closeOnBackdropClick, }: ModalProps): import('react').ReactPortal | null;
|
|
78
65
|
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
66
|
} & {
|
|
90
67
|
Header: {
|
|
91
68
|
({ children, className }: {
|
|
@@ -93,10 +70,6 @@ export declare const Modal: {
|
|
|
93
70
|
className?: string;
|
|
94
71
|
}): import("react/jsx-runtime").JSX.Element;
|
|
95
72
|
displayName: string;
|
|
96
|
-
propTypes: {
|
|
97
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
98
|
-
className: PropTypes.Requireable<string>;
|
|
99
|
-
};
|
|
100
73
|
};
|
|
101
74
|
Body: {
|
|
102
75
|
({ children, className }: {
|
|
@@ -104,10 +77,6 @@ export declare const Modal: {
|
|
|
104
77
|
className?: string;
|
|
105
78
|
}): import("react/jsx-runtime").JSX.Element;
|
|
106
79
|
displayName: string;
|
|
107
|
-
propTypes: {
|
|
108
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
109
|
-
className: PropTypes.Requireable<string>;
|
|
110
|
-
};
|
|
111
80
|
};
|
|
112
81
|
Footer: {
|
|
113
82
|
({ children, className }: {
|
|
@@ -115,9 +84,5 @@ export declare const Modal: {
|
|
|
115
84
|
className?: string;
|
|
116
85
|
}): import("react/jsx-runtime").JSX.Element;
|
|
117
86
|
displayName: string;
|
|
118
|
-
propTypes: {
|
|
119
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
120
|
-
className: PropTypes.Requireable<string>;
|
|
121
|
-
};
|
|
122
87
|
};
|
|
123
88
|
};
|
|
@@ -1,123 +1,100 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as E, useRef as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { clsx as
|
|
5
|
-
import * as o from "prop-types";
|
|
1
|
+
import { jsx as e, jsxs as r, Fragment as g } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as E, useRef as C, useState as B, useEffect as f, useContext as j } from "react";
|
|
3
|
+
import { createPortal as F } from "react-dom";
|
|
4
|
+
import { clsx as d } from "clsx";
|
|
6
5
|
/* empty css */
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
if (!
|
|
6
|
+
const h = E(void 0), L = () => {
|
|
7
|
+
const o = j(h);
|
|
8
|
+
if (!o)
|
|
10
9
|
throw new Error("Modal compound components must be used within a Modal");
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
const { onClose:
|
|
14
|
-
return /* @__PURE__ */
|
|
15
|
-
/* @__PURE__ */
|
|
16
|
-
/* @__PURE__ */
|
|
10
|
+
return o;
|
|
11
|
+
}, n = ({ children: o, className: t }) => {
|
|
12
|
+
const { onClose: a } = L();
|
|
13
|
+
return /* @__PURE__ */ r("div", { className: d("ui-modal-header", t), children: [
|
|
14
|
+
/* @__PURE__ */ e("h3", { className: "ui-modal-title", children: o }),
|
|
15
|
+
/* @__PURE__ */ e(
|
|
17
16
|
"button",
|
|
18
17
|
{
|
|
19
18
|
className: "ui-modal-close",
|
|
20
|
-
onClick:
|
|
19
|
+
onClick: a,
|
|
21
20
|
"aria-label": "Close modal",
|
|
22
|
-
children: /* @__PURE__ */
|
|
23
|
-
/* @__PURE__ */
|
|
24
|
-
/* @__PURE__ */
|
|
21
|
+
children: /* @__PURE__ */ r("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
22
|
+
/* @__PURE__ */ e("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
23
|
+
/* @__PURE__ */ e("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
25
24
|
] })
|
|
26
25
|
}
|
|
27
26
|
)
|
|
28
27
|
] });
|
|
29
|
-
}, i = ({ children:
|
|
30
|
-
isOpen:
|
|
31
|
-
onClose:
|
|
32
|
-
title:
|
|
33
|
-
children:
|
|
34
|
-
footer:
|
|
28
|
+
}, i = ({ children: o, className: t }) => /* @__PURE__ */ e("div", { className: d("ui-modal-body", t), children: o }), s = ({ children: o, className: t }) => /* @__PURE__ */ e("div", { className: d("ui-modal-footer", t), children: o }), v = ({
|
|
29
|
+
isOpen: o,
|
|
30
|
+
onClose: t,
|
|
31
|
+
title: a,
|
|
32
|
+
children: c,
|
|
33
|
+
footer: m,
|
|
35
34
|
size: x = "md",
|
|
36
|
-
className:
|
|
37
|
-
closeOnBackdropClick:
|
|
35
|
+
className: M,
|
|
36
|
+
closeOnBackdropClick: k = !0
|
|
38
37
|
}) => {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, [
|
|
43
|
-
const
|
|
44
|
-
|
|
38
|
+
const u = C(null), [N, y] = B(o);
|
|
39
|
+
f(() => {
|
|
40
|
+
o && y(!0);
|
|
41
|
+
}, [o]);
|
|
42
|
+
const b = () => {
|
|
43
|
+
o || y(!1);
|
|
45
44
|
};
|
|
46
|
-
if (
|
|
47
|
-
const
|
|
48
|
-
w.key === "Escape" &&
|
|
45
|
+
if (f(() => {
|
|
46
|
+
const l = (w) => {
|
|
47
|
+
w.key === "Escape" && t();
|
|
49
48
|
};
|
|
50
|
-
return
|
|
51
|
-
document.removeEventListener("keydown",
|
|
49
|
+
return o && (document.addEventListener("keydown", l), document.body.style.overflow = "hidden"), () => {
|
|
50
|
+
document.removeEventListener("keydown", l), document.body.style.overflow = "";
|
|
52
51
|
};
|
|
53
|
-
}, [
|
|
54
|
-
const
|
|
55
|
-
|
|
52
|
+
}, [o, t]), !N) return null;
|
|
53
|
+
const p = (l) => {
|
|
54
|
+
k && l.target === u.current && t();
|
|
56
55
|
};
|
|
57
|
-
return
|
|
58
|
-
/* @__PURE__ */
|
|
56
|
+
return F(
|
|
57
|
+
/* @__PURE__ */ e(h.Provider, { value: { onClose: t }, children: /* @__PURE__ */ e(
|
|
59
58
|
"div",
|
|
60
59
|
{
|
|
61
|
-
className:
|
|
62
|
-
ref:
|
|
63
|
-
onClick:
|
|
64
|
-
onAnimationEnd:
|
|
65
|
-
children: /* @__PURE__ */
|
|
60
|
+
className: d("ui-modal-overlay", !o && "ui-modal-closing"),
|
|
61
|
+
ref: u,
|
|
62
|
+
onClick: p,
|
|
63
|
+
onAnimationEnd: b,
|
|
64
|
+
children: /* @__PURE__ */ e(
|
|
66
65
|
"div",
|
|
67
66
|
{
|
|
68
|
-
className:
|
|
67
|
+
className: d(
|
|
69
68
|
"ui-modal",
|
|
70
69
|
`ui-modal-${x}`,
|
|
71
|
-
!
|
|
72
|
-
|
|
70
|
+
!o && "ui-modal-closing",
|
|
71
|
+
M
|
|
73
72
|
),
|
|
74
73
|
role: "dialog",
|
|
75
74
|
"aria-modal": "true",
|
|
76
|
-
children:
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
/* @__PURE__ */
|
|
79
|
-
|
|
80
|
-
] }) :
|
|
75
|
+
children: a ? /* @__PURE__ */ r(g, { children: [
|
|
76
|
+
/* @__PURE__ */ e(n, { children: a }),
|
|
77
|
+
/* @__PURE__ */ e(i, { children: c }),
|
|
78
|
+
m && /* @__PURE__ */ e(s, { children: m })
|
|
79
|
+
] }) : c
|
|
81
80
|
}
|
|
82
81
|
)
|
|
83
82
|
}
|
|
84
83
|
) }),
|
|
85
84
|
document.body
|
|
86
85
|
);
|
|
87
|
-
},
|
|
88
|
-
Header:
|
|
86
|
+
}, I = Object.assign(v, {
|
|
87
|
+
Header: n,
|
|
89
88
|
Body: i,
|
|
90
89
|
Footer: s
|
|
91
90
|
});
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
v.displayName = "Modal";
|
|
92
|
+
n.displayName = "ModalHeader";
|
|
94
93
|
i.displayName = "ModalBody";
|
|
95
94
|
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
95
|
export {
|
|
119
|
-
|
|
96
|
+
I as Modal,
|
|
120
97
|
i as ModalBody,
|
|
121
98
|
s as ModalFooter,
|
|
122
|
-
|
|
99
|
+
n as ModalHeader
|
|
123
100
|
};
|
|
@@ -1,52 +1,36 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { clsx as
|
|
4
|
-
import * as r from "prop-types";
|
|
1
|
+
import { jsxs as t, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as p } from "react";
|
|
3
|
+
import { clsx as l } from "clsx";
|
|
5
4
|
/* empty css */
|
|
6
|
-
const
|
|
7
|
-
({ className:
|
|
5
|
+
const u = p(
|
|
6
|
+
({ className: o, label: a, error: c, disabled: r, size: s = "md", variant: d = "primary", ...e }, m) => /* @__PURE__ */ t(
|
|
8
7
|
"label",
|
|
9
8
|
{
|
|
10
|
-
className:
|
|
9
|
+
className: l(
|
|
11
10
|
"ui-radio-label",
|
|
11
|
+
`ui-radio-${s}`,
|
|
12
12
|
`ui-radio-${d}`,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
s
|
|
13
|
+
r && "ui-radio-disabled",
|
|
14
|
+
o
|
|
16
15
|
),
|
|
17
16
|
children: [
|
|
18
|
-
/* @__PURE__ */
|
|
17
|
+
/* @__PURE__ */ i(
|
|
19
18
|
"input",
|
|
20
19
|
{
|
|
21
20
|
type: "radio",
|
|
22
21
|
className: "ui-radio-input",
|
|
23
|
-
disabled:
|
|
22
|
+
disabled: r,
|
|
24
23
|
ref: m,
|
|
25
|
-
...
|
|
24
|
+
...e
|
|
26
25
|
}
|
|
27
26
|
),
|
|
28
|
-
/* @__PURE__ */
|
|
29
|
-
a && /* @__PURE__ */
|
|
27
|
+
/* @__PURE__ */ i("span", { className: "ui-radio-custom", children: /* @__PURE__ */ i("span", { className: "ui-radio-dot" }) }),
|
|
28
|
+
a && /* @__PURE__ */ i("span", { className: "ui-radio-text", children: a })
|
|
30
29
|
]
|
|
31
30
|
}
|
|
32
31
|
)
|
|
33
32
|
);
|
|
34
|
-
|
|
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
|
-
};
|
|
33
|
+
u.displayName = "Radio";
|
|
50
34
|
export {
|
|
51
|
-
|
|
35
|
+
u as Radio
|
|
52
36
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
export interface SelectOption {
|
|
3
3
|
value: string | number;
|
|
4
4
|
label: string;
|
|
@@ -57,20 +57,4 @@ export interface SelectProps {
|
|
|
57
57
|
export declare const Select: {
|
|
58
58
|
({ options, value, onChange, placeholder, label, error, helperText, disabled, fullWidth, size, className, }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
59
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
60
|
};
|
|
@@ -1,129 +1,112 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { clsx as
|
|
4
|
-
import * as e from "prop-types";
|
|
1
|
+
import { jsxs as r, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useState as N, useRef as C, useEffect as g } from "react";
|
|
3
|
+
import { clsx as n } from "clsx";
|
|
5
4
|
/* empty css */
|
|
6
|
-
const
|
|
7
|
-
options:
|
|
8
|
-
value:
|
|
9
|
-
onChange:
|
|
10
|
-
placeholder:
|
|
11
|
-
label:
|
|
12
|
-
error:
|
|
13
|
-
helperText:
|
|
14
|
-
disabled:
|
|
15
|
-
fullWidth:
|
|
16
|
-
size:
|
|
17
|
-
className:
|
|
5
|
+
const O = ({
|
|
6
|
+
options: c,
|
|
7
|
+
value: a,
|
|
8
|
+
onChange: p,
|
|
9
|
+
placeholder: x = "Select an option",
|
|
10
|
+
label: f,
|
|
11
|
+
error: h,
|
|
12
|
+
helperText: v,
|
|
13
|
+
disabled: u,
|
|
14
|
+
fullWidth: w,
|
|
15
|
+
size: k = "md",
|
|
16
|
+
className: y
|
|
18
17
|
}) => {
|
|
19
|
-
const [
|
|
20
|
-
if (
|
|
21
|
-
const
|
|
22
|
-
o < 250 &&
|
|
18
|
+
const [t, d] = N(!1), [L, b] = N("bottom"), i = C(null), m = c.find((e) => e.value === a), l = () => {
|
|
19
|
+
if (i.current) {
|
|
20
|
+
const e = i.current.getBoundingClientRect(), o = window.innerHeight - e.bottom, B = e.top;
|
|
21
|
+
o < 250 && B > o ? b("top") : b("bottom");
|
|
23
22
|
}
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
|
|
23
|
+
}, E = () => {
|
|
24
|
+
u || (t || l(), d(!t));
|
|
25
|
+
}, S = (e) => {
|
|
26
|
+
p && p(e), d(!1);
|
|
28
27
|
};
|
|
29
|
-
return
|
|
30
|
-
window.removeEventListener("resize",
|
|
31
|
-
}), [
|
|
32
|
-
const
|
|
33
|
-
|
|
28
|
+
return g(() => (t && (window.addEventListener("resize", l), window.addEventListener("scroll", l, { capture: !0 })), () => {
|
|
29
|
+
window.removeEventListener("resize", l), window.removeEventListener("scroll", l, { capture: !0 });
|
|
30
|
+
}), [t]), g(() => {
|
|
31
|
+
const e = (o) => {
|
|
32
|
+
i.current && !i.current.contains(o.target) && d(!1);
|
|
34
33
|
};
|
|
35
|
-
return
|
|
36
|
-
document.removeEventListener("mousedown",
|
|
34
|
+
return t && document.addEventListener("mousedown", e), () => {
|
|
35
|
+
document.removeEventListener("mousedown", e);
|
|
37
36
|
};
|
|
38
|
-
}, [
|
|
37
|
+
}, [t]), /* @__PURE__ */ r(
|
|
39
38
|
"div",
|
|
40
39
|
{
|
|
41
|
-
className:
|
|
42
|
-
ref:
|
|
43
|
-
style: { width:
|
|
40
|
+
className: n("ui-select-wrapper", w && "ui-w-full", y),
|
|
41
|
+
ref: i,
|
|
42
|
+
style: { width: w ? "100%" : "auto" },
|
|
44
43
|
children: [
|
|
45
|
-
|
|
46
|
-
/* @__PURE__ */
|
|
47
|
-
/* @__PURE__ */
|
|
44
|
+
f && /* @__PURE__ */ s("label", { className: "ui-label", style: { marginBottom: "0.375rem", display: "block" }, children: f }),
|
|
45
|
+
/* @__PURE__ */ r("div", { className: "ui-select-input-container", children: [
|
|
46
|
+
/* @__PURE__ */ r(
|
|
48
47
|
"button",
|
|
49
48
|
{
|
|
50
49
|
type: "button",
|
|
51
|
-
className:
|
|
50
|
+
className: n(
|
|
52
51
|
"ui-select-trigger",
|
|
53
|
-
`ui-select-${
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
`ui-select-${k}`,
|
|
53
|
+
h && "ui-select-error",
|
|
54
|
+
u && "ui-select-disabled",
|
|
55
|
+
t && "ui-select-open"
|
|
57
56
|
),
|
|
58
|
-
onClick:
|
|
59
|
-
disabled:
|
|
57
|
+
onClick: E,
|
|
58
|
+
disabled: u,
|
|
60
59
|
"aria-haspopup": "listbox",
|
|
61
|
-
"aria-expanded":
|
|
60
|
+
"aria-expanded": t,
|
|
62
61
|
children: [
|
|
63
|
-
/* @__PURE__ */
|
|
64
|
-
/* @__PURE__ */
|
|
62
|
+
/* @__PURE__ */ s("span", { className: n(!m && "ui-select-placeholder"), children: m ? m.label : x }),
|
|
63
|
+
/* @__PURE__ */ s(
|
|
65
64
|
"svg",
|
|
66
65
|
{
|
|
67
66
|
className: "ui-select-icon",
|
|
68
67
|
fill: "none",
|
|
69
68
|
stroke: "currentColor",
|
|
70
69
|
viewBox: "0 0 24 24",
|
|
71
|
-
children: /* @__PURE__ */
|
|
70
|
+
children: /* @__PURE__ */ s("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" })
|
|
72
71
|
}
|
|
73
72
|
)
|
|
74
73
|
]
|
|
75
74
|
}
|
|
76
75
|
),
|
|
77
|
-
|
|
76
|
+
t && /* @__PURE__ */ r(
|
|
78
77
|
"ul",
|
|
79
78
|
{
|
|
80
|
-
className:
|
|
79
|
+
className: n(
|
|
81
80
|
"ui-select-menu",
|
|
82
|
-
|
|
81
|
+
L === "top" && "ui-select-menu-top"
|
|
83
82
|
),
|
|
84
83
|
role: "listbox",
|
|
85
84
|
children: [
|
|
86
|
-
|
|
85
|
+
c.map((e) => /* @__PURE__ */ s(
|
|
87
86
|
"li",
|
|
88
87
|
{
|
|
89
|
-
className:
|
|
88
|
+
className: n(
|
|
90
89
|
"ui-select-option",
|
|
91
|
-
|
|
90
|
+
e.value === a && "ui-select-selected"
|
|
92
91
|
),
|
|
93
|
-
onClick: () =>
|
|
92
|
+
onClick: () => S(e.value),
|
|
94
93
|
role: "option",
|
|
95
|
-
"aria-selected":
|
|
96
|
-
children:
|
|
94
|
+
"aria-selected": e.value === a,
|
|
95
|
+
children: e.label
|
|
97
96
|
},
|
|
98
|
-
|
|
97
|
+
e.value
|
|
99
98
|
)),
|
|
100
|
-
|
|
99
|
+
c.length === 0 && /* @__PURE__ */ s("li", { className: "ui-select-option", style: { color: "var(--ui-text-muted)", cursor: "default" }, children: "No options" })
|
|
101
100
|
]
|
|
102
101
|
}
|
|
103
102
|
)
|
|
104
103
|
] }),
|
|
105
|
-
|
|
104
|
+
v && /* @__PURE__ */ s("span", { className: n("ui-helper-text", h && "ui-helper-text-error"), style: { marginTop: "0.375rem", display: "block" }, children: v })
|
|
106
105
|
]
|
|
107
106
|
}
|
|
108
107
|
);
|
|
109
108
|
};
|
|
110
|
-
|
|
111
|
-
x.propTypes = {
|
|
112
|
-
options: e.arrayOf(e.shape({
|
|
113
|
-
value: e.oneOfType([e.string, e.number]).isRequired,
|
|
114
|
-
label: e.string.isRequired
|
|
115
|
-
})).isRequired,
|
|
116
|
-
value: e.oneOfType([e.string, e.number]),
|
|
117
|
-
onChange: e.func,
|
|
118
|
-
placeholder: e.string,
|
|
119
|
-
label: e.string,
|
|
120
|
-
error: e.bool,
|
|
121
|
-
helperText: e.string,
|
|
122
|
-
disabled: e.bool,
|
|
123
|
-
fullWidth: e.bool,
|
|
124
|
-
size: e.oneOf(["sm", "md", "lg", "xl"]),
|
|
125
|
-
className: e.string
|
|
126
|
-
};
|
|
109
|
+
O.displayName = "Select";
|
|
127
110
|
export {
|
|
128
|
-
|
|
111
|
+
O as Select
|
|
129
112
|
};
|