@agility/plenum-ui 2.1.3 → 2.1.5

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/tailwind.css CHANGED
@@ -59222,4 +59222,12 @@ select {
59222
59222
  font-size: 0.875rem;
59223
59223
  line-height: 1.25rem;
59224
59224
  }
59225
+ }
59226
+
59227
+ .\[\&\>path\:first-of-type\]\:stroke-gray-300>path:first-of-type {
59228
+ stroke: #D1D5DB;
59229
+ }
59230
+
59231
+ .\[\&\>path\:last-of-type\]\:stroke-white>path:last-of-type {
59232
+ stroke: #fff;
59225
59233
  }
@@ -32,6 +32,7 @@ export interface IDropdownProps extends HTMLAttributes<HTMLDivElement> {
32
32
  disabled?: boolean;
33
33
  onFocus?: () => void;
34
34
  onBlur?: () => void;
35
+ showFloatingArrow?: boolean;
35
36
  }
36
37
  export declare const defaultClassNames: {
37
38
  groupClassname: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agility/plenum-ui",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -75,4 +75,12 @@ export const WithIcons: Story = {
75
75
  CustomDropdownTrigger: <IconElement />
76
76
  }
77
77
  }
78
+
79
+ export const WithFloatingArrow: Story = {
80
+ args: {
81
+ ...defaultArgs,
82
+ showFloatingArrow: true
83
+ }
84
+ }
85
+
78
86
  export default meta
@@ -15,7 +15,9 @@ import {
15
15
  FloatingList,
16
16
  useTransitionStyles,
17
17
  Placement,
18
- useListNavigation
18
+ useListNavigation,
19
+ FloatingArrow,
20
+ arrow
19
21
  } from "@floating-ui/react"
20
22
 
21
23
  import { ClassNameWithAutocomplete } from "utils/types"
@@ -54,6 +56,7 @@ export interface IDropdownProps extends HTMLAttributes<HTMLDivElement> {
54
56
  disabled?: boolean
55
57
  onFocus?: () => void
56
58
  onBlur?: () => void
59
+ showFloatingArrow?: boolean
57
60
  }
58
61
  export const defaultClassNames = {
59
62
  groupClassname: "flex inline-block text-left",
@@ -85,6 +88,7 @@ const Dropdown: React.FC<IDropdownProps> = ({
85
88
  disabled,
86
89
  onFocus,
87
90
  onBlur,
91
+ showFloatingArrow = false,
88
92
  ...props
89
93
  }: IDropdownProps): JSX.Element | null => {
90
94
  const [isOpen, setIsOpen] = useState(false)
@@ -92,6 +96,7 @@ const Dropdown: React.FC<IDropdownProps> = ({
92
96
  const [activeIndex, setActiveIndex] = useState<number | null>(null)
93
97
 
94
98
  const listRef = useRef<(HTMLButtonElement | null)[]>([])
99
+ const arrowRef = React.useRef(null)
95
100
 
96
101
  // Floating UI logic
97
102
  const { refs, floatingStyles, context } = useFloating({
@@ -113,7 +118,11 @@ const Dropdown: React.FC<IDropdownProps> = ({
113
118
  autoPlacement({
114
119
  allowedPlacements: [placement, "bottom-start", "bottom-end", "bottom"]
115
120
  }),
116
- shift({ rootBoundary: "document" })
121
+ shift({ rootBoundary: "document" }),
122
+ arrow({
123
+ element: arrowRef,
124
+ padding: 4
125
+ })
117
126
  ],
118
127
  whileElementsMounted: autoUpdate
119
128
  })
@@ -351,6 +360,9 @@ const Dropdown: React.FC<IDropdownProps> = ({
351
360
  }}
352
361
  >
353
362
  {ItemComponents}
363
+ {showFloatingArrow &&
364
+ <FloatingArrow ref={arrowRef} context={context} strokeWidth={1}
365
+ className={cn("fill-white [&>path:first-of-type]:stroke-gray-300 [&>path:last-of-type]:stroke-white")}/>}
354
366
  </div>
355
367
  </FloatingFocusManager>
356
368
  </FloatingPortal>