@cjlapao/ui-kit 0.2.35 → 0.2.37
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/{CodeBlock-QDW3hqU0.d.cts → CodeBlock-Sj3AzAca.d.cts} +27 -1
- package/dist/{CodeBlock-QDW3hqU0.d.ts → CodeBlock-Sj3AzAca.d.ts} +27 -1
- package/dist/index.cjs +856 -504
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +24 -0
- package/dist/index.d.cts +173 -9
- package/dist/index.d.ts +173 -9
- package/dist/index.js +1236 -881
- package/dist/index.js.map +1 -1
- package/dist/markdown.cjs +43 -18
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.d.cts +2 -2
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.js +43 -18
- package/dist/markdown.js.map +1 -1
- package/package.json +1 -1
package/dist/markdown.cjs
CHANGED
|
@@ -11299,53 +11299,72 @@ var ScrollArea = ({
|
|
|
11299
11299
|
const [hovered, setHovered] = (0, import_react160.useState)(false);
|
|
11300
11300
|
const [scrolling, setScrolling] = (0, import_react160.useState)(false);
|
|
11301
11301
|
const dragging = (0, import_react160.useRef)(null);
|
|
11302
|
+
const virtual = virtualScroll != null;
|
|
11303
|
+
const virtualViewport = virtualScroll?.viewportSize ?? 0;
|
|
11304
|
+
const virtualContent = virtualScroll?.contentSize ?? 0;
|
|
11305
|
+
const virtualOffset = virtualScroll?.offset ?? 0;
|
|
11302
11306
|
const thumb = (0, import_react160.useCallback)(
|
|
11303
11307
|
(viewport, track, axis) => {
|
|
11304
|
-
const viewportSize = axis === "y" &&
|
|
11305
|
-
const contentSize = axis === "y" &&
|
|
11308
|
+
const viewportSize = axis === "y" && virtual ? virtualViewport : axis === "y" ? viewport.clientHeight : viewport.clientWidth;
|
|
11309
|
+
const contentSize = axis === "y" && virtual ? virtualContent : axis === "y" ? viewport.scrollHeight : viewport.scrollWidth;
|
|
11306
11310
|
const trackSize = (track ? axis === "y" ? track.clientHeight : track.clientWidth : viewportSize) || 1;
|
|
11307
11311
|
const scrollable = contentSize - viewportSize;
|
|
11308
|
-
if (scrollable <= (
|
|
11312
|
+
if (scrollable <= (virtual ? 0 : 1)) return FITTING_THUMB;
|
|
11309
11313
|
const size = Math.max(
|
|
11310
11314
|
MIN_THUMB,
|
|
11311
11315
|
viewportSize / contentSize * trackSize
|
|
11312
11316
|
);
|
|
11313
|
-
const position = axis === "y" &&
|
|
11317
|
+
const position = axis === "y" && virtual ? virtualOffset : axis === "y" ? viewport.scrollTop : viewport.scrollLeft;
|
|
11314
11318
|
return {
|
|
11315
11319
|
size,
|
|
11316
11320
|
offset: position / scrollable * (trackSize - size),
|
|
11317
11321
|
ratio: position / scrollable
|
|
11318
11322
|
};
|
|
11319
11323
|
},
|
|
11320
|
-
[
|
|
11324
|
+
[virtual, virtualViewport, virtualContent, virtualOffset]
|
|
11321
11325
|
);
|
|
11326
|
+
const sameMetrics = (a, b) => a.size === b.size && a.offset === b.offset && a.ratio === b.ratio;
|
|
11322
11327
|
const update = (0, import_react160.useCallback)(() => {
|
|
11323
11328
|
const viewport = viewportRef.current;
|
|
11324
11329
|
if (!viewport) return;
|
|
11325
|
-
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
setThumbY(thumb(viewport, yTrackRef.current, "y"));
|
|
11330
|
-
setThumbX(
|
|
11331
|
-
horizontal ? thumb(viewport, xTrackRef.current, "x") : FITTING_THUMB
|
|
11330
|
+
const nextX = horizontal && viewport.scrollWidth - viewport.clientWidth > 1;
|
|
11331
|
+
const nextY = virtual ? virtualContent > virtualViewport : viewport.scrollHeight - viewport.clientHeight > 1;
|
|
11332
|
+
setOverflow(
|
|
11333
|
+
(prev) => prev.x === nextX && prev.y === nextY ? prev : { x: nextX, y: nextY }
|
|
11332
11334
|
);
|
|
11333
|
-
|
|
11335
|
+
const nextYThumb = thumb(viewport, yTrackRef.current, "y");
|
|
11336
|
+
setThumbY((prev) => sameMetrics(prev, nextYThumb) ? prev : nextYThumb);
|
|
11337
|
+
const nextXThumb = horizontal ? thumb(viewport, xTrackRef.current, "x") : FITTING_THUMB;
|
|
11338
|
+
setThumbX((prev) => sameMetrics(prev, nextXThumb) ? prev : nextXThumb);
|
|
11339
|
+
}, [thumb, horizontal, virtual, virtualContent, virtualViewport]);
|
|
11340
|
+
const updateRef = (0, import_react160.useRef)(update);
|
|
11334
11341
|
(0, import_react160.useEffect)(() => {
|
|
11335
|
-
update
|
|
11342
|
+
updateRef.current = update;
|
|
11343
|
+
});
|
|
11344
|
+
(0, import_react160.useEffect)(() => {
|
|
11345
|
+
updateRef.current();
|
|
11336
11346
|
let observer;
|
|
11347
|
+
let frame = 0;
|
|
11348
|
+
const schedule = () => {
|
|
11349
|
+
if (frame) return;
|
|
11350
|
+
frame = requestAnimationFrame(() => {
|
|
11351
|
+
frame = 0;
|
|
11352
|
+
updateRef.current();
|
|
11353
|
+
});
|
|
11354
|
+
};
|
|
11337
11355
|
if (typeof ResizeObserver !== "undefined") {
|
|
11338
|
-
observer = new ResizeObserver(
|
|
11356
|
+
observer = new ResizeObserver(schedule);
|
|
11339
11357
|
if (viewportRef.current) observer.observe(viewportRef.current);
|
|
11340
11358
|
if (contentRef.current) observer.observe(contentRef.current);
|
|
11341
11359
|
} else {
|
|
11342
|
-
window.addEventListener("resize",
|
|
11360
|
+
window.addEventListener("resize", schedule);
|
|
11343
11361
|
}
|
|
11344
11362
|
return () => {
|
|
11363
|
+
if (frame) cancelAnimationFrame(frame);
|
|
11345
11364
|
observer?.disconnect();
|
|
11346
|
-
window.removeEventListener("resize",
|
|
11365
|
+
window.removeEventListener("resize", schedule);
|
|
11347
11366
|
};
|
|
11348
|
-
}, [
|
|
11367
|
+
}, []);
|
|
11349
11368
|
(0, import_react160.useEffect)(() => () => window.clearTimeout(lingerTimer.current), []);
|
|
11350
11369
|
const handleScroll = () => {
|
|
11351
11370
|
update();
|
|
@@ -11483,6 +11502,12 @@ var ScrollArea = ({
|
|
|
11483
11502
|
"data-slot": "scrollarea-content",
|
|
11484
11503
|
className: (0, import_classnames9.default)(
|
|
11485
11504
|
virtualScroll ? "h-full min-w-full" : "table min-w-full",
|
|
11505
|
+
// The overlay bar's lane is reserved in the content *always*:
|
|
11506
|
+
// the auto/hover bar appears on gesture, and a gutter tied to
|
|
11507
|
+
// its visibility would jog the text sideways on every scroll.
|
|
11508
|
+
// A constant 10px inset is the calmer contract — the thumb then
|
|
11509
|
+
// never sits on the caller's content, or its hover state.
|
|
11510
|
+
"pr-2.5",
|
|
11486
11511
|
contentClassName
|
|
11487
11512
|
),
|
|
11488
11513
|
children
|