@alexgorbatchev/shadcn 0.0.165 → 0.0.166

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.
@@ -895,6 +895,7 @@ function DiagramViewer({
895
895
  });
896
896
  const center = useRef4({ x: 0.5, y: 0.5 });
897
897
  const viewportRef = useRef4(null);
898
+ const toolbarContainerRef = useRef4(null);
898
899
  const toolbarRef = useRef4(null);
899
900
  const mergedStageRef = useMergedRefs3(viewportRef, stageRef);
900
901
  const viewportSize = useElementSize(viewportRef);
@@ -906,26 +907,33 @@ function DiagramViewer({
906
907
  const hasToolbar = showZoomControl || toolbar !== undefined;
907
908
  const updateToolbarOverflow = useCallback(() => {
908
909
  const el = toolbarRef.current;
910
+ const outer = toolbarContainerRef.current;
909
911
  if (!el) {
910
912
  setToolbarOverflow((current) => current.left || current.right ? { left: false, right: false } : current);
911
913
  return;
912
914
  }
913
- const left = el.scrollLeft > 1;
914
- const right = el.scrollLeft + el.clientWidth < el.scrollWidth - 1;
915
+ const availableWidth = outer?.clientWidth ?? el.clientWidth;
916
+ const hasOverflow = el.scrollWidth > availableWidth + 1;
917
+ const left = hasOverflow && el.scrollLeft > 1;
918
+ const right = hasOverflow && el.scrollLeft + el.clientWidth < el.scrollWidth - 1;
915
919
  setToolbarOverflow((current) => current.left === left && current.right === right ? current : { left, right });
916
920
  }, []);
917
921
  useIsoLayoutEffect4(() => {
918
922
  const el = toolbarRef.current;
923
+ const outer = toolbarContainerRef.current;
919
924
  if (!el)
920
925
  return;
921
926
  updateToolbarOverflow();
922
927
  const observer = new ResizeObserver(updateToolbarOverflow);
923
928
  observer.observe(el);
929
+ if (outer)
930
+ observer.observe(outer);
924
931
  return () => observer.disconnect();
925
932
  }, [hasToolbar, updateToolbarOverflow]);
926
933
  const scrollToolbar = (delta) => {
927
934
  toolbarRef.current?.scrollBy({ left: delta, behavior: "smooth" });
928
935
  };
936
+ const toolbarMaskImage = toolbarOverflow.left && toolbarOverflow.right ? "linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)" : toolbarOverflow.left ? "linear-gradient(to right, transparent, black 24px)" : toolbarOverflow.right ? "linear-gradient(to right, black calc(100% - 24px), transparent)" : undefined;
929
937
  useIsoLayoutEffect4(() => {
930
938
  if (zoom !== undefined || openingZoom !== undefined || !naturalSize || !viewportSize)
931
939
  return;
@@ -950,12 +958,24 @@ function DiagramViewer({
950
958
  className: "flex size-full min-h-0 min-w-0 flex-1 flex-col gap-2",
951
959
  children: [
952
960
  hasToolbar && /* @__PURE__ */ jsxs5("div", {
953
- className: "relative flex min-w-0 shrink-0 items-center",
961
+ ref: toolbarContainerRef,
962
+ className: "flex min-w-0 shrink-0 items-center gap-control-gap",
954
963
  children: [
964
+ toolbarOverflow.left && /* @__PURE__ */ jsx5(Button2, {
965
+ type: "button",
966
+ variant: "outline",
967
+ size: "icon-sm",
968
+ density,
969
+ "aria-label": "Scroll toolbar left",
970
+ className: "shrink-0",
971
+ onClick: () => scrollToolbar(-120),
972
+ children: /* @__PURE__ */ jsx5(ChevronLeftIcon, {})
973
+ }),
955
974
  /* @__PURE__ */ jsxs5("div", {
956
975
  ref: toolbarRef,
957
976
  "data-slot": "diagram-viewer-toolbar",
958
977
  onScroll: updateToolbarOverflow,
978
+ style: toolbarMaskImage ? { maskImage: toolbarMaskImage, WebkitMaskImage: toolbarMaskImage } : undefined,
959
979
  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
980
  children: [
961
981
  showZoomControl && /* @__PURE__ */ jsx5(ImageZoomControl, {
@@ -968,31 +988,15 @@ function DiagramViewer({
968
988
  toolbar
969
989
  ]
970
990
  }),
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
- })
991
+ toolbarOverflow.right && /* @__PURE__ */ jsx5(Button2, {
992
+ type: "button",
993
+ variant: "outline",
994
+ size: "icon-sm",
995
+ density,
996
+ "aria-label": "Scroll toolbar right",
997
+ className: "shrink-0",
998
+ onClick: () => scrollToolbar(120),
999
+ children: /* @__PURE__ */ jsx5(ChevronRightIcon, {})
996
1000
  })
997
1001
  ]
998
1002
  }),
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.165",
2054
+ version: "0.0.166",
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.165",
3
+ "version": "0.0.166",
4
4
  "description": "Sharp, monospace React components with compact, comfortable, and touch densities.",
5
5
  "license": "MIT",
6
6
  "repository": {