automoby-kit 1.0.13 → 1.0.15

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.
Files changed (115) hide show
  1. package/dist/cjs/Accordion.js +1 -59
  2. package/dist/cjs/Backdrop.js +1 -26
  3. package/dist/cjs/Breadcrumb.js +1 -61
  4. package/dist/cjs/Button.js +1 -48
  5. package/dist/cjs/Chips.js +1 -117
  6. package/dist/cjs/Divider.js +1 -23
  7. package/dist/cjs/Drawer.js +1 -112
  8. package/dist/cjs/Input.js +1 -84
  9. package/dist/cjs/Menu.js +1 -122
  10. package/dist/cjs/Pagination.js +1 -188
  11. package/dist/cjs/RadioGroup.js +1 -73
  12. package/dist/cjs/Tabs.js +1 -54
  13. package/dist/cjs/Typography.js +1 -63
  14. package/dist/cjs/contexts.js +1 -1491
  15. package/dist/cjs/index.js +1 -52
  16. package/dist/cjs/utils.js +1 -9
  17. package/dist/esm/Accordion.js +1 -57
  18. package/dist/esm/Backdrop.js +1 -24
  19. package/dist/esm/Breadcrumb.js +1 -59
  20. package/dist/esm/Button.js +1 -46
  21. package/dist/esm/Chips.js +1 -112
  22. package/dist/esm/Divider.js +1 -21
  23. package/dist/esm/Drawer.js +1 -110
  24. package/dist/esm/Input.js +1 -82
  25. package/dist/esm/Menu.js +1 -120
  26. package/dist/esm/Pagination.js +1 -186
  27. package/dist/esm/RadioGroup.js +1 -71
  28. package/dist/esm/Tabs.js +1 -52
  29. package/dist/esm/Typography.js +1 -60
  30. package/dist/esm/contexts.js +1 -1485
  31. package/dist/esm/index.js +1 -37
  32. package/dist/esm/utils.js +1 -7
  33. package/dist/types/Accordion.js +57 -0
  34. package/dist/types/Backdrop.js +24 -0
  35. package/dist/types/Breadcrumb.js +59 -0
  36. package/dist/types/Button.js +46 -0
  37. package/dist/types/Chips.js +112 -0
  38. package/dist/types/Divider.js +21 -0
  39. package/dist/types/Drawer.js +110 -0
  40. package/dist/types/Input.js +82 -0
  41. package/dist/types/Menu.js +120 -0
  42. package/dist/types/Pagination.js +186 -0
  43. package/dist/types/RadioGroup.js +71 -0
  44. package/dist/types/Tabs.js +52 -0
  45. package/dist/types/Typography.js +60 -0
  46. package/dist/types/contexts.js +1485 -0
  47. package/dist/{cjs → types}/index.d.ts +1 -0
  48. package/dist/types/index.js +37 -0
  49. package/dist/types/utils.js +7 -0
  50. package/package.json +1 -1
  51. package/dist/cjs/chevron-left-COj1qGVo.js +0 -16
  52. package/dist/cjs/createLucideIcon-BTjFFtDc.js +0 -114
  53. package/dist/esm/components/Accordion/Accordion.d.ts +0 -25
  54. package/dist/esm/components/Accordion/Accordion.stories.d.ts +0 -175
  55. package/dist/esm/components/Backdrop/Backdrop.d.ts +0 -20
  56. package/dist/esm/components/Backdrop/Backdrop.stories.d.ts +0 -9
  57. package/dist/esm/components/Breadcrumb/Breadcrumb.d.ts +0 -16
  58. package/dist/esm/components/Breadcrumb/Breadcrumb.stories.d.ts +0 -177
  59. package/dist/esm/components/Button/Button.d.ts +0 -13
  60. package/dist/esm/components/Button/Button.stories.d.ts +0 -100
  61. package/dist/esm/components/Chips/Chips.d.ts +0 -37
  62. package/dist/esm/components/Chips/Chips.stories.d.ts +0 -90
  63. package/dist/esm/components/Divider/Divider.d.ts +0 -25
  64. package/dist/esm/components/Divider/Divider.stories.d.ts +0 -88
  65. package/dist/esm/components/Drawer/Drawer.d.ts +0 -16
  66. package/dist/esm/components/Drawer/Drawer.stories.d.ts +0 -128
  67. package/dist/esm/components/Input/Input.d.ts +0 -24
  68. package/dist/esm/components/Input/Input.stories.d.ts +0 -131
  69. package/dist/esm/components/Menu/Menu.d.ts +0 -39
  70. package/dist/esm/components/Menu/Menu.stories.d.ts +0 -89
  71. package/dist/esm/components/Pagination/Pagination.d.ts +0 -12
  72. package/dist/esm/components/Pagination/Pagination.stories.d.ts +0 -76
  73. package/dist/esm/components/RadioGroup/RadioGroup.d.ts +0 -55
  74. package/dist/esm/components/RadioGroup/RadioGroup.stories.d.ts +0 -86
  75. package/dist/esm/components/Select/Select.d.ts +0 -17
  76. package/dist/esm/components/Select/Select.stories.d.ts +0 -104
  77. package/dist/esm/components/Tabs/Tabs.d.ts +0 -43
  78. package/dist/esm/components/Tabs/Tabs.stories.d.ts +0 -66
  79. package/dist/esm/components/Typography/Typography.d.ts +0 -9
  80. package/dist/esm/components/Typography/Typography.stories.d.ts +0 -57
  81. package/dist/esm/contexts/MobileContext.d.ts +0 -13
  82. package/dist/esm/index.d.ts +0 -34
  83. package/dist/esm/utils/cn.d.ts +0 -2
  84. /package/dist/{esm → types}/chevron-left-Ck6O99eF.js +0 -0
  85. /package/dist/{cjs → types}/components/Accordion/Accordion.d.ts +0 -0
  86. /package/dist/{cjs → types}/components/Accordion/Accordion.stories.d.ts +0 -0
  87. /package/dist/{cjs → types}/components/Backdrop/Backdrop.d.ts +0 -0
  88. /package/dist/{cjs → types}/components/Backdrop/Backdrop.stories.d.ts +0 -0
  89. /package/dist/{cjs → types}/components/Breadcrumb/Breadcrumb.d.ts +0 -0
  90. /package/dist/{cjs → types}/components/Breadcrumb/Breadcrumb.stories.d.ts +0 -0
  91. /package/dist/{cjs → types}/components/Button/Button.d.ts +0 -0
  92. /package/dist/{cjs → types}/components/Button/Button.stories.d.ts +0 -0
  93. /package/dist/{cjs → types}/components/Chips/Chips.d.ts +0 -0
  94. /package/dist/{cjs → types}/components/Chips/Chips.stories.d.ts +0 -0
  95. /package/dist/{cjs → types}/components/Divider/Divider.d.ts +0 -0
  96. /package/dist/{cjs → types}/components/Divider/Divider.stories.d.ts +0 -0
  97. /package/dist/{cjs → types}/components/Drawer/Drawer.d.ts +0 -0
  98. /package/dist/{cjs → types}/components/Drawer/Drawer.stories.d.ts +0 -0
  99. /package/dist/{cjs → types}/components/Input/Input.d.ts +0 -0
  100. /package/dist/{cjs → types}/components/Input/Input.stories.d.ts +0 -0
  101. /package/dist/{cjs → types}/components/Menu/Menu.d.ts +0 -0
  102. /package/dist/{cjs → types}/components/Menu/Menu.stories.d.ts +0 -0
  103. /package/dist/{cjs → types}/components/Pagination/Pagination.d.ts +0 -0
  104. /package/dist/{cjs → types}/components/Pagination/Pagination.stories.d.ts +0 -0
  105. /package/dist/{cjs → types}/components/RadioGroup/RadioGroup.d.ts +0 -0
  106. /package/dist/{cjs → types}/components/RadioGroup/RadioGroup.stories.d.ts +0 -0
  107. /package/dist/{cjs → types}/components/Select/Select.d.ts +0 -0
  108. /package/dist/{cjs → types}/components/Select/Select.stories.d.ts +0 -0
  109. /package/dist/{cjs → types}/components/Tabs/Tabs.d.ts +0 -0
  110. /package/dist/{cjs → types}/components/Tabs/Tabs.stories.d.ts +0 -0
  111. /package/dist/{cjs → types}/components/Typography/Typography.d.ts +0 -0
  112. /package/dist/{cjs → types}/components/Typography/Typography.stories.d.ts +0 -0
  113. /package/dist/{cjs → types}/contexts/MobileContext.d.ts +0 -0
  114. /package/dist/{esm → types}/createLucideIcon-D-q73LTT.js +0 -0
  115. /package/dist/{cjs → types}/utils/cn.d.ts +0 -0
