@alexgorbatchev/shadcn 0.0.163 → 0.0.165

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,10 +1,10 @@
1
1
  // src/components/image-viewer/hooks/useElementSize.ts
2
2
  import { useIsoLayoutEffect } from "@base-ui/utils/useIsoLayoutEffect";
3
3
  import { useState } from "react";
4
- function useElementSize(ref) {
4
+ function useElementSize(target) {
5
5
  const [size, setSize] = useState();
6
6
  useIsoLayoutEffect(() => {
7
- const element = ref.current;
7
+ const element = target && "current" in target ? target.current : target;
8
8
  if (!element)
9
9
  return;
10
10
  const measure = () => {
@@ -16,8 +16,8 @@ function useElementSize(ref) {
16
16
  const observer = new ResizeObserver(measure);
17
17
  observer.observe(element);
18
18
  return () => observer.disconnect();
19
- }, [ref]);
20
- return size;
19
+ }, [target]);
20
+ return target ? size : undefined;
21
21
  }
22
22
 
23
23
  export { useElementSize };
@@ -1,4 +1,4 @@
1
1
  import { type RefObject } from "react";
2
2
  import type { IImageSize } from "../types.js";
3
3
  /** Tracks an element's client size, which excludes borders and scrollbars. */
4
- export declare function useElementSize(ref: RefObject<HTMLElement | null>): IImageSize | undefined;
4
+ export declare function useElementSize(target: RefObject<HTMLElement | null> | HTMLElement | null): IImageSize | undefined;
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../chunk-en44w1pn.js";
4
4
  import {
5
5
  useElementSize
6
- } from "../../chunk-e4t5njn9.js";
6
+ } from "../../chunk-fecmzpgx.js";
7
7
  import"../../chunk-7ny0vyek.js";
8
8
  import"../../chunk-8ssktt4b.js";
9
9
  import"../../chunk-e6hk39ev.js";
@@ -409,25 +409,25 @@ function ImageViewport({
409
409
  "data-slot": "image-viewport-scroll-hint",
410
410
  "data-edge": "left",
411
411
  "aria-hidden": "true",
412
- className: "pointer-events-none absolute inset-y-0 left-0 w-5 bg-gradient-to-r from-black/45 via-black/15 to-transparent dark:from-black/75 dark:via-black/30 dark:shadow-[inset_8px_0_12px_-8px_rgba(255,255,255,0.28)]"
412
+ className: "pointer-events-none absolute inset-y-0 left-0 w-5 bg-gradient-to-r from-black/45 via-black/15 to-transparent dark:from-black/75 dark:via-black/30 dark:shadow-[inset_1px_0_0_rgba(255,255,255,0.22),inset_10px_0_14px_-8px_rgba(255,255,255,0.38)]"
413
413
  }),
414
414
  scrollHints.right && /* @__PURE__ */ jsx("div", {
415
415
  "data-slot": "image-viewport-scroll-hint",
416
416
  "data-edge": "right",
417
417
  "aria-hidden": "true",
418
- className: "pointer-events-none absolute inset-y-0 right-0 w-5 bg-gradient-to-l from-black/45 via-black/15 to-transparent dark:from-black/75 dark:via-black/30 dark:shadow-[inset_-8px_0_12px_-8px_rgba(255,255,255,0.28)]"
418
+ className: "pointer-events-none absolute inset-y-0 right-0 w-5 bg-gradient-to-l from-black/45 via-black/15 to-transparent dark:from-black/75 dark:via-black/30 dark:shadow-[inset_-1px_0_0_rgba(255,255,255,0.22),inset_-10px_0_14px_-8px_rgba(255,255,255,0.38)]"
419
419
  }),
420
420
  scrollHints.top && /* @__PURE__ */ jsx("div", {
421
421
  "data-slot": "image-viewport-scroll-hint",
422
422
  "data-edge": "top",
423
423
  "aria-hidden": "true",
424
- className: "pointer-events-none absolute inset-x-0 top-0 h-5 bg-gradient-to-b from-black/45 via-black/15 to-transparent dark:from-black/75 dark:via-black/30 dark:shadow-[inset_0_8px_12px_-8px_rgba(255,255,255,0.28)]"
424
+ className: "pointer-events-none absolute inset-x-0 top-0 h-5 bg-gradient-to-b from-black/45 via-black/15 to-transparent dark:from-black/75 dark:via-black/30 dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.22),inset_0_10px_14px_-8px_rgba(255,255,255,0.38)]"
425
425
  }),
