shared-design-system 1.11.0 → 1.13.0
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/src/components/Alert.d.ts +2 -1
- package/dist/src/components/Alert.js +80 -38
- package/dist/src/components/Alert.js.map +1 -1
- package/dist/src/components/Avatar.d.ts +11 -1
- package/dist/src/components/Avatar.js +96 -31
- package/dist/src/components/Avatar.js.map +1 -1
- package/dist/src/components/Badge.d.ts +5 -2
- package/dist/src/components/Badge.js +94 -30
- package/dist/src/components/Badge.js.map +1 -1
- package/dist/src/components/Breadcrumbs.d.ts +4 -1
- package/dist/src/components/Breadcrumbs.js +56 -27
- package/dist/src/components/Breadcrumbs.js.map +1 -1
- package/dist/src/components/Button.d.ts +4 -2
- package/dist/src/components/Button.js +99 -95
- package/dist/src/components/Button.js.map +1 -1
- package/dist/src/components/Card.d.ts +6 -1
- package/dist/src/components/Card.js +109 -21
- package/dist/src/components/Card.js.map +1 -1
- package/dist/src/components/ConfirmModal.d.ts +5 -2
- package/dist/src/components/ConfirmModal.js +99 -47
- package/dist/src/components/ConfirmModal.js.map +1 -1
- package/dist/src/components/DatePicker.js +55 -8
- package/dist/src/components/DatePicker.js.map +1 -1
- package/dist/src/components/Divider.d.ts +5 -1
- package/dist/src/components/Divider.js +53 -18
- package/dist/src/components/Divider.js.map +1 -1
- package/dist/src/components/InputComponents.d.ts +2 -4
- package/dist/src/components/InputComponents.js +89 -132
- package/dist/src/components/InputComponents.js.map +1 -1
- package/dist/src/components/ListComponents.d.ts +7 -4
- package/dist/src/components/ListComponents.js +70 -35
- package/dist/src/components/ListComponents.js.map +1 -1
- package/dist/src/components/LoadingSpinner.d.ts +9 -2
- package/dist/src/components/LoadingSpinner.js +59 -17
- package/dist/src/components/LoadingSpinner.js.map +1 -1
- package/dist/src/components/MultiSelect.d.ts +14 -0
- package/dist/src/components/MultiSelect.js +142 -0
- package/dist/src/components/MultiSelect.js.map +1 -0
- package/dist/src/components/Progress.d.ts +5 -1
- package/dist/src/components/Progress.js +58 -26
- package/dist/src/components/Progress.js.map +1 -1
- package/dist/src/components/Radio.d.ts +4 -0
- package/dist/src/components/Radio.js +50 -24
- package/dist/src/components/Radio.js.map +1 -1
- package/dist/src/components/ReadOnlyField.d.ts +6 -1
- package/dist/src/components/ReadOnlyField.js +78 -18
- package/dist/src/components/ReadOnlyField.js.map +1 -1
- package/dist/src/components/Select.d.ts +19 -0
- package/dist/src/components/Select.js +110 -0
- package/dist/src/components/Select.js.map +1 -0
- package/dist/src/components/Skeleton.d.ts +3 -1
- package/dist/src/components/Skeleton.js +52 -22
- package/dist/src/components/Skeleton.js.map +1 -1
- package/dist/src/components/Stack.d.ts +4 -0
- package/dist/src/components/Stack.js +32 -18
- package/dist/src/components/Stack.js.map +1 -1
- package/dist/src/components/Steps.d.ts +3 -1
- package/dist/src/components/Steps.js +93 -68
- package/dist/src/components/Steps.js.map +1 -1
- package/dist/src/components/Switch.d.ts +6 -2
- package/dist/src/components/Switch.js +45 -22
- package/dist/src/components/Switch.js.map +1 -1
- package/dist/src/components/Table.d.ts +9 -1
- package/dist/src/components/Table.js +102 -37
- package/dist/src/components/Table.js.map +1 -1
- package/dist/src/components/Tabs.d.ts +9 -5
- package/dist/src/components/Tabs.js +88 -88
- package/dist/src/components/Tabs.js.map +1 -1
- package/dist/src/components/Tag.d.ts +5 -2
- package/dist/src/components/Tag.js +106 -28
- package/dist/src/components/Tag.js.map +1 -1
- package/dist/src/components/Tooltip.d.ts +3 -0
- package/dist/src/components/Tooltip.js +89 -38
- package/dist/src/components/Tooltip.js.map +1 -1
- package/dist/src/components/Typography.d.ts +15 -2
- package/dist/src/components/Typography.js +108 -53
- package/dist/src/components/Typography.js.map +1 -1
- package/dist/src/index.d.ts +12 -8
- package/dist/src/index.js +6 -4
- package/dist/src/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,94 +1,94 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { tokens } from '../tokens';
|
|
4
|
-
export const Tabs = ({ value, onChange, items, children, variant = 'standard', columns = 4, className = '', style = {} }) => {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return (_jsx("div", { style: containerStyle, className: className, children: items ? items.map((item, index) => (_jsx(Tab, { label: item.label, value: item.value, icon: item.icon, active: item.value === value, onClick: () => onChange(item.value), variant: variant }, index))) : React.Children.map(children, child => {
|
|
16
|
-
if (!React.isValidElement(child))
|
|
17
|
-
return null;
|
|
18
|
-
return React.cloneElement(child, {
|
|
19
|
-
active: child.props.value === value,
|
|
20
|
-
onClick: () => onChange(child.props.value),
|
|
21
|
-
variant
|
|
22
|
-
});
|
|
23
|
-
}) }));
|
|
24
|
-
};
|
|
25
|
-
export const Tab = ({ label, value, icon, active, onClick, variant, className = '', style = {} }) => {
|
|
26
|
-
const getTabStyle = () => {
|
|
27
|
-
switch (variant) {
|
|
28
|
-
case 'dashboard':
|
|
29
|
-
return {
|
|
30
|
-
position: 'relative',
|
|
31
|
-
cursor: 'pointer',
|
|
32
|
-
backgroundColor: tokens.color.white,
|
|
33
|
-
borderRadius: tokens.radius.xl,
|
|
34
|
-
padding: tokens.spacing[5],
|
|
35
|
-
boxShadow: active ? tokens.shadow.md : tokens.shadow.sm,
|
|
36
|
-
borderTop: `2px solid ${active ? tokens.color.danger : 'transparent'}`,
|
|
37
|
-
transition: tokens.transition.normal,
|
|
38
|
-
display: 'flex',
|
|
39
|
-
alignItems: 'center',
|
|
40
|
-
gap: tokens.spacing[3],
|
|
41
|
-
flex: 1,
|
|
42
|
-
borderBottom: 'none',
|
|
43
|
-
...style
|
|
44
|
-
};
|
|
45
|
-
case 'pills':
|
|
46
|
-
return {
|
|
47
|
-
display: 'flex',
|
|
48
|
-
alignItems: 'center',
|
|
49
|
-
gap: tokens.spacing[2],
|
|
50
|
-
padding: `${tokens.spacing[3]} ${tokens.spacing[4]}`,
|
|
51
|
-
fontSize: tokens.font.sm,
|
|
52
|
-
fontWeight: active ? tokens.font.weightBold : tokens.font.weightMedium,
|
|
53
|
-
color: active ? tokens.color.primary : tokens.color.textMuted,
|
|
54
|
-
cursor: 'pointer',
|
|
55
|
-
transition: tokens.transition.fast,
|
|
56
|
-
backgroundColor: active ? tokens.color.primaryLight : 'transparent',
|
|
57
|
-
borderRadius: tokens.radius.md,
|
|
58
|
-
whiteSpace: 'nowrap',
|
|
59
|
-
...style
|
|
60
|
-
};
|
|
61
|
-
case 'standard':
|
|
62
|
-
default:
|
|
63
|
-
return {
|
|
64
|
-
display: 'flex',
|
|
65
|
-
alignItems: 'center',
|
|
66
|
-
gap: tokens.spacing[2],
|
|
67
|
-
padding: `${tokens.spacing[3]} ${tokens.spacing[4]}`,
|
|
68
|
-
fontSize: tokens.font.sm,
|
|
69
|
-
fontWeight: active ? tokens.font.weightBold : tokens.font.weightMedium,
|
|
70
|
-
color: active ? tokens.color.primary : tokens.color.textMuted,
|
|
71
|
-
cursor: 'pointer',
|
|
72
|
-
borderBottom: `2px solid ${active ? tokens.color.primary : 'transparent'}`,
|
|
73
|
-
transition: tokens.transition.fast,
|
|
74
|
-
whiteSpace: 'nowrap',
|
|
75
|
-
...style
|
|
76
|
-
};
|
|
4
|
+
export const Tabs = ({ value, onChange, items, children, variant = 'standard', columns = 4, className = '', style = {}, }) => {
|
|
5
|
+
const isPills = variant === 'pills';
|
|
6
|
+
const isDashboard = variant === 'dashboard';
|
|
7
|
+
const isUnderline = variant === 'underline' || variant === 'standard';
|
|
8
|
+
const containerStyle = isDashboard
|
|
9
|
+
? {
|
|
10
|
+
display: 'grid',
|
|
11
|
+
gridTemplateColumns: `repeat(${columns}, 1fr)`,
|
|
12
|
+
gap: tokens.spacing[4],
|
|
13
|
+
width: '100%',
|
|
14
|
+
...style,
|
|
77
15
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
16
|
+
: {
|
|
17
|
+
display: 'flex',
|
|
18
|
+
gap: isPills ? tokens.spacing[1] : tokens.spacing[2],
|
|
19
|
+
borderBottom: isUnderline ? `1.5px solid ${tokens.color.slate100}` : 'none',
|
|
20
|
+
width: '100%',
|
|
21
|
+
overflowX: 'auto',
|
|
22
|
+
padding: isPills ? tokens.spacing[1] : '0',
|
|
23
|
+
backgroundColor: isPills ? tokens.color.slate50 : 'transparent',
|
|
24
|
+
borderRadius: isPills ? tokens.radius.xl : 'none',
|
|
25
|
+
...style,
|
|
26
|
+
};
|
|
27
|
+
return (_jsx("div", { style: containerStyle, className: `ds-tabs ds-tabs--${variant} ${className}`, role: "tablist", children: items
|
|
28
|
+
? items.map((item, index) => (_jsx(Tab, { label: item.label, value: item.value, icon: item.icon, badge: item.badge, disabled: item.disabled, active: item.value === value, onClick: () => !item.disabled && onChange(item.value), variant: variant }, index)))
|
|
29
|
+
: React.Children.map(children, (child) => {
|
|
30
|
+
if (!React.isValidElement(child))
|
|
31
|
+
return null;
|
|
32
|
+
return React.cloneElement(child, {
|
|
33
|
+
active: child.props.value === value,
|
|
34
|
+
onClick: () => !child.props.disabled && onChange(child.props.value),
|
|
35
|
+
variant,
|
|
36
|
+
});
|
|
37
|
+
}) }));
|
|
38
|
+
};
|
|
39
|
+
export const Tab = ({ label, value, icon, badge, active, disabled = false, onClick, variant, className = '', style = {}, }) => {
|
|
40
|
+
const isPills = variant === 'pills';
|
|
41
|
+
const isDashboard = variant === 'dashboard';
|
|
42
|
+
if (isDashboard) {
|
|
43
|
+
return (_jsxs("div", { role: "tab", "aria-selected": active, style: {
|
|
44
|
+
position: 'relative',
|
|
45
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
46
|
+
backgroundColor: tokens.color.white,
|
|
47
|
+
borderRadius: tokens.radius.xl,
|
|
48
|
+
padding: tokens.spacing[5],
|
|
49
|
+
boxShadow: active ? tokens.shadow.md : tokens.shadow.sm,
|
|
50
|
+
borderTop: `3px solid ${active ? tokens.color.primary : 'transparent'}`,
|
|
51
|
+
transition: tokens.transition.normal,
|
|
52
|
+
display: 'flex',
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
gap: tokens.spacing[3],
|
|
55
|
+
opacity: disabled ? 0.5 : 1,
|
|
56
|
+
...style,
|
|
57
|
+
}, onClick: disabled ? undefined : onClick, className: className, children: [icon && (_jsx("span", { style: {
|
|
58
|
+
display: 'flex',
|
|
59
|
+
padding: tokens.spacing[2],
|
|
60
|
+
borderRadius: tokens.radius.md,
|
|
61
|
+
color: active ? tokens.color.primary : tokens.color.slate400,
|
|
62
|
+
backgroundColor: active ? tokens.color.primaryLight : tokens.color.slate50,
|
|
63
|
+
transition: tokens.transition.fast,
|
|
64
|
+
}, children: icon })), _jsx("span", { style: {
|
|
65
|
+
fontSize: tokens.font.sm,
|
|
66
|
+
fontWeight: active ? tokens.font.weightBold : tokens.font.weightSemibold,
|
|
67
|
+
color: active ? tokens.color.slate800 : tokens.color.slate500,
|
|
68
|
+
transition: tokens.transition.fast,
|
|
69
|
+
}, children: label }), badge && _jsx("span", { style: { marginLeft: 'auto' }, children: badge })] }));
|
|
70
|
+
}
|
|
71
|
+
// Pills & Standard/Underline
|
|
72
|
+
return (_jsxs("div", { role: "tab", "aria-selected": active, style: {
|
|
73
|
+
display: 'inline-flex',
|
|
74
|
+
alignItems: 'center',
|
|
75
|
+
gap: tokens.spacing[2],
|
|
76
|
+
padding: isPills
|
|
77
|
+
? `${tokens.spacing[2]} ${tokens.spacing[4]}`
|
|
78
|
+
: `${tokens.spacing[3]} ${tokens.spacing[4]}`,
|
|
79
|
+
fontSize: tokens.font.sm,
|
|
80
|
+
fontWeight: active ? tokens.font.weightBold : tokens.font.weightMedium,
|
|
81
|
+
color: active ? tokens.color.primary : tokens.color.textMuted,
|
|
82
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
83
|
+
borderRadius: isPills ? tokens.radius.lg : '0',
|
|
84
|
+
borderBottom: !isPills ? `2px solid ${active ? tokens.color.primary : 'transparent'}` : 'none',
|
|
85
|
+
backgroundColor: isPills && active ? tokens.color.surface : 'transparent',
|
|
86
|
+
boxShadow: isPills && active ? tokens.shadow.sm : 'none',
|
|
87
|
+
transition: tokens.transition.fast,
|
|
88
|
+
whiteSpace: 'nowrap',
|
|
89
|
+
opacity: disabled ? 0.45 : 1,
|
|
90
|
+
userSelect: 'none',
|
|
91
|
+
...style,
|
|
92
|
+
}, onClick: disabled ? undefined : onClick, className: className, children: [icon && _jsx("span", { style: { display: 'inline-flex', alignItems: 'center' }, children: icon }), label, badge && _jsx("span", { style: { marginLeft: '2px' }, children: badge })] }));
|
|
93
93
|
};
|
|
94
94
|
//# sourceMappingURL=Tabs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../src/components/Tabs.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../src/components/Tabs.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AA6BnC,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,EACxC,KAAK,EACL,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,OAAO,GAAG,UAAU,EACpB,OAAO,GAAG,CAAC,EACX,SAAS,GAAG,EAAE,EACd,KAAK,GAAG,EAAE,GACX,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,OAAO,K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ACJ,CAAC,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface TagProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
3
|
-
color?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'slate';
|
|
4
|
-
variant?: '
|
|
3
|
+
color?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'slate' | 'premium' | 'gold';
|
|
4
|
+
variant?: 'subtle' | 'solid' | 'outline' | 'gradient';
|
|
5
|
+
size?: 'sm' | 'md';
|
|
5
6
|
onClose?: () => void;
|
|
7
|
+
icon?: React.ReactNode;
|
|
8
|
+
clickable?: boolean;
|
|
6
9
|
}
|
|
7
10
|
export declare const Tag: React.FC<TagProps>;
|
|
@@ -1,43 +1,121 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { tokens } from '../tokens';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
const COLOR_SCHEMES = {
|
|
4
|
+
primary: {
|
|
5
|
+
bg: tokens.color.primary,
|
|
6
|
+
text: '#fff',
|
|
7
|
+
lightBg: tokens.color.primaryLight,
|
|
8
|
+
lightText: tokens.color.primary,
|
|
9
|
+
border: 'rgba(37, 99, 235, 0.2)',
|
|
10
|
+
},
|
|
11
|
+
success: {
|
|
12
|
+
bg: tokens.color.success,
|
|
13
|
+
text: '#fff',
|
|
14
|
+
lightBg: tokens.color.successBg,
|
|
15
|
+
lightText: tokens.color.success,
|
|
16
|
+
border: 'rgba(5, 150, 105, 0.2)',
|
|
17
|
+
},
|
|
18
|
+
warning: {
|
|
19
|
+
bg: tokens.color.warning,
|
|
20
|
+
text: '#fff',
|
|
21
|
+
lightBg: tokens.color.warningBg,
|
|
22
|
+
lightText: '#b45309',
|
|
23
|
+
border: 'rgba(245, 158, 11, 0.2)',
|
|
24
|
+
},
|
|
25
|
+
danger: {
|
|
26
|
+
bg: tokens.color.danger,
|
|
27
|
+
text: '#fff',
|
|
28
|
+
lightBg: tokens.color.dangerBg,
|
|
29
|
+
lightText: tokens.color.danger,
|
|
30
|
+
border: 'rgba(220, 38, 38, 0.2)',
|
|
31
|
+
},
|
|
32
|
+
info: {
|
|
33
|
+
bg: tokens.color.info,
|
|
34
|
+
text: '#fff',
|
|
35
|
+
lightBg: tokens.color.infoBg,
|
|
36
|
+
lightText: tokens.color.info,
|
|
37
|
+
border: 'rgba(59, 130, 246, 0.2)',
|
|
38
|
+
},
|
|
39
|
+
premium: {
|
|
40
|
+
bg: '#7c3aed',
|
|
41
|
+
text: '#fff',
|
|
42
|
+
lightBg: '#f5f3ff',
|
|
43
|
+
lightText: '#7c3aed',
|
|
44
|
+
border: '#ede9fe',
|
|
45
|
+
},
|
|
46
|
+
gold: {
|
|
47
|
+
bg: '#b45309',
|
|
48
|
+
text: '#fff',
|
|
49
|
+
lightBg: '#fffbeb',
|
|
50
|
+
lightText: '#92400e',
|
|
51
|
+
border: '#fde68a',
|
|
52
|
+
},
|
|
53
|
+
slate: {
|
|
54
|
+
bg: tokens.color.slate700,
|
|
55
|
+
text: '#fff',
|
|
56
|
+
lightBg: tokens.color.slate100,
|
|
57
|
+
lightText: tokens.color.slate600,
|
|
58
|
+
border: tokens.color.slate200,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
export const Tag = ({ children, color = 'slate', variant = 'subtle', size = 'md', className = '', style = {}, onClose, icon, clickable = false, onClick, ...props }) => {
|
|
62
|
+
const c = COLOR_SCHEMES[color] || COLOR_SCHEMES.slate;
|
|
63
|
+
const isGradient = variant === 'gradient';
|
|
64
|
+
const backgroundStyle = () => {
|
|
65
|
+
if (isGradient && color === 'premium') {
|
|
66
|
+
return { background: 'linear-gradient(135deg, #7c3aed 0%, #db2777 100%)', color: '#fff' };
|
|
67
|
+
}
|
|
68
|
+
if (isGradient && color === 'gold') {
|
|
69
|
+
return { background: 'linear-gradient(135deg, #f59e0b 0%, #ef4444 100%)', color: '#fff' };
|
|
70
|
+
}
|
|
71
|
+
if (variant === 'solid' || isGradient) {
|
|
72
|
+
return { backgroundColor: c.bg, color: c.text };
|
|
13
73
|
}
|
|
74
|
+
if (variant === 'outline') {
|
|
75
|
+
return { backgroundColor: 'transparent', color: c.lightText };
|
|
76
|
+
}
|
|
77
|
+
return { backgroundColor: c.lightBg, color: c.lightText };
|
|
14
78
|
};
|
|
15
|
-
const
|
|
79
|
+
const borderColor = variant === 'outline' ? c.lightText :
|
|
80
|
+
variant === 'subtle' ? c.border :
|
|
81
|
+
'transparent';
|
|
82
|
+
const sizeStyles = size === 'sm'
|
|
83
|
+
? { padding: '1px 8px', fontSize: '10px', gap: '4px' }
|
|
84
|
+
: { padding: '3px 10px', fontSize: '11px', gap: '5px' };
|
|
16
85
|
const baseStyle = {
|
|
17
86
|
display: 'inline-flex',
|
|
18
87
|
alignItems: 'center',
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
backgroundColor: variant === 'solid' ? c.bg : c.lightBg,
|
|
25
|
-
color: variant === 'solid' ? c.text : c.lightText,
|
|
26
|
-
border: variant === 'outline' ? `1px solid ${c.bg}` : '1px solid transparent',
|
|
88
|
+
borderRadius: tokens.radius.md,
|
|
89
|
+
fontWeight: tokens.font.weightSemibold,
|
|
90
|
+
letterSpacing: '0.02em',
|
|
91
|
+
lineHeight: 1.5,
|
|
92
|
+
border: `1px solid ${borderColor}`,
|
|
27
93
|
transition: tokens.transition.fast,
|
|
28
94
|
userSelect: 'none',
|
|
29
|
-
|
|
95
|
+
whiteSpace: 'nowrap',
|
|
96
|
+
cursor: clickable || onClick ? 'pointer' : 'default',
|
|
97
|
+
...sizeStyles,
|
|
98
|
+
...backgroundStyle(),
|
|
99
|
+
...style,
|
|
30
100
|
};
|
|
31
|
-
|
|
32
|
-
baseStyle.backgroundColor = 'transparent';
|
|
33
|
-
baseStyle.color = c.lightText;
|
|
34
|
-
}
|
|
35
|
-
return (_jsxs("span", { style: baseStyle, className: className, ...props, children: [children, onClose && (_jsx("span", { onClick: (e) => { e.stopPropagation(); onClose(); }, style: {
|
|
101
|
+
return (_jsxs("span", { style: baseStyle, className: `ds-tag ${className}`, onClick: onClick, ...props, children: [icon && (_jsx("span", { style: { display: 'inline-flex', alignItems: 'center', flexShrink: 0 }, children: icon })), children, onClose && (_jsx("span", { onClick: (e) => { e.stopPropagation(); onClose(); }, style: {
|
|
36
102
|
cursor: 'pointer',
|
|
37
|
-
marginLeft: '2px',
|
|
38
103
|
display: 'inline-flex',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
justifyContent: 'center',
|
|
106
|
+
marginLeft: '2px',
|
|
107
|
+
width: size === 'sm' ? '14px' : '16px',
|
|
108
|
+
height: size === 'sm' ? '14px' : '16px',
|
|
109
|
+
borderRadius: '50%',
|
|
39
110
|
opacity: 0.7,
|
|
40
|
-
transition: 'opacity 0.
|
|
41
|
-
|
|
111
|
+
transition: 'opacity 0.15s, background-color 0.15s',
|
|
112
|
+
flexShrink: 0,
|
|
113
|
+
}, onMouseEnter: (e) => {
|
|
114
|
+
e.currentTarget.style.opacity = '1';
|
|
115
|
+
e.currentTarget.style.backgroundColor = 'rgba(0,0,0,0.1)';
|
|
116
|
+
}, onMouseLeave: (e) => {
|
|
117
|
+
e.currentTarget.style.opacity = '0.7';
|
|
118
|
+
e.currentTarget.style.backgroundColor = 'transparent';
|
|
119
|
+
}, children: _jsx("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", children: _jsx("path", { d: "M18 6L6 18M6 6l12 12" }) }) }))] }));
|
|
42
120
|
};
|
|
43
121
|
//# sourceMappingURL=Tag.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.js","sourceRoot":"","sources":["../../../src/components/Tag.tsx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,CAAC,CAAC,EAAE,EAAE;oBACjB,CAAC,CAAC,aAA6B,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;oBACtD,CAAC,CAAC,aAA6B,CAAC,KAAK,CAAC,eAAe,GAAG,aAAa,CAAC;gBACzE,CAAC,YAED,cAAK,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAC,GAAG,YAC/F,eAAM,CAAC,EAAC,sBAAsB,GAAG,GAC7B,GACD,CACR,IACI,CACR,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -2,5 +2,8 @@ import React from 'react';
|
|
|
2
2
|
export interface TooltipProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
3
3
|
title: React.ReactNode;
|
|
4
4
|
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
5
|
+
delay?: number;
|
|
6
|
+
maxWidth?: string;
|
|
7
|
+
arrow?: boolean;
|
|
5
8
|
}
|
|
6
9
|
export declare const Tooltip: React.FC<TooltipProps>;
|
|
@@ -1,43 +1,94 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from 'react';
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect } from 'react';
|
|
3
3
|
import { tokens } from '../tokens';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
4
|
+
const ARROW_STYLES = {
|
|
5
|
+
top: {
|
|
6
|
+
bottom: '-5px',
|
|
7
|
+
left: '50%',
|
|
8
|
+
transform: 'translateX(-50%)',
|
|
9
|
+
borderLeft: '5px solid transparent',
|
|
10
|
+
borderRight: '5px solid transparent',
|
|
11
|
+
borderTop: `5px solid ${tokens.color.slate800}`,
|
|
12
|
+
},
|
|
13
|
+
bottom: {
|
|
14
|
+
top: '-5px',
|
|
15
|
+
left: '50%',
|
|
16
|
+
transform: 'translateX(-50%)',
|
|
17
|
+
borderLeft: '5px solid transparent',
|
|
18
|
+
borderRight: '5px solid transparent',
|
|
19
|
+
borderBottom: `5px solid ${tokens.color.slate800}`,
|
|
20
|
+
},
|
|
21
|
+
left: {
|
|
22
|
+
top: '50%',
|
|
23
|
+
right: '-5px',
|
|
24
|
+
transform: 'translateY(-50%)',
|
|
25
|
+
borderTop: '5px solid transparent',
|
|
26
|
+
borderBottom: '5px solid transparent',
|
|
27
|
+
borderLeft: `5px solid ${tokens.color.slate800}`,
|
|
28
|
+
},
|
|
29
|
+
right: {
|
|
30
|
+
top: '50%',
|
|
31
|
+
left: '-5px',
|
|
32
|
+
transform: 'translateY(-50%)',
|
|
33
|
+
borderTop: '5px solid transparent',
|
|
34
|
+
borderBottom: '5px solid transparent',
|
|
35
|
+
borderRight: `5px solid ${tokens.color.slate800}`,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
const POSITION_STYLES = {
|
|
39
|
+
top: { bottom: 'calc(100% + 8px)', left: '50%', transform: 'translateX(-50%)' },
|
|
40
|
+
bottom: { top: 'calc(100% + 8px)', left: '50%', transform: 'translateX(-50%)' },
|
|
41
|
+
left: { top: '50%', right: 'calc(100% + 8px)', transform: 'translateY(-50%)' },
|
|
42
|
+
right: { top: '50%', left: 'calc(100% + 8px)', transform: 'translateY(-50%)' },
|
|
43
|
+
};
|
|
44
|
+
export const Tooltip = ({ children, title, position = 'top', delay = 120, maxWidth = '240px', arrow = true, className = '', style = {}, ...props }) => {
|
|
45
|
+
const [visible, setVisible] = useState(false);
|
|
46
|
+
const timerRef = useRef(null);
|
|
47
|
+
const show = () => {
|
|
48
|
+
timerRef.current = setTimeout(() => setVisible(true), delay);
|
|
23
49
|
};
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
padding: `${tokens.spacing[1]} ${tokens.spacing[3]}`,
|
|
29
|
-
borderRadius: tokens.radius.sm,
|
|
30
|
-
fontSize: '11px',
|
|
31
|
-
fontWeight: tokens.font.weightMedium,
|
|
32
|
-
whiteSpace: 'nowrap',
|
|
33
|
-
pointerEvents: 'none',
|
|
34
|
-
opacity: isVisible ? 1 : 0,
|
|
35
|
-
visibility: isVisible ? 'visible' : 'hidden',
|
|
36
|
-
transition: tokens.transition.fast,
|
|
37
|
-
zIndex: 1000,
|
|
38
|
-
boxShadow: tokens.shadow.md,
|
|
39
|
-
...getPositionStyles()
|
|
50
|
+
const hide = () => {
|
|
51
|
+
if (timerRef.current)
|
|
52
|
+
clearTimeout(timerRef.current);
|
|
53
|
+
setVisible(false);
|
|
40
54
|
};
|
|
41
|
-
|
|
55
|
+
useEffect(() => () => {
|
|
56
|
+
if (timerRef.current)
|
|
57
|
+
clearTimeout(timerRef.current);
|
|
58
|
+
}, []);
|
|
59
|
+
if (!title)
|
|
60
|
+
return _jsx(_Fragment, { children: children });
|
|
61
|
+
return (_jsxs("div", { style: { position: 'relative', display: 'inline-flex', ...style }, className: `ds-tooltip-wrapper ${className}`, onMouseEnter: show, onMouseLeave: hide, onFocus: show, onBlur: hide, ...props, children: [children, _jsxs("div", { role: "tooltip", style: {
|
|
62
|
+
position: 'absolute',
|
|
63
|
+
...POSITION_STYLES[position],
|
|
64
|
+
backgroundColor: tokens.color.slate800,
|
|
65
|
+
color: '#fff',
|
|
66
|
+
padding: `${tokens.spacing[1]} ${tokens.spacing[3]}`,
|
|
67
|
+
borderRadius: tokens.radius.md,
|
|
68
|
+
fontSize: '11.5px',
|
|
69
|
+
fontWeight: tokens.font.weightMedium,
|
|
70
|
+
fontFamily: tokens.font.family,
|
|
71
|
+
letterSpacing: '0.01em',
|
|
72
|
+
lineHeight: 1.5,
|
|
73
|
+
whiteSpace: 'pre-wrap',
|
|
74
|
+
maxWidth,
|
|
75
|
+
pointerEvents: 'none',
|
|
76
|
+
zIndex: 9999,
|
|
77
|
+
opacity: visible ? 1 : 0,
|
|
78
|
+
visibility: visible ? 'visible' : 'hidden',
|
|
79
|
+
transform: `${POSITION_STYLES[position].transform || ''} ${!visible
|
|
80
|
+
? position === 'top' ? 'translateY(4px)' :
|
|
81
|
+
position === 'bottom' ? 'translateY(-4px)' :
|
|
82
|
+
position === 'left' ? 'translateX(4px)' : 'translateX(-4px)'
|
|
83
|
+
: ''}`,
|
|
84
|
+
transition: 'opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease',
|
|
85
|
+
boxShadow: `${tokens.shadow.lg}, 0 0 0 1px rgba(0,0,0,0.05)`,
|
|
86
|
+
willChange: 'opacity, transform',
|
|
87
|
+
}, children: [title, arrow && (_jsx("div", { style: {
|
|
88
|
+
position: 'absolute',
|
|
89
|
+
width: 0,
|
|
90
|
+
height: 0,
|
|
91
|
+
...ARROW_STYLES[position],
|
|
92
|
+
} }))] })] }));
|
|
42
93
|
};
|
|
43
94
|
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/components/Tooltip.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/components/Tooltip.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAUnC,MAAM,YAAY,GAAwC;IACxD,GAAG,EAAE;QACH,MAAM,EAAE,MAAM;QACd,IA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aAEA,KAAK,EACL,KAAK,IAAI,CACR,cAAK,KAAK,EAAE;4BACV,QAAQ,EAAE,UAAU;4BACpB,KAAK,EAAE,CAAC;4BACR,MAAM,EAAE,CAAC;4BACT,GAAG,YAAY,CAAC,QAAQ,CAAC;yBAC1B,GAAI,CACN,IACG,IACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { tokens } from '../tokens';
|
|
3
3
|
export interface HeadingProps extends React.HTMLAttributes<HTMLHeadingElement> {
|
|
4
|
-
level?: 1 | 2 | 3 | 4;
|
|
4
|
+
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
5
|
+
gradient?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export declare const Heading: React.FC<HeadingProps>;
|
|
8
|
+
type TextColor = keyof typeof tokens.color | 'default' | 'muted' | 'disabled' | 'primary' | 'danger' | 'success' | 'warning' | 'info';
|
|
7
9
|
export interface TextProps extends React.HTMLAttributes<HTMLParagraphElement> {
|
|
8
10
|
size?: keyof typeof tokens.font;
|
|
9
11
|
weight?: 'normal' | 'medium' | 'semibold' | 'bold';
|
|
10
|
-
color?:
|
|
12
|
+
color?: TextColor;
|
|
13
|
+
truncate?: boolean;
|
|
14
|
+
as?: 'p' | 'span' | 'div' | 'li';
|
|
11
15
|
}
|
|
12
16
|
export declare const Text: React.FC<TextProps>;
|
|
17
|
+
export interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
18
|
+
required?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare const Label: React.FC<LabelProps>;
|
|
21
|
+
export interface CaptionProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
22
|
+
}
|
|
23
|
+
export declare const Caption: React.FC<CaptionProps>;
|
|
13
24
|
export interface SectionHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
14
25
|
title: string;
|
|
26
|
+
description?: string;
|
|
15
27
|
}
|
|
16
28
|
export declare const SectionHeader: React.FC<SectionHeaderProps>;
|
|
29
|
+
export {};
|