@choice-ui/react 1.8.5 → 1.8.7

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.
@@ -7,6 +7,12 @@ export interface DropdownProps {
7
7
  * @default true
8
8
  */
9
9
  autoSelectFirstItem?: boolean;
10
+ /**
11
+ * Whether to avoid collisions by flipping or shifting the dropdown position.
12
+ * When false, the dropdown will strictly follow the placement direction.
13
+ * @default true
14
+ */
15
+ avoidCollisions?: boolean;
10
16
  children?: React.ReactNode;
11
17
  disabledNested?: boolean;
12
18
  focusManagerProps?: Partial<FloatingFocusManagerProps>;
@@ -13,6 +13,7 @@ const DropdownComponent = memo(function DropdownComponent2(props) {
13
13
  const {
14
14
  children,
15
15
  autoSelectFirstItem = true,
16
+ avoidCollisions = true,
16
17
  disabledNested = false,
17
18
  offset: offsetDistance = DEFAULT_OFFSET,
18
19
  placement = "bottom-start",
@@ -77,11 +78,14 @@ const DropdownComponent = memo(function DropdownComponent2(props) {
77
78
  });
78
79
  });
79
80
  const lastPositionRef = useRef(null);
80
- const middleware = useMemo(
81
- () => [
82
- offset({ mainAxis: isNested ? 10 : offsetDistance, alignmentAxis: isNested ? -4 : 0 }),
83
- flip(),
84
- shift(),
81
+ const middleware = useMemo(() => {
82
+ const baseMiddleware = [
83
+ offset({ mainAxis: isNested ? 10 : offsetDistance, alignmentAxis: isNested ? -4 : 0 })
84
+ ];
85
+ if (avoidCollisions) {
86
+ baseMiddleware.push(flip(), shift());
87
+ }
88
+ baseMiddleware.push(
85
89
  size({
86
90
  padding: 4,
87
91
  apply({ elements, availableHeight, rects }) {
@@ -104,9 +108,9 @@ const DropdownComponent = memo(function DropdownComponent2(props) {
104
108
  }
105
109
  }
106
110
  })
107
- ],
108
- [isNested, offsetDistance, matchTriggerWidth, scrollRef]
109
- );
111
+ );
112
+ return baseMiddleware;
113
+ }, [isNested, offsetDistance, matchTriggerWidth, scrollRef, avoidCollisions]);
110
114
  const { refs, floatingStyles, context, isPositioned } = useFloating({
111
115
  nodeId,
112
116
  open: isControlledOpen,
@@ -6,9 +6,13 @@ import { MenuScrollArrowTv } from "../tv.js";
6
6
  import { useIsomorphicLayoutEffect } from "../../../../shared/hooks/use-isomorphic-layout-effect/use-isomorphic-layout-effect.js";
7
7
  import { tcx } from "../../../../shared/utils/tcx/tcx.js";
8
8
  const SCROLL_ARROW_PADDING = 16;
9
+ const MIN_HEIGHT_FOR_ARROWS = 48;
9
10
  const shouldShowArrow = (scrollRef, dir) => {
10
11
  if (scrollRef.current) {
11
12
  const { scrollTop, scrollHeight, clientHeight } = scrollRef.current;
13
+ if (clientHeight < MIN_HEIGHT_FOR_ARROWS) {
14
+ return false;
15
+ }
12
16
  if (dir === "up") {
13
17
  return scrollTop >= SCROLL_ARROW_PADDING;
14
18
  }
@@ -84,11 +84,14 @@ const MenuContextItem = memo(
84
84
  );
85
85
  const suffixConfig = useMemo(() => {
86
86
  if (suffixElement !== void 0) return suffixElement;
87
+ if (prefixElement !== void 0 && menu.selection && !customActive && selected) {
88
+ return /* @__PURE__ */ jsx(Check, {});
89
+ }
87
90
  if (asLink) {
88
91
  return /* @__PURE__ */ jsx(Launch, { className: "h-3 w-3 text-current" });
89
92
  }
90
93
  return void 0;
91
- }, [suffixElement, asLink]);
94
+ }, [suffixElement, prefixElement, menu.selection, selected, customActive, asLink]);
92
95
  const combinedRef = useCallback(
93
96
  (node) => {
94
97
  item.ref(node);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@choice-ui/react",
3
- "version": "1.8.5",
3
+ "version": "1.8.7",
4
4
  "description": "A desktop-first React UI component library built for professional desktop applications with comprehensive documentation",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@choiceform/icons-react": "^1.3.8",
54
- "@choice-ui/design-tokens": "^0.2.13",
54
+ "@choice-ui/design-tokens": "workspace:*",
55
55
  "classnames": "^2.5.1",
56
56
  "tailwind-merge": "^3.3.1",
57
57
  "tailwind-variants": "^3.1.0",