@spark-ui/components 12.0.1 → 12.1.1
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/alert-dialog/index.mjs +1 -1
- package/dist/avatar/index.mjs +2 -2
- package/dist/carousel/index.d.mts +3 -0
- package/dist/carousel/index.d.ts +3 -0
- package/dist/carousel/index.js +146 -65
- package/dist/carousel/index.js.map +1 -1
- package/dist/carousel/index.mjs +127 -46
- package/dist/carousel/index.mjs.map +1 -1
- package/dist/combobox/index.d.mts +1 -1
- package/dist/combobox/index.d.ts +1 -1
- package/dist/combobox/index.mjs +3 -3
- package/dist/dialog/index.mjs +1 -1
- package/dist/docgen.json +193 -104
- package/dist/drawer/index.mjs +2 -2
- package/dist/dropdown/index.d.mts +1 -1
- package/dist/dropdown/index.d.ts +1 -1
- package/dist/dropdown/index.mjs +2 -2
- package/dist/file-upload/index.mjs +3 -3
- package/dist/icon/index.d.mts +2 -2
- package/dist/icon/index.d.ts +2 -2
- package/dist/index-Cno_GFuW.d.mts +93 -0
- package/dist/index-Cno_GFuW.d.ts +93 -0
- package/dist/pagination/index.mjs +3 -3
- package/dist/popover/index.d.mts +6 -93
- package/dist/popover/index.d.ts +6 -93
- package/dist/popover/index.mjs +1 -1
- package/dist/scrolling-list/index.mjs +3 -3
- package/dist/snackbar/index.mjs +3 -3
- package/dist/stepper/index.mjs +2 -2
- package/dist/tabs/index.d.mts +37 -3
- package/dist/tabs/index.d.ts +37 -3
- package/dist/tabs/index.js +471 -17
- package/dist/tabs/index.js.map +1 -1
- package/dist/tabs/index.mjs +135 -14
- package/dist/tabs/index.mjs.map +1 -1
- package/dist/toast/index.mjs +3 -3
- package/package.json +5 -5
package/dist/tabs/index.js
CHANGED
|
@@ -1272,12 +1272,422 @@ var TabsList = ({
|
|
|
1272
1272
|
TabsList.displayName = "Tabs.List";
|
|
1273
1273
|
|
|
1274
1274
|
// src/tabs/TabsTrigger.tsx
|
|
1275
|
-
var
|
|
1275
|
+
var import_use_merge_refs2 = require("@spark-ui/hooks/use-merge-refs");
|
|
1276
|
+
var import_radix_ui12 = require("radix-ui");
|
|
1277
|
+
var import_react10 = require("react");
|
|
1276
1278
|
|
|
1277
|
-
// src/tabs/
|
|
1279
|
+
// src/tabs/TabsPopoverAbstraction.tsx
|
|
1280
|
+
var import_use_merge_refs = require("@spark-ui/hooks/use-merge-refs");
|
|
1281
|
+
var import_MoreMenuHorizontal = require("@spark-ui/icons/MoreMenuHorizontal");
|
|
1282
|
+
var import_class_variance_authority13 = require("class-variance-authority");
|
|
1283
|
+
var import_react9 = require("react");
|
|
1284
|
+
|
|
1285
|
+
// src/icon-button/IconButton.styles.tsx
|
|
1278
1286
|
var import_internal_utils9 = require("@spark-ui/internal-utils");
|
|
1279
1287
|
var import_class_variance_authority8 = require("class-variance-authority");
|
|
1280
|
-
var
|
|
1288
|
+
var iconButtonStyles = (0, import_class_variance_authority8.cva)(["pl-0 pr-0"], {
|
|
1289
|
+
variants: {
|
|
1290
|
+
/**
|
|
1291
|
+
* Sets the size of the icon.
|
|
1292
|
+
*/
|
|
1293
|
+
size: (0, import_internal_utils9.makeVariants)({
|
|
1294
|
+
sm: ["text-body-1"],
|
|
1295
|
+
md: ["text-body-1"],
|
|
1296
|
+
lg: ["text-display-3"]
|
|
1297
|
+
})
|
|
1298
|
+
}
|
|
1299
|
+
});
|
|
1300
|
+
|
|
1301
|
+
// src/icon-button/IconButton.tsx
|
|
1302
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1303
|
+
var IconButton = ({
|
|
1304
|
+
design = "filled",
|
|
1305
|
+
disabled = false,
|
|
1306
|
+
intent = "main",
|
|
1307
|
+
shape = "rounded",
|
|
1308
|
+
size = "md",
|
|
1309
|
+
className,
|
|
1310
|
+
ref,
|
|
1311
|
+
...others
|
|
1312
|
+
}) => {
|
|
1313
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1314
|
+
Button,
|
|
1315
|
+
{
|
|
1316
|
+
"data-spark-component": "icon-button",
|
|
1317
|
+
ref,
|
|
1318
|
+
className: iconButtonStyles({ size, className }),
|
|
1319
|
+
design,
|
|
1320
|
+
disabled,
|
|
1321
|
+
intent,
|
|
1322
|
+
shape,
|
|
1323
|
+
size,
|
|
1324
|
+
...others
|
|
1325
|
+
}
|
|
1326
|
+
);
|
|
1327
|
+
};
|
|
1328
|
+
IconButton.displayName = "IconButton";
|
|
1329
|
+
|
|
1330
|
+
// src/popover/Popover.tsx
|
|
1331
|
+
var import_radix_ui5 = require("radix-ui");
|
|
1332
|
+
|
|
1333
|
+
// src/popover/PopoverContext.tsx
|
|
1334
|
+
var import_react7 = require("react");
|
|
1335
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1336
|
+
var PopoverContext = (0, import_react7.createContext)(null);
|
|
1337
|
+
var ID_PREFIX = ":popover";
|
|
1338
|
+
var PopoverProvider = ({
|
|
1339
|
+
children,
|
|
1340
|
+
intent
|
|
1341
|
+
}) => {
|
|
1342
|
+
const [headerId, setHeaderId] = (0, import_react7.useState)(null);
|
|
1343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1344
|
+
PopoverContext.Provider,
|
|
1345
|
+
{
|
|
1346
|
+
value: {
|
|
1347
|
+
headerId,
|
|
1348
|
+
setHeaderId,
|
|
1349
|
+
intent
|
|
1350
|
+
},
|
|
1351
|
+
children
|
|
1352
|
+
}
|
|
1353
|
+
);
|
|
1354
|
+
};
|
|
1355
|
+
var usePopover = () => {
|
|
1356
|
+
const context = (0, import_react7.useContext)(PopoverContext);
|
|
1357
|
+
if (!context) {
|
|
1358
|
+
throw Error("usePopover must be used within a Popover provider");
|
|
1359
|
+
}
|
|
1360
|
+
return context;
|
|
1361
|
+
};
|
|
1362
|
+
|
|
1363
|
+
// src/popover/Popover.tsx
|
|
1364
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1365
|
+
var Popover = ({ children, intent = "surface", modal = false, ...rest }) => {
|
|
1366
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PopoverProvider, { intent, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_radix_ui5.Popover.Root, { "data-spark-component": "popover", modal, ...rest, children }) });
|
|
1367
|
+
};
|
|
1368
|
+
Popover.displayName = "Popover";
|
|
1369
|
+
|
|
1370
|
+
// src/popover/PopoverAnchor.tsx
|
|
1371
|
+
var import_radix_ui6 = require("radix-ui");
|
|
1372
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1373
|
+
var Anchor = ({ asChild = false, children, ref, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_radix_ui6.Popover.Anchor, { "data-spark-component": "popover-anchor", ref, asChild, ...rest, children });
|
|
1374
|
+
Anchor.displayName = "Popover.Anchor";
|
|
1375
|
+
|
|
1376
|
+
// src/popover/PopoverArrow.tsx
|
|
1377
|
+
var import_class_variance_authority9 = require("class-variance-authority");
|
|
1378
|
+
var import_radix_ui7 = require("radix-ui");
|
|
1379
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1380
|
+
var Arrow = ({
|
|
1381
|
+
asChild = false,
|
|
1382
|
+
width = 16,
|
|
1383
|
+
height = 8,
|
|
1384
|
+
className,
|
|
1385
|
+
ref,
|
|
1386
|
+
...rest
|
|
1387
|
+
}) => {
|
|
1388
|
+
const { intent } = usePopover();
|
|
1389
|
+
const styles2 = (0, import_class_variance_authority9.cva)("visible", {
|
|
1390
|
+
variants: {
|
|
1391
|
+
intent: {
|
|
1392
|
+
surface: "fill-surface",
|
|
1393
|
+
main: "fill-main-container",
|
|
1394
|
+
support: "fill-support-container",
|
|
1395
|
+
accent: "fill-accent-container",
|
|
1396
|
+
basic: "fill-basic-container",
|
|
1397
|
+
success: "fill-success-container",
|
|
1398
|
+
alert: "fill-alert-container",
|
|
1399
|
+
danger: "fill-error-container",
|
|
1400
|
+
info: "fill-info-container",
|
|
1401
|
+
neutral: "fill-neutral-container"
|
|
1402
|
+
}
|
|
1403
|
+
},
|
|
1404
|
+
defaultVariants: {
|
|
1405
|
+
intent: "surface"
|
|
1406
|
+
}
|
|
1407
|
+
});
|
|
1408
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1409
|
+
import_radix_ui7.Popover.Arrow,
|
|
1410
|
+
{
|
|
1411
|
+
"data-spark-component": "popover-arrow",
|
|
1412
|
+
ref,
|
|
1413
|
+
className: styles2({ intent, className }),
|
|
1414
|
+
asChild,
|
|
1415
|
+
width,
|
|
1416
|
+
height,
|
|
1417
|
+
...rest
|
|
1418
|
+
}
|
|
1419
|
+
);
|
|
1420
|
+
};
|
|
1421
|
+
Arrow.displayName = "Popover.Arrow";
|
|
1422
|
+
|
|
1423
|
+
// src/popover/PopoverCloseButton.tsx
|
|
1424
|
+
var import_Close = require("@spark-ui/icons/Close");
|
|
1425
|
+
var import_class_variance_authority10 = require("class-variance-authority");
|
|
1426
|
+
var import_radix_ui8 = require("radix-ui");
|
|
1427
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1428
|
+
var CloseButton = ({
|
|
1429
|
+
"aria-label": ariaLabel,
|
|
1430
|
+
className,
|
|
1431
|
+
ref,
|
|
1432
|
+
...rest
|
|
1433
|
+
}) => {
|
|
1434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1435
|
+
import_radix_ui8.Popover.Close,
|
|
1436
|
+
{
|
|
1437
|
+
"data-spark-component": "popover-close-button",
|
|
1438
|
+
ref,
|
|
1439
|
+
className: (0, import_class_variance_authority10.cx)("right-lg top-md absolute", className),
|
|
1440
|
+
asChild: true,
|
|
1441
|
+
...rest,
|
|
1442
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(IconButton, { size: "sm", intent: "neutral", design: "ghost", "aria-label": ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_Close.Close, {}) }) })
|
|
1443
|
+
}
|
|
1444
|
+
);
|
|
1445
|
+
};
|
|
1446
|
+
CloseButton.displayName = "Popover.CloseButton";
|
|
1447
|
+
|
|
1448
|
+
// src/popover/PopoverContent.tsx
|
|
1449
|
+
var import_radix_ui9 = require("radix-ui");
|
|
1450
|
+
|
|
1451
|
+
// src/popover/PopoverContent.styles.ts
|
|
1452
|
+
var import_class_variance_authority11 = require("class-variance-authority");
|
|
1453
|
+
var styles = (0, import_class_variance_authority11.cva)(
|
|
1454
|
+
[
|
|
1455
|
+
"rounded-md",
|
|
1456
|
+
"shadow-sm",
|
|
1457
|
+
"focus-visible:outline-hidden focus-visible:u-outline",
|
|
1458
|
+
"max-h-(--radix-popper-available-height) overflow-y-auto"
|
|
1459
|
+
],
|
|
1460
|
+
{
|
|
1461
|
+
variants: {
|
|
1462
|
+
intent: {
|
|
1463
|
+
surface: "bg-surface text-on-surface",
|
|
1464
|
+
main: "bg-main-container text-on-main-container",
|
|
1465
|
+
support: "bg-support-container text-on-support-container",
|
|
1466
|
+
accent: "bg-accent-container text-on-accent-container",
|
|
1467
|
+
basic: "bg-basic-container text-on-basic-container",
|
|
1468
|
+
success: "bg-success-container text-on-success-container",
|
|
1469
|
+
alert: "bg-alert-container text-on-alert-container",
|
|
1470
|
+
danger: "bg-error-container text-on-error-container",
|
|
1471
|
+
info: "bg-info-container text-on-info-container",
|
|
1472
|
+
neutral: "bg-neutral-container text-on-neutral-container"
|
|
1473
|
+
},
|
|
1474
|
+
matchTriggerWidth: {
|
|
1475
|
+
true: "w-(--radix-popper-anchor-width)"
|
|
1476
|
+
},
|
|
1477
|
+
enforceBoundaries: {
|
|
1478
|
+
true: ["max-w-(--radix-popper-available-width)"]
|
|
1479
|
+
},
|
|
1480
|
+
inset: {
|
|
1481
|
+
true: "overflow-hidden",
|
|
1482
|
+
false: "p-lg"
|
|
1483
|
+
},
|
|
1484
|
+
elevation: {
|
|
1485
|
+
dropdown: "z-dropdown",
|
|
1486
|
+
popover: "z-popover"
|
|
1487
|
+
}
|
|
1488
|
+
},
|
|
1489
|
+
compoundVariants: [
|
|
1490
|
+
{
|
|
1491
|
+
inset: false,
|
|
1492
|
+
/**
|
|
1493
|
+
* When there is a close button, padding to the right side must be adjusted to avoid content overlapping with it.
|
|
1494
|
+
*/
|
|
1495
|
+
class: "has-data-[spark-component=popover-close-button]:pr-3xl"
|
|
1496
|
+
},
|
|
1497
|
+
{
|
|
1498
|
+
enforceBoundaries: false,
|
|
1499
|
+
matchTriggerWidth: false,
|
|
1500
|
+
class: "max-w-[min(var(--spacing-sz-384),100vw)]"
|
|
1501
|
+
}
|
|
1502
|
+
],
|
|
1503
|
+
defaultVariants: {
|
|
1504
|
+
matchTriggerWidth: false,
|
|
1505
|
+
enforceBoundaries: false,
|
|
1506
|
+
inset: false,
|
|
1507
|
+
intent: "surface",
|
|
1508
|
+
elevation: "popover"
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
);
|
|
1512
|
+
|
|
1513
|
+
// src/popover/PopoverContent.tsx
|
|
1514
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1515
|
+
var Content = ({
|
|
1516
|
+
// Spark props
|
|
1517
|
+
className,
|
|
1518
|
+
children,
|
|
1519
|
+
matchTriggerWidth = false,
|
|
1520
|
+
// Radix props
|
|
1521
|
+
align = "center",
|
|
1522
|
+
arrowPadding = 16,
|
|
1523
|
+
// In order not to overlap the arrow on the rounded corners of the popover.
|
|
1524
|
+
asChild = false,
|
|
1525
|
+
avoidCollisions = true,
|
|
1526
|
+
"aria-labelledby": ariaLabelledBy,
|
|
1527
|
+
collisionBoundary,
|
|
1528
|
+
collisionPadding = 0,
|
|
1529
|
+
hideWhenDetached = false,
|
|
1530
|
+
side = "bottom",
|
|
1531
|
+
sideOffset = 8,
|
|
1532
|
+
sticky = "partial",
|
|
1533
|
+
inset = false,
|
|
1534
|
+
elevation = "popover",
|
|
1535
|
+
ref,
|
|
1536
|
+
...rest
|
|
1537
|
+
}) => {
|
|
1538
|
+
const { headerId, intent } = usePopover();
|
|
1539
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1540
|
+
import_radix_ui9.Popover.Content,
|
|
1541
|
+
{
|
|
1542
|
+
"aria-labelledby": headerId || ariaLabelledBy,
|
|
1543
|
+
className: styles({
|
|
1544
|
+
enforceBoundaries: !!collisionBoundary,
|
|
1545
|
+
matchTriggerWidth,
|
|
1546
|
+
inset,
|
|
1547
|
+
elevation,
|
|
1548
|
+
intent,
|
|
1549
|
+
className
|
|
1550
|
+
}),
|
|
1551
|
+
"data-spark-component": "popover-content",
|
|
1552
|
+
ref,
|
|
1553
|
+
...{
|
|
1554
|
+
align,
|
|
1555
|
+
arrowPadding,
|
|
1556
|
+
asChild,
|
|
1557
|
+
avoidCollisions,
|
|
1558
|
+
collisionBoundary,
|
|
1559
|
+
collisionPadding,
|
|
1560
|
+
hideWhenDetached,
|
|
1561
|
+
side,
|
|
1562
|
+
sideOffset,
|
|
1563
|
+
sticky
|
|
1564
|
+
},
|
|
1565
|
+
...rest,
|
|
1566
|
+
children
|
|
1567
|
+
}
|
|
1568
|
+
);
|
|
1569
|
+
};
|
|
1570
|
+
Content.displayName = "Popover.Content";
|
|
1571
|
+
|
|
1572
|
+
// src/popover/PopoverHeader.tsx
|
|
1573
|
+
var import_class_variance_authority12 = require("class-variance-authority");
|
|
1574
|
+
var import_react8 = require("react");
|
|
1575
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1576
|
+
var Header = ({ children, className, ref, ...rest }) => {
|
|
1577
|
+
const id = `${ID_PREFIX}-header-${(0, import_react8.useId)()}`;
|
|
1578
|
+
const { setHeaderId } = usePopover();
|
|
1579
|
+
(0, import_react8.useLayoutEffect)(() => {
|
|
1580
|
+
setHeaderId(id);
|
|
1581
|
+
return () => setHeaderId(null);
|
|
1582
|
+
}, [id, setHeaderId]);
|
|
1583
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("header", { id, ref, className: (0, import_class_variance_authority12.cx)("mb-md text-headline-2", className), ...rest, children });
|
|
1584
|
+
};
|
|
1585
|
+
Header.displayName = "Popover.Header";
|
|
1586
|
+
|
|
1587
|
+
// src/popover/PopoverPortal.tsx
|
|
1588
|
+
var import_radix_ui10 = require("radix-ui");
|
|
1589
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1590
|
+
var Portal = ({ children, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_radix_ui10.Popover.Portal, { ...rest, children });
|
|
1591
|
+
Portal.displayName = "Popover.Portal";
|
|
1592
|
+
|
|
1593
|
+
// src/popover/PopoverTrigger.tsx
|
|
1594
|
+
var import_radix_ui11 = require("radix-ui");
|
|
1595
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1596
|
+
var Trigger = ({ asChild = false, children, ref, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1597
|
+
import_radix_ui11.Popover.Trigger,
|
|
1598
|
+
{
|
|
1599
|
+
"data-spark-component": "popover-trigger",
|
|
1600
|
+
ref,
|
|
1601
|
+
asChild,
|
|
1602
|
+
...rest,
|
|
1603
|
+
children
|
|
1604
|
+
}
|
|
1605
|
+
);
|
|
1606
|
+
Trigger.displayName = "Popover.Trigger";
|
|
1607
|
+
|
|
1608
|
+
// src/popover/index.ts
|
|
1609
|
+
var Popover2 = Object.assign(Popover, {
|
|
1610
|
+
Anchor,
|
|
1611
|
+
Arrow,
|
|
1612
|
+
CloseButton,
|
|
1613
|
+
Content,
|
|
1614
|
+
Header,
|
|
1615
|
+
Portal,
|
|
1616
|
+
Trigger
|
|
1617
|
+
});
|
|
1618
|
+
Popover2.displayName = "Popover";
|
|
1619
|
+
Anchor.displayName = "Popover.Anchor";
|
|
1620
|
+
Arrow.displayName = "Popover.Arrow";
|
|
1621
|
+
CloseButton.displayName = "Popover.CloseButton";
|
|
1622
|
+
Content.displayName = "Popover.Content";
|
|
1623
|
+
Header.displayName = "Popover.Header";
|
|
1624
|
+
Portal.displayName = "Popover.Portal";
|
|
1625
|
+
Trigger.displayName = "Popover.Trigger";
|
|
1626
|
+
|
|
1627
|
+
// src/tabs/TabsPopoverAbstraction.tsx
|
|
1628
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1629
|
+
var TabsPopoverContext = (0, import_react9.createContext)(void 0);
|
|
1630
|
+
var useTabsPopoverContext = () => {
|
|
1631
|
+
const context = (0, import_react9.useContext)(TabsPopoverContext);
|
|
1632
|
+
if (!context) {
|
|
1633
|
+
throw new Error("TabsPopover components must be used within TabsPopover");
|
|
1634
|
+
}
|
|
1635
|
+
return context;
|
|
1636
|
+
};
|
|
1637
|
+
var TabsPopoverTrigger = (0, import_react9.forwardRef)(
|
|
1638
|
+
({ "aria-label": ariaLabel, children: iconChildren, ...triggerProps }, forwardedRef) => {
|
|
1639
|
+
const { popoverTriggerRef } = useTabsPopoverContext();
|
|
1640
|
+
const mergedRef = (0, import_use_merge_refs.useMergeRefs)(forwardedRef, popoverTriggerRef);
|
|
1641
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Popover2.Trigger, { asChild: true, ...triggerProps, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1642
|
+
IconButton,
|
|
1643
|
+
{
|
|
1644
|
+
ref: mergedRef,
|
|
1645
|
+
size: "sm",
|
|
1646
|
+
intent: "surfaceInverse",
|
|
1647
|
+
design: "ghost",
|
|
1648
|
+
"aria-label": ariaLabel,
|
|
1649
|
+
tabIndex: -1,
|
|
1650
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Icon, { children: iconChildren || /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_MoreMenuHorizontal.MoreMenuHorizontal, {}) })
|
|
1651
|
+
}
|
|
1652
|
+
) });
|
|
1653
|
+
}
|
|
1654
|
+
);
|
|
1655
|
+
TabsPopoverTrigger.displayName = "Popover.Trigger";
|
|
1656
|
+
var TabsPopoverContent = (0, import_react9.forwardRef)(
|
|
1657
|
+
({ side, align = "start", className, ...contentProps }, ref) => {
|
|
1658
|
+
const { popoverSide } = useTabsPopoverContext();
|
|
1659
|
+
const mergedClassName = (0, import_class_variance_authority13.cx)("gap-sm flex flex-col", className);
|
|
1660
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1661
|
+
Popover2.Content,
|
|
1662
|
+
{
|
|
1663
|
+
ref,
|
|
1664
|
+
...contentProps,
|
|
1665
|
+
side: side ?? popoverSide,
|
|
1666
|
+
align,
|
|
1667
|
+
className: mergedClassName
|
|
1668
|
+
}
|
|
1669
|
+
);
|
|
1670
|
+
}
|
|
1671
|
+
);
|
|
1672
|
+
TabsPopoverContent.displayName = "Popover.Content";
|
|
1673
|
+
var Popover3 = ({ popoverSide, popoverTriggerRef, children }) => {
|
|
1674
|
+
const contextValue = (0, import_react9.useMemo)(
|
|
1675
|
+
() => ({ popoverSide, popoverTriggerRef }),
|
|
1676
|
+
[popoverSide, popoverTriggerRef]
|
|
1677
|
+
);
|
|
1678
|
+
const PopoverWrapper = ((props) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TabsPopoverContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Popover2, { ...props, children: props.children }) }));
|
|
1679
|
+
const PopoverComponent = Object.assign(PopoverWrapper, Popover2, {
|
|
1680
|
+
Content: TabsPopoverContent,
|
|
1681
|
+
Trigger: TabsPopoverTrigger
|
|
1682
|
+
});
|
|
1683
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TabsPopoverContext.Provider, { value: contextValue, children: children(PopoverComponent) });
|
|
1684
|
+
};
|
|
1685
|
+
Popover3.displayName = "Popover";
|
|
1686
|
+
|
|
1687
|
+
// src/tabs/TabsTrigger.styles.ts
|
|
1688
|
+
var import_internal_utils10 = require("@spark-ui/internal-utils");
|
|
1689
|
+
var import_class_variance_authority14 = require("class-variance-authority");
|
|
1690
|
+
var triggerVariants = (0, import_class_variance_authority14.cva)(
|
|
1281
1691
|
[
|
|
1282
1692
|
"px-md",
|
|
1283
1693
|
"relative flex flex-none items-center",
|
|
@@ -1299,7 +1709,7 @@ var triggerVariants = (0, import_class_variance_authority8.cva)(
|
|
|
1299
1709
|
* Change the color scheme of the tabs
|
|
1300
1710
|
* @default basic
|
|
1301
1711
|
*/
|
|
1302
|
-
intent: (0,
|
|
1712
|
+
intent: (0, import_internal_utils10.makeVariants)({
|
|
1303
1713
|
main: ["data-[state=active]:text-main data-[state=active]:after:bg-main"],
|
|
1304
1714
|
support: ["data-[state=active]:text-support data-[state=active]:after:bg-support"],
|
|
1305
1715
|
basic: ["data-[state=active]:text-basic data-[state=active]:after:bg-basic"]
|
|
@@ -1312,17 +1722,33 @@ var triggerVariants = (0, import_class_variance_authority8.cva)(
|
|
|
1312
1722
|
xs: ["h-sz-32 min-w-sz-32 text-caption"],
|
|
1313
1723
|
sm: ["h-sz-36 min-w-sz-36 text-body-2"],
|
|
1314
1724
|
md: ["h-sz-40 min-w-sz-40 text-body-1"]
|
|
1725
|
+
},
|
|
1726
|
+
hasMenu: {
|
|
1727
|
+
true: "pr-3xl"
|
|
1728
|
+
},
|
|
1729
|
+
orientation: {
|
|
1730
|
+
horizontal: "",
|
|
1731
|
+
vertical: ""
|
|
1315
1732
|
}
|
|
1316
1733
|
},
|
|
1734
|
+
compoundVariants: [
|
|
1735
|
+
{
|
|
1736
|
+
hasMenu: true,
|
|
1737
|
+
orientation: "vertical",
|
|
1738
|
+
class: "w-full"
|
|
1739
|
+
}
|
|
1740
|
+
],
|
|
1317
1741
|
defaultVariants: {
|
|
1318
1742
|
intent: "basic",
|
|
1319
|
-
size: "md"
|
|
1743
|
+
size: "md",
|
|
1744
|
+
hasMenu: false,
|
|
1745
|
+
orientation: "horizontal"
|
|
1320
1746
|
}
|
|
1321
1747
|
}
|
|
1322
1748
|
);
|
|
1323
1749
|
|
|
1324
1750
|
// src/tabs/TabsTrigger.tsx
|
|
1325
|
-
var
|
|
1751
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1326
1752
|
var TabsTrigger = ({
|
|
1327
1753
|
/**
|
|
1328
1754
|
* Default Radix Primitive values
|
|
@@ -1334,28 +1760,56 @@ var TabsTrigger = ({
|
|
|
1334
1760
|
children,
|
|
1335
1761
|
className,
|
|
1336
1762
|
ref,
|
|
1763
|
+
onKeyDown,
|
|
1764
|
+
renderMenu,
|
|
1337
1765
|
...rest
|
|
1338
1766
|
}) => {
|
|
1339
|
-
const { intent, size } = useTabsContext();
|
|
1340
|
-
const
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1767
|
+
const { intent, size, orientation } = useTabsContext();
|
|
1768
|
+
const popoverTriggerRef = (0, import_react10.useRef)(null);
|
|
1769
|
+
const tabsTriggerRef = (0, import_react10.useRef)(null);
|
|
1770
|
+
const mergedRef = (0, import_use_merge_refs2.useMergeRefs)(ref, tabsTriggerRef);
|
|
1771
|
+
const handleKeyDown = (e) => {
|
|
1772
|
+
if (e.key === "F10" && e.shiftKey && renderMenu && popoverTriggerRef.current) {
|
|
1773
|
+
e.preventDefault();
|
|
1774
|
+
popoverTriggerRef.current.click();
|
|
1775
|
+
}
|
|
1776
|
+
onKeyDown?.(e);
|
|
1777
|
+
};
|
|
1778
|
+
const hasMenu = !!renderMenu;
|
|
1779
|
+
const popoverSide = orientation === "vertical" ? "right" : "bottom";
|
|
1780
|
+
const trigger = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1781
|
+
import_radix_ui12.Tabs.Trigger,
|
|
1347
1782
|
{
|
|
1348
1783
|
"data-spark-component": "tabs-trigger",
|
|
1349
|
-
ref,
|
|
1350
|
-
className: triggerVariants({
|
|
1784
|
+
ref: mergedRef,
|
|
1785
|
+
className: triggerVariants({
|
|
1786
|
+
intent,
|
|
1787
|
+
size,
|
|
1788
|
+
hasMenu,
|
|
1789
|
+
orientation: orientation ?? "horizontal",
|
|
1790
|
+
className
|
|
1791
|
+
}),
|
|
1351
1792
|
asChild,
|
|
1352
1793
|
disabled,
|
|
1353
1794
|
value,
|
|
1354
|
-
onFocus:
|
|
1795
|
+
onFocus: ({ target }) => target.scrollIntoView({
|
|
1796
|
+
behavior: "smooth",
|
|
1797
|
+
block: "nearest",
|
|
1798
|
+
inline: "nearest"
|
|
1799
|
+
}),
|
|
1800
|
+
onKeyDown: handleKeyDown,
|
|
1801
|
+
"aria-haspopup": hasMenu ? "true" : void 0,
|
|
1355
1802
|
...rest,
|
|
1356
1803
|
children
|
|
1357
1804
|
}
|
|
1358
1805
|
);
|
|
1806
|
+
if (!hasMenu) {
|
|
1807
|
+
return trigger;
|
|
1808
|
+
}
|
|
1809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: orientation === "vertical" ? "relative w-full" : "relative", children: [
|
|
1810
|
+
trigger,
|
|
1811
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "right-md mr-md pointer-events-auto absolute top-1/2 -translate-y-1/2", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Popover3, { popoverSide, popoverTriggerRef, children: (PopoverAbstraction) => renderMenu?.({ Popover: PopoverAbstraction }) }) })
|
|
1812
|
+
] });
|
|
1359
1813
|
};
|
|
1360
1814
|
TabsTrigger.displayName = "Tabs.Trigger";
|
|
1361
1815
|
|