@mirohq/design-system-dropdown-menu 4.3.1 → 4.3.3

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/main.js CHANGED
@@ -387,12 +387,16 @@ const CheckboxItem = React__default["default"].forwardRef(
387
387
  );
388
388
 
389
389
  const CONTENT_GAP = "$50";
390
- const CONTENT_GUTTER = parseInt(designSystemStitches.theme.space[150]);
391
390
  const CONTENT_OFFSET = parseInt(designSystemStitches.theme.space[50]);
391
+ const CONTENT_PADDING_TOKENS = {
392
+ small: { y: 50, x: 150 },
393
+ medium: { y: 150, x: 150 },
394
+ large: { y: 150, x: 300 }
395
+ };
392
396
  const CONTENT_PADDING = {
393
- small: "$50 $150",
394
- medium: "$150",
395
- large: "$150 $300"
397
+ small: "$".concat(CONTENT_PADDING_TOKENS.small.y, " $").concat(CONTENT_PADDING_TOKENS.small.x),
398
+ medium: "$".concat(CONTENT_PADDING_TOKENS.medium.y, " $").concat(CONTENT_PADDING_TOKENS.medium.x),
399
+ large: "$".concat(CONTENT_PADDING_TOKENS.large.y, " $").concat(CONTENT_PADDING_TOKENS.large.x)
396
400
  };
397
401
  const contentDefaults = {
398
402
  maxWidth: "$125",
@@ -427,53 +431,47 @@ const contentDefaults = {
427
431
  }
428
432
  },
429
433
  position: "relative",
430
- zIndex: "$dropdownMenu"
434
+ zIndex: "$dropdownMenu",
435
+ outline: "1px solid transparent !important"
436
+ // important because Radix overrides outline in element styles
431
437
  };
432
438
 
433
439
  const StyledItemsContainer = designSystemStitches.styled("div", {
434
440
  display: "grid",
435
- gap: CONTENT_GAP
436
- });
437
- const StyledContent = designSystemStitches.styled(RadixDropdownMenu__namespace.Content, {
438
- ...contentDefaults,
441
+ gap: CONTENT_GAP,
439
442
  variants: {
440
443
  containerSpacing: {
441
444
  small: {
442
- '&, [role="menu"]': {
443
- padding: CONTENT_PADDING.small
444
- }
445
+ padding: CONTENT_PADDING.small
445
446
  },
446
447
  medium: {
447
- '&, [role="menu"]': {
448
- padding: CONTENT_PADDING.medium
449
- }
448
+ padding: CONTENT_PADDING.medium
450
449
  },
451
450
  large: {
452
- '&, [role="menu"]': {
453
- padding: CONTENT_PADDING.large
454
- }
451
+ padding: CONTENT_PADDING.large
455
452
  }
456
453
  }
457
454
  }
458
455
  });
456
+ const StyledContent = designSystemStitches.styled(RadixDropdownMenu__namespace.Content, {
457
+ ...contentDefaults
458
+ });
459
459
 
