@cjlapao/ui-kit 0.2.36 → 0.2.38

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.
@@ -1,6 +1,6 @@
1
1
  import React__default from 'react';
2
- import { w as CapsuleBlueprintParameter, a0 as CodeBlockProps } from './CodeBlock-QDW3hqU0.cjs';
3
- export { $ as CodeBlock, an as HelpButton } from './CodeBlock-QDW3hqU0.cjs';
2
+ import { x as CapsuleBlueprintParameter, a1 as CodeBlockProps } from './CodeBlock-Sj3AzAca.cjs';
3
+ export { a0 as CodeBlock, ao as HelpButton } from './CodeBlock-Sj3AzAca.cjs';
4
4
  import { Components } from 'react-markdown';
5
5
 
6
6
  interface MarkdownEditorProps {
@@ -1,6 +1,6 @@
1
1
  import React__default from 'react';
2
- import { w as CapsuleBlueprintParameter, a0 as CodeBlockProps } from './CodeBlock-QDW3hqU0.js';
3
- export { $ as CodeBlock, an as HelpButton } from './CodeBlock-QDW3hqU0.js';
2
+ import { x as CapsuleBlueprintParameter, a1 as CodeBlockProps } from './CodeBlock-Sj3AzAca.js';
3
+ export { a0 as CodeBlock, ao as HelpButton } from './CodeBlock-Sj3AzAca.js';
4
4
  import { Components } from 'react-markdown';
5
5
 
6
6
  interface MarkdownEditorProps {
package/dist/markdown.js CHANGED
@@ -11281,53 +11281,72 @@ var ScrollArea = ({
11281
11281
  const [hovered, setHovered] = useState3(false);
11282
11282
  const [scrolling, setScrolling] = useState3(false);
11283
11283
  const dragging = useRef3(null);
11284
+ const virtual = virtualScroll != null;
11285
+ const virtualViewport = virtualScroll?.viewportSize ?? 0;
11286
+ const virtualContent = virtualScroll?.contentSize ?? 0;
11287
+ const virtualOffset = virtualScroll?.offset ?? 0;
11284
11288
  const thumb = useCallback3(
11285
11289
  (viewport, track, axis) => {
11286
- const viewportSize = axis === "y" && virtualScroll ? virtualScroll.viewportSize : axis === "y" ? viewport.clientHeight : viewport.clientWidth;
11287
- const contentSize = axis === "y" && virtualScroll ? virtualScroll.contentSize : axis === "y" ? viewport.scrollHeight : viewport.scrollWidth;
11290
+ const viewportSize = axis === "y" && virtual ? virtualViewport : axis === "y" ? viewport.clientHeight : viewport.clientWidth;
11291
+ const contentSize = axis === "y" && virtual ? virtualContent : axis === "y" ? viewport.scrollHeight : viewport.scrollWidth;
11288
11292
  const trackSize = (track ? axis === "y" ? track.clientHeight : track.clientWidth : viewportSize) || 1;
11289
11293
  const scrollable = contentSize - viewportSize;
11290
- if (scrollable <= (virtualScroll ? 0 : 1)) return FITTING_THUMB;
11294
+ if (scrollable <= (virtual ? 0 : 1)) return FITTING_THUMB;
11291
11295
  const size = Math.max(
11292
11296
  MIN_THUMB,
11293
11297
  viewportSize / contentSize * trackSize
11294
11298
  );
11295
- const position = axis === "y" && virtualScroll ? virtualScroll.offset : axis === "y" ? viewport.scrollTop : viewport.scrollLeft;
11299
+ const position = axis === "y" && virtual ? virtualOffset : axis === "y" ? viewport.scrollTop : viewport.scrollLeft;
11296
11300
  return {
11297
11301
  size,
11298
11302
  offset: position / scrollable * (trackSize - size),
11299
11303
  ratio: position / scrollable
11300
11304
  };
11301
11305
  },
11302
- [virtualScroll]
11306
+ [virtual, virtualViewport, virtualContent, virtualOffset]
11303
11307
  );
11308
+ const sameMetrics = (a, b) => a.size === b.size && a.offset === b.offset && a.ratio === b.ratio;
11304
11309
  const update = useCallback3(() => {
11305
11310
  const viewport = viewportRef.current;
11306
11311
  if (!viewport) return;
11307
- setOverflow({
11308
- x: horizontal && viewport.scrollWidth - viewport.clientWidth > 1,
11309
- y: virtualScroll ? virtualScroll.contentSize > virtualScroll.viewportSize : viewport.scrollHeight - viewport.clientHeight > 1
11310
- });
11311
- setThumbY(thumb(viewport, yTrackRef.current, "y"));
11312
- setThumbX(
11313
- horizontal ? thumb(viewport, xTrackRef.current, "x") : FITTING_THUMB
11312
+ const nextX = horizontal && viewport.scrollWidth - viewport.clientWidth > 1;
11313
+ const nextY = virtual ? virtualContent > virtualViewport : viewport.scrollHeight - viewport.clientHeight > 1;
11314
+ setOverflow(
11315
+ (prev) => prev.x === nextX && prev.y === nextY ? prev : { x: nextX, y: nextY }
11314
11316
  );
11315
- }, [thumb, horizontal, virtualScroll]);
11317
+ const nextYThumb = thumb(viewport, yTrackRef.current, "y");
11318
+ setThumbY((prev) => sameMetrics(prev, nextYThumb) ? prev : nextYThumb);
11319
+ const nextXThumb = horizontal ? thumb(viewport, xTrackRef.current, "x") : FITTING_THUMB;
11320
+ setThumbX((prev) => sameMetrics(prev, nextXThumb) ? prev : nextXThumb);
11321
+ }, [thumb, horizontal, virtual, virtualContent, virtualViewport]);
11322
+ const updateRef = useRef3(update);
11316
11323
  useEffect3(() => {
11317
- update();
11324
+ updateRef.current = update;
11325
+ });
11326
+ useEffect3(() => {
11327
+ updateRef.current();
11318
11328
  let observer;
11329
+ let frame = 0;
11330
+ const schedule = () => {
11331
+ if (frame) return;
11332
+ frame = requestAnimationFrame(() => {
11333
+ frame = 0;
11334
+ updateRef.current();
11335
+ });
11336
+ };
11319
11337
  if (typeof ResizeObserver !== "undefined") {
11320
- observer = new ResizeObserver(update);
11338
+ observer = new ResizeObserver(schedule);
11321
11339
  if (viewportRef.current) observer.observe(viewportRef.current);
11322
11340
  if (contentRef.current) observer.observe(contentRef.current);
11323
11341
  } else {
11324
- window.addEventListener("resize", update);
11342
+ window.addEventListener("resize", schedule);
11325
11343
  }
11326
11344
  return () => {
11345
+ if (frame) cancelAnimationFrame(frame);
11327
11346
  observer?.disconnect();
11328
- window.removeEventListener("resize", update);
11347
+ window.removeEventListener("resize", schedule);
11329
11348
  };
11330
- }, [update]);
11349
+ }, []);
11331
11350
  useEffect3(() => () => window.clearTimeout(lingerTimer.current), []);
11332
11351
  const handleScroll = () => {
11333
11352
  update();
@@ -11465,6 +11484,12 @@ var ScrollArea = ({
11465
11484
  "data-slot": "scrollarea-content",
11466
11485
  className: classNames9(
11467
11486
  virtualScroll ? "h-full min-w-full" : "table min-w-full",
11487
+ // The overlay bar's lane is reserved in the content *always*:
11488
+ // the auto/hover bar appears on gesture, and a gutter tied to
11489
+ // its visibility would jog the text sideways on every scroll.
11490
+ // A constant 10px inset is the calmer contract — the thumb then
11491
+ // never sits on the caller's content, or its hover state.
11492
+ "pr-2.5",
11468
11493
  contentClassName
11469
11494
  ),
11470
11495
  children