automoby-kit 1.0.47 → 1.0.48
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/cjs/Menu.js +1 -1
- package/dist/esm/Menu.js +1 -1
- package/dist/types/Menu.js +4 -4
- package/package.json +1 -1
package/dist/cjs/Menu.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("./utils.js"),n=require("./Typography.js");const a=r.forwardRef(({buttonText:a,items:i,disabled:o=!1,className:s,onOpenChange:l,isOpen:d,"aria-label":u,...c},
|
|
1
|
+
"use client";"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("./utils.js"),n=require("./Typography.js");const a=r.forwardRef(({buttonText:a,items:i,disabled:o=!1,className:s,onOpenChange:l,isOpen:d,"aria-label":u,...c},b)=>{const[p,f]=r.useState(!1),h=r.useRef(null),m=r.useRef(null),v=void 0!==d?d:p,handleToggle=()=>{if(o)return;const e=!v;void 0===d&&f(e),l?.(e)};r.useEffect(()=>{const handleClickOutside=e=>{h.current&&!h.current.contains(e.target)&&(void 0===d&&f(!1),l?.(!1))};if(v)return document.addEventListener("mousedown",handleClickOutside),()=>{document.removeEventListener("mousedown",handleClickOutside)}},[v,d,l]);const y=t("inline-flex items-center justify-center","bg-white border border-neutral-light","rounded-md px-4 py-3","transition-colors duration-200","hover:bg-neutral-lighter","focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",{"opacity-50 cursor-not-allowed":o,"cursor-pointer":!o}),x=t("absolute top-full left-0 right-0 z-10 mt-1","bg-white border border-neutral-light","rounded-md py-3 px-4","shadow-lg","transition-all duration-200",{"opacity-100 translate-y-0 pointer-events-auto":v,"opacity-0 -translate-y-2 pointer-events-none":!v}),g=t("block w-full text-right","transition-colors duration-200","hover:bg-neutral-lighter rounded px-2 py-1 -mx-2","focus:outline-none focus:bg-neutral-lighter");return e.jsx("div",{ref:b,className:t("relative inline-block",s),...c,children:e.jsxs("div",{ref:h,children:[e.jsx("button",{ref:m,type:"button",className:y,onClick:handleToggle,onKeyDown:e=>{if(!o)switch(e.key){case"Escape":v&&(e.preventDefault(),void 0===d&&f(!1),l?.(!1),m.current?.focus());break;case"ArrowDown":v||(e.preventDefault(),handleToggle());break;case"Enter":case" ":e.preventDefault(),handleToggle()}},disabled:o,"aria-expanded":v,"aria-haspopup":"true","aria-label":u||`منوی ${a}`,children:e.jsx(n.Typography,{variant:"body-s-heavy",color:"neutral-darker",className:"text-right",children:a})}),e.jsx("div",{className:x,children:e.jsx("div",{className:"flex flex-col gap-4",children:i.map(r=>{const a=e.jsx(n.Typography,{variant:"body-s-heavy",color:r.disabled?"neutral-main":"neutral-darker",className:"text-right",children:r.label}),i={className:t(g,{"opacity-50 cursor-not-allowed":r.disabled,"cursor-pointer":!r.disabled}),onClick:r.disabled?void 0:()=>(e=>{e.disabled||(void 0===d&&f(!1),l?.(!1),e.onClick?.())})(r),"aria-label":`منوی ${r.label}`};return r.href&&!r.disabled?e.jsx("a",{...i,href:r.href,role:"menuitem",tabIndex:v?0:-1,children:a},r.id):e.jsx("button",{...i,type:"button",role:"menuitem",tabIndex:v?0:-1,disabled:r.disabled,children:a},r.id)})})})]})})});a.displayName="Menu",exports.Menu=a;
|
package/dist/esm/Menu.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as r}from"react/jsx-runtime";import t,{useState as n,useRef as o,useEffect as a}from"react";import i from"./utils.js";import{Typography as l}from"./Typography.js";const s=t.forwardRef(({buttonText:t,items:s,disabled:d=!1,className:c,onOpenChange:u,isOpen:
|
|
1
|
+
"use client";import{jsx as e,jsxs as r}from"react/jsx-runtime";import t,{useState as n,useRef as o,useEffect as a}from"react";import i from"./utils.js";import{Typography as l}from"./Typography.js";const s=t.forwardRef(({buttonText:t,items:s,disabled:d=!1,className:c,onOpenChange:u,isOpen:b,"aria-label":p,...m},f)=>{const[h,v]=n(!1),g=o(null),y=o(null),x=void 0!==b?b:h,handleToggle=()=>{if(d)return;const e=!x;void 0===b&&v(e),u?.(e)};a(()=>{const handleClickOutside=e=>{g.current&&!g.current.contains(e.target)&&(void 0===b&&v(!1),u?.(!1))};if(x)return document.addEventListener("mousedown",handleClickOutside),()=>{document.removeEventListener("mousedown",handleClickOutside)}},[x,b,u]);const w=i("inline-flex items-center justify-center","bg-white border border-neutral-light","rounded-md px-4 py-3","transition-colors duration-200","hover:bg-neutral-lighter","focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",{"opacity-50 cursor-not-allowed":d,"cursor-pointer":!d}),k=i("absolute top-full left-0 right-0 z-10 mt-1","bg-white border border-neutral-light","rounded-md py-3 px-4","shadow-lg","transition-all duration-200",{"opacity-100 translate-y-0 pointer-events-auto":x,"opacity-0 -translate-y-2 pointer-events-none":!x}),N=i("block w-full text-right","transition-colors duration-200","hover:bg-neutral-lighter rounded px-2 py-1 -mx-2","focus:outline-none focus:bg-neutral-lighter");return e("div",{ref:f,className:i("relative inline-block",c),...m,children:r("div",{ref:g,children:[e("button",{ref:y,type:"button",className:w,onClick:handleToggle,onKeyDown:e=>{if(!d)switch(e.key){case"Escape":x&&(e.preventDefault(),void 0===b&&v(!1),u?.(!1),y.current?.focus());break;case"ArrowDown":x||(e.preventDefault(),handleToggle());break;case"Enter":case" ":e.preventDefault(),handleToggle()}},disabled:d,"aria-expanded":x,"aria-haspopup":"true","aria-label":p||`منوی ${t}`,children:e(l,{variant:"body-s-heavy",color:"neutral-darker",className:"text-right",children:t})}),e("div",{className:k,children:e("div",{className:"flex flex-col gap-4",children:s.map(r=>{const t=e(l,{variant:"body-s-heavy",color:r.disabled?"neutral-main":"neutral-darker",className:"text-right",children:r.label}),n={className:i(N,{"opacity-50 cursor-not-allowed":r.disabled,"cursor-pointer":!r.disabled}),onClick:r.disabled?void 0:()=>(e=>{e.disabled||(void 0===b&&v(!1),u?.(!1),e.onClick?.())})(r),"aria-label":`منوی ${r.label}`};return r.href&&!r.disabled?e("a",{...n,href:r.href,role:"menuitem",tabIndex:x?0:-1,children:t},r.id):e("button",{...n,type:"button",role:"menuitem",tabIndex:x?0:-1,disabled:r.disabled,children:t},r.id)})})})]})})});s.displayName="Menu";export{s as Menu};
|
package/dist/types/Menu.js
CHANGED
|
@@ -78,7 +78,7 @@ const Menu = React.forwardRef(({ buttonText, items, disabled = false, className,
|
|
|
78
78
|
};
|
|
79
79
|
const buttonClasses = cn(
|
|
80
80
|
// Base button styles matching Figma design
|
|
81
|
-
'inline-flex items-center justify-center', 'bg-white border border-neutral-light', 'rounded-
|
|
81
|
+
'inline-flex items-center justify-center', 'bg-white border border-neutral-light', 'rounded-md px-4 py-3', 'transition-colors duration-200',
|
|
82
82
|
// Interactive states
|
|
83
83
|
'hover:bg-neutral-lighter', 'focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2',
|
|
84
84
|
// Disabled state
|
|
@@ -88,14 +88,14 @@ const Menu = React.forwardRef(({ buttonText, items, disabled = false, className,
|
|
|
88
88
|
});
|
|
89
89
|
const dropdownClasses = cn(
|
|
90
90
|
// Base dropdown styles
|
|
91
|
-
'absolute top-full left-0 right-0 z-10 mt-
|
|
91
|
+
'absolute top-full left-0 right-0 z-10 mt-1', 'bg-white border border-neutral-light', 'rounded-md py-3 px-4', 'shadow-lg',
|
|
92
92
|
// Animation
|
|
93
93
|
'transition-all duration-200', {
|
|
94
94
|
'opacity-100 translate-y-0 pointer-events-auto': isOpen,
|
|
95
95
|
'opacity-0 -translate-y-2 pointer-events-none': !isOpen,
|
|
96
96
|
});
|
|
97
|
-
const itemClasses = cn('block w-full text-right', 'transition-colors duration-200', 'hover:bg-neutral-lighter rounded
|
|
98
|
-
return (jsx("div", { ref: ref, className: cn('relative inline-block', className), ...props, children: jsxs("div", { ref: menuRef, children: [jsx("button", { ref: buttonRef, type: "button", className: buttonClasses, onClick: handleToggle, onKeyDown: handleKeyDown, disabled: disabled, "aria-expanded": isOpen, "aria-haspopup": "true", "aria-label": ariaLabel || `منوی ${buttonText}`, children: jsx(Typography, { variant: "body-s-heavy", color: "neutral-darker", className: "text-right", children: buttonText }) }), jsx("div", { className: dropdownClasses, children: jsx("div", { className: "flex flex-col gap-
|
|
97
|
+
const itemClasses = cn('block w-full text-right', 'transition-colors duration-200', 'hover:bg-neutral-lighter rounded px-2 py-1 -mx-2', 'focus:outline-none focus:bg-neutral-lighter');
|
|
98
|
+
return (jsx("div", { ref: ref, className: cn('relative inline-block', className), ...props, children: jsxs("div", { ref: menuRef, children: [jsx("button", { ref: buttonRef, type: "button", className: buttonClasses, onClick: handleToggle, onKeyDown: handleKeyDown, disabled: disabled, "aria-expanded": isOpen, "aria-haspopup": "true", "aria-label": ariaLabel || `منوی ${buttonText}`, children: jsx(Typography, { variant: "body-s-heavy", color: "neutral-darker", className: "text-right", children: buttonText }) }), jsx("div", { className: dropdownClasses, children: jsx("div", { className: "flex flex-col gap-4", children: items.map((item) => {
|
|
99
99
|
const content = (jsx(Typography, { variant: "body-s-heavy", color: item.disabled ? 'neutral-main' : 'neutral-darker', className: "text-right", children: item.label }));
|
|
100
100
|
const commonProps = {
|
|
101
101
|
className: cn(itemClasses, {
|