460
+ const RADIX_CONTENT_AVAILABLE_HEIGHT = "var(--radix-dropdown-menu-content-available-height)";
460
461
  const ScrollableContent = ({
461
462
  children,
462
463
  maxHeight,
463
464
  overflow,
464
- containerSpacing,
465
465
  direction
466
466
  }) => {
467
467
  if (overflow === "auto") {
468
- const [top, , bottom] = CONTENT_PADDING[containerSpacing].split(" ").map((value) => value.replace("$", ""));
469
- const gap = top !== void 0 && bottom !== void 0 ? "var(--space-".concat(top, ") + var(--space-").concat(bottom, ")") : "var(--space-".concat(top, ") * 2");
470
468
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystemScrollArea.ScrollArea, { dir: direction, type: "always", children: [
471
469
  /* @__PURE__ */ jsxRuntime.jsx(
472
470
  designSystemScrollArea.ScrollArea.Viewport,
473
471
  {
474
- availableHeight: "var(--radix-dropdown-menu-content-available-height)",
475
- verticalGap: gap,
476
- maxHeight,
472
+ css: {
473
+ maxHeight
474
+ },
477
475
  children
478
476
  }
479
477
  ),
@@ -530,12 +528,13 @@ const Content = React__default["default"].forwardRef(
530
528
  collisionPadding,
531
529
  sticky,
532
530
  hideWhenDetached,
533
- containerSpacing,
534
531
  children: /* @__PURE__ */ jsxRuntime.jsx(
535
532
  ScrollableContent,
536
533
  {
537
- ...{ containerSpacing, maxHeight, overflow, direction },
538
- children: /* @__PURE__ */ jsxRuntime.jsx(StyledItemsContainer, { children })
534
+ maxHeight: maxHeight !== void 0 ? "min(".concat(RADIX_CONTENT_AVAILABLE_HEIGHT, ", ").concat(typeof maxHeight === "number" ? "".concat(maxHeight, "px") : maxHeight, ")") : RADIX_CONTENT_AVAILABLE_HEIGHT,
535
+ overflow,
536
+ direction,
537
+ children: /* @__PURE__ */ jsxRuntime.jsx(StyledItemsContainer, { containerSpacing, children })
539
538
  }
540
539
  )
541
540
  }
@@ -827,38 +826,45 @@ const StyledSubContent = designSystemStitches.styled(
827
826
  contentDefaults
828
827
  );
829
828
 
830
- const SIDE_OFFSET = CONTENT_GUTTER + CONTENT_OFFSET;
831
829
  const SubContent = React__default["default"].forwardRef(
832
830
  ({
833
- sideOffset = SIDE_OFFSET,
834
- alignOffset = -CONTENT_GUTTER,
831
+ sideOffset,
832
+ alignOffset,
835
833
  collisionPadding = 0,
836
834
  loop = false,
837
835
  hideWhenDetached = true,
838
836
  sticky = "partial",
839
837
  overflow = "visible",
840
838
  maxHeight,
839
+ collisionBoundary,
841
840
  children,
842
841
  ...restProps
843
842
  }, forwardRef) => {
844
843
  const { containerSpacing } = useContent();
845
844
  const { direction } = useDropdownContext();
845
+ const paddingToken = CONTENT_PADDING_TOKENS[containerSpacing];
846
+ const contentSideOffset = CONTENT_OFFSET + parseInt(designSystemStitches.theme.space[paddingToken.x]);
847
+ const contentAlignOffset = -parseInt(designSystemStitches.theme.space[paddingToken.y]);
848
+ const availableHeight = collisionBoundary != null ? getComputedStyle(collisionBoundary).getPropertyValue("height") : RADIX_CONTENT_AVAILABLE_HEIGHT;
846
849
  return /* @__PURE__ */ jsxRuntime.jsx(ContentProvider, { containerSpacing, children: /* @__PURE__ */ jsxRuntime.jsx(
847
850
  StyledSubContent,
848
851
  {
849
852
  ...restProps,
850
853
  ref: forwardRef,
851
- sideOffset,
852
- alignOffset,
854
+ sideOffset: sideOffset != null ? sideOffset : contentSideOffset,
855
+ alignOffset: alignOffset != null ? alignOffset : contentAlignOffset,
853
856
  collisionPadding,
854
857
  loop,
855
858
  hideWhenDetached,
856
859
  sticky,
860
+ collisionBoundary,
857
861
  children: /* @__PURE__ */ jsxRuntime.jsx(
858
862
  ScrollableContent,
859
863
  {
860
- ...{ containerSpacing, maxHeight, overflow, direction },
861
- children: /* @__PURE__ */ jsxRuntime.jsx(StyledItemsContainer, { children })
864
+ maxHeight: maxHeight !== void 0 ? "min(".concat(availableHeight, ", ").concat(typeof maxHeight === "number" ? "".concat(maxHeight, "px") : maxHeight, ")") : availableHeight,
865
+ overflow,
866
+ direction,
867
+ children: /* @__PURE__ */ jsxRuntime.jsx(StyledItemsContainer, { containerSpacing, children })
862
868
  }
863
869
  )
864
870
  }