@ataraui/ataraui-react 0.4.0 → 0.6.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/README.md +291 -105
- package/dist/index.d.mts +142 -1
- package/dist/index.d.ts +142 -1
- package/dist/index.js +693 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +662 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1110,7 +1110,668 @@ var Popover = ({
|
|
|
1110
1110
|
] });
|
|
1111
1111
|
};
|
|
1112
1112
|
Popover.displayName = "Popover";
|
|
1113
|
+
var ToastContext = React13.createContext(null);
|
|
1114
|
+
var counter = 0;
|
|
1115
|
+
var genId = () => `toast-${++counter}`;
|
|
1116
|
+
var ToastProvider = ({ children }) => {
|
|
1117
|
+
const [toasts, setToasts] = React13.useState([]);
|
|
1118
|
+
const toast = React13.useCallback((input) => {
|
|
1119
|
+
const id = genId();
|
|
1120
|
+
setToasts((prev) => [...prev, { ...input, id }]);
|
|
1121
|
+
return id;
|
|
1122
|
+
}, []);
|
|
1123
|
+
const dismiss = React13.useCallback((id) => {
|
|
1124
|
+
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
1125
|
+
}, []);
|
|
1126
|
+
const dismissAll = React13.useCallback(() => {
|
|
1127
|
+
setToasts([]);
|
|
1128
|
+
}, []);
|
|
1129
|
+
return /* @__PURE__ */ jsx(ToastContext.Provider, { value: { toasts, toast, dismiss, dismissAll }, children });
|
|
1130
|
+
};
|
|
1131
|
+
var useToast = () => {
|
|
1132
|
+
const ctx = React13.useContext(ToastContext);
|
|
1133
|
+
if (!ctx) throw new Error("useToast must be used within a ToastProvider");
|
|
1134
|
+
return ctx;
|
|
1135
|
+
};
|
|
1136
|
+
var toastVariants = cva(
|
|
1137
|
+
"pointer-events-auto relative flex w-80 max-w-[calc(100vw-2rem)] items-start gap-3 overflow-hidden rounded-(--radius-lg) border p-4 pr-8 shadow-lg",
|
|
1138
|
+
{
|
|
1139
|
+
variants: {
|
|
1140
|
+
variant: {
|
|
1141
|
+
default: "border-(--color-neutral-200) bg-white text-(--color-neutral-800)",
|
|
1142
|
+
success: "border-green-200 bg-green-50 text-green-900",
|
|
1143
|
+
warning: "border-yellow-200 bg-yellow-50 text-yellow-900",
|
|
1144
|
+
destructive: "border-red-200 bg-red-50 text-red-900"
|
|
1145
|
+
}
|
|
1146
|
+
},
|
|
1147
|
+
defaultVariants: { variant: "default" }
|
|
1148
|
+
}
|
|
1149
|
+
);
|
|
1150
|
+
var positionClasses = {
|
|
1151
|
+
"top-left": "top-4 left-4 items-start",
|
|
1152
|
+
"top-center": "top-4 left-1/2 -translate-x-1/2 items-center",
|
|
1153
|
+
"top-right": "top-4 right-4 items-end",
|
|
1154
|
+
"bottom-left": "bottom-4 left-4 items-start",
|
|
1155
|
+
"bottom-center": "bottom-4 left-1/2 -translate-x-1/2 items-center",
|
|
1156
|
+
"bottom-right": "bottom-4 right-4 items-end"
|
|
1157
|
+
};
|
|
1158
|
+
var SingleToast = ({ toast, onDismiss, defaultDuration }) => {
|
|
1159
|
+
var _a, _b;
|
|
1160
|
+
const duration = (_a = toast.duration) != null ? _a : defaultDuration;
|
|
1161
|
+
React13.useEffect(() => {
|
|
1162
|
+
if (duration <= 0) return;
|
|
1163
|
+
const timer = setTimeout(() => onDismiss(toast.id), duration);
|
|
1164
|
+
return () => clearTimeout(timer);
|
|
1165
|
+
}, [duration, onDismiss, toast.id]);
|
|
1166
|
+
return /* @__PURE__ */ jsxs(
|
|
1167
|
+
"div",
|
|
1168
|
+
{
|
|
1169
|
+
role: "status",
|
|
1170
|
+
"aria-live": "polite",
|
|
1171
|
+
className: toastVariants({ variant: (_b = toast.variant) != null ? _b : "default" }),
|
|
1172
|
+
children: [
|
|
1173
|
+
toast.icon && /* @__PURE__ */ jsx("span", { className: "mt-0.5 shrink-0 [&>svg]:size-4", children: toast.icon }),
|
|
1174
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-1", children: [
|
|
1175
|
+
toast.title && /* @__PURE__ */ jsx("p", { className: "text-sm font-semibold leading-none", children: toast.title }),
|
|
1176
|
+
toast.description && /* @__PURE__ */ jsx("p", { className: "text-xs opacity-80", children: toast.description }),
|
|
1177
|
+
toast.action && /* @__PURE__ */ jsx(
|
|
1178
|
+
"button",
|
|
1179
|
+
{
|
|
1180
|
+
type: "button",
|
|
1181
|
+
onClick: () => {
|
|
1182
|
+
toast.action.onClick();
|
|
1183
|
+
onDismiss(toast.id);
|
|
1184
|
+
},
|
|
1185
|
+
className: "mt-1.5 text-xs font-medium underline underline-offset-2 hover:no-underline focus:outline-none",
|
|
1186
|
+
children: toast.action.label
|
|
1187
|
+
}
|
|
1188
|
+
)
|
|
1189
|
+
] }),
|
|
1190
|
+
/* @__PURE__ */ jsx(
|
|
1191
|
+
"button",
|
|
1192
|
+
{
|
|
1193
|
+
type: "button",
|
|
1194
|
+
"aria-label": "Dismiss",
|
|
1195
|
+
onClick: () => onDismiss(toast.id),
|
|
1196
|
+
className: "absolute right-2 top-2 rounded opacity-50 transition-opacity hover:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-(--color-primary-500)",
|
|
1197
|
+
children: /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1198
|
+
/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }),
|
|
1199
|
+
/* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })
|
|
1200
|
+
] })
|
|
1201
|
+
}
|
|
1202
|
+
)
|
|
1203
|
+
]
|
|
1204
|
+
}
|
|
1205
|
+
);
|
|
1206
|
+
};
|
|
1207
|
+
var Toaster = ({
|
|
1208
|
+
position = "bottom-right",
|
|
1209
|
+
defaultDuration = 4e3,
|
|
1210
|
+
className
|
|
1211
|
+
}) => {
|
|
1212
|
+
const { toasts, dismiss } = useToast();
|
|
1213
|
+
const [mounted, setMounted] = React13.useState(false);
|
|
1214
|
+
React13.useEffect(() => {
|
|
1215
|
+
setMounted(true);
|
|
1216
|
+
}, []);
|
|
1217
|
+
if (!mounted) return null;
|
|
1218
|
+
return createPortal(
|
|
1219
|
+
/* @__PURE__ */ jsx(
|
|
1220
|
+
"div",
|
|
1221
|
+
{
|
|
1222
|
+
"aria-label": "Notifications",
|
|
1223
|
+
className: cn(
|
|
1224
|
+
"fixed z-[100] flex flex-col gap-2 pointer-events-none",
|
|
1225
|
+
positionClasses[position],
|
|
1226
|
+
className
|
|
1227
|
+
),
|
|
1228
|
+
children: toasts.map((t) => /* @__PURE__ */ jsx(
|
|
1229
|
+
SingleToast,
|
|
1230
|
+
{
|
|
1231
|
+
toast: t,
|
|
1232
|
+
onDismiss: dismiss,
|
|
1233
|
+
defaultDuration
|
|
1234
|
+
},
|
|
1235
|
+
t.id
|
|
1236
|
+
))
|
|
1237
|
+
}
|
|
1238
|
+
),
|
|
1239
|
+
document.body
|
|
1240
|
+
);
|
|
1241
|
+
};
|
|
1242
|
+
Toaster.displayName = "Toaster";
|
|
1243
|
+
ToastProvider.displayName = "ToastProvider";
|
|
1244
|
+
var alertVariants = cva(
|
|
1245
|
+
"relative flex w-full gap-3 rounded-(--radius-lg) border p-4 text-sm",
|
|
1246
|
+
{
|
|
1247
|
+
variants: {
|
|
1248
|
+
variant: {
|
|
1249
|
+
default: "border-(--color-neutral-200) bg-(--color-neutral-50) text-(--color-neutral-700)",
|
|
1250
|
+
success: "border-green-200 bg-green-50 text-green-800",
|
|
1251
|
+
warning: "border-yellow-200 bg-yellow-50 text-yellow-800",
|
|
1252
|
+
destructive: "border-red-200 bg-red-50 text-red-800"
|
|
1253
|
+
}
|
|
1254
|
+
},
|
|
1255
|
+
defaultVariants: { variant: "default" }
|
|
1256
|
+
}
|
|
1257
|
+
);
|
|
1258
|
+
var Alert = ({
|
|
1259
|
+
variant,
|
|
1260
|
+
icon,
|
|
1261
|
+
onClose,
|
|
1262
|
+
className,
|
|
1263
|
+
children,
|
|
1264
|
+
...props
|
|
1265
|
+
}) => {
|
|
1266
|
+
return /* @__PURE__ */ jsxs(
|
|
1267
|
+
"div",
|
|
1268
|
+
{
|
|
1269
|
+
role: "alert",
|
|
1270
|
+
className: cn(alertVariants({ variant }), className),
|
|
1271
|
+
...props,
|
|
1272
|
+
children: [
|
|
1273
|
+
icon && /* @__PURE__ */ jsx("span", { className: "mt-0.5 shrink-0 [&>svg]:size-4", children: icon }),
|
|
1274
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1", children }),
|
|
1275
|
+
onClose && /* @__PURE__ */ jsx(
|
|
1276
|
+
"button",
|
|
1277
|
+
{
|
|
1278
|
+
type: "button",
|
|
1279
|
+
"aria-label": "Dismiss",
|
|
1280
|
+
onClick: onClose,
|
|
1281
|
+
className: "ml-auto shrink-0 self-start rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-(--color-primary-500)",
|
|
1282
|
+
children: /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1283
|
+
/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }),
|
|
1284
|
+
/* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })
|
|
1285
|
+
] })
|
|
1286
|
+
}
|
|
1287
|
+
)
|
|
1288
|
+
]
|
|
1289
|
+
}
|
|
1290
|
+
);
|
|
1291
|
+
};
|
|
1292
|
+
Alert.displayName = "Alert";
|
|
1293
|
+
var AlertTitle = ({
|
|
1294
|
+
className,
|
|
1295
|
+
children,
|
|
1296
|
+
...props
|
|
1297
|
+
}) => /* @__PURE__ */ jsx("p", { className: cn("font-semibold leading-none tracking-tight", className), ...props, children });
|
|
1298
|
+
AlertTitle.displayName = "AlertTitle";
|
|
1299
|
+
var AlertDescription = ({
|
|
1300
|
+
className,
|
|
1301
|
+
children,
|
|
1302
|
+
...props
|
|
1303
|
+
}) => /* @__PURE__ */ jsx("p", { className: cn("mt-1 text-[0.8rem] opacity-80", className), ...props, children });
|
|
1304
|
+
AlertDescription.displayName = "AlertDescription";
|
|
1305
|
+
var progressVariants = cva(
|
|
1306
|
+
"w-full overflow-hidden rounded-full bg-(--color-neutral-200)",
|
|
1307
|
+
{
|
|
1308
|
+
variants: {
|
|
1309
|
+
size: {
|
|
1310
|
+
sm: "h-1",
|
|
1311
|
+
md: "h-2",
|
|
1312
|
+
lg: "h-3"
|
|
1313
|
+
}
|
|
1314
|
+
},
|
|
1315
|
+
defaultVariants: { size: "md" }
|
|
1316
|
+
}
|
|
1317
|
+
);
|
|
1318
|
+
var Progress = ({
|
|
1319
|
+
value,
|
|
1320
|
+
size,
|
|
1321
|
+
label,
|
|
1322
|
+
showLabel = false,
|
|
1323
|
+
className,
|
|
1324
|
+
...props
|
|
1325
|
+
}) => {
|
|
1326
|
+
const isIndeterminate = value === void 0 || value === null;
|
|
1327
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
1328
|
+
(label || showLabel) && /* @__PURE__ */ jsxs("div", { className: "mb-1.5 flex items-center justify-between text-xs text-(--color-neutral-600)", children: [
|
|
1329
|
+
label && /* @__PURE__ */ jsx("span", { children: label }),
|
|
1330
|
+
showLabel && !isIndeterminate && /* @__PURE__ */ jsxs("span", { className: "ml-auto font-medium", children: [
|
|
1331
|
+
Math.round(value),
|
|
1332
|
+
"%"
|
|
1333
|
+
] })
|
|
1334
|
+
] }),
|
|
1335
|
+
/* @__PURE__ */ jsx(
|
|
1336
|
+
"div",
|
|
1337
|
+
{
|
|
1338
|
+
role: "progressbar",
|
|
1339
|
+
"aria-valuemin": 0,
|
|
1340
|
+
"aria-valuemax": 100,
|
|
1341
|
+
"aria-valuenow": isIndeterminate ? void 0 : value,
|
|
1342
|
+
className: cn(progressVariants({ size }), className),
|
|
1343
|
+
...props,
|
|
1344
|
+
children: /* @__PURE__ */ jsx(
|
|
1345
|
+
"div",
|
|
1346
|
+
{
|
|
1347
|
+
className: cn(
|
|
1348
|
+
"h-full rounded-full bg-(--color-primary-500) transition-all duration-300 ease-in-out",
|
|
1349
|
+
isIndeterminate && "w-1/3 animate-[indeterminate_1.5s_ease-in-out_infinite]"
|
|
1350
|
+
),
|
|
1351
|
+
style: isIndeterminate ? void 0 : { width: `${Math.min(100, Math.max(0, value))}%` }
|
|
1352
|
+
}
|
|
1353
|
+
)
|
|
1354
|
+
}
|
|
1355
|
+
)
|
|
1356
|
+
] });
|
|
1357
|
+
};
|
|
1358
|
+
Progress.displayName = "Progress";
|
|
1359
|
+
var skeletonVariants = cva(
|
|
1360
|
+
"animate-pulse bg-(--color-neutral-200)",
|
|
1361
|
+
{
|
|
1362
|
+
variants: {
|
|
1363
|
+
variant: {
|
|
1364
|
+
text: "h-4 w-full rounded",
|
|
1365
|
+
circle: "rounded-full",
|
|
1366
|
+
rect: "rounded-(--radius-md)"
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
defaultVariants: { variant: "rect" }
|
|
1370
|
+
}
|
|
1371
|
+
);
|
|
1372
|
+
var Skeleton = ({
|
|
1373
|
+
variant,
|
|
1374
|
+
width,
|
|
1375
|
+
height,
|
|
1376
|
+
className,
|
|
1377
|
+
style,
|
|
1378
|
+
...props
|
|
1379
|
+
}) => {
|
|
1380
|
+
return /* @__PURE__ */ jsx(
|
|
1381
|
+
"div",
|
|
1382
|
+
{
|
|
1383
|
+
"aria-hidden": "true",
|
|
1384
|
+
className: cn(skeletonVariants({ variant }), className),
|
|
1385
|
+
style: {
|
|
1386
|
+
width: typeof width === "number" ? `${width}px` : width,
|
|
1387
|
+
height: typeof height === "number" ? `${height}px` : height,
|
|
1388
|
+
...style
|
|
1389
|
+
},
|
|
1390
|
+
...props
|
|
1391
|
+
}
|
|
1392
|
+
);
|
|
1393
|
+
};
|
|
1394
|
+
Skeleton.displayName = "Skeleton";
|
|
1395
|
+
var tabsListVariants = cva(
|
|
1396
|
+
"flex items-center gap-1 rounded-(--radius-lg) bg-(--color-neutral-100) p-1",
|
|
1397
|
+
{
|
|
1398
|
+
variants: {
|
|
1399
|
+
variant: {
|
|
1400
|
+
default: "bg-(--color-neutral-100)",
|
|
1401
|
+
outline: "bg-transparent border border-(--color-neutral-200)",
|
|
1402
|
+
pills: "bg-transparent gap-2"
|
|
1403
|
+
}
|
|
1404
|
+
},
|
|
1405
|
+
defaultVariants: { variant: "default" }
|
|
1406
|
+
}
|
|
1407
|
+
);
|
|
1408
|
+
var tabsTriggerVariants = cva(
|
|
1409
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-(--radius-md) px-3 py-1.5 text-sm font-medium transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-(--color-primary-500) disabled:pointer-events-none disabled:opacity-50",
|
|
1410
|
+
{
|
|
1411
|
+
variants: {
|
|
1412
|
+
variant: {
|
|
1413
|
+
default: "text-(--color-neutral-500) data-[state=active]:bg-white data-[state=active]:text-(--color-neutral-900) data-[state=active]:shadow-sm",
|
|
1414
|
+
outline: "text-(--color-neutral-500) data-[state=active]:border data-[state=active]:border-(--color-neutral-200) data-[state=active]:bg-white data-[state=active]:text-(--color-neutral-900)",
|
|
1415
|
+
pills: "text-(--color-neutral-500) rounded-full data-[state=active]:bg-(--color-primary-500) data-[state=active]:text-white"
|
|
1416
|
+
}
|
|
1417
|
+
},
|
|
1418
|
+
defaultVariants: { variant: "default" }
|
|
1419
|
+
}
|
|
1420
|
+
);
|
|
1421
|
+
var TabsContext = React13.createContext(null);
|
|
1422
|
+
var useTabsContext = () => {
|
|
1423
|
+
const ctx = React13.useContext(TabsContext);
|
|
1424
|
+
if (!ctx) throw new Error("Tabs components must be used within <Tabs>");
|
|
1425
|
+
return ctx;
|
|
1426
|
+
};
|
|
1427
|
+
var Tabs = ({
|
|
1428
|
+
value,
|
|
1429
|
+
defaultValue = "",
|
|
1430
|
+
onChange,
|
|
1431
|
+
variant = "default",
|
|
1432
|
+
className,
|
|
1433
|
+
children,
|
|
1434
|
+
...props
|
|
1435
|
+
}) => {
|
|
1436
|
+
const [uncontrolled, setUncontrolled] = React13.useState(defaultValue);
|
|
1437
|
+
const isControlled = value !== void 0;
|
|
1438
|
+
const active = isControlled ? value : uncontrolled;
|
|
1439
|
+
const setActive = React13.useCallback((val) => {
|
|
1440
|
+
if (!isControlled) setUncontrolled(val);
|
|
1441
|
+
onChange == null ? void 0 : onChange(val);
|
|
1442
|
+
}, [isControlled, onChange]);
|
|
1443
|
+
return /* @__PURE__ */ jsx(TabsContext.Provider, { value: { active, setActive, variant }, children: /* @__PURE__ */ jsx("div", { className: cn("flex flex-col gap-2", className), ...props, children }) });
|
|
1444
|
+
};
|
|
1445
|
+
Tabs.displayName = "Tabs";
|
|
1446
|
+
var TabsList = ({ className, children, ...props }) => {
|
|
1447
|
+
const { variant } = useTabsContext();
|
|
1448
|
+
return /* @__PURE__ */ jsx(
|
|
1449
|
+
"div",
|
|
1450
|
+
{
|
|
1451
|
+
role: "tablist",
|
|
1452
|
+
className: cn(tabsListVariants({ variant }), className),
|
|
1453
|
+
...props,
|
|
1454
|
+
children
|
|
1455
|
+
}
|
|
1456
|
+
);
|
|
1457
|
+
};
|
|
1458
|
+
TabsList.displayName = "TabsList";
|
|
1459
|
+
var TabsTrigger = ({
|
|
1460
|
+
value,
|
|
1461
|
+
className,
|
|
1462
|
+
children,
|
|
1463
|
+
...props
|
|
1464
|
+
}) => {
|
|
1465
|
+
const { active, setActive, variant } = useTabsContext();
|
|
1466
|
+
const isActive = active === value;
|
|
1467
|
+
return /* @__PURE__ */ jsx(
|
|
1468
|
+
"button",
|
|
1469
|
+
{
|
|
1470
|
+
type: "button",
|
|
1471
|
+
role: "tab",
|
|
1472
|
+
"aria-selected": isActive,
|
|
1473
|
+
"data-state": isActive ? "active" : "inactive",
|
|
1474
|
+
onClick: () => setActive(value),
|
|
1475
|
+
className: cn(tabsTriggerVariants({ variant }), className),
|
|
1476
|
+
...props,
|
|
1477
|
+
children
|
|
1478
|
+
}
|
|
1479
|
+
);
|
|
1480
|
+
};
|
|
1481
|
+
TabsTrigger.displayName = "TabsTrigger";
|
|
1482
|
+
var TabsContent = ({
|
|
1483
|
+
value,
|
|
1484
|
+
className,
|
|
1485
|
+
children,
|
|
1486
|
+
...props
|
|
1487
|
+
}) => {
|
|
1488
|
+
const { active } = useTabsContext();
|
|
1489
|
+
if (active !== value) return null;
|
|
1490
|
+
return /* @__PURE__ */ jsx(
|
|
1491
|
+
"div",
|
|
1492
|
+
{
|
|
1493
|
+
role: "tabpanel",
|
|
1494
|
+
className: cn("mt-2", className),
|
|
1495
|
+
...props,
|
|
1496
|
+
children
|
|
1497
|
+
}
|
|
1498
|
+
);
|
|
1499
|
+
};
|
|
1500
|
+
TabsContent.displayName = "TabsContent";
|
|
1501
|
+
var accordionVariants = cva(
|
|
1502
|
+
"w-full",
|
|
1503
|
+
{
|
|
1504
|
+
variants: {
|
|
1505
|
+
variant: {
|
|
1506
|
+
default: "divide-y divide-(--color-neutral-200) rounded-(--radius-lg) border border-(--color-neutral-200)",
|
|
1507
|
+
ghost: "divide-y divide-(--color-neutral-200)",
|
|
1508
|
+
outlined: "flex flex-col gap-2"
|
|
1509
|
+
}
|
|
1510
|
+
},
|
|
1511
|
+
defaultVariants: { variant: "default" }
|
|
1512
|
+
}
|
|
1513
|
+
);
|
|
1514
|
+
var AccordionContext = React13.createContext(null);
|
|
1515
|
+
var useAccordionContext = () => {
|
|
1516
|
+
const ctx = React13.useContext(AccordionContext);
|
|
1517
|
+
if (!ctx) throw new Error("Accordion components must be used within <Accordion>");
|
|
1518
|
+
return ctx;
|
|
1519
|
+
};
|
|
1520
|
+
var Accordion = ({
|
|
1521
|
+
type = "single",
|
|
1522
|
+
value,
|
|
1523
|
+
defaultValue,
|
|
1524
|
+
onChange,
|
|
1525
|
+
variant = "default",
|
|
1526
|
+
className,
|
|
1527
|
+
children,
|
|
1528
|
+
...props
|
|
1529
|
+
}) => {
|
|
1530
|
+
const initOpen = defaultValue ? Array.isArray(defaultValue) ? defaultValue : [defaultValue] : [];
|
|
1531
|
+
const [uncontrolled, setUncontrolled] = React13.useState(initOpen);
|
|
1532
|
+
const isControlled = value !== void 0;
|
|
1533
|
+
const openItems = isControlled ? Array.isArray(value) ? value : [value] : uncontrolled;
|
|
1534
|
+
const toggle = React13.useCallback((val) => {
|
|
1535
|
+
var _a;
|
|
1536
|
+
let next;
|
|
1537
|
+
if (type === "single") {
|
|
1538
|
+
next = openItems.includes(val) ? [] : [val];
|
|
1539
|
+
} else {
|
|
1540
|
+
next = openItems.includes(val) ? openItems.filter((v) => v !== val) : [...openItems, val];
|
|
1541
|
+
}
|
|
1542
|
+
if (!isControlled) setUncontrolled(next);
|
|
1543
|
+
onChange == null ? void 0 : onChange(type === "single" ? (_a = next[0]) != null ? _a : "" : next);
|
|
1544
|
+
}, [isControlled, onChange, openItems, type]);
|
|
1545
|
+
return /* @__PURE__ */ jsx(AccordionContext.Provider, { value: { openItems, toggle, variant }, children: /* @__PURE__ */ jsx("div", { className: cn(accordionVariants({ variant }), className), ...props, children }) });
|
|
1546
|
+
};
|
|
1547
|
+
Accordion.displayName = "Accordion";
|
|
1548
|
+
var AccordionItemContext = React13.createContext(null);
|
|
1549
|
+
var useAccordionItemContext = () => {
|
|
1550
|
+
const ctx = React13.useContext(AccordionItemContext);
|
|
1551
|
+
if (!ctx) throw new Error("AccordionTrigger/Content must be used within <AccordionItem>");
|
|
1552
|
+
return ctx;
|
|
1553
|
+
};
|
|
1554
|
+
var AccordionItem = ({
|
|
1555
|
+
value,
|
|
1556
|
+
disabled = false,
|
|
1557
|
+
className,
|
|
1558
|
+
children,
|
|
1559
|
+
...props
|
|
1560
|
+
}) => {
|
|
1561
|
+
const { openItems, variant } = useAccordionContext();
|
|
1562
|
+
const isOpen = openItems.includes(value);
|
|
1563
|
+
return /* @__PURE__ */ jsx(AccordionItemContext.Provider, { value: { value, isOpen, disabled }, children: /* @__PURE__ */ jsx(
|
|
1564
|
+
"div",
|
|
1565
|
+
{
|
|
1566
|
+
"data-state": isOpen ? "open" : "closed",
|
|
1567
|
+
className: cn(
|
|
1568
|
+
variant === "outlined" && "rounded-(--radius-lg) border border-(--color-neutral-200)",
|
|
1569
|
+
disabled && "opacity-50 pointer-events-none",
|
|
1570
|
+
className
|
|
1571
|
+
),
|
|
1572
|
+
...props,
|
|
1573
|
+
children
|
|
1574
|
+
}
|
|
1575
|
+
) });
|
|
1576
|
+
};
|
|
1577
|
+
AccordionItem.displayName = "AccordionItem";
|
|
1578
|
+
var AccordionTrigger = ({
|
|
1579
|
+
className,
|
|
1580
|
+
children,
|
|
1581
|
+
...props
|
|
1582
|
+
}) => {
|
|
1583
|
+
const { toggle } = useAccordionContext();
|
|
1584
|
+
const { value, isOpen } = useAccordionItemContext();
|
|
1585
|
+
return /* @__PURE__ */ jsxs(
|
|
1586
|
+
"button",
|
|
1587
|
+
{
|
|
1588
|
+
type: "button",
|
|
1589
|
+
"aria-expanded": isOpen,
|
|
1590
|
+
onClick: () => toggle(value),
|
|
1591
|
+
className: cn(
|
|
1592
|
+
"flex w-full items-center justify-between px-4 py-4 text-sm font-medium text-(--color-neutral-900) transition-all hover:bg-(--color-neutral-50) focus:outline-none focus-visible:ring-2 focus-visible:ring-(--color-primary-500)",
|
|
1593
|
+
className
|
|
1594
|
+
),
|
|
1595
|
+
...props,
|
|
1596
|
+
children: [
|
|
1597
|
+
children,
|
|
1598
|
+
/* @__PURE__ */ jsx(
|
|
1599
|
+
"svg",
|
|
1600
|
+
{
|
|
1601
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1602
|
+
width: "16",
|
|
1603
|
+
height: "16",
|
|
1604
|
+
viewBox: "0 0 24 24",
|
|
1605
|
+
fill: "none",
|
|
1606
|
+
stroke: "currentColor",
|
|
1607
|
+
strokeWidth: "2",
|
|
1608
|
+
strokeLinecap: "round",
|
|
1609
|
+
strokeLinejoin: "round",
|
|
1610
|
+
className: cn("shrink-0 text-(--color-neutral-500) transition-transform duration-200", isOpen && "rotate-180"),
|
|
1611
|
+
children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" })
|
|
1612
|
+
}
|
|
1613
|
+
)
|
|
1614
|
+
]
|
|
1615
|
+
}
|
|
1616
|
+
);
|
|
1617
|
+
};
|
|
1618
|
+
AccordionTrigger.displayName = "AccordionTrigger";
|
|
1619
|
+
var AccordionContent = ({
|
|
1620
|
+
className,
|
|
1621
|
+
children,
|
|
1622
|
+
...props
|
|
1623
|
+
}) => {
|
|
1624
|
+
const { isOpen } = useAccordionItemContext();
|
|
1625
|
+
if (!isOpen) return null;
|
|
1626
|
+
return /* @__PURE__ */ jsx(
|
|
1627
|
+
"div",
|
|
1628
|
+
{
|
|
1629
|
+
className: cn("px-4 pb-4 text-sm text-(--color-neutral-600)", className),
|
|
1630
|
+
...props,
|
|
1631
|
+
children
|
|
1632
|
+
}
|
|
1633
|
+
);
|
|
1634
|
+
};
|
|
1635
|
+
AccordionContent.displayName = "AccordionContent";
|
|
1636
|
+
var tableVariants = cva(
|
|
1637
|
+
"w-full caption-bottom text-sm",
|
|
1638
|
+
{
|
|
1639
|
+
variants: {
|
|
1640
|
+
variant: {
|
|
1641
|
+
default: "",
|
|
1642
|
+
striped: "",
|
|
1643
|
+
bordered: ""
|
|
1644
|
+
}
|
|
1645
|
+
},
|
|
1646
|
+
defaultVariants: { variant: "default" }
|
|
1647
|
+
}
|
|
1648
|
+
);
|
|
1649
|
+
var TableContext = React13.createContext({ variant: "default" });
|
|
1650
|
+
var Table = ({
|
|
1651
|
+
variant = "default",
|
|
1652
|
+
className,
|
|
1653
|
+
children,
|
|
1654
|
+
...props
|
|
1655
|
+
}) => {
|
|
1656
|
+
return /* @__PURE__ */ jsx(TableContext.Provider, { value: { variant }, children: /* @__PURE__ */ jsx("div", { className: "w-full overflow-auto rounded-(--radius-lg) border border-(--color-neutral-200)", children: /* @__PURE__ */ jsx(
|
|
1657
|
+
"table",
|
|
1658
|
+
{
|
|
1659
|
+
className: cn(tableVariants({ variant }), className),
|
|
1660
|
+
...props,
|
|
1661
|
+
children
|
|
1662
|
+
}
|
|
1663
|
+
) }) });
|
|
1664
|
+
};
|
|
1665
|
+
Table.displayName = "Table";
|
|
1666
|
+
var TableHeader = ({
|
|
1667
|
+
className,
|
|
1668
|
+
children,
|
|
1669
|
+
...props
|
|
1670
|
+
}) => /* @__PURE__ */ jsx(
|
|
1671
|
+
"thead",
|
|
1672
|
+
{
|
|
1673
|
+
className: cn("bg-(--color-neutral-50) [&_tr]:border-b [&_tr]:border-(--color-neutral-200)", className),
|
|
1674
|
+
...props,
|
|
1675
|
+
children
|
|
1676
|
+
}
|
|
1677
|
+
);
|
|
1678
|
+
TableHeader.displayName = "TableHeader";
|
|
1679
|
+
var TableBody = ({
|
|
1680
|
+
className,
|
|
1681
|
+
children,
|
|
1682
|
+
...props
|
|
1683
|
+
}) => {
|
|
1684
|
+
const { variant } = React13.useContext(TableContext);
|
|
1685
|
+
return /* @__PURE__ */ jsx(
|
|
1686
|
+
"tbody",
|
|
1687
|
+
{
|
|
1688
|
+
className: cn(
|
|
1689
|
+
"[&_tr:last-child]:border-0",
|
|
1690
|
+
variant === "striped" && "[&_tr:nth-child(odd)]:bg-(--color-neutral-50)",
|
|
1691
|
+
className
|
|
1692
|
+
),
|
|
1693
|
+
...props,
|
|
1694
|
+
children
|
|
1695
|
+
}
|
|
1696
|
+
);
|
|
1697
|
+
};
|
|
1698
|
+
TableBody.displayName = "TableBody";
|
|
1699
|
+
var TableFooter = ({
|
|
1700
|
+
className,
|
|
1701
|
+
children,
|
|
1702
|
+
...props
|
|
1703
|
+
}) => /* @__PURE__ */ jsx(
|
|
1704
|
+
"tfoot",
|
|
1705
|
+
{
|
|
1706
|
+
className: cn("border-t border-(--color-neutral-200) bg-(--color-neutral-50) font-medium", className),
|
|
1707
|
+
...props,
|
|
1708
|
+
children
|
|
1709
|
+
}
|
|
1710
|
+
);
|
|
1711
|
+
TableFooter.displayName = "TableFooter";
|
|
1712
|
+
var TableRow = ({
|
|
1713
|
+
className,
|
|
1714
|
+
children,
|
|
1715
|
+
...props
|
|
1716
|
+
}) => {
|
|
1717
|
+
const { variant } = React13.useContext(TableContext);
|
|
1718
|
+
return /* @__PURE__ */ jsx(
|
|
1719
|
+
"tr",
|
|
1720
|
+
{
|
|
1721
|
+
className: cn(
|
|
1722
|
+
"border-b border-(--color-neutral-200) transition-colors hover:bg-(--color-neutral-50)",
|
|
1723
|
+
variant === "bordered" && "[&_td]:border-r [&_td]:last:border-r-0 [&_th]:border-r [&_th]:last:border-r-0",
|
|
1724
|
+
className
|
|
1725
|
+
),
|
|
1726
|
+
...props,
|
|
1727
|
+
children
|
|
1728
|
+
}
|
|
1729
|
+
);
|
|
1730
|
+
};
|
|
1731
|
+
TableRow.displayName = "TableRow";
|
|
1732
|
+
var TableHead = ({
|
|
1733
|
+
className,
|
|
1734
|
+
children,
|
|
1735
|
+
...props
|
|
1736
|
+
}) => /* @__PURE__ */ jsx(
|
|
1737
|
+
"th",
|
|
1738
|
+
{
|
|
1739
|
+
className: cn(
|
|
1740
|
+
"h-10 px-4 text-left align-middle text-xs font-semibold uppercase tracking-wide text-(--color-neutral-500)",
|
|
1741
|
+
className
|
|
1742
|
+
),
|
|
1743
|
+
...props,
|
|
1744
|
+
children
|
|
1745
|
+
}
|
|
1746
|
+
);
|
|
1747
|
+
TableHead.displayName = "TableHead";
|
|
1748
|
+
var TableCell = ({
|
|
1749
|
+
className,
|
|
1750
|
+
children,
|
|
1751
|
+
...props
|
|
1752
|
+
}) => /* @__PURE__ */ jsx(
|
|
1753
|
+
"td",
|
|
1754
|
+
{
|
|
1755
|
+
className: cn("px-4 py-3 align-middle text-(--color-neutral-700)", className),
|
|
1756
|
+
...props,
|
|
1757
|
+
children
|
|
1758
|
+
}
|
|
1759
|
+
);
|
|
1760
|
+
TableCell.displayName = "TableCell";
|
|
1761
|
+
var TableCaption = ({
|
|
1762
|
+
className,
|
|
1763
|
+
children,
|
|
1764
|
+
...props
|
|
1765
|
+
}) => /* @__PURE__ */ jsx(
|
|
1766
|
+
"caption",
|
|
1767
|
+
{
|
|
1768
|
+
className: cn("mt-4 text-sm text-(--color-neutral-500)", className),
|
|
1769
|
+
...props,
|
|
1770
|
+
children
|
|
1771
|
+
}
|
|
1772
|
+
);
|
|
1773
|
+
TableCaption.displayName = "TableCaption";
|
|
1113
1774
|
|
|
1114
|
-
export { Avatar, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Drawer, DrawerBody, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, Input, Modal, ModalBody, ModalDescription, ModalFooter, ModalHeader, ModalTitle, Popover, RadioGroup, Select, Separator, Spinner, Switch, Tooltip, avatarVariants, badgeVariants, buttonVariants, cardVariants, cn, colors, drawerVariants, fontSize, inputVariants, modalVariants, radius, selectVariants, separatorVariants, spinnerVariants };
|
|
1775
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Avatar, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Drawer, DrawerBody, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, Input, Modal, ModalBody, ModalDescription, ModalFooter, ModalHeader, ModalTitle, Popover, Progress, RadioGroup, Select, Separator, Skeleton, Spinner, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, ToastProvider, Toaster, Tooltip, accordionVariants, alertVariants, avatarVariants, badgeVariants, buttonVariants, cardVariants, cn, colors, drawerVariants, fontSize, inputVariants, modalVariants, progressVariants, radius, selectVariants, separatorVariants, skeletonVariants, spinnerVariants, tableVariants, tabsListVariants, tabsTriggerVariants, toastVariants, useToast };
|
|
1115
1776
|
//# sourceMappingURL=index.mjs.map
|
|
1116
1777
|
//# sourceMappingURL=index.mjs.map
|