UNPKG

@snowball-tech/fractal

Version:

Fractal's (Snowball's design system) React component library based on RadixUI and TailwindCSS

2 lines 1.92 kB
"use client";import{PREFIX as e}from"../../constants.js";import{cj as t,cn as n}from"../../styles/helpers.js";import r from"../Typography/Typography.js";import{onlyText as i}from"../../utils.js";import{GROUP_NAME as a}from"./Menu.constants.js";import{MenuContext as o}from"./MenuContext.js";import{MenuGroupContext as s}from"./MenuGroupContext.js";import{forwardRef as c,useContext as l}from"react";import u from"lodash/fp/isEmpty.js";import d from"lodash/fp/isFunction.js";import f from"lodash/fp/isString.js";import p from"lodash/fp/omit.js";import{jsx as m,jsxs as h}from"react/jsx-runtime";const g=c(({active:c=!1,children:g,condensed:_=!1,disabled:v,href:y,icon:b,label:x,onActivate:S,onClick:C,onKeyDown:w,rainbow:T=!0,target:E,...D},O)=>{let k=!!g;!k&&!x&&console.warn("You must provide a `label` or `children` to the `MenuItem` component");let{condensed:A,disabled:j,rainbow:M}=l(o),{condensed:N,disabled:P,rainbow:F}=l(s),I=v||j||P,L=_||A||N,R=T&&F&&M,z=!u(y),B=e=>{d(C)&&C(e),d(S)&&S()},V=e=>{d(w)&&w(e),(e.key===`Enter`||e.key===` `)&&d(S)&&S()},H=f(x)?x:u(x)?i(g):i(x);return h(r,{ref:O,"aria-label":H,className:n(`${e}-${a}__item`,R?`alternatee`:``,`flex flex-row items-center gap-1 text-nowrap`,`rounded-sm outline-none transition-background-color duration-300 ease-out`,L?`max-h-6 px-2 py-1`:`p-2`,b?`${e}-${a}--with-icon`:``,I?`${e}-${a}__item--disabled pointer-events-none cursor-not-allowed !bg-transparent text-disabled`:`cursor-pointer text-dark`,!I&&!R?`hover:bg-decorative-pink-90`:``,z?`${e}-${a}__item__link no-underline`:``,D.className),element:z?`a`:`div`,role:`menuitem`,tabIndex:-1,title:H,onClick:B,onKeyDown:V,...c?{"data-highlighted":c}:{},...z?{href:y,target:E}:{},...p([`className`,`data-value`],D),children:[b&&m(`div`,{className:t(`fractal-menu__item__icon`,`max-h-3 max-w-3`),children:b}),k?g:x]})});g.displayName=`MenuItem`;export{g as default}; //# sourceMappingURL=MenuItem.js.map