@melony/react 0.1.52 → 0.1.53
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 +170 -160
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -9
- package/dist/index.d.ts +8 -9
- package/dist/index.js +171 -161
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2137,6 +2137,165 @@ var Form = ({
|
|
|
2137
2137
|
}
|
|
2138
2138
|
);
|
|
2139
2139
|
};
|
|
2140
|
+
function DropdownMenu({ ...props }) {
|
|
2141
|
+
return /* @__PURE__ */ jsxRuntime.jsx(menu.Menu.Root, { "data-slot": "dropdown-menu", ...props });
|
|
2142
|
+
}
|
|
2143
|
+
function DropdownMenuTrigger({ ...props }) {
|
|
2144
|
+
return /* @__PURE__ */ jsxRuntime.jsx(menu.Menu.Trigger, { "data-slot": "dropdown-menu-trigger", ...props });
|
|
2145
|
+
}
|
|
2146
|
+
function DropdownMenuContent({
|
|
2147
|
+
align = "start",
|
|
2148
|
+
alignOffset = 0,
|
|
2149
|
+
side = "bottom",
|
|
2150
|
+
sideOffset = 4,
|
|
2151
|
+
className,
|
|
2152
|
+
...props
|
|
2153
|
+
}) {
|
|
2154
|
+
return /* @__PURE__ */ jsxRuntime.jsx(menu.Menu.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2155
|
+
menu.Menu.Positioner,
|
|
2156
|
+
{
|
|
2157
|
+
className: "isolate z-50 outline-none",
|
|
2158
|
+
align,
|
|
2159
|
+
alignOffset,
|
|
2160
|
+
side,
|
|
2161
|
+
sideOffset,
|
|
2162
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2163
|
+
menu.Menu.Popup,
|
|
2164
|
+
{
|
|
2165
|
+
"data-slot": "dropdown-menu-content",
|
|
2166
|
+
className: cn("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/5 bg-popover text-popover-foreground min-w-48 rounded-2xl p-1 shadow-2xl ring-1 duration-100 z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden", className),
|
|
2167
|
+
...props
|
|
2168
|
+
}
|
|
2169
|
+
)
|
|
2170
|
+
}
|
|
2171
|
+
) });
|
|
2172
|
+
}
|
|
2173
|
+
function DropdownMenuGroup({ ...props }) {
|
|
2174
|
+
return /* @__PURE__ */ jsxRuntime.jsx(menu.Menu.Group, { "data-slot": "dropdown-menu-group", ...props });
|
|
2175
|
+
}
|
|
2176
|
+
function DropdownMenuLabel({
|
|
2177
|
+
className,
|
|
2178
|
+
inset,
|
|
2179
|
+
...props
|
|
2180
|
+
}) {
|
|
2181
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2182
|
+
menu.Menu.GroupLabel,
|
|
2183
|
+
{
|
|
2184
|
+
"data-slot": "dropdown-menu-label",
|
|
2185
|
+
"data-inset": inset,
|
|
2186
|
+
className: cn("text-muted-foreground px-3 py-2.5 text-xs data-[inset]:pl-8", className),
|
|
2187
|
+
...props
|
|
2188
|
+
}
|
|
2189
|
+
);
|
|
2190
|
+
}
|
|
2191
|
+
function DropdownMenuItem({
|
|
2192
|
+
className,
|
|
2193
|
+
inset,
|
|
2194
|
+
variant = "default",
|
|
2195
|
+
...props
|
|
2196
|
+
}) {
|
|
2197
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2198
|
+
menu.Menu.Item,
|
|
2199
|
+
{
|
|
2200
|
+
"data-slot": "dropdown-menu-item",
|
|
2201
|
+
"data-inset": inset,
|
|
2202
|
+
"data-variant": variant,
|
|
2203
|
+
className: cn(
|
|
2204
|
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground gap-2.5 rounded-xl px-3 py-2 text-sm [&_svg:not([class*='size-'])]:size-4 group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
2205
|
+
className
|
|
2206
|
+
),
|
|
2207
|
+
...props
|
|
2208
|
+
}
|
|
2209
|
+
);
|
|
2210
|
+
}
|
|
2211
|
+
function DropdownMenuCheckboxItem({
|
|
2212
|
+
className,
|
|
2213
|
+
children,
|
|
2214
|
+
checked,
|
|
2215
|
+
...props
|
|
2216
|
+
}) {
|
|
2217
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2218
|
+
menu.Menu.CheckboxItem,
|
|
2219
|
+
{
|
|
2220
|
+
"data-slot": "dropdown-menu-checkbox-item",
|
|
2221
|
+
className: cn(
|
|
2222
|
+
"focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground gap-2.5 rounded-xl py-2 pr-8 pl-3 text-sm [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
2223
|
+
className
|
|
2224
|
+
),
|
|
2225
|
+
checked,
|
|
2226
|
+
...props,
|
|
2227
|
+
children: [
|
|
2228
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2229
|
+
"span",
|
|
2230
|
+
{
|
|
2231
|
+
className: "pointer-events-none absolute right-2 flex items-center justify-center pointer-events-none",
|
|
2232
|
+
"data-slot": "dropdown-menu-checkbox-item-indicator",
|
|
2233
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(menu.Menu.CheckboxItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2234
|
+
ICONS.IconCheck,
|
|
2235
|
+
{}
|
|
2236
|
+
) })
|
|
2237
|
+
}
|
|
2238
|
+
),
|
|
2239
|
+
children
|
|
2240
|
+
]
|
|
2241
|
+
}
|
|
2242
|
+
);
|
|
2243
|
+
}
|
|
2244
|
+
function DropdownMenuSeparator({
|
|
2245
|
+
className,
|
|
2246
|
+
...props
|
|
2247
|
+
}) {
|
|
2248
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2249
|
+
menu.Menu.Separator,
|
|
2250
|
+
{
|
|
2251
|
+
"data-slot": "dropdown-menu-separator",
|
|
2252
|
+
className: cn("bg-border/50 -mx-1 my-1 h-px", className),
|
|
2253
|
+
...props
|
|
2254
|
+
}
|
|
2255
|
+
);
|
|
2256
|
+
}
|
|
2257
|
+
var Dropdown = ({
|
|
2258
|
+
items = [],
|
|
2259
|
+
children
|
|
2260
|
+
}) => {
|
|
2261
|
+
const { sendEvent } = useMelony();
|
|
2262
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
|
|
2263
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2264
|
+
DropdownMenuTrigger,
|
|
2265
|
+
{
|
|
2266
|
+
render: (props) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2267
|
+
Button,
|
|
2268
|
+
{
|
|
2269
|
+
variant: "ghost",
|
|
2270
|
+
size: "icon-xs",
|
|
2271
|
+
...props,
|
|
2272
|
+
onClick: (e) => {
|
|
2273
|
+
e.stopPropagation();
|
|
2274
|
+
props.onClick?.(e);
|
|
2275
|
+
},
|
|
2276
|
+
children: children || /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconDotsVertical, { className: "size-3.5" })
|
|
2277
|
+
}
|
|
2278
|
+
)
|
|
2279
|
+
}
|
|
2280
|
+
),
|
|
2281
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuContent, { align: "start", className: cn("w-32"), children: items.map((item, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2282
|
+
DropdownMenuItem,
|
|
2283
|
+
{
|
|
2284
|
+
onClick: (e) => {
|
|
2285
|
+
e.stopPropagation();
|
|
2286
|
+
if (item.onClickAction) {
|
|
2287
|
+
sendEvent(item.onClickAction);
|
|
2288
|
+
}
|
|
2289
|
+
},
|
|
2290
|
+
children: [
|
|
2291
|
+
item.icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: item.icon, size: "sm" }),
|
|
2292
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: item.icon ? "ml-2" : "", children: item.label })
|
|
2293
|
+
]
|
|
2294
|
+
},
|
|
2295
|
+
`${item.label}-${i}`
|
|
2296
|
+
)) })
|
|
2297
|
+
] });
|
|
2298
|
+
};
|
|
2140
2299
|
function UIRenderer({ node }) {
|
|
2141
2300
|
const { type, props, children } = node;
|
|
2142
2301
|
const typeMap = {
|
|
@@ -2166,7 +2325,8 @@ function UIRenderer({ node }) {
|
|
|
2166
2325
|
form: Form,
|
|
2167
2326
|
chart: Chart,
|
|
2168
2327
|
label: Label2,
|
|
2169
|
-
upload: Upload
|
|
2328
|
+
upload: Upload,
|
|
2329
|
+
dropdown: Dropdown
|
|
2170
2330
|
};
|
|
2171
2331
|
const Component = typeMap[type];
|
|
2172
2332
|
if (!Component) {
|
|
@@ -2349,123 +2509,6 @@ var useAuth = () => {
|
|
|
2349
2509
|
}
|
|
2350
2510
|
return context;
|
|
2351
2511
|
};
|
|
2352
|
-
function DropdownMenu({ ...props }) {
|
|
2353
|
-
return /* @__PURE__ */ jsxRuntime.jsx(menu.Menu.Root, { "data-slot": "dropdown-menu", ...props });
|
|
2354
|
-
}
|
|
2355
|
-
function DropdownMenuTrigger({ ...props }) {
|
|
2356
|
-
return /* @__PURE__ */ jsxRuntime.jsx(menu.Menu.Trigger, { "data-slot": "dropdown-menu-trigger", ...props });
|
|
2357
|
-
}
|
|
2358
|
-
function DropdownMenuContent({
|
|
2359
|
-
align = "start",
|
|
2360
|
-
alignOffset = 0,
|
|
2361
|
-
side = "bottom",
|
|
2362
|
-
sideOffset = 4,
|
|
2363
|
-
className,
|
|
2364
|
-
...props
|
|
2365
|
-
}) {
|
|
2366
|
-
return /* @__PURE__ */ jsxRuntime.jsx(menu.Menu.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2367
|
-
menu.Menu.Positioner,
|
|
2368
|
-
{
|
|
2369
|
-
className: "isolate z-50 outline-none",
|
|
2370
|
-
align,
|
|
2371
|
-
alignOffset,
|
|
2372
|
-
side,
|
|
2373
|
-
sideOffset,
|
|
2374
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2375
|
-
menu.Menu.Popup,
|
|
2376
|
-
{
|
|
2377
|
-
"data-slot": "dropdown-menu-content",
|
|
2378
|
-
className: cn("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/5 bg-popover text-popover-foreground min-w-48 rounded-2xl p-1 shadow-2xl ring-1 duration-100 z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden", className),
|
|
2379
|
-
...props
|
|
2380
|
-
}
|
|
2381
|
-
)
|
|
2382
|
-
}
|
|
2383
|
-
) });
|
|
2384
|
-
}
|
|
2385
|
-
function DropdownMenuGroup({ ...props }) {
|
|
2386
|
-
return /* @__PURE__ */ jsxRuntime.jsx(menu.Menu.Group, { "data-slot": "dropdown-menu-group", ...props });
|
|
2387
|
-
}
|
|
2388
|
-
function DropdownMenuLabel({
|
|
2389
|
-
className,
|
|
2390
|
-
inset,
|
|
2391
|
-
...props
|
|
2392
|
-
}) {
|
|
2393
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2394
|
-
menu.Menu.GroupLabel,
|
|
2395
|
-
{
|
|
2396
|
-
"data-slot": "dropdown-menu-label",
|
|
2397
|
-
"data-inset": inset,
|
|
2398
|
-
className: cn("text-muted-foreground px-3 py-2.5 text-xs data-[inset]:pl-8", className),
|
|
2399
|
-
...props
|
|
2400
|
-
}
|
|
2401
|
-
);
|
|
2402
|
-
}
|
|
2403
|
-
function DropdownMenuItem({
|
|
2404
|
-
className,
|
|
2405
|
-
inset,
|
|
2406
|
-
variant = "default",
|
|
2407
|
-
...props
|
|
2408
|
-
}) {
|
|
2409
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2410
|
-
menu.Menu.Item,
|
|
2411
|
-
{
|
|
2412
|
-
"data-slot": "dropdown-menu-item",
|
|
2413
|
-
"data-inset": inset,
|
|
2414
|
-
"data-variant": variant,
|
|
2415
|
-
className: cn(
|
|
2416
|
-
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground gap-2.5 rounded-xl px-3 py-2 text-sm [&_svg:not([class*='size-'])]:size-4 group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
2417
|
-
className
|
|
2418
|
-
),
|
|
2419
|
-
...props
|
|
2420
|
-
}
|
|
2421
|
-
);
|
|
2422
|
-
}
|
|
2423
|
-
function DropdownMenuCheckboxItem({
|
|
2424
|
-
className,
|
|
2425
|
-
children,
|
|
2426
|
-
checked,
|
|
2427
|
-
...props
|
|
2428
|
-
}) {
|
|
2429
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2430
|
-
menu.Menu.CheckboxItem,
|
|
2431
|
-
{
|
|
2432
|
-
"data-slot": "dropdown-menu-checkbox-item",
|
|
2433
|
-
className: cn(
|
|
2434
|
-
"focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground gap-2.5 rounded-xl py-2 pr-8 pl-3 text-sm [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
2435
|
-
className
|
|
2436
|
-
),
|
|
2437
|
-
checked,
|
|
2438
|
-
...props,
|
|
2439
|
-
children: [
|
|
2440
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2441
|
-
"span",
|
|
2442
|
-
{
|
|
2443
|
-
className: "pointer-events-none absolute right-2 flex items-center justify-center pointer-events-none",
|
|
2444
|
-
"data-slot": "dropdown-menu-checkbox-item-indicator",
|
|
2445
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(menu.Menu.CheckboxItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2446
|
-
ICONS.IconCheck,
|
|
2447
|
-
{}
|
|
2448
|
-
) })
|
|
2449
|
-
}
|
|
2450
|
-
),
|
|
2451
|
-
children
|
|
2452
|
-
]
|
|
2453
|
-
}
|
|
2454
|
-
);
|
|
2455
|
-
}
|
|
2456
|
-
function DropdownMenuSeparator({
|
|
2457
|
-
className,
|
|
2458
|
-
...props
|
|
2459
|
-
}) {
|
|
2460
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2461
|
-
menu.Menu.Separator,
|
|
2462
|
-
{
|
|
2463
|
-
"data-slot": "dropdown-menu-separator",
|
|
2464
|
-
className: cn("bg-border/50 -mx-1 my-1 h-px", className),
|
|
2465
|
-
...props
|
|
2466
|
-
}
|
|
2467
|
-
);
|
|
2468
|
-
}
|
|
2469
2512
|
var AccountButton = ({
|
|
2470
2513
|
className,
|
|
2471
2514
|
variant = "outline",
|
|
@@ -3581,40 +3624,8 @@ function ChatHeader({
|
|
|
3581
3624
|
}
|
|
3582
3625
|
);
|
|
3583
3626
|
}
|
|
3584
|
-
var Dropdown = ({
|
|
3585
|
-
className,
|
|
3586
|
-
trigger,
|
|
3587
|
-
triggerClassName,
|
|
3588
|
-
items
|
|
3589
|
-
}) => {
|
|
3590
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
|
|
3591
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3592
|
-
DropdownMenuTrigger,
|
|
3593
|
-
{
|
|
3594
|
-
className: triggerClassName,
|
|
3595
|
-
render: (props) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3596
|
-
Button,
|
|
3597
|
-
{
|
|
3598
|
-
variant: "ghost",
|
|
3599
|
-
size: "icon-xs",
|
|
3600
|
-
...props,
|
|
3601
|
-
onClick: (e) => {
|
|
3602
|
-
e.stopPropagation();
|
|
3603
|
-
props.onClick?.(e);
|
|
3604
|
-
},
|
|
3605
|
-
children: trigger || /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconDotsVertical, { className: "size-3.5" })
|
|
3606
|
-
}
|
|
3607
|
-
)
|
|
3608
|
-
}
|
|
3609
|
-
),
|
|
3610
|
-
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuContent, { align: "start", className: cn("w-32", className), children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { onClick: item.onClick, children: [
|
|
3611
|
-
item.icon,
|
|
3612
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: item.label })
|
|
3613
|
-
] }, item.label)) })
|
|
3614
|
-
] });
|
|
3615
|
-
};
|
|
3616
3627
|
var ThreadList = ({ padding, background, gap, radius = "md" }) => {
|
|
3617
|
-
const { threads, activeThreadId
|
|
3628
|
+
const { threads, activeThreadId } = useThreads();
|
|
3618
3629
|
const sortedThreads = React3__namespace.useMemo(() => {
|
|
3619
3630
|
return [...threads].sort((a, b) => {
|
|
3620
3631
|
const dateA = a.updatedAt ? new Date(a.updatedAt).getTime() : 0;
|
|
@@ -3622,13 +3633,6 @@ var ThreadList = ({ padding, background, gap, radius = "md" }) => {
|
|
|
3622
3633
|
return dateB - dateA;
|
|
3623
3634
|
});
|
|
3624
3635
|
}, [threads]);
|
|
3625
|
-
const handleDelete = async (threadId) => {
|
|
3626
|
-
try {
|
|
3627
|
-
await deleteThread(threadId);
|
|
3628
|
-
} catch (error) {
|
|
3629
|
-
console.error("Failed to delete thread:", error);
|
|
3630
|
-
}
|
|
3631
|
-
};
|
|
3632
3636
|
return /* @__PURE__ */ jsxRuntime.jsx(List, { padding, gap, flex: "1", overflow: "scroll", children: sortedThreads.map((thread) => {
|
|
3633
3637
|
thread.id === activeThreadId;
|
|
3634
3638
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3652,8 +3656,14 @@ var ThreadList = ({ padding, background, gap, radius = "md" }) => {
|
|
|
3652
3656
|
items: [
|
|
3653
3657
|
{
|
|
3654
3658
|
label: "Delete",
|
|
3655
|
-
icon:
|
|
3656
|
-
|
|
3659
|
+
icon: "trash",
|
|
3660
|
+
onClickAction: {
|
|
3661
|
+
role: "system",
|
|
3662
|
+
type: "delete-thread",
|
|
3663
|
+
data: {
|
|
3664
|
+
threadId: thread.id
|
|
3665
|
+
}
|
|
3666
|
+
}
|
|
3657
3667
|
}
|
|
3658
3668
|
]
|
|
3659
3669
|
}
|