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