automoby-kit 1.0.59 → 1.0.60

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 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:l,disabled:i=!1,className:s,onOpenChange:o,isOpen:d,"aria-label":u,...c},p)=>{const[m,x]=r.useState(!1),g=r.useRef(null),b=r.useRef(null),y=void 0!==d?d:m,handleToggle=()=>{if(i)return;const e=!y;void 0===d&&x(e),o?.(e)};r.useEffect(()=>{const handleClickOutside=e=>{g.current&&!g.current.contains(e.target)&&(void 0===d&&x(!1),o?.(!1))};if(y)return document.addEventListener("mousedown",handleClickOutside),()=>{document.removeEventListener("mousedown",handleClickOutside)}},[y,d,o]);const f=t("inline-flex items-center justify-center","bg-white border border-neutral-light","rounded-md transition-colors duration-200","px-2 py-1 sm:px-3 sm:py-2 md:px-4 md:py-3 lg:px-6 lg:py-4 xl:px-8 xl:py-5","min-w-16 sm:min-w-20 md:min-w-24 lg:min-w-32 xl:min-w-40","hover:bg-neutral-lighter","focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",{"opacity-50 cursor-not-allowed":i,"cursor-pointer":!i}),h=t("absolute top-full z-10 mt-1","bg-white border border-neutral-light","rounded-md shadow-lg","left-0 right-0 sm:left-0 sm:right-auto sm:min-w-40 md:min-w-48 lg:min-w-56 xl:min-w-64","py-1 px-2 sm:py-2 sm:px-3 md:py-3 md:px-4 lg:py-4 lg:px-6 xl:py-5 xl:px-8","transition-all duration-200",{"opacity-100 translate-y-0 pointer-events-auto":y,"opacity-0 -translate-y-2 pointer-events-none":!y}),v=t("block w-full text-right","transition-colors duration-200","hover:bg-neutral-lighter rounded","focus:outline-none focus:bg-neutral-lighter","px-1 py-0.5 sm:px-2 sm:py-1 md:px-3 md:py-2 lg:px-4 lg:py-3 xl:px-5 xl:py-4","-mx-1 sm:-mx-2 md:-mx-3 lg:-mx-4 xl:-mx-5");return e.jsx("div",{ref:p,className:t("relative inline-block",s),...c,children:e.jsxs("div",{ref:g,children:[e.jsx("button",{ref:b,type:"button",className:f,onClick:handleToggle,onKeyDown:e=>{if(!i)switch(e.key){case"Escape":y&&(e.preventDefault(),void 0===d&&x(!1),o?.(!1),b.current?.focus());break;case"ArrowDown":y||(e.preventDefault(),handleToggle());break;case"Enter":case" ":e.preventDefault(),handleToggle()}},disabled:i,"aria-expanded":y,"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:h,children:e.jsx("div",{className:"flex flex-col gap-1 sm:gap-2 md:gap-3 lg:gap-4 xl:gap-5",children:l.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}),l={className:t(v,{"opacity-50 cursor-not-allowed":r.disabled,"cursor-pointer":!r.disabled}),onClick:r.disabled?void 0:()=>(e=>{e.disabled||(void 0===d&&x(!1),o?.(!1),e.onClick?.())})(r),"aria-label":`منوی ${r.label}`};return r.href&&!r.disabled?e.jsx("a",{...l,href:r.href,role:"menuitem",tabIndex:y?0:-1,children:a},r.id):e.jsx("button",{...l,type:"button",role:"menuitem",tabIndex:y?0:-1,disabled:r.disabled,children:a},r.id)})})})]})})});a.displayName="Menu",exports.Menu=a;
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:l,disabled:i=!1,wrapperClassName:s,buttonClassName:o,onOpenChange:d,isOpen:u,"aria-label":p,...c},m)=>{const[x,b]=r.useState(!1),g=r.useRef(null),y=r.useRef(null),f=void 0!==u?u:x,handleToggle=()=>{if(i)return;const e=!f;void 0===u&&b(e),d?.(e)};r.useEffect(()=>{const handleClickOutside=e=>{g.current&&!g.current.contains(e.target)&&(void 0===u&&b(!1),d?.(!1))};if(f)return document.addEventListener("mousedown",handleClickOutside),()=>{document.removeEventListener("mousedown",handleClickOutside)}},[f,u,d]);const h=t("inline-flex items-center justify-center","bg-white border border-neutral-light","rounded-md transition-colors duration-200","px-2 py-1 sm:px-3 sm:py-2 md:px-4 md:py-3 lg:px-6 lg:py-4 xl:px-8 xl:py-5","min-w-16 sm:min-w-20 md:min-w-24 lg:min-w-32 xl:min-w-40","hover:bg-neutral-lighter","focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",{"opacity-50 cursor-not-allowed":i,"cursor-pointer":!i},o),v=t("absolute top-full z-10 mt-1","bg-white border border-neutral-light","rounded-md shadow-lg","left-0 right-0 sm:left-0 sm:right-auto sm:min-w-40 md:min-w-48 lg:min-w-56 xl:min-w-64","py-1 px-2 sm:py-2 sm:px-3 md:py-3 md:px-4 lg:py-4 lg:px-6 xl:py-5 xl:px-8","transition-all duration-200",{"opacity-100 translate-y-0 pointer-events-auto":f,"opacity-0 -translate-y-2 pointer-events-none":!f}),w=t("block w-full text-right","transition-colors duration-200","hover:bg-neutral-lighter rounded","focus:outline-none focus:bg-neutral-lighter","px-1 py-0.5 sm:px-2 sm:py-1 md:px-3 md:py-2 lg:px-4 lg:py-3 xl:px-5 xl:py-4","-mx-1 sm:-mx-2 md:-mx-3 lg:-mx-4 xl:-mx-5");return e.jsx("div",{ref:m,className:t("relative inline-block",s),...c,children:e.jsxs("div",{ref:g,children:[e.jsx("button",{ref:y,type:"button",className:h,onClick:handleToggle,onKeyDown:e=>{if(!i)switch(e.key){case"Escape":f&&(e.preventDefault(),void 0===u&&b(!1),d?.(!1),y.current?.focus());break;case"ArrowDown":f||(e.preventDefault(),handleToggle());break;case"Enter":case" ":e.preventDefault(),handleToggle()}},disabled:i,"aria-expanded":f,"aria-haspopup":"true","aria-label":p||`منوی ${a}`,children:e.jsx(n.Typography,{variant:"body-s-heavy",color:"neutral-darker",className:"text-right",children:a})}),e.jsx("div",{className:v,children:e.jsx("div",{className:"flex flex-col gap-1 sm:gap-2 md:gap-3 lg:gap-4 xl:gap-5",children:l.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}),l={className:t(w,{"opacity-50 cursor-not-allowed":r.disabled,"cursor-pointer":!r.disabled}),onClick:r.disabled?void 0:()=>(e=>{e.disabled||(void 0===u&&b(!1),d?.(!1),e.onClick?.())})(r),"aria-label":`منوی ${r.label}`};return r.href&&!r.disabled?e.jsx("a",{...l,href:r.href,role:"menuitem",tabIndex:f?0:-1,children:a},r.id):e.jsx("button",{...l,type:"button",role:"menuitem",tabIndex:f?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 l,useEffect as a}from"react";import i from"./utils.js";import{Typography as o}from"./Typography.js";const s=t.forwardRef(({buttonText:t,items:s,disabled:d=!1,className:m,onOpenChange:p,isOpen:c,"aria-label":u,...x},b)=>{const[g,f]=n(!1),y=l(null),h=l(null),v=void 0!==c?c:g,handleToggle=()=>{if(d)return;const e=!v;void 0===c&&f(e),p?.(e)};a(()=>{const handleClickOutside=e=>{y.current&&!y.current.contains(e.target)&&(void 0===c&&f(!1),p?.(!1))};if(v)return document.addEventListener("mousedown",handleClickOutside),()=>{document.removeEventListener("mousedown",handleClickOutside)}},[v,c,p]);const w=i("inline-flex items-center justify-center","bg-white border border-neutral-light","rounded-md transition-colors duration-200","px-2 py-1 sm:px-3 sm:py-2 md:px-4 md:py-3 lg:px-6 lg:py-4 xl:px-8 xl:py-5","min-w-16 sm:min-w-20 md:min-w-24 lg:min-w-32 xl:min-w-40","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 z-10 mt-1","bg-white border border-neutral-light","rounded-md shadow-lg","left-0 right-0 sm:left-0 sm:right-auto sm:min-w-40 md:min-w-48 lg:min-w-56 xl:min-w-64","py-1 px-2 sm:py-2 sm:px-3 md:py-3 md:px-4 lg:py-4 lg:px-6 xl:py-5 xl:px-8","transition-all duration-200",{"opacity-100 translate-y-0 pointer-events-auto":v,"opacity-0 -translate-y-2 pointer-events-none":!v}),N=i("block w-full text-right","transition-colors duration-200","hover:bg-neutral-lighter rounded","focus:outline-none focus:bg-neutral-lighter","px-1 py-0.5 sm:px-2 sm:py-1 md:px-3 md:py-2 lg:px-4 lg:py-3 xl:px-5 xl:py-4","-mx-1 sm:-mx-2 md:-mx-3 lg:-mx-4 xl:-mx-5");return e("div",{ref:b,className:i("relative inline-block",m),...x,children:r("div",{ref:y,children:[e("button",{ref:h,type:"button",className:w,onClick:handleToggle,onKeyDown:e=>{if(!d)switch(e.key){case"Escape":v&&(e.preventDefault(),void 0===c&&f(!1),p?.(!1),h.current?.focus());break;case"ArrowDown":v||(e.preventDefault(),handleToggle());break;case"Enter":case" ":e.preventDefault(),handleToggle()}},disabled:d,"aria-expanded":v,"aria-haspopup":"true","aria-label":u||`منوی ${t}`,children:e(o,{variant:"body-s-heavy",color:"neutral-darker",className:"text-right",children:t})}),e("div",{className:k,children:e("div",{className:"flex flex-col gap-1 sm:gap-2 md:gap-3 lg:gap-4 xl:gap-5",children:s.map(r=>{const t=e(o,{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===c&&f(!1),p?.(!1),e.onClick?.())})(r),"aria-label":`منوی ${r.label}`};return r.href&&!r.disabled?e("a",{...n,href:r.href,role:"menuitem",tabIndex:v?0:-1,children:t},r.id):e("button",{...n,type:"button",role:"menuitem",tabIndex:v?0:-1,disabled:r.disabled,children:t},r.id)})})})]})})});s.displayName="Menu";export{s as Menu};
1
+ "use client";import{jsx as e,jsxs as r}from"react/jsx-runtime";import t,{useState as n,useRef as l,useEffect as a}from"react";import i from"./utils.js";import{Typography as o}from"./Typography.js";const s=t.forwardRef(({buttonText:t,items:s,disabled:d=!1,wrapperClassName:m,buttonClassName:p,onOpenChange:c,isOpen:u,"aria-label":x,...b},g)=>{const[f,y]=n(!1),h=l(null),v=l(null),w=void 0!==u?u:f,handleToggle=()=>{if(d)return;const e=!w;void 0===u&&y(e),c?.(e)};a(()=>{const handleClickOutside=e=>{h.current&&!h.current.contains(e.target)&&(void 0===u&&y(!1),c?.(!1))};if(w)return document.addEventListener("mousedown",handleClickOutside),()=>{document.removeEventListener("mousedown",handleClickOutside)}},[w,u,c]);const k=i("inline-flex items-center justify-center","bg-white border border-neutral-light","rounded-md transition-colors duration-200","px-2 py-1 sm:px-3 sm:py-2 md:px-4 md:py-3 lg:px-6 lg:py-4 xl:px-8 xl:py-5","min-w-16 sm:min-w-20 md:min-w-24 lg:min-w-32 xl:min-w-40","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},p),N=i("absolute top-full z-10 mt-1","bg-white border border-neutral-light","rounded-md shadow-lg","left-0 right-0 sm:left-0 sm:right-auto sm:min-w-40 md:min-w-48 lg:min-w-56 xl:min-w-64","py-1 px-2 sm:py-2 sm:px-3 md:py-3 md:px-4 lg:py-4 lg:px-6 xl:py-5 xl:px-8","transition-all duration-200",{"opacity-100 translate-y-0 pointer-events-auto":w,"opacity-0 -translate-y-2 pointer-events-none":!w}),C=i("block w-full text-right","transition-colors duration-200","hover:bg-neutral-lighter rounded","focus:outline-none focus:bg-neutral-lighter","px-1 py-0.5 sm:px-2 sm:py-1 md:px-3 md:py-2 lg:px-4 lg:py-3 xl:px-5 xl:py-4","-mx-1 sm:-mx-2 md:-mx-3 lg:-mx-4 xl:-mx-5");return e("div",{ref:g,className:i("relative inline-block",m),...b,children:r("div",{ref:h,children:[e("button",{ref:v,type:"button",className:k,onClick:handleToggle,onKeyDown:e=>{if(!d)switch(e.key){case"Escape":w&&(e.preventDefault(),void 0===u&&y(!1),c?.(!1),v.current?.focus());break;case"ArrowDown":w||(e.preventDefault(),handleToggle());break;case"Enter":case" ":e.preventDefault(),handleToggle()}},disabled:d,"aria-expanded":w,"aria-haspopup":"true","aria-label":x||`منوی ${t}`,children:e(o,{variant:"body-s-heavy",color:"neutral-darker",className:"text-right",children:t})}),e("div",{className:N,children:e("div",{className:"flex flex-col gap-1 sm:gap-2 md:gap-3 lg:gap-4 xl:gap-5",children:s.map(r=>{const t=e(o,{variant:"body-s-heavy",color:r.disabled?"neutral-main":"neutral-darker",className:"text-right",children:r.label}),n={className:i(C,{"opacity-50 cursor-not-allowed":r.disabled,"cursor-pointer":!r.disabled}),onClick:r.disabled?void 0:()=>(e=>{e.disabled||(void 0===u&&y(!1),c?.(!1),e.onClick?.())})(r),"aria-label":`منوی ${r.label}`};return r.href&&!r.disabled?e("a",{...n,href:r.href,role:"menuitem",tabIndex:w?0:-1,children:t},r.id):e("button",{...n,type:"button",role:"menuitem",tabIndex:w?0:-1,disabled:r.disabled,children:t},r.id)})})})]})})});s.displayName="Menu";export{s as Menu};
@@ -3,7 +3,7 @@ import React, { useState, useRef, useEffect } from 'react';
3
3
  import cn from './utils.js';
4
4
  import { Typography } from './Typography.js';
5
5
 
6
- const Menu = React.forwardRef(({ buttonText, items, disabled = false, className, onOpenChange, isOpen: controlledIsOpen, 'aria-label': ariaLabel, ...props }, ref) => {
6
+ const Menu = React.forwardRef(({ buttonText, items, disabled = false, wrapperClassName, buttonClassName, onOpenChange, isOpen: controlledIsOpen, 'aria-label': ariaLabel, ...props }, ref) => {
7
7
  const [internalIsOpen, setInternalIsOpen] = useState(false);
8
8
  const menuRef = useRef(null);
9
9
  const buttonRef = useRef(null);
@@ -87,7 +87,7 @@ const Menu = React.forwardRef(({ buttonText, items, disabled = false, className,
87
87
  {
88
88
  'opacity-50 cursor-not-allowed': disabled,
89
89
  'cursor-pointer': !disabled,
90
- });
90
+ }, buttonClassName);
91
91
  const dropdownClasses = cn(
92
92
  // Base dropdown styles
93
93
  'absolute top-full z-10 mt-1', 'bg-white border border-neutral-light', 'rounded-md shadow-lg',
@@ -105,7 +105,7 @@ const Menu = React.forwardRef(({ buttonText, items, disabled = false, className,
105
105
  'px-1 py-0.5 sm:px-2 sm:py-1 md:px-3 md:py-2 lg:px-4 lg:py-3 xl:px-5 xl:py-4',
106
106
  // Enhanced responsive margins
107
107
  '-mx-1 sm:-mx-2 md:-mx-3 lg:-mx-4 xl:-mx-5');
108
- 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-1 sm:gap-2 md:gap-3 lg:gap-4 xl:gap-5", children: items.map((item) => {
108
+ return (jsx("div", { ref: ref, className: cn('relative inline-block', wrapperClassName), ...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-1 sm:gap-2 md:gap-3 lg:gap-4 xl:gap-5", children: items.map((item) => {
109
109
  const content = (jsx(Typography, { variant: "body-s-heavy", color: item.disabled ? 'neutral-main' : 'neutral-darker', className: "text-right", children: item.label }));
110
110
  const commonProps = {
111
111
  className: cn(itemClasses, {
@@ -20,9 +20,13 @@ export interface MenuProps {
20
20
  */
21
21
  disabled?: boolean;
22
22
  /**
23
- * Additional CSS classes for the menu container
23
+ * Additional CSS classes for the menu wrapper container
24
24
  */
25
- className?: string;
25
+ wrapperClassName?: string;
26
+ /**
27
+ * Additional CSS classes for the main menu button
28
+ */
29
+ buttonClassName?: string;
26
30
  /**
27
31
  * Callback fired when menu open state changes
28
32
  */
@@ -31,6 +31,20 @@ declare const _default: {
31
31
  type: string;
32
32
  };
33
33
  };
34
+ wrapperClassName: {
35
+ name: string;
36
+ control: {
37
+ type: string;
38
+ };
39
+ description: string;
40
+ };
41
+ buttonClassName: {
42
+ name: string;
43
+ control: {
44
+ type: string;
45
+ };
46
+ description: string;
47
+ };
34
48
  items: {
35
49
  name: string;
36
50
  control: {
@@ -44,6 +58,8 @@ type StoryProps = {
44
58
  buttonText: string;
45
59
  disabled: boolean;
46
60
  isOpen?: boolean;
61
+ wrapperClassName?: string;
62
+ buttonClassName?: string;
47
63
  items: MenuItem[];
48
64
  };
49
65
  export declare const Playground: {
@@ -79,6 +95,10 @@ export declare const ControlledMenu: {
79
95
  (): import("react/jsx-runtime").JSX.Element;
80
96
  storyName: string;
81
97
  };
98
+ export declare const CustomStyling: {
99
+ (): import("react/jsx-runtime").JSX.Element;
100
+ storyName: string;
101
+ };
82
102
  export declare const ResponsiveDemo: {
83
103
  (): import("react/jsx-runtime").JSX.Element;
84
104
  storyName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "automoby-kit",
3
- "version": "1.0.59",
3
+ "version": "1.0.60",
4
4
  "description": "A comprehensive React UI component library - created in war 2025",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",