@bigtablet/design-system 1.2.1 → 1.2.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/index.d.ts +19 -1
- package/dist/index.js +100 -4
- package/dist/next.js +2 -0
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,24 @@ declare const Card: ({ shadow, padding, bordered, className, ...props }: CardPro
|
|
|
11
11
|
|
|
12
12
|
type AlertVariant = "info" | "success" | "warning" | "error";
|
|
13
13
|
type AlertActionsAlign = "left" | "center" | "right";
|
|
14
|
+
interface AlertOptions {
|
|
15
|
+
variant?: AlertVariant;
|
|
16
|
+
title?: React.ReactNode;
|
|
17
|
+
message?: React.ReactNode;
|
|
18
|
+
confirmText?: string;
|
|
19
|
+
cancelText?: string;
|
|
20
|
+
showCancel?: boolean;
|
|
21
|
+
actionsAlign?: AlertActionsAlign;
|
|
22
|
+
onConfirm?: () => void;
|
|
23
|
+
onCancel?: () => void;
|
|
24
|
+
}
|
|
25
|
+
interface AlertContextValue {
|
|
26
|
+
showAlert: (options: AlertOptions) => void;
|
|
27
|
+
}
|
|
28
|
+
declare const useAlert: () => AlertContextValue;
|
|
29
|
+
declare const AlertProvider: React.FC<{
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
}>;
|
|
14
32
|
interface AlertProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
15
33
|
variant?: AlertVariant;
|
|
16
34
|
title?: React.ReactNode;
|
|
@@ -147,4 +165,4 @@ declare const SkeletonCard: () => react_jsx_runtime.JSX.Element;
|
|
|
147
165
|
|
|
148
166
|
declare const SkeletonList: () => react_jsx_runtime.JSX.Element;
|
|
149
167
|
|
|
150
|
-
export { Alert, Button, Card, Checkbox, FileInput, Loading, MarkdownEditor, Modal, Pagination, Radio, Select, SkeletonCard, SkeletonList, Switch, TextField, ToastProvider, useToast };
|
|
168
|
+
export { Alert, AlertProvider, Button, Card, Checkbox, FileInput, Loading, MarkdownEditor, Modal, Pagination, Radio, Select, SkeletonCard, SkeletonList, Switch, TextField, ToastProvider, useAlert, useToast };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import './index.css';
|
|
1
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
4
|
import * as React4 from 'react';
|
|
3
|
-
import { createContext } from 'react';
|
|
4
|
-
import 'react-dom';
|
|
5
|
+
import { createContext, useContext, useState, useCallback } from 'react';
|
|
6
|
+
import { createPortal } from 'react-dom';
|
|
5
7
|
import { ToastContainer, Slide, toast } from 'react-toastify';
|
|
6
8
|
import 'react-toastify/dist/ReactToastify.css';
|
|
7
9
|
import ReactMarkdown from 'react-markdown';
|
|
@@ -25,7 +27,101 @@ var Card = ({
|
|
|
25
27
|
].filter(Boolean).join(" ");
|
|
26
28
|
return /* @__PURE__ */ jsx("div", { className: cls, ...props });
|
|
27
29
|
};
|
|
28
|
-
createContext(null);
|
|
30
|
+
var AlertContext = createContext(null);
|
|
31
|
+
var useAlert = () => {
|
|
32
|
+
const context = useContext(AlertContext);
|
|
33
|
+
if (!context) {
|
|
34
|
+
throw new Error("useAlert must be used within AlertProvider");
|
|
35
|
+
}
|
|
36
|
+
return context;
|
|
37
|
+
};
|
|
38
|
+
var AlertProvider = ({
|
|
39
|
+
children
|
|
40
|
+
}) => {
|
|
41
|
+
const [alertState, setAlertState] = useState({
|
|
42
|
+
isOpen: false
|
|
43
|
+
});
|
|
44
|
+
const showAlert = useCallback((options) => {
|
|
45
|
+
setAlertState({
|
|
46
|
+
...options,
|
|
47
|
+
isOpen: true
|
|
48
|
+
});
|
|
49
|
+
}, []);
|
|
50
|
+
const handleClose = useCallback(() => {
|
|
51
|
+
setAlertState((prev) => ({ ...prev, isOpen: false }));
|
|
52
|
+
}, []);
|
|
53
|
+
const handleConfirm = useCallback(() => {
|
|
54
|
+
alertState.onConfirm?.();
|
|
55
|
+
handleClose();
|
|
56
|
+
}, [alertState.onConfirm, handleClose]);
|
|
57
|
+
const handleCancel = useCallback(() => {
|
|
58
|
+
alertState.onCancel?.();
|
|
59
|
+
handleClose();
|
|
60
|
+
}, [alertState.onCancel, handleClose]);
|
|
61
|
+
return /* @__PURE__ */ jsxs(AlertContext.Provider, { value: { showAlert }, children: [
|
|
62
|
+
children,
|
|
63
|
+
alertState.isOpen && createPortal(
|
|
64
|
+
/* @__PURE__ */ jsx(
|
|
65
|
+
AlertModal,
|
|
66
|
+
{
|
|
67
|
+
...alertState,
|
|
68
|
+
onConfirm: handleConfirm,
|
|
69
|
+
onCancel: handleCancel,
|
|
70
|
+
onClose: handleClose
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
document.body
|
|
74
|
+
)
|
|
75
|
+
] });
|
|
76
|
+
};
|
|
77
|
+
var AlertModal = ({
|
|
78
|
+
variant = "info",
|
|
79
|
+
title,
|
|
80
|
+
message,
|
|
81
|
+
confirmText = "\uD655\uC778",
|
|
82
|
+
cancelText = "\uCDE8\uC18C",
|
|
83
|
+
showCancel = false,
|
|
84
|
+
actionsAlign = "right",
|
|
85
|
+
onConfirm,
|
|
86
|
+
onCancel,
|
|
87
|
+
onClose
|
|
88
|
+
}) => {
|
|
89
|
+
return /* @__PURE__ */ jsx("div", { className: "alert-overlay", onClick: onClose, children: /* @__PURE__ */ jsxs(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
className: `alert-modal alert-modal--${variant}`,
|
|
93
|
+
onClick: (e) => e.stopPropagation(),
|
|
94
|
+
role: "alertdialog",
|
|
95
|
+
"aria-modal": "true",
|
|
96
|
+
"aria-labelledby": "alert-title",
|
|
97
|
+
"aria-describedby": "alert-message",
|
|
98
|
+
children: [
|
|
99
|
+
title && /* @__PURE__ */ jsx("div", { className: "alert-modal__title", id: "alert-title", children: title }),
|
|
100
|
+
message && /* @__PURE__ */ jsx("div", { className: "alert-modal__message", id: "alert-message", children: message }),
|
|
101
|
+
/* @__PURE__ */ jsxs("div", { className: `alert-modal__actions alert-modal__actions--${actionsAlign}`, children: [
|
|
102
|
+
showCancel && /* @__PURE__ */ jsx(
|
|
103
|
+
"button",
|
|
104
|
+
{
|
|
105
|
+
type: "button",
|
|
106
|
+
className: "alert-modal__button alert-modal__button--cancel",
|
|
107
|
+
onClick: onCancel,
|
|
108
|
+
children: cancelText
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
/* @__PURE__ */ jsx(
|
|
112
|
+
"button",
|
|
113
|
+
{
|
|
114
|
+
type: "button",
|
|
115
|
+
className: "alert-modal__button alert-modal__button--confirm",
|
|
116
|
+
onClick: onConfirm,
|
|
117
|
+
children: confirmText
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
] })
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
) });
|
|
124
|
+
};
|
|
29
125
|
var Alert = ({
|
|
30
126
|
variant = "info",
|
|
31
127
|
title,
|
|
@@ -609,4 +705,4 @@ var SkeletonList = () => /* @__PURE__ */ jsxs("div", { className: "request-item
|
|
|
609
705
|
/* @__PURE__ */ jsx("div", { className: "request-item__dday", children: /* @__PURE__ */ jsx("span", { className: "skeleton__dday" }) })
|
|
610
706
|
] });
|
|
611
707
|
|
|
612
|
-
export { Alert, Button, Card, Checkbox, FileInput, Loading, MarkdownEditor, Modal, Pagination, Radio, Select, card_default as SkeletonCard, SkeletonList, Switch, TextField, ToastProvider, useToast };
|
|
708
|
+
export { Alert, AlertProvider, Button, Card, Checkbox, FileInput, Loading, MarkdownEditor, Modal, Pagination, Radio, Select, card_default as SkeletonCard, SkeletonList, Switch, TextField, ToastProvider, useAlert, useToast };
|
package/dist/next.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigtablet/design-system",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Bigtablet Design System UI Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"types": "./dist/next.d.ts",
|
|
15
15
|
"import": "./dist/next.js"
|
|
16
16
|
},
|
|
17
|
-
"./
|
|
17
|
+
"./style.css": "./dist/index.css"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
"LICENSE"
|
|
23
23
|
],
|
|
24
24
|
"sideEffects": [
|
|
25
|
-
"
|
|
25
|
+
"**/*.css",
|
|
26
|
+
"**/*.scss",
|
|
27
|
+
"./dist/next.css"
|
|
26
28
|
],
|
|
27
29
|
"scripts": {
|
|
28
30
|
"build": "tsup",
|