@classic-homes/theme-react 0.1.57 → 0.1.58
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.d.mts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +39 -36
- package/dist/index.mjs +43 -36
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -261,6 +261,17 @@ interface DataPanelProps {
|
|
|
261
261
|
actions?: DataPanelAction[];
|
|
262
262
|
/** Size constraints */
|
|
263
263
|
constraints?: PanelConstraints;
|
|
264
|
+
/**
|
|
265
|
+
* Length (px) of the collapsed tab along its edge. Fixed rather than
|
|
266
|
+
* content-sized; raise it for longer titles. Defaults to 220.
|
|
267
|
+
*/
|
|
268
|
+
tabWidth?: number;
|
|
269
|
+
/**
|
|
270
|
+
* Distance (px) of the collapsed tab from its pinned edge. Use it to clear
|
|
271
|
+
* fixed app chrome — a sticky header, a toolbar — that would otherwise cover
|
|
272
|
+
* the tab. Defaults to 0.
|
|
273
|
+
*/
|
|
274
|
+
tabInset?: number;
|
|
264
275
|
/** Disable close button */
|
|
265
276
|
disableClose?: boolean;
|
|
266
277
|
/** Disable resize functionality */
|
|
@@ -358,6 +369,18 @@ interface DataPanelTabProps {
|
|
|
358
369
|
offset?: number;
|
|
359
370
|
/** Called with the new offset after the tab is dragged along its edge */
|
|
360
371
|
onOffsetChange?: (offset: number) => void;
|
|
372
|
+
/**
|
|
373
|
+
* Length (px) of the tab along its edge. Fixed rather than content-sized so
|
|
374
|
+
* the tab's geometry is pure pixel math in every browser; raise it for longer
|
|
375
|
+
* labels. Defaults to 220.
|
|
376
|
+
*/
|
|
377
|
+
tabWidth?: number;
|
|
378
|
+
/**
|
|
379
|
+
* Distance (px) from the pinned edge. Use it to clear fixed app chrome — a
|
|
380
|
+
* sticky header, a toolbar — that would otherwise cover the tab. Defaults
|
|
381
|
+
* to 0 (flush with the edge).
|
|
382
|
+
*/
|
|
383
|
+
tabInset?: number;
|
|
361
384
|
className?: string;
|
|
362
385
|
}
|
|
363
386
|
declare const DataPanelTab: React$1.ForwardRefExoticComponent<DataPanelTabProps & React$1.RefAttributes<HTMLDivElement>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -261,6 +261,17 @@ interface DataPanelProps {
|
|
|
261
261
|
actions?: DataPanelAction[];
|
|
262
262
|
/** Size constraints */
|
|
263
263
|
constraints?: PanelConstraints;
|
|
264
|
+
/**
|
|
265
|
+
* Length (px) of the collapsed tab along its edge. Fixed rather than
|
|
266
|
+
* content-sized; raise it for longer titles. Defaults to 220.
|
|
267
|
+
*/
|
|
268
|
+
tabWidth?: number;
|
|
269
|
+
/**
|
|
270
|
+
* Distance (px) of the collapsed tab from its pinned edge. Use it to clear
|
|
271
|
+
* fixed app chrome — a sticky header, a toolbar — that would otherwise cover
|
|
272
|
+
* the tab. Defaults to 0.
|
|
273
|
+
*/
|
|
274
|
+
tabInset?: number;
|
|
264
275
|
/** Disable close button */
|
|
265
276
|
disableClose?: boolean;
|
|
266
277
|
/** Disable resize functionality */
|
|
@@ -358,6 +369,18 @@ interface DataPanelTabProps {
|
|
|
358
369
|
offset?: number;
|
|
359
370
|
/** Called with the new offset after the tab is dragged along its edge */
|
|
360
371
|
onOffsetChange?: (offset: number) => void;
|
|
372
|
+
/**
|
|
373
|
+
* Length (px) of the tab along its edge. Fixed rather than content-sized so
|
|
374
|
+
* the tab's geometry is pure pixel math in every browser; raise it for longer
|
|
375
|
+
* labels. Defaults to 220.
|
|
376
|
+
*/
|
|
377
|
+
tabWidth?: number;
|
|
378
|
+
/**
|
|
379
|
+
* Distance (px) from the pinned edge. Use it to clear fixed app chrome — a
|
|
380
|
+
* sticky header, a toolbar — that would otherwise cover the tab. Defaults
|
|
381
|
+
* to 0 (flush with the edge).
|
|
382
|
+
*/
|
|
383
|
+
tabInset?: number;
|
|
361
384
|
className?: string;
|
|
362
385
|
}
|
|
363
386
|
declare const DataPanelTab: React$1.ForwardRefExoticComponent<DataPanelTabProps & React$1.RefAttributes<HTMLDivElement>>;
|
package/dist/index.js
CHANGED
|
@@ -1329,20 +1329,22 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1329
1329
|
disableClose = false,
|
|
1330
1330
|
offset = 0,
|
|
1331
1331
|
onOffsetChange,
|
|
1332
|
+
tabWidth = import_data_panel_core.DEFAULT_TAB_WIDTH,
|
|
1333
|
+
tabInset = 0,
|
|
1332
1334
|
className
|
|
1333
1335
|
}, ref) => {
|
|
1334
1336
|
const isVertical = edge === "left" || edge === "right";
|
|
1335
1337
|
const positionClasses = {
|
|
1336
|
-
//
|
|
1337
|
-
//
|
|
1338
|
-
//
|
|
1339
|
-
//
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
bottom: "bottom-0 left-1/2 rounded-t-lg border-b-0"
|
|
1338
|
+
// Border classes are in the chip's pre-rotation frame: its bottom rotates
|
|
1339
|
+
// to the attached (edge) side and its top corners to the viewport-facing
|
|
1340
|
+
// corners, so both side edges drop the bottom border and round the top.
|
|
1341
|
+
// The anchored axis is set inline (see insetStyle) so tabInset can move it.
|
|
1342
|
+
left: "top-1/2 rounded-t-lg border-b-0",
|
|
1343
|
+
right: "top-1/2 rounded-t-lg border-b-0",
|
|
1344
|
+
top: "left-1/2 rounded-b-lg border-t-0",
|
|
1345
|
+
bottom: "left-1/2 rounded-t-lg border-b-0"
|
|
1345
1346
|
}[edge];
|
|
1347
|
+
const insetStyle = { [edge]: tabInset };
|
|
1346
1348
|
const innerRef = React14.useRef(null);
|
|
1347
1349
|
const dragRef = React14.useRef({
|
|
1348
1350
|
startX: 0,
|
|
@@ -1354,8 +1356,8 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1354
1356
|
const [dragOffset, setDragOffset] = React14.useState(null);
|
|
1355
1357
|
const effectiveOffset = dragOffset ?? offset;
|
|
1356
1358
|
const draggable = !!onOffsetChange;
|
|
1357
|
-
const
|
|
1358
|
-
const
|
|
1359
|
+
const tabTransform = (0, import_data_panel_core.getTabTransform)(edge, tabWidth, effectiveOffset);
|
|
1360
|
+
const tabBounds = (0, import_data_panel_core.getTabBounds)(edge, tabWidth);
|
|
1359
1361
|
const setRefs = (node) => {
|
|
1360
1362
|
innerRef.current = node;
|
|
1361
1363
|
if (typeof ref === "function") ref(node);
|
|
@@ -1380,13 +1382,11 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1380
1382
|
if (d.pointerId !== e.pointerId || !e.currentTarget.hasPointerCapture(e.pointerId)) return;
|
|
1381
1383
|
const delta = isVertical ? e.clientY - d.startY : e.clientX - d.startX;
|
|
1382
1384
|
if (Math.abs(delta) > 3) d.moved = true;
|
|
1383
|
-
const rect = innerRef.current?.getBoundingClientRect();
|
|
1384
|
-
const tabSize = { width: rect?.width ?? 160, height: rect?.height ?? 48 };
|
|
1385
1385
|
setDragOffset(
|
|
1386
1386
|
(0, import_data_panel_core.constrainTabOffset)(
|
|
1387
1387
|
d.startOffset + delta,
|
|
1388
1388
|
edge,
|
|
1389
|
-
|
|
1389
|
+
tabBounds,
|
|
1390
1390
|
window.innerWidth,
|
|
1391
1391
|
window.innerHeight
|
|
1392
1392
|
)
|
|
@@ -1424,42 +1424,41 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1424
1424
|
};
|
|
1425
1425
|
React14.useEffect(() => {
|
|
1426
1426
|
if (!onOffsetChange || dragOffset !== null) return;
|
|
1427
|
-
const
|
|
1428
|
-
|
|
1429
|
-
const clamped = (0, import_data_panel_core.constrainTabOffset)(
|
|
1430
|
-
offset,
|
|
1431
|
-
edge,
|
|
1432
|
-
{ width: rect.width, height: rect.height },
|
|
1433
|
-
window.innerWidth,
|
|
1434
|
-
window.innerHeight
|
|
1435
|
-
);
|
|
1436
|
-
if (clamped !== offset) onOffsetChange(clamped);
|
|
1437
|
-
const onResize = () => {
|
|
1438
|
-
const r = innerRef.current?.getBoundingClientRect();
|
|
1439
|
-
if (!r) return;
|
|
1440
|
-
const c = (0, import_data_panel_core.constrainTabOffset)(
|
|
1427
|
+
const reclamp = () => {
|
|
1428
|
+
const clamped = (0, import_data_panel_core.constrainTabOffset)(
|
|
1441
1429
|
offset,
|
|
1442
1430
|
edge,
|
|
1443
|
-
|
|
1431
|
+
tabBounds,
|
|
1444
1432
|
window.innerWidth,
|
|
1445
1433
|
window.innerHeight
|
|
1446
1434
|
);
|
|
1447
|
-
if (
|
|
1435
|
+
if (clamped !== offset) onOffsetChange(clamped);
|
|
1448
1436
|
};
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1437
|
+
reclamp();
|
|
1438
|
+
window.addEventListener("resize", reclamp);
|
|
1439
|
+
return () => window.removeEventListener("resize", reclamp);
|
|
1440
|
+
}, [edge, tabWidth, offset, onOffsetChange, dragOffset]);
|
|
1452
1441
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1453
1442
|
"div",
|
|
1454
1443
|
{
|
|
1455
1444
|
ref: setRefs,
|
|
1456
1445
|
className: cn(
|
|
1457
|
-
|
|
1446
|
+
// Same layer as the expanded panel: the tab is the only way to bring
|
|
1447
|
+
// the panel back, so it must never sit under chrome the panel covers.
|
|
1448
|
+
"fixed z-50 flex items-center gap-2 border border-border bg-background px-2.5 py-1.5 shadow-md focus-within:ring-2 focus-within:ring-ring",
|
|
1458
1449
|
draggable && "cursor-grab touch-none active:cursor-grabbing",
|
|
1459
1450
|
positionClasses,
|
|
1460
1451
|
className
|
|
1461
1452
|
),
|
|
1462
|
-
style: {
|
|
1453
|
+
style: {
|
|
1454
|
+
...insetStyle,
|
|
1455
|
+
width: tabWidth,
|
|
1456
|
+
// Side tabs rotate, so they need a fixed thickness for a deterministic
|
|
1457
|
+
// edge hug; top/bottom stay content-height.
|
|
1458
|
+
height: isVertical ? import_data_panel_core.TAB_THICKNESS : void 0,
|
|
1459
|
+
transformOrigin: "0 0",
|
|
1460
|
+
transform: tabTransform
|
|
1461
|
+
},
|
|
1463
1462
|
onPointerDown: handlePointerDown,
|
|
1464
1463
|
onPointerMove: draggable ? handlePointerMove : void 0,
|
|
1465
1464
|
onPointerUp: draggable ? handlePointerUp : void 0,
|
|
@@ -1709,6 +1708,8 @@ var DataPanel = React14.forwardRef(
|
|
|
1709
1708
|
children,
|
|
1710
1709
|
actions = [],
|
|
1711
1710
|
constraints = {},
|
|
1711
|
+
tabWidth = import_data_panel_core.DEFAULT_TAB_WIDTH,
|
|
1712
|
+
tabInset = 0,
|
|
1712
1713
|
disableClose = false,
|
|
1713
1714
|
disableResize = false,
|
|
1714
1715
|
disableDrag = false,
|
|
@@ -2517,7 +2518,9 @@ var DataPanel = React14.forwardRef(
|
|
|
2517
2518
|
onClose: () => handleOpenChange(false),
|
|
2518
2519
|
disableClose,
|
|
2519
2520
|
offset: tabOffset,
|
|
2520
|
-
onOffsetChange: setTabOffset
|
|
2521
|
+
onOffsetChange: setTabOffset,
|
|
2522
|
+
tabWidth,
|
|
2523
|
+
tabInset
|
|
2521
2524
|
}
|
|
2522
2525
|
);
|
|
2523
2526
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -789,6 +789,10 @@ import {
|
|
|
789
789
|
getInitialDetachedPosition,
|
|
790
790
|
isHorizontalEdge,
|
|
791
791
|
constrainTabOffset,
|
|
792
|
+
getTabTransform,
|
|
793
|
+
getTabBounds,
|
|
794
|
+
TAB_THICKNESS,
|
|
795
|
+
DEFAULT_TAB_WIDTH,
|
|
792
796
|
calculateDetachDistance,
|
|
793
797
|
calculatePullOffset,
|
|
794
798
|
calculateDetachedPositionFromPinned,
|
|
@@ -1263,20 +1267,22 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1263
1267
|
disableClose = false,
|
|
1264
1268
|
offset = 0,
|
|
1265
1269
|
onOffsetChange,
|
|
1270
|
+
tabWidth = DEFAULT_TAB_WIDTH,
|
|
1271
|
+
tabInset = 0,
|
|
1266
1272
|
className
|
|
1267
1273
|
}, ref) => {
|
|
1268
1274
|
const isVertical = edge === "left" || edge === "right";
|
|
1269
1275
|
const positionClasses = {
|
|
1270
|
-
//
|
|
1271
|
-
//
|
|
1272
|
-
//
|
|
1273
|
-
//
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
bottom: "bottom-0 left-1/2 rounded-t-lg border-b-0"
|
|
1276
|
+
// Border classes are in the chip's pre-rotation frame: its bottom rotates
|
|
1277
|
+
// to the attached (edge) side and its top corners to the viewport-facing
|
|
1278
|
+
// corners, so both side edges drop the bottom border and round the top.
|
|
1279
|
+
// The anchored axis is set inline (see insetStyle) so tabInset can move it.
|
|
1280
|
+
left: "top-1/2 rounded-t-lg border-b-0",
|
|
1281
|
+
right: "top-1/2 rounded-t-lg border-b-0",
|
|
1282
|
+
top: "left-1/2 rounded-b-lg border-t-0",
|
|
1283
|
+
bottom: "left-1/2 rounded-t-lg border-b-0"
|
|
1279
1284
|
}[edge];
|
|
1285
|
+
const insetStyle = { [edge]: tabInset };
|
|
1280
1286
|
const innerRef = React14.useRef(null);
|
|
1281
1287
|
const dragRef = React14.useRef({
|
|
1282
1288
|
startX: 0,
|
|
@@ -1288,8 +1294,8 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1288
1294
|
const [dragOffset, setDragOffset] = React14.useState(null);
|
|
1289
1295
|
const effectiveOffset = dragOffset ?? offset;
|
|
1290
1296
|
const draggable = !!onOffsetChange;
|
|
1291
|
-
const
|
|
1292
|
-
const
|
|
1297
|
+
const tabTransform = getTabTransform(edge, tabWidth, effectiveOffset);
|
|
1298
|
+
const tabBounds = getTabBounds(edge, tabWidth);
|
|
1293
1299
|
const setRefs = (node) => {
|
|
1294
1300
|
innerRef.current = node;
|
|
1295
1301
|
if (typeof ref === "function") ref(node);
|
|
@@ -1314,13 +1320,11 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1314
1320
|
if (d.pointerId !== e.pointerId || !e.currentTarget.hasPointerCapture(e.pointerId)) return;
|
|
1315
1321
|
const delta = isVertical ? e.clientY - d.startY : e.clientX - d.startX;
|
|
1316
1322
|
if (Math.abs(delta) > 3) d.moved = true;
|
|
1317
|
-
const rect = innerRef.current?.getBoundingClientRect();
|
|
1318
|
-
const tabSize = { width: rect?.width ?? 160, height: rect?.height ?? 48 };
|
|
1319
1323
|
setDragOffset(
|
|
1320
1324
|
constrainTabOffset(
|
|
1321
1325
|
d.startOffset + delta,
|
|
1322
1326
|
edge,
|
|
1323
|
-
|
|
1327
|
+
tabBounds,
|
|
1324
1328
|
window.innerWidth,
|
|
1325
1329
|
window.innerHeight
|
|
1326
1330
|
)
|
|
@@ -1358,42 +1362,41 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1358
1362
|
};
|
|
1359
1363
|
React14.useEffect(() => {
|
|
1360
1364
|
if (!onOffsetChange || dragOffset !== null) return;
|
|
1361
|
-
const
|
|
1362
|
-
|
|
1363
|
-
const clamped = constrainTabOffset(
|
|
1364
|
-
offset,
|
|
1365
|
-
edge,
|
|
1366
|
-
{ width: rect.width, height: rect.height },
|
|
1367
|
-
window.innerWidth,
|
|
1368
|
-
window.innerHeight
|
|
1369
|
-
);
|
|
1370
|
-
if (clamped !== offset) onOffsetChange(clamped);
|
|
1371
|
-
const onResize = () => {
|
|
1372
|
-
const r = innerRef.current?.getBoundingClientRect();
|
|
1373
|
-
if (!r) return;
|
|
1374
|
-
const c = constrainTabOffset(
|
|
1365
|
+
const reclamp = () => {
|
|
1366
|
+
const clamped = constrainTabOffset(
|
|
1375
1367
|
offset,
|
|
1376
1368
|
edge,
|
|
1377
|
-
|
|
1369
|
+
tabBounds,
|
|
1378
1370
|
window.innerWidth,
|
|
1379
1371
|
window.innerHeight
|
|
1380
1372
|
);
|
|
1381
|
-
if (
|
|
1373
|
+
if (clamped !== offset) onOffsetChange(clamped);
|
|
1382
1374
|
};
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1375
|
+
reclamp();
|
|
1376
|
+
window.addEventListener("resize", reclamp);
|
|
1377
|
+
return () => window.removeEventListener("resize", reclamp);
|
|
1378
|
+
}, [edge, tabWidth, offset, onOffsetChange, dragOffset]);
|
|
1386
1379
|
return /* @__PURE__ */ jsxs5(
|
|
1387
1380
|
"div",
|
|
1388
1381
|
{
|
|
1389
1382
|
ref: setRefs,
|
|
1390
1383
|
className: cn(
|
|
1391
|
-
|
|
1384
|
+
// Same layer as the expanded panel: the tab is the only way to bring
|
|
1385
|
+
// the panel back, so it must never sit under chrome the panel covers.
|
|
1386
|
+
"fixed z-50 flex items-center gap-2 border border-border bg-background px-2.5 py-1.5 shadow-md focus-within:ring-2 focus-within:ring-ring",
|
|
1392
1387
|
draggable && "cursor-grab touch-none active:cursor-grabbing",
|
|
1393
1388
|
positionClasses,
|
|
1394
1389
|
className
|
|
1395
1390
|
),
|
|
1396
|
-
style: {
|
|
1391
|
+
style: {
|
|
1392
|
+
...insetStyle,
|
|
1393
|
+
width: tabWidth,
|
|
1394
|
+
// Side tabs rotate, so they need a fixed thickness for a deterministic
|
|
1395
|
+
// edge hug; top/bottom stay content-height.
|
|
1396
|
+
height: isVertical ? TAB_THICKNESS : void 0,
|
|
1397
|
+
transformOrigin: "0 0",
|
|
1398
|
+
transform: tabTransform
|
|
1399
|
+
},
|
|
1397
1400
|
onPointerDown: handlePointerDown,
|
|
1398
1401
|
onPointerMove: draggable ? handlePointerMove : void 0,
|
|
1399
1402
|
onPointerUp: draggable ? handlePointerUp : void 0,
|
|
@@ -1643,6 +1646,8 @@ var DataPanel = React14.forwardRef(
|
|
|
1643
1646
|
children,
|
|
1644
1647
|
actions = [],
|
|
1645
1648
|
constraints = {},
|
|
1649
|
+
tabWidth = DEFAULT_TAB_WIDTH,
|
|
1650
|
+
tabInset = 0,
|
|
1646
1651
|
disableClose = false,
|
|
1647
1652
|
disableResize = false,
|
|
1648
1653
|
disableDrag = false,
|
|
@@ -2451,7 +2456,9 @@ var DataPanel = React14.forwardRef(
|
|
|
2451
2456
|
onClose: () => handleOpenChange(false),
|
|
2452
2457
|
disableClose,
|
|
2453
2458
|
offset: tabOffset,
|
|
2454
|
-
onOffsetChange: setTabOffset
|
|
2459
|
+
onOffsetChange: setTabOffset,
|
|
2460
|
+
tabWidth,
|
|
2461
|
+
tabInset
|
|
2455
2462
|
}
|
|
2456
2463
|
);
|
|
2457
2464
|
}
|