@terminal-blueprint/react 0.1.0 → 0.1.2
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 +369 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -4
- package/dist/index.d.ts +58 -4
- package/dist/index.js +362 -104
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -29,6 +29,7 @@ __export(index_exports, {
|
|
|
29
29
|
Checkbox: () => Checkbox,
|
|
30
30
|
CodeBlock: () => CodeBlock,
|
|
31
31
|
CornerBrackets: () => CornerBrackets,
|
|
32
|
+
FileUpload: () => FileUpload,
|
|
32
33
|
Input: () => Input,
|
|
33
34
|
Modal: () => Modal,
|
|
34
35
|
NavDropdown: () => NavDropdown,
|
|
@@ -43,6 +44,7 @@ __export(index_exports, {
|
|
|
43
44
|
SelectTrigger: () => SelectTrigger,
|
|
44
45
|
Sidenav: () => Sidenav,
|
|
45
46
|
Skeleton: () => Skeleton,
|
|
47
|
+
Slider: () => Slider,
|
|
46
48
|
Spinner: () => Spinner,
|
|
47
49
|
Table: () => Table,
|
|
48
50
|
Tabs: () => Tabs,
|
|
@@ -222,6 +224,7 @@ function CardRoot({
|
|
|
222
224
|
brackets = false,
|
|
223
225
|
pulse = false,
|
|
224
226
|
hoverable = false,
|
|
227
|
+
href,
|
|
225
228
|
className,
|
|
226
229
|
children,
|
|
227
230
|
ref,
|
|
@@ -237,10 +240,12 @@ function CardRoot({
|
|
|
237
240
|
brackets && "tb-card--bracketed",
|
|
238
241
|
pulse && "tb-card--pulse",
|
|
239
242
|
hoverable && "tb-card--hoverable",
|
|
243
|
+
href && "tb-card--link",
|
|
240
244
|
className
|
|
241
245
|
),
|
|
242
246
|
...props,
|
|
243
247
|
children: [
|
|
248
|
+
href && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { className: "tb-card__link", href, "aria-hidden": "true", tabIndex: -1 }),
|
|
244
249
|
brackets && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
245
250
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "tb-card__bracket tb-card__bracket--tl" }),
|
|
246
251
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "tb-card__bracket tb-card__bracket--tr" }),
|
|
@@ -650,6 +655,7 @@ function ModalRoot({
|
|
|
650
655
|
closeOnBackdrop = true,
|
|
651
656
|
hideCloseButton = false,
|
|
652
657
|
portalTarget,
|
|
658
|
+
variant,
|
|
653
659
|
children,
|
|
654
660
|
className,
|
|
655
661
|
ref
|
|
@@ -735,7 +741,7 @@ function ModalRoot({
|
|
|
735
741
|
"aria-modal": "true",
|
|
736
742
|
"aria-labelledby": titleId,
|
|
737
743
|
"aria-describedby": descId,
|
|
738
|
-
className: cn("tb-modal", className),
|
|
744
|
+
className: cn("tb-modal", variant && `tb-modal--${variant}`, className),
|
|
739
745
|
tabIndex: -1,
|
|
740
746
|
onKeyDown: handleKeyDown,
|
|
741
747
|
children: [
|
|
@@ -1388,22 +1394,81 @@ function Progress({
|
|
|
1388
1394
|
);
|
|
1389
1395
|
}
|
|
1390
1396
|
|
|
1391
|
-
// src/components/
|
|
1397
|
+
// src/components/Slider.tsx
|
|
1398
|
+
var import_react13 = require("react");
|
|
1392
1399
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1400
|
+
function Slider({
|
|
1401
|
+
value,
|
|
1402
|
+
onChange,
|
|
1403
|
+
min = 0,
|
|
1404
|
+
max = 100,
|
|
1405
|
+
step = 1,
|
|
1406
|
+
variant = "default",
|
|
1407
|
+
label,
|
|
1408
|
+
showValue = false,
|
|
1409
|
+
disabled = false,
|
|
1410
|
+
className,
|
|
1411
|
+
ref
|
|
1412
|
+
}) {
|
|
1413
|
+
const id = (0, import_react13.useId)();
|
|
1414
|
+
const percent = (value - min) / (max - min) * 100;
|
|
1415
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
1416
|
+
"div",
|
|
1417
|
+
{
|
|
1418
|
+
className: cn(
|
|
1419
|
+
"tb-slider",
|
|
1420
|
+
variant !== "default" && `tb-slider--${variant}`,
|
|
1421
|
+
disabled && "tb-slider--disabled",
|
|
1422
|
+
className
|
|
1423
|
+
),
|
|
1424
|
+
children: [
|
|
1425
|
+
(label || showValue) && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "tb-slider__header", children: [
|
|
1426
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("label", { className: "tb-slider__label", htmlFor: id, children: label }),
|
|
1427
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "tb-slider__value", children: value })
|
|
1428
|
+
] }),
|
|
1429
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1430
|
+
"input",
|
|
1431
|
+
{
|
|
1432
|
+
ref,
|
|
1433
|
+
id,
|
|
1434
|
+
type: "range",
|
|
1435
|
+
className: "tb-slider__input",
|
|
1436
|
+
style: { "--slider-percent": `${percent}%` },
|
|
1437
|
+
value,
|
|
1438
|
+
min,
|
|
1439
|
+
max,
|
|
1440
|
+
step,
|
|
1441
|
+
disabled,
|
|
1442
|
+
onChange: (e) => onChange(Number(e.target.value)),
|
|
1443
|
+
"aria-label": label,
|
|
1444
|
+
"aria-valuenow": value,
|
|
1445
|
+
"aria-valuemin": min,
|
|
1446
|
+
"aria-valuemax": max
|
|
1447
|
+
}
|
|
1448
|
+
)
|
|
1449
|
+
]
|
|
1450
|
+
}
|
|
1451
|
+
);
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
// src/components/Battery.tsx
|
|
1455
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1393
1456
|
function Battery({
|
|
1394
1457
|
value,
|
|
1395
1458
|
total = 10,
|
|
1396
1459
|
variant = "default",
|
|
1397
1460
|
animated = false,
|
|
1398
1461
|
label,
|
|
1462
|
+
showValue = false,
|
|
1399
1463
|
className
|
|
1400
1464
|
}) {
|
|
1401
1465
|
const clampedValue = Math.max(0, Math.min(total, value));
|
|
1402
|
-
|
|
1466
|
+
const percent = Math.round(clampedValue / total * 100);
|
|
1467
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
1403
1468
|
"div",
|
|
1404
1469
|
{
|
|
1405
1470
|
className: cn(
|
|
1406
|
-
"tb-battery",
|
|
1471
|
+
"tb-battery tb-battery--inline",
|
|
1407
1472
|
variant !== "default" && `tb-battery--${variant}`,
|
|
1408
1473
|
animated && "tb-battery--animated",
|
|
1409
1474
|
className
|
|
@@ -1414,19 +1479,20 @@ function Battery({
|
|
|
1414
1479
|
"aria-valuemax": total,
|
|
1415
1480
|
"aria-label": label,
|
|
1416
1481
|
children: [
|
|
1417
|
-
label && /* @__PURE__ */ (0,
|
|
1418
|
-
/* @__PURE__ */ (0,
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1482
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "tb-battery__label", children: label }),
|
|
1483
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "tb-battery__track", children: Array.from({ length: total }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1484
|
+
"div",
|
|
1485
|
+
{
|
|
1486
|
+
className: cn(
|
|
1487
|
+
"tb-battery__segment",
|
|
1488
|
+
i < clampedValue && "tb-battery__segment--filled"
|
|
1489
|
+
)
|
|
1490
|
+
},
|
|
1491
|
+
i
|
|
1492
|
+
)) }),
|
|
1493
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "tb-battery__value", children: [
|
|
1494
|
+
percent,
|
|
1495
|
+
"%"
|
|
1430
1496
|
] })
|
|
1431
1497
|
]
|
|
1432
1498
|
}
|
|
@@ -1434,7 +1500,7 @@ function Battery({
|
|
|
1434
1500
|
}
|
|
1435
1501
|
|
|
1436
1502
|
// src/components/BatteryInline.tsx
|
|
1437
|
-
var
|
|
1503
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1438
1504
|
function BatteryInline({
|
|
1439
1505
|
value,
|
|
1440
1506
|
total = 10,
|
|
@@ -1446,11 +1512,12 @@ function BatteryInline({
|
|
|
1446
1512
|
}) {
|
|
1447
1513
|
const clampedValue = Math.max(0, Math.min(total, value));
|
|
1448
1514
|
const percent = Math.round(clampedValue / total * 100);
|
|
1449
|
-
return /* @__PURE__ */ (0,
|
|
1515
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
1450
1516
|
"div",
|
|
1451
1517
|
{
|
|
1452
1518
|
className: cn(
|
|
1453
1519
|
"tb-battery tb-battery--inline",
|
|
1520
|
+
variant !== "default" && `tb-battery--${variant}`,
|
|
1454
1521
|
animated && "tb-battery--animated",
|
|
1455
1522
|
className
|
|
1456
1523
|
),
|
|
@@ -1460,20 +1527,18 @@ function BatteryInline({
|
|
|
1460
1527
|
"aria-valuemax": total,
|
|
1461
1528
|
"aria-label": label,
|
|
1462
1529
|
children: [
|
|
1463
|
-
label && /* @__PURE__ */ (0,
|
|
1464
|
-
/* @__PURE__ */ (0,
|
|
1530
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "tb-battery__label", children: label }),
|
|
1531
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "tb-battery__track", children: Array.from({ length: total }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
1465
1532
|
"div",
|
|
1466
1533
|
{
|
|
1467
1534
|
className: cn(
|
|
1468
1535
|
"tb-battery__segment",
|
|
1469
|
-
i < clampedValue && "tb-battery__segment--filled"
|
|
1470
|
-
i < clampedValue && variant !== "default" && `tb-battery__segment--${variant}`
|
|
1536
|
+
i < clampedValue && "tb-battery__segment--filled"
|
|
1471
1537
|
)
|
|
1472
1538
|
},
|
|
1473
1539
|
i
|
|
1474
1540
|
)) }),
|
|
1475
|
-
/* @__PURE__ */ (0,
|
|
1476
|
-
showValue && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "tb-battery__value", children: [
|
|
1541
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { className: "tb-battery__value", children: [
|
|
1477
1542
|
percent,
|
|
1478
1543
|
"%"
|
|
1479
1544
|
] })
|
|
@@ -1483,7 +1548,7 @@ function BatteryInline({
|
|
|
1483
1548
|
}
|
|
1484
1549
|
|
|
1485
1550
|
// src/components/Table.tsx
|
|
1486
|
-
var
|
|
1551
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1487
1552
|
function getCellValue(row, accessor) {
|
|
1488
1553
|
if (typeof accessor === "function") return accessor(row);
|
|
1489
1554
|
return row[accessor];
|
|
@@ -1494,9 +1559,9 @@ function Table({
|
|
|
1494
1559
|
onRowClick,
|
|
1495
1560
|
className
|
|
1496
1561
|
}) {
|
|
1497
|
-
return /* @__PURE__ */ (0,
|
|
1498
|
-
/* @__PURE__ */ (0,
|
|
1499
|
-
/* @__PURE__ */ (0,
|
|
1562
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: cn("tb-table__wrapper", className), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("table", { className: "tb-table", children: [
|
|
1563
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("thead", { className: "tb-table__head", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("tr", { className: "tb-table__row", children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("th", { className: "tb-table__th", children: col.header }, col.id)) }) }),
|
|
1564
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("tbody", { className: "tb-table__body", children: data.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1500
1565
|
"tr",
|
|
1501
1566
|
{
|
|
1502
1567
|
className: cn(
|
|
@@ -1506,7 +1571,7 @@ function Table({
|
|
|
1506
1571
|
onClick: onRowClick ? () => onRowClick(row) : void 0,
|
|
1507
1572
|
children: columns.map((col) => {
|
|
1508
1573
|
const value = getCellValue(row, col.accessor);
|
|
1509
|
-
return /* @__PURE__ */ (0,
|
|
1574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("td", { className: "tb-table__td", children: col.cell ? col.cell(value, row) : value }, col.id);
|
|
1510
1575
|
})
|
|
1511
1576
|
},
|
|
1512
1577
|
rowIndex
|
|
@@ -1515,7 +1580,7 @@ function Table({
|
|
|
1515
1580
|
}
|
|
1516
1581
|
|
|
1517
1582
|
// src/components/Skeleton.tsx
|
|
1518
|
-
var
|
|
1583
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1519
1584
|
function Skeleton({
|
|
1520
1585
|
variant = "text",
|
|
1521
1586
|
width,
|
|
@@ -1528,7 +1593,7 @@ function Skeleton({
|
|
|
1528
1593
|
height: typeof height === "number" ? `${height}px` : height
|
|
1529
1594
|
};
|
|
1530
1595
|
if (variant === "text" && lines > 1) {
|
|
1531
|
-
return /* @__PURE__ */ (0,
|
|
1596
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: cn("tb-skeleton__group", className), children: Array.from({ length: lines }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1532
1597
|
"div",
|
|
1533
1598
|
{
|
|
1534
1599
|
className: cn(
|
|
@@ -1540,7 +1605,7 @@ function Skeleton({
|
|
|
1540
1605
|
i
|
|
1541
1606
|
)) });
|
|
1542
1607
|
}
|
|
1543
|
-
return /* @__PURE__ */ (0,
|
|
1608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1544
1609
|
"div",
|
|
1545
1610
|
{
|
|
1546
1611
|
className: cn(
|
|
@@ -1554,13 +1619,13 @@ function Skeleton({
|
|
|
1554
1619
|
}
|
|
1555
1620
|
|
|
1556
1621
|
// src/components/Spinner.tsx
|
|
1557
|
-
var
|
|
1622
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1558
1623
|
function Spinner({
|
|
1559
1624
|
variant = "multi-square",
|
|
1560
1625
|
size = "md",
|
|
1561
1626
|
className
|
|
1562
1627
|
}) {
|
|
1563
|
-
return /* @__PURE__ */ (0,
|
|
1628
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1564
1629
|
"span",
|
|
1565
1630
|
{
|
|
1566
1631
|
className: cn(
|
|
@@ -1571,19 +1636,19 @@ function Spinner({
|
|
|
1571
1636
|
),
|
|
1572
1637
|
role: "status",
|
|
1573
1638
|
"aria-label": "Loading",
|
|
1574
|
-
children: variant === "multi-square" && /* @__PURE__ */ (0,
|
|
1575
|
-
/* @__PURE__ */ (0,
|
|
1576
|
-
/* @__PURE__ */ (0,
|
|
1577
|
-
/* @__PURE__ */ (0,
|
|
1578
|
-
/* @__PURE__ */ (0,
|
|
1579
|
-
/* @__PURE__ */ (0,
|
|
1639
|
+
children: variant === "multi-square" && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
1640
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "tb-spinner__square" }),
|
|
1641
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "tb-spinner__square" }),
|
|
1642
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "tb-spinner__square" }),
|
|
1643
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "tb-spinner__square" }),
|
|
1644
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "tb-spinner__square" })
|
|
1580
1645
|
] })
|
|
1581
1646
|
}
|
|
1582
1647
|
);
|
|
1583
1648
|
}
|
|
1584
1649
|
|
|
1585
1650
|
// src/components/Pagination.tsx
|
|
1586
|
-
var
|
|
1651
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1587
1652
|
function getPageRange(page, totalPages, siblingCount) {
|
|
1588
1653
|
const totalSlots = siblingCount * 2 + 5;
|
|
1589
1654
|
if (totalPages <= totalSlots) {
|
|
@@ -1616,8 +1681,8 @@ function Pagination({
|
|
|
1616
1681
|
className
|
|
1617
1682
|
}) {
|
|
1618
1683
|
const pages = getPageRange(page, totalPages, siblingCount);
|
|
1619
|
-
return /* @__PURE__ */ (0,
|
|
1620
|
-
/* @__PURE__ */ (0,
|
|
1684
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("nav", { className: cn("tb-pagination", className), "aria-label": "Pagination", children: [
|
|
1685
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1621
1686
|
"button",
|
|
1622
1687
|
{
|
|
1623
1688
|
className: "tb-pagination__btn tb-pagination__btn--prev",
|
|
@@ -1628,7 +1693,7 @@ function Pagination({
|
|
|
1628
1693
|
}
|
|
1629
1694
|
),
|
|
1630
1695
|
pages.map(
|
|
1631
|
-
(p, i) => p === "ellipsis" ? /* @__PURE__ */ (0,
|
|
1696
|
+
(p, i) => p === "ellipsis" ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "tb-pagination__ellipsis", children: "..." }, `ellipsis-${i}`) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1632
1697
|
"button",
|
|
1633
1698
|
{
|
|
1634
1699
|
className: cn(
|
|
@@ -1642,7 +1707,7 @@ function Pagination({
|
|
|
1642
1707
|
p
|
|
1643
1708
|
)
|
|
1644
1709
|
),
|
|
1645
|
-
/* @__PURE__ */ (0,
|
|
1710
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1646
1711
|
"button",
|
|
1647
1712
|
{
|
|
1648
1713
|
className: "tb-pagination__btn tb-pagination__btn--next",
|
|
@@ -1656,7 +1721,7 @@ function Pagination({
|
|
|
1656
1721
|
}
|
|
1657
1722
|
|
|
1658
1723
|
// src/components/Breadcrumbs.tsx
|
|
1659
|
-
var
|
|
1724
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
1660
1725
|
function Breadcrumbs({
|
|
1661
1726
|
items,
|
|
1662
1727
|
separator = "/",
|
|
@@ -1664,10 +1729,10 @@ function Breadcrumbs({
|
|
|
1664
1729
|
className
|
|
1665
1730
|
}) {
|
|
1666
1731
|
const LinkComponent = linkComponent || "a";
|
|
1667
|
-
return /* @__PURE__ */ (0,
|
|
1732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("nav", { className: cn("tb-breadcrumbs", className), "aria-label": "Breadcrumb", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("ol", { className: "tb-breadcrumbs__list", children: items.map((item, i) => {
|
|
1668
1733
|
const isLast = i === items.length - 1;
|
|
1669
|
-
return /* @__PURE__ */ (0,
|
|
1670
|
-
item.href && !isLast ? /* @__PURE__ */ (0,
|
|
1734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("li", { className: "tb-breadcrumbs__item", children: [
|
|
1735
|
+
item.href && !isLast ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(LinkComponent, { href: item.href, className: "tb-breadcrumbs__link", children: item.label }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
1671
1736
|
"span",
|
|
1672
1737
|
{
|
|
1673
1738
|
className: "tb-breadcrumbs__current",
|
|
@@ -1675,14 +1740,14 @@ function Breadcrumbs({
|
|
|
1675
1740
|
children: item.label
|
|
1676
1741
|
}
|
|
1677
1742
|
),
|
|
1678
|
-
!isLast && /* @__PURE__ */ (0,
|
|
1743
|
+
!isLast && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "tb-breadcrumbs__separator", "aria-hidden": "true", children: separator })
|
|
1679
1744
|
] }, i);
|
|
1680
1745
|
}) }) });
|
|
1681
1746
|
}
|
|
1682
1747
|
|
|
1683
1748
|
// src/components/Toolbar.tsx
|
|
1684
|
-
var
|
|
1685
|
-
var
|
|
1749
|
+
var import_react14 = require("react");
|
|
1750
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
1686
1751
|
function ToolbarSelect({
|
|
1687
1752
|
options,
|
|
1688
1753
|
value: controlledValue,
|
|
@@ -1692,12 +1757,12 @@ function ToolbarSelect({
|
|
|
1692
1757
|
minWidth,
|
|
1693
1758
|
className
|
|
1694
1759
|
}) {
|
|
1695
|
-
const [internalValue, setInternalValue] = (0,
|
|
1696
|
-
const [open, setOpen] = (0,
|
|
1697
|
-
const ref = (0,
|
|
1760
|
+
const [internalValue, setInternalValue] = (0, import_react14.useState)(defaultValue ?? options[0]?.value ?? "");
|
|
1761
|
+
const [open, setOpen] = (0, import_react14.useState)(false);
|
|
1762
|
+
const ref = (0, import_react14.useRef)(null);
|
|
1698
1763
|
const value = controlledValue ?? internalValue;
|
|
1699
1764
|
const activeOption = options.find((o) => o.value === value);
|
|
1700
|
-
(0,
|
|
1765
|
+
(0, import_react14.useEffect)(() => {
|
|
1701
1766
|
function handleClick(e) {
|
|
1702
1767
|
if (ref.current && !ref.current.contains(e.target)) {
|
|
1703
1768
|
setOpen(false);
|
|
@@ -1711,13 +1776,13 @@ function ToolbarSelect({
|
|
|
1711
1776
|
onChange?.(opt.value);
|
|
1712
1777
|
setOpen(false);
|
|
1713
1778
|
}
|
|
1714
|
-
return /* @__PURE__ */ (0,
|
|
1779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
1715
1780
|
"div",
|
|
1716
1781
|
{
|
|
1717
1782
|
ref,
|
|
1718
1783
|
className: cn("tb-toolbar__select", open && "tb-toolbar__select--open", className),
|
|
1719
1784
|
children: [
|
|
1720
|
-
/* @__PURE__ */ (0,
|
|
1785
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
1721
1786
|
"button",
|
|
1722
1787
|
{
|
|
1723
1788
|
type: "button",
|
|
@@ -1728,20 +1793,19 @@ function ToolbarSelect({
|
|
|
1728
1793
|
setOpen(!open);
|
|
1729
1794
|
},
|
|
1730
1795
|
children: [
|
|
1731
|
-
/* @__PURE__ */ (0,
|
|
1732
|
-
/* @__PURE__ */ (0,
|
|
1796
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { children: activeOption?.label ?? "" }),
|
|
1797
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "tb-toolbar__chevron" })
|
|
1733
1798
|
]
|
|
1734
1799
|
}
|
|
1735
1800
|
),
|
|
1736
|
-
/* @__PURE__ */ (0,
|
|
1801
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: cn("tb-toolbar__dropdown", dropDown && "tb-toolbar__dropdown--down"), children: options.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
1737
1802
|
"div",
|
|
1738
1803
|
{
|
|
1739
1804
|
className: cn("tb-toolbar__option", opt.value === value && "tb-toolbar__option--active"),
|
|
1740
|
-
style: { fontFamily: opt.value },
|
|
1741
1805
|
onClick: () => select(opt),
|
|
1742
1806
|
children: [
|
|
1743
1807
|
opt.label,
|
|
1744
|
-
opt.meta && /* @__PURE__ */ (0,
|
|
1808
|
+
opt.meta && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "tb-toolbar__option-meta", children: opt.meta })
|
|
1745
1809
|
]
|
|
1746
1810
|
},
|
|
1747
1811
|
opt.value
|
|
@@ -1751,13 +1815,13 @@ function ToolbarSelect({
|
|
|
1751
1815
|
);
|
|
1752
1816
|
}
|
|
1753
1817
|
function ToolbarLabel({ children, className, ...props }) {
|
|
1754
|
-
return /* @__PURE__ */ (0,
|
|
1818
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: cn("tb-toolbar__label", className), ...props, children });
|
|
1755
1819
|
}
|
|
1756
1820
|
function ToolbarDivider({ className, ...props }) {
|
|
1757
|
-
return /* @__PURE__ */ (0,
|
|
1821
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: cn("tb-toolbar__divider", className), ...props });
|
|
1758
1822
|
}
|
|
1759
1823
|
function ToolbarRoot({ position, fixed = false, children, className, ref, ...props }) {
|
|
1760
|
-
return /* @__PURE__ */ (0,
|
|
1824
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
1761
1825
|
"div",
|
|
1762
1826
|
{
|
|
1763
1827
|
ref,
|
|
@@ -1778,10 +1842,199 @@ var Toolbar = Object.assign(ToolbarRoot, {
|
|
|
1778
1842
|
Divider: ToolbarDivider
|
|
1779
1843
|
});
|
|
1780
1844
|
|
|
1845
|
+
// src/components/FileUpload.tsx
|
|
1846
|
+
var import_react15 = require("react");
|
|
1847
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1848
|
+
function formatSize(bytes) {
|
|
1849
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
1850
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
1851
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
1852
|
+
}
|
|
1853
|
+
function isImage(file) {
|
|
1854
|
+
return file.type.startsWith("image/");
|
|
1855
|
+
}
|
|
1856
|
+
function FileUpload({
|
|
1857
|
+
onChange,
|
|
1858
|
+
value,
|
|
1859
|
+
accept,
|
|
1860
|
+
multiple = false,
|
|
1861
|
+
maxSize,
|
|
1862
|
+
compact = false,
|
|
1863
|
+
preview = false,
|
|
1864
|
+
label,
|
|
1865
|
+
placeholder,
|
|
1866
|
+
hint,
|
|
1867
|
+
error: errorProp,
|
|
1868
|
+
icon,
|
|
1869
|
+
disabled = false,
|
|
1870
|
+
className,
|
|
1871
|
+
ref
|
|
1872
|
+
}) {
|
|
1873
|
+
const autoId = (0, import_react15.useId)();
|
|
1874
|
+
const inputRef = (0, import_react15.useRef)(null);
|
|
1875
|
+
const [dragging, setDragging] = (0, import_react15.useState)(false);
|
|
1876
|
+
const [files, setFiles] = (0, import_react15.useState)([]);
|
|
1877
|
+
const [internalError, setInternalError] = (0, import_react15.useState)();
|
|
1878
|
+
const error = errorProp ?? internalError;
|
|
1879
|
+
const displayFiles = value ? value.map((f) => ({ file: f, preview: preview && isImage(f) ? URL.createObjectURL(f) : void 0 })) : files;
|
|
1880
|
+
const processFiles = (0, import_react15.useCallback)(
|
|
1881
|
+
(incoming) => {
|
|
1882
|
+
const arr = Array.from(incoming);
|
|
1883
|
+
setInternalError(void 0);
|
|
1884
|
+
if (maxSize) {
|
|
1885
|
+
const tooBig = arr.find((f) => f.size > maxSize);
|
|
1886
|
+
if (tooBig) {
|
|
1887
|
+
setInternalError(`${tooBig.name} exceeds ${formatSize(maxSize)}`);
|
|
1888
|
+
return;
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
const newFiles = arr.map((f) => ({
|
|
1892
|
+
file: f,
|
|
1893
|
+
preview: preview && isImage(f) ? URL.createObjectURL(f) : void 0
|
|
1894
|
+
}));
|
|
1895
|
+
if (multiple) {
|
|
1896
|
+
const merged = [...files, ...newFiles];
|
|
1897
|
+
setFiles(merged);
|
|
1898
|
+
onChange?.(merged.map((f) => f.file));
|
|
1899
|
+
} else {
|
|
1900
|
+
files.forEach((f) => f.preview && URL.revokeObjectURL(f.preview));
|
|
1901
|
+
setFiles(newFiles.slice(0, 1));
|
|
1902
|
+
onChange?.(newFiles.slice(0, 1).map((f) => f.file));
|
|
1903
|
+
}
|
|
1904
|
+
},
|
|
1905
|
+
[files, maxSize, multiple, onChange, preview]
|
|
1906
|
+
);
|
|
1907
|
+
const handleChange = (0, import_react15.useCallback)(
|
|
1908
|
+
(e) => {
|
|
1909
|
+
if (e.target.files?.length) {
|
|
1910
|
+
processFiles(e.target.files);
|
|
1911
|
+
}
|
|
1912
|
+
e.target.value = "";
|
|
1913
|
+
},
|
|
1914
|
+
[processFiles]
|
|
1915
|
+
);
|
|
1916
|
+
const handleDragOver = (0, import_react15.useCallback)(
|
|
1917
|
+
(e) => {
|
|
1918
|
+
e.preventDefault();
|
|
1919
|
+
if (!disabled) setDragging(true);
|
|
1920
|
+
},
|
|
1921
|
+
[disabled]
|
|
1922
|
+
);
|
|
1923
|
+
const handleDragLeave = (0, import_react15.useCallback)((e) => {
|
|
1924
|
+
e.preventDefault();
|
|
1925
|
+
setDragging(false);
|
|
1926
|
+
}, []);
|
|
1927
|
+
const handleDrop = (0, import_react15.useCallback)(
|
|
1928
|
+
(e) => {
|
|
1929
|
+
e.preventDefault();
|
|
1930
|
+
setDragging(false);
|
|
1931
|
+
if (!disabled && e.dataTransfer.files.length) {
|
|
1932
|
+
processFiles(e.dataTransfer.files);
|
|
1933
|
+
}
|
|
1934
|
+
},
|
|
1935
|
+
[disabled, processFiles]
|
|
1936
|
+
);
|
|
1937
|
+
const removeFile = (0, import_react15.useCallback)(
|
|
1938
|
+
(index) => {
|
|
1939
|
+
const removed = files[index];
|
|
1940
|
+
if (removed?.preview) URL.revokeObjectURL(removed.preview);
|
|
1941
|
+
const next = files.filter((_, i) => i !== index);
|
|
1942
|
+
setFiles(next);
|
|
1943
|
+
onChange?.(next.map((f) => f.file));
|
|
1944
|
+
},
|
|
1945
|
+
[files, onChange]
|
|
1946
|
+
);
|
|
1947
|
+
const setRef = (0, import_react15.useCallback)(
|
|
1948
|
+
(el) => {
|
|
1949
|
+
inputRef.current = el;
|
|
1950
|
+
if (typeof ref === "function") ref(el);
|
|
1951
|
+
else if (ref) ref.current = el;
|
|
1952
|
+
},
|
|
1953
|
+
[ref]
|
|
1954
|
+
);
|
|
1955
|
+
const defaultPlaceholder = compact ? "Choose file" : "Drop files here or click to browse";
|
|
1956
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
1957
|
+
"div",
|
|
1958
|
+
{
|
|
1959
|
+
className: cn(
|
|
1960
|
+
"tb-file-upload",
|
|
1961
|
+
compact && "tb-file-upload--compact",
|
|
1962
|
+
className
|
|
1963
|
+
),
|
|
1964
|
+
children: [
|
|
1965
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("label", { htmlFor: autoId, className: "tb-label", children: label }),
|
|
1966
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
1967
|
+
"div",
|
|
1968
|
+
{
|
|
1969
|
+
className: cn(
|
|
1970
|
+
"tb-file-upload__zone",
|
|
1971
|
+
dragging && "tb-file-upload__zone--drag",
|
|
1972
|
+
error && "tb-file-upload__zone--error",
|
|
1973
|
+
disabled && "tb-file-upload__zone--disabled"
|
|
1974
|
+
),
|
|
1975
|
+
onDragOver: handleDragOver,
|
|
1976
|
+
onDragLeave: handleDragLeave,
|
|
1977
|
+
onDrop: handleDrop,
|
|
1978
|
+
children: [
|
|
1979
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1980
|
+
"input",
|
|
1981
|
+
{
|
|
1982
|
+
ref: setRef,
|
|
1983
|
+
id: autoId,
|
|
1984
|
+
type: "file",
|
|
1985
|
+
className: "tb-file-upload__input",
|
|
1986
|
+
accept,
|
|
1987
|
+
multiple,
|
|
1988
|
+
disabled,
|
|
1989
|
+
onChange: handleChange,
|
|
1990
|
+
"aria-describedby": error ? `${autoId}-error` : void 0
|
|
1991
|
+
}
|
|
1992
|
+
),
|
|
1993
|
+
compact ? /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("span", { className: "tb-btn tb-btn--sm", children: [
|
|
1994
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "tb-btn__icon", children: icon }),
|
|
1995
|
+
placeholder ?? defaultPlaceholder
|
|
1996
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
|
|
1997
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "tb-file-upload__icon", "aria-hidden": "true", children: icon ?? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "material-symbols-outlined", children: "upload_file" }) }),
|
|
1998
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "tb-file-upload__text", children: placeholder ?? defaultPlaceholder }),
|
|
1999
|
+
hint && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "tb-file-upload__hint-text", children: hint })
|
|
2000
|
+
] })
|
|
2001
|
+
]
|
|
2002
|
+
}
|
|
2003
|
+
),
|
|
2004
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { id: `${autoId}-error`, className: "tb-file-upload__error", role: "alert", children: error }),
|
|
2005
|
+
displayFiles.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "tb-file-upload__files", children: displayFiles.map((f, i) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "tb-file-upload__file", children: [
|
|
2006
|
+
f.preview ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
2007
|
+
"img",
|
|
2008
|
+
{
|
|
2009
|
+
src: f.preview,
|
|
2010
|
+
alt: f.file.name,
|
|
2011
|
+
className: "tb-file-upload__preview"
|
|
2012
|
+
}
|
|
2013
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "tb-file-upload__file-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "material-symbols-outlined", children: isImage(f.file) ? "image" : "description" }) }),
|
|
2014
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "tb-file-upload__file-info", children: [
|
|
2015
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "tb-file-upload__file-name", children: f.file.name }),
|
|
2016
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "tb-file-upload__file-size", children: formatSize(f.file.size) })
|
|
2017
|
+
] }),
|
|
2018
|
+
!value && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
2019
|
+
"button",
|
|
2020
|
+
{
|
|
2021
|
+
type: "button",
|
|
2022
|
+
className: "tb-file-upload__file-remove",
|
|
2023
|
+
onClick: () => removeFile(i),
|
|
2024
|
+
"aria-label": `Remove ${f.file.name}`,
|
|
2025
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "material-symbols-outlined", children: "close" })
|
|
2026
|
+
}
|
|
2027
|
+
)
|
|
2028
|
+
] }, `${f.file.name}-${i}`)) })
|
|
2029
|
+
]
|
|
2030
|
+
}
|
|
2031
|
+
);
|
|
2032
|
+
}
|
|
2033
|
+
|
|
1781
2034
|
// src/components/Sidenav/Sidenav.tsx
|
|
1782
|
-
var
|
|
1783
|
-
var
|
|
1784
|
-
var SidenavContext = (0,
|
|
2035
|
+
var import_react16 = require("react");
|
|
2036
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
2037
|
+
var SidenavContext = (0, import_react16.createContext)({
|
|
1785
2038
|
iconPosition: "left",
|
|
1786
2039
|
borderSide: "left"
|
|
1787
2040
|
});
|
|
@@ -1793,7 +2046,7 @@ function SidenavRoot({
|
|
|
1793
2046
|
ref,
|
|
1794
2047
|
...props
|
|
1795
2048
|
}) {
|
|
1796
|
-
return /* @__PURE__ */ (0,
|
|
2049
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(SidenavContext.Provider, { value: { iconPosition, borderSide }, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1797
2050
|
"nav",
|
|
1798
2051
|
{
|
|
1799
2052
|
ref,
|
|
@@ -1817,7 +2070,7 @@ function Item({
|
|
|
1817
2070
|
...props
|
|
1818
2071
|
}) {
|
|
1819
2072
|
const Component = as || "a";
|
|
1820
|
-
return /* @__PURE__ */ (0,
|
|
2073
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1821
2074
|
Component,
|
|
1822
2075
|
{
|
|
1823
2076
|
ref,
|
|
@@ -1832,7 +2085,7 @@ function Item({
|
|
|
1832
2085
|
);
|
|
1833
2086
|
}
|
|
1834
2087
|
function Icon({ className, ref, ...props }) {
|
|
1835
|
-
return /* @__PURE__ */ (0,
|
|
2088
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1836
2089
|
"span",
|
|
1837
2090
|
{
|
|
1838
2091
|
ref,
|
|
@@ -1852,7 +2105,7 @@ function Group({
|
|
|
1852
2105
|
ref,
|
|
1853
2106
|
...props
|
|
1854
2107
|
}) {
|
|
1855
|
-
const [internalOpen, setInternalOpen] = (0,
|
|
2108
|
+
const [internalOpen, setInternalOpen] = (0, import_react16.useState)(defaultOpen);
|
|
1856
2109
|
const isControlled = controlledOpen !== void 0;
|
|
1857
2110
|
const isOpen = isControlled ? controlledOpen : internalOpen;
|
|
1858
2111
|
function toggle() {
|
|
@@ -1860,7 +2113,7 @@ function Group({
|
|
|
1860
2113
|
if (!isControlled) setInternalOpen(next);
|
|
1861
2114
|
onOpenChange?.(next);
|
|
1862
2115
|
}
|
|
1863
|
-
return /* @__PURE__ */ (0,
|
|
2116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
1864
2117
|
"div",
|
|
1865
2118
|
{
|
|
1866
2119
|
ref,
|
|
@@ -1871,7 +2124,7 @@ function Group({
|
|
|
1871
2124
|
),
|
|
1872
2125
|
...props,
|
|
1873
2126
|
children: [
|
|
1874
|
-
/* @__PURE__ */ (0,
|
|
2127
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
1875
2128
|
"button",
|
|
1876
2129
|
{
|
|
1877
2130
|
type: "button",
|
|
@@ -1879,13 +2132,13 @@ function Group({
|
|
|
1879
2132
|
onClick: toggle,
|
|
1880
2133
|
"aria-expanded": isOpen,
|
|
1881
2134
|
children: [
|
|
1882
|
-
icon && /* @__PURE__ */ (0,
|
|
2135
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "tb-sidenav__icon", children: icon }),
|
|
1883
2136
|
label,
|
|
1884
|
-
/* @__PURE__ */ (0,
|
|
2137
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "tb-sidenav__group-chevron material-symbols-outlined", "aria-hidden": "true", children: "expand_more" })
|
|
1885
2138
|
]
|
|
1886
2139
|
}
|
|
1887
2140
|
),
|
|
1888
|
-
/* @__PURE__ */ (0,
|
|
2141
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "tb-sidenav__group-content", children })
|
|
1889
2142
|
]
|
|
1890
2143
|
}
|
|
1891
2144
|
);
|
|
@@ -1897,38 +2150,38 @@ var Sidenav = Object.assign(SidenavRoot, {
|
|
|
1897
2150
|
});
|
|
1898
2151
|
|
|
1899
2152
|
// src/components/CodeBlock.tsx
|
|
1900
|
-
var
|
|
1901
|
-
var
|
|
2153
|
+
var import_react17 = require("react");
|
|
2154
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
1902
2155
|
function CodeBlock({ children, copyText, className, ref, ...props }) {
|
|
1903
|
-
const [copied, setCopied] = (0,
|
|
1904
|
-
const contentRef = (0,
|
|
2156
|
+
const [copied, setCopied] = (0, import_react17.useState)(false);
|
|
2157
|
+
const contentRef = (0, import_react17.useRef)(null);
|
|
1905
2158
|
async function handleCopy() {
|
|
1906
2159
|
const text = copyText ?? contentRef.current?.textContent ?? "";
|
|
1907
2160
|
await navigator.clipboard.writeText(text);
|
|
1908
2161
|
setCopied(true);
|
|
1909
2162
|
setTimeout(() => setCopied(false), 2e3);
|
|
1910
2163
|
}
|
|
1911
|
-
return /* @__PURE__ */ (0,
|
|
1912
|
-
/* @__PURE__ */ (0,
|
|
1913
|
-
/* @__PURE__ */ (0,
|
|
2164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { ref, className: cn("tb-code-block", className), ...props, children: [
|
|
2165
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { ref: contentRef, children }),
|
|
2166
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
1914
2167
|
"button",
|
|
1915
2168
|
{
|
|
1916
2169
|
type: "button",
|
|
1917
2170
|
className: cn("tb-code-block__copy", copied && "tb-code-block__copy--copied"),
|
|
1918
2171
|
onClick: handleCopy,
|
|
1919
2172
|
"aria-label": copied ? "Copied" : "Copy to clipboard",
|
|
1920
|
-
children: /* @__PURE__ */ (0,
|
|
2173
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "material-symbols-outlined", style: { fontSize: 14 }, children: copied ? "check" : "content_copy" })
|
|
1921
2174
|
}
|
|
1922
2175
|
)
|
|
1923
2176
|
] });
|
|
1924
2177
|
}
|
|
1925
2178
|
|
|
1926
2179
|
// src/components/ThemeProvider.tsx
|
|
1927
|
-
var
|
|
1928
|
-
var
|
|
1929
|
-
var ThemeContext = (0,
|
|
2180
|
+
var import_react18 = require("react");
|
|
2181
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
2182
|
+
var ThemeContext = (0, import_react18.createContext)(null);
|
|
1930
2183
|
function useTheme() {
|
|
1931
|
-
const ctx = (0,
|
|
2184
|
+
const ctx = (0, import_react18.useContext)(ThemeContext);
|
|
1932
2185
|
if (!ctx) throw new Error("useTheme must be used within <ThemeProvider>");
|
|
1933
2186
|
return ctx;
|
|
1934
2187
|
}
|
|
@@ -1943,29 +2196,29 @@ function ThemeProvider({
|
|
|
1943
2196
|
}) {
|
|
1944
2197
|
const isThemeControlled = controlledTheme !== void 0;
|
|
1945
2198
|
const isContrastControlled = controlledContrast !== void 0;
|
|
1946
|
-
const [internalTheme, setInternalTheme] = (0,
|
|
1947
|
-
const [internalContrast, setInternalContrast] = (0,
|
|
2199
|
+
const [internalTheme, setInternalTheme] = (0, import_react18.useState)(defaultTheme);
|
|
2200
|
+
const [internalContrast, setInternalContrast] = (0, import_react18.useState)(defaultContrast);
|
|
1948
2201
|
const theme = isThemeControlled ? controlledTheme : internalTheme;
|
|
1949
2202
|
const contrast = isContrastControlled ? controlledContrast : internalContrast;
|
|
1950
|
-
const setTheme = (0,
|
|
2203
|
+
const setTheme = (0, import_react18.useCallback)(
|
|
1951
2204
|
(next) => {
|
|
1952
2205
|
if (!isThemeControlled) setInternalTheme(next);
|
|
1953
2206
|
onThemeChange?.(next);
|
|
1954
2207
|
},
|
|
1955
2208
|
[isThemeControlled, onThemeChange]
|
|
1956
2209
|
);
|
|
1957
|
-
const setContrast = (0,
|
|
2210
|
+
const setContrast = (0, import_react18.useCallback)(
|
|
1958
2211
|
(next) => {
|
|
1959
2212
|
if (!isContrastControlled) setInternalContrast(next);
|
|
1960
2213
|
onContrastChange?.(next);
|
|
1961
2214
|
},
|
|
1962
2215
|
[isContrastControlled, onContrastChange]
|
|
1963
2216
|
);
|
|
1964
|
-
const toggleTheme = (0,
|
|
2217
|
+
const toggleTheme = (0, import_react18.useCallback)(
|
|
1965
2218
|
() => setTheme(theme === "dark" ? "light" : "dark"),
|
|
1966
2219
|
[theme, setTheme]
|
|
1967
2220
|
);
|
|
1968
|
-
(0,
|
|
2221
|
+
(0, import_react18.useEffect)(() => {
|
|
1969
2222
|
const root = document.documentElement;
|
|
1970
2223
|
root.setAttribute("data-theme", theme);
|
|
1971
2224
|
if (contrast === "high") {
|
|
@@ -1974,23 +2227,23 @@ function ThemeProvider({
|
|
|
1974
2227
|
root.removeAttribute("data-contrast");
|
|
1975
2228
|
}
|
|
1976
2229
|
}, [theme, contrast]);
|
|
1977
|
-
return /* @__PURE__ */ (0,
|
|
2230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ThemeContext.Provider, { value: { theme, setTheme, contrast, setContrast, toggleTheme }, children });
|
|
1978
2231
|
}
|
|
1979
2232
|
|
|
1980
2233
|
// src/hooks/useDisclosure.ts
|
|
1981
|
-
var
|
|
2234
|
+
var import_react19 = require("react");
|
|
1982
2235
|
function useDisclosure(options = {}) {
|
|
1983
2236
|
const { defaultOpen = false, onOpen: onOpenCallback, onClose: onCloseCallback } = options;
|
|
1984
|
-
const [isOpen, setIsOpen] = (0,
|
|
1985
|
-
const onOpen = (0,
|
|
2237
|
+
const [isOpen, setIsOpen] = (0, import_react19.useState)(defaultOpen);
|
|
2238
|
+
const onOpen = (0, import_react19.useCallback)(() => {
|
|
1986
2239
|
setIsOpen(true);
|
|
1987
2240
|
onOpenCallback?.();
|
|
1988
2241
|
}, [onOpenCallback]);
|
|
1989
|
-
const onClose = (0,
|
|
2242
|
+
const onClose = (0, import_react19.useCallback)(() => {
|
|
1990
2243
|
setIsOpen(false);
|
|
1991
2244
|
onCloseCallback?.();
|
|
1992
2245
|
}, [onCloseCallback]);
|
|
1993
|
-
const onToggle = (0,
|
|
2246
|
+
const onToggle = (0, import_react19.useCallback)(() => {
|
|
1994
2247
|
if (isOpen) {
|
|
1995
2248
|
onClose();
|
|
1996
2249
|
} else {
|
|
@@ -2001,7 +2254,7 @@ function useDisclosure(options = {}) {
|
|
|
2001
2254
|
}
|
|
2002
2255
|
|
|
2003
2256
|
// src/hooks/useFocusTrap.ts
|
|
2004
|
-
var
|
|
2257
|
+
var import_react20 = require("react");
|
|
2005
2258
|
var FOCUSABLE_SELECTOR = [
|
|
2006
2259
|
"a[href]",
|
|
2007
2260
|
"button:not([disabled])",
|
|
@@ -2011,8 +2264,8 @@ var FOCUSABLE_SELECTOR = [
|
|
|
2011
2264
|
'[tabindex]:not([tabindex="-1"])'
|
|
2012
2265
|
].join(", ");
|
|
2013
2266
|
function useFocusTrap(ref, active) {
|
|
2014
|
-
const previouslyFocusedRef = (0,
|
|
2015
|
-
(0,
|
|
2267
|
+
const previouslyFocusedRef = (0, import_react20.useRef)(null);
|
|
2268
|
+
(0, import_react20.useEffect)(() => {
|
|
2016
2269
|
if (!active || !ref.current) return;
|
|
2017
2270
|
previouslyFocusedRef.current = document.activeElement;
|
|
2018
2271
|
const container = ref.current;
|
|
@@ -2049,13 +2302,13 @@ function useFocusTrap(ref, active) {
|
|
|
2049
2302
|
}
|
|
2050
2303
|
|
|
2051
2304
|
// src/hooks/useKeyboardNav.ts
|
|
2052
|
-
var
|
|
2305
|
+
var import_react21 = require("react");
|
|
2053
2306
|
function useKeyboardNav(items, options = {}) {
|
|
2054
2307
|
const { orientation = "vertical", loop = true, onSelect } = options;
|
|
2055
|
-
const [activeIndex, setActiveIndex] = (0,
|
|
2308
|
+
const [activeIndex, setActiveIndex] = (0, import_react21.useState)(0);
|
|
2056
2309
|
const prevKey = orientation === "vertical" ? "ArrowUp" : "ArrowLeft";
|
|
2057
2310
|
const nextKey = orientation === "vertical" ? "ArrowDown" : "ArrowRight";
|
|
2058
|
-
const onKeyDown = (0,
|
|
2311
|
+
const onKeyDown = (0, import_react21.useCallback)(
|
|
2059
2312
|
(e) => {
|
|
2060
2313
|
const list = items.current;
|
|
2061
2314
|
if (!list || list.length === 0) return;
|
|
@@ -2104,10 +2357,10 @@ function useKeyboardNav(items, options = {}) {
|
|
|
2104
2357
|
}
|
|
2105
2358
|
|
|
2106
2359
|
// src/hooks/useReducedMotion.ts
|
|
2107
|
-
var
|
|
2360
|
+
var import_react22 = require("react");
|
|
2108
2361
|
function useReducedMotion() {
|
|
2109
|
-
const [reduced, setReduced] = (0,
|
|
2110
|
-
(0,
|
|
2362
|
+
const [reduced, setReduced] = (0, import_react22.useState)(false);
|
|
2363
|
+
(0, import_react22.useEffect)(() => {
|
|
2111
2364
|
const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
2112
2365
|
setReduced(mq.matches);
|
|
2113
2366
|
const handler = (e) => setReduced(e.matches);
|
|
@@ -2118,9 +2371,9 @@ function useReducedMotion() {
|
|
|
2118
2371
|
}
|
|
2119
2372
|
|
|
2120
2373
|
// src/hooks/useMergedRef.ts
|
|
2121
|
-
var
|
|
2374
|
+
var import_react23 = require("react");
|
|
2122
2375
|
function useMergedRef(...refs) {
|
|
2123
|
-
return (0,
|
|
2376
|
+
return (0, import_react23.useCallback)((node) => {
|
|
2124
2377
|
refs.forEach((ref) => {
|
|
2125
2378
|
if (typeof ref === "function") ref(node);
|
|
2126
2379
|
else if (ref) ref.current = node;
|
|
@@ -2138,6 +2391,7 @@ function useMergedRef(...refs) {
|
|
|
2138
2391
|
Checkbox,
|
|
2139
2392
|
CodeBlock,
|
|
2140
2393
|
CornerBrackets,
|
|
2394
|
+
FileUpload,
|
|
2141
2395
|
Input,
|
|
2142
2396
|
Modal,
|
|
2143
2397
|
NavDropdown,
|
|
@@ -2152,6 +2406,7 @@ function useMergedRef(...refs) {
|
|
|
2152
2406
|
SelectTrigger,
|
|
2153
2407
|
Sidenav,
|
|
2154
2408
|
Skeleton,
|
|
2409
|
+
Slider,
|
|
2155
2410
|
Spinner,
|
|
2156
2411
|
Table,
|
|
2157
2412
|
Tabs,
|