@neoptocom/neopto-ui 1.3.1 → 1.4.0
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.cjs +16 -5
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +16 -5
- package/package.json +1 -1
- package/src/components/Chat/AgentButton.tsx +20 -7
- package/src/stories/AgentButton.stories.tsx +76 -0
package/dist/index.cjs
CHANGED
|
@@ -1255,7 +1255,8 @@ var AgentButton = ({
|
|
|
1255
1255
|
notificationMessage = "",
|
|
1256
1256
|
logoSrc,
|
|
1257
1257
|
logoAlt = "Agent",
|
|
1258
|
-
animationColors = ["#7DADB9", "#3864F5", "#55468D", "#479A8D"]
|
|
1258
|
+
animationColors = ["#7DADB9", "#3864F5", "#55468D", "#479A8D"],
|
|
1259
|
+
disabled = false
|
|
1259
1260
|
}) => {
|
|
1260
1261
|
const [showText, setShowText] = React3.useState(false);
|
|
1261
1262
|
const [delayedHasNotification, setDelayedHasNotification] = React3.useState(false);
|
|
@@ -1296,12 +1297,17 @@ var AgentButton = ({
|
|
|
1296
1297
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1297
1298
|
"div",
|
|
1298
1299
|
{
|
|
1299
|
-
className: `flex justify-end items-center fixed bottom-3 right-8 z-40 h-24 transition-all duration-
|
|
1300
|
+
className: `flex justify-end items-center fixed bottom-3 right-8 z-40 h-24 transition-all duration-1000 ease-in-out ${delayedHasNotification ? "w-[432px]" : "w-24"} ${isMounted ? "opacity-100" : "opacity-0"}`,
|
|
1301
|
+
style: {
|
|
1302
|
+
filter: disabled ? "grayscale(100%)" : "grayscale(0%)",
|
|
1303
|
+
transition: "filter 1s ease-in-out"
|
|
1304
|
+
},
|
|
1300
1305
|
children: [
|
|
1301
1306
|
circleAnimations.map((circle, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1302
1307
|
"div",
|
|
1303
1308
|
{
|
|
1304
|
-
className: `absolute ${circle.style} h-20 min-w-20
|
|
1309
|
+
className: `absolute ${circle.style} h-20 min-w-20 w-20 overflow-visible flex justify-between transition-opacity duration-1000 ease-in-out`,
|
|
1310
|
+
style: { opacity: disabled ? 0 : 1 },
|
|
1305
1311
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1306
1312
|
AnimatedBgCircle_default,
|
|
1307
1313
|
{
|
|
@@ -1316,7 +1322,11 @@ var AgentButton = ({
|
|
|
1316
1322
|
rectAnimations.map((rect, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1317
1323
|
"div",
|
|
1318
1324
|
{
|
|
1319
|
-
className: `absolute ${rect.style} h-20 transition-all
|
|
1325
|
+
className: `absolute ${rect.style} h-20 transition-all ease-in-out ${delayedHasNotification ? "w-[324px] px-0" : "w-20 px-10"} overflow-visible flex justify-between`,
|
|
1326
|
+
style: {
|
|
1327
|
+
opacity: disabled ? 0 : delayedHasNotification ? 1 : 0,
|
|
1328
|
+
transitionDuration: "1s"
|
|
1329
|
+
},
|
|
1320
1330
|
children: /* @__PURE__ */ jsxRuntime.jsx(AnimatedBgRectangle_default, { colors: animationColors, delay: rect.delay })
|
|
1321
1331
|
},
|
|
1322
1332
|
`rect-${index}`
|
|
@@ -1325,7 +1335,8 @@ var AgentButton = ({
|
|
|
1325
1335
|
"button",
|
|
1326
1336
|
{
|
|
1327
1337
|
onClick: onOpenChat,
|
|
1328
|
-
|
|
1338
|
+
disabled,
|
|
1339
|
+
className: `flex flex-row-reverse items-center gap-1.5 fixed p-3 rounded-full shadow-md h-16 mr-4 transition-all duration-600 ease-in-out border-2 border-[var(--border)] ${delayedHasNotification ? "w-[400px]" : "w-16"} ${disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
|
|
1329
1340
|
style: {
|
|
1330
1341
|
background: "var(--chat-button-gradient)"
|
|
1331
1342
|
},
|
package/dist/index.d.cts
CHANGED
|
@@ -298,8 +298,10 @@ interface AgentButtonProps {
|
|
|
298
298
|
logoAlt?: string;
|
|
299
299
|
/** Custom animation colors */
|
|
300
300
|
animationColors?: string[];
|
|
301
|
+
/** Whether the button is disabled (greyscale, no animations) */
|
|
302
|
+
disabled?: boolean;
|
|
301
303
|
}
|
|
302
|
-
declare const AgentButton: ({ onOpenChat, hasNotification, notificationMessage, logoSrc, logoAlt, animationColors, }: AgentButtonProps) => react_jsx_runtime.JSX.Element;
|
|
304
|
+
declare const AgentButton: ({ onOpenChat, hasNotification, notificationMessage, logoSrc, logoAlt, animationColors, disabled, }: AgentButtonProps) => react_jsx_runtime.JSX.Element;
|
|
303
305
|
|
|
304
306
|
interface AnimatedBgCircleProps {
|
|
305
307
|
colors: string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -298,8 +298,10 @@ interface AgentButtonProps {
|
|
|
298
298
|
logoAlt?: string;
|
|
299
299
|
/** Custom animation colors */
|
|
300
300
|
animationColors?: string[];
|
|
301
|
+
/** Whether the button is disabled (greyscale, no animations) */
|
|
302
|
+
disabled?: boolean;
|
|
301
303
|
}
|
|
302
|
-
declare const AgentButton: ({ onOpenChat, hasNotification, notificationMessage, logoSrc, logoAlt, animationColors, }: AgentButtonProps) => react_jsx_runtime.JSX.Element;
|
|
304
|
+
declare const AgentButton: ({ onOpenChat, hasNotification, notificationMessage, logoSrc, logoAlt, animationColors, disabled, }: AgentButtonProps) => react_jsx_runtime.JSX.Element;
|
|
303
305
|
|
|
304
306
|
interface AnimatedBgCircleProps {
|
|
305
307
|
colors: string[];
|
package/dist/index.js
CHANGED
|
@@ -1234,7 +1234,8 @@ var AgentButton = ({
|
|
|
1234
1234
|
notificationMessage = "",
|
|
1235
1235
|
logoSrc,
|
|
1236
1236
|
logoAlt = "Agent",
|
|
1237
|
-
animationColors = ["#7DADB9", "#3864F5", "#55468D", "#479A8D"]
|
|
1237
|
+
animationColors = ["#7DADB9", "#3864F5", "#55468D", "#479A8D"],
|
|
1238
|
+
disabled = false
|
|
1238
1239
|
}) => {
|
|
1239
1240
|
const [showText, setShowText] = useState(false);
|
|
1240
1241
|
const [delayedHasNotification, setDelayedHasNotification] = useState(false);
|
|
@@ -1275,12 +1276,17 @@ var AgentButton = ({
|
|
|
1275
1276
|
return /* @__PURE__ */ jsxs(
|
|
1276
1277
|
"div",
|
|
1277
1278
|
{
|
|
1278
|
-
className: `flex justify-end items-center fixed bottom-3 right-8 z-40 h-24 transition-all duration-
|
|
1279
|
+
className: `flex justify-end items-center fixed bottom-3 right-8 z-40 h-24 transition-all duration-1000 ease-in-out ${delayedHasNotification ? "w-[432px]" : "w-24"} ${isMounted ? "opacity-100" : "opacity-0"}`,
|
|
1280
|
+
style: {
|
|
1281
|
+
filter: disabled ? "grayscale(100%)" : "grayscale(0%)",
|
|
1282
|
+
transition: "filter 1s ease-in-out"
|
|
1283
|
+
},
|
|
1279
1284
|
children: [
|
|
1280
1285
|
circleAnimations.map((circle, index) => /* @__PURE__ */ jsx(
|
|
1281
1286
|
"div",
|
|
1282
1287
|
{
|
|
1283
|
-
className: `absolute ${circle.style} h-20 min-w-20
|
|
1288
|
+
className: `absolute ${circle.style} h-20 min-w-20 w-20 overflow-visible flex justify-between transition-opacity duration-1000 ease-in-out`,
|
|
1289
|
+
style: { opacity: disabled ? 0 : 1 },
|
|
1284
1290
|
children: /* @__PURE__ */ jsx(
|
|
1285
1291
|
AnimatedBgCircle_default,
|
|
1286
1292
|
{
|
|
@@ -1295,7 +1301,11 @@ var AgentButton = ({
|
|
|
1295
1301
|
rectAnimations.map((rect, index) => /* @__PURE__ */ jsx(
|
|
1296
1302
|
"div",
|
|
1297
1303
|
{
|
|
1298
|
-
className: `absolute ${rect.style} h-20 transition-all
|
|
1304
|
+
className: `absolute ${rect.style} h-20 transition-all ease-in-out ${delayedHasNotification ? "w-[324px] px-0" : "w-20 px-10"} overflow-visible flex justify-between`,
|
|
1305
|
+
style: {
|
|
1306
|
+
opacity: disabled ? 0 : delayedHasNotification ? 1 : 0,
|
|
1307
|
+
transitionDuration: "1s"
|
|
1308
|
+
},
|
|
1299
1309
|
children: /* @__PURE__ */ jsx(AnimatedBgRectangle_default, { colors: animationColors, delay: rect.delay })
|
|
1300
1310
|
},
|
|
1301
1311
|
`rect-${index}`
|
|
@@ -1304,7 +1314,8 @@ var AgentButton = ({
|
|
|
1304
1314
|
"button",
|
|
1305
1315
|
{
|
|
1306
1316
|
onClick: onOpenChat,
|
|
1307
|
-
|
|
1317
|
+
disabled,
|
|
1318
|
+
className: `flex flex-row-reverse items-center gap-1.5 fixed p-3 rounded-full shadow-md h-16 mr-4 transition-all duration-600 ease-in-out border-2 border-[var(--border)] ${delayedHasNotification ? "w-[400px]" : "w-16"} ${disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
|
|
1308
1319
|
style: {
|
|
1309
1320
|
background: "var(--chat-button-gradient)"
|
|
1310
1321
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neoptocom/neopto-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A modern React component library built with Tailwind CSS v4 and TypeScript. Features dark mode, design tokens, and comprehensive Storybook documentation. Requires Tailwind v4+.",
|
|
6
6
|
"keywords": [
|
|
@@ -16,6 +16,8 @@ export interface AgentButtonProps {
|
|
|
16
16
|
logoAlt?: string;
|
|
17
17
|
/** Custom animation colors */
|
|
18
18
|
animationColors?: string[];
|
|
19
|
+
/** Whether the button is disabled (greyscale, no animations) */
|
|
20
|
+
disabled?: boolean;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
const AgentButton = ({
|
|
@@ -25,6 +27,7 @@ const AgentButton = ({
|
|
|
25
27
|
logoSrc,
|
|
26
28
|
logoAlt = "Agent",
|
|
27
29
|
animationColors = ["#7DADB9", "#3864F5", "#55468D", "#479A8D"],
|
|
30
|
+
disabled = false,
|
|
28
31
|
}: AgentButtonProps) => {
|
|
29
32
|
const [showText, setShowText] = useState(false);
|
|
30
33
|
const [delayedHasNotification, setDelayedHasNotification] = useState(false);
|
|
@@ -68,14 +71,19 @@ const AgentButton = ({
|
|
|
68
71
|
|
|
69
72
|
return (
|
|
70
73
|
<div
|
|
71
|
-
className={`flex justify-end items-center fixed bottom-3 right-8 z-40 h-24 transition-all duration-
|
|
74
|
+
className={`flex justify-end items-center fixed bottom-3 right-8 z-40 h-24 transition-all duration-1000 ease-in-out ${
|
|
72
75
|
delayedHasNotification ? "w-[432px]" : "w-24"
|
|
73
76
|
} ${isMounted ? "opacity-100" : "opacity-0"}`}
|
|
77
|
+
style={{
|
|
78
|
+
filter: disabled ? "grayscale(100%)" : "grayscale(0%)",
|
|
79
|
+
transition: "filter 1s ease-in-out",
|
|
80
|
+
}}
|
|
74
81
|
>
|
|
75
82
|
{circleAnimations.map((circle, index) => (
|
|
76
83
|
<div
|
|
77
84
|
key={`circle-${index}`}
|
|
78
|
-
className={`absolute ${circle.style} h-20 min-w-20
|
|
85
|
+
className={`absolute ${circle.style} h-20 min-w-20 w-20 overflow-visible flex justify-between transition-opacity duration-1000 ease-in-out`}
|
|
86
|
+
style={{ opacity: disabled ? 0 : 1 }}
|
|
79
87
|
>
|
|
80
88
|
<AnimatedBgCircle
|
|
81
89
|
colors={animationColors}
|
|
@@ -87,11 +95,15 @@ const AgentButton = ({
|
|
|
87
95
|
{rectAnimations.map((rect, index) => (
|
|
88
96
|
<div
|
|
89
97
|
key={`rect-${index}`}
|
|
90
|
-
className={`absolute ${rect.style} h-20 transition-all
|
|
98
|
+
className={`absolute ${rect.style} h-20 transition-all ease-in-out ${
|
|
91
99
|
delayedHasNotification
|
|
92
|
-
? "w-[324px]
|
|
93
|
-
: "w-20 px-10
|
|
100
|
+
? "w-[324px] px-0"
|
|
101
|
+
: "w-20 px-10"
|
|
94
102
|
} overflow-visible flex justify-between`}
|
|
103
|
+
style={{
|
|
104
|
+
opacity: disabled ? 0 : delayedHasNotification ? 1 : 0,
|
|
105
|
+
transitionDuration: "1s",
|
|
106
|
+
}}
|
|
95
107
|
>
|
|
96
108
|
<AnimatedBgRectangle colors={animationColors} delay={rect.delay} />
|
|
97
109
|
</div>
|
|
@@ -99,9 +111,10 @@ const AgentButton = ({
|
|
|
99
111
|
{isMounted && (
|
|
100
112
|
<button
|
|
101
113
|
onClick={onOpenChat}
|
|
102
|
-
|
|
114
|
+
disabled={disabled}
|
|
115
|
+
className={`flex flex-row-reverse items-center gap-1.5 fixed p-3 rounded-full shadow-md h-16 mr-4 transition-all duration-600 ease-in-out border-2 border-[var(--border)] ${
|
|
103
116
|
delayedHasNotification ? "w-[400px]" : "w-16"
|
|
104
|
-
}`}
|
|
117
|
+
} ${disabled ? "cursor-not-allowed" : "cursor-pointer"}`}
|
|
105
118
|
style={{
|
|
106
119
|
background: "var(--chat-button-gradient)",
|
|
107
120
|
}}
|
|
@@ -92,3 +92,79 @@ export const AutoToggleNotification: Story = {
|
|
|
92
92
|
},
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
+
export const Disabled: Story = {
|
|
96
|
+
args: {
|
|
97
|
+
disabled: true,
|
|
98
|
+
hasNotification: true,
|
|
99
|
+
notificationMessage: "This button is disabled (greyscale, no animations)",
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const DisabledWhenChatOpen: Story = {
|
|
104
|
+
render: (args) => {
|
|
105
|
+
const [chatOpen, setChatOpen] = React.useState(false);
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<>
|
|
109
|
+
<AgentButton
|
|
110
|
+
{...args}
|
|
111
|
+
disabled={chatOpen}
|
|
112
|
+
hasNotification={!chatOpen}
|
|
113
|
+
notificationMessage="Click to open chat (button will become disabled)"
|
|
114
|
+
onOpenChat={() => {
|
|
115
|
+
setChatOpen(true);
|
|
116
|
+
console.log("Chat opened!");
|
|
117
|
+
}}
|
|
118
|
+
/>
|
|
119
|
+
{chatOpen && (
|
|
120
|
+
<div className="fixed bottom-24 right-8 bg-[var(--surface)] border border-[var(--border)] rounded-lg p-4 shadow-lg z-50 max-w-md">
|
|
121
|
+
<Typo variant="body-md" className="text-[var(--fg)]">
|
|
122
|
+
Chat is open! Notice the button is now disabled (greyscale with no animations).
|
|
123
|
+
</Typo>
|
|
124
|
+
<button
|
|
125
|
+
onClick={() => setChatOpen(false)}
|
|
126
|
+
className="mt-2 px-3 py-1 bg-[var(--color-brand)] text-white rounded-full"
|
|
127
|
+
>
|
|
128
|
+
<Typo variant="label-sm">Close Chat</Typo>
|
|
129
|
+
</button>
|
|
130
|
+
</div>
|
|
131
|
+
)}
|
|
132
|
+
</>
|
|
133
|
+
);
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const DisabledTransition: Story = {
|
|
138
|
+
render: (args) => {
|
|
139
|
+
const [disabled, setDisabled] = React.useState(false);
|
|
140
|
+
|
|
141
|
+
React.useEffect(() => {
|
|
142
|
+
const interval = setInterval(() => {
|
|
143
|
+
setDisabled((prev) => !prev);
|
|
144
|
+
}, 4000);
|
|
145
|
+
|
|
146
|
+
return () => clearInterval(interval);
|
|
147
|
+
}, []);
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<>
|
|
151
|
+
<AgentButton
|
|
152
|
+
{...args}
|
|
153
|
+
disabled={disabled}
|
|
154
|
+
hasNotification={!disabled}
|
|
155
|
+
notificationMessage="Watch the smooth 1-second transition!"
|
|
156
|
+
onOpenChat={() => console.log("Chat opened!")}
|
|
157
|
+
/>
|
|
158
|
+
<div className="fixed top-8 left-8 bg-[var(--surface)] border border-[var(--border)] rounded-lg p-4 shadow-lg">
|
|
159
|
+
<Typo variant="body-md" className="text-[var(--fg)]">
|
|
160
|
+
State: <strong>{disabled ? "Disabled" : "Enabled"}</strong>
|
|
161
|
+
</Typo>
|
|
162
|
+
<Typo variant="label-sm" className="text-[var(--muted-fg)] mt-1">
|
|
163
|
+
Toggles every 4 seconds
|
|
164
|
+
</Typo>
|
|
165
|
+
</div>
|
|
166
|
+
</>
|
|
167
|
+
);
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
|