@neuctra/ui 0.2.2 → 0.2.4
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/components/basic/Accordation.d.ts +27 -18
- package/dist/components/basic/Alert.d.ts +14 -2
- package/dist/components/basic/Avatar.d.ts +5 -3
- package/dist/components/basic/Badge.d.ts +3 -3
- package/dist/components/basic/Button.d.ts +15 -17
- package/dist/components/basic/Card.d.ts +7 -49
- package/dist/components/basic/{CheckRadioInput.d.ts → CheckboxGroup.d.ts} +4 -5
- package/dist/components/basic/Container.d.ts +28 -26
- package/dist/components/basic/Drawer.d.ts +20 -11
- package/dist/components/basic/DropDown.d.ts +24 -34
- package/dist/components/basic/Flexbox.d.ts +18 -10
- package/dist/components/basic/GridView.d.ts +7 -5
- package/dist/components/basic/Image.d.ts +31 -6
- package/dist/components/basic/Input.d.ts +18 -10
- package/dist/components/basic/List.d.ts +11 -3
- package/dist/components/basic/Modal.d.ts +8 -2
- package/dist/components/basic/RadioGroup.d.ts +25 -0
- package/dist/components/basic/Section.d.ts +36 -0
- package/dist/components/basic/Stack.d.ts +27 -0
- package/dist/components/basic/SwitchGroup.d.ts +25 -0
- package/dist/components/basic/Table.d.ts +18 -54
- package/dist/components/basic/Tabs.d.ts +28 -28
- package/dist/components/basic/Text.d.ts +19 -32
- package/dist/index.cjs.js +55 -176
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +19 -18
- package/dist/index.es.js +3501 -4738
- package/dist/index.es.js.map +1 -0
- package/dist/src/components/avatar/AvatarGroup.js +9 -0
- package/dist/src/components/avatar/AvatarWithStatus.js +18 -0
- package/dist/src/components/basic/Accordation.js +74 -0
- package/dist/src/components/basic/Alert.js +141 -0
- package/dist/src/components/basic/AudioGallery.js +425 -0
- package/dist/src/components/basic/AudioPlayer.js +116 -0
- package/dist/src/components/basic/Avatar.js +181 -0
- package/dist/src/components/basic/Badge.js +66 -0
- package/dist/src/components/basic/Button.js +101 -0
- package/dist/src/components/basic/Card.js +47 -0
- package/dist/src/components/basic/CheckboxGroup.js +40 -0
- package/dist/src/components/basic/Container.js +45 -0
- package/dist/src/components/basic/Drawer.js +94 -0
- package/dist/src/components/basic/DropDown.js +162 -0
- package/dist/src/components/basic/Flexbox.js +67 -0
- package/dist/src/components/basic/GridView.js +51 -0
- package/dist/src/components/basic/Image.js +95 -0
- package/dist/src/components/basic/Input.js +123 -0
- package/dist/src/components/basic/List.js +71 -0
- package/dist/src/components/basic/Modal.js +86 -0
- package/dist/src/components/basic/RadioGroup.js +37 -0
- package/dist/src/components/basic/Section.js +100 -0
- package/dist/src/components/basic/Stack.js +75 -0
- package/dist/src/components/basic/SwitchGroup.js +50 -0
- package/dist/src/components/basic/Table.js +32 -0
- package/dist/src/components/basic/Tabs.js +149 -0
- package/dist/src/components/basic/Text.js +117 -0
- package/dist/src/index.js +46 -0
- package/dist/types/src/components/basic/Accordation.d.ts +44 -0
- package/dist/types/{components → src/components}/basic/Alert.d.ts +14 -2
- package/dist/types/{components → src/components}/basic/Avatar.d.ts +5 -3
- package/dist/types/{components → src/components}/basic/Badge.d.ts +3 -3
- package/dist/types/src/components/basic/Button.d.ts +26 -0
- package/dist/types/src/components/basic/Card.d.ts +28 -0
- package/dist/types/{components/basic/CheckRadioInput.d.ts → src/components/basic/CheckboxGroup.d.ts} +4 -5
- package/dist/types/src/components/basic/Container.d.ts +32 -0
- package/dist/types/src/components/basic/Drawer.d.ts +33 -0
- package/dist/types/src/components/basic/DropDown.d.ts +53 -0
- package/dist/types/src/components/basic/Flexbox.d.ts +25 -0
- package/dist/types/{components → src/components}/basic/GridView.d.ts +7 -5
- package/dist/types/src/components/basic/Image.d.ts +58 -0
- package/dist/types/{components → src/components}/basic/Input.d.ts +18 -10
- package/dist/types/{components → src/components}/basic/List.d.ts +11 -3
- package/dist/types/{components → src/components}/basic/Modal.d.ts +8 -2
- package/dist/types/src/components/basic/RadioGroup.d.ts +25 -0
- package/dist/types/src/components/basic/Section.d.ts +36 -0
- package/dist/types/src/components/basic/Stack.d.ts +27 -0
- package/dist/types/src/components/basic/SwitchGroup.d.ts +25 -0
- package/dist/types/src/components/basic/Table.d.ts +23 -0
- package/dist/types/src/components/basic/Tabs.d.ts +47 -0
- package/dist/types/src/components/basic/Text.d.ts +26 -0
- package/dist/types/{index.d.ts → src/index.d.ts} +19 -18
- package/dist/types/vite.config.d.ts +2 -0
- package/dist/ui.css +1 -1
- package/dist/vite.config.js +34 -0
- package/package.json +2 -1
- package/dist/components/basic/ImageGallery.d.ts +0 -21
- package/dist/components/basic/VideoGallery.d.ts +0 -136
- package/dist/components/basic/VideoPlayer.d.ts +0 -36
- package/dist/types/components/basic/Accordation.d.ts +0 -35
- package/dist/types/components/basic/Button.d.ts +0 -28
- package/dist/types/components/basic/Card.d.ts +0 -70
- package/dist/types/components/basic/Container.d.ts +0 -30
- package/dist/types/components/basic/Drawer.d.ts +0 -24
- package/dist/types/components/basic/DropDown.d.ts +0 -63
- package/dist/types/components/basic/Flexbox.d.ts +0 -17
- package/dist/types/components/basic/Image.d.ts +0 -33
- package/dist/types/components/basic/ImageGallery.d.ts +0 -21
- package/dist/types/components/basic/Table.d.ts +0 -59
- package/dist/types/components/basic/Tabs.d.ts +0 -47
- package/dist/types/components/basic/Text.d.ts +0 -39
- package/dist/types/components/basic/VideoGallery.d.ts +0 -136
- package/dist/types/components/basic/VideoPlayer.d.ts +0 -36
- /package/dist/types/{components → src/components}/avatar/AvatarGroup.d.ts +0 -0
- /package/dist/types/{components → src/components}/avatar/AvatarWithStatus.d.ts +0 -0
- /package/dist/types/{components → src/components}/basic/AudioGallery.d.ts +0 -0
- /package/dist/types/{components → src/components}/basic/AudioPlayer.d.ts +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const AvatarGroup = ({ avatars, size = "medium", maxVisible = 3, className = "", }) => {
|
|
3
|
+
const avatarSizes = {
|
|
4
|
+
small: "w-8 h-8",
|
|
5
|
+
medium: "w-12 h-12",
|
|
6
|
+
large: "w-16 h-16",
|
|
7
|
+
};
|
|
8
|
+
return (_jsxs("div", { className: "flex -space-x-2", children: [avatars.slice(0, maxVisible).map((src, index) => (_jsx("img", { src: src, className: `rounded-full border-2 border-white object-cover ${avatarSizes[size]} ${className}` }, index))), avatars.length > maxVisible && (_jsxs("span", { className: `rounded-full border-2 border-white bg-gray-500 text-white flex items-center justify-center ${avatarSizes[size]}`, children: ["+", avatars.length - maxVisible] }))] }));
|
|
9
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
export const AvatarWithStatus = ({ src, alt = "User Avatar", status = "online", size = "medium", className = "", }) => {
|
|
4
|
+
const [imageError, setImageError] = useState(false);
|
|
5
|
+
const avatarSizes = {
|
|
6
|
+
small: { size: "w-8 h-8", statusSize: "w-2 h-2" },
|
|
7
|
+
medium: { size: "w-12 h-12", statusSize: "w-3 h-3" },
|
|
8
|
+
large: { size: "w-16 h-16", statusSize: "w-4 h-4" },
|
|
9
|
+
};
|
|
10
|
+
const statusColors = {
|
|
11
|
+
online: "bg-green-500",
|
|
12
|
+
offline: "bg-gray-400",
|
|
13
|
+
away: "bg-yellow-500",
|
|
14
|
+
busy: "bg-red-500",
|
|
15
|
+
};
|
|
16
|
+
return (_jsxs("div", { className: `relative inline-block ${avatarSizes[size].size}`, children: [src && !imageError ? (_jsx("img", { src: src, alt: alt, "aria-label": alt, className: `rounded-full object-cover ${avatarSizes[size].size} ${className}`, onError: () => setImageError(true) })) : (_jsx("svg", { "aria-label": "Placeholder for user avatar" // Added for accessibility
|
|
17
|
+
, className: `rounded-full bg-gray-300 text-gray-500 dark:bg-gray-600 dark:text-gray-400 ${avatarSizes[size].size}`, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: _jsx("path", { fillRule: "evenodd", d: "M12 12a5 5 0 100-10 5 5 0 000 10zm-7 9c0-3 3-5 7-5s7 2 7 5v1H5v-1z", clipRule: "evenodd" }) })), _jsx("span", { className: `z-[1000] w-full h-full absolute bottom-0 right-0 border-2 border-white rounded-full ${statusColors[status]} ${avatarSizes[size].statusSize}` })] }));
|
|
18
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect, memo } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* 🧠 Industry-standard, minimal, and fully customizable Accordion
|
|
5
|
+
*/
|
|
6
|
+
export const Accordion = memo(({ items, allowMultiple = false, defaultOpen = [], borderColor = "#e5e7eb", backgroundColor = "#fff", textColor = "#111827", hoverBgColor = "#f9fafb", hoverTextColor = "#111827", contentBgColor = "#fff", contentTextColor = "#374151", paddingY = "1rem", paddingX = "1rem", marginY = "0.75rem", borderRadius = "0.5rem", contentPadding = "1rem", fontSize = "1rem", fontWeight = 600, contentFontSize = "0.95rem", contentFontWeight = 400, iconOpen = "−", iconClose = "+", iconSize = "1.25rem", transitionDuration = "300ms", shadow = "0 1px 4px rgba(0,0,0,0.08)", className = "", style, }) => {
|
|
7
|
+
const [openIndexes, setOpenIndexes] = useState(defaultOpen);
|
|
8
|
+
const contentRefs = useRef([]);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
contentRefs.current.forEach((el, index) => {
|
|
11
|
+
if (el) {
|
|
12
|
+
el.style.maxHeight = openIndexes.includes(index)
|
|
13
|
+
? `${el.scrollHeight}px`
|
|
14
|
+
: "0px";
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}, [openIndexes]);
|
|
18
|
+
const toggleItem = (index) => {
|
|
19
|
+
setOpenIndexes((prev) => allowMultiple
|
|
20
|
+
? prev.includes(index)
|
|
21
|
+
? prev.filter((i) => i !== index)
|
|
22
|
+
: [...prev, index]
|
|
23
|
+
: prev.includes(index)
|
|
24
|
+
? []
|
|
25
|
+
: [index]);
|
|
26
|
+
};
|
|
27
|
+
return (_jsx("div", { className: className, style: { width: "100%", ...style }, children: items.map((item, index) => {
|
|
28
|
+
const isOpen = openIndexes.includes(index);
|
|
29
|
+
return (_jsxs("div", { style: {
|
|
30
|
+
border: `1px solid ${borderColor}`,
|
|
31
|
+
borderRadius,
|
|
32
|
+
margin: `${marginY} 0`,
|
|
33
|
+
boxShadow: shadow,
|
|
34
|
+
overflow: "hidden",
|
|
35
|
+
transition: `all ${transitionDuration} ease`,
|
|
36
|
+
}, children: [_jsxs("button", { onClick: () => toggleItem(index), style: {
|
|
37
|
+
width: "100%",
|
|
38
|
+
display: "flex",
|
|
39
|
+
justifyContent: "space-between",
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
backgroundColor,
|
|
42
|
+
color: textColor,
|
|
43
|
+
padding: `${paddingY} ${paddingX}`,
|
|
44
|
+
fontWeight,
|
|
45
|
+
fontSize,
|
|
46
|
+
cursor: "pointer",
|
|
47
|
+
border: "none",
|
|
48
|
+
outline: "none",
|
|
49
|
+
transition: `all ${transitionDuration}`,
|
|
50
|
+
}, onMouseEnter: (e) => {
|
|
51
|
+
e.currentTarget.style.backgroundColor = hoverBgColor;
|
|
52
|
+
e.currentTarget.style.color = hoverTextColor;
|
|
53
|
+
}, onMouseLeave: (e) => {
|
|
54
|
+
e.currentTarget.style.backgroundColor = backgroundColor;
|
|
55
|
+
e.currentTarget.style.color = textColor;
|
|
56
|
+
}, children: [_jsx("span", { children: item.title }), _jsx("span", { style: { fontSize: iconSize }, children: isOpen ? iconOpen : iconClose })] }), _jsx("div", { ref: (el) => {
|
|
57
|
+
contentRefs.current[index] = el;
|
|
58
|
+
}, style: {
|
|
59
|
+
overflow: "hidden",
|
|
60
|
+
maxHeight: isOpen
|
|
61
|
+
? `${contentRefs.current[index]?.scrollHeight}px`
|
|
62
|
+
: "0px",
|
|
63
|
+
transition: `max-height ${transitionDuration} ease-in-out`,
|
|
64
|
+
}, children: _jsx("div", { style: {
|
|
65
|
+
borderTop: `1px solid ${borderColor}`,
|
|
66
|
+
backgroundColor: contentBgColor,
|
|
67
|
+
color: contentTextColor,
|
|
68
|
+
padding: contentPadding,
|
|
69
|
+
fontSize: contentFontSize,
|
|
70
|
+
fontWeight: contentFontWeight,
|
|
71
|
+
}, children: item.content }) })] }, index));
|
|
72
|
+
}) }));
|
|
73
|
+
});
|
|
74
|
+
Accordion.displayName = "Accordion";
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState, useMemo } from "react";
|
|
3
|
+
import { X, Info, CheckCircle, AlertCircle, AlertTriangle, } from "lucide-react";
|
|
4
|
+
const typeStyles = {
|
|
5
|
+
success: {
|
|
6
|
+
bg: "#ecfdf5",
|
|
7
|
+
border: "#34d399",
|
|
8
|
+
iconColor: "#059669",
|
|
9
|
+
Icon: _jsx(CheckCircle, { size: 20 }),
|
|
10
|
+
},
|
|
11
|
+
error: {
|
|
12
|
+
bg: "#fef2f2",
|
|
13
|
+
border: "#f87171",
|
|
14
|
+
iconColor: "#dc2626",
|
|
15
|
+
Icon: _jsx(AlertCircle, { size: 20 }),
|
|
16
|
+
},
|
|
17
|
+
warning: {
|
|
18
|
+
bg: "#fffbeb",
|
|
19
|
+
border: "#facc15",
|
|
20
|
+
iconColor: "#d97706",
|
|
21
|
+
Icon: _jsx(AlertTriangle, { size: 20 }),
|
|
22
|
+
},
|
|
23
|
+
info: {
|
|
24
|
+
bg: "#eff6ff",
|
|
25
|
+
border: "#3b82f6",
|
|
26
|
+
iconColor: "#2563eb",
|
|
27
|
+
Icon: _jsx(Info, { size: 20 }),
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
const getPositionStyle = (position) => {
|
|
31
|
+
const base = {
|
|
32
|
+
position: "fixed",
|
|
33
|
+
zIndex: 9999,
|
|
34
|
+
pointerEvents: "auto",
|
|
35
|
+
};
|
|
36
|
+
switch (position) {
|
|
37
|
+
case "top-left":
|
|
38
|
+
return { ...base, top: "1.25rem", left: "1.25rem" };
|
|
39
|
+
case "top-center":
|
|
40
|
+
return { ...base, top: "1.25rem", left: "50%", transform: "translateX(-50%)" };
|
|
41
|
+
case "top-right":
|
|
42
|
+
return { ...base, top: "1.25rem", right: "1.25rem" };
|
|
43
|
+
case "bottom-left":
|
|
44
|
+
return { ...base, bottom: "1.25rem", left: "1.25rem" };
|
|
45
|
+
case "bottom-center":
|
|
46
|
+
return { ...base, bottom: "1.25rem", left: "50%", transform: "translateX(-50%)" };
|
|
47
|
+
case "bottom-right":
|
|
48
|
+
default:
|
|
49
|
+
return { ...base, bottom: "1.25rem", right: "1.25rem" };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export const Alert = ({ title, description, type = "info", dismissible = true, duration, onClose, icon, actionButton, position = "top-right", backgroundColor, borderColor, textColor = "#111827", borderRadius = "0.75rem", shadow = "0 4px 14px rgba(0,0,0,0.1)", padding = "1rem", fontSize = "0.95rem", fontWeight = 500, descriptionColor = "#374151", animationDuration = "300ms", maxWidth = "480px", className = "", style, }) => {
|
|
53
|
+
const [visible, setVisible] = useState(false);
|
|
54
|
+
const [exiting, setExiting] = useState(false);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
setVisible(true);
|
|
57
|
+
if (duration) {
|
|
58
|
+
const timer = setTimeout(() => {
|
|
59
|
+
setExiting(true);
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
setVisible(false);
|
|
62
|
+
onClose?.();
|
|
63
|
+
}, parseInt(animationDuration));
|
|
64
|
+
}, duration);
|
|
65
|
+
return () => clearTimeout(timer);
|
|
66
|
+
}
|
|
67
|
+
}, [duration, onClose, animationDuration]);
|
|
68
|
+
const { bg, border, iconColor, Icon } = typeStyles[type];
|
|
69
|
+
const positionStyle = getPositionStyle(position);
|
|
70
|
+
const containerStyle = useMemo(() => ({
|
|
71
|
+
...positionStyle,
|
|
72
|
+
display: "flex",
|
|
73
|
+
alignItems: "flex-start",
|
|
74
|
+
gap: "0.75rem",
|
|
75
|
+
backgroundColor: backgroundColor ?? bg,
|
|
76
|
+
borderLeft: `4px solid ${borderColor ?? border}`,
|
|
77
|
+
borderRadius,
|
|
78
|
+
color: textColor,
|
|
79
|
+
boxShadow: shadow,
|
|
80
|
+
padding,
|
|
81
|
+
maxWidth,
|
|
82
|
+
width: "calc(100% - 2.5rem)",
|
|
83
|
+
opacity: visible && !exiting ? 1 : 0,
|
|
84
|
+
transform: visible && !exiting
|
|
85
|
+
? "translateY(0)"
|
|
86
|
+
: position.includes("bottom")
|
|
87
|
+
? "translateY(20px)"
|
|
88
|
+
: "translateY(-20px)",
|
|
89
|
+
transition: `opacity ${animationDuration} ease, transform ${animationDuration} ease`,
|
|
90
|
+
fontWeight,
|
|
91
|
+
fontSize,
|
|
92
|
+
...style,
|
|
93
|
+
}), [
|
|
94
|
+
visible,
|
|
95
|
+
exiting,
|
|
96
|
+
bg,
|
|
97
|
+
border,
|
|
98
|
+
borderColor,
|
|
99
|
+
borderRadius,
|
|
100
|
+
position,
|
|
101
|
+
shadow,
|
|
102
|
+
padding,
|
|
103
|
+
textColor,
|
|
104
|
+
maxWidth,
|
|
105
|
+
backgroundColor,
|
|
106
|
+
animationDuration,
|
|
107
|
+
style,
|
|
108
|
+
fontSize,
|
|
109
|
+
fontWeight,
|
|
110
|
+
]);
|
|
111
|
+
if (!visible)
|
|
112
|
+
return null;
|
|
113
|
+
return (_jsxs(_Fragment, { children: [_jsx("style", { children: `
|
|
114
|
+
@keyframes alert-slide-in-top {
|
|
115
|
+
from { opacity: 0; transform: translateY(-20px); }
|
|
116
|
+
to { opacity: 1; transform: translateY(0); }
|
|
117
|
+
}
|
|
118
|
+
@keyframes alert-slide-in-bottom {
|
|
119
|
+
from { opacity: 0; transform: translateY(20px); }
|
|
120
|
+
to { opacity: 1; transform: translateY(0); }
|
|
121
|
+
}
|
|
122
|
+
` }), _jsxs("div", { className: className, style: {
|
|
123
|
+
...containerStyle,
|
|
124
|
+
animation: `${position.includes("bottom") ? "alert-slide-in-bottom" : "alert-slide-in-top"} ${animationDuration} ease`,
|
|
125
|
+
}, role: "alert", children: [_jsx("div", { style: { color: iconColor, marginTop: "2px" }, children: icon || Icon }), _jsxs("div", { style: { flex: 1, minWidth: 0 }, children: [title && (_jsx("div", { style: { fontWeight: 600, fontSize, marginBottom: "4px" }, children: title })), description && (_jsx("div", { style: { fontSize: "0.875rem", color: descriptionColor, lineHeight: 1.4 }, children: description })), actionButton && _jsx("div", { style: { marginTop: "8px" }, children: actionButton })] }), dismissible && (_jsx("button", { onClick: () => {
|
|
126
|
+
setExiting(true);
|
|
127
|
+
setTimeout(() => {
|
|
128
|
+
setVisible(false);
|
|
129
|
+
onClose?.();
|
|
130
|
+
}, parseInt(animationDuration));
|
|
131
|
+
}, style: {
|
|
132
|
+
background: "transparent",
|
|
133
|
+
border: "none",
|
|
134
|
+
color: "#6b7280",
|
|
135
|
+
cursor: "pointer",
|
|
136
|
+
marginLeft: "8px",
|
|
137
|
+
padding: 0,
|
|
138
|
+
lineHeight: 0,
|
|
139
|
+
}, "aria-label": "Close alert", children: _jsx(X, { size: 16 }) }))] })] }));
|
|
140
|
+
};
|
|
141
|
+
Alert.displayName = "Alert";
|