shared-design-system 1.12.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 -2
- package/dist/src/components/Avatar.js +87 -40
- package/dist/src/components/Avatar.js.map +1 -1
- package/dist/src/components/Badge.d.ts +4 -2
- package/dist/src/components/Badge.js +67 -29
- 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 +3 -1
- package/dist/src/components/Card.js +86 -23
- 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/Divider.d.ts +4 -2
- package/dist/src/components/Divider.js +46 -19
- package/dist/src/components/Divider.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/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 +4 -0
- package/dist/src/components/ReadOnlyField.js +78 -25
- package/dist/src/components/ReadOnlyField.js.map +1 -1
- 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 +2 -0
- package/dist/src/components/Stack.js +21 -20
- 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 +3 -1
- package/dist/src/components/Tag.js +104 -26
- 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 +14 -1
- package/dist/src/components/Typography.js +108 -61
- package/dist/src/components/Typography.js.map +1 -1
- package/dist/src/index.d.ts +6 -6
- package/dist/src/index.js +3 -3
- package/dist/src/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,8 +2,9 @@ import React from 'react';
|
|
|
2
2
|
export interface AlertProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
3
3
|
severity?: 'success' | 'warning' | 'error' | 'info';
|
|
4
4
|
title?: string;
|
|
5
|
-
variant?: 'standard';
|
|
5
|
+
variant?: 'standard' | 'filled' | 'outlined';
|
|
6
6
|
icon?: React.ReactNode;
|
|
7
7
|
onClose?: () => void;
|
|
8
|
+
action?: React.ReactNode;
|
|
8
9
|
}
|
|
9
10
|
export declare const Alert: React.FC<AlertProps>;
|
|
@@ -1,58 +1,100 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import { tokens } from '../tokens';
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
const SEVERITY_CONFIG = {
|
|
5
|
+
success: {
|
|
6
|
+
bg: tokens.color.successBg,
|
|
7
|
+
border: 'rgba(16, 185, 129, 0.2)',
|
|
8
|
+
text: tokens.color.success,
|
|
9
|
+
darkText: '#065f46',
|
|
10
|
+
accentBar: tokens.color.success,
|
|
11
|
+
filledBg: tokens.color.success,
|
|
12
|
+
},
|
|
13
|
+
warning: {
|
|
14
|
+
bg: tokens.color.warningBg,
|
|
15
|
+
border: 'rgba(245, 158, 11, 0.2)',
|
|
16
|
+
text: '#d97706',
|
|
17
|
+
darkText: '#92400e',
|
|
18
|
+
accentBar: tokens.color.warning,
|
|
19
|
+
filledBg: tokens.color.warning,
|
|
20
|
+
},
|
|
21
|
+
error: {
|
|
22
|
+
bg: tokens.color.dangerBg,
|
|
23
|
+
border: 'rgba(239, 68, 68, 0.2)',
|
|
24
|
+
text: tokens.color.danger,
|
|
25
|
+
darkText: '#991b1b',
|
|
26
|
+
accentBar: tokens.color.danger,
|
|
27
|
+
filledBg: tokens.color.danger,
|
|
28
|
+
},
|
|
29
|
+
info: {
|
|
30
|
+
bg: tokens.color.infoBg,
|
|
31
|
+
border: 'rgba(59, 130, 246, 0.2)',
|
|
32
|
+
text: tokens.color.info,
|
|
33
|
+
darkText: '#1e40af',
|
|
34
|
+
accentBar: tokens.color.info,
|
|
35
|
+
filledBg: tokens.color.info,
|
|
36
|
+
},
|
|
17
37
|
};
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return { bg: tokens.color.warningBg, border: 'rgba(245, 158, 11, 0.2)', text: tokens.color.warning, darkText: '#92400e' };
|
|
24
|
-
case 'error':
|
|
25
|
-
return { bg: tokens.color.dangerBg, border: 'rgba(239, 68, 68, 0.2)', text: tokens.color.danger, darkText: '#991b1b' };
|
|
26
|
-
case 'info':
|
|
27
|
-
default:
|
|
28
|
-
return { bg: tokens.color.infoBg, border: 'rgba(59, 130, 246, 0.2)', text: tokens.color.info, darkText: '#1e40af' };
|
|
29
|
-
}
|
|
38
|
+
const DEFAULT_ICONS = {
|
|
39
|
+
success: (_jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: "M22 11.08V12a10 10 0 11-5.93-9.14" }), _jsx("polyline", { points: "22 4 12 14.01 9 11.01" })] })),
|
|
40
|
+
warning: (_jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: "M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z" }), _jsx("line", { x1: "12", y1: "9", x2: "12", y2: "13" }), _jsx("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })] })),
|
|
41
|
+
error: (_jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("circle", { cx: "12", cy: "12", r: "10" }), _jsx("line", { x1: "15", y1: "9", x2: "9", y2: "15" }), _jsx("line", { x1: "9", y1: "9", x2: "15", y2: "15" })] })),
|
|
42
|
+
info: (_jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("circle", { cx: "12", cy: "12", r: "10" }), _jsx("line", { x1: "12", y1: "16", x2: "12", y2: "12" }), _jsx("line", { x1: "12", y1: "8", x2: "12.01", y2: "8" })] })),
|
|
30
43
|
};
|
|
31
|
-
export const Alert = ({ severity = 'info', title, children, className = '', style = {}, variant = 'standard', icon, onClose, ...props }) => {
|
|
32
|
-
const
|
|
44
|
+
export const Alert = ({ severity = 'info', title, children, className = '', style = {}, variant = 'standard', icon, onClose, action, ...props }) => {
|
|
45
|
+
const [dismissed, setDismissed] = useState(false);
|
|
46
|
+
if (dismissed)
|
|
47
|
+
return null;
|
|
48
|
+
const s = SEVERITY_CONFIG[severity] || SEVERITY_CONFIG.info;
|
|
49
|
+
const isFilled = variant === 'filled';
|
|
50
|
+
const isOutlined = variant === 'outlined';
|
|
33
51
|
const baseStyle = {
|
|
34
52
|
display: 'flex',
|
|
35
53
|
gap: tokens.spacing['3'],
|
|
36
|
-
padding: tokens.spacing['4']
|
|
54
|
+
padding: `${tokens.spacing['3']} ${tokens.spacing['4']}`,
|
|
37
55
|
borderRadius: tokens.radius.lg,
|
|
38
|
-
border: `1px solid ${s.border}`,
|
|
39
|
-
backgroundColor: s.bg,
|
|
40
|
-
color: s.darkText,
|
|
41
56
|
fontSize: tokens.font.sm,
|
|
42
|
-
lineHeight: 1.
|
|
57
|
+
lineHeight: 1.55,
|
|
43
58
|
position: 'relative',
|
|
59
|
+
overflow: 'hidden',
|
|
60
|
+
fontFamily: tokens.font.family,
|
|
61
|
+
...(isFilled ? {
|
|
62
|
+
backgroundColor: s.filledBg,
|
|
63
|
+
color: '#fff',
|
|
64
|
+
border: 'none',
|
|
65
|
+
boxShadow: `0 4px 12px ${s.filledBg}40`,
|
|
66
|
+
} : isOutlined ? {
|
|
67
|
+
backgroundColor: 'transparent',
|
|
68
|
+
color: s.darkText,
|
|
69
|
+
border: `1.5px solid ${s.accentBar}`,
|
|
70
|
+
} : {
|
|
71
|
+
backgroundColor: s.bg,
|
|
72
|
+
color: s.darkText,
|
|
73
|
+
border: `1px solid ${s.border}`,
|
|
74
|
+
borderLeft: `4px solid ${s.accentBar}`,
|
|
75
|
+
}),
|
|
44
76
|
...style,
|
|
45
77
|
};
|
|
46
|
-
|
|
78
|
+
const iconColor = isFilled ? '#fff' : s.text;
|
|
79
|
+
const resolvedIcon = icon || DEFAULT_ICONS[severity];
|
|
80
|
+
return (_jsxs("div", { style: baseStyle, className: `ds-alert ds-alert--${severity} ds-alert--${variant} ${className}`, ...props, children: [_jsx("div", { style: { color: iconColor, flexShrink: 0, marginTop: '2px', display: 'flex', alignItems: 'flex-start' }, children: resolvedIcon }), _jsxs("div", { style: { flex: 1, minWidth: 0 }, children: [title && (_jsx("div", { style: {
|
|
81
|
+
fontWeight: tokens.font.weightBold,
|
|
82
|
+
marginBottom: children ? '3px' : 0,
|
|
83
|
+
fontSize: tokens.font.sm,
|
|
84
|
+
lineHeight: 1.4,
|
|
85
|
+
}, children: title })), children && (_jsx("div", { style: { opacity: isFilled ? 0.9 : 1, fontWeight: tokens.font.weightMedium }, children: children })), action && (_jsx("div", { style: { marginTop: tokens.spacing['2'] }, children: action }))] }), onClose && (_jsx("button", { type: "button", onClick: () => { setDismissed(true); onClose(); }, style: {
|
|
47
86
|
background: 'none',
|
|
48
87
|
border: 'none',
|
|
49
88
|
cursor: 'pointer',
|
|
50
|
-
padding:
|
|
51
|
-
color: '
|
|
52
|
-
opacity: 0.5,
|
|
89
|
+
padding: '3px',
|
|
90
|
+
color: isFilled ? 'rgba(255,255,255,0.8)' : s.darkText,
|
|
53
91
|
display: 'flex',
|
|
54
92
|
alignItems: 'center',
|
|
55
93
|
justifyContent: 'center',
|
|
56
|
-
|
|
94
|
+
borderRadius: tokens.radius.sm,
|
|
95
|
+
flexShrink: 0,
|
|
96
|
+
opacity: 0.65,
|
|
97
|
+
transition: tokens.transition.fast,
|
|
98
|
+
}, onMouseEnter: (e) => (e.currentTarget.style.opacity = '1'), onMouseLeave: (e) => (e.currentTarget.style.opacity = '0.65'), children: _jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", children: _jsx("path", { d: "M18 6L6 18M6 6l12 12" }) }) }))] }));
|
|
57
99
|
};
|
|
58
100
|
//# sourceMappingURL=Alert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../../src/components/Alert.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../../src/components/Alert.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAoBnC,MAAM,eAAe,GAAmC;IACtD,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS;QAC1B,MAAM,EAAE,yBAAyB;QACjC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;QAC1B,QAAQ,EAAE,SAAS;QACnB,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;QAC/B,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;KAC/B;IACD,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS;QAC1B,MAAM,EAAE,yBAAyB;QACjC,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,SAAS;QACnB,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;QAC/B,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;KAC/B;IACD,KAAK,EAAE;QACL,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ;QACzB,MAAM,EAAE,wBAAwB;QAChC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;QACzB,QAAQ,EAAE,SAAS;QACnB,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;QAC9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AAE,GAAG,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EACjD,KAAK,EAAE;oBACL,UAAU,EAAE,MAAM;oBAClB,MAAM,EAAE,MAAM;oBACd,MAAM,EAAE,SAAS;oBACjB,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ;oBACtD,OAAO,EAAE,MAAM;oBACf,UAAU,EAAE,QAAQ;oBACpB,cAAc,EAAE,QAAQ;oBACxB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE;oBAC9B,UAAU,EAAE,CAAC;oBACb,OAAO,EAAE,IAAI;oBACb,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI;iBACnC,EACD,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC,EAC1D,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,YAE7D,cAAK,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAE,GAAG,EAAE,aAAa,EAAC,OAAO,YACvH,eAAM,CAAC,EAAC,sBAAsB,GAAG,GAC7B,GACC,CACV,IACG,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -2,8 +2,17 @@ import React from 'react';
|
|
|
2
2
|
export interface AvatarProps extends React.HTMLAttributes<HTMLElement> {
|
|
3
3
|
src?: string;
|
|
4
4
|
alt?: string;
|
|
5
|
-
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
6
|
-
variant?: 'circle' | 'rounded';
|
|
5
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
6
|
+
variant?: 'circle' | 'rounded' | 'square';
|
|
7
7
|
status?: 'online' | 'offline' | 'busy' | 'away';
|
|
8
|
+
initials?: string;
|
|
9
|
+
ring?: boolean;
|
|
10
|
+
ringColor?: string;
|
|
8
11
|
}
|
|
9
12
|
export declare const Avatar: React.FC<AvatarProps>;
|
|
13
|
+
export interface AvatarGroupProps {
|
|
14
|
+
max?: number;
|
|
15
|
+
size?: AvatarProps['size'];
|
|
16
|
+
children: React.ReactElement<AvatarProps>[];
|
|
17
|
+
}
|
|
18
|
+
export declare const AvatarGroup: React.FC<AvatarGroupProps>;
|
|
@@ -1,61 +1,108 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import { tokens } from '../tokens';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
const SIZE_MAP = {
|
|
5
|
+
xs: '24px',
|
|
6
|
+
sm: '32px',
|
|
7
|
+
md: '40px',
|
|
8
|
+
lg: '48px',
|
|
9
|
+
xl: '64px',
|
|
10
|
+
'2xl': '80px',
|
|
11
|
+
};
|
|
12
|
+
const STATUS_COLOR_MAP = {
|
|
13
|
+
online: tokens.color.success,
|
|
14
|
+
busy: tokens.color.danger,
|
|
15
|
+
away: tokens.color.warning,
|
|
16
|
+
offline: tokens.color.slate300,
|
|
17
|
+
};
|
|
18
|
+
const GRADIENT_POOL = [
|
|
19
|
+
'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
|
|
20
|
+
'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
|
|
21
|
+
'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)',
|
|
22
|
+
'linear-gradient(135deg, #43e97b 0%, #38f9d7 100%)',
|
|
23
|
+
'linear-gradient(135deg, #fa709a 0%, #fee140 100%)',
|
|
24
|
+
'linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%)',
|
|
25
|
+
];
|
|
26
|
+
function getGradientForInitials(text) {
|
|
27
|
+
let hash = 0;
|
|
28
|
+
for (let i = 0; i < text.length; i++)
|
|
29
|
+
hash = text.charCodeAt(i) + ((hash << 5) - hash);
|
|
30
|
+
return GRADIENT_POOL[Math.abs(hash) % GRADIENT_POOL.length];
|
|
31
|
+
}
|
|
32
|
+
export const Avatar = ({ src, alt, children, size = 'md', variant = 'circle', status, initials, ring = false, ringColor, className = '', style = {}, ...props }) => {
|
|
33
|
+
const dims = SIZE_MAP[size] || '40px';
|
|
34
|
+
const borderRadius = variant === 'circle' ? '50%' :
|
|
35
|
+
variant === 'rounded' ? tokens.radius.lg :
|
|
36
|
+
tokens.radius.md;
|
|
37
|
+
const fallbackLabel = initials || (typeof children === 'string' ? children : undefined);
|
|
38
|
+
const gradientBg = fallbackLabel ? getGradientForInitials(fallbackLabel) : undefined;
|
|
39
|
+
const statusDotSize = size === 'xs' || size === 'sm' ? '8px' : '10px';
|
|
15
40
|
const containerStyle = {
|
|
16
41
|
position: 'relative',
|
|
17
42
|
width: dims,
|
|
18
43
|
height: dims,
|
|
19
|
-
display: 'inline-
|
|
20
|
-
|
|
44
|
+
display: 'inline-flex',
|
|
45
|
+
flexShrink: 0,
|
|
46
|
+
...style,
|
|
21
47
|
};
|
|
22
|
-
const
|
|
48
|
+
const innerStyle = {
|
|
23
49
|
width: '100%',
|
|
24
50
|
height: '100%',
|
|
25
|
-
borderRadius
|
|
51
|
+
borderRadius,
|
|
26
52
|
display: 'flex',
|
|
27
53
|
alignItems: 'center',
|
|
28
54
|
justifyContent: 'center',
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
55
|
+
...(src ? {} : {
|
|
56
|
+
background: gradientBg || tokens.color.slate100,
|
|
57
|
+
}),
|
|
58
|
+
color: '#fff',
|
|
59
|
+
fontSize: `calc(${dims} / 2.5)`,
|
|
32
60
|
fontWeight: tokens.font.weightBold,
|
|
33
61
|
overflow: 'hidden',
|
|
34
62
|
userSelect: 'none',
|
|
35
|
-
|
|
36
|
-
|
|
63
|
+
boxShadow: ring
|
|
64
|
+
? `0 0 0 2.5px ${ringColor || tokens.color.surface}, 0 0 0 4.5px ${ringColor ? ringColor + '80' : tokens.color.primary}`
|
|
65
|
+
: tokens.shadow.sm,
|
|
37
66
|
objectFit: 'cover',
|
|
67
|
+
letterSpacing: '-0.02em',
|
|
38
68
|
};
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
69
|
+
const statusStyle = {
|
|
70
|
+
position: 'absolute',
|
|
71
|
+
bottom: variant === 'circle' ? '1px' : '-2px',
|
|
72
|
+
right: variant === 'circle' ? '1px' : '-2px',
|
|
73
|
+
width: statusDotSize,
|
|
74
|
+
height: statusDotSize,
|
|
75
|
+
borderRadius: '50%',
|
|
76
|
+
backgroundColor: STATUS_COLOR_MAP[status] || 'transparent',
|
|
77
|
+
border: `2px solid ${tokens.color.white}`,
|
|
78
|
+
boxShadow: '0 1px 3px rgba(0,0,0,0.15)',
|
|
47
79
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
80
|
+
return (_jsxs("div", { style: containerStyle, className: `ds-avatar ${className}`, children: [src ? (_jsx("img", { src: src, alt: alt || 'Avatar', style: innerStyle, ...props })) : (_jsx("div", { style: innerStyle, ...props, children: fallbackLabel || children })), status && _jsx("div", { style: statusStyle })] }));
|
|
81
|
+
};
|
|
82
|
+
export const AvatarGroup = ({ max = 4, size = 'md', children, }) => {
|
|
83
|
+
const visible = children.slice(0, max);
|
|
84
|
+
const overflow = children.length - max;
|
|
85
|
+
const dims = SIZE_MAP[size] || '40px';
|
|
86
|
+
const offset = `calc(${dims} * -0.3)`;
|
|
87
|
+
return (_jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [visible.map((child, i) => React.cloneElement(child, {
|
|
88
|
+
key: i,
|
|
89
|
+
size,
|
|
90
|
+
ring: true,
|
|
91
|
+
style: { marginLeft: i === 0 ? 0 : offset, ...(child.props.style || {}) },
|
|
92
|
+
})), overflow > 0 && (_jsxs("div", { style: {
|
|
93
|
+
width: dims,
|
|
94
|
+
height: dims,
|
|
55
95
|
borderRadius: '50%',
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
96
|
+
background: tokens.color.slate200,
|
|
97
|
+
color: tokens.color.slate600,
|
|
98
|
+
display: 'flex',
|
|
99
|
+
alignItems: 'center',
|
|
100
|
+
justifyContent: 'center',
|
|
101
|
+
fontSize: `calc(${dims} / 3)`,
|
|
102
|
+
fontWeight: tokens.font.weightBold,
|
|
103
|
+
marginLeft: offset,
|
|
104
|
+
boxShadow: `0 0 0 2.5px ${tokens.color.surface}`,
|
|
105
|
+
userSelect: 'none',
|
|
106
|
+
}, children: ["+", overflow] }))] }));
|
|
60
107
|
};
|
|
61
108
|
//# sourceMappingURL=Avatar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../../../src/components/Avatar.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../../../src/components/Avatar.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAanC,MAAM,QAAQ,GAA2B;IACvC,EAAE,EAAG,MAAM;IACX,EAAE,EAAG,MAAM;IACX,EAAE,EAAG,MAAM;IACX,EAAE,EAAG,MAAM;IACX,EAAE,EAAG,MAAM;IACX,KAAK,EAAE,MAAM;CACd,CAAC;AAEF,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{
|
|
3
3
|
variant?: 'success' | 'warning' | 'danger' | 'info' | 'primary' | 'slate';
|
|
4
|
-
type?: 'subtle' | 'solid';
|
|
5
|
-
size?: 'sm' | 'md';
|
|
4
|
+
type?: 'subtle' | 'solid' | 'outline';
|
|
5
|
+
size?: 'sm' | 'md' | 'lg';
|
|
6
|
+
dot?: boolean;
|
|
7
|
+
icon?: React.ReactNode;
|
|
6
8
|
}
|
|
7
9
|
export declare const Badge: React.FC<BadgeProps>;
|
|
@@ -1,89 +1,127 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { tokens } from '../tokens';
|
|
3
|
-
export const Badge = ({ children, variant = 'slate', type = 'subtle', size = 'md', className = '', style = {}, ...props }) => {
|
|
3
|
+
export const Badge = ({ children, variant = 'slate', type = 'subtle', size = 'md', dot = false, icon, className = '', style = {}, ...props }) => {
|
|
4
4
|
const getVariantStyles = () => {
|
|
5
5
|
const isSubtle = type === 'subtle';
|
|
6
|
+
const isOutline = type === 'outline';
|
|
6
7
|
switch (variant) {
|
|
7
8
|
case 'primary':
|
|
8
9
|
return isSubtle ? {
|
|
9
10
|
backgroundColor: tokens.color.primaryLight,
|
|
10
11
|
color: tokens.color.primary,
|
|
11
|
-
borderColor: 'rgba(37, 99, 235, 0.
|
|
12
|
+
borderColor: 'rgba(37, 99, 235, 0.2)',
|
|
13
|
+
} : isOutline ? {
|
|
14
|
+
backgroundColor: 'transparent',
|
|
15
|
+
color: tokens.color.primary,
|
|
16
|
+
borderColor: tokens.color.primary,
|
|
12
17
|
} : {
|
|
13
18
|
backgroundColor: tokens.color.primary,
|
|
14
|
-
color: '
|
|
15
|
-
borderColor: 'transparent'
|
|
19
|
+
color: '#fff',
|
|
20
|
+
borderColor: 'transparent',
|
|
16
21
|
};
|
|
17
22
|
case 'success':
|
|
18
23
|
return isSubtle ? {
|
|
19
24
|
backgroundColor: tokens.color.successBg,
|
|
20
25
|
color: tokens.color.success,
|
|
21
|
-
borderColor: 'rgba(5, 150, 105, 0.
|
|
26
|
+
borderColor: 'rgba(5, 150, 105, 0.2)',
|
|
27
|
+
} : isOutline ? {
|
|
28
|
+
backgroundColor: 'transparent',
|
|
29
|
+
color: tokens.color.success,
|
|
30
|
+
borderColor: tokens.color.success,
|
|
22
31
|
} : {
|
|
23
32
|
backgroundColor: tokens.color.success,
|
|
24
|
-
color: '
|
|
25
|
-
borderColor: 'transparent'
|
|
33
|
+
color: '#fff',
|
|
34
|
+
borderColor: 'transparent',
|
|
26
35
|
};
|
|
27
36
|
case 'warning':
|
|
28
37
|
return isSubtle ? {
|
|
29
38
|
backgroundColor: tokens.color.warningBg,
|
|
39
|
+
color: '#b45309',
|
|
40
|
+
borderColor: 'rgba(245, 158, 11, 0.2)',
|
|
41
|
+
} : isOutline ? {
|
|
42
|
+
backgroundColor: 'transparent',
|
|
30
43
|
color: tokens.color.warning,
|
|
31
|
-
borderColor:
|
|
44
|
+
borderColor: tokens.color.warning,
|
|
32
45
|
} : {
|
|
33
46
|
backgroundColor: tokens.color.warning,
|
|
34
|
-
color: '
|
|
35
|
-
borderColor: 'transparent'
|
|
47
|
+
color: '#fff',
|
|
48
|
+
borderColor: 'transparent',
|
|
36
49
|
};
|
|
37
50
|
case 'danger':
|
|
38
51
|
return isSubtle ? {
|
|
39
52
|
backgroundColor: tokens.color.dangerBg,
|
|
40
53
|
color: tokens.color.danger,
|
|
41
|
-
borderColor: 'rgba(220, 38, 38, 0.
|
|
54
|
+
borderColor: 'rgba(220, 38, 38, 0.2)',
|
|
55
|
+
} : isOutline ? {
|
|
56
|
+
backgroundColor: 'transparent',
|
|
57
|
+
color: tokens.color.danger,
|
|
58
|
+
borderColor: tokens.color.danger,
|
|
42
59
|
} : {
|
|
43
60
|
backgroundColor: tokens.color.danger,
|
|
44
|
-
color: '
|
|
45
|
-
borderColor: 'transparent'
|
|
61
|
+
color: '#fff',
|
|
62
|
+
borderColor: 'transparent',
|
|
46
63
|
};
|
|
47
64
|
case 'info':
|
|
48
65
|
return isSubtle ? {
|
|
49
66
|
backgroundColor: tokens.color.infoBg,
|
|
50
67
|
color: tokens.color.info,
|
|
51
|
-
borderColor: 'rgba(59, 130, 246, 0.
|
|
68
|
+
borderColor: 'rgba(59, 130, 246, 0.2)',
|
|
69
|
+
} : isOutline ? {
|
|
70
|
+
backgroundColor: 'transparent',
|
|
71
|
+
color: tokens.color.info,
|
|
72
|
+
borderColor: tokens.color.info,
|
|
52
73
|
} : {
|
|
53
74
|
backgroundColor: tokens.color.info,
|
|
54
|
-
color: '
|
|
55
|
-
borderColor: 'transparent'
|
|
75
|
+
color: '#fff',
|
|
76
|
+
borderColor: 'transparent',
|
|
56
77
|
};
|
|
57
78
|
case 'slate':
|
|
58
79
|
default:
|
|
59
80
|
return isSubtle ? {
|
|
60
81
|
backgroundColor: tokens.color.slate100,
|
|
61
|
-
color: tokens.color.
|
|
62
|
-
borderColor:
|
|
82
|
+
color: tokens.color.slate600,
|
|
83
|
+
borderColor: tokens.color.slate200,
|
|
84
|
+
} : isOutline ? {
|
|
85
|
+
backgroundColor: 'transparent',
|
|
86
|
+
color: tokens.color.slate600,
|
|
87
|
+
borderColor: tokens.color.slate400,
|
|
63
88
|
} : {
|
|
64
89
|
backgroundColor: tokens.color.slate700,
|
|
65
|
-
color: '
|
|
66
|
-
borderColor: 'transparent'
|
|
90
|
+
color: '#fff',
|
|
91
|
+
borderColor: 'transparent',
|
|
67
92
|
};
|
|
68
93
|
}
|
|
69
94
|
};
|
|
70
|
-
const
|
|
95
|
+
const getSizeStyles = () => {
|
|
96
|
+
switch (size) {
|
|
97
|
+
case 'sm': return { padding: '1px 7px', fontSize: '10px', gap: '4px' };
|
|
98
|
+
case 'lg': return { padding: '4px 14px', fontSize: '12px', gap: '6px' };
|
|
99
|
+
default: return { padding: '2px 10px', fontSize: '11px', gap: '5px' };
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const dotColor = getVariantStyles().color;
|
|
71
103
|
const baseStyle = {
|
|
72
104
|
display: 'inline-flex',
|
|
73
105
|
alignItems: 'center',
|
|
74
106
|
justifyContent: 'center',
|
|
75
|
-
padding: size === 'sm' ? '1px 8px' : '3px 12px',
|
|
76
107
|
borderRadius: tokens.radius.full,
|
|
77
|
-
|
|
78
|
-
fontWeight: tokens.font.weightBold,
|
|
108
|
+
fontWeight: tokens.font.weightSemibold,
|
|
79
109
|
textTransform: 'uppercase',
|
|
80
|
-
letterSpacing: '0.
|
|
110
|
+
letterSpacing: '0.05em',
|
|
81
111
|
border: '1px solid',
|
|
82
112
|
whiteSpace: 'nowrap',
|
|
113
|
+
lineHeight: 1.6,
|
|
83
114
|
transition: tokens.transition.fast,
|
|
84
|
-
...
|
|
85
|
-
...
|
|
115
|
+
...getSizeStyles(),
|
|
116
|
+
...getVariantStyles(),
|
|
117
|
+
...style,
|
|
86
118
|
};
|
|
87
|
-
return (
|
|
119
|
+
return (_jsxs("span", { style: baseStyle, className: `ds-badge ${className}`, ...props, children: [dot && (_jsx("span", { style: {
|
|
120
|
+
width: '6px',
|
|
121
|
+
height: '6px',
|
|
122
|
+
borderRadius: '50%',
|
|
123
|
+
backgroundColor: 'currentColor',
|
|
124
|
+
flexShrink: 0,
|
|
125
|
+
} })), icon && _jsx("span", { style: { display: 'inline-flex', alignItems: 'center', flexShrink: 0 }, children: icon }), children] }));
|
|
88
126
|
};
|
|
89
127
|
//# sourceMappingURL=Badge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../../src/components/Badge.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../../src/components/Badge.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAUnC,MAAM,CAAC,MAAM,K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.ReactNode;
|
|
4
|
+
icon?: React.ReactNode;
|
|
4
5
|
onClick?: () => void;
|
|
5
6
|
}
|
|
6
7
|
export interface BreadcrumbsProps extends React.HTMLAttributes<HTMLElement> {
|
|
7
8
|
items: BreadcrumbItem[];
|
|
8
9
|
separator?: React.ReactNode;
|
|
10
|
+
size?: 'sm' | 'md';
|
|
11
|
+
maxItems?: number;
|
|
9
12
|
}
|
|
10
13
|
export declare const Breadcrumbs: React.FC<BreadcrumbsProps>;
|