package/dist/esm/Menu.js CHANGED
@@ -1,120 +1 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import React, { useState, useRef, useEffect } from 'react';
3
- import cn from './utils.js';
4
- import { Typography } from './Typography.js';
5
-
6
- const Menu = React.forwardRef(({ buttonText, items, disabled = false, className, onOpenChange, isOpen: controlledIsOpen, 'aria-label': ariaLabel, ...props }, ref) => {
7
- const [internalIsOpen, setInternalIsOpen] = useState(false);
8
- const menuRef = useRef(null);
9
- const buttonRef = useRef(null);
10
- // Use controlled or uncontrolled state
11
- const isOpen = controlledIsOpen !== undefined ? controlledIsOpen : internalIsOpen;
12
- const handleToggle = () => {
13
- if (disabled)
14
- return;
15
- const newIsOpen = !isOpen;
16
- if (controlledIsOpen === undefined) {
17
- setInternalIsOpen(newIsOpen);
18
- }
19
- onOpenChange?.(newIsOpen);
20
- };
21
- const handleItemClick = (item) => {
22
- if (item.disabled)
23
- return;
24
- // Close menu after item click
25
- if (controlledIsOpen === undefined) {
26
- setInternalIsOpen(false);
27
- }
28
- onOpenChange?.(false);
29
- // Execute item's onClick if provided
30
- item.onClick?.();
31
- };
32
- // Close menu when clicking outside
33
- useEffect(() => {
34
- const handleClickOutside = (event) => {
35
- if (menuRef.current &&
36
- !menuRef.current.contains(event.target)) {
37
- if (controlledIsOpen === undefined) {
38
- setInternalIsOpen(false);
39
- }
40
- onOpenChange?.(false);
41
- }
42
- };
43
- if (isOpen) {
44
- document.addEventListener('mousedown', handleClickOutside);
45
- return () => {
46
- document.removeEventListener('mousedown', handleClickOutside);
47
- };
48
- }
49
- return undefined;
50
- }, [isOpen, controlledIsOpen, onOpenChange]);
51
- // Handle keyboard navigation
52
- const handleKeyDown = (event) => {
53
- if (disabled)
54
- return;
55
- switch (event.key) {
56
- case 'Escape':
57
- if (isOpen) {
58
- event.preventDefault();
59
- if (controlledIsOpen === undefined) {
60
- setInternalIsOpen(false);
61
- }
62
- onOpenChange?.(false);
63
- buttonRef.current?.focus();
64
- }
65
- break;
66
- case 'ArrowDown':
67
- if (!isOpen) {
68
- event.preventDefault();
69
- handleToggle();
70
- }
71
- break;
72
- case 'Enter':
73
- case ' ':
74
- event.preventDefault();
75
- handleToggle();
76
- break;
77
- }
78
- };
79
- const buttonClasses = cn(
80
- // Base button styles matching Figma design
81
- 'inline-flex items-center justify-center', 'bg-white border border-[var(--color-neutral-light)]', 'rounded-[6px] px-[16px] py-[13px]', 'transition-colors duration-200',
82
- // Interactive states
83
- 'hover:bg-[var(--color-neutral-lighter)]', 'focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:ring-offset-2',
84
- // Disabled state
85
- {
86
- 'opacity-50 cursor-not-allowed': disabled,
87
- 'cursor-pointer': !disabled,
88
- });
89
- const dropdownClasses = cn(
90
- // Base dropdown styles
91
- 'absolute top-full left-0 right-0 z-10 mt-[4px]', 'bg-white border border-[var(--color-neutral-light)]', 'rounded-[6px] py-[13px] px-[16px]', 'shadow-lg',
92
- // Animation
93
- 'transition-all duration-200', {
94
- 'opacity-100 translate-y-0 pointer-events-auto': isOpen,
95
- 'opacity-0 -translate-y-2 pointer-events-none': !isOpen,
96
- });
97
- const itemClasses = cn('block w-full text-right', 'transition-colors duration-200', 'hover:bg-[var(--color-neutral-lighter)] rounded-[4px] px-[8px] py-[4px] -mx-[8px]', 'focus:outline-none focus:bg-[var(--color-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-[16px]", children: items.map((item) => {
99
- const content = (jsx(Typography, { variant: "body-s-heavy", color: item.disabled ? 'neutral-main' : 'neutral-darker', className: "text-right", children: item.label }));
100
- const commonProps = {
101
- className: cn(itemClasses, {
102
- 'opacity-50 cursor-not-allowed': item.disabled,
103
- 'cursor-pointer': !item.disabled,
104
- }),
105
- onClick: item.disabled
106
- ? undefined
107
- : () => handleItemClick(item),
108
- 'aria-label': `منوی ${item.label}`,
109
- };
110
- // Render as link if href is provided
111
- if (item.href && !item.disabled) {
112
- return (jsx("a", { ...commonProps, href: item.href, role: "menuitem", tabIndex: isOpen ? 0 : -1, children: content }, item.id));
113
- }
114
- // Render as button
115
- return (jsx("button", { ...commonProps, type: "button", role: "menuitem", tabIndex: isOpen ? 0 : -1, disabled: item.disabled, children: content }, item.id));
116
- }) }) })] }) }));
117
- });
118
- Menu.displayName = 'Menu';
119
-
120
- export { Menu };
1
+ "use client";import{jsx as e,jsxs as r}from"react/jsx-runtime";import t,{useState as o,useRef as a,useEffect as n}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:p,"aria-label":b,...f},m)=>{const[h,v]=o(!1),x=a(null),g=a(null),y=void 0!==p?p:h,handleToggle=()=>{if(d)return;const e=!y;void 0===p&&v(e),u?.(e)};n(()=>{const handleClickOutside=e=>{x.current&&!x.current.contains(e.target)&&(void 0===p&&v(!1),u?.(!1))};if(y)return document.addEventListener("mousedown",handleClickOutside),()=>{document.removeEventListener("mousedown",handleClickOutside)}},[y,p,u]);const w=i("inline-flex items-center justify-center","bg-white border border-[var(--color-neutral-light)]","rounded-[6px] px-[16px] py-[13px]","transition-colors duration-200","hover:bg-[var(--color-neutral-lighter)]","focus:outline-none focus:ring-2 focus:ring-[var(--color-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-[4px]","bg-white border border-[var(--color-neutral-light)]","rounded-[6px] py-[13px] px-[16px]","shadow-lg","transition-all duration-200",{"opacity-100 translate-y-0 pointer-events-auto":y,"opacity-0 -translate-y-2 pointer-events-none":!y}),N=i("block w-full text-right","transition-colors duration-200","hover:bg-[var(--color-neutral-lighter)] rounded-[4px] px-[8px] py-[4px] -mx-[8px]","focus:outline-none focus:bg-[var(--color-neutral-lighter)]");return e("div",{ref:m,className:i("relative inline-block",c),...f,children:r("div",{ref:x,children:[e("button",{ref:g,type:"button",className:w,onClick:handleToggle,onKeyDown:e=>{if(!d)switch(e.key){case"Escape":y&&(e.preventDefault(),void 0===p&&v(!1),u?.(!1),g.current?.focus());break;case"ArrowDown":y||(e.preventDefault(),handleToggle());break;case"Enter":case" ":e.preventDefault(),handleToggle()}},disabled:d,"aria-expanded":y,"aria-haspopup":"true","aria-label":b||`منوی ${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-[16px]",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}),o={className:i(N,{"opacity-50 cursor-not-allowed":r.disabled,"cursor-pointer":!r.disabled}),onClick:r.disabled?void 0:()=>(e=>{e.disabled||(void 0===p&&v(!1),u?.(!1),e.onClick?.())})(r),"aria-label":`منوی ${r.label}`};return r.href&&!r.disabled?e("a",{...o,href:r.href,role:"menuitem",tabIndex:y?0:-1,children:t},r.id):e("button",{...o,type:"button",role:"menuitem",tabIndex:y?0:-1,disabled:r.disabled,children:t},r.id)})})})]})})});s.displayName="Menu";export{s as Menu};
@@ -1,186 +1 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { useState, useEffect } 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
- import { C as ChevronLeft } from './chevron-left-Ck6O99eF.js';
7
-
8
- /**
9
- * @license lucide-react v0.522.0 - ISC
10
- *
11
- * This source code is licensed under the ISC license.
12
- * See the LICENSE file in the root directory of this source tree.
13
- */
14
-
15
-
16
- const __iconNode$3 = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
17
- const ChevronRight = createLucideIcon("chevron-right", __iconNode$3);
18
-
19
- /**
20
- * @license lucide-react v0.522.0 - ISC
21
- *
22
- * This source code is licensed under the ISC license.
23
- * See the LICENSE file in the root directory of this source tree.
24
- */
25
-
26
-
27
- const __iconNode$2 = [
28
- ["path", { d: "m11 17-5-5 5-5", key: "13zhaf" }],
29
- ["path", { d: "m18 17-5-5 5-5", key: "h8a8et" }]
30
- ];
31
- const ChevronsLeft = createLucideIcon("chevrons-left", __iconNode$2);
32
-
33
- /**
34
- * @license lucide-react v0.522.0 - ISC
35
- *
36
- * This source code is licensed under the ISC license.
37
- * See the LICENSE file in the root directory of this source tree.
38
- */
39
-
40
-
41
- const __iconNode$1 = [
42
- ["path", { d: "m6 17 5-5-5-5", key: "xnjwq" }],
43
- ["path", { d: "m13 17 5-5-5-5", key: "17xmmf" }]
44
- ];
45
- const ChevronsRight = createLucideIcon("chevrons-right", __iconNode$1);
46
-
47
- /**
48
- * @license lucide-react v0.522.0 - ISC
49
- *
50
- * This source code is licensed under the ISC license.
51
- * See the LICENSE file in the root directory of this source tree.
52
- */
53
-
54
-
55
- const __iconNode = [
56
- ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
57
- ["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
58
- ["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
59
- ];
60
- const Ellipsis = createLucideIcon("ellipsis", __iconNode);
61
-
62
- function PaginationRoot({ className, ...props }) {
63
- return (jsx("nav", { role: "navigation", "aria-label": "pagination", "data-slot": "pagination", className: cn('mx-auto flex w-full justify-center', className), ...props }));
64
- }
65
- function PaginationContent({ className, device, ...props }) {
66
- return (jsx("ul", { "data-slot": "pagination-content", className: cn('flex flex-row items-center', device === 'mobile' ? 'gap-[6px]' : 'gap-2', className), ...props }));
67
- }
68
- function PaginationItem({ ...props }) {
69
- return jsx("li", { "data-slot": "pagination-item", ...props });
70
- }
71
- function PaginationLink({ className, device, variant, isActive, ...props }) {
72
- return (jsx("a", { "aria-current": isActive ? 'page' : undefined, "data-slot": "pagination-link", "data-active": isActive, className: cn(buttonVariants({
73
- variant: variant === 'nextPrev' ? variant : isActive ? 'active' : 'outline',
74
- device,
75
- }), className), tabIndex: props['aria-disabled'] ? -1 : 0, ...props }));
76
- }
77
- function PaginationPrevious({ className, device, variant, ...props }) {
78
- const isMobile = device === 'mobile';
79
- const content = {
80
- mobile: jsx(ChevronRight, { size: 18 }),
81
- desktop: (jsxs(Fragment, { children: [jsx(ChevronsRight, { size: 20 }), " ", jsx("span", { children: "\u0642\u0628\u0644\u06CC" })] })),
82
- };
83
- return (jsx(PaginationLink, { "aria-label": "Go to previous page", className: !isMobile
84
- ? 'flex justify-center items-center gap-2 w-[89px] h-[48px] ml-4'
85
- : 'ml-2.5', device: device, variant: "nextPrev", ...props, children: device === 'mobile' ? content.mobile : content.desktop }));
86
- }
87
- function PaginationNext({ className, device, variant, ...props }) {
88
- const isMobile = device === 'mobile';
89
- const content = {
90
- mobile: jsx(ChevronLeft, { size: 18 }),
91
- desktop: (jsxs(Fragment, { children: [jsx("span", { children: "\u0628\u0639\u062F\u06CC" }), jsx(ChevronsLeft, { size: 20 })] })),
92
- };
93
- return (jsx(PaginationLink, { "aria-label": "Go to next page", className: !isMobile
94
- ? 'flex justify-center items-center gap-2 w-[89px] h-[48px] mr-4'
95
- : 'mr-2.5', device: device, variant: "nextPrev", ...props, children: device === 'mobile' ? content.mobile : content.desktop }));
96
- }
97
- function PaginationEllipsis({ className, ...props }) {
98
- return (jsx("span", { "aria-hidden": true, "data-slot": "pagination-ellipsis", className: cn('flex size-9 items-center justify-center', className), ...props, children: jsx(Ellipsis, { className: "size-4" }) }));
99
- }
100
- function buttonVariants({ variant, device, }) {
101
- const isMobile = device === 'mobile';
102
- const base = cn({
103
- 'flex items-center justify-center rounded-[6px]': true,
104
- 'w-[40px] h-[40px] text-s font-heavy': isMobile,
105
- 'w-[48px] h-[48px] text-l font-heavy': !isMobile,
106
- });
107
- const variants = {
108
- outline: 'border border-neutral-light bg-white text-neutral-darker',
109
- active: 'bg-primary text-white',
110
- nextPrev: 'border border-neutral-light bg-white text-neutral-darker',
111
- };
112
- return [base, variants[variant]].join(' ');
113
- }
114
- const Pagination = ({ pageCount, page: controlledPage, defaultPage = 1, onPageChange, className, isMobile, ...navProps }) => {
115
- const detectedIsMobile = useMobile();
116
- const actualIsMobile = isMobile ?? detectedIsMobile;
117
- const isControlled = controlledPage !== undefined;
118
- const [internalPage, setInternalPage] = useState(defaultPage);
119
- const page = isControlled ? controlledPage : internalPage;
120
- const device = actualIsMobile ? 'mobile' : 'desktop';
121
- useEffect(() => {
122
- if (!isControlled)
123
- setInternalPage(defaultPage);
124
- }, [defaultPage, isControlled]);
125
- const changePage = (newPage) => {
126
- if (!isControlled)
127
- setInternalPage(newPage);
128
- onPageChange?.(newPage);
129
- };
130
- function renderPages() {
131
- const items = [];
132
- if (pageCount <= 5) {
133
- for (let i = 1; i <= pageCount; i++) {
134
- items.push(jsx(PaginationItem, { children: jsx(PaginationLink, { href: "#", isActive: page === i, variant: "main", device: device, onClick: (e) => {
135
- e.preventDefault();
136
- if (page !== i)
137
- changePage(i);
138
- }, "aria-disabled": page === i, tabIndex: page === i ? -1 : 0, children: i }) }, i));
139
- }
140
- }
141
- else {
142
- // First page
143
- items.push(jsx(PaginationItem, { children: jsx(PaginationLink, { href: "#", isActive: page === 1, device: device, variant: "main", onClick: (e) => {
144
- e.preventDefault();
145
- if (page !== 1)
146
- changePage(1);
147
- }, "aria-disabled": page === 1, tabIndex: page === 1 ? -1 : 0, children: "1" }) }, 1));
148
- // Ellipsis start
149
- if (page > 3) {
150
- items.push(jsx(PaginationItem, { children: jsx(PaginationEllipsis, {}) }, "start-ellipsis"));
151
- }
152
- // Middle pages
153
- const start = Math.max(2, page - 1);
154
- const end = Math.min(pageCount - 1, page + 1);
155
- for (let i = start; i <= end; i++) {
156
- items.push(jsx(PaginationItem, { children: jsx(PaginationLink, { href: "#", isActive: page === i, device: device, variant: "main", onClick: (e) => {
157
- e.preventDefault();
158
- if (page !== i)
159
- changePage(i);
160
- }, "aria-disabled": page === i, tabIndex: page === i ? -1 : 0, children: i }) }, i));
161
- }
162
- // Ellipsis end
163
- if (page < pageCount - 2) {
164
- items.push(jsx(PaginationItem, { children: jsx(PaginationEllipsis, {}) }, "end-ellipsis"));
165
- }
166
- // Last page
167
- items.push(jsx(PaginationItem, { children: jsx(PaginationLink, { href: "#", isActive: page === pageCount, device: device, variant: "main", onClick: (e) => {
168
- e.preventDefault();
169
- if (page !== pageCount)
170
- changePage(pageCount);
171
- }, "aria-disabled": page === pageCount, tabIndex: page === pageCount ? -1 : 0, children: pageCount }) }, pageCount));
172
- }
173
- return items;
174
- }
175
- return (jsx(PaginationRoot, { className: className, ...navProps, children: jsxs(PaginationContent, { device: "mobile", children: [jsx(PaginationItem, { children: jsx(PaginationPrevious, { href: "#", onClick: (e) => {
176
- e.preventDefault();
177
- if (page > 1)
178
- changePage(page - 1);
179
- }, variant: "nextPrev", device: device, "aria-disabled": page === 1, tabIndex: page === 1 ? -1 : 0 }) }), renderPages(), jsx(PaginationItem, { children: jsx(PaginationNext, { href: "#", onClick: (e) => {
180
- e.preventDefault();
181
- if (page < pageCount)
182
- changePage(page + 1);
183
- }, variant: "nextPrev", device: device, "aria-disabled": page === pageCount, tabIndex: page === pageCount ? -1 : 0 }) })] }) }));
184
- };
185
-
186
- export { Pagination };
1
+ "use client";import{jsx as e,jsxs as i,Fragment as a}from"react/jsx-runtime";import{useState as t,useEffect as n}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 c}from"./chunks/chevron-left-4HSuTes3.js";const s=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,...a}){return e("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:r("mx-auto flex w-full justify-center",i),...a})}function PaginationContent({className:i,device:a,...t}){return e("ul",{"data-slot":"pagination-content",className:r("flex flex-row items-center","mobile"===a?"gap-[6px]":"gap-2",i),...t})}function PaginationItem({...i}){return e("li",{"data-slot":"pagination-item",...i})}function PaginationLink({className:i,device:a,variant:t,isActive:n,...o}){return e("a",{"aria-current":n?"page":void 0,"data-slot":"pagination-link","data-active":n,className:r(buttonVariants({variant:"nextPrev"===t?t:n?"active":"outline",device:a}),i),tabIndex:o["aria-disabled"]?-1:0,...o})}function PaginationPrevious({className:t,device:n,variant:r,...o}){const l="mobile"===n,c={mobile:e(s,{size:18}),desktop:i(a,{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:n,variant:"nextPrev",...o,children:"mobile"===n?c.mobile:c.desktop})}function PaginationNext({className:t,device:n,variant:r,...o}){const l="mobile"===n,s={mobile:e(c,{size:18}),desktop:i(a,{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:n,variant:"nextPrev",...o,children:"mobile"===n?s.mobile:s.desktop})}function PaginationEllipsis({className:i,...a}){return e("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:r("flex size-9 items-center justify-center",i),...a,children:e(p,{className:"size-4"})})}function buttonVariants({variant:e,device:i}){const a="mobile"===i;return[r({"flex items-center justify-center rounded-[6px]":!0,"w-[40px] h-[40px] text-s font-heavy":a,"w-[48px] h-[48px] text-l font-heavy":!a}),{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:a,page:r,defaultPage:l=1,onPageChange:c,className:s,isMobile:d,...m})=>{const p=o(),h=d??p,v=void 0!==r,[u,g]=t(l),f=v?r:u,x=h?"mobile":"desktop";n(()=>{v||g(l)},[l,v]);const changePage=e=>{v||g(e),c?.(e)};return e(PaginationRoot,{className:s,...m,children:i(PaginationContent,{device:"mobile",children:[e(PaginationItem,{children:e(PaginationPrevious,{href:"#",onClick:e=>{e.preventDefault(),f>1&&changePage(f-1)},variant:"nextPrev",device:x,"aria-disabled":1===f,tabIndex:1===f?-1:0})}),function(){const i=[];if(a<=5)for(let t=1;t<=a;t++)i.push(e(PaginationItem,{children:e(PaginationLink,{href:"#",isActive:f===t,variant:"main",device:x,onClick:e=>{e.preventDefault(),f!==t&&changePage(t)},"aria-disabled":f===t,tabIndex:f===t?-1:0,children:t})},t));else{i.push(e(PaginationItem,{children:e(PaginationLink,{href:"#",isActive:1===f,device:x,variant:"main",onClick:e=>{e.preventDefault(),1!==f&&changePage(1)},"aria-disabled":1===f,tabIndex:1===f?-1:0,children:"1"})},1)),f>3&&i.push(e(PaginationItem,{children:e(PaginationEllipsis,{})},"start-ellipsis"));const t=Math.max(2,f-1),n=Math.min(a-1,f+1);for(let a=t;a<=n;a++)i.push(e(PaginationItem,{children:e(PaginationLink,{href:"#",isActive:f===a,device:x,variant:"main",onClick:e=>{e.preventDefault(),f!==a&&changePage(a)},"aria-disabled":f===a,tabIndex:f===a?-1:0,children:a})},a));f<a-2&&i.push(e(PaginationItem,{children:e(PaginationEllipsis,{})},"end-ellipsis")),i.push(e(PaginationItem,{children:e(PaginationLink,{href:"#",isActive:f===a,device:x,variant:"main",onClick:e=>{e.preventDefault(),f!==a&&changePage(a)},"aria-disabled":f===a,tabIndex:f===a?-1:0,children:a})},a))}return i}(),e(PaginationItem,{children:e(PaginationNext,{href:"#",onClick:e=>{e.preventDefault(),f<a&&changePage(f+1)},variant:"nextPrev",device:x,"aria-disabled":f===a,tabIndex:f===a?-1:0})})]})})};export{Pagination};
@@ -1,71 +1 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import React from 'react';
3
- import cn from './utils.js';
4
- import { useMobile } from './contexts.js';
5
-
6
- const RadioButton = ({ selected, disabled, isMobile, }) => {
7
- const size = isMobile ? 'size-5' : 'size-6';
8
- if (selected) {
9
- return (jsxs("div", { className: cn('relative flex items-center justify-center', size), children: [jsx("div", { className: cn('absolute inset-0 rounded-full border-2', disabled
10
- ? 'bg-neutral-light border-neutral-light'
11
- : 'bg-primary border-primary') }), jsx("div", { className: cn('absolute rounded-full bg-white', isMobile ? 'inset-[5px]' : 'inset-1.5') })] }));
12
- }
13
- return (jsx("div", { className: cn('relative flex items-center justify-center', size), children: jsx("div", { className: cn('absolute inset-0 rounded-full border', isMobile ? 'border' : 'border-[1.5px]', disabled ? 'border-neutral-light' : 'border-midnight') }) }));
14
- };
15
- const RadioOptionComponent = ({ option, selected, disabled, onClick, name, isMobile = false, }) => {
16
- const [isHovered, setIsHovered] = React.useState(false);
17
- const handleKeyDown = (e) => {
18
- if ((e.key === 'Enter' || e.key === ' ') && !disabled) {
19
- e.preventDefault();
20
- onClick();
21
- }
22
- };
23
- const getBackgroundColor = () => {
24
- if (disabled)
25
- return 'bg-neutral-lighter';
26
- if (selected)
27
- return 'bg-primary-lightest';
28
- if (isHovered)
29
- return 'bg-primary-lightest/20';
30
- return 'bg-white';
31
- };
32
- const getBorderColor = () => {
33
- if (selected)
34
- return 'border-primary';
35
- return 'border-transparent';
36
- };
37
- const getTextColor = () => {
38
- if (disabled)
39
- return 'text-midnight';
40
- if (selected)
41
- return 'text-primary';
42
- return 'text-neutral-dark';
43
- };
44
- const getShadow = () => {
45
- if (disabled)
46
- return '';
47
- return 'shadow-[0px_2px_4px_0px_rgba(0,0,0,0.08)]';
48
- };
49
- return (jsx("div", { className: cn('relative rounded-lg border-[1.5px] cursor-pointer transition-all duration-200', getBackgroundColor(), getBorderColor(), getShadow(), disabled && 'cursor-not-allowed'), onClick: disabled ? undefined : onClick, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onKeyDown: handleKeyDown, tabIndex: disabled ? -1 : 0, role: "radio", "aria-checked": selected, "aria-disabled": disabled, children: jsx("div", { className: "flex flex-row items-center justify-end relative w-full", children: jsx("div", { className: cn('box-border flex flex-row items-center justify-end relative w-full', isMobile ? 'gap-2 px-4 py-3' : 'gap-4 px-6 py-4'), children: jsxs("div", { className: cn('flex flex-row items-center justify-end p-0 relative shrink-0', isMobile ? 'gap-2' : 'gap-3'), children: [jsx("input", { type: "radio", name: name, value: option.id, checked: selected, disabled: disabled, onChange: onClick, className: "sr-only", "aria-label": option.label }), jsx("div", { className: "flex flex-col gap-0.5 items-end justify-start p-0 relative shrink-0", children: jsx("div", { className: cn('font-sans font-bold text-nowrap text-right transition-colors duration-200', isMobile
50
- ? 'text-[14px] leading-[24px]'
51
- : 'text-[16px] leading-normal', getTextColor()), children: jsx("p", { className: "whitespace-pre", dir: "auto", children: option.label }) }) }), option.icon && (jsx("div", { className: cn('flex items-center justify-center shrink-0 transition-colors duration-200', isMobile ? 'size-6' : 'size-7', getTextColor()), children: option.icon })), jsx("div", { className: "flex flex-col items-start justify-start p-0 relative shrink-0", children: jsx(RadioButton, { selected: selected, disabled: disabled, isMobile: isMobile }) })] }) }) }) }));
52
- };
53
- const RadioGroup = React.forwardRef(({ options, value, onChange, name, disabled = false, className, isMobile, direction = 'vertical', ...props }, ref) => {
54
- const detectedIsMobile = useMobile();
55
- const actualIsMobile = isMobile ?? detectedIsMobile;
56
- const handleOptionClick = (optionId) => {
57
- if (!disabled && onChange) {
58
- onChange(optionId);
59
- }
60
- };
61
- const getContainerClasses = () => {
62
- if (direction === 'horizontal') {
63
- return cn('flex flex-row gap-2', actualIsMobile ? 'flex-wrap' : 'flex-nowrap', className);
64
- }
65
- return cn('flex flex-col gap-2', className);
66
- };
67
- return (jsx("div", { ref: ref, className: getContainerClasses(), role: "radiogroup", ...props, children: options.map((option) => (jsx(RadioOptionComponent, { option: option, selected: value === option.id, disabled: disabled || option.disabled, onClick: () => handleOptionClick(option.id), name: name, isMobile: actualIsMobile }, option.id))) }));
68
- });
69
- RadioGroup.displayName = 'RadioGroup';
70
-
71
- export { RadioGroup };
1
+ "use client";import{jsx as e,jsxs as r}from"react/jsx-runtime";import i from"react";import t from"./utils.js";import{useMobile as l}from"./contexts.js";const RadioButton=({selected:i,disabled:l,isMobile:a})=>{const s=a?"size-5":"size-6";return i?r("div",{className:t("relative flex items-center justify-center",s),children:[e("div",{className:t("absolute inset-0 rounded-full border-2",l?"bg-neutral-light border-neutral-light":"bg-primary border-primary")}),e("div",{className:t("absolute rounded-full bg-white",a?"inset-[5px]":"inset-1.5")})]}):e("div",{className:t("relative flex items-center justify-center",s),children:e("div",{className:t("absolute inset-0 rounded-full border",a?"border":"border-[1.5px]",l?"border-neutral-light":"border-midnight")})})},RadioOptionComponent=({option:l,selected:a,disabled:s,onClick:n,name:o,isMobile:d=!1})=>{const[c,p]=i.useState(!1),getTextColor=()=>s?"text-midnight":a?"text-primary":"text-neutral-dark";return e("div",{className:t("relative rounded-lg border-[1.5px] cursor-pointer transition-all duration-200",s?"bg-neutral-lighter":a?"bg-primary-lightest":c?"bg-primary-lightest/20":"bg-white",a?"border-primary":"border-transparent",s?"":"shadow-[0px_2px_4px_0px_rgba(0,0,0,0.08)]",s&&"cursor-not-allowed"),onClick:s?void 0:n,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||s||(e.preventDefault(),n())},tabIndex:s?-1:0,role:"radio","aria-checked":a,"aria-disabled":s,children:e("div",{className:"flex flex-row items-center justify-end relative w-full",children:e("div",{className:t("box-border flex flex-row items-center justify-end relative w-full",d?"gap-2 px-4 py-3":"gap-4 px-6 py-4"),children:r("div",{className:t("flex flex-row items-center justify-end p-0 relative shrink-0",d?"gap-2":"gap-3"),children:[e("input",{type:"radio",name:o,value:l.id,checked:a,disabled:s,onChange:n,className:"sr-only","aria-label":l.label}),e("div",{className:"flex flex-col gap-0.5 items-end justify-start p-0 relative shrink-0",children:e("div",{className:t("font-sans font-bold text-nowrap text-right transition-colors duration-200",d?"text-[14px] leading-[24px]":"text-[16px] leading-normal",getTextColor()),children:e("p",{className:"whitespace-pre",dir:"auto",children:l.label})})}),l.icon&&e("div",{className:t("flex items-center justify-center shrink-0 transition-colors duration-200",d?"size-6":"size-7",getTextColor()),children:l.icon}),e("div",{className:"flex flex-col items-start justify-start p-0 relative shrink-0",children:e(RadioButton,{selected:a,disabled:s,isMobile:d})})]})})})})},a=i.forwardRef(({options:r,value:i,onChange:a,name:s,disabled:n=!1,className:o,isMobile:d,direction:c="vertical",...p},m)=>{const u=l(),x=d??u;return e("div",{ref:m,className:"horizontal"===c?t("flex flex-row gap-2",x?"flex-wrap":"flex-nowrap",o):t("flex flex-col gap-2",o),role:"radiogroup",...p,children:r.map(r=>e(RadioOptionComponent,{option:r,selected:i===r.id,disabled:n||r.disabled,onClick:()=>{return e=r.id,void(!n&&a&&a(e));var e},name:s,isMobile:x},r.id))})});a.displayName="RadioGroup";export{a as RadioGroup};
package/dist/esm/Tabs.js CHANGED
@@ -1,52 +1 @@
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
-
6
- // Helper functions moved outside component
7
- const handleTabClick = (tabId, disabled, onTabChange) => {
8
- if (!disabled) {
9
- onTabChange(tabId);
10
- }
11
- };
12
- const handleKeyDown = (e, tabId, disabled, onTabChange) => {
13
- if ((e.key === 'Enter' || e.key === ' ') && !disabled) {
14
- e.preventDefault();
15
- onTabChange(tabId);
16
- }
17
- };
18
- const renderBadge = (count, isActive, disabled, isMobile) => {
19
- if (count === undefined)
20
- return null;
21
- return (jsx("div", { className: cn('flex items-center justify-center rounded-[5px] font-sans font-bold text-white', 'transition-colors duration-200', isMobile
22
- ? 'size-6 text-[14px] pt-0.5'
23
- : 'size-[25px] text-[14px] pt-[3px]', disabled ? 'bg-midnight' : isActive ? 'bg-primary' : 'bg-neutral-main'), children: jsx("p", { className: "leading-[24px] whitespace-pre", dir: "auto", children: count }) }));
24
- };
25
- const renderTabContent = (item, isActive, isMobile) => {
26
- const hasCount = item.count !== undefined;
27
- return (jsxs("div", { className: cn('flex flex-row items-center justify-start transition-colors duration-200', isMobile ? 'gap-1.5' : 'gap-1.5'), children: [hasCount && renderBadge(item.count, isActive, item.disabled, isMobile), jsx("div", { className: cn('font-sans text-nowrap text-right transition-colors duration-200', isMobile ? 'text-[14px]' : isActive ? 'text-[16px]' : 'text-[18px]', item.disabled
28
- ? 'font-normal text-midnight'
29
- : isActive
30
- ? 'font-bold text-primary'
31
- : 'font-normal text-neutral-main', isMobile
32
- ? 'leading-[24px]'
33
- : isActive
34
- ? 'leading-normal'
35
- : 'leading-[1.9]'), children: jsx("p", { className: "whitespace-pre", dir: "auto", children: item.label }) })] }));
36
- };
37
- const renderTab = (item, activeTab, isMobile, onTabChange) => {
38
- const isActive = item.id === activeTab;
39
- return (jsxs("div", { className: cn('box-border flex flex-col items-center justify-between relative shrink-0', 'cursor-pointer transition-all duration-200', isMobile ? 'h-12 px-3' : 'h-14 px-4', isActive
40
- ? isMobile
41
- ? 'pt-[11px] pb-0'
42
- : 'pt-3.5 pb-0'
43
- : 'py-0 justify-center', item.disabled && 'cursor-not-allowed opacity-50', !item.disabled && 'hover:opacity-80'), onClick: () => handleTabClick(item.id, item.disabled, onTabChange), onKeyDown: (e) => handleKeyDown(e, item.id, item.disabled, onTabChange), tabIndex: item.disabled ? -1 : 0, role: "tab", "aria-selected": isActive, "aria-disabled": item.disabled, children: [renderTabContent(item, isActive, isMobile), isActive && (jsx("div", { className: "bg-primary h-1 rounded-tl-[8px] rounded-tr-[8px] shrink-0 w-full" }))] }, item.id));
44
- };
45
- const Tabs = React.forwardRef(({ items, activeTab, onTabChange, className, isMobile, ...props }, ref) => {
46
- const detectedIsMobile = useMobile();
47
- const actualIsMobile = isMobile ?? detectedIsMobile;
48
- return (jsxs("div", { ref: ref, className: cn('relative w-full', className), ...props, children: [jsx("div", { className: "box-border flex flex-row items-center justify-end p-0 relative w-full", children: items.map((item) => renderTab(item, activeTab, actualIsMobile, onTabChange)) }), jsx("div", { className: "absolute border-midnight-light border-[0px_0px_1px] border-solid bottom-[-0.5px] left-0 right-0 top-0 pointer-events-none" })] }));
49
- });
50
- Tabs.displayName = 'Tabs';
51
-
52
- export { Tabs };
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import i from"react";import r from"./utils.js";import{useMobile as a}from"./contexts.js";const renderBadge=(e,i,a,n)=>void 0===e?null:t("div",{className:r("flex items-center justify-center rounded-[5px] font-sans font-bold text-white","transition-colors duration-200",n?"size-6 text-[14px] pt-0.5":"size-[25px] text-[14px] pt-[3px]",a?"bg-midnight":i?"bg-primary":"bg-neutral-main"),children:t("p",{className:"leading-[24px] whitespace-pre",dir:"auto",children:e})}),renderTabContent=(i,a,n)=>{const o=void 0!==i.count;return e("div",{className:r("flex flex-row items-center justify-start transition-colors duration-200","gap-1.5"),children:[o&&renderBadge(i.count,a,i.disabled,n),t("div",{className:r("font-sans text-nowrap text-right transition-colors duration-200",n?"text-[14px]":a?"text-[16px]":"text-[18px]",i.disabled?"font-normal text-midnight":a?"font-bold text-primary":"font-normal text-neutral-main",n?"leading-[24px]":a?"leading-normal":"leading-[1.9]"),children:t("p",{className:"whitespace-pre",dir:"auto",children:i.label})})]})},n=i.forwardRef(({items:i,activeTab:n,onTabChange:o,className:l,isMobile:s,...d},p)=>{const c=a(),x=s??c;return e("div",{ref:p,className:r("relative w-full",l),...d,children:[t("div",{className:"box-border flex flex-row items-center justify-end p-0 relative w-full",children:i.map(i=>((i,a,n,o)=>{const l=i.id===a;return e("div",{className:r("box-border flex flex-col items-center justify-between relative shrink-0","cursor-pointer transition-all duration-200",n?"h-12 px-3":"h-14 px-4",l?n?"pt-[11px] pb-0":"pt-3.5 pb-0":"py-0 justify-center",i.disabled&&"cursor-not-allowed opacity-50",!i.disabled&&"hover:opacity-80"),onClick:()=>((e,t,i)=>{t||i(e)})(i.id,i.disabled,o),onKeyDown:e=>((e,t,i,r)=>{"Enter"!==e.key&&" "!==e.key||i||(e.preventDefault(),r(t))})(e,i.id,i.disabled,o),tabIndex:i.disabled?-1:0,role:"tab","aria-selected":l,"aria-disabled":i.disabled,children:[renderTabContent(i,l,n),l&&t("div",{className:"bg-primary h-1 rounded-tl-[8px] rounded-tr-[8px] shrink-0 w-full"})]},i.id)})(i,n,x,o))}),t("div",{className:"absolute border-midnight-light border-[0px_0px_1px] border-solid bottom-[-0.5px] left-0 right-0 top-0 pointer-events-none"})]})});n.displayName="Tabs";export{n as Tabs};
@@ -1,60 +1 @@
1
- import React from 'react';
2
- import cn from './utils.js';
3
-
4
- const variantClasses = {
5
- // Headings with Fat weight (900)
6
- h1: 'text-[36px] font-[var(--font-weight-fat)]',
7
- h2: 'text-[32px] font-[var(--font-weight-fat)]',
8
- h3: 'text-[28px] font-[var(--font-weight-fat)]',
9
- h4: 'text-[24px] font-[var(--font-weight-heavy)]',
10
- h5: 'text-[22px] font-[var(--font-weight-heavy)]',
11
- h6: 'text-[20px] font-[var(--font-weight-heavy)]',
12
- // Body Copy with specific weight variants
13
- 'body-xl-heavy': 'text-[20px] font-[var(--font-weight-heavy)]',
14
- 'body-l-heavy': 'text-[18px] font-[var(--font-weight-heavy)]',
15
- 'body-l-bold': 'text-[18px] font-[var(--font-weight-bold)]',
16
- 'body-l-medium': 'text-[18px] font-[var(--font-weight-medium)]',
17
- 'body-m-heavy': 'text-[16px] font-[var(--font-weight-heavy)]',
18
- 'body-m-bold': 'text-[16px] font-[var(--font-weight-bold)]',
19
- 'body-m-medium': 'text-[16px] font-[var(--font-weight-medium)]',
20
- 'body-s-heavy': 'text-[14px] font-[var(--font-weight-heavy)]',
21
- 'body-s-bold': 'text-[14px] font-[var(--font-weight-bold)]',
22
- 'body-s-medium': 'text-[14px] font-[var(--font-weight-medium)]',
23
- 'body-ms-bold': 'text-[13px] font-[var(--font-weight-bold)]',
24
- 'body-ms-medium': 'text-[13px] font-[var(--font-weight-medium)]',
25
- 'body-xs-bold': 'text-[12px] font-[var(--font-weight-bold)]',
26
- 'body-xs-medium': 'text-[12px] font-[var(--font-weight-medium)]',
27
- 'body-t-bold': 'text-[10px] font-[var(--font-weight-bold)]',
28
- 'body-t-medium': 'text-[10px] font-[var(--font-weight-medium)]',
29
- 'body-ss-medium': 'text-[9px] font-[var(--font-weight-medium)]',
30
- };
31
- // Export for reuse in other components
32
- const getTypographyClasses = (variant) => {
33
- return variantClasses[variant];
34
- };
35
- const colorClasses = {
36
- primary: 'text-[var(--color-primary)]',
37
- secondary: 'text-[var(--color-secondary)]',
38
- 'neutral-darker': 'text-[var(--color-neutral-darker)]',
39
- 'neutral-dark': 'text-[var(--color-neutral-dark)]',
40
- 'neutral-main': 'text-[var(--color-neutral-main)]',
41
- white: 'text-[var(--color-white)]',
42
- inherit: 'text-inherit',
43
- };
44
- const getDefaultElement = (variant) => {
45
- if (variant.startsWith('h'))
46
- return variant.split('-')[0]; // h1, h2, etc.
47
- return 'p';
48
- };
49
- const Typography = React.forwardRef(({ variant = 'body-m-medium', color = 'inherit', as, className, children, ...props }, ref) => {
50
- const Element = as || getDefaultElement(variant);
51
- return React.createElement(Element, {
52
- ref,
53
- className: cn(variantClasses[variant], colorClasses[color], 'leading-[var(--leading-default)]', // 180% line height
54
- className),
55
- ...props,
56
- }, children);
57
- });
58
- Typography.displayName = 'Typography';
59
-
60
- export { Typography, getTypographyClasses };
1
+ import t from"react";import e from"./utils.js";const o={h1:"text-[36px] font-[var(--font-weight-fat)]",h2:"text-[32px] font-[var(--font-weight-fat)]",h3:"text-[28px] font-[var(--font-weight-fat)]",h4:"text-[24px] font-[var(--font-weight-heavy)]",h5:"text-[22px] font-[var(--font-weight-heavy)]",h6:"text-[20px] font-[var(--font-weight-heavy)]","body-xl-heavy":"text-[20px] font-[var(--font-weight-heavy)]","body-l-heavy":"text-[18px] font-[var(--font-weight-heavy)]","body-l-bold":"text-[18px] font-[var(--font-weight-bold)]","body-l-medium":"text-[18px] font-[var(--font-weight-medium)]","body-m-heavy":"text-[16px] font-[var(--font-weight-heavy)]","body-m-bold":"text-[16px] font-[var(--font-weight-bold)]","body-m-medium":"text-[16px] font-[var(--font-weight-medium)]","body-s-heavy":"text-[14px] font-[var(--font-weight-heavy)]","body-s-bold":"text-[14px] font-[var(--font-weight-bold)]","body-s-medium":"text-[14px] font-[var(--font-weight-medium)]","body-ms-bold":"text-[13px] font-[var(--font-weight-bold)]","body-ms-medium":"text-[13px] font-[var(--font-weight-medium)]","body-xs-bold":"text-[12px] font-[var(--font-weight-bold)]","body-xs-medium":"text-[12px] font-[var(--font-weight-medium)]","body-t-bold":"text-[10px] font-[var(--font-weight-bold)]","body-t-medium":"text-[10px] font-[var(--font-weight-medium)]","body-ss-medium":"text-[9px] font-[var(--font-weight-medium)]"},getTypographyClasses=t=>o[t],a={primary:"text-[var(--color-primary)]",secondary:"text-[var(--color-secondary)]","neutral-darker":"text-[var(--color-neutral-darker)]","neutral-dark":"text-[var(--color-neutral-dark)]","neutral-main":"text-[var(--color-neutral-main)]",white:"text-[var(--color-white)]",inherit:"text-inherit"},r=t.forwardRef(({variant:r="body-m-medium",color:n="inherit",as:i,className:d,children:x,...f},h)=>{const m=i||(t=>t.startsWith("h")?t.split("-")[0]:"p")(r);return t.createElement(m,{ref:h,className:e(o[r],a[n],"leading-[var(--leading-default)]",d),...f},x)});r.displayName="Typography";export{r as Typography,getTypographyClasses};