@human-kit/ui 1.1.0 → 1.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.
|
@@ -16,6 +16,16 @@ export type CollapseTransition = {
|
|
|
16
16
|
*/
|
|
17
17
|
setPanel: (panel: HTMLElement | null, content?: HTMLElement | null) => void;
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* The content's size without the rounding `scrollHeight`/`scrollWidth` apply.
|
|
21
|
+
*
|
|
22
|
+
* Those are whole pixels: content 57.5px tall measures 58, so an open panel came out half a pixel
|
|
23
|
+
* taller than the same content laid out without the variable (on the server, before hydration),
|
|
24
|
+
* and everything under it moved when the page hydrated. Within a pixel of the laid-out box the
|
|
25
|
+
* scroll size is only that rounding, so the box's own fractional size is the answer; beyond it the
|
|
26
|
+
* content really overflows its box, and the scroll size is what the panel has to open to.
|
|
27
|
+
*/
|
|
28
|
+
export declare function exactSize(scrollSize: number, boxSize: number): number;
|
|
19
29
|
/**
|
|
20
30
|
* Drives a collapsible panel's enter/exit transitions the way Base UI's Collapsible does:
|
|
21
31
|
* - keeps the content mounted for the full exit animation, then unmounts it (or, with
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { trackMotionEnd } from './motion';
|
|
2
|
+
/**
|
|
3
|
+
* The content's size without the rounding `scrollHeight`/`scrollWidth` apply.
|
|
4
|
+
*
|
|
5
|
+
* Those are whole pixels: content 57.5px tall measures 58, so an open panel came out half a pixel
|
|
6
|
+
* taller than the same content laid out without the variable (on the server, before hydration),
|
|
7
|
+
* and everything under it moved when the page hydrated. Within a pixel of the laid-out box the
|
|
8
|
+
* scroll size is only that rounding, so the box's own fractional size is the answer; beyond it the
|
|
9
|
+
* content really overflows its box, and the scroll size is what the panel has to open to.
|
|
10
|
+
*/
|
|
11
|
+
export function exactSize(scrollSize, boxSize) {
|
|
12
|
+
return Math.abs(scrollSize - boxSize) < 1 ? boxSize : scrollSize;
|
|
13
|
+
}
|
|
2
14
|
/**
|
|
3
15
|
* Drives a collapsible panel's enter/exit transitions the way Base UI's Collapsible does:
|
|
4
16
|
* - keeps the content mounted for the full exit animation, then unmounts it (or, with
|
|
@@ -26,8 +38,8 @@ export function createCollapseTransition(open, forceMount) {
|
|
|
26
38
|
// Freeze the size while collapsing so the exit animates from the open height, not from 0.
|
|
27
39
|
if (!measured || status === 'ending')
|
|
28
40
|
return;
|
|
29
|
-
height = measured.scrollHeight;
|
|
30
|
-
width = measured.scrollWidth;
|
|
41
|
+
height = exactSize(measured.scrollHeight, measured.getBoundingClientRect().height);
|
|
42
|
+
width = exactSize(measured.scrollWidth, measured.getBoundingClientRect().width);
|
|
31
43
|
}
|
|
32
44
|
function cancelRelease() {
|
|
33
45
|
if (releaseFrame !== undefined) {
|
|
@@ -40,6 +40,15 @@
|
|
|
40
40
|
// its width outwards; the physical shift direction depends on the layout
|
|
41
41
|
// direction, resolved once the element mounts.
|
|
42
42
|
const handleRtl = $derived(element ? isRightToLeft() : false);
|
|
43
|
+
// A column pinned to the inline end is held by that edge: it is the table's, or the next
|
|
44
|
+
// pinned column's, which paints over it — half the handle was covered and the drag found
|
|
45
|
+
// nothing there. Its free edge is the inline start, so the handle moves there and the drag
|
|
46
|
+
// reads mirrored: pulling it towards the start widens the column.
|
|
47
|
+
const atInlineStart = $derived(column.pin === 'right');
|
|
48
|
+
// Centred on the edge it sits on: half inside the column, half over its neighbour.
|
|
49
|
+
const handleTransform = $derived(
|
|
50
|
+
atInlineStart !== handleRtl ? 'translateX(-50%)' : 'translateX(50%)'
|
|
51
|
+
);
|
|
43
52
|
|
|
44
53
|
let isFocused = $state(false);
|
|
45
54
|
let isFocusVisible = $state(false);
|
|
@@ -336,7 +345,7 @@
|
|
|
336
345
|
|
|
337
346
|
const pointerDelta = latestClientX - previousClientX;
|
|
338
347
|
previousClientX = latestClientX;
|
|
339
|
-
const widthDelta = isRTL ? -pointerDelta : pointerDelta;
|
|
348
|
+
const widthDelta = isRTL !== atInlineStart ? -pointerDelta : pointerDelta;
|
|
340
349
|
dragWidth = clampWidth(dragWidth + widthDelta);
|
|
341
350
|
const nextWidth = dragWidth;
|
|
342
351
|
updateWidth(nextWidth);
|
|
@@ -531,7 +540,7 @@
|
|
|
531
540
|
event.stopPropagation();
|
|
532
541
|
|
|
533
542
|
const delta = event.shiftKey ? shiftStep : step;
|
|
534
|
-
const direction = isRightToLeft() ? -1 : 1;
|
|
543
|
+
const direction = isRightToLeft() !== atInlineStart ? -1 : 1;
|
|
535
544
|
const baseWidth = getResolvedWidth();
|
|
536
545
|
|
|
537
546
|
switch (event.key) {
|
|
@@ -595,12 +604,13 @@
|
|
|
595
604
|
data-resizing={isResizing ? 'true' : undefined}
|
|
596
605
|
data-resizable={isResizable ? 'true' : undefined}
|
|
597
606
|
data-table-column-resizer="true"
|
|
598
|
-
data-resizable-direction=
|
|
607
|
+
data-resizable-direction={atInlineStart ? 'left' : 'right'}
|
|
599
608
|
style:position="absolute"
|
|
600
609
|
style:z-index="2"
|
|
601
610
|
style:top="0"
|
|
602
|
-
style:inset-inline-
|
|
603
|
-
style:
|
|
611
|
+
style:inset-inline-start={atInlineStart ? '0' : undefined}
|
|
612
|
+
style:inset-inline-end={atInlineStart ? undefined : '0'}
|
|
613
|
+
style:transform={handleTransform}
|
|
604
614
|
style:width="0.75rem"
|
|
605
615
|
style:height="100%"
|
|
606
616
|
style:display="flex"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@human-kit/ui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Accessible, typed UI components for Svelte 5 — shipped as native ESM with per-component subpath exports so bundlers only include what you import.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Agustin Delgado <agustindariodelgado@gmail.com>",
|