426
426
  scrollHints.bottom && /* @__PURE__ */ jsx("div", {
427
427
  "data-slot": "image-viewport-scroll-hint",
428
428
  "data-edge": "bottom",
429
429
  "aria-hidden": "true",
430
- className: "pointer-events-none absolute inset-x-0 bottom-0 h-5 bg-gradient-to-t from-black/45 via-black/15 to-transparent dark:from-black/75 dark:via-black/30 dark:shadow-[inset_0_-8px_12px_-8px_rgba(255,255,255,0.28)]"
430
+ className: "pointer-events-none absolute inset-x-0 bottom-0 h-5 bg-gradient-to-t from-black/45 via-black/15 to-transparent dark:from-black/75 dark:via-black/30 dark:shadow-[inset_0_-1px_0_rgba(255,255,255,0.22),inset_0_-10px_14px_-8px_rgba(255,255,255,0.38)]"
431
431
  })
432
432
  ]
433
433
  });
@@ -863,7 +863,13 @@ function DiagramSurface({
863
863
  import { useControlled as useControlled2 } from "@base-ui/utils/useControlled";
864
864
  import { useIsoLayoutEffect as useIsoLayoutEffect4 } from "@base-ui/utils/useIsoLayoutEffect";
865
865
  import { useMergedRefs as useMergedRefs3 } from "@base-ui/utils/useMergedRefs";
866
- import { useMemo, useRef as useRef4, useState as useState4 } from "react";
866
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
867
+ import {
868
+ useCallback,
869
+ useMemo,
870
+ useRef as useRef4,
871
+ useState as useState4
872
+ } from "react";
867
873
  import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
868
874
  function DiagramViewer({
869
875
  svg,
@@ -889,12 +895,37 @@ function DiagramViewer({
889
895
  });
890
896
  const center = useRef4({ x: 0.5, y: 0.5 });
891
897
  const viewportRef = useRef4(null);
898
+ const toolbarRef = useRef4(null);
892
899
  const mergedStageRef = useMergedRefs3(viewportRef, stageRef);
893
900
  const viewportSize = useElementSize(viewportRef);
894
901
  const parsedSize = useMemo(() => getDiagramSvgSize(svg), [svg]);
895
902
  const naturalSize = naturalSizeProp ?? parsedSize;
896
903
  const [openingZoom, setOpeningZoom] = useState4();
904
+ const [toolbarOverflow, setToolbarOverflow] = useState4({ left: false, right: false });
897
905
  const scales = naturalSize && viewportSize ? getImageZoomScales(naturalSize, viewportSize) : undefined;
906
+ const hasToolbar = showZoomControl || toolbar !== undefined;
907
+ const updateToolbarOverflow = useCallback(() => {
908
+ const el = toolbarRef.current;
909
+ if (!el) {
910
+ setToolbarOverflow((current) => current.left || current.right ? { left: false, right: false } : current);
911
+ return;
912
+ }
913
+ const left = el.scrollLeft > 1;
914
+ const right = el.scrollLeft + el.clientWidth < el.scrollWidth - 1;
915
+ setToolbarOverflow((current) => current.left === left && current.right === right ? current : { left, right });
916
+ }, []);
917
+ useIsoLayoutEffect4(() => {
918
+ const el = toolbarRef.current;
919
+ if (!el)
920
+ return;
921
+ updateToolbarOverflow();
922
+ const observer = new ResizeObserver(updateToolbarOverflow);
923
+ observer.observe(el);
924
+ return () => observer.disconnect();
925
+ }, [hasToolbar, updateToolbarOverflow]);
926
+ const scrollToolbar = (delta) => {
927
+ toolbarRef.current?.scrollBy({ left: delta, behavior: "smooth" });
928
+ };
898
929
  useIsoLayoutEffect4(() => {
899
930
  if (zoom !== undefined || openingZoom !== undefined || !naturalSize || !viewportSize)
900
931
  return;
@@ -918,18 +949,51 @@ function DiagramViewer({
918
949
  "data-zoom": shownZoom,
919
950
  className: "flex size-full min-h-0 min-w-0 flex-1 flex-col gap-2",
920
951
  children: [
921
- (showZoomControl || toolbar !== undefined) && /* @__PURE__ */ jsxs5("div", {
922
- "data-slot": "diagram-viewer-toolbar",
923
- className: "flex shrink-0 flex-wrap items-center gap-control-gap *:shrink-0 [@media(max-height:280px)]:flex-nowrap [@media(max-height:280px)]:overflow-x-auto",
952
+ hasToolbar && /* @__PURE__ */ jsxs5("div", {
953
+ className: "relative flex min-w-0 shrink-0 items-center",
924
954
  children: [
925
- showZoomControl && /* @__PURE__ */ jsx5(ImageZoomControl, {
926
- zoom: shownZoom,
927
- scale,
928
- scales,
929
- onZoomChange: setZoom,
930
- density
955
+ /* @__PURE__ */ jsxs5("div", {
956
+ ref: toolbarRef,
957
+ "data-slot": "diagram-viewer-toolbar",
958
+ onScroll: updateToolbarOverflow,
959
+ className: "flex min-w-0 flex-1 flex-wrap items-center gap-control-gap *:shrink-0 [@media(max-height:280px)]:flex-nowrap [@media(max-height:280px)]:overflow-x-auto [@media(max-height:280px)]:[scrollbar-width:none] [@media(max-height:280px)]:[&::-webkit-scrollbar]:hidden",
960
+ children: [
961
+ showZoomControl && /* @__PURE__ */ jsx5(ImageZoomControl, {
962
+ zoom: shownZoom,
963
+ scale,
964
+ scales,
965
+ onZoomChange: setZoom,
966
+ density
967
+ }),
968
+ toolbar
969
+ ]
931
970
  }),
932
- toolbar
971
+ toolbarOverflow.left && /* @__PURE__ */ jsx5("div", {
972
+ className: "pointer-events-none absolute inset-y-0 left-0 flex items-center bg-gradient-to-r from-background via-background/95 to-transparent pe-4",
973
+ children: /* @__PURE__ */ jsx5(Button2, {
974
+ type: "button",
975
+ variant: "outline",
976
+ size: "icon-sm",
977
+ density,
978
+ "aria-label": "Scroll toolbar left",
979
+ className: "pointer-events-auto bg-background",
980
+ onClick: () => scrollToolbar(-120),
981
+ children: /* @__PURE__ */ jsx5(ChevronLeftIcon, {})
982
+ })
983
+ }),
984
+ toolbarOverflow.right && /* @__PURE__ */ jsx5("div", {
985
+ className: "pointer-events-none absolute inset-y-0 right-0 flex items-center bg-gradient-to-l from-background via-background/95 to-transparent ps-4",
986
+ children: /* @__PURE__ */ jsx5(Button2, {
987
+ type: "button",
988
+ variant: "outline",
989
+ size: "icon-sm",
990
+ density,
991
+ "aria-label": "Scroll toolbar right",
992
+ className: "pointer-events-auto bg-background",
993
+ onClick: () => scrollToolbar(120),
994
+ children: /* @__PURE__ */ jsx5(ChevronRightIcon, {})
995
+ })
996
+ })
933
997
  ]
934
998
  }),
935
999
  /* @__PURE__ */ jsx5(ImageViewport, {
@@ -1441,7 +1505,7 @@ function ImageRegionFields({
1441
1505
  }
1442
1506
  // src/components/image-viewer/ImageGallery.tsx
1443
1507
  import { useControlled as useControlled3 } from "@base-ui/utils/useControlled";
1444
- import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
1508
+ import { ChevronLeftIcon as ChevronLeftIcon2, ChevronRightIcon as ChevronRightIcon2 } from "lucide-react";
1445
1509
  import {
1446
1510
  useRef as useRef6,
1447
1511
  useState as useState7
@@ -1690,7 +1754,7 @@ function ImageGallery({
1690
1754
  "aria-label": previousLabel,
1691
1755
  disabledReason: index === 0 ? "This is the first image" : undefined,
1692
1756
  onClick: () => step(index - 1),
1693
- children: /* @__PURE__ */ jsx10(ChevronLeftIcon, {})
1757
+ children: /* @__PURE__ */ jsx10(ChevronLeftIcon2, {})
1694
1758
  }),
1695
1759
  /* @__PURE__ */ jsxs8("span", {
1696
1760
  "data-slot": "image-gallery-position",
@@ -1708,7 +1772,7 @@ function ImageGallery({
1708
1772
  "aria-label": nextLabel,
1709
1773
  disabledReason: index === count - 1 ? "This is the last image" : undefined,
1710
1774
  onClick: () => step(index + 1),
1711
- children: /* @__PURE__ */ jsx10(ChevronRightIcon, {})
1775
+ children: /* @__PURE__ */ jsx10(ChevronRightIcon2, {})
1712
1776
  })
1713
1777
  ]
1714
1778
  }),
@@ -1753,6 +1817,7 @@ function MediaShell({
1753
1817
  className: "[@media(max-height:280px)]:gap-1.5 [@media(max-height:280px)]:p-2",
1754
1818
  children: [
1755
1819
  /* @__PURE__ */ jsxs9(DialogHeader2, {
1820
+ className: "[@media(max-height:280px)]:min-h-control-sm [@media(max-height:280px)]:justify-center [@media(max-height:280px)]:pe-8",
1756
1821
  children: [
1757
1822
  /* @__PURE__ */ jsx11(DialogTitle2, {
1758
1823
  className: "truncate",
@@ -1776,10 +1841,11 @@ function MediaShell({
1776
1841
  }
1777
1842
  // src/components/image-viewer/ImageComparison.tsx
1778
1843
  import { useControlled as useControlled4 } from "@base-ui/utils/useControlled";
1844
+ import { useMergedRefs as useMergedRefs4 } from "@base-ui/utils/useMergedRefs";
1779
1845
  import { useRef as useRef8, useState as useState9 } from "react";
1780
1846
 
1781
1847
  // src/components/image-viewer/ImageComparisonToolbar.tsx
1782
- import { ChevronLeftIcon as ChevronLeftIcon2, ChevronRightIcon as ChevronRightIcon2, Columns2Icon, Rows2Icon } from "lucide-react";
1848
+ import { ChevronLeftIcon as ChevronLeftIcon3, ChevronRightIcon as ChevronRightIcon3, Columns2Icon, Rows2Icon } from "lucide-react";
1783
1849
  import { useId as useId3 } from "react";
1784
1850
  import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
1785
1851
  function ToolbarSection({ title, titleId, children }) {
@@ -1991,8 +2057,13 @@ function ImageComparisonToolbar({
1991
2057
  onContextMenu: (event) => event.preventDefault(),
1992
2058
  children: `Hold to show ${side === "before" ? "after" : "before"}`
1993
2059
  }),
2060
+ toolbar && /* @__PURE__ */ jsx12("div", {
2061
+ "data-slot": "image-comparison-toolbar-extra",
2062
+ className: "contents",
2063
+ children: toolbar
2064
+ }),
1994
2065
  /* @__PURE__ */ jsxs10("div", {
1995
- className: "flex shrink-0 items-center gap-1.5",
2066
+ className: "flex min-h-control-sm shrink-0 items-center gap-1.5",
1996
2067
  children: [
1997
2068
  /* @__PURE__ */ jsx12(Switch2, {
1998
2069
  id: `${id}-differences`,
@@ -2033,6 +2104,11 @@ function ImageComparisonToolbar({
2033
2104
  /* @__PURE__ */ jsx12("span", {
2034
2105
  className: "hidden @md:inline",
2035
2106
  children: "Changed region"
2107
+ }),
2108
+ /* @__PURE__ */ jsx12("span", {
2109
+ "aria-hidden": "true",
2110
+ className: "hidden @md:inline",
2111
+ children: "·"
2036
2112
  })
2037
2113
  ]
2038
2114
  }),
@@ -2053,7 +2129,7 @@ function ImageComparisonToolbar({
2053
2129
  "aria-label": "Previous change",
2054
2130
  "aria-keyshortcuts": "Shift+N",
2055
2131
  onClick: () => onStepChange(-1),
2056
- children: /* @__PURE__ */ jsx12(ChevronLeftIcon2, {})
2132
+ children: /* @__PURE__ */ jsx12(ChevronLeftIcon3, {})
2057
2133
  }),
2058
2134
  /* @__PURE__ */ jsx12(Button2, {
2059
2135
  variant: "outline",
@@ -2062,7 +2138,7 @@ function ImageComparisonToolbar({
2062
2138
  "aria-label": "Next change",
2063
2139
  "aria-keyshortcuts": "N",
2064
2140
  onClick: () => onStepChange(1),
2065
- children: /* @__PURE__ */ jsx12(ChevronRightIcon2, {})
2141
+ children: /* @__PURE__ */ jsx12(ChevronRightIcon3, {})
2066
2142
  }),
2067
2143
  onCommentActiveDifference && /* @__PURE__ */ jsx12(Button2, {
2068
2144
  variant: "outline",
@@ -2074,11 +2150,6 @@ function ImageComparisonToolbar({
2074
2150
  })
2075
2151
  ]
2076
2152
  }),
2077
- toolbar && /* @__PURE__ */ jsx12("div", {
2078
- "data-slot": "image-comparison-toolbar-extra",
2079
- className: "flex min-w-0 flex-wrap items-center gap-1.5",
2080
- children: toolbar
2081
- }),
2082
2153
  sizeMismatch && /* @__PURE__ */ jsx12("p", {
2083
2154
  "data-slot": "image-comparison-size-mismatch",
2084
2155
  className: "w-full text-xs text-muted-foreground",
@@ -2523,12 +2594,14 @@ ${after.src}`;
2523
2594
  const singleViewportRef = useRef8(null);
2524
2595
  const beforeViewportRef = useRef8(null);
2525
2596
  const afterViewportRef = useRef8(null);
2597
+ const [singleViewportElement, setSingleViewportElement] = useState9(null);
2598
+ const [afterViewportElement, setAfterViewportElement] = useState9(null);
2599
+ const mergedSingleViewportRef = useMergedRefs4(singleViewportRef, setSingleViewportElement);
2600
+ const mergedAfterViewportRef = useMergedRefs4(afterViewportRef, setAfterViewportElement);
2526
2601
  const expectedScrollRef = useRef8(new WeakMap);
2527
2602
  const center = useRef8({ x: 0.5, y: 0.5 });
2528
2603
  const stageSize = useElementSize(stageRef);
2529
- const singleViewportSize = useElementSize(singleViewportRef);
2530
- const afterViewportSize = useElementSize(afterViewportRef);
2531
- const activeViewportSize = mode === "side-by-side" ? afterViewportSize : singleViewportSize;
2604
+ const activeViewportSize = useElementSize(mode === "side-by-side" ? afterViewportElement : singleViewportElement);
2532
2605
  const zoomScales = afterImage.size && activeViewportSize ? getImageZoomScales(afterImage.size, activeViewportSize) : undefined;
2533
2606
  const zoomScale = zoomScales ? resolveImageZoomScale(zoom, zoomScales) : undefined;
2534
2607
  const autoOrientation = stageSize && stageSize.height > stageSize.width ? "vertical" : "horizontal";
@@ -2725,7 +2798,7 @@ ${after.src}`;
2725
2798
  center,
2726
2799
  onZoomChange: setZoom,
2727
2800
  fallback,
2728
- viewportRef: afterViewportRef,
2801
+ viewportRef: mergedAfterViewportRef,
2729
2802
  onViewportScroll: (viewport) => syncScroll(viewport, beforeViewportRef.current),
2730
2803
  onStageKeyDown: (event) => handleStageKey(event, "after"),
2731
2804
  stageKeyShortcuts: sharedStageKeys || undefined,
@@ -2757,7 +2830,7 @@ ${after.src}`;
2757
2830
  center,
2758
2831
  onZoomChange: setZoom,
2759
2832
  fallback,
2760
- viewportRef: singleViewportRef,
2833
+ viewportRef: mergedSingleViewportRef,
2761
2834
  onStageKeyDown: (event) => handleStageKey(event, position > 50 ? "before" : "after"),
2762
2835
  stageKeyShortcuts: sharedStageKeys || undefined,
2763
2836
  children: [
@@ -2794,7 +2867,7 @@ ${after.src}`;
2794
2867
  center,
2795
2868
  onZoomChange: setZoom,
2796
2869
  fallback,
2797
- viewportRef: singleViewportRef,
2870
+ viewportRef: mergedSingleViewportRef,
2798
2871
  onStageKeyDown: (event) => handleStageKey(event, shownSide),
2799
2872
  stageKeyShortcuts: toggleStageKeys,
2800
2873
  children: [
@@ -24,7 +24,7 @@ import {
24
24
  } from "../../chunk-31kppqkn.js";
25
25
  import {
26
26
  useElementSize
27
- } from "../../chunk-e4t5njn9.js";
27
+ } from "../../chunk-fecmzpgx.js";
28
28
  import"../../chunk-5mydsjp3.js";
29
29
 
30
30
  // src/components/text-diff/TextDiff.tsx
package/dist/prototype.js CHANGED
@@ -2051,7 +2051,7 @@ var program = new Command;
2051
2051
  // package.json
2052
2052
  var package_default = {
2053
2053
  name: "@alexgorbatchev/shadcn",
2054
- version: "0.0.163",
2054
+ version: "0.0.165",
2055
2055
  description: "Sharp, monospace React components with compact, comfortable, and touch densities.",
2056
2056
  license: "MIT",
2057
2057
  repository: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgorbatchev/shadcn",
3
- "version": "0.0.163",
3
+ "version": "0.0.165",
4
4
  "description": "Sharp, monospace React components with compact, comfortable, and touch densities.",
5
5
  "license": "MIT",
6
6
  "repository": {