@deepnoid/ui 0.0.84 → 0.0.86
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/{chunk-NTTHTGDK.mjs → chunk-FNPWLOGV.mjs} +37 -39
- package/dist/chunk-FRIK4CS7.mjs +83 -0
- package/dist/{chunk-ILMIS63S.mjs → chunk-H7BLXC5M.mjs} +14 -14
- package/dist/{chunk-XTJL67KM.mjs → chunk-HH2LF2SU.mjs} +32 -46
- package/dist/{chunk-ADDUBJ4I.mjs → chunk-S4DTK5GI.mjs} +1 -1
- package/dist/chunk-ZOTHPHXA.mjs +41 -0
- package/dist/components/accordion/accordion.d.mts +154 -0
- package/dist/components/accordion/accordion.test.js +37 -39
- package/dist/components/accordion/accordion.test.mjs +1 -1
- package/dist/components/accordion/accordionItem.d.mts +282 -0
- package/dist/components/accordion/index.d.mts +6 -0
- package/dist/components/button/button-group.d.mts +14 -0
- package/dist/components/button/button-group.test.d.mts +2 -0
- package/dist/components/button/button-group.test.js +37 -39
- package/dist/components/button/button-group.test.mjs +2 -2
- package/dist/components/button/button.d.mts +18 -0
- package/dist/components/button/button.test.d.mts +2 -0
- package/dist/components/button/button.test.js +50 -52
- package/dist/components/button/button.test.mjs +2 -2
- package/dist/components/button/index.d.mts +3 -0
- package/dist/components/card/card.d.mts +124 -0
- package/dist/components/card/card.test.d.mts +2 -0
- package/dist/components/card/card.test.js +37 -39
- package/dist/components/card/card.test.mjs +1 -1
- package/dist/components/card/index.d.mts +5 -0
- package/dist/components/card/index.d.ts +5 -0
- package/dist/components/checkbox/checkbox.d.mts +349 -0
- package/dist/components/checkbox/checkbox.test.d.mts +2 -0
- package/dist/components/checkbox/checkbox.test.js +37 -39
- package/dist/components/checkbox/checkbox.test.mjs +2 -2
- package/dist/components/checkbox/index.d.mts +5 -0
- package/dist/components/checkbox/index.d.ts +5 -0
- package/dist/components/icon/Icon.d.mts +513 -0
- package/dist/components/icon/index.d.mts +4 -0
- package/dist/components/icon/index.d.ts +4 -0
- package/dist/components/icon/template.d.mts +134 -0
- package/dist/components/input/index.d.mts +5 -0
- package/dist/components/input/index.d.ts +5 -0
- package/dist/components/input/input.d.mts +437 -0
- package/dist/components/input/input.test.d.mts +2 -0
- package/dist/components/input/input.test.js +50 -52
- package/dist/components/input/input.test.mjs +2 -2
- package/dist/components/list/index.d.mts +6 -0
- package/dist/components/list/index.mjs +3 -3
- package/dist/components/{dropdown/dropdown.d.ts → list/list.d.mts} +9 -9
- package/dist/components/list/list.test.d.mts +2 -0
- package/dist/components/list/list.test.js +37 -39
- package/dist/components/list/list.test.mjs +1 -1
- package/dist/components/list/listItem.d.mts +183 -0
- package/dist/components/modal/index.d.mts +8 -0
- package/dist/components/modal/index.d.ts +8 -0
- package/dist/components/modal/modal.d.mts +214 -0
- package/dist/components/modal/modal.test.d.mts +2 -0
- package/dist/components/modal/modal.test.js +37 -39
- package/dist/components/modal/modal.test.mjs +1 -1
- package/dist/components/pagination/index.d.mts +4 -0
- package/dist/components/pagination/index.d.ts +4 -0
- package/dist/components/pagination/pagination.d.mts +186 -0
- package/dist/components/pagination/pagination.test.d.mts +2 -0
- package/dist/components/pagination/pagination.test.js +37 -39
- package/dist/components/pagination/pagination.test.mjs +1 -1
- package/dist/components/pagination/usePagination.d.mts +16 -0
- package/dist/components/progress/index.d.mts +5 -0
- package/dist/components/progress/index.d.ts +5 -0
- package/dist/components/progress/progress.d.mts +281 -0
- package/dist/components/progress/progress.test.d.mts +2 -0
- package/dist/components/progress/progress.test.d.ts +2 -0
- package/dist/components/progress/progress.test.js +37 -39
- package/dist/components/progress/progress.test.mjs +1 -1
- package/dist/components/radio/index.d.mts +5 -0
- package/dist/components/radio/index.d.ts +5 -0
- package/dist/components/radio/radio.d.mts +278 -0
- package/dist/components/radio/radio.test.d.mts +2 -0
- package/dist/components/radio/radio.test.js +37 -39
- package/dist/components/radio/radio.test.mjs +1 -1
- package/dist/components/select/index.d.mts +5 -0
- package/dist/components/select/index.d.ts +5 -0
- package/dist/components/select/index.mjs +2 -2
- package/dist/components/select/option.d.mts +18 -0
- package/dist/components/select/select.d.mts +449 -0
- package/dist/components/select/select.mjs +2 -2
- package/dist/components/select/select.test.d.mts +2 -0
- package/dist/components/select/select.test.js +37 -39
- package/dist/components/select/select.test.mjs +4 -4
- package/dist/components/select/useSelect.d.mts +32 -0
- package/dist/components/slider/index.d.mts +5 -0
- package/dist/components/slider/index.d.ts +5 -0
- package/dist/components/slider/slider.d.mts +333 -0
- package/dist/components/slider/slider.test.d.mts +2 -0
- package/dist/components/slider/slider.test.d.ts +2 -0
- package/dist/components/slider/slider.test.js +37 -39
- package/dist/components/slider/slider.test.mjs +1 -1
- package/dist/components/switch/index.d.mts +5 -0
- package/dist/components/switch/index.d.ts +5 -0
- package/dist/components/switch/switch.d.mts +304 -0
- package/dist/components/switch/switch.test.d.mts +2 -0
- package/dist/components/switch/switch.test.d.ts +2 -0
- package/dist/components/switch/switch.test.js +37 -39
- package/dist/components/switch/switch.test.mjs +1 -1
- package/dist/components/table/index.d.mts +5 -0
- package/dist/components/table/index.d.ts +5 -0
- package/dist/components/table/index.mjs +2 -2
- package/dist/components/table/table-body.d.mts +26 -0
- package/dist/components/table/table-head.d.mts +21 -0
- package/dist/components/table/table.d.mts +583 -0
- package/dist/components/table/table.mjs +2 -2
- package/dist/components/table/table.test.d.mts +2 -0
- package/dist/components/table/table.test.d.ts +2 -0
- package/dist/components/table/table.test.js +37 -39
- package/dist/components/table/table.test.mjs +3 -3
- package/dist/components/tabs/index.d.mts +5 -0
- package/dist/components/tabs/index.d.ts +5 -0
- package/dist/components/tabs/tabs.d.mts +241 -0
- package/dist/components/tabs/tabs.test.d.mts +2 -0
- package/dist/components/tabs/tabs.test.d.ts +2 -0
- package/dist/components/tabs/tabs.test.js +37 -39
- package/dist/components/tabs/tabs.test.mjs +2 -2
- package/dist/components/textarea/index.d.mts +2 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/textarea.d.mts +17 -0
- package/dist/components/textarea/textarea.test.d.mts +2 -0
- package/dist/components/textarea/textarea.test.d.ts +2 -0
- package/dist/components/textarea/textarea.test.js +50 -52
- package/dist/components/textarea/textarea.test.mjs +2 -2
- package/dist/components/toast/index.d.mts +9 -0
- package/dist/components/toast/index.d.ts +9 -0
- package/dist/components/toast/index.js +147 -127
- package/dist/components/toast/index.mjs +10 -5
- package/dist/components/toast/toast-utils.d.mts +9 -0
- package/dist/components/toast/toast-utils.d.ts +9 -0
- package/dist/components/toast/toast-utils.js +25 -45
- package/dist/components/toast/toast-utils.mjs +1 -1
- package/dist/components/toast/toast.d.mts +207 -0
- package/dist/components/toast/toast.d.ts +13 -10
- package/dist/components/toast/toast.js +32 -125
- package/dist/components/toast/toast.mjs +1 -3
- package/dist/components/toast/toast.test.d.mts +2 -0
- package/dist/components/toast/toast.test.d.ts +2 -0
- package/dist/components/toast/toast.test.js +73 -168
- package/dist/components/toast/toast.test.mjs +4 -6
- package/dist/components/toast/use-toast.d.mts +31 -0
- package/dist/components/toast/use-toast.d.ts +31 -0
- package/dist/components/toast/use-toast.js +3826 -0
- package/dist/components/toast/use-toast.mjs +17 -0
- package/dist/components/tooltip/index.d.mts +6 -0
- package/dist/components/tooltip/index.d.ts +6 -0
- package/dist/components/tooltip/tooltip-utils.d.mts +2 -0
- package/dist/components/tooltip/tooltip-utils.d.ts +2 -0
- package/dist/components/tooltip/tooltip.d.mts +143 -0
- package/dist/components/tooltip/tooltip.test.d.mts +2 -0
- package/dist/components/tooltip/tooltip.test.d.ts +2 -0
- package/dist/components/tooltip/tooltip.test.js +37 -39
- package/dist/components/tooltip/tooltip.test.mjs +1 -1
- package/dist/components/tooltip/useTooltip.d.mts +2 -0
- package/dist/components/tooltip/useTooltip.d.ts +2 -0
- package/dist/index.d.mts +33 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +249 -180
- package/dist/index.mjs +136 -36
- package/dist/tooltip-utils-DCKA5gnI.d.mts +30 -0
- package/dist/tooltip-utils-DCKA5gnI.d.ts +30 -0
- package/dist/utils/clsx.d.mts +3 -0
- package/dist/utils/props.d.mts +3 -0
- package/dist/utils/tailwind-variants.d.mts +26 -0
- package/dist/utils/types.d.mts +10 -0
- package/package.json +2 -2
- package/dist/chunk-5T5F5WVS.mjs +0 -32
- package/dist/chunk-LXPWTJ3F.mjs +0 -58
- package/dist/chunk-SDNTEP5C.mjs +0 -61
- package/dist/chunk-W7ABNK3K.mjs +0 -1
- package/dist/components/dropdown/dropdown.js +0 -122
- package/dist/components/dropdown/dropdown.mjs +0 -10
- package/dist/components/dropdown/dropdown.test.js +0 -12997
- package/dist/components/dropdown/dropdown.test.mjs +0 -25
- package/dist/components/dropdown/index.js +0 -128
- package/dist/components/dropdown/index.mjs +0 -11
- package/dist/components/toast/useToast.d.ts +0 -0
- package/dist/components/toast/useToast.js +0 -110
- package/dist/components/toast/useToast.mjs +0 -9
- package/dist/{chunk-RDEWIZV3.mjs → chunk-LUWGOKLG.mjs} +0 -0
- package/dist/{chunk-RTH3FPAS.mjs → chunk-PSXPOYLX.mjs} +3 -3
- package/dist/{chunk-463XE4SI.mjs → chunk-RVGOARET.mjs} +3 -3
- /package/dist/components/{dropdown/dropdown.test.d.ts → accordion/accordion.test.d.mts} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import "../../chunk-
|
|
2
|
+
import "../../chunk-H7BLXC5M.mjs";
|
|
3
3
|
import {
|
|
4
4
|
textarea_default
|
|
5
5
|
} from "../../chunk-WOX3SLJB.mjs";
|
|
6
6
|
import {
|
|
7
7
|
render,
|
|
8
8
|
waitForWrapper
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-FNPWLOGV.mjs";
|
|
10
10
|
import "../../chunk-IZ6II3QA.mjs";
|
|
11
11
|
|
|
12
12
|
// src/components/textarea/textarea.test.tsx
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as Toast, ToastProps } from './toast.mjs';
|
|
2
|
+
export { ToastProvider, useToast } from './use-toast.mjs';
|
|
3
|
+
import 'tailwind-variants';
|
|
4
|
+
import 'tailwind-variants/dist/config';
|
|
5
|
+
import 'react';
|
|
6
|
+
import './toast-utils.mjs';
|
|
7
|
+
import '../icon/Icon.mjs';
|
|
8
|
+
import 'react/jsx-runtime';
|
|
9
|
+
import '../icon/template.mjs';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as Toast, ToastProps } from './toast.js';
|
|
2
|
+
export { ToastProvider, useToast } from './use-toast.js';
|
|
3
|
+
import 'tailwind-variants';
|
|
4
|
+
import 'tailwind-variants/dist/config';
|
|
5
|
+
import 'react';
|
|
6
|
+
import './toast-utils.js';
|
|
7
|
+
import '../icon/Icon.js';
|
|
8
|
+
import 'react/jsx-runtime';
|
|
9
|
+
import '../icon/template.js';
|
|
@@ -21,13 +21,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/components/toast/index.ts
|
|
22
22
|
var toast_exports = {};
|
|
23
23
|
__export(toast_exports, {
|
|
24
|
-
Toast: () => toast_default
|
|
24
|
+
Toast: () => toast_default,
|
|
25
|
+
ToastProvider: () => ToastProvider,
|
|
26
|
+
useToast: () => useToast
|
|
25
27
|
});
|
|
26
28
|
module.exports = __toCommonJS(toast_exports);
|
|
27
29
|
|
|
28
30
|
// src/components/toast/toast.tsx
|
|
29
|
-
var
|
|
30
|
-
var import_react_dom = require("react-dom");
|
|
31
|
+
var import_react = require("react");
|
|
31
32
|
|
|
32
33
|
// src/utils/tailwind-variants.ts
|
|
33
34
|
var import_tailwind_variants = require("tailwind-variants");
|
|
@@ -68,88 +69,6 @@ var mapPropsVariants = (props, variantKeys, removeVariantProps = true) => {
|
|
|
68
69
|
}
|
|
69
70
|
};
|
|
70
71
|
|
|
71
|
-
// src/components/toast/useToast.ts
|
|
72
|
-
var import_react = require("react");
|
|
73
|
-
|
|
74
|
-
// src/components/toast/toast-utils.ts
|
|
75
|
-
var getToastPosition = (placement, targetRect, width, height, offset) => {
|
|
76
|
-
let x = 0, y = 0;
|
|
77
|
-
switch (placement) {
|
|
78
|
-
case "top":
|
|
79
|
-
x = targetRect.left + targetRect.width / 2 - width / 2;
|
|
80
|
-
y = targetRect.top - height - offset;
|
|
81
|
-
break;
|
|
82
|
-
case "left":
|
|
83
|
-
x = targetRect.left - width - offset;
|
|
84
|
-
y = targetRect.top + targetRect.height / 2 - height / 2;
|
|
85
|
-
break;
|
|
86
|
-
case "right":
|
|
87
|
-
x = targetRect.right + offset;
|
|
88
|
-
y = targetRect.top + targetRect.height / 2 - height / 2;
|
|
89
|
-
break;
|
|
90
|
-
case "bottom":
|
|
91
|
-
x = targetRect.left + targetRect.width / 2 - width / 2;
|
|
92
|
-
y = targetRect.bottom + offset;
|
|
93
|
-
break;
|
|
94
|
-
case "top-start":
|
|
95
|
-
x = targetRect.left;
|
|
96
|
-
y = targetRect.top - height - offset;
|
|
97
|
-
break;
|
|
98
|
-
case "top-end":
|
|
99
|
-
x = targetRect.right - width;
|
|
100
|
-
y = targetRect.top - height - offset;
|
|
101
|
-
break;
|
|
102
|
-
case "bottom-start":
|
|
103
|
-
x = targetRect.left;
|
|
104
|
-
y = targetRect.bottom + offset;
|
|
105
|
-
break;
|
|
106
|
-
case "bottom-end":
|
|
107
|
-
x = targetRect.right - width;
|
|
108
|
-
y = targetRect.bottom + offset;
|
|
109
|
-
break;
|
|
110
|
-
case "left-start":
|
|
111
|
-
x = targetRect.left - width - offset;
|
|
112
|
-
y = targetRect.top;
|
|
113
|
-
break;
|
|
114
|
-
case "left-end":
|
|
115
|
-
x = targetRect.left - width - offset;
|
|
116
|
-
y = targetRect.bottom - height;
|
|
117
|
-
break;
|
|
118
|
-
case "right-start":
|
|
119
|
-
x = targetRect.right + offset;
|
|
120
|
-
y = targetRect.top;
|
|
121
|
-
break;
|
|
122
|
-
case "right-end":
|
|
123
|
-
x = targetRect.right + offset;
|
|
124
|
-
y = targetRect.bottom - height;
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
return { toastX: x, toastY: y };
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
// src/components/toast/useToast.ts
|
|
131
|
-
var useToast = ({ placement, offset, targetRect }) => {
|
|
132
|
-
const [toastPosition, setToastPosition] = (0, import_react.useState)({ x: 0, y: 0 });
|
|
133
|
-
const toastRef = (0, import_react.useRef)(null);
|
|
134
|
-
(0, import_react.useEffect)(() => {
|
|
135
|
-
if (targetRect && toastRef.current) {
|
|
136
|
-
const { width, height } = toastRef.current.getBoundingClientRect();
|
|
137
|
-
const scrollX = window.scrollX;
|
|
138
|
-
const scrollY = window.scrollY;
|
|
139
|
-
const adjustedTargetRect = {
|
|
140
|
-
...targetRect,
|
|
141
|
-
left: targetRect.left + scrollX,
|
|
142
|
-
top: targetRect.top + scrollY,
|
|
143
|
-
right: targetRect.right + scrollX,
|
|
144
|
-
bottom: targetRect.bottom + scrollY
|
|
145
|
-
};
|
|
146
|
-
const { toastX, toastY } = getToastPosition(placement, adjustedTargetRect, width, height, offset);
|
|
147
|
-
setToastPosition({ x: toastX, y: toastY });
|
|
148
|
-
}
|
|
149
|
-
}, [placement, offset, targetRect]);
|
|
150
|
-
return { toastPosition, toastRef };
|
|
151
|
-
};
|
|
152
|
-
|
|
153
72
|
// src/components/icon/template.tsx
|
|
154
73
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
155
74
|
var template = {
|
|
@@ -3699,63 +3618,53 @@ var Icon_default = Icon;
|
|
|
3699
3618
|
|
|
3700
3619
|
// src/components/toast/toast.tsx
|
|
3701
3620
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
3702
|
-
var Toast = (0,
|
|
3703
|
-
const [props, variantProps] = mapPropsVariants(originalProps,
|
|
3704
|
-
const { placement =
|
|
3705
|
-
const slots = (0,
|
|
3706
|
-
const
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
const getBaseProps = (0, import_react2.useCallback)(
|
|
3621
|
+
var Toast = (0, import_react.forwardRef)((originalProps, ref) => {
|
|
3622
|
+
const [props, variantProps] = mapPropsVariants(originalProps, toast.variantKeys);
|
|
3623
|
+
const { placement, classNames, showIcon = true, showCloseButton = true, onClose, ...toastProps } = props;
|
|
3624
|
+
const slots = (0, import_react.useMemo)(() => toast({ ...variantProps }), [variantProps]);
|
|
3625
|
+
const toastRef = (0, import_react.useRef)(null);
|
|
3626
|
+
(0, import_react.useImperativeHandle)(
|
|
3627
|
+
ref,
|
|
3710
3628
|
() => ({
|
|
3711
|
-
|
|
3629
|
+
getWidth: () => {
|
|
3630
|
+
if (toastRef.current) {
|
|
3631
|
+
return toastRef.current.offsetWidth;
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3712
3634
|
}),
|
|
3713
|
-
[
|
|
3635
|
+
[]
|
|
3714
3636
|
);
|
|
3715
|
-
const
|
|
3637
|
+
const getBaseProps = (0, import_react.useCallback)(
|
|
3716
3638
|
() => ({
|
|
3717
|
-
className: slots.
|
|
3639
|
+
className: slots.base({
|
|
3640
|
+
class: [classNames == null ? void 0 : classNames.base, (placement == null ? void 0 : placement.includes("top")) ? "animate-slideInFromTop" : "animate-slideInFromBottom"]
|
|
3641
|
+
})
|
|
3718
3642
|
}),
|
|
3719
|
-
[slots, classNames == null ? void 0 : classNames.
|
|
3643
|
+
[slots, classNames == null ? void 0 : classNames.base]
|
|
3720
3644
|
);
|
|
3721
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
3722
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
props.content,
|
|
3726
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon_default, { name: "close", className: "cursor-pointer" })
|
|
3727
|
-
] }),
|
|
3728
|
-
condition && (0, import_react_dom.createPortal)(
|
|
3729
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
3730
|
-
"div",
|
|
3731
|
-
{
|
|
3732
|
-
ref: toastRef,
|
|
3733
|
-
...getContentProps(),
|
|
3734
|
-
style: {
|
|
3735
|
-
visibility: toastPosition.x !== 0 ? "visible" : "hidden",
|
|
3736
|
-
transform: `translate3d(${toastPosition.x}px, ${toastPosition.y}px, 0)`
|
|
3737
|
-
},
|
|
3738
|
-
children: props.content
|
|
3739
|
-
}
|
|
3740
|
-
),
|
|
3741
|
-
document.body
|
|
3742
|
-
)
|
|
3645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { ref: toastRef, ...getBaseProps(), children: [
|
|
3646
|
+
showIcon && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon_default, { name: originalProps.icon || "info-circle", fill: true, className: "mt-[2px]" }),
|
|
3647
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "flex-1", children: props.content }),
|
|
3648
|
+
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon_default, { name: "close", className: "cursor-pointer mt-[2px]", onClick: onClose })
|
|
3743
3649
|
] });
|
|
3744
3650
|
});
|
|
3745
3651
|
Toast.displayName = "Toast";
|
|
3746
3652
|
var toast_default = Toast;
|
|
3747
|
-
var
|
|
3653
|
+
var toast = tv({
|
|
3748
3654
|
slots: {
|
|
3749
3655
|
base: [
|
|
3750
|
-
"
|
|
3656
|
+
"w-[300px]",
|
|
3751
3657
|
"relative",
|
|
3752
3658
|
"inline-flex",
|
|
3753
|
-
"items-
|
|
3754
|
-
"text-md",
|
|
3755
|
-
"gap-[5px]",
|
|
3659
|
+
"items-start",
|
|
3756
3660
|
"border",
|
|
3661
|
+
"rounded-md",
|
|
3662
|
+
"text-md",
|
|
3757
3663
|
"p-[10px]",
|
|
3758
|
-
"
|
|
3664
|
+
"gap-[5px]",
|
|
3665
|
+
"z-0",
|
|
3666
|
+
"transition-all",
|
|
3667
|
+
"duration-300"
|
|
3759
3668
|
],
|
|
3760
3669
|
content: [
|
|
3761
3670
|
"absolute",
|
|
@@ -3804,7 +3713,118 @@ var tooltip = tv({
|
|
|
3804
3713
|
disableAnimation: false
|
|
3805
3714
|
}
|
|
3806
3715
|
});
|
|
3716
|
+
|
|
3717
|
+
// src/components/toast/use-toast.tsx
|
|
3718
|
+
var import_react2 = require("react");
|
|
3719
|
+
|
|
3720
|
+
// src/components/toast/toast-utils.ts
|
|
3721
|
+
var getToastPosition = (placement, width, offset) => {
|
|
3722
|
+
let top = void 0;
|
|
3723
|
+
let left = void 0;
|
|
3724
|
+
let bottom = void 0;
|
|
3725
|
+
let right = void 0;
|
|
3726
|
+
const viewportWidth = window.innerWidth;
|
|
3727
|
+
switch (placement) {
|
|
3728
|
+
case "top-left":
|
|
3729
|
+
top = offset;
|
|
3730
|
+
left = offset;
|
|
3731
|
+
break;
|
|
3732
|
+
case "top-right":
|
|
3733
|
+
top = offset;
|
|
3734
|
+
right = offset;
|
|
3735
|
+
break;
|
|
3736
|
+
case "top-center":
|
|
3737
|
+
top = offset;
|
|
3738
|
+
left = (viewportWidth - width) / 2;
|
|
3739
|
+
break;
|
|
3740
|
+
case "bottom-left":
|
|
3741
|
+
bottom = offset;
|
|
3742
|
+
left = offset;
|
|
3743
|
+
break;
|
|
3744
|
+
case "bottom-right":
|
|
3745
|
+
bottom = offset;
|
|
3746
|
+
right = offset;
|
|
3747
|
+
break;
|
|
3748
|
+
case "bottom-center":
|
|
3749
|
+
bottom = offset;
|
|
3750
|
+
left = (viewportWidth - width) / 2;
|
|
3751
|
+
break;
|
|
3752
|
+
}
|
|
3753
|
+
return { top, left, bottom, right };
|
|
3754
|
+
};
|
|
3755
|
+
|
|
3756
|
+
// src/components/toast/use-toast.tsx
|
|
3757
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
3758
|
+
var ToastContext = (0, import_react2.createContext)(null);
|
|
3759
|
+
var useToast = () => {
|
|
3760
|
+
const context = (0, import_react2.useContext)(ToastContext);
|
|
3761
|
+
if (!context) {
|
|
3762
|
+
throw new Error("useToast must be used within a ToastProvider");
|
|
3763
|
+
}
|
|
3764
|
+
return context;
|
|
3765
|
+
};
|
|
3766
|
+
var ToastProvider = ({
|
|
3767
|
+
globalOptions,
|
|
3768
|
+
children
|
|
3769
|
+
}) => {
|
|
3770
|
+
const [toasts, setToasts] = (0, import_react2.useState)([]);
|
|
3771
|
+
const [containerStyle, setContainerStyle] = (0, import_react2.useState)({});
|
|
3772
|
+
const toastRef = (0, import_react2.useRef)();
|
|
3773
|
+
const addToast = (0, import_react2.useCallback)((content, options) => {
|
|
3774
|
+
const id = Date.now();
|
|
3775
|
+
const newToast = {
|
|
3776
|
+
id,
|
|
3777
|
+
content,
|
|
3778
|
+
...options
|
|
3779
|
+
};
|
|
3780
|
+
setToasts((prevToasts) => [...prevToasts, newToast]);
|
|
3781
|
+
setTimeout(() => {
|
|
3782
|
+
setToasts((prevToasts) => prevToasts.filter((toast2) => toast2.id !== id));
|
|
3783
|
+
}, options.duration || 3e3);
|
|
3784
|
+
}, []);
|
|
3785
|
+
const removeToast = (0, import_react2.useCallback)((id) => {
|
|
3786
|
+
setToasts((prevToasts) => prevToasts.filter((toast2) => toast2.id !== id));
|
|
3787
|
+
}, []);
|
|
3788
|
+
const value = {
|
|
3789
|
+
default: (content, options) => addToast(content, { type: "default", icon: "info-circle", color: "default", ...globalOptions, ...options }),
|
|
3790
|
+
info: (content, options) => addToast(content, { type: "info", icon: "info-circle", color: "info", ...globalOptions, ...options }),
|
|
3791
|
+
success: (content, options) => addToast(content, { type: "success", icon: "check-circle", color: "success", ...globalOptions, ...options }),
|
|
3792
|
+
warning: (content, options) => addToast(content, {
|
|
3793
|
+
type: "warning",
|
|
3794
|
+
icon: "exclamation-triangle",
|
|
3795
|
+
color: "warning",
|
|
3796
|
+
...globalOptions,
|
|
3797
|
+
...options
|
|
3798
|
+
}),
|
|
3799
|
+
error: (content, options) => addToast(content, { type: "error", icon: "exclamation-circle", color: "danger", ...globalOptions, ...options })
|
|
3800
|
+
};
|
|
3801
|
+
(0, import_react2.useEffect)(() => {
|
|
3802
|
+
var _a;
|
|
3803
|
+
const width = typeof ((_a = toastRef.current) == null ? void 0 : _a.getWidth) === "function" ? toastRef.current.getWidth() : (globalOptions == null ? void 0 : globalOptions.width) || 300;
|
|
3804
|
+
const offset = 20;
|
|
3805
|
+
const calculatePosition = () => {
|
|
3806
|
+
const placement = (globalOptions == null ? void 0 : globalOptions.placement) || "bottom-right";
|
|
3807
|
+
const { top, left, bottom, right } = getToastPosition(placement, width, offset);
|
|
3808
|
+
setContainerStyle({
|
|
3809
|
+
position: "fixed",
|
|
3810
|
+
top: top !== void 0 ? `${top}px` : void 0,
|
|
3811
|
+
left: left !== void 0 ? `${left}px` : void 0,
|
|
3812
|
+
bottom: bottom !== void 0 ? `${bottom}px` : void 0,
|
|
3813
|
+
right: right !== void 0 ? `${right}px` : void 0
|
|
3814
|
+
});
|
|
3815
|
+
};
|
|
3816
|
+
calculatePosition();
|
|
3817
|
+
window.addEventListener("resize", calculatePosition);
|
|
3818
|
+
return () => window.removeEventListener("resize", calculatePosition);
|
|
3819
|
+
}, [globalOptions == null ? void 0 : globalOptions.placement, globalOptions == null ? void 0 : globalOptions.width]);
|
|
3820
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(ToastContext.Provider, { value, children: [
|
|
3821
|
+
children,
|
|
3822
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { id: "deepnoid-toast-container", className: "flex flex-col gap-[10px]", style: containerStyle, children: toasts.map((toast2) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(toast_default, { ref: toastRef, onClose: () => removeToast(toast2.id), ...toast2 }, toast2.id)) })
|
|
3823
|
+
] });
|
|
3824
|
+
};
|
|
3807
3825
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3808
3826
|
0 && (module.exports = {
|
|
3809
|
-
Toast
|
|
3827
|
+
Toast,
|
|
3828
|
+
ToastProvider,
|
|
3829
|
+
useToast
|
|
3810
3830
|
});
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import "../../chunk-
|
|
2
|
+
import "../../chunk-LUWGOKLG.mjs";
|
|
3
|
+
import {
|
|
4
|
+
ToastProvider,
|
|
5
|
+
useToast
|
|
6
|
+
} from "../../chunk-FRIK4CS7.mjs";
|
|
7
|
+
import "../../chunk-ZOTHPHXA.mjs";
|
|
3
8
|
import {
|
|
4
9
|
toast_default
|
|
5
|
-
} from "../../chunk-
|
|
6
|
-
import "../../chunk-5T5F5WVS.mjs";
|
|
7
|
-
import "../../chunk-SDNTEP5C.mjs";
|
|
10
|
+
} from "../../chunk-HH2LF2SU.mjs";
|
|
8
11
|
import "../../chunk-ZYIIXWVY.mjs";
|
|
9
12
|
import "../../chunk-AHORH5PH.mjs";
|
|
10
13
|
import "../../chunk-QURXBWKK.mjs";
|
|
@@ -12,5 +15,7 @@ import "../../chunk-E3G5QXSH.mjs";
|
|
|
12
15
|
import "../../chunk-J725QONZ.mjs";
|
|
13
16
|
import "../../chunk-IZ6II3QA.mjs";
|
|
14
17
|
export {
|
|
15
|
-
toast_default as Toast
|
|
18
|
+
toast_default as Toast,
|
|
19
|
+
ToastProvider,
|
|
20
|
+
useToast
|
|
16
21
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type ToastPlacement = "top-left" | "top-right" | "top-center" | "bottom-left" | "bottom-right" | "bottom-center";
|
|
2
|
+
declare const getToastPosition: (placement: ToastPlacement, width: number, offset: number) => {
|
|
3
|
+
top: number | undefined;
|
|
4
|
+
left: number | undefined;
|
|
5
|
+
bottom: number | undefined;
|
|
6
|
+
right: number | undefined;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { type ToastPlacement, getToastPosition };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type ToastPlacement = "top-left" | "top-right" | "top-center" | "bottom-left" | "bottom-right" | "bottom-center";
|
|
2
|
+
declare const getToastPosition: (placement: ToastPlacement, width: number, offset: number) => {
|
|
3
|
+
top: number | undefined;
|
|
4
|
+
left: number | undefined;
|
|
5
|
+
bottom: number | undefined;
|
|
6
|
+
right: number | undefined;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { type ToastPlacement, getToastPosition };
|
|
@@ -24,59 +24,39 @@ __export(toast_utils_exports, {
|
|
|
24
24
|
getToastPosition: () => getToastPosition
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(toast_utils_exports);
|
|
27
|
-
var getToastPosition = (placement,
|
|
28
|
-
let
|
|
27
|
+
var getToastPosition = (placement, width, offset) => {
|
|
28
|
+
let top = void 0;
|
|
29
|
+
let left = void 0;
|
|
30
|
+
let bottom = void 0;
|
|
31
|
+
let right = void 0;
|
|
32
|
+
const viewportWidth = window.innerWidth;
|
|
29
33
|
switch (placement) {
|
|
30
|
-
case "top":
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
case "top-left":
|
|
35
|
+
top = offset;
|
|
36
|
+
left = offset;
|
|
33
37
|
break;
|
|
34
|
-
case "
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
case "top-right":
|
|
39
|
+
top = offset;
|
|
40
|
+
right = offset;
|
|
37
41
|
break;
|
|
38
|
-
case "
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
case "top-center":
|
|
43
|
+
top = offset;
|
|
44
|
+
left = (viewportWidth - width) / 2;
|
|
41
45
|
break;
|
|
42
|
-
case "bottom":
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
case "bottom-left":
|
|
47
|
+
bottom = offset;
|
|
48
|
+
left = offset;
|
|
45
49
|
break;
|
|
46
|
-
case "
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
case "bottom-right":
|
|
51
|
+
bottom = offset;
|
|
52
|
+
right = offset;
|
|
49
53
|
break;
|
|
50
|
-
case "
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
break;
|
|
54
|
-
case "bottom-start":
|
|
55
|
-
x = targetRect.left;
|
|
56
|
-
y = targetRect.bottom + offset;
|
|
57
|
-
break;
|
|
58
|
-
case "bottom-end":
|
|
59
|
-
x = targetRect.right - width;
|
|
60
|
-
y = targetRect.bottom + offset;
|
|
61
|
-
break;
|
|
62
|
-
case "left-start":
|
|
63
|
-
x = targetRect.left - width - offset;
|
|
64
|
-
y = targetRect.top;
|
|
65
|
-
break;
|
|
66
|
-
case "left-end":
|
|
67
|
-
x = targetRect.left - width - offset;
|
|
68
|
-
y = targetRect.bottom - height;
|
|
69
|
-
break;
|
|
70
|
-
case "right-start":
|
|
71
|
-
x = targetRect.right + offset;
|
|
72
|
-
y = targetRect.top;
|
|
73
|
-
break;
|
|
74
|
-
case "right-end":
|
|
75
|
-
x = targetRect.right + offset;
|
|
76
|
-
y = targetRect.bottom - height;
|
|
54
|
+
case "bottom-center":
|
|
55
|
+
bottom = offset;
|
|
56
|
+
left = (viewportWidth - width) / 2;
|
|
77
57
|
break;
|
|
78
58
|
}
|
|
79
|
-
return {
|
|
59
|
+
return { top, left, bottom, right };
|
|
80
60
|
};
|
|
81
61
|
// Annotate the CommonJS export names for ESM import in node:
|
|
82
62
|
0 && (module.exports = {
|