automoby-kit 1.0.40 → 1.0.42
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/Backdrop.js +1 -1
- package/dist/cjs/Chips.js +1 -1
- package/dist/cjs/Pagination.js +1 -1
- package/dist/cjs/chunks/Chips-BY1LBLLt.js +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/esm/Backdrop.js +1 -1
- package/dist/esm/Chips.js +1 -1
- package/dist/esm/Pagination.js +1 -1
- package/dist/esm/chunks/Chips-DV9Y7v7k.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/types/Backdrop.js +1 -1
- package/dist/types/Chips-zfhiOvK2.js +112 -0
- package/dist/types/Chips.js +6 -112
- package/dist/types/Pagination.js +44 -15
- package/dist/types/components/Dialog/Dialog.d.ts +18 -0
- package/dist/types/components/Dialog/Dialog.stories.d.ts +13 -0
- package/dist/types/components/Pagination/Pagination.d.ts +8 -0
- package/dist/types/components/Pagination/Pagination.stories.d.ts +23 -2
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.js +35 -5
- package/package.json +1 -1
package/dist/cjs/Backdrop.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var r=require("react/jsx-runtime"),e=require("react"),t=require("./utils.js");const
|
|
1
|
+
"use strict";var r=require("react/jsx-runtime"),e=require("react"),t=require("./utils.js");const n=e.forwardRef(({isOpen:e=!1,onClick:n,blur:i=!1,zIndex:s=40,className:a,children:c,...l},o)=>{if(!e)return null;const u=t("fixed inset-0 transition-all duration-300 flex items-center justify-center",{"backdrop-blur-sm":i},a),d={backgroundColor:"rgba(0, 0, 0, 0.60)",zIndex:s};return r.jsx("div",{ref:o,className:u,style:d,onClick:r=>{n&&r.target===r.currentTarget&&n()},role:"presentation",...l,children:c})});n.displayName="Backdrop",exports.Backdrop=n;
|
package/dist/cjs/Chips.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,"__esModule",{value:!0})
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("react/jsx-runtime"),require("react"),require("./utils.js"),require("./contexts.js");var e=require("./chunks/Chips-BY1LBLLt.js");require("./chunks/createLucideIcon-BqJVOzoK.js"),exports.Chips=e.Chips,exports.default=e.Chips;
|
package/dist/cjs/Pagination.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";var e=require("react/jsx-runtime"),i=require("react"),
|
|
1
|
+
"use client";"use strict";var e=require("react/jsx-runtime"),i=require("react"),n=require("./utils.js"),t=require("./contexts.js"),a=require("./chunks/createLucideIcon-BqJVOzoK.js"),r=require("./chunks/chevron-left-Do__K6cA.js");const s=a.createLucideIcon("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),o=a.createLucideIcon("chevrons-left",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]),c=a.createLucideIcon("chevrons-right",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]),l=a.createLucideIcon("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);function PaginationRoot({className:i,...t}){return e.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:n("mx-auto flex w-full justify-center",i),...t})}function PaginationContent({className:i,device:t,...a}){return e.jsx("ul",{"data-slot":"pagination-content",className:n("flex flex-row items-center","mobile"===t?"gap-[6px]":"gap-2",i),...a})}function PaginationItem({...i}){return e.jsx("li",{"data-slot":"pagination-item",...i})}function PaginationLink({className:i,device:t,variant:a,isActive:r,linkComponent:s,...o}){const c=s??"a";return e.jsx(c,{"aria-current":r?"page":void 0,"data-slot":"pagination-link","data-active":r,className:n(buttonVariants({variant:"nextPrev"===a?a:r?"active":"outline",device:t}),i),tabIndex:o["aria-disabled"]?-1:0,...o})}function PaginationPrevious({className:i,device:n,variant:t,...a}){const r="mobile"===n,o={mobile:e.jsx(s,{size:18}),desktop:e.jsxs(e.Fragment,{children:[e.jsx(c,{size:20})," ",e.jsx("span",{children:"قبلی"})]})};return e.jsx(PaginationLink,{"aria-label":"Go to previous page",className:r?"ml-2.5":"flex justify-center items-center gap-2 w-[89px] h-[48px] ml-4",device:n,variant:"nextPrev",...a,children:"mobile"===n?o.mobile:o.desktop})}function PaginationNext({className:i,device:n,variant:t,...a}){const s="mobile"===n,c={mobile:e.jsx(r.ChevronLeft,{size:18}),desktop:e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"بعدی"}),e.jsx(o,{size:20})]})};return e.jsx(PaginationLink,{"aria-label":"Go to next page",className:s?"mr-2.5":"flex justify-center items-center gap-2 w-[89px] h-[48px] mr-4",device:n,variant:"nextPrev",...a,children:"mobile"===n?c.mobile:c.desktop})}function PaginationEllipsis({className:i,...t}){return e.jsx("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:n("flex size-9 items-center justify-center",i),...t,children:e.jsx(l,{className:"size-4"})})}function buttonVariants({variant:e,device:i}){const t="mobile"===i;return[n({"flex items-center justify-center rounded-[6px]":!0,"w-[40px] h-[40px] text-s font-heavy":t,"w-[48px] h-[48px] text-l font-heavy":!t}),{outline:"border border-neutral-light bg-white text-neutral-darker",active:"bg-primary text-white",nextPrev:"border border-neutral-light bg-white text-neutral-darker"}[e]].join(" ")}exports.Pagination=({pageCount:n,page:a,defaultPage:r=1,onPageChange:s,className:o,isMobile:c,baseUrl:l,linkComponent:d,...x})=>{const u=t.useMobile(),h=c??u,m=void 0!==a,[p,v]=i.useState(r),g=m?a:p,f=h?"mobile":"desktop";i.useEffect(()=>{m||v(r)},[r,m]);const changePage=e=>{m||v(e),s?.(e)},buildHref=e=>{if(!l)return"#";try{const i=new URL(l,"http://localhost");i.searchParams.set("page",String(e));const{pathname:n,search:t,hash:a}=i;return`${n}${t}${a}`}catch{const i=l.includes("?");return`${l}${i?"&":"?"}page=${e}`}};return e.jsx(PaginationRoot,{className:o,...x,children:e.jsxs(PaginationContent,{device:f,children:[e.jsx(PaginationItem,{children:e.jsx(PaginationPrevious,{href:buildHref(Math.max(1,g-1)),linkComponent:d,onClick:e=>{s&&e.preventDefault(),g>1&&changePage(g-1)},variant:"nextPrev",device:f,"aria-disabled":1===g,tabIndex:1===g?-1:0})}),function(){const i=[];if(n<=5)for(let t=1;t<=n;t++)i.push(e.jsx(PaginationItem,{children:e.jsx(PaginationLink,{href:buildHref(t),isActive:g===t,variant:"main",device:f,linkComponent:d,onClick:e=>{s&&e.preventDefault(),g!==t&&changePage(t)},"aria-disabled":g===t,tabIndex:g===t?-1:0,children:t})},t));else{i.push(e.jsx(PaginationItem,{children:e.jsx(PaginationLink,{href:buildHref(1),isActive:1===g,device:f,variant:"main",linkComponent:d,onClick:e=>{s&&e.preventDefault(),1!==g&&changePage(1)},"aria-disabled":1===g,tabIndex:1===g?-1:0,children:"1"})},1)),g>3&&i.push(e.jsx(PaginationItem,{children:e.jsx(PaginationEllipsis,{})},"start-ellipsis"));const t=Math.max(2,g-1),a=Math.min(n-1,g+1);for(let n=t;n<=a;n++)i.push(e.jsx(PaginationItem,{children:e.jsx(PaginationLink,{href:buildHref(n),isActive:g===n,device:f,variant:"main",linkComponent:d,onClick:e=>{s&&e.preventDefault(),g!==n&&changePage(n)},"aria-disabled":g===n,tabIndex:g===n?-1:0,children:n})},n));g<n-2&&i.push(e.jsx(PaginationItem,{children:e.jsx(PaginationEllipsis,{})},"end-ellipsis")),i.push(e.jsx(PaginationItem,{children:e.jsx(PaginationLink,{href:buildHref(n),isActive:g===n,device:f,variant:"main",linkComponent:d,onClick:e=>{s&&e.preventDefault(),g!==n&&changePage(n)},"aria-disabled":g===n,tabIndex:g===n?-1:0,children:n})},n))}return i}(),e.jsx(PaginationItem,{children:e.jsx(PaginationNext,{href:buildHref(Math.min(n,g+1)),linkComponent:d,onClick:e=>{s&&e.preventDefault(),g<n&&changePage(g+1)},variant:"nextPrev",device:f,"aria-disabled":g===n,tabIndex:g===n?-1:0})})]})})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("../utils.js"),i=require("../contexts.js");const o=require("./createLucideIcon-BqJVOzoK.js").createLucideIcon("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),n={purple:{background:"bg-primary-lightest",text:"text-primary-darkest",border:"border-primary-light"},red:{background:"bg-error-light",text:"text-error",border:"border-[#f0d6d6]"},green:{background:"bg-success-light",text:"text-success",border:"border-[#d4e8dc]"},orange:{background:"bg-warning-light",text:"text-warning",border:"border-[#f5e1d1]"},blue:{background:"bg-info-light",text:"text-info",border:"border-[#d3e9f2]"},white:{background:"bg-white",text:"text-neutral-darker",border:"border-neutral-light"},disabled:{background:"bg-neutral-lighter",text:"text-neutral-main",border:"border-neutral-light"}},a={mobile:{padding:"px-2.5 py-1",gap:"gap-1",iconSize:"size-4",fontSize:"text-xs",lineHeight:"leading-[1.8]"},desktop:{padding:"px-3 py-1",gap:"gap-1.5",iconSize:"size-5",fontSize:"text-s",lineHeight:"leading-[24px]"}},d=r.forwardRef(({variant:r="purple",size:d,children:s="متن پیشفرض",disabled:l=!1,onClick:c,onIconClick:b,className:g,isMobile:u,...p},x)=>{const h=i.useMobile(),k=n[l?"disabled":r],f=a[d||(u??h?"mobile":"desktop")],handleIconClick=e=>{e.stopPropagation(),b&&b()};return e.jsxs("div",{ref:x,className:t("relative rounded-[50px] border border-solid inline-flex","flex-row items-center justify-center","font-sans font-bold not-italic","text-nowrap text-right","transition-all duration-200",k.background,k.text,k.border,f.padding,f.gap,f.fontSize,f.lineHeight,c&&!l&&"cursor-pointer hover:opacity-80",l&&"cursor-not-allowed opacity-60",g),onClick:l?void 0:c,onKeyDown:c&&!l?e=>{"Enter"!==e.key&&" "!==e.key||!c||l||(e.preventDefault(),c())}:void 0,tabIndex:c&&!l?0:void 0,role:c?"button":void 0,...p,children:[e.jsx("span",{className:"text-center",children:s}),(()=>{const r=e.jsx(o,{className:t(f.iconSize)});return b?e.jsx("button",{type:"button",onClick:handleIconClick,disabled:l,className:t("flex items-center justify-center","hover:opacity-70 transition-opacity",l&&"cursor-not-allowed opacity-50"),"aria-label":"حذف",children:r}):r})()]})});d.displayName="Chips",exports.Chips=d,exports.X=o;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e=require("./Typography.js"),r=require("./Button.js"),s=require("./Input.js"),o=require("./Tabs.js"),a=require("./Drawer.js"),i=require("./Backdrop.js"),t=require("./Breadcrumb.js"),l=require("./Pagination.js"),n=require("./Accordion.js"),c=require("./Divider.js"),d=require("./RadioGroup.js"),u=require("./chunks/Chips-BY1LBLLt.js"),x=require("./Menu.js"),p=require("react/jsx-runtime"),b=require("react"),m=require("./utils.js"),h=require("./contexts.js");require("react-dom"),require("./chunks/chevron-left-Do__K6cA.js"),require("./chunks/createLucideIcon-BqJVOzoK.js");const j=b.forwardRef(({isOpen:e=!1,onClose:r,title:s,content:o,buttons:a,showCloseButton:t=!0,size:l="md",className:n,children:c},d)=>{const handleClose=()=>{r&&r()},x=m("bg-white rounded-[10px] shadow-lg mx-4 w-full",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl"}[l],n);return p.jsx(i.Backdrop,{isOpen:e,onClick:handleClose,blur:!0,children:p.jsx("div",{ref:d,className:x,onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Escape"===e.key&&r&&r()},role:"dialog","aria-modal":"true","aria-labelledby":s?"dialog-title":void 0,children:p.jsxs("div",{className:"flex flex-col p-6 gap-8",children:[s&&p.jsx("div",{className:"flex flex-col gap-2.5",children:p.jsx("div",{className:"flex items-center justify-between pb-4 border-b border-[#ebeaf0]",children:p.jsxs("div",{className:"flex items-center justify-between gap-3 w-full flex-row-reverse",children:[p.jsx("div",{className:"text-[#590d8b] text-xl font-extrabold leading-8",children:s}),t&&p.jsx("button",{type:"button",onClick:handleClose,className:"p-1 rounded-full hover:bg-gray-100 transition-colors","aria-label":"Close dialog",children:p.jsx(u.X,{className:"w-6 h-6 text-[#a4a2bb]"})})]})})}),o&&p.jsx("div",{className:"flex flex-col gap-4",children:o}),c&&!o&&p.jsx("div",{className:"flex flex-col gap-4",children:c}),a&&p.jsx("div",{className:"flex flex-col gap-1.5",children:a})]})})})});j.displayName="Dialog";const g=b.forwardRef(({variant:e="primary",icon:r,children:s,className:o,...a},i)=>{const t=m("h-14 px-4 py-[13px] rounded-md font-bold text-base leading-[1.8] flex items-center justify-center gap-2 transition-colors",{"bg-[#590d8b] text-white hover:bg-[#4a0a75]":"primary"===e,"bg-white text-[#1a1922] border border-[#ebeaf0] hover:bg-gray-50":"secondary"===e},o);return p.jsxs("button",{type:"button",ref:i,className:t,...a,children:[s,r&&p.jsx("span",{className:"w-5 h-5",children:r})]})});g.displayName="DialogButton";const f=e.Typography,v=r.Button,w=s.Input,y=o.Tabs,q=a.Drawer,N=i.Backdrop,B=t.Breadcrumb,k=l.Pagination,D=n.Accordion,C=c.Divider,M=d.RadioGroup,P=u.Chips,T=x.Menu;exports.MobileProvider=h.MobileProvider,exports.useMobile=h.useMobile,exports.Accordion=D,exports.Backdrop=N,exports.Breadcrumb=B,exports.Button=v,exports.Chips=P,exports.Dialog=j,exports.DialogButton=g,exports.Divider=C,exports.Drawer=q,exports.Input=w,exports.Menu=T,exports.Pagination=k,exports.RadioGroup=M,exports.Tabs=y,exports.Typography=f;
|
package/dist/esm/Backdrop.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import e from"react";import t from"./utils.js";const n=e.forwardRef(({isOpen:e=!1,onClick:n,blur:
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import e from"react";import t from"./utils.js";const n=e.forwardRef(({isOpen:e=!1,onClick:n,blur:i=!1,zIndex:o=40,className:a,children:l,...s},c)=>{if(!e)return null;const d=t("fixed inset-0 transition-all duration-300 flex items-center justify-center",{"backdrop-blur-sm":i},a);return r("div",{ref:c,className:d,style:{backgroundColor:"rgba(0, 0, 0, 0.60)",zIndex:o},onClick:r=>{n&&r.target===r.currentTarget&&n()},role:"presentation",...s,children:l})});n.displayName="Backdrop";export{n as Backdrop};
|
package/dist/esm/Chips.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import
|
|
1
|
+
"use client";import"react/jsx-runtime";import"react";import"./utils.js";import"./contexts.js";export{C as Chips,C as default}from"./chunks/Chips-DV9Y7v7k.js";import"./chunks/createLucideIcon-DGp0SoUT.js";
|
package/dist/esm/Pagination.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as i,Fragment as
|
|
1
|
+
"use client";import{jsx as e,jsxs as i,Fragment as n}from"react/jsx-runtime";import{useState as t,useEffect as a}from"react";import r from"./utils.js";import{useMobile as o}from"./contexts.js";import{c as l}from"./chunks/createLucideIcon-DGp0SoUT.js";import{C as s}from"./chunks/chevron-left-4HSuTes3.js";const c=l("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),d=l("chevrons-left",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]),m=l("chevrons-right",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]),p=l("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);function PaginationRoot({className:i,...n}){return e("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:r("mx-auto flex w-full justify-center",i),...n})}function PaginationContent({className:i,device:n,...t}){return e("ul",{"data-slot":"pagination-content",className:r("flex flex-row items-center","mobile"===n?"gap-[6px]":"gap-2",i),...t})}function PaginationItem({...i}){return e("li",{"data-slot":"pagination-item",...i})}function PaginationLink({className:i,device:n,variant:t,isActive:a,linkComponent:o,...l}){return e(o??"a",{"aria-current":a?"page":void 0,"data-slot":"pagination-link","data-active":a,className:r(buttonVariants({variant:"nextPrev"===t?t:a?"active":"outline",device:n}),i),tabIndex:l["aria-disabled"]?-1:0,...l})}function PaginationPrevious({className:t,device:a,variant:r,...o}){const l="mobile"===a,s={mobile:e(c,{size:18}),desktop:i(n,{children:[e(m,{size:20})," ",e("span",{children:"قبلی"})]})};return e(PaginationLink,{"aria-label":"Go to previous page",className:l?"ml-2.5":"flex justify-center items-center gap-2 w-[89px] h-[48px] ml-4",device:a,variant:"nextPrev",...o,children:"mobile"===a?s.mobile:s.desktop})}function PaginationNext({className:t,device:a,variant:r,...o}){const l="mobile"===a,c={mobile:e(s,{size:18}),desktop:i(n,{children:[e("span",{children:"بعدی"}),e(d,{size:20})]})};return e(PaginationLink,{"aria-label":"Go to next page",className:l?"mr-2.5":"flex justify-center items-center gap-2 w-[89px] h-[48px] mr-4",device:a,variant:"nextPrev",...o,children:"mobile"===a?c.mobile:c.desktop})}function PaginationEllipsis({className:i,...n}){return e("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:r("flex size-9 items-center justify-center",i),...n,children:e(p,{className:"size-4"})})}function buttonVariants({variant:e,device:i}){const n="mobile"===i;return[r({"flex items-center justify-center rounded-[6px]":!0,"w-[40px] h-[40px] text-s font-heavy":n,"w-[48px] h-[48px] text-l font-heavy":!n}),{outline:"border border-neutral-light bg-white text-neutral-darker",active:"bg-primary text-white",nextPrev:"border border-neutral-light bg-white text-neutral-darker"}[e]].join(" ")}const Pagination=({pageCount:n,page:r,defaultPage:l=1,onPageChange:s,className:c,isMobile:d,baseUrl:m,linkComponent:p,...h})=>{const u=o(),v=d??u,g=void 0!==r,[f,x]=t(l),b=g?r:f,k=v?"mobile":"desktop";a(()=>{g||x(l)},[l,g]);const changePage=e=>{g||x(e),s?.(e)},buildHref=e=>{if(!m)return"#";try{const i=new URL(m,"http://localhost");i.searchParams.set("page",String(e));const{pathname:n,search:t,hash:a}=i;return`${n}${t}${a}`}catch{const i=m.includes("?");return`${m}${i?"&":"?"}page=${e}`}};return e(PaginationRoot,{className:c,...h,children:i(PaginationContent,{device:k,children:[e(PaginationItem,{children:e(PaginationPrevious,{href:buildHref(Math.max(1,b-1)),linkComponent:p,onClick:e=>{s&&e.preventDefault(),b>1&&changePage(b-1)},variant:"nextPrev",device:k,"aria-disabled":1===b,tabIndex:1===b?-1:0})}),function(){const i=[];if(n<=5)for(let t=1;t<=n;t++)i.push(e(PaginationItem,{children:e(PaginationLink,{href:buildHref(t),isActive:b===t,variant:"main",device:k,linkComponent:p,onClick:e=>{s&&e.preventDefault(),b!==t&&changePage(t)},"aria-disabled":b===t,tabIndex:b===t?-1:0,children:t})},t));else{i.push(e(PaginationItem,{children:e(PaginationLink,{href:buildHref(1),isActive:1===b,device:k,variant:"main",linkComponent:p,onClick:e=>{s&&e.preventDefault(),1!==b&&changePage(1)},"aria-disabled":1===b,tabIndex:1===b?-1:0,children:"1"})},1)),b>3&&i.push(e(PaginationItem,{children:e(PaginationEllipsis,{})},"start-ellipsis"));const t=Math.max(2,b-1),a=Math.min(n-1,b+1);for(let n=t;n<=a;n++)i.push(e(PaginationItem,{children:e(PaginationLink,{href:buildHref(n),isActive:b===n,device:k,variant:"main",linkComponent:p,onClick:e=>{s&&e.preventDefault(),b!==n&&changePage(n)},"aria-disabled":b===n,tabIndex:b===n?-1:0,children:n})},n));b<n-2&&i.push(e(PaginationItem,{children:e(PaginationEllipsis,{})},"end-ellipsis")),i.push(e(PaginationItem,{children:e(PaginationLink,{href:buildHref(n),isActive:b===n,device:k,variant:"main",linkComponent:p,onClick:e=>{s&&e.preventDefault(),b!==n&&changePage(n)},"aria-disabled":b===n,tabIndex:b===n?-1:0,children:n})},n))}return i}(),e(PaginationItem,{children:e(PaginationNext,{href:buildHref(Math.min(n,b+1)),linkComponent:p,onClick:e=>{s&&e.preventDefault(),b<n&&changePage(b+1)},variant:"nextPrev",device:k,"aria-disabled":b===n,tabIndex:b===n?-1:0})})]})})};export{Pagination};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsxs as e,jsx as t}from"react/jsx-runtime";import r from"react";import o from"../utils.js";import{useMobile as i}from"../contexts.js";import{c as n}from"./createLucideIcon-DGp0SoUT.js";const a=n("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),d={purple:{background:"bg-primary-lightest",text:"text-primary-darkest",border:"border-primary-light"},red:{background:"bg-error-light",text:"text-error",border:"border-[#f0d6d6]"},green:{background:"bg-success-light",text:"text-success",border:"border-[#d4e8dc]"},orange:{background:"bg-warning-light",text:"text-warning",border:"border-[#f5e1d1]"},blue:{background:"bg-info-light",text:"text-info",border:"border-[#d3e9f2]"},white:{background:"bg-white",text:"text-neutral-darker",border:"border-neutral-light"},disabled:{background:"bg-neutral-lighter",text:"text-neutral-main",border:"border-neutral-light"}},l={mobile:{padding:"px-2.5 py-1",gap:"gap-1",iconSize:"size-4",fontSize:"text-xs",lineHeight:"leading-[1.8]"},desktop:{padding:"px-3 py-1",gap:"gap-1.5",iconSize:"size-5",fontSize:"text-s",lineHeight:"leading-[24px]"}},s=r.forwardRef(({variant:r="purple",size:n,children:s="متن پیشفرض",disabled:c=!1,onClick:b,onIconClick:p,className:g,isMobile:u,...x},m)=>{const f=i(),h=d[c?"disabled":r],k=l[n||(u??f?"mobile":"desktop")],handleIconClick=e=>{e.stopPropagation(),p&&p()};return e("div",{ref:m,className:o("relative rounded-[50px] border border-solid inline-flex","flex-row items-center justify-center","font-sans font-bold not-italic","text-nowrap text-right","transition-all duration-200",h.background,h.text,h.border,k.padding,k.gap,k.fontSize,k.lineHeight,b&&!c&&"cursor-pointer hover:opacity-80",c&&"cursor-not-allowed opacity-60",g),onClick:c?void 0:b,onKeyDown:b&&!c?e=>{"Enter"!==e.key&&" "!==e.key||!b||c||(e.preventDefault(),b())}:void 0,tabIndex:b&&!c?0:void 0,role:b?"button":void 0,...x,children:[t("span",{className:"text-center",children:s}),(()=>{const e=t(a,{className:o(k.iconSize)});return p?t("button",{type:"button",onClick:handleIconClick,disabled:c,className:o("flex items-center justify-center","hover:opacity-70 transition-opacity",c&&"cursor-not-allowed opacity-50"),"aria-label":"حذف",children:e}):e})()]})});s.displayName="Chips";export{s as C,a as X};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Typography as
|
|
1
|
+
import{Typography as e}from"./Typography.js";import{Button as r}from"./Button.js";import{Input as o}from"./Input.js";import{Tabs as a}from"./Tabs.js";import{Drawer as t}from"./Drawer.js";import{Backdrop as s}from"./Backdrop.js";import{Breadcrumb as i}from"./Breadcrumb.js";import{Pagination as l}from"./Pagination.js";import{Accordion as n}from"./Accordion.js";import{Divider as m}from"./Divider.js";import{RadioGroup as c}from"./RadioGroup.js";import{X as d,C as p}from"./chunks/Chips-DV9Y7v7k.js";import{Menu as f}from"./Menu.js";import{jsx as b,jsxs as u}from"react/jsx-runtime";import x from"react";import h from"./utils.js";export{MobileProvider,useMobile}from"./contexts.js";import"react-dom";import"./chunks/chevron-left-4HSuTes3.js";import"./chunks/createLucideIcon-DGp0SoUT.js";const g=x.forwardRef(({isOpen:e=!1,onClose:r,title:o,content:a,buttons:t,showCloseButton:i=!0,size:l="md",className:n,children:m},c)=>{const handleClose=()=>{r&&r()},p=h("bg-white rounded-[10px] shadow-lg mx-4 w-full",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl"}[l],n);return b(s,{isOpen:e,onClick:handleClose,blur:!0,children:b("div",{ref:c,className:p,onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Escape"===e.key&&r&&r()},role:"dialog","aria-modal":"true","aria-labelledby":o?"dialog-title":void 0,children:u("div",{className:"flex flex-col p-6 gap-8",children:[o&&b("div",{className:"flex flex-col gap-2.5",children:b("div",{className:"flex items-center justify-between pb-4 border-b border-[#ebeaf0]",children:u("div",{className:"flex items-center justify-between gap-3 w-full flex-row-reverse",children:[b("div",{className:"text-[#590d8b] text-xl font-extrabold leading-8",children:o}),i&&b("button",{type:"button",onClick:handleClose,className:"p-1 rounded-full hover:bg-gray-100 transition-colors","aria-label":"Close dialog",children:b(d,{className:"w-6 h-6 text-[#a4a2bb]"})})]})})}),a&&b("div",{className:"flex flex-col gap-4",children:a}),m&&!a&&b("div",{className:"flex flex-col gap-4",children:m}),t&&b("div",{className:"flex flex-col gap-1.5",children:t})]})})})});g.displayName="Dialog";const j=x.forwardRef(({variant:e="primary",icon:r,children:o,className:a,...t},s)=>{const i=h("h-14 px-4 py-[13px] rounded-md font-bold text-base leading-[1.8] flex items-center justify-center gap-2 transition-colors",{"bg-[#590d8b] text-white hover:bg-[#4a0a75]":"primary"===e,"bg-white text-[#1a1922] border border-[#ebeaf0] hover:bg-gray-50":"secondary"===e},a);return u("button",{type:"button",ref:s,className:i,...t,children:[o,r&&b("span",{className:"w-5 h-5",children:r})]})});j.displayName="DialogButton";const w=e,y=r,v=o,N=a,k=t,B=s,C=i,D=l,M=n,P=m,R=c,T=p,I=f;export{M as Accordion,B as Backdrop,C as Breadcrumb,y as Button,T as Chips,g as Dialog,j as DialogButton,P as Divider,k as Drawer,v as Input,I as Menu,D as Pagination,R as RadioGroup,N as Tabs,w as Typography};
|
package/dist/types/Backdrop.js
CHANGED
|
@@ -12,7 +12,7 @@ const Backdrop = React.forwardRef(({ isOpen = false, onClick, blur = false, zInd
|
|
|
12
12
|
onClick();
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
const backdropClasses = cn('fixed inset-0 transition-all duration-300', {
|
|
15
|
+
const backdropClasses = cn('fixed inset-0 transition-all duration-300 flex items-center justify-center', {
|
|
16
16
|
'backdrop-blur-sm': blur,
|
|
17
17
|
}, className);
|
|
18
18
|
const backdropStyle = {
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import cn from './utils.js';
|
|
4
|
+
import { useMobile } from './contexts.js';
|
|
5
|
+
import { c as createLucideIcon } from './createLucideIcon-D-q73LTT.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @license lucide-react v0.522.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const __iconNode = [
|
|
16
|
+
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
17
|
+
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
18
|
+
];
|
|
19
|
+
const X = createLucideIcon("x", __iconNode);
|
|
20
|
+
|
|
21
|
+
const chipVariants = {
|
|
22
|
+
purple: {
|
|
23
|
+
background: 'bg-primary-lightest',
|
|
24
|
+
text: 'text-primary-darkest',
|
|
25
|
+
border: 'border-primary-light',
|
|
26
|
+
},
|
|
27
|
+
red: {
|
|
28
|
+
background: 'bg-error-light',
|
|
29
|
+
text: 'text-error',
|
|
30
|
+
border: 'border-[#f0d6d6]',
|
|
31
|
+
},
|
|
32
|
+
green: {
|
|
33
|
+
background: 'bg-success-light',
|
|
34
|
+
text: 'text-success',
|
|
35
|
+
border: 'border-[#d4e8dc]',
|
|
36
|
+
},
|
|
37
|
+
orange: {
|
|
38
|
+
background: 'bg-warning-light',
|
|
39
|
+
text: 'text-warning',
|
|
40
|
+
border: 'border-[#f5e1d1]',
|
|
41
|
+
},
|
|
42
|
+
blue: {
|
|
43
|
+
background: 'bg-info-light',
|
|
44
|
+
text: 'text-info',
|
|
45
|
+
border: 'border-[#d3e9f2]',
|
|
46
|
+
},
|
|
47
|
+
white: {
|
|
48
|
+
background: 'bg-white',
|
|
49
|
+
text: 'text-neutral-darker',
|
|
50
|
+
border: 'border-neutral-light',
|
|
51
|
+
},
|
|
52
|
+
disabled: {
|
|
53
|
+
background: 'bg-neutral-lighter',
|
|
54
|
+
text: 'text-neutral-main',
|
|
55
|
+
border: 'border-neutral-light',
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
const chipSizes = {
|
|
59
|
+
mobile: {
|
|
60
|
+
padding: 'px-2.5 py-1',
|
|
61
|
+
gap: 'gap-1',
|
|
62
|
+
iconSize: 'size-4',
|
|
63
|
+
fontSize: 'text-xs',
|
|
64
|
+
lineHeight: 'leading-[1.8]',
|
|
65
|
+
},
|
|
66
|
+
desktop: {
|
|
67
|
+
padding: 'px-3 py-1',
|
|
68
|
+
gap: 'gap-1.5',
|
|
69
|
+
iconSize: 'size-5',
|
|
70
|
+
fontSize: 'text-s',
|
|
71
|
+
lineHeight: 'leading-[24px]',
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
const Chips = React.forwardRef(({ variant = 'purple', size, children = 'متن پیشفرض', disabled = false, onClick, onIconClick, className, isMobile, ...props }, ref) => {
|
|
75
|
+
const detectedIsMobile = useMobile();
|
|
76
|
+
const actualIsMobile = isMobile ?? detectedIsMobile;
|
|
77
|
+
const actualSize = size || (actualIsMobile ? 'mobile' : 'desktop');
|
|
78
|
+
const actualVariant = disabled ? 'disabled' : variant;
|
|
79
|
+
const variantStyles = chipVariants[actualVariant];
|
|
80
|
+
const sizeStyles = chipSizes[actualSize];
|
|
81
|
+
const handleIconClick = (e) => {
|
|
82
|
+
e.stopPropagation();
|
|
83
|
+
if (onIconClick) {
|
|
84
|
+
onIconClick();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const handleKeyDown = (e) => {
|
|
88
|
+
if ((e.key === 'Enter' || e.key === ' ') && onClick && !disabled) {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
onClick();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const renderIcon = () => {
|
|
94
|
+
const iconElement = jsx(X, { className: cn(sizeStyles.iconSize) });
|
|
95
|
+
if (onIconClick) {
|
|
96
|
+
return (jsx("button", { type: "button", onClick: handleIconClick, disabled: disabled, className: cn('flex items-center justify-center', 'hover:opacity-70 transition-opacity', disabled && 'cursor-not-allowed opacity-50'), "aria-label": "\u062D\u0630\u0641", children: iconElement }));
|
|
97
|
+
}
|
|
98
|
+
return iconElement;
|
|
99
|
+
};
|
|
100
|
+
return (jsxs("div", { ref: ref, className: cn(
|
|
101
|
+
// Base styles
|
|
102
|
+
'relative rounded-[50px] border border-solid inline-flex', 'flex-row items-center justify-center', 'font-sans font-bold not-italic', 'text-nowrap text-right', 'transition-all duration-200',
|
|
103
|
+
// Variant styles
|
|
104
|
+
variantStyles.background, variantStyles.text, variantStyles.border,
|
|
105
|
+
// Size styles
|
|
106
|
+
sizeStyles.padding, sizeStyles.gap, sizeStyles.fontSize, sizeStyles.lineHeight,
|
|
107
|
+
// Interactive styles
|
|
108
|
+
onClick && !disabled && 'cursor-pointer hover:opacity-80', disabled && 'cursor-not-allowed opacity-60', className), onClick: disabled ? undefined : onClick, onKeyDown: onClick && !disabled ? handleKeyDown : undefined, tabIndex: onClick && !disabled ? 0 : undefined, role: onClick ? 'button' : undefined, ...props, children: [jsx("span", { className: "text-center", children: children }), renderIcon()] }));
|
|
109
|
+
});
|
|
110
|
+
Chips.displayName = 'Chips';
|
|
111
|
+
|
|
112
|
+
export { Chips as C, X };
|
package/dist/types/Chips.js
CHANGED
|
@@ -1,112 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @license lucide-react v0.522.0 - ISC
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the ISC license.
|
|
11
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const __iconNode = [
|
|
16
|
-
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
17
|
-
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
18
|
-
];
|
|
19
|
-
const X = createLucideIcon("x", __iconNode);
|
|
20
|
-
|
|
21
|
-
const chipVariants = {
|
|
22
|
-
purple: {
|
|
23
|
-
background: 'bg-primary-lightest',
|
|
24
|
-
text: 'text-primary-darkest',
|
|
25
|
-
border: 'border-primary-light',
|
|
26
|
-
},
|
|
27
|
-
red: {
|
|
28
|
-
background: 'bg-error-light',
|
|
29
|
-
text: 'text-error',
|
|
30
|
-
border: 'border-[#f0d6d6]',
|
|
31
|
-
},
|
|
32
|
-
green: {
|
|
33
|
-
background: 'bg-success-light',
|
|
34
|
-
text: 'text-success',
|
|
35
|
-
border: 'border-[#d4e8dc]',
|
|
36
|
-
},
|
|
37
|
-
orange: {
|
|
38
|
-
background: 'bg-warning-light',
|
|
39
|
-
text: 'text-warning',
|
|
40
|
-
border: 'border-[#f5e1d1]',
|
|
41
|
-
},
|
|
42
|
-
blue: {
|
|
43
|
-
background: 'bg-info-light',
|
|
44
|
-
text: 'text-info',
|
|
45
|
-
border: 'border-[#d3e9f2]',
|
|
46
|
-
},
|
|
47
|
-
white: {
|
|
48
|
-
background: 'bg-white',
|
|
49
|
-
text: 'text-neutral-darker',
|
|
50
|
-
border: 'border-neutral-light',
|
|
51
|
-
},
|
|
52
|
-
disabled: {
|
|
53
|
-
background: 'bg-neutral-lighter',
|
|
54
|
-
text: 'text-neutral-main',
|
|
55
|
-
border: 'border-neutral-light',
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
const chipSizes = {
|
|
59
|
-
mobile: {
|
|
60
|
-
padding: 'px-2.5 py-1',
|
|
61
|
-
gap: 'gap-1',
|
|
62
|
-
iconSize: 'size-4',
|
|
63
|
-
fontSize: 'text-xs',
|
|
64
|
-
lineHeight: 'leading-[1.8]',
|
|
65
|
-
},
|
|
66
|
-
desktop: {
|
|
67
|
-
padding: 'px-3 py-1',
|
|
68
|
-
gap: 'gap-1.5',
|
|
69
|
-
iconSize: 'size-5',
|
|
70
|
-
fontSize: 'text-s',
|
|
71
|
-
lineHeight: 'leading-[24px]',
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
const Chips = React.forwardRef(({ variant = 'purple', size, children = 'متن پیشفرض', disabled = false, onClick, onIconClick, className, isMobile, ...props }, ref) => {
|
|
75
|
-
const detectedIsMobile = useMobile();
|
|
76
|
-
const actualIsMobile = isMobile ?? detectedIsMobile;
|
|
77
|
-
const actualSize = size || (actualIsMobile ? 'mobile' : 'desktop');
|
|
78
|
-
const actualVariant = disabled ? 'disabled' : variant;
|
|
79
|
-
const variantStyles = chipVariants[actualVariant];
|
|
80
|
-
const sizeStyles = chipSizes[actualSize];
|
|
81
|
-
const handleIconClick = (e) => {
|
|
82
|
-
e.stopPropagation();
|
|
83
|
-
if (onIconClick) {
|
|
84
|
-
onIconClick();
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const handleKeyDown = (e) => {
|
|
88
|
-
if ((e.key === 'Enter' || e.key === ' ') && onClick && !disabled) {
|
|
89
|
-
e.preventDefault();
|
|
90
|
-
onClick();
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const renderIcon = () => {
|
|
94
|
-
const iconElement = jsx(X, { className: cn(sizeStyles.iconSize) });
|
|
95
|
-
if (onIconClick) {
|
|
96
|
-
return (jsx("button", { type: "button", onClick: handleIconClick, disabled: disabled, className: cn('flex items-center justify-center', 'hover:opacity-70 transition-opacity', disabled && 'cursor-not-allowed opacity-50'), "aria-label": "\u062D\u0630\u0641", children: iconElement }));
|
|
97
|
-
}
|
|
98
|
-
return iconElement;
|
|
99
|
-
};
|
|
100
|
-
return (jsxs("div", { ref: ref, className: cn(
|
|
101
|
-
// Base styles
|
|
102
|
-
'relative rounded-[50px] border border-solid inline-flex', 'flex-row items-center justify-center', 'font-sans font-bold not-italic', 'text-nowrap text-right', 'transition-all duration-200',
|
|
103
|
-
// Variant styles
|
|
104
|
-
variantStyles.background, variantStyles.text, variantStyles.border,
|
|
105
|
-
// Size styles
|
|
106
|
-
sizeStyles.padding, sizeStyles.gap, sizeStyles.fontSize, sizeStyles.lineHeight,
|
|
107
|
-
// Interactive styles
|
|
108
|
-
onClick && !disabled && 'cursor-pointer hover:opacity-80', disabled && 'cursor-not-allowed opacity-60', className), onClick: disabled ? undefined : onClick, onKeyDown: onClick && !disabled ? handleKeyDown : undefined, tabIndex: onClick && !disabled ? 0 : undefined, role: onClick ? 'button' : undefined, ...props, children: [jsx("span", { className: "text-center", children: children }), renderIcon()] }));
|
|
109
|
-
});
|
|
110
|
-
Chips.displayName = 'Chips';
|
|
111
|
-
|
|
112
|
-
export { Chips, Chips as default };
|
|
1
|
+
import 'react/jsx-runtime';
|
|
2
|
+
import 'react';
|
|
3
|
+
import './utils.js';
|
|
4
|
+
import './contexts.js';
|
|
5
|
+
export { C as Chips, C as default } from './Chips-zfhiOvK2.js';
|
|
6
|
+
import './createLucideIcon-D-q73LTT.js';
|
package/dist/types/Pagination.js
CHANGED
|
@@ -68,8 +68,9 @@ function PaginationContent({ className, device, ...props }) {
|
|
|
68
68
|
function PaginationItem({ ...props }) {
|
|
69
69
|
return jsx("li", { "data-slot": "pagination-item", ...props });
|
|
70
70
|
}
|
|
71
|
-
function PaginationLink({ className, device, variant, isActive, ...props }) {
|
|
72
|
-
|
|
71
|
+
function PaginationLink({ className, device, variant, isActive, linkComponent, ...props }) {
|
|
72
|
+
const Comp = linkComponent ?? 'a';
|
|
73
|
+
return (jsx(Comp, { "aria-current": isActive ? 'page' : undefined, "data-slot": "pagination-link", "data-active": isActive, className: cn(buttonVariants({
|
|
73
74
|
variant: variant === 'nextPrev' ? variant : isActive ? 'active' : 'outline',
|
|
74
75
|
device,
|
|
75
76
|
}), className), tabIndex: props['aria-disabled'] ? -1 : 0, ...props }));
|
|
@@ -111,7 +112,7 @@ function buttonVariants({ variant, device, }) {
|
|
|
111
112
|
};
|
|
112
113
|
return [base, variants[variant]].join(' ');
|
|
113
114
|
}
|
|
114
|
-
const Pagination = ({ pageCount, page: controlledPage, defaultPage = 1, onPageChange, className, isMobile, ...navProps }) => {
|
|
115
|
+
const Pagination = ({ pageCount, page: controlledPage, defaultPage = 1, onPageChange, className, isMobile, baseUrl, linkComponent, ...navProps }) => {
|
|
115
116
|
const detectedIsMobile = useMobile();
|
|
116
117
|
const actualIsMobile = isMobile ?? detectedIsMobile;
|
|
117
118
|
const isControlled = controlledPage !== undefined;
|
|
@@ -127,12 +128,30 @@ const Pagination = ({ pageCount, page: controlledPage, defaultPage = 1, onPageCh
|
|
|
127
128
|
setInternalPage(newPage);
|
|
128
129
|
onPageChange?.(newPage);
|
|
129
130
|
};
|
|
131
|
+
const buildHref = (targetPage) => {
|
|
132
|
+
if (!baseUrl)
|
|
133
|
+
return '#';
|
|
134
|
+
try {
|
|
135
|
+
const url = new URL(baseUrl, 'http://localhost');
|
|
136
|
+
url.searchParams.set('page', String(targetPage));
|
|
137
|
+
const { pathname, search, hash } = url; // search already includes leading '?'
|
|
138
|
+
return `${pathname}${search}${hash}`;
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
// Fallback naive concatenation
|
|
142
|
+
const hasQuery = baseUrl.includes('?');
|
|
143
|
+
const sep = hasQuery ? '&' : '?';
|
|
144
|
+
return `${baseUrl}${sep}page=${targetPage}`;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
130
147
|
function renderPages() {
|
|
131
148
|
const items = [];
|
|
132
149
|
if (pageCount <= 5) {
|
|
133
150
|
for (let i = 1; i <= pageCount; i++) {
|
|
134
|
-
items.push(jsx(PaginationItem, { children: jsx(PaginationLink, { href:
|
|
135
|
-
|
|
151
|
+
items.push(jsx(PaginationItem, { children: jsx(PaginationLink, { href: buildHref(i), isActive: page === i, variant: "main", device: device, linkComponent: linkComponent, onClick: (e) => {
|
|
152
|
+
if (onPageChange) {
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
}
|
|
136
155
|
if (page !== i)
|
|
137
156
|
changePage(i);
|
|
138
157
|
}, "aria-disabled": page === i, tabIndex: page === i ? -1 : 0, children: i }) }, i));
|
|
@@ -140,8 +159,10 @@ const Pagination = ({ pageCount, page: controlledPage, defaultPage = 1, onPageCh
|
|
|
140
159
|
}
|
|
141
160
|
else {
|
|
142
161
|
// First page
|
|
143
|
-
items.push(jsx(PaginationItem, { children: jsx(PaginationLink, { href:
|
|
144
|
-
|
|
162
|
+
items.push(jsx(PaginationItem, { children: jsx(PaginationLink, { href: buildHref(1), isActive: page === 1, device: device, variant: "main", linkComponent: linkComponent, onClick: (e) => {
|
|
163
|
+
if (onPageChange) {
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
}
|
|
145
166
|
if (page !== 1)
|
|
146
167
|
changePage(1);
|
|
147
168
|
}, "aria-disabled": page === 1, tabIndex: page === 1 ? -1 : 0, children: "1" }) }, 1));
|
|
@@ -153,8 +174,10 @@ const Pagination = ({ pageCount, page: controlledPage, defaultPage = 1, onPageCh
|
|
|
153
174
|
const start = Math.max(2, page - 1);
|
|
154
175
|
const end = Math.min(pageCount - 1, page + 1);
|
|
155
176
|
for (let i = start; i <= end; i++) {
|
|
156
|
-
items.push(jsx(PaginationItem, { children: jsx(PaginationLink, { href:
|
|
157
|
-
|
|
177
|
+
items.push(jsx(PaginationItem, { children: jsx(PaginationLink, { href: buildHref(i), isActive: page === i, device: device, variant: "main", linkComponent: linkComponent, onClick: (e) => {
|
|
178
|
+
if (onPageChange) {
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
}
|
|
158
181
|
if (page !== i)
|
|
159
182
|
changePage(i);
|
|
160
183
|
}, "aria-disabled": page === i, tabIndex: page === i ? -1 : 0, children: i }) }, i));
|
|
@@ -164,20 +187,26 @@ const Pagination = ({ pageCount, page: controlledPage, defaultPage = 1, onPageCh
|
|
|
164
187
|
items.push(jsx(PaginationItem, { children: jsx(PaginationEllipsis, {}) }, "end-ellipsis"));
|
|
165
188
|
}
|
|
166
189
|
// Last page
|
|
167
|
-
items.push(jsx(PaginationItem, { children: jsx(PaginationLink, { href:
|
|
168
|
-
|
|
190
|
+
items.push(jsx(PaginationItem, { children: jsx(PaginationLink, { href: buildHref(pageCount), isActive: page === pageCount, device: device, variant: "main", linkComponent: linkComponent, onClick: (e) => {
|
|
191
|
+
if (onPageChange) {
|
|
192
|
+
e.preventDefault();
|
|
193
|
+
}
|
|
169
194
|
if (page !== pageCount)
|
|
170
195
|
changePage(pageCount);
|
|
171
196
|
}, "aria-disabled": page === pageCount, tabIndex: page === pageCount ? -1 : 0, children: pageCount }) }, pageCount));
|
|
172
197
|
}
|
|
173
198
|
return items;
|
|
174
199
|
}
|
|
175
|
-
return (jsx(PaginationRoot, { className: className, ...navProps, children: jsxs(PaginationContent, { device:
|
|
176
|
-
|
|
200
|
+
return (jsx(PaginationRoot, { className: className, ...navProps, children: jsxs(PaginationContent, { device: device, children: [jsx(PaginationItem, { children: jsx(PaginationPrevious, { href: buildHref(Math.max(1, page - 1)), linkComponent: linkComponent, onClick: (e) => {
|
|
201
|
+
if (onPageChange) {
|
|
202
|
+
e.preventDefault();
|
|
203
|
+
}
|
|
177
204
|
if (page > 1)
|
|
178
205
|
changePage(page - 1);
|
|
179
|
-
}, variant: "nextPrev", device: device, "aria-disabled": page === 1, tabIndex: page === 1 ? -1 : 0 }) }), renderPages(), jsx(PaginationItem, { children: jsx(PaginationNext, { href:
|
|
180
|
-
|
|
206
|
+
}, variant: "nextPrev", device: device, "aria-disabled": page === 1, tabIndex: page === 1 ? -1 : 0 }) }), renderPages(), jsx(PaginationItem, { children: jsx(PaginationNext, { href: buildHref(Math.min(pageCount, page + 1)), linkComponent: linkComponent, onClick: (e) => {
|
|
207
|
+
if (onPageChange) {
|
|
208
|
+
e.preventDefault();
|
|
209
|
+
}
|
|
181
210
|
if (page < pageCount)
|
|
182
211
|
changePage(page + 1);
|
|
183
212
|
}, variant: "nextPrev", device: device, "aria-disabled": page === pageCount, tabIndex: page === pageCount ? -1 : 0 }) })] }) }));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface DialogProps {
|
|
3
|
+
isOpen?: boolean;
|
|
4
|
+
onClose?: () => void;
|
|
5
|
+
title?: React.ReactNode;
|
|
6
|
+
content?: React.ReactNode;
|
|
7
|
+
buttons?: React.ReactNode;
|
|
8
|
+
showCloseButton?: boolean;
|
|
9
|
+
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
10
|
+
className?: string;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
declare const Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export declare const DialogButton: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
15
|
+
variant?: "primary" | "secondary";
|
|
16
|
+
icon?: React.ReactNode;
|
|
17
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
18
|
+
export { Dialog };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Dialog } from './Dialog';
|
|
3
|
+
declare const meta: Meta<typeof Dialog>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Dialog>;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const WithTitle: Story;
|
|
8
|
+
export declare const WithButtons: Story;
|
|
9
|
+
export declare const FormDialog: Story;
|
|
10
|
+
export declare const LargeContent: Story;
|
|
11
|
+
export declare const NoCloseButton: Story;
|
|
12
|
+
export declare const DifferentSizes: Story;
|
|
13
|
+
export declare const WithoutTitle: Story;
|
|
@@ -8,5 +8,13 @@ export interface UnifiedPaginationProps {
|
|
|
8
8
|
* Whether the component is in mobile mode (optional, auto-detected if not provided)
|
|
9
9
|
*/
|
|
10
10
|
isMobile?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Base URL to construct hrefs, e.g. "/products" -> "/products?page=2"
|
|
13
|
+
*/
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Custom link component to render instead of <a/>
|
|
17
|
+
*/
|
|
18
|
+
linkComponent?: React.ElementType<React.AnchorHTMLAttributes<HTMLAnchorElement>>;
|
|
11
19
|
}
|
|
12
20
|
export declare const Pagination: React.FC<UnifiedPaginationProps>;
|
|
@@ -36,6 +36,14 @@ declare const _default: {
|
|
|
36
36
|
};
|
|
37
37
|
defaultValue: undefined;
|
|
38
38
|
};
|
|
39
|
+
baseUrl: {
|
|
40
|
+
name: string;
|
|
41
|
+
control: {
|
|
42
|
+
type: string;
|
|
43
|
+
};
|
|
44
|
+
defaultValue: string;
|
|
45
|
+
description: string;
|
|
46
|
+
};
|
|
39
47
|
isMobile: {
|
|
40
48
|
name: string;
|
|
41
49
|
control: {
|
|
@@ -50,23 +58,26 @@ export default _default;
|
|
|
50
58
|
type StoryProps = {
|
|
51
59
|
pageCount: number;
|
|
52
60
|
defaultPage: number;
|
|
61
|
+
baseUrl: string;
|
|
53
62
|
isMobile: boolean;
|
|
54
63
|
};
|
|
55
64
|
export declare const Uncontrolled: {
|
|
56
|
-
({ pageCount, defaultPage, isMobile, }: StoryProps): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
({ pageCount, defaultPage, baseUrl, isMobile, }: StoryProps): import("react/jsx-runtime").JSX.Element;
|
|
57
66
|
storyName: string;
|
|
58
67
|
args: {
|
|
59
68
|
pageCount: number;
|
|
60
69
|
defaultPage: number;
|
|
70
|
+
baseUrl: string;
|
|
61
71
|
isMobile: boolean;
|
|
62
72
|
};
|
|
63
73
|
};
|
|
64
74
|
export declare const Controlled: {
|
|
65
|
-
({ pageCount, defaultPage, isMobile, }: StoryProps): import("react/jsx-runtime").JSX.Element;
|
|
75
|
+
({ pageCount, defaultPage, baseUrl, isMobile, }: StoryProps): import("react/jsx-runtime").JSX.Element;
|
|
66
76
|
storyName: string;
|
|
67
77
|
args: {
|
|
68
78
|
pageCount: number;
|
|
69
79
|
defaultPage: number;
|
|
80
|
+
baseUrl: string;
|
|
70
81
|
isMobile: boolean;
|
|
71
82
|
};
|
|
72
83
|
};
|
|
@@ -74,3 +85,13 @@ export declare const ResponsiveComparison: {
|
|
|
74
85
|
(): import("react/jsx-runtime").JSX.Element;
|
|
75
86
|
storyName: string;
|
|
76
87
|
};
|
|
88
|
+
export declare const WithCustomLinkComponent: {
|
|
89
|
+
({ pageCount, defaultPage, baseUrl, isMobile, }: StoryProps): import("react/jsx-runtime").JSX.Element;
|
|
90
|
+
storyName: string;
|
|
91
|
+
args: {
|
|
92
|
+
pageCount: number;
|
|
93
|
+
defaultPage: number;
|
|
94
|
+
baseUrl: string;
|
|
95
|
+
isMobile: boolean;
|
|
96
|
+
};
|
|
97
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -24,7 +24,8 @@ export type { InputProps } from './components/Input/Input';
|
|
|
24
24
|
export type { TabsProps, TabItem } from './components/Tabs/Tabs';
|
|
25
25
|
export type { DrawerProps, DrawerDirection } from './components/Drawer/Drawer';
|
|
26
26
|
export type { BackdropProps } from './components/Backdrop/Backdrop';
|
|
27
|
-
export
|
|
27
|
+
export { Dialog, DialogButton } from './components/Dialog/Dialog';
|
|
28
|
+
export type { DialogProps } from './components/Dialog/Dialog';
|
|
28
29
|
export type { UnifiedPaginationProps as PaginationProps } from './components/Pagination/Pagination';
|
|
29
30
|
export type { AccordionProps } from './components/Accordion/Accordion';
|
|
30
31
|
export type { DividerProps } from './components/Divider/Divider';
|
package/dist/types/index.js
CHANGED
|
@@ -9,16 +9,46 @@ import { Pagination as Pagination$1 } from './Pagination.js';
|
|
|
9
9
|
import { Accordion as Accordion$1 } from './Accordion.js';
|
|
10
10
|
import { Divider as Divider$1 } from './Divider.js';
|
|
11
11
|
import { RadioGroup as RadioGroup$1 } from './RadioGroup.js';
|
|
12
|
-
import {
|
|
12
|
+
import { X, C as Chips$1 } from './Chips-zfhiOvK2.js';
|
|
13
13
|
import { Menu as Menu$1 } from './Menu.js';
|
|
14
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
15
|
+
import React from 'react';
|
|
16
|
+
import cn from './utils.js';
|
|
14
17
|
export { MobileProvider, useMobile } from './contexts.js';
|
|
15
|
-
import 'react';
|
|
16
|
-
import './utils.js';
|
|
17
|
-
import 'react/jsx-runtime';
|
|
18
18
|
import 'react-dom';
|
|
19
19
|
import './chevron-left-Ck6O99eF.js';
|
|
20
20
|
import './createLucideIcon-D-q73LTT.js';
|
|
21
21
|
|
|
22
|
+
const Dialog = React.forwardRef(({ isOpen = false, onClose, title, content, buttons, showCloseButton = true, size = 'md', className, children, }, ref) => {
|
|
23
|
+
const handleClose = () => {
|
|
24
|
+
if (onClose) {
|
|
25
|
+
onClose();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const sizeClasses = {
|
|
29
|
+
sm: 'max-w-sm',
|
|
30
|
+
md: 'max-w-md',
|
|
31
|
+
lg: 'max-w-lg',
|
|
32
|
+
xl: 'max-w-xl',
|
|
33
|
+
};
|
|
34
|
+
const dialogClasses = cn('bg-white rounded-[10px] shadow-lg mx-4 w-full', sizeClasses[size], className);
|
|
35
|
+
return (jsx(Backdrop$1, { isOpen: isOpen, onClick: handleClose, blur: true, children: jsx("div", { ref: ref, className: dialogClasses, onClick: (e) => e.stopPropagation(), onKeyDown: (e) => {
|
|
36
|
+
if (e.key === 'Escape' && onClose) {
|
|
37
|
+
onClose();
|
|
38
|
+
}
|
|
39
|
+
}, role: "dialog", "aria-modal": "true", "aria-labelledby": title ? 'dialog-title' : undefined, children: jsxs("div", { className: "flex flex-col p-6 gap-8", children: [title && (jsx("div", { className: "flex flex-col gap-2.5", children: jsx("div", { className: "flex items-center justify-between pb-4 border-b border-[#ebeaf0]", children: jsxs("div", { className: "flex items-center justify-between gap-3 w-full flex-row-reverse", children: [jsx("div", { className: "text-[#590d8b] text-xl font-extrabold leading-8", children: title }), showCloseButton && (jsx("button", { type: "button", onClick: handleClose, className: "p-1 rounded-full hover:bg-gray-100 transition-colors", "aria-label": "Close dialog", children: jsx(X, { className: "w-6 h-6 text-[#a4a2bb]" }) }))] }) }) })), content && jsx("div", { className: "flex flex-col gap-4", children: content }), children && !content && (jsx("div", { className: "flex flex-col gap-4", children: children })), buttons && jsx("div", { className: "flex flex-col gap-1.5", children: buttons })] }) }) }));
|
|
40
|
+
});
|
|
41
|
+
Dialog.displayName = 'Dialog';
|
|
42
|
+
// Button components for the dialog
|
|
43
|
+
const DialogButton = React.forwardRef(({ variant = 'primary', icon, children, className, ...props }, ref) => {
|
|
44
|
+
const buttonClasses = cn('h-14 px-4 py-[13px] rounded-md font-bold text-base leading-[1.8] flex items-center justify-center gap-2 transition-colors', {
|
|
45
|
+
'bg-[#590d8b] text-white hover:bg-[#4a0a75]': variant === 'primary',
|
|
46
|
+
'bg-white text-[#1a1922] border border-[#ebeaf0] hover:bg-gray-50': variant === 'secondary',
|
|
47
|
+
}, className);
|
|
48
|
+
return (jsxs("button", { type: "button", ref: ref, className: buttonClasses, ...props, children: [children, icon && jsx("span", { className: "w-5 h-5", children: icon })] }));
|
|
49
|
+
});
|
|
50
|
+
DialogButton.displayName = 'DialogButton';
|
|
51
|
+
|
|
22
52
|
// Original Components (for internal use)
|
|
23
53
|
// Components (direct exports)
|
|
24
54
|
const Typography = Typography$1;
|
|
@@ -35,4 +65,4 @@ const RadioGroup = RadioGroup$1;
|
|
|
35
65
|
const Chips = Chips$1;
|
|
36
66
|
const Menu = Menu$1;
|
|
37
67
|
|
|
38
|
-
export { Accordion, Backdrop, Breadcrumb, Button, Chips, Divider, Drawer, Input, Menu, Pagination, RadioGroup, Tabs, Typography };
|
|
68
|
+
export { Accordion, Backdrop, Breadcrumb, Button, Chips, Dialog, DialogButton, Divider, Drawer, Input, Menu, Pagination, RadioGroup, Tabs, Typography };
|