@snowball-tech/fractal
Version:
Fractal's (Snowball's design system) React component library based on RadixUI and TailwindCSS
2 lines • 2.02 kB
JavaScript
"use client";import{a as e}from"../constants-CW2-utNH.js";import{n as t,r as n}from"../helpers-DBEwVIlX.js";import{Typography as r}from"../Typography/Typography.js";import{r as i}from"../utils-K22C_6qC.js";import{GROUP_NAME as a}from"./Dropdown.constants.js";import{DropdownContext as o}from"./DropdownContext.js";import{DropdownGroupContext as s}from"./DropdownGroupContext.js";import*as c from"@radix-ui/react-dropdown-menu";import{forwardRef as l,useContext as u}from"react";import d from"lodash/fp/isEmpty.js";import f from"lodash/fp/isFunction.js";import p from"lodash/fp/isString.js";import m from"lodash/fp/omit.js";import{jsx as h,jsxs as g}from"react/jsx-runtime";const _=l(({active:l=!1,children:_,condensed:v=!1,disabled:y,href:b,icon:x,label:S,onClick:C,onSelect:w,rainbow:T=!0,target:E,value:D,...O},k)=>{let A=!!_;!A&&!S&&console.warn("You must provide a `label` or `children` to the `DropdownItem` component");let{condensed:j,disabled:M,rainbow:N}=u(o),{condensed:P,disabled:F,rainbow:I}=u(s),L=y||F||M,R=v||P||j,z=T&&I&&N,B=!d(b),V=p(S)?S:d(S)?i(_):i(S);return h(c.Item,{ref:k,"aria-label":V,asChild:!0,className:n(`${e}-${a}__item`,z?`alternatee`:``,`flex items-center gap-1`,`rounded-sm outline-none transition-background-color duration-300 ease-out`,R?`${e}-${a}__item--condensed max-h-6 px-2 py-1`:`p-2`,x?`${e}-${a}__with-icon`:``,L?`${e}-${a}__item--disabled cursor-not-allowed !bg-transparent text-disabled`:`cursor-pointer text-dark`,!L&&!z?`hover:bg-decorative-pink-90`:``,B?`${e}-${a}__item__link no-underline`:``,O.className),disabled:L,title:V,...l?{"data-highlighted":l}:{},...B?{href:b,target:E}:{},...D===void 0?{}:{"data-value":D},...f(C)?{onSelect:C}:{},...f(w)?{onSelect:w}:{},...m([`className`,`data-value`],O),children:g(r,{element:B?`a`:`div`,variant:`body-1`,children:[x&&h(`div`,{className:t(`fractal-dropdown__item__icon`,`max-h-3 max-w-3`),children:x}),A?_:S]})})});_.displayName=`DropdownItem`;export{_ as DropdownItem,_ as default};
//# sourceMappingURL=DropdownItem.js.map