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.
- package/dist/cjs/Accordion.js +1 -59
- package/dist/cjs/Backdrop.js +1 -26
- package/dist/cjs/Breadcrumb.js +1 -61
- package/dist/cjs/Button.js +1 -48
- package/dist/cjs/Chips.js +1 -117
- package/dist/cjs/Divider.js +1 -23
- package/dist/cjs/Drawer.js +1 -112
- package/dist/cjs/Input.js +1 -84
- package/dist/cjs/Menu.js +1 -122
- package/dist/cjs/Pagination.js +1 -188
- package/dist/cjs/RadioGroup.js +1 -73
- package/dist/cjs/Tabs.js +1 -54
- package/dist/cjs/Typography.js +1 -63
- package/dist/cjs/contexts.js +1 -1491
- package/dist/cjs/index.js +1 -52
- package/dist/cjs/utils.js +1 -9
- package/dist/esm/Accordion.js +1 -57
- package/dist/esm/Backdrop.js +1 -24
- package/dist/esm/Breadcrumb.js +1 -59
- package/dist/esm/Button.js +1 -46
- package/dist/esm/Chips.js +1 -112
- package/dist/esm/Divider.js +1 -21
- package/dist/esm/Drawer.js +1 -110
- package/dist/esm/Input.js +1 -82
- package/dist/esm/Menu.js +1 -120
- package/dist/esm/Pagination.js +1 -186
- package/dist/esm/RadioGroup.js +1 -71
- package/dist/esm/Tabs.js +1 -52
- package/dist/esm/Typography.js +1 -60
- package/dist/esm/contexts.js +1 -1485
- package/dist/esm/index.js +1 -37
- package/dist/esm/utils.js +1 -7
- package/dist/types/Accordion.js +57 -0
- package/dist/types/Backdrop.js +24 -0
- package/dist/types/Breadcrumb.js +59 -0
- package/dist/types/Button.js +46 -0
- package/dist/types/Chips.js +112 -0
- package/dist/types/Divider.js +21 -0
- package/dist/types/Drawer.js +110 -0
- package/dist/types/Input.js +82 -0
- package/dist/types/Menu.js +120 -0
- package/dist/types/Pagination.js +186 -0
- package/dist/types/RadioGroup.js +71 -0
- package/dist/types/Tabs.js +52 -0
- package/dist/types/Typography.js +60 -0
- package/dist/types/contexts.js +1485 -0
- package/dist/{cjs → types}/index.d.ts +1 -0
- package/dist/types/index.js +37 -0
- package/dist/types/utils.js +7 -0
- package/package.json +1 -1
- package/dist/cjs/chevron-left-COj1qGVo.js +0 -16
- package/dist/cjs/createLucideIcon-BTjFFtDc.js +0 -114
- package/dist/esm/components/Accordion/Accordion.d.ts +0 -25
- package/dist/esm/components/Accordion/Accordion.stories.d.ts +0 -175
- package/dist/esm/components/Backdrop/Backdrop.d.ts +0 -20
- package/dist/esm/components/Backdrop/Backdrop.stories.d.ts +0 -9
- package/dist/esm/components/Breadcrumb/Breadcrumb.d.ts +0 -16
- package/dist/esm/components/Breadcrumb/Breadcrumb.stories.d.ts +0 -177
- package/dist/esm/components/Button/Button.d.ts +0 -13
- package/dist/esm/components/Button/Button.stories.d.ts +0 -100
- package/dist/esm/components/Chips/Chips.d.ts +0 -37
- package/dist/esm/components/Chips/Chips.stories.d.ts +0 -90
- package/dist/esm/components/Divider/Divider.d.ts +0 -25
- package/dist/esm/components/Divider/Divider.stories.d.ts +0 -88
- package/dist/esm/components/Drawer/Drawer.d.ts +0 -16
- package/dist/esm/components/Drawer/Drawer.stories.d.ts +0 -128
- package/dist/esm/components/Input/Input.d.ts +0 -24
- package/dist/esm/components/Input/Input.stories.d.ts +0 -131
- package/dist/esm/components/Menu/Menu.d.ts +0 -39
- package/dist/esm/components/Menu/Menu.stories.d.ts +0 -89
- package/dist/esm/components/Pagination/Pagination.d.ts +0 -12
- package/dist/esm/components/Pagination/Pagination.stories.d.ts +0 -76
- package/dist/esm/components/RadioGroup/RadioGroup.d.ts +0 -55
- package/dist/esm/components/RadioGroup/RadioGroup.stories.d.ts +0 -86
- package/dist/esm/components/Select/Select.d.ts +0 -17
- package/dist/esm/components/Select/Select.stories.d.ts +0 -104
- package/dist/esm/components/Tabs/Tabs.d.ts +0 -43
- package/dist/esm/components/Tabs/Tabs.stories.d.ts +0 -66
- package/dist/esm/components/Typography/Typography.d.ts +0 -9
- package/dist/esm/components/Typography/Typography.stories.d.ts +0 -57
- package/dist/esm/contexts/MobileContext.d.ts +0 -13
- package/dist/esm/index.d.ts +0 -34
- package/dist/esm/utils/cn.d.ts +0 -2
- /package/dist/{esm → types}/chevron-left-Ck6O99eF.js +0 -0
- /package/dist/{cjs → types}/components/Accordion/Accordion.d.ts +0 -0
- /package/dist/{cjs → types}/components/Accordion/Accordion.stories.d.ts +0 -0
- /package/dist/{cjs → types}/components/Backdrop/Backdrop.d.ts +0 -0
- /package/dist/{cjs → types}/components/Backdrop/Backdrop.stories.d.ts +0 -0
- /package/dist/{cjs → types}/components/Breadcrumb/Breadcrumb.d.ts +0 -0
- /package/dist/{cjs → types}/components/Breadcrumb/Breadcrumb.stories.d.ts +0 -0
- /package/dist/{cjs → types}/components/Button/Button.d.ts +0 -0
- /package/dist/{cjs → types}/components/Button/Button.stories.d.ts +0 -0
- /package/dist/{cjs → types}/components/Chips/Chips.d.ts +0 -0
- /package/dist/{cjs → types}/components/Chips/Chips.stories.d.ts +0 -0
- /package/dist/{cjs → types}/components/Divider/Divider.d.ts +0 -0
- /package/dist/{cjs → types}/components/Divider/Divider.stories.d.ts +0 -0
- /package/dist/{cjs → types}/components/Drawer/Drawer.d.ts +0 -0
- /package/dist/{cjs → types}/components/Drawer/Drawer.stories.d.ts +0 -0
- /package/dist/{cjs → types}/components/Input/Input.d.ts +0 -0
- /package/dist/{cjs → types}/components/Input/Input.stories.d.ts +0 -0
- /package/dist/{cjs → types}/components/Menu/Menu.d.ts +0 -0
- /package/dist/{cjs → types}/components/Menu/Menu.stories.d.ts +0 -0
- /package/dist/{cjs → types}/components/Pagination/Pagination.d.ts +0 -0
- /package/dist/{cjs → types}/components/Pagination/Pagination.stories.d.ts +0 -0
- /package/dist/{cjs → types}/components/RadioGroup/RadioGroup.d.ts +0 -0
- /package/dist/{cjs → types}/components/RadioGroup/RadioGroup.stories.d.ts +0 -0
- /package/dist/{cjs → types}/components/Select/Select.d.ts +0 -0
- /package/dist/{cjs → types}/components/Select/Select.stories.d.ts +0 -0
- /package/dist/{cjs → types}/components/Tabs/Tabs.d.ts +0 -0
- /package/dist/{cjs → types}/components/Tabs/Tabs.stories.d.ts +0 -0
- /package/dist/{cjs → types}/components/Typography/Typography.d.ts +0 -0
- /package/dist/{cjs → types}/components/Typography/Typography.stories.d.ts +0 -0
- /package/dist/{cjs → types}/contexts/MobileContext.d.ts +0 -0
- /package/dist/{esm → types}/createLucideIcon-D-q73LTT.js +0 -0
- /package/dist/{cjs → types}/utils/cn.d.ts +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -1,52 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var Typography$1 = require('./Typography.js');
|
|
4
|
-
var Button$1 = require('./Button.js');
|
|
5
|
-
var Input$1 = require('./Input.js');
|
|
6
|
-
var Tabs$1 = require('./Tabs.js');
|
|
7
|
-
var Drawer$1 = require('./Drawer.js');
|
|
8
|
-
var Backdrop$1 = require('./Backdrop.js');
|
|
9
|
-
var Breadcrumb$1 = require('./Breadcrumb.js');
|
|
10
|
-
var Pagination$1 = require('./Pagination.js');
|
|
11
|
-
var Accordion$1 = require('./Accordion.js');
|
|
12
|
-
var Divider$1 = require('./Divider.js');
|
|
13
|
-
var RadioGroup$1 = require('./RadioGroup.js');
|
|
14
|
-
var Chips$1 = require('./Chips.js');
|
|
15
|
-
var Menu$1 = require('./Menu.js');
|
|
16
|
-
var contexts = require('./contexts.js');
|
|
17
|
-
require('react');
|
|
18
|
-
require('./utils.js');
|
|
19
|
-
require('react/jsx-runtime');
|
|
20
|
-
require('./chevron-left-COj1qGVo.js');
|
|
21
|
-
require('./createLucideIcon-BTjFFtDc.js');
|
|
22
|
-
|
|
23
|
-
// Original Components (for internal use)
|
|
24
|
-
// Components (direct exports)
|
|
25
|
-
const Typography = Typography$1.Typography;
|
|
26
|
-
const Button = Button$1.Button;
|
|
27
|
-
const Input = Input$1.Input;
|
|
28
|
-
const Tabs = Tabs$1.Tabs;
|
|
29
|
-
const Drawer = Drawer$1.Drawer;
|
|
30
|
-
const Backdrop = Backdrop$1.Backdrop;
|
|
31
|
-
const Breadcrumb = Breadcrumb$1.Breadcrumb;
|
|
32
|
-
const Pagination = Pagination$1.Pagination;
|
|
33
|
-
const Accordion = Accordion$1.Accordion;
|
|
34
|
-
const Divider = Divider$1.Divider;
|
|
35
|
-
const RadioGroup = RadioGroup$1.RadioGroup;
|
|
36
|
-
const Chips = Chips$1.Chips;
|
|
37
|
-
const Menu = Menu$1.Menu;
|
|
38
|
-
|
|
39
|
-
exports.MobileProvider = contexts.MobileProvider;
|
|
40
|
-
exports.Accordion = Accordion;
|
|
41
|
-
exports.Backdrop = Backdrop;
|
|
42
|
-
exports.Breadcrumb = Breadcrumb;
|
|
43
|
-
exports.Button = Button;
|
|
44
|
-
exports.Chips = Chips;
|
|
45
|
-
exports.Divider = Divider;
|
|
46
|
-
exports.Drawer = Drawer;
|
|
47
|
-
exports.Input = Input;
|
|
48
|
-
exports.Menu = Menu;
|
|
49
|
-
exports.Pagination = Pagination;
|
|
50
|
-
exports.RadioGroup = RadioGroup;
|
|
51
|
-
exports.Tabs = Tabs;
|
|
52
|
-
exports.Typography = Typography;
|
|
1
|
+
"use strict";var r=require("./Typography.js"),e=require("./Button.js"),i=require("./Input.js"),o=require("./Tabs.js"),s=require("./Drawer.js"),u=require("./Backdrop.js"),t=require("./Breadcrumb.js"),p=require("./Pagination.js"),a=require("./Accordion.js"),n=require("./Divider.js"),c=require("./RadioGroup.js"),q=require("./Chips.js"),d=require("./Menu.js"),j=require("./contexts.js");require("react"),require("./utils.js"),require("react/jsx-runtime"),require("./chunks/chevron-left-Do__K6cA.js"),require("./chunks/createLucideIcon-BqJVOzoK.js");const x=r.Typography,b=e.Button,h=i.Input,B=o.Tabs,v=s.Drawer,M=u.Backdrop,g=t.Breadcrumb,l=p.Pagination,y=a.Accordion,D=n.Divider,T=c.RadioGroup,k=q.Chips,P=d.Menu;exports.MobileProvider=j.MobileProvider,exports.useMobile=j.useMobile,exports.Accordion=y,exports.Backdrop=M,exports.Breadcrumb=g,exports.Button=b,exports.Chips=k,exports.Divider=D,exports.Drawer=v,exports.Input=h,exports.Menu=P,exports.Pagination=l,exports.RadioGroup=T,exports.Tabs=B,exports.Typography=x;
|
package/dist/cjs/utils.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
4
|
-
|
|
5
|
-
function cn(...inputs) {
|
|
6
|
-
return clsx(inputs);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
module.exports = cn;
|
|
1
|
+
"use strict";function r(e){var t,n,f="";if("string"==typeof e||"number"==typeof e)f+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=r(e[t]))&&(f&&(f+=" "),f+=n)}else for(n in e)e[n]&&(f&&(f+=" "),f+=n);return f}module.exports=function(...e){return function(){for(var e,t,n=0,f="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=r(e))&&(f&&(f+=" "),f+=t);return f}(e)};
|
package/dist/esm/Accordion.js
CHANGED
|
@@ -1,57 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import cn from './utils.js';
|
|
4
|
-
import { useMobile } from './contexts.js';
|
|
5
|
-
import { Typography } from './Typography.js';
|
|
6
|
-
import { c as createLucideIcon } from './createLucideIcon-D-q73LTT.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$1 = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
|
|
17
|
-
const ChevronDown = createLucideIcon("chevron-down", __iconNode$1);
|
|
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 = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]];
|
|
28
|
-
const ChevronUp = createLucideIcon("chevron-up", __iconNode);
|
|
29
|
-
|
|
30
|
-
const Accordion = React.forwardRef(({ title, body, startIcon, isExpanded: controlledExpanded, onToggle, defaultExpanded = false, className, id, disabled = false, isMobile, ...props }, ref) => {
|
|
31
|
-
const detectedIsMobile = useMobile();
|
|
32
|
-
const actualIsMobile = isMobile ?? detectedIsMobile;
|
|
33
|
-
const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);
|
|
34
|
-
// Use controlled state if provided, otherwise use internal state
|
|
35
|
-
const isExpanded = controlledExpanded !== undefined ? controlledExpanded : internalExpanded;
|
|
36
|
-
const handleToggle = () => {
|
|
37
|
-
if (disabled)
|
|
38
|
-
return;
|
|
39
|
-
const newExpanded = !isExpanded;
|
|
40
|
-
if (controlledExpanded === undefined) {
|
|
41
|
-
setInternalExpanded(newExpanded);
|
|
42
|
-
}
|
|
43
|
-
onToggle?.(newExpanded);
|
|
44
|
-
};
|
|
45
|
-
const accordionId = id || `accordion-${Math.random().toString(36).substr(2, 9)}`;
|
|
46
|
-
const headerId = `${accordionId}-header`;
|
|
47
|
-
const contentId = `${accordionId}-content`;
|
|
48
|
-
// Icon size based on device
|
|
49
|
-
const iconSize = actualIsMobile ? 20 : 24;
|
|
50
|
-
// Typography variants based on device
|
|
51
|
-
const titleVariant = actualIsMobile ? 'body-s-heavy' : 'body-l-heavy';
|
|
52
|
-
const bodyVariant = actualIsMobile ? 'body-s-medium' : 'body-m-medium';
|
|
53
|
-
return (jsxs("div", { ref: ref, className: cn('rounded-2xl border-0 overflow-hidden', 'transition-all duration-200 ease-in-out', className), ...props, children: [jsxs("button", { id: headerId, type: "button", onClick: handleToggle, disabled: disabled, "aria-expanded": isExpanded, "aria-controls": contentId, className: cn('w-full flex items-center justify-between', actualIsMobile ? 'p-3' : 'p-4', 'focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2', 'disabled:opacity-50 disabled:cursor-not-allowed', 'transition-all duration-200 ease-in-out', !disabled && 'hover:bg-neutral-lighter'), children: [jsx("div", { className: "flex-shrink-0 mr-4", children: isExpanded ? (jsx(ChevronUp, { size: iconSize, className: "text-neutral-darker transition-transform duration-200", "aria-hidden": "true" })) : (jsx(ChevronDown, { size: iconSize, className: "text-neutral-darker transition-transform duration-200", "aria-hidden": "true" })) }), jsxs("div", { className: cn('flex items-center flex-1', actualIsMobile ? 'gap-3' : 'gap-4'), children: [jsx("div", { className: "flex-1 text-right", children: jsx(Typography, { variant: titleVariant, color: "neutral-darker", children: title }) }), startIcon && (jsx("div", { className: cn('flex-shrink-0 flex items-center justify-center', actualIsMobile ? 'w-6 h-6' : 'w-8 h-8'), children: startIcon }))] })] }), jsx("div", { id: contentId, role: "region", "aria-labelledby": headerId, className: cn('w-full overflow-hidden transition-all duration-300 ease-in-out', isExpanded ? 'max-h-screen opacity-100' : 'max-h-0 opacity-0'), children: jsx("div", { className: cn(actualIsMobile ? 'pb-3 mt-1' : 'pb-4 mt-1.5'), children: jsx("div", { className: cn('bg-neutral-lighter rounded-lg', actualIsMobile ? 'p-3' : 'p-4'), children: jsx(Typography, { variant: bodyVariant, color: "neutral-dark", children: body }) }) }) })] }));
|
|
54
|
-
});
|
|
55
|
-
Accordion.displayName = 'Accordion';
|
|
56
|
-
|
|
57
|
-
export { Accordion };
|
|
1
|
+
"use client";import{jsxs as e,jsx as r}from"react/jsx-runtime";import i,{useState as a}from"react";import t from"./utils.js";import{useMobile as o}from"./contexts.js";import{Typography as n}from"./Typography.js";import{c as d}from"./chunks/createLucideIcon-DGp0SoUT.js";const l=d("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),s=d("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),c=i.forwardRef(({title:i,body:d,startIcon:c,isExpanded:m,onToggle:u,defaultExpanded:h=!1,className:f,id:p,disabled:b=!1,isMobile:y,...v},x)=>{const g=o(),N=y??g,[w,k]=a(h),j=void 0!==m?m:w,$=p||`accordion-${Math.random().toString(36).substr(2,9)}`,z=`${$}-header`,E=`${$}-content`,I=N?20:24,M=N?"body-s-heavy":"body-l-heavy",T=N?"body-s-medium":"body-m-medium";return e("div",{ref:x,className:t("rounded-2xl border-0 overflow-hidden","transition-all duration-200 ease-in-out",f),...v,children:[e("button",{id:z,type:"button",onClick:()=>{if(b)return;const e=!j;void 0===m&&k(e),u?.(e)},disabled:b,"aria-expanded":j,"aria-controls":E,className:t("w-full flex items-center justify-between",N?"p-3":"p-4","focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2","disabled:opacity-50 disabled:cursor-not-allowed","transition-all duration-200 ease-in-out",!b&&"hover:bg-neutral-lighter"),children:[r("div",{className:"flex-shrink-0 mr-4",children:r(j?s:l,{size:I,className:"text-neutral-darker transition-transform duration-200","aria-hidden":"true"})}),e("div",{className:t("flex items-center flex-1",N?"gap-3":"gap-4"),children:[r("div",{className:"flex-1 text-right",children:r(n,{variant:M,color:"neutral-darker",children:i})}),c&&r("div",{className:t("flex-shrink-0 flex items-center justify-center",N?"w-6 h-6":"w-8 h-8"),children:c})]})]}),r("div",{id:E,role:"region","aria-labelledby":z,className:t("w-full overflow-hidden transition-all duration-300 ease-in-out",j?"max-h-screen opacity-100":"max-h-0 opacity-0"),children:r("div",{className:t(N?"pb-3 mt-1":"pb-4 mt-1.5"),children:r("div",{className:t("bg-neutral-lighter rounded-lg",N?"p-3":"p-4"),children:r(n,{variant:T,color:"neutral-dark",children:d})})})})]})});c.displayName="Accordion";export{c as Accordion};
|
package/dist/esm/Backdrop.js
CHANGED
|
@@ -1,24 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import cn from './utils.js';
|
|
4
|
-
|
|
5
|
-
const Backdrop = React.forwardRef(({ isOpen = false, onClick, blur = false, zIndex = 51, className, children, ...props }, ref) => {
|
|
6
|
-
const handleClick = (event) => {
|
|
7
|
-
if (onClick && event.target === event.currentTarget) {
|
|
8
|
-
onClick();
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
const backdropClasses = cn('fixed inset-0 transition-all duration-300', {
|
|
12
|
-
'opacity-100 pointer-events-auto': isOpen,
|
|
13
|
-
'opacity-0 pointer-events-none': !isOpen,
|
|
14
|
-
'backdrop-blur-sm': blur,
|
|
15
|
-
}, className);
|
|
16
|
-
const backdropStyle = {
|
|
17
|
-
backgroundColor: 'rgba(0, 0, 0, 0.60)',
|
|
18
|
-
zIndex,
|
|
19
|
-
};
|
|
20
|
-
return (jsx("div", { ref: ref, className: backdropClasses, style: backdropStyle, onClick: handleClick, role: "presentation", "aria-hidden": !isOpen, ...props, children: children }));
|
|
21
|
-
});
|
|
22
|
-
Backdrop.displayName = 'Backdrop';
|
|
23
|
-
|
|
24
|
-
export { Backdrop };
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import e from"react";import t from"./utils.js";const o=e.forwardRef(({isOpen:e=!1,onClick:o,blur:n=!1,zIndex:a=51,className:i,children:s,...c},l)=>{const d=t("fixed inset-0 transition-all duration-300",{"opacity-100 pointer-events-auto":e,"opacity-0 pointer-events-none":!e,"backdrop-blur-sm":n},i);return r("div",{ref:l,className:d,style:{backgroundColor:"rgba(0, 0, 0, 0.60)",zIndex:a},onClick:r=>{o&&r.target===r.currentTarget&&o()},role:"presentation","aria-hidden":!e,...c,children:s})});o.displayName="Backdrop";export{o as Backdrop};
|
package/dist/esm/Breadcrumb.js
CHANGED
|
@@ -1,59 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import cn from './utils.js';
|
|
4
|
-
import { useMobile } from './contexts.js';
|
|
5
|
-
import { C as ChevronLeft } from './chevron-left-Ck6O99eF.js';
|
|
6
|
-
import './createLucideIcon-D-q73LTT.js';
|
|
7
|
-
|
|
8
|
-
const Breadcrumb = React.forwardRef(({ items, className, isMobile }, ref) => {
|
|
9
|
-
const detectedIsMobile = useMobile();
|
|
10
|
-
const actualIsMobile = isMobile ?? detectedIsMobile;
|
|
11
|
-
const handleItemClick = (item, index, e) => {
|
|
12
|
-
// Don't make the last item (current page) clickable
|
|
13
|
-
if (index === items.length - 1)
|
|
14
|
-
return;
|
|
15
|
-
if (item.onClick) {
|
|
16
|
-
e.preventDefault();
|
|
17
|
-
item.onClick();
|
|
18
|
-
}
|
|
19
|
-
// If item has href, let the anchor tag handle navigation naturally
|
|
20
|
-
};
|
|
21
|
-
return (jsx("nav", { ref: ref, className: cn(
|
|
22
|
-
// Base layout - RTL with flex-row-reverse to show items right to left
|
|
23
|
-
'flex flex-row-reverse items-center',
|
|
24
|
-
// Responsive gap and padding based on mobile state
|
|
25
|
-
actualIsMobile ? 'gap-1 px-4 py-2.5' : 'gap-3 pr-1 pt-3 pb-4 pl-0', className), "aria-label": "Breadcrumb navigation", children: jsx("ol", { className: "flex flex-row-reverse items-center gap-inherit", children: items.map((item, index) => {
|
|
26
|
-
const isLast = index === items.length - 1;
|
|
27
|
-
const isClickable = !isLast && (item.href || item.onClick);
|
|
28
|
-
const itemKey = `${item.label}-${index}`;
|
|
29
|
-
return (jsxs("li", { className: "flex items-center gap-inherit", children: [isClickable ? (jsx("a", { href: item.href || '#', className: cn(
|
|
30
|
-
// Base styles
|
|
31
|
-
'whitespace-nowrap border-0 bg-transparent p-0 no-underline',
|
|
32
|
-
// Responsive font size based on mobile state
|
|
33
|
-
actualIsMobile ? 'text-t' : 'text-s',
|
|
34
|
-
// Color
|
|
35
|
-
'text-neutral-main',
|
|
36
|
-
// Cursor and hover effects for clickable items
|
|
37
|
-
'cursor-pointer hover:text-neutral-dark transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded-sm'), onClick: (e) => handleItemClick(item, index, e), onKeyDown: (e) => {
|
|
38
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
39
|
-
e.preventDefault();
|
|
40
|
-
if (item.onClick) {
|
|
41
|
-
item.onClick();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}, "aria-label": `Go to ${item.label}`, children: item.label })) : (jsx("span", { className: cn(
|
|
45
|
-
// Base styles
|
|
46
|
-
'whitespace-nowrap',
|
|
47
|
-
// Responsive font size based on mobile state
|
|
48
|
-
actualIsMobile ? 'text-t' : 'text-s',
|
|
49
|
-
// Color
|
|
50
|
-
'text-neutral-main',
|
|
51
|
-
// Different styles for current page (last item)
|
|
52
|
-
'font-medium'), "aria-current": isLast ? 'page' : undefined, "aria-label": isLast ? `Current page: ${item.label}` : undefined, children: item.label })), !isLast && (jsx(ChevronLeft, { className: cn('text-black flex-shrink-0',
|
|
53
|
-
// Responsive icon size
|
|
54
|
-
actualIsMobile ? 'w-2.5 h-2.5' : 'w-3 h-3'), "aria-hidden": "true" }))] }, itemKey));
|
|
55
|
-
}) }) }));
|
|
56
|
-
});
|
|
57
|
-
Breadcrumb.displayName = 'Breadcrumb';
|
|
58
|
-
|
|
59
|
-
export { Breadcrumb };
|
|
1
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import t from"react";import a from"./utils.js";import{useMobile as n}from"./contexts.js";import{C as l}from"./chunks/chevron-left-4HSuTes3.js";import"./chunks/createLucideIcon-DGp0SoUT.js";const i=t.forwardRef(({items:t,className:i,isMobile:o},s)=>{const c=n(),m=o??c;return e("nav",{ref:s,className:a("flex flex-row-reverse items-center",m?"gap-1 px-4 py-2.5":"gap-3 pr-1 pt-3 pb-4 pl-0",i),"aria-label":"Breadcrumb navigation",children:e("ol",{className:"flex flex-row-reverse items-center gap-inherit",children:t.map((n,i)=>{const o=i===t.length-1,s=!o&&(n.href||n.onClick),c=`${n.label}-${i}`;return r("li",{className:"flex items-center gap-inherit",children:[s?e("a",{href:n.href||"#",className:a("whitespace-nowrap border-0 bg-transparent p-0 no-underline",m?"text-t":"text-s","text-neutral-main","cursor-pointer hover:text-neutral-dark transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded-sm"),onClick:e=>((e,r,a)=>{r!==t.length-1&&e.onClick&&(a.preventDefault(),e.onClick())})(n,i,e),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n.onClick&&n.onClick())},"aria-label":`Go to ${n.label}`,children:n.label}):e("span",{className:a("whitespace-nowrap",m?"text-t":"text-s","text-neutral-main","font-medium"),"aria-current":o?"page":void 0,"aria-label":o?`Current page: ${n.label}`:void 0,children:n.label}),!o&&e(l,{className:a("text-black flex-shrink-0",m?"w-2.5 h-2.5":"w-3 h-3"),"aria-hidden":"true"})]},c)})})})});i.displayName="Breadcrumb";export{i as Breadcrumb};
|
package/dist/esm/Button.js
CHANGED
|
@@ -1,46 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import cn from './utils.js';
|
|
4
|
-
import { getTypographyClasses } from './Typography.js';
|
|
5
|
-
|
|
6
|
-
const sizeClasses = {
|
|
7
|
-
sm: 'px-[16px] py-[7px]',
|
|
8
|
-
md: 'px-[16px] py-[9px]',
|
|
9
|
-
lg: 'px-[16px] py-[13px]',
|
|
10
|
-
xl: 'px-[20px] py-[13px]',
|
|
11
|
-
};
|
|
12
|
-
const defaultTextVariants = {
|
|
13
|
-
sm: 'body-s-bold', // 14px / Bold (600)
|
|
14
|
-
md: 'body-m-bold', // 16px / Bold (600)
|
|
15
|
-
lg: 'body-l-bold', // 18px / Bold (600)
|
|
16
|
-
xl: 'body-xl-heavy', // 20px / Heavy (700)
|
|
17
|
-
};
|
|
18
|
-
const variantClasses = {
|
|
19
|
-
primary: `
|
|
20
|
-
bg-[var(--color-primary)] text-white
|
|
21
|
-
hover:bg-[var(--color-primary-dark)]
|
|
22
|
-
disabled:bg-[var(--color-neutral-light)] disabled:text-[var(--color-neutral-darker)]
|
|
23
|
-
`,
|
|
24
|
-
secondary: `
|
|
25
|
-
bg-[var(--color-primary-lightest)] text-[var(--color-primary)]
|
|
26
|
-
hover:bg-[var(--color-primary-lighter)]
|
|
27
|
-
disabled:bg-[var(--color-neutral-light)] disabled:text-[var(--color-neutral-darker)]
|
|
28
|
-
`,
|
|
29
|
-
tertiary: `
|
|
30
|
-
bg-white border border-[var(--color-primary-light)] text-[var(--color-primary)]
|
|
31
|
-
hover:bg-[var(--color-neutral-lighter)]
|
|
32
|
-
disabled:bg-[var(--color-neutral-light)] disabled:text-[var(--color-neutral-darker)]
|
|
33
|
-
`,
|
|
34
|
-
ghost: `
|
|
35
|
-
bg-transparent text-[var(--color-primary)]
|
|
36
|
-
hover:bg-[var(--color-primary-lightest)]
|
|
37
|
-
disabled:bg-[var(--color-neutral-light)] disabled:text-[var(--color-neutral-darker)]
|
|
38
|
-
`,
|
|
39
|
-
};
|
|
40
|
-
const Button = React.forwardRef(({ className, variant = 'primary', size = 'md', icon, iconPosition = 'right', children, loading = false, disabled, textVariant, ...props }, ref) => {
|
|
41
|
-
const finalTextVariant = textVariant || defaultTextVariants[size];
|
|
42
|
-
return (jsxs("button", { ref: ref, type: "button", className: cn('inline-flex items-center justify-center rounded-[8px] transition-colors duration-200', sizeClasses[size], variantClasses[variant], getTypographyClasses(finalTextVariant), disabled && 'opacity-50 pointer-events-none', className), disabled: disabled || loading, ...props, children: [icon && iconPosition === 'left' && (jsx("span", { className: "mr-2 flex items-center", children: icon })), loading ? '...' : children, icon && iconPosition === 'right' && (jsx("span", { className: "ml-2 flex items-center", children: icon }))] }));
|
|
43
|
-
});
|
|
44
|
-
Button.displayName = 'Button';
|
|
45
|
-
|
|
46
|
-
export { Button };
|
|
1
|
+
import{jsxs as r,jsx as e}from"react/jsx-runtime";import a from"react";import t from"./utils.js";import{getTypographyClasses as o}from"./Typography.js";const l={sm:"px-[16px] py-[7px]",md:"px-[16px] py-[9px]",lg:"px-[16px] py-[13px]",xl:"px-[20px] py-[13px]"},i={sm:"body-s-bold",md:"body-m-bold",lg:"body-l-bold",xl:"body-xl-heavy"},n={primary:"\n bg-[var(--color-primary)] text-white\n hover:bg-[var(--color-primary-dark)]\n disabled:bg-[var(--color-neutral-light)] disabled:text-[var(--color-neutral-darker)]\n ",secondary:"\n bg-[var(--color-primary-lightest)] text-[var(--color-primary)]\n hover:bg-[var(--color-primary-lighter)]\n disabled:bg-[var(--color-neutral-light)] disabled:text-[var(--color-neutral-darker)]\n ",tertiary:"\n bg-white border border-[var(--color-primary-light)] text-[var(--color-primary)]\n hover:bg-[var(--color-neutral-lighter)]\n disabled:bg-[var(--color-neutral-light)] disabled:text-[var(--color-neutral-darker)]\n ",ghost:"\n bg-transparent text-[var(--color-primary)]\n hover:bg-[var(--color-primary-lightest)]\n disabled:bg-[var(--color-neutral-light)] disabled:text-[var(--color-neutral-darker)]\n "},d=a.forwardRef(({className:a,variant:d="primary",size:s="md",icon:p,iconPosition:c="right",children:m,loading:b=!1,disabled:x,textVariant:g,...y},v)=>r("button",{ref:v,type:"button",className:t("inline-flex items-center justify-center rounded-[8px] transition-colors duration-200",l[s],n[d],o(g||i[s]),x&&"opacity-50 pointer-events-none",a),disabled:x||b,...y,children:[p&&"left"===c&&e("span",{className:"mr-2 flex items-center",children:p}),b?"...":m,p&&"right"===c&&e("span",{className:"ml-2 flex items-center",children:p})]}));d.displayName="Button";export{d as Button};
|
package/dist/esm/Chips.js
CHANGED
|
@@ -1,112 +1 @@
|
|
|
1
|
-
import
|
|
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-[var(--color-primary-lightest)]',
|
|
24
|
-
text: 'text-[var(--color-primary-darkest)]',
|
|
25
|
-
border: 'border-[var(--color-primary-light)]',
|
|
26
|
-
},
|
|
27
|
-
red: {
|
|
28
|
-
background: 'bg-[var(--color-error-light)]',
|
|
29
|
-
text: 'text-[var(--color-error)]',
|
|
30
|
-
border: 'border-[#f0d6d6]',
|
|
31
|
-
},
|
|
32
|
-
green: {
|
|
33
|
-
background: 'bg-[var(--color-success-light)]',
|
|
34
|
-
text: 'text-[var(--color-success)]',
|
|
35
|
-
border: 'border-[#d4e8dc]',
|
|
36
|
-
},
|
|
37
|
-
orange: {
|
|
38
|
-
background: 'bg-[var(--color-warning-light)]',
|
|
39
|
-
text: 'text-[var(--color-warning)]',
|
|
40
|
-
border: 'border-[#f5e1d1]',
|
|
41
|
-
},
|
|
42
|
-
blue: {
|
|
43
|
-
background: 'bg-[var(--color-info-light)]',
|
|
44
|
-
text: 'text-[var(--color-info)]',
|
|
45
|
-
border: 'border-[#d3e9f2]',
|
|
46
|
-
},
|
|
47
|
-
white: {
|
|
48
|
-
background: 'bg-[var(--color-white)]',
|
|
49
|
-
text: 'text-[var(--color-neutral-darker)]',
|
|
50
|
-
border: 'border-[var(--color-neutral-light)]',
|
|
51
|
-
},
|
|
52
|
-
disabled: {
|
|
53
|
-
background: 'bg-[var(--color-neutral-lighter)]',
|
|
54
|
-
text: 'text-[var(--color-neutral-main)]',
|
|
55
|
-
border: 'border-[var(--color-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-[12px]',
|
|
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-[14px]',
|
|
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{jsxs as r,jsx as e}from"react/jsx-runtime";import o from"react";import t from"./utils.js";import{useMobile as a}from"./contexts.js";import{c as i}from"./chunks/createLucideIcon-DGp0SoUT.js";const n=i("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),l={purple:{background:"bg-[var(--color-primary-lightest)]",text:"text-[var(--color-primary-darkest)]",border:"border-[var(--color-primary-light)]"},red:{background:"bg-[var(--color-error-light)]",text:"text-[var(--color-error)]",border:"border-[#f0d6d6]"},green:{background:"bg-[var(--color-success-light)]",text:"text-[var(--color-success)]",border:"border-[#d4e8dc]"},orange:{background:"bg-[var(--color-warning-light)]",text:"text-[var(--color-warning)]",border:"border-[#f5e1d1]"},blue:{background:"bg-[var(--color-info-light)]",text:"text-[var(--color-info)]",border:"border-[#d3e9f2]"},white:{background:"bg-[var(--color-white)]",text:"text-[var(--color-neutral-darker)]",border:"border-[var(--color-neutral-light)]"},disabled:{background:"bg-[var(--color-neutral-lighter)]",text:"text-[var(--color-neutral-main)]",border:"border-[var(--color-neutral-light)]"}},d={mobile:{padding:"px-2.5 py-1",gap:"gap-1",iconSize:"size-4",fontSize:"text-[12px]",lineHeight:"leading-[1.8]"},desktop:{padding:"px-3 py-1",gap:"gap-1.5",iconSize:"size-5",fontSize:"text-[14px]",lineHeight:"leading-[24px]"}},c=o.forwardRef(({variant:o="purple",size:i,children:c="متن پیشفرض",disabled:s=!1,onClick:b,onIconClick:p,className:g,isMobile:u,...x},v)=>{const f=a(),m=l[s?"disabled":o],h=d[i||(u??f?"mobile":"desktop")],handleIconClick=r=>{r.stopPropagation(),p&&p()};return r("div",{ref:v,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",m.background,m.text,m.border,h.padding,h.gap,h.fontSize,h.lineHeight,b&&!s&&"cursor-pointer hover:opacity-80",s&&"cursor-not-allowed opacity-60",g),onClick:s?void 0:b,onKeyDown:b&&!s?r=>{"Enter"!==r.key&&" "!==r.key||!b||s||(r.preventDefault(),b())}:void 0,tabIndex:b&&!s?0:void 0,role:b?"button":void 0,...x,children:[e("span",{className:"text-center",children:c}),(()=>{const r=e(n,{className:t(h.iconSize)});return p?e("button",{type:"button",onClick:handleIconClick,disabled:s,className:t("flex items-center justify-center","hover:opacity-70 transition-opacity",s&&"cursor-not-allowed opacity-50"),"aria-label":"حذف",children:r}):r})()]})});c.displayName="Chips";export{c as Chips,c as default};
|
package/dist/esm/Divider.js
CHANGED
|
@@ -1,21 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import cn from './utils.js';
|
|
4
|
-
|
|
5
|
-
const Divider = React.forwardRef(({ width = '100%', height = 1, orientation = 'horizontal', variant = 'neutral-light', className, style, ...props }, ref) => {
|
|
6
|
-
const isHorizontal = orientation === 'horizontal';
|
|
7
|
-
const variantClasses = {
|
|
8
|
-
'neutral-light': 'bg-neutral-light',
|
|
9
|
-
'neutral-main': 'bg-neutral-main',
|
|
10
|
-
primary: 'bg-primary',
|
|
11
|
-
};
|
|
12
|
-
const dividerStyle = {
|
|
13
|
-
width: isHorizontal ? width : height,
|
|
14
|
-
height: isHorizontal ? height : width,
|
|
15
|
-
...style,
|
|
16
|
-
};
|
|
17
|
-
return (jsx("div", { ref: ref, className: cn('shrink-0', variantClasses[variant], className), style: dividerStyle, role: "separator", ...props }));
|
|
18
|
-
});
|
|
19
|
-
Divider.displayName = 'Divider';
|
|
20
|
-
|
|
21
|
-
export { Divider };
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import t from"react";import i from"./utils.js";const a=t.forwardRef(({width:t="100%",height:a=1,orientation:e="horizontal",variant:o="neutral-light",className:l,style:n,...m},s)=>{const h="horizontal"===e,g={width:h?t:a,height:h?a:t,...n};return r("div",{ref:s,className:i("shrink-0",{"neutral-light":"bg-neutral-light","neutral-main":"bg-neutral-main",primary:"bg-primary"}[o],l),style:g,role:"separator",...m})});a.displayName="Divider";export{a as Divider};
|
package/dist/esm/Drawer.js
CHANGED
|
@@ -1,110 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { useRef, useEffect } from 'react';
|
|
3
|
-
import cn from './utils.js';
|
|
4
|
-
import { useMobile } from './contexts.js';
|
|
5
|
-
|
|
6
|
-
const Drawer = React.forwardRef(({ children, direction = 'bottom', fullScreen = false, isOpen = false, onClose, className, isMobile, ...props }, ref) => {
|
|
7
|
-
const detectedIsMobile = useMobile();
|
|
8
|
-
const actualIsMobile = isMobile ?? detectedIsMobile;
|
|
9
|
-
const overlayRef = useRef(null);
|
|
10
|
-
const drawerRef = useRef(null);
|
|
11
|
-
// Handle escape key
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
const handleEscape = (event) => {
|
|
14
|
-
if (event.key === 'Escape' && isOpen && onClose) {
|
|
15
|
-
onClose();
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
if (isOpen) {
|
|
19
|
-
document.addEventListener('keydown', handleEscape);
|
|
20
|
-
// Prevent body scroll when drawer is open
|
|
21
|
-
document.body.style.overflow = 'hidden';
|
|
22
|
-
}
|
|
23
|
-
return () => {
|
|
24
|
-
document.removeEventListener('keydown', handleEscape);
|
|
25
|
-
document.body.style.overflow = 'auto';
|
|
26
|
-
};
|
|
27
|
-
}, [isOpen, onClose]);
|
|
28
|
-
// Handle click outside
|
|
29
|
-
const handleOverlayClick = (event) => {
|
|
30
|
-
if (!fullScreen &&
|
|
31
|
-
onClose &&
|
|
32
|
-
overlayRef.current &&
|
|
33
|
-
event.target === overlayRef.current) {
|
|
34
|
-
onClose();
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
// Handle keyboard events on overlay
|
|
38
|
-
const handleOverlayKeyDown = (event) => {
|
|
39
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
40
|
-
if (!fullScreen &&
|
|
41
|
-
onClose &&
|
|
42
|
-
overlayRef.current &&
|
|
43
|
-
event.target === overlayRef.current) {
|
|
44
|
-
onClose();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const getTranslateClasses = () => {
|
|
49
|
-
if (!isOpen) {
|
|
50
|
-
switch (direction) {
|
|
51
|
-
case 'top':
|
|
52
|
-
return '-translate-y-full';
|
|
53
|
-
case 'bottom':
|
|
54
|
-
return 'translate-y-full';
|
|
55
|
-
case 'left':
|
|
56
|
-
return '-translate-x-full';
|
|
57
|
-
case 'right':
|
|
58
|
-
return 'translate-x-full';
|
|
59
|
-
default:
|
|
60
|
-
return 'translate-y-full';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return 'translate-x-0 translate-y-0';
|
|
64
|
-
};
|
|
65
|
-
const getPositionClasses = () => {
|
|
66
|
-
switch (direction) {
|
|
67
|
-
case 'top':
|
|
68
|
-
return 'top-0 left-0 right-0';
|
|
69
|
-
case 'bottom':
|
|
70
|
-
return 'bottom-0 left-0 right-0';
|
|
71
|
-
case 'left':
|
|
72
|
-
return 'top-0 left-0 bottom-0';
|
|
73
|
-
case 'right':
|
|
74
|
-
return 'top-0 right-0 bottom-0';
|
|
75
|
-
default:
|
|
76
|
-
return 'bottom-0 left-0 right-0';
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const getSizeClasses = () => {
|
|
80
|
-
const isVertical = direction === 'top' || direction === 'bottom';
|
|
81
|
-
if (fullScreen) {
|
|
82
|
-
return isVertical ? 'w-full h-full' : 'w-full h-full';
|
|
83
|
-
}
|
|
84
|
-
if (isVertical) {
|
|
85
|
-
return 'w-full max-h-[90vh]';
|
|
86
|
-
}
|
|
87
|
-
return 'h-full max-w-[90vw]';
|
|
88
|
-
};
|
|
89
|
-
const baseOverlayClasses = 'fixed inset-0 z-50 transition-all duration-300';
|
|
90
|
-
const baseDrawerClasses = 'fixed bg-white shadow-2xl transition-all duration-300 ease-out overflow-auto';
|
|
91
|
-
const overlayClasses = cn(baseOverlayClasses, {
|
|
92
|
-
'bg-neutral-darker/50 backdrop-blur-sm': isOpen,
|
|
93
|
-
'bg-transparent pointer-events-none': !isOpen,
|
|
94
|
-
});
|
|
95
|
-
const drawerClasses = cn(baseDrawerClasses, getPositionClasses(), getSizeClasses(), getTranslateClasses(), {
|
|
96
|
-
'rounded-t-2xl': direction === 'bottom' && !fullScreen,
|
|
97
|
-
'rounded-b-2xl': direction === 'top' && !fullScreen,
|
|
98
|
-
'rounded-r-2xl': direction === 'left' && !fullScreen,
|
|
99
|
-
'rounded-l-2xl': direction === 'right' && !fullScreen,
|
|
100
|
-
'p-6': !actualIsMobile,
|
|
101
|
-
'p-4': actualIsMobile,
|
|
102
|
-
}, className);
|
|
103
|
-
if (!isOpen) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
return (jsx("div", { ref: overlayRef, className: overlayClasses, onClick: handleOverlayClick, onKeyDown: handleOverlayKeyDown, tabIndex: -1, role: "button", "aria-label": "Close drawer", children: jsx("div", { ref: ref || drawerRef, className: drawerClasses, role: "dialog", "aria-modal": "true", "aria-label": "Drawer", ...props, children: children }) }));
|
|
107
|
-
});
|
|
108
|
-
Drawer.displayName = 'Drawer';
|
|
109
|
-
|
|
110
|
-
export { Drawer };
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import e,{useRef as r,useEffect as o}from"react";import l from"./utils.js";import{useMobile as n}from"./contexts.js";const a=e.forwardRef(({children:e,direction:a="bottom",fullScreen:s=!1,isOpen:u=!1,onClose:i,className:d,isMobile:c,...f},m)=>{const b=n(),p=c??b,h=r(null),w=r(null);o(()=>{const handleEscape=t=>{"Escape"===t.key&&u&&i&&i()};return u&&(document.addEventListener("keydown",handleEscape),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",handleEscape),document.body.style.overflow="auto"}},[u,i]);const x=l("fixed inset-0 z-50 transition-all duration-300",{"bg-neutral-darker/50 backdrop-blur-sm":u,"bg-transparent pointer-events-none":!u}),y=l("fixed bg-white shadow-2xl transition-all duration-300 ease-out overflow-auto",(()=>{switch(a){case"top":return"top-0 left-0 right-0";case"bottom":default:return"bottom-0 left-0 right-0";case"left":return"top-0 left-0 bottom-0";case"right":return"top-0 right-0 bottom-0"}})(),(()=>{const t="top"===a||"bottom"===a;return s?"w-full h-full":t?"w-full max-h-[90vh]":"h-full max-w-[90vw]"})(),(()=>{if(!u)switch(a){case"top":return"-translate-y-full";case"bottom":default:return"translate-y-full";case"left":return"-translate-x-full";case"right":return"translate-x-full"}return"translate-x-0 translate-y-0"})(),{"rounded-t-2xl":"bottom"===a&&!s,"rounded-b-2xl":"top"===a&&!s,"rounded-r-2xl":"left"===a&&!s,"rounded-l-2xl":"right"===a&&!s,"p-6":!p,"p-4":p},d);return u?t("div",{ref:h,className:x,onClick:t=>{!s&&i&&h.current&&t.target===h.current&&i()},onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||!s&&i&&h.current&&t.target===h.current&&i()},tabIndex:-1,role:"button","aria-label":"Close drawer",children:t("div",{ref:m||w,className:y,role:"dialog","aria-modal":"true","aria-label":"Drawer",...f,children:e})}):null});a.displayName="Drawer";export{a as Drawer};
|
package/dist/esm/Input.js
CHANGED
|
@@ -1,82 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { useState, useId } from 'react';
|
|
3
|
-
import cn from './utils.js';
|
|
4
|
-
import { useMobile } from './contexts.js';
|
|
5
|
-
|
|
6
|
-
const Input = React.forwardRef(({ state = 'default', label, value, onChange, helperText, startIcon, endIcon, type = 'text', isMobile, ...props }, ref) => {
|
|
7
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
8
|
-
const id = useId();
|
|
9
|
-
const detectedIsMobile = useMobile();
|
|
10
|
-
const actualIsMobile = isMobile ?? detectedIsMobile;
|
|
11
|
-
const hasContent = value !== '' && value !== null && value !== undefined;
|
|
12
|
-
const isLabelFloated = isFocused || hasContent;
|
|
13
|
-
const isDisabled = state === 'disabled';
|
|
14
|
-
const handleFocus = (e) => {
|
|
15
|
-
if (!isDisabled) {
|
|
16
|
-
setIsFocused(true);
|
|
17
|
-
props.onFocus?.(e);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
const handleBlur = (e) => {
|
|
21
|
-
if (!isDisabled) {
|
|
22
|
-
setIsFocused(false);
|
|
23
|
-
props.onBlur?.(e);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const baseContainerClasses = 'relative flex items-center border rounded-lg transition-all duration-300 w-[360px]';
|
|
27
|
-
const baseLabelClasses = 'absolute pointer-events-none transition-all duration-300';
|
|
28
|
-
const baseInputClasses = 'peer w-full h-full bg-transparent outline-none text-m font-medium disabled:text-neutral-light';
|
|
29
|
-
const baseIconClasses = 'absolute h-5 w-5 transition-colors duration-300';
|
|
30
|
-
const containerClasses = cn(baseContainerClasses, {
|
|
31
|
-
'h-[54px]': !actualIsMobile,
|
|
32
|
-
'h-12': actualIsMobile,
|
|
33
|
-
'border-neutral-light': state === 'default' && !isFocused,
|
|
34
|
-
'border-primary': state === 'default' && isFocused,
|
|
35
|
-
'border-error': state === 'error',
|
|
36
|
-
'bg-white border-neutral-light cursor-not-allowed': isDisabled,
|
|
37
|
-
});
|
|
38
|
-
const labelClasses = cn(baseLabelClasses, {
|
|
39
|
-
'top-[-10px] bg-white px-1 mx-3 font-medium': isLabelFloated,
|
|
40
|
-
'text-s': (!actualIsMobile && isLabelFloated) ||
|
|
41
|
-
(actualIsMobile && !isLabelFloated),
|
|
42
|
-
'text-xs': actualIsMobile && isLabelFloated,
|
|
43
|
-
'text-m': !actualIsMobile && !isLabelFloated,
|
|
44
|
-
'right-1': startIcon,
|
|
45
|
-
'right-3': !startIcon,
|
|
46
|
-
'top-1/2 -translate-y-1/2 text-m font-medium': !isLabelFloated,
|
|
47
|
-
'right-11': !isLabelFloated && startIcon,
|
|
48
|
-
'right-4': !isLabelFloated && !startIcon,
|
|
49
|
-
'text-neutral-main': !isFocused && state === 'default',
|
|
50
|
-
'text-neutral-light': isDisabled,
|
|
51
|
-
'text-primary': isFocused && state === 'default',
|
|
52
|
-
'text-error': isLabelFloated && state === 'error',
|
|
53
|
-
});
|
|
54
|
-
const inputClasses = cn(baseInputClasses, {
|
|
55
|
-
'pr-12': startIcon,
|
|
56
|
-
'pl-12': endIcon,
|
|
57
|
-
'px-4': !startIcon && !endIcon,
|
|
58
|
-
'pr-4 pl-12': !startIcon && endIcon,
|
|
59
|
-
'pl-4 pr-12': startIcon && !endIcon,
|
|
60
|
-
'cursor-not-allowed text-red-500': isDisabled,
|
|
61
|
-
'text-neutral-dark': !isFocused,
|
|
62
|
-
'text-neutral-darker': isFocused,
|
|
63
|
-
});
|
|
64
|
-
const iconClasses = cn(baseIconClasses, {
|
|
65
|
-
'text-neutral-main': state !== 'error' && !isFocused,
|
|
66
|
-
'text-primary': state === 'default' && isFocused,
|
|
67
|
-
'text-error': state === 'error',
|
|
68
|
-
'text-neutral-light': isDisabled,
|
|
69
|
-
});
|
|
70
|
-
const helperTextClasses = cn('font-light mt-1 px-2 h-4', {
|
|
71
|
-
'text-s': !actualIsMobile,
|
|
72
|
-
'text-xs': actualIsMobile,
|
|
73
|
-
'text-neutral-main': state === 'default',
|
|
74
|
-
'text-primary': state === 'default' && isFocused,
|
|
75
|
-
'text-error': state === 'error',
|
|
76
|
-
'text-neutral-light': isDisabled,
|
|
77
|
-
});
|
|
78
|
-
return (jsxs("div", { children: [jsxs("div", { className: containerClasses, children: [endIcon && (jsx("span", { className: cn(iconClasses, 'left-4'), children: endIcon })), jsx("label", { htmlFor: id, className: labelClasses, children: label }), jsx("input", { ref: ref, id: id, type: type, value: value, onChange: onChange, onFocus: handleFocus, onBlur: handleBlur, disabled: isDisabled, className: inputClasses, ...props }), startIcon && (jsx("span", { className: cn(iconClasses, 'right-4'), children: startIcon }))] }), helperText && jsx("p", { className: helperTextClasses, children: helperText })] }));
|
|
79
|
-
});
|
|
80
|
-
Input.displayName = 'Input';
|
|
81
|
-
|
|
82
|
-
export { Input };
|
|
1
|
+
"use client";import{jsxs as t,jsx as e}from"react/jsx-runtime";import r,{useState as l,useId as a}from"react";import n from"./utils.js";import{useMobile as o}from"./contexts.js";const i=r.forwardRef(({state:r="default",label:i,value:s,onChange:u,helperText:d,startIcon:x,endIcon:m,type:p="text",isMobile:h,...c},f)=>{const[g,b]=l(!1),w=a(),y=o(),N=h??y,v=g||""!==s&&null!=s,j="disabled"===r,F=n("relative flex items-center border rounded-lg transition-all duration-300 w-[360px]",{"h-[54px]":!N,"h-12":N,"border-neutral-light":"default"===r&&!g,"border-primary":"default"===r&&g,"border-error":"error"===r,"bg-white border-neutral-light cursor-not-allowed":j}),I=n("absolute pointer-events-none transition-all duration-300",{"top-[-10px] bg-white px-1 mx-3 font-medium":v,"text-s":!N&&v||N&&!v,"text-xs":N&&v,"text-m":!N&&!v,"right-1":x,"right-3":!x,"top-1/2 -translate-y-1/2 text-m font-medium":!v,"right-11":!v&&x,"right-4":!v&&!x,"text-neutral-main":!g&&"default"===r,"text-neutral-light":j,"text-primary":g&&"default"===r,"text-error":v&&"error"===r}),k=n("peer w-full h-full bg-transparent outline-none text-m font-medium disabled:text-neutral-light",{"pr-12":x,"pl-12":m,"px-4":!x&&!m,"pr-4 pl-12":!x&&m,"pl-4 pr-12":x&&!m,"cursor-not-allowed text-red-500":j,"text-neutral-dark":!g,"text-neutral-darker":g}),B=n("absolute h-5 w-5 transition-colors duration-300",{"text-neutral-main":"error"!==r&&!g,"text-primary":"default"===r&&g,"text-error":"error"===r,"text-neutral-light":j}),C=n("font-light mt-1 px-2 h-4",{"text-s":!N,"text-xs":N,"text-neutral-main":"default"===r,"text-primary":"default"===r&&g,"text-error":"error"===r,"text-neutral-light":j});return t("div",{children:[t("div",{className:F,children:[m&&e("span",{className:n(B,"left-4"),children:m}),e("label",{htmlFor:w,className:I,children:i}),e("input",{ref:f,id:w,type:p,value:s,onChange:u,onFocus:t=>{j||(b(!0),c.onFocus?.(t))},onBlur:t=>{j||(b(!1),c.onBlur?.(t))},disabled:j,className:k,...c}),x&&e("span",{className:n(B,"right-4"),children:x})]}),d&&e("p",{className:C,children:d})]})});i.displayName="Input";export{i as Input};
|