infinity-ui-elements 1.7.12 → 1.8.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/components/Alert/Alert.d.ts +60 -0
- package/dist/components/Alert/Alert.d.ts.map +1 -0
- package/dist/components/Alert/Alert.stories.d.ts +16 -0
- package/dist/components/Alert/Alert.stories.d.ts.map +1 -0
- package/dist/components/Alert/index.d.ts +3 -0
- package/dist/components/Alert/index.d.ts.map +1 -0
- package/dist/components/Avatar/Avatar.d.ts +1 -1
- package/dist/components/Badge/Badge.d.ts +2 -2
- package/dist/components/Button/Button.d.ts +3 -3
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/ButtonGroup/ButtonGroup.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/Counter/Counter.d.ts +1 -1
- package/dist/components/Divider/Divider.d.ts +1 -1
- package/dist/components/Dropdown/Dropdown.d.ts +1 -1
- package/dist/components/Dropdown/Dropdown.stories.d.ts +60 -60
- package/dist/components/IconButton/IconButton.d.ts +22 -0
- package/dist/components/IconButton/IconButton.d.ts.map +1 -0
- package/dist/components/IconButton/IconButton.stories.d.ts +17 -0
- package/dist/components/IconButton/IconButton.stories.d.ts.map +1 -0
- package/dist/components/IconButton/index.d.ts +3 -0
- package/dist/components/IconButton/index.d.ts.map +1 -0
- package/dist/components/Link/Link.d.ts +3 -3
- package/dist/components/Link/Link.d.ts.map +1 -1
- package/dist/components/Pagination/Pagination.d.ts +1 -1
- package/dist/components/Radio/Radio.d.ts +1 -1
- package/dist/components/SearchableDropdown/SearchableDropdown.stories.d.ts +74 -74
- package/dist/components/Select/Select.d.ts +2 -2
- package/dist/components/Switch/Switch.d.ts +1 -1
- package/dist/components/TabItem/TabItem.d.ts +1 -1
- package/dist/components/Table/Table.d.ts +1 -5
- package/dist/components/Table/Table.d.ts.map +1 -1
- package/dist/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/components/Table/TableBody.d.ts +2 -5
- package/dist/components/Table/TableBody.d.ts.map +1 -1
- package/dist/components/Table/TableHeader.d.ts +1 -3
- package/dist/components/Table/TableHeader.d.ts.map +1 -1
- package/dist/components/Table/tableVariants.d.ts +3 -3
- package/dist/components/TextArea/TextArea.d.ts +2 -2
- package/dist/components/TextField/TextField.d.ts +2 -2
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +961 -600
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +963 -598
- package/dist/index.js.map +1 -1
- package/dist/lib/icons.d.ts +3 -0
- package/dist/lib/icons.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var classVarianceAuthority = require('class-variance-authority');
|
|
6
|
-
var clsx = require('clsx');
|
|
7
|
-
var tailwindMerge = require('tailwind-merge');
|
|
8
6
|
var reactSlot = require('@radix-ui/react-slot');
|
|
9
7
|
var reactSpinners = require('react-spinners');
|
|
8
|
+
var clsx = require('clsx');
|
|
9
|
+
var tailwindMerge = require('tailwind-merge');
|
|
10
10
|
var lucideReact = require('lucide-react');
|
|
11
11
|
var reactDom = require('react-dom');
|
|
12
12
|
var reactTable = require('@tanstack/react-table');
|
|
@@ -30,6 +30,112 @@ function _interopNamespaceDefault(e) {
|
|
|
30
30
|
|
|
31
31
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* ==============================================
|
|
35
|
+
* HOW TO ADD A NEW ICON:
|
|
36
|
+
* ==============================================
|
|
37
|
+
*
|
|
38
|
+
* 1. Add your SVG file to: src/assets/icons/{iconName}.svg
|
|
39
|
+
*
|
|
40
|
+
* 2. Copy the SVG content from the file
|
|
41
|
+
*
|
|
42
|
+
* 3. Add it to the iconRegistry below:
|
|
43
|
+
* iconName: `<svg>...</svg>`,
|
|
44
|
+
*
|
|
45
|
+
* 4. Use it anywhere in your app:
|
|
46
|
+
* <Icon name="iconName" size={24} />
|
|
47
|
+
*
|
|
48
|
+
* The Icon component will automatically:
|
|
49
|
+
* - Replace hardcoded colors with currentColor
|
|
50
|
+
* - Allow you to control color via className or style
|
|
51
|
+
* - Resize based on the size prop
|
|
52
|
+
* ==============================================
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* Icon registry - maps icon names to their SVG content
|
|
56
|
+
* Add your icons here by copying the SVG content from your icon files
|
|
57
|
+
*/
|
|
58
|
+
const iconRegistry = {
|
|
59
|
+
// Tick/Check icon
|
|
60
|
+
tick: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
61
|
+
<path d="M10.364 15.1924L19.5564 6L20.9706 7.41421L10.364 18.0208L4 11.6569L5.41422 10.2427L10.364 15.1924Z" fill="#081416"/>
|
|
62
|
+
</svg>`,
|
|
63
|
+
// Alias: check points to the same icon as tick
|
|
64
|
+
check: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
65
|
+
<path d="M10.364 15.1924L19.5564 6L20.9706 7.41421L10.364 18.0208L4 11.6569L5.41422 10.2427L10.364 15.1924Z" fill="#081416"/>
|
|
66
|
+
</svg>`,
|
|
67
|
+
add: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
68
|
+
<path d="M12.9 11.0999L21 11.0997V12.8997L12.9 12.8999V21H11.1V12.8999L3.00004 12.9001L3 11.1001L11.1 11.0999L11.0999 3.00001L12.8999 3L12.9 11.0999Z" fill="#081416"/>
|
|
69
|
+
</svg>`,
|
|
70
|
+
// Info icon
|
|
71
|
+
info: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
72
|
+
<path d="M12 22.5C6.20101 22.5 1.5 17.7989 1.5 12C1.5 6.20101 6.20101 1.5 12 1.5C17.7989 1.5 22.5 6.20101 22.5 12C22.5 17.7989 17.7989 22.5 12 22.5ZM12 20.4C16.6392 20.4 20.4 16.6392 20.4 12C20.4 7.36081 16.6392 3.6 12 3.6C7.36081 3.6 3.6 7.36081 3.6 12C3.6 16.6392 7.36081 20.4 12 20.4ZM10.95 6.75H13.05V8.85H10.95V6.75ZM10.95 10.95H13.05V17.25H10.95V10.95Z" fill="#081416"/>
|
|
73
|
+
</svg>
|
|
74
|
+
`,
|
|
75
|
+
// Exclamation/Warning icon
|
|
76
|
+
exclamation: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
77
|
+
<path d="M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM13 17H11V15H13V17ZM13 13H11V7H13V13Z" fill="#081416"/>
|
|
78
|
+
</svg>`,
|
|
79
|
+
// Close/X icon
|
|
80
|
+
close: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
81
|
+
<path d="M18 6L6 18M6 6L18 18" stroke="#081416" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
82
|
+
</svg>`,
|
|
83
|
+
};
|
|
84
|
+
const Icon = ({ name, size = 24, className = "", style = {}, ...props }) => {
|
|
85
|
+
const svgContent = iconRegistry[name];
|
|
86
|
+
if (!svgContent) {
|
|
87
|
+
console.warn(`Icon "${String(name)}" not found in registry.\n` +
|
|
88
|
+
`Available icons: ${Object.keys(iconRegistry).join(", ")}`);
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
// Parse the SVG content
|
|
92
|
+
const parser = new DOMParser();
|
|
93
|
+
const svgDoc = parser.parseFromString(svgContent, "image/svg+xml");
|
|
94
|
+
const svgElement = svgDoc.querySelector("svg");
|
|
95
|
+
if (!svgElement) {
|
|
96
|
+
console.error(`Invalid SVG content for icon "${String(name)}"`);
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
// Get the viewBox for proper scaling
|
|
100
|
+
const viewBox = svgElement.getAttribute("viewBox") || "0 0 24 24";
|
|
101
|
+
// Get all SVG content as string and replace hardcoded colors with currentColor
|
|
102
|
+
let innerSVG = svgElement.innerHTML;
|
|
103
|
+
// Replace common hardcoded colors with currentColor
|
|
104
|
+
// This allows the icon to inherit text color from parent
|
|
105
|
+
innerSVG = innerSVG
|
|
106
|
+
.replace(/fill="[^"]*"/g, 'fill="currentColor"')
|
|
107
|
+
.replace(/stroke="[^"]*"/g, 'stroke="currentColor"');
|
|
108
|
+
return (jsxRuntime.jsx("svg", { width: size, height: size, viewBox: viewBox, className: className, style: style, xmlns: "http://www.w3.org/2000/svg", ...props, dangerouslySetInnerHTML: { __html: innerSVG } }));
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Get all available icon names from the registry
|
|
112
|
+
* @returns Array of registered icon names
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```tsx
|
|
116
|
+
* const icons = getAvailableIcons();
|
|
117
|
+
* console.log(icons); // ['tick', 'check', ...]
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
function getAvailableIcons() {
|
|
121
|
+
return Object.keys(iconRegistry);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Check if an icon exists in the registry
|
|
125
|
+
* @param name - Icon name to check
|
|
126
|
+
* @returns true if the icon exists
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```tsx
|
|
130
|
+
* if (hasIcon('tick')) {
|
|
131
|
+
* // Icon exists
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
function hasIcon(name) {
|
|
136
|
+
return name in iconRegistry;
|
|
137
|
+
}
|
|
138
|
+
|
|
33
139
|
// Define patterns for custom classes that should be preserved
|
|
34
140
|
// This approach is more scalable than hardcoding individual class names
|
|
35
141
|
const CUSTOM_CLASS_PATTERNS = [
|
|
@@ -69,123 +175,12 @@ function cn(...inputs) {
|
|
|
69
175
|
return clsx.clsx(mergedStandard, customClasses);
|
|
70
176
|
}
|
|
71
177
|
|
|
72
|
-
|
|
73
|
-
function getTextClassName(variant = "body", size = "medium", weight = "regular", color = "default") {
|
|
74
|
-
// Build the base class name
|
|
75
|
-
let baseClass = `text-${variant}`;
|
|
76
|
-
// Add size
|
|
77
|
-
if (size) {
|
|
78
|
-
baseClass += `-${size}`;
|
|
79
|
-
}
|
|
80
|
-
// Add weight
|
|
81
|
-
if (weight) {
|
|
82
|
-
baseClass += `-${weight}`;
|
|
83
|
-
}
|
|
84
|
-
// Add color class separately
|
|
85
|
-
const colorClass = `text-color-${color}`;
|
|
86
|
-
return `${baseClass} ${colorClass}`;
|
|
87
|
-
}
|
|
88
|
-
const Text = React__namespace.forwardRef(({ className, variant = "body", size = "medium", weight = "regular", color = "default", as = "p", children, ...props }, ref) => {
|
|
89
|
-
const Component = as;
|
|
90
|
-
const textClass = getTextClassName(variant, size, weight, color);
|
|
91
|
-
return React__namespace.createElement(Component, {
|
|
92
|
-
className: cn(textClass, className),
|
|
93
|
-
ref,
|
|
94
|
-
...props,
|
|
95
|
-
}, children);
|
|
96
|
-
});
|
|
97
|
-
Text.displayName = "Text";
|
|
98
|
-
|
|
99
|
-
const inverseColorClasses = {
|
|
100
|
-
a1: "bg-avatar-fill-a1-on-bg text-avatar-fill-a1-bg",
|
|
101
|
-
a2: "bg-avatar-fill-a2-on-bg text-avatar-fill-a2-bg",
|
|
102
|
-
a3: "bg-avatar-fill-a3-on-bg text-avatar-fill-a3-bg",
|
|
103
|
-
a4: "bg-avatar-fill-a4-on-bg text-avatar-fill-a4-bg",
|
|
104
|
-
a5: "bg-avatar-fill-a5-on-bg text-avatar-fill-a5-bg",
|
|
105
|
-
};
|
|
106
|
-
const avatarVariants = classVarianceAuthority.cva("inline-flex items-center justify-center font-medium text-center select-none", {
|
|
107
|
-
variants: {
|
|
108
|
-
color: {
|
|
109
|
-
a1: "bg-avatar-fill-a1-bg text-avatar-fill-a1-on-bg",
|
|
110
|
-
a2: "bg-avatar-fill-a2-bg text-avatar-fill-a2-on-bg",
|
|
111
|
-
a3: "bg-avatar-fill-a3-bg text-avatar-fill-a3-on-bg",
|
|
112
|
-
a4: "bg-avatar-fill-a4-bg text-avatar-fill-a4-on-bg",
|
|
113
|
-
a5: "bg-avatar-fill-a5-bg text-avatar-fill-a5-on-bg",
|
|
114
|
-
},
|
|
115
|
-
size: {
|
|
116
|
-
small: "h-[24px] w-[24px] text-body-medium-regular rounded-large",
|
|
117
|
-
medium: "h-[32px] w-[32px] text-body-medium-regular rounded-xlarge",
|
|
118
|
-
xlarge: "h-[36px] w-[36px] text-body-medium-regular rounded-xlarge",
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
defaultVariants: {
|
|
122
|
-
color: "a1",
|
|
123
|
-
size: "medium",
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
const statusVariants = classVarianceAuthority.cva("absolute flex items-center justify-center rounded-full border-2 border-surface-fill-neutral-intense", {
|
|
127
|
-
variants: {
|
|
128
|
-
size: {
|
|
129
|
-
small: "h-5 w-5 -bottom-0.5 -right-0.5",
|
|
130
|
-
medium: "h-6 w-6 -bottom-1 -right-1",
|
|
131
|
-
xlarge: "h-6 w-6 -bottom-1 -right-1",
|
|
132
|
-
},
|
|
133
|
-
statusColor: {
|
|
134
|
-
positive: "bg-action-fill-positive-default",
|
|
135
|
-
negative: "bg-action-fill-negative-default",
|
|
136
|
-
notice: "bg-action-fill-notice-default",
|
|
137
|
-
info: "bg-action-fill-info-default",
|
|
138
|
-
neutral: "bg-action-fill-neutral-default",
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
defaultVariants: {
|
|
142
|
-
size: "medium",
|
|
143
|
-
statusColor: "notice",
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
const Avatar = React__namespace.forwardRef(({ className, appearance = "default", color, size, children, src, alt, showStatus = false, statusColor = "notice", statusIcon, label, trailingComponent, containerClassName, ...props }, ref) => {
|
|
147
|
-
const [imageError, setImageError] = React__namespace.useState(false);
|
|
148
|
-
const handleImageError = () => {
|
|
149
|
-
setImageError(true);
|
|
150
|
-
};
|
|
151
|
-
const getStatusIconSize = () => {
|
|
152
|
-
switch (size) {
|
|
153
|
-
case "small":
|
|
154
|
-
return "h-3.5 w-3.5";
|
|
155
|
-
case "medium":
|
|
156
|
-
return "h-4 w-4";
|
|
157
|
-
default:
|
|
158
|
-
return "h-4 w-4";
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
const getTextSize = () => {
|
|
162
|
-
switch (size) {
|
|
163
|
-
case "small":
|
|
164
|
-
return "small";
|
|
165
|
-
case "medium":
|
|
166
|
-
return "medium";
|
|
167
|
-
default:
|
|
168
|
-
return "medium";
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
const resolvedColor = color ?? "a1";
|
|
172
|
-
const avatarElement = (jsxRuntime.jsxs("div", { className: "relative inline-block", children: [jsxRuntime.jsx("div", { className: cn(avatarVariants({ color: resolvedColor, size }), appearance === "inverse"
|
|
173
|
-
? inverseColorClasses[resolvedColor]
|
|
174
|
-
: undefined, className), ...props, children: src && !imageError ? (jsxRuntime.jsx("img", { src: src, alt: alt || "Avatar", className: cn("h-full w-full object-cover", size === "small" ? "rounded-large" : "rounded-xlarge"), onError: handleImageError })) : (children) }), showStatus && (jsxRuntime.jsx("div", { className: cn(statusVariants({ size, statusColor })), children: statusIcon && (jsxRuntime.jsx("span", { className: cn("text-action-ink-on-primary-normal", getStatusIconSize()), children: statusIcon })) }))] }));
|
|
175
|
-
// If no label or trailing component, return just the avatar
|
|
176
|
-
if (!label && !trailingComponent) {
|
|
177
|
-
return jsxRuntime.jsx("div", { ref: ref, children: avatarElement });
|
|
178
|
-
}
|
|
179
|
-
// Otherwise, return avatar with label and/or trailing component
|
|
180
|
-
return (jsxRuntime.jsxs("div", { ref: ref, className: cn("inline-flex items-center gap-3", containerClassName), children: [avatarElement, label && (jsxRuntime.jsx(Text, { variant: "body", size: getTextSize(), weight: "medium", color: "default", as: "span", children: label })), trailingComponent && (jsxRuntime.jsx("span", { className: "ml-auto", children: trailingComponent }))] }));
|
|
181
|
-
});
|
|
182
|
-
Avatar.displayName = "Avatar";
|
|
183
|
-
|
|
184
|
-
const badgeVariants = classVarianceAuthority.cva("inline-flex items-center whitespace-nowrap transition-colors", {
|
|
178
|
+
const buttonVariants = classVarianceAuthority.cva("items-center gap-3 justify-center whitespace-nowrap ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none", {
|
|
185
179
|
variants: {
|
|
186
180
|
variant: {
|
|
187
|
-
|
|
188
|
-
|
|
181
|
+
primary: "bg-action-fill-primary-default text-action-ink-on-primary-normal hover:bg-action-fill-primary-hover",
|
|
182
|
+
secondary: "border",
|
|
183
|
+
tertiary: "hover:bg-accent hover:text-accent-foreground",
|
|
189
184
|
},
|
|
190
185
|
color: {
|
|
191
186
|
primary: "",
|
|
@@ -194,171 +189,45 @@ const badgeVariants = classVarianceAuthority.cva("inline-flex items-center white
|
|
|
194
189
|
notice: "",
|
|
195
190
|
info: "",
|
|
196
191
|
neutral: "",
|
|
192
|
+
white: "",
|
|
197
193
|
},
|
|
198
194
|
size: {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
195
|
+
xsmall: "md:h-[28px] px-3 rounded-medium text-body-small-medium",
|
|
196
|
+
small: "md:h-[32px] px-4 rounded-medium text-body-small-medium",
|
|
197
|
+
medium: "md:h-[36px] px-5 py-2 rounded-large text-body-medium-medium",
|
|
198
|
+
large: "md:h-[44px] px-6 rounded-large text-body-large-medium",
|
|
199
|
+
},
|
|
200
|
+
isIconOnly: {
|
|
201
|
+
true: "aspect-square p-0",
|
|
202
|
+
false: "",
|
|
203
|
+
},
|
|
204
|
+
isLoading: {
|
|
205
|
+
true: "cursor-not-allowed",
|
|
206
|
+
false: "",
|
|
207
|
+
},
|
|
208
|
+
isDisabled: {
|
|
209
|
+
true: "cursor-not-allowed",
|
|
210
|
+
false: "cursor-pointer",
|
|
211
|
+
},
|
|
212
|
+
isFullWidth: {
|
|
213
|
+
true: "flex w-full",
|
|
214
|
+
false: "flex w-fit",
|
|
202
215
|
},
|
|
203
216
|
},
|
|
204
217
|
compoundVariants: [
|
|
205
|
-
//
|
|
218
|
+
// Primary variant colors
|
|
206
219
|
{
|
|
207
|
-
variant: "
|
|
220
|
+
variant: "primary",
|
|
208
221
|
color: "primary",
|
|
209
|
-
class:
|
|
222
|
+
class: `bg-action-fill-primary-default text-action-ink-on-primary-normal
|
|
223
|
+
hover:bg-action-fill-primary-hover
|
|
224
|
+
disabled:bg-action-fill-primary-disabled
|
|
225
|
+
disabled:text-action-ink-primary-disabled,
|
|
226
|
+
active:bg-action-fill-primary-activated
|
|
227
|
+
`,
|
|
210
228
|
},
|
|
211
229
|
{
|
|
212
|
-
variant: "
|
|
213
|
-
color: "positive",
|
|
214
|
-
class: "bg-action-fill-positive-faded text-action-ink-positive-normal",
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
variant: "light",
|
|
218
|
-
color: "negative",
|
|
219
|
-
class: "bg-action-fill-negative-faded text-action-ink-negative-normal",
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
variant: "light",
|
|
223
|
-
color: "notice",
|
|
224
|
-
class: "bg-action-fill-notice-faded text-action-ink-notice-normal",
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
variant: "light",
|
|
228
|
-
color: "info",
|
|
229
|
-
class: "bg-action-fill-info-faded text-action-ink-info-normal",
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
variant: "light",
|
|
233
|
-
color: "neutral",
|
|
234
|
-
class: "bg-action-fill-neutral-faded text-action-ink-neutral-normal",
|
|
235
|
-
},
|
|
236
|
-
// Filled variant colors
|
|
237
|
-
{
|
|
238
|
-
variant: "filled",
|
|
239
|
-
color: "primary",
|
|
240
|
-
class: "bg-action-fill-primary-default text-action-ink-on-primary-normal",
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
variant: "filled",
|
|
244
|
-
color: "positive",
|
|
245
|
-
class: "bg-action-fill-positive-default text-action-ink-on-primary-normal",
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
variant: "filled",
|
|
249
|
-
color: "negative",
|
|
250
|
-
class: "bg-action-fill-negative-default text-action-ink-on-primary-normal",
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
variant: "filled",
|
|
254
|
-
color: "notice",
|
|
255
|
-
class: "bg-action-fill-notice-default text-action-ink-on-primary-normal",
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
variant: "filled",
|
|
259
|
-
color: "info",
|
|
260
|
-
class: "bg-action-fill-info-default text-action-ink-on-primary-normal",
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
variant: "filled",
|
|
264
|
-
color: "neutral",
|
|
265
|
-
class: "bg-action-fill-neutral-default text-action-ink-on-primary-normal",
|
|
266
|
-
},
|
|
267
|
-
],
|
|
268
|
-
defaultVariants: {
|
|
269
|
-
variant: "light",
|
|
270
|
-
color: "info",
|
|
271
|
-
size: "medium",
|
|
272
|
-
},
|
|
273
|
-
});
|
|
274
|
-
const Badge = React__namespace.forwardRef(({ className, variant, size, color, showDot = false, children, ...props }, ref) => {
|
|
275
|
-
const getDotColor = () => {
|
|
276
|
-
if (variant === "filled") {
|
|
277
|
-
return "bg-action-ink-on-primary-normal";
|
|
278
|
-
}
|
|
279
|
-
// Light variant - use the corresponding action color
|
|
280
|
-
switch (color) {
|
|
281
|
-
case "primary":
|
|
282
|
-
return "bg-action-fill-primary-default";
|
|
283
|
-
case "positive":
|
|
284
|
-
return "bg-action-fill-positive-default";
|
|
285
|
-
case "negative":
|
|
286
|
-
return "bg-action-fill-negative-default";
|
|
287
|
-
case "notice":
|
|
288
|
-
return "bg-action-fill-notice-default";
|
|
289
|
-
case "info":
|
|
290
|
-
return "bg-action-fill-info-default";
|
|
291
|
-
case "neutral":
|
|
292
|
-
return "bg-action-fill-neutral-default";
|
|
293
|
-
default:
|
|
294
|
-
return "bg-action-fill-info-default";
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
const getDotSize = () => {
|
|
298
|
-
if (size === "small") {
|
|
299
|
-
return "h-2 w-2";
|
|
300
|
-
}
|
|
301
|
-
if (size === "medium") {
|
|
302
|
-
return "h-[6px] w-[6px]";
|
|
303
|
-
}
|
|
304
|
-
return "h-3 w-3";
|
|
305
|
-
};
|
|
306
|
-
return (jsxRuntime.jsxs("div", { ref: ref, className: cn(badgeVariants({ variant, size, color }), className), ...props, children: [showDot && (jsxRuntime.jsx("span", { className: cn("rounded-full", getDotColor(), getDotSize()), "aria-hidden": "true" })), children] }));
|
|
307
|
-
});
|
|
308
|
-
Badge.displayName = "Badge";
|
|
309
|
-
|
|
310
|
-
const buttonVariants = classVarianceAuthority.cva("items-center gap-3 justify-center whitespace-nowrap ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none", {
|
|
311
|
-
variants: {
|
|
312
|
-
variant: {
|
|
313
|
-
primary: "bg-action-fill-primary-default text-action-ink-on-primary-normal hover:bg-action-fill-primary-hover",
|
|
314
|
-
secondary: "border",
|
|
315
|
-
tertiary: "hover:bg-accent hover:text-accent-foreground",
|
|
316
|
-
},
|
|
317
|
-
color: {
|
|
318
|
-
primary: "",
|
|
319
|
-
positive: "",
|
|
320
|
-
negative: "",
|
|
321
|
-
notice: "",
|
|
322
|
-
info: "",
|
|
323
|
-
neutral: "",
|
|
324
|
-
},
|
|
325
|
-
size: {
|
|
326
|
-
xsmall: "md:h-[28px] px-3 rounded-medium text-body-small-medium",
|
|
327
|
-
small: "md:h-[32px] px-4 rounded-medium text-body-small-medium",
|
|
328
|
-
medium: "md:h-[36px] px-5 py-2 rounded-large text-body-medium-medium",
|
|
329
|
-
large: "md:h-[44px] px-6 rounded-large text-body-large-medium",
|
|
330
|
-
},
|
|
331
|
-
isIconOnly: {
|
|
332
|
-
true: "aspect-square p-0",
|
|
333
|
-
false: "",
|
|
334
|
-
},
|
|
335
|
-
isLoading: {
|
|
336
|
-
true: "cursor-not-allowed",
|
|
337
|
-
false: "",
|
|
338
|
-
},
|
|
339
|
-
isDisabled: {
|
|
340
|
-
true: "cursor-not-allowed",
|
|
341
|
-
false: "cursor-pointer",
|
|
342
|
-
},
|
|
343
|
-
isFullWidth: {
|
|
344
|
-
true: "flex w-full",
|
|
345
|
-
false: "flex w-fit",
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
compoundVariants: [
|
|
349
|
-
// Primary variant colors
|
|
350
|
-
{
|
|
351
|
-
variant: "primary",
|
|
352
|
-
color: "primary",
|
|
353
|
-
class: `bg-action-fill-primary-default text-action-ink-on-primary-normal
|
|
354
|
-
hover:bg-action-fill-primary-hover
|
|
355
|
-
disabled:bg-action-fill-primary-disabled
|
|
356
|
-
disabled:text-action-ink-primary-disabled,
|
|
357
|
-
active:bg-action-fill-primary-activated
|
|
358
|
-
`,
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
variant: "primary",
|
|
230
|
+
variant: "primary",
|
|
362
231
|
color: "positive",
|
|
363
232
|
class: `bg-action-fill-positive-default text-action-ink-on-primary-normal
|
|
364
233
|
hover:bg-action-fill-positive-hover
|
|
@@ -407,6 +276,16 @@ const buttonVariants = classVarianceAuthority.cva("items-center gap-3 justify-ce
|
|
|
407
276
|
active:bg-action-fill-neutral-activated
|
|
408
277
|
`,
|
|
409
278
|
},
|
|
279
|
+
{
|
|
280
|
+
variant: "primary",
|
|
281
|
+
color: "white",
|
|
282
|
+
class: `bg-action-fill-white-default text-action-ink-neutral-subtle
|
|
283
|
+
hover:bg-action-fill-white-hover
|
|
284
|
+
disabled:bg-action-fill-white-disabled
|
|
285
|
+
disabled:text-action-ink-neutral-disabled
|
|
286
|
+
active:bg-action-fill-white-activated
|
|
287
|
+
`,
|
|
288
|
+
},
|
|
410
289
|
// Secondary variant colors
|
|
411
290
|
{
|
|
412
291
|
variant: "secondary",
|
|
@@ -495,6 +374,19 @@ const buttonVariants = classVarianceAuthority.cva("items-center gap-3 justify-ce
|
|
|
495
374
|
active:bg-action-fill-neutral-faded-activated
|
|
496
375
|
`,
|
|
497
376
|
},
|
|
377
|
+
{
|
|
378
|
+
variant: "secondary",
|
|
379
|
+
color: "white",
|
|
380
|
+
class: `border-action-outline-white-faded
|
|
381
|
+
text-action-ink-on-primary-subtle
|
|
382
|
+
hover:border-action-outline-white-faded-hover
|
|
383
|
+
hover:bg-action-fill-white-faded-hover
|
|
384
|
+
disabled:text-surface-ink-white-disabled
|
|
385
|
+
disabled:border-action-outline-white-disabled
|
|
386
|
+
active:border-action-outline-white-faded-activated
|
|
387
|
+
active:bg-action-fill-white-faded-activated
|
|
388
|
+
`,
|
|
389
|
+
},
|
|
498
390
|
// Tertiary variant colors
|
|
499
391
|
{
|
|
500
392
|
variant: "tertiary",
|
|
@@ -550,6 +442,16 @@ const buttonVariants = classVarianceAuthority.cva("items-center gap-3 justify-ce
|
|
|
550
442
|
active:bg-action-fill-neutral-faded-activated
|
|
551
443
|
`,
|
|
552
444
|
},
|
|
445
|
+
{
|
|
446
|
+
variant: "tertiary",
|
|
447
|
+
color: "white",
|
|
448
|
+
class: `text-action-ink-white-subtle
|
|
449
|
+
hover:bg-action-white-faded-hover
|
|
450
|
+
disabled:text-action-ink-white-disabled
|
|
451
|
+
disabled:bg-action-fill-white-disabled
|
|
452
|
+
active:bg-action-white-faded-activated
|
|
453
|
+
`,
|
|
454
|
+
},
|
|
553
455
|
// Icon only sizing
|
|
554
456
|
{
|
|
555
457
|
isIconOnly: true,
|
|
@@ -584,7 +486,13 @@ const buttonVariants = classVarianceAuthority.cva("items-center gap-3 justify-ce
|
|
|
584
486
|
const Button = React__namespace.forwardRef(({ className, variant = "primary", color = "primary", size, isIconOnly, isLoading, asChild = false, leadingIcon, trailingIcon, isFullWidth = false, children, disabled, ...props }, ref) => {
|
|
585
487
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
586
488
|
const isDisabled = disabled || isLoading || false;
|
|
587
|
-
const
|
|
489
|
+
const getLoaderColor = () => {
|
|
490
|
+
if (color === "white") {
|
|
491
|
+
return "var(--color-surface-ink-neutral-normal)";
|
|
492
|
+
}
|
|
493
|
+
return `var(--color-action-ink-${color}-normal)`;
|
|
494
|
+
};
|
|
495
|
+
const buttonContent = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isLoading && !isIconOnly && (jsxRuntime.jsx(reactSpinners.PulseLoader, { color: getLoaderColor(), size: 10 })), isLoading && isIconOnly && (jsxRuntime.jsx(reactSpinners.ClipLoader, { color: getLoaderColor(), size: 20 })), !isLoading && leadingIcon && (jsxRuntime.jsx("span", { className: "mr-2", children: leadingIcon })), !isIconOnly && !isLoading && children, isIconOnly && !isLoading && children, !isLoading && trailingIcon && jsxRuntime.jsx("span", { children: trailingIcon })] }));
|
|
588
496
|
return (jsxRuntime.jsx(Comp, { className: cn(buttonVariants({
|
|
589
497
|
variant,
|
|
590
498
|
color,
|
|
@@ -595,7 +503,752 @@ const Button = React__namespace.forwardRef(({ className, variant = "primary", co
|
|
|
595
503
|
isFullWidth,
|
|
596
504
|
}), className), ref: ref, disabled: isDisabled, ...props, children: buttonContent }));
|
|
597
505
|
});
|
|
598
|
-
Button.displayName = "Button";
|
|
506
|
+
Button.displayName = "Button";
|
|
507
|
+
|
|
508
|
+
const iconButtonVariants = classVarianceAuthority.cva("inline-flex items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none p-0 border-0 bg-transparent", {
|
|
509
|
+
variants: {
|
|
510
|
+
color: {
|
|
511
|
+
primary: "",
|
|
512
|
+
positive: "",
|
|
513
|
+
negative: "",
|
|
514
|
+
notice: "",
|
|
515
|
+
info: "",
|
|
516
|
+
neutral: "",
|
|
517
|
+
white: "",
|
|
518
|
+
},
|
|
519
|
+
size: {
|
|
520
|
+
xsmall: "",
|
|
521
|
+
small: "",
|
|
522
|
+
medium: "",
|
|
523
|
+
large: "",
|
|
524
|
+
},
|
|
525
|
+
isLoading: {
|
|
526
|
+
true: "cursor-not-allowed",
|
|
527
|
+
false: "",
|
|
528
|
+
},
|
|
529
|
+
isDisabled: {
|
|
530
|
+
true: "cursor-not-allowed",
|
|
531
|
+
false: "cursor-pointer",
|
|
532
|
+
},
|
|
533
|
+
},
|
|
534
|
+
defaultVariants: {
|
|
535
|
+
color: "primary",
|
|
536
|
+
size: "medium",
|
|
537
|
+
isLoading: false,
|
|
538
|
+
},
|
|
539
|
+
});
|
|
540
|
+
const IconButton = React__namespace.forwardRef(({ className, color = "primary", size = "medium", isLoading, asChild = false, icon, iconElement, disabled, ...props }, ref) => {
|
|
541
|
+
const Comp = asChild ? reactSlot.Slot : "button";
|
|
542
|
+
const isDisabled = disabled || isLoading || false;
|
|
543
|
+
const getLoaderColor = () => {
|
|
544
|
+
if (color === "white") {
|
|
545
|
+
return "var(--color-surface-ink-neutral-normal)";
|
|
546
|
+
}
|
|
547
|
+
return `var(--color-action-ink-${color}-normal)`;
|
|
548
|
+
};
|
|
549
|
+
const getIconSize = () => {
|
|
550
|
+
switch (size) {
|
|
551
|
+
case "xsmall":
|
|
552
|
+
return 16;
|
|
553
|
+
case "small":
|
|
554
|
+
return 18;
|
|
555
|
+
case "medium":
|
|
556
|
+
return 20;
|
|
557
|
+
case "large":
|
|
558
|
+
return 24;
|
|
559
|
+
default:
|
|
560
|
+
return 20;
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
const getIconColorClass = () => {
|
|
564
|
+
// Color classes with normal, hover, focus, and disabled states
|
|
565
|
+
const colorMap = {
|
|
566
|
+
primary: "text-action-ink-primary-normal hover:text-action-ink-primary-subtle focus-visible:text-action-ink-primary-subtle disabled:text-action-ink-primary-muted",
|
|
567
|
+
positive: "text-action-ink-positive-normal hover:text-action-ink-positive-subtle focus-visible:text-action-ink-positive-subtle disabled:text-action-ink-positive-muted",
|
|
568
|
+
negative: "text-action-ink-negative-normal hover:text-action-ink-negative-subtle focus-visible:text-action-ink-negative-subtle disabled:text-action-ink-negative-muted",
|
|
569
|
+
notice: "text-action-ink-notice-normal hover:text-action-ink-notice-subtle focus-visible:text-action-ink-notice-subtle disabled:text-action-ink-notice-muted",
|
|
570
|
+
info: "text-action-ink-info-normal hover:text-action-ink-info-subtle focus-visible:text-action-ink-info-subtle disabled:text-action-ink-info-muted",
|
|
571
|
+
neutral: "text-action-ink-neutral-normal hover:text-action-ink-neutral-subtle focus-visible:text-action-ink-neutral-subtle disabled:text-action-ink-neutral-muted",
|
|
572
|
+
white: "text-surface-ink-white-subtle hover:text-surface-ink-white-normal focus-visible:text-surface-ink-white-normal disabled:text-surface-ink-white-muted",
|
|
573
|
+
};
|
|
574
|
+
return colorMap[color] || colorMap.primary;
|
|
575
|
+
};
|
|
576
|
+
const buttonContent = (jsxRuntime.jsx(jsxRuntime.Fragment, { children: isLoading ? (jsxRuntime.jsx(reactSpinners.ClipLoader, { color: getLoaderColor(), size: getIconSize() })) : icon ? (jsxRuntime.jsx(Icon, { name: icon, size: getIconSize(), className: getIconColorClass() })) : iconElement ? (jsxRuntime.jsx("span", { className: getIconColorClass(), children: iconElement })) : null }));
|
|
577
|
+
return (jsxRuntime.jsx(Comp, { className: cn(iconButtonVariants({
|
|
578
|
+
color,
|
|
579
|
+
size,
|
|
580
|
+
isLoading,
|
|
581
|
+
isDisabled,
|
|
582
|
+
}), className), ref: ref, disabled: isDisabled, ...props, children: buttonContent }));
|
|
583
|
+
});
|
|
584
|
+
IconButton.displayName = "IconButton";
|
|
585
|
+
|
|
586
|
+
const linkVariants = classVarianceAuthority.cva("inline-flex items-center gap-1 whitespace-nowrap transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none decoration-1 underline-offset-4", {
|
|
587
|
+
variants: {
|
|
588
|
+
type: {
|
|
589
|
+
anchor: "hover:underline",
|
|
590
|
+
action: "no-underline cursor-pointer",
|
|
591
|
+
},
|
|
592
|
+
color: {
|
|
593
|
+
primary: "",
|
|
594
|
+
positive: "",
|
|
595
|
+
negative: "",
|
|
596
|
+
notice: "",
|
|
597
|
+
info: "",
|
|
598
|
+
neutral: "",
|
|
599
|
+
white: "",
|
|
600
|
+
},
|
|
601
|
+
size: {
|
|
602
|
+
xsmall: "text-body-xsmall-medium gap-1",
|
|
603
|
+
small: "text-body-small-medium gap-1",
|
|
604
|
+
medium: "text-body-medium-medium gap-1.5",
|
|
605
|
+
large: "text-body-large-medium gap-1.5",
|
|
606
|
+
},
|
|
607
|
+
isIconOnly: {
|
|
608
|
+
true: "no-underline",
|
|
609
|
+
false: "",
|
|
610
|
+
},
|
|
611
|
+
isDisabled: {
|
|
612
|
+
true: "cursor-not-allowed opacity-50",
|
|
613
|
+
false: "cursor-pointer",
|
|
614
|
+
},
|
|
615
|
+
},
|
|
616
|
+
compoundVariants: [
|
|
617
|
+
// Primary color variants
|
|
618
|
+
{
|
|
619
|
+
color: "primary",
|
|
620
|
+
class: `text-action-ink-primary-normal
|
|
621
|
+
hover:text-action-ink-primary-subtle
|
|
622
|
+
hover:decoration-action-outline-primary-hover
|
|
623
|
+
disabled:text-action-ink-primary-disabled
|
|
624
|
+
focus:text-action-ink-primary-hover
|
|
625
|
+
`,
|
|
626
|
+
},
|
|
627
|
+
// Positive color variants
|
|
628
|
+
{
|
|
629
|
+
color: "positive",
|
|
630
|
+
class: `text-action-ink-positive-normal
|
|
631
|
+
hover:text-action-ink-positive-subtle
|
|
632
|
+
hover:decoration-action-outline-positive-hover
|
|
633
|
+
hover:text-action-ink-positive-hover
|
|
634
|
+
disabled:text-action-ink-positive-disabled
|
|
635
|
+
focus:text-action-ink-positive-hover
|
|
636
|
+
`,
|
|
637
|
+
},
|
|
638
|
+
// Negative color variants
|
|
639
|
+
{
|
|
640
|
+
color: "negative",
|
|
641
|
+
class: `text-action-ink-negative-normal
|
|
642
|
+
hover:text-action-ink-negative-subtle
|
|
643
|
+
hover:decoration-action-outline-negative-hover
|
|
644
|
+
hover:text-action-ink-negative-hover
|
|
645
|
+
disabled:text-action-ink-negative-disabled
|
|
646
|
+
focus:text-action-ink-negative-hover
|
|
647
|
+
`,
|
|
648
|
+
},
|
|
649
|
+
// Notice color variants
|
|
650
|
+
{
|
|
651
|
+
color: "notice",
|
|
652
|
+
class: `text-action-ink-notice-normal
|
|
653
|
+
hover:text-action-ink-notice-subtle
|
|
654
|
+
hover:decoration-action-outline-notice-hover
|
|
655
|
+
hover:text-action-ink-notice-hover
|
|
656
|
+
disabled:text-action-ink-notice-disabled
|
|
657
|
+
focus:text-action-ink-notice-hover
|
|
658
|
+
`,
|
|
659
|
+
},
|
|
660
|
+
// Info color variants
|
|
661
|
+
{
|
|
662
|
+
color: "info",
|
|
663
|
+
class: `text-action-ink-info-normal
|
|
664
|
+
hover:text-action-ink-info-subtle
|
|
665
|
+
hover:decoration-action-outline-info-hover
|
|
666
|
+
hover:text-action-ink-info-hover
|
|
667
|
+
disabled:text-action-ink-info-disabled
|
|
668
|
+
focus:text-action-ink-info-hover
|
|
669
|
+
`,
|
|
670
|
+
},
|
|
671
|
+
// Neutral color variants
|
|
672
|
+
{
|
|
673
|
+
color: "neutral",
|
|
674
|
+
class: `text-action-ink-neutral-normal
|
|
675
|
+
hover:text-action-ink-neutral-subtle
|
|
676
|
+
hover:decoration-action-outline-neutral-hover
|
|
677
|
+
hover:text-action-ink-neutral-hover
|
|
678
|
+
disabled:text-action-ink-neutral-disabled
|
|
679
|
+
focus:text-action-ink-neutral-hover
|
|
680
|
+
`,
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
color: "white",
|
|
684
|
+
class: `text-action-ink-white-subtle
|
|
685
|
+
hover:text-action-ink-white-subtle
|
|
686
|
+
hover:decoration-action-outline-white-hover
|
|
687
|
+
hover:text-action-ink-white-hover
|
|
688
|
+
disabled:text-action-ink-white-disabled
|
|
689
|
+
focus:text-action-ink-white-hover
|
|
690
|
+
`,
|
|
691
|
+
},
|
|
692
|
+
],
|
|
693
|
+
defaultVariants: {
|
|
694
|
+
type: "anchor",
|
|
695
|
+
color: "primary",
|
|
696
|
+
size: "medium",
|
|
697
|
+
isIconOnly: false,
|
|
698
|
+
isDisabled: false,
|
|
699
|
+
},
|
|
700
|
+
});
|
|
701
|
+
const Link = React__namespace.forwardRef(({ className, type = "anchor", color = "primary", size = "medium", isIconOnly = false, isDisabled = false, asChild = false, showIcon = false, icon, leadingIcon, trailingIcon, children, onClick, ...props }, ref) => {
|
|
702
|
+
const Comp = asChild ? reactSlot.Slot : "a";
|
|
703
|
+
const handleClick = (e) => {
|
|
704
|
+
if (isDisabled) {
|
|
705
|
+
e.preventDefault();
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
onClick?.(e);
|
|
709
|
+
};
|
|
710
|
+
// Icon size based on link size
|
|
711
|
+
const iconSize = {
|
|
712
|
+
xsmall: 12,
|
|
713
|
+
small: 14,
|
|
714
|
+
medium: 16,
|
|
715
|
+
large: 18,
|
|
716
|
+
}[size];
|
|
717
|
+
// Determine what to show as trailing icon
|
|
718
|
+
// Priority: trailingIcon > (showIcon && icon) > (showIcon && default ExternalLink)
|
|
719
|
+
const finalTrailingIcon = trailingIcon || (showIcon && (icon || jsxRuntime.jsx(lucideReact.ExternalLink, { size: iconSize })));
|
|
720
|
+
const linkContent = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [leadingIcon && !isIconOnly && (jsxRuntime.jsx("span", { className: "inline-flex items-center", children: leadingIcon })), !isIconOnly && children, isIconOnly && children, finalTrailingIcon && !isIconOnly && (jsxRuntime.jsx("span", { className: "inline-flex items-center", children: finalTrailingIcon })), isIconOnly &&
|
|
721
|
+
(leadingIcon || finalTrailingIcon || (jsxRuntime.jsx(lucideReact.ExternalLink, { size: iconSize })))] }));
|
|
722
|
+
return (jsxRuntime.jsx(Comp, { className: cn(linkVariants({
|
|
723
|
+
type,
|
|
724
|
+
color,
|
|
725
|
+
size,
|
|
726
|
+
isIconOnly,
|
|
727
|
+
isDisabled,
|
|
728
|
+
}), className), ref: ref, onClick: handleClick, "aria-disabled": isDisabled, tabIndex: isDisabled ? -1 : undefined, ...props, children: linkContent }));
|
|
729
|
+
});
|
|
730
|
+
Link.displayName = "Link";
|
|
731
|
+
|
|
732
|
+
const alertVariants = classVarianceAuthority.cva("relative flex gap-4 p-4 rounded-large transition-colors", {
|
|
733
|
+
variants: {
|
|
734
|
+
emphasis: {
|
|
735
|
+
subtle: "",
|
|
736
|
+
intense: "",
|
|
737
|
+
},
|
|
738
|
+
intent: {
|
|
739
|
+
positive: "",
|
|
740
|
+
negative: "",
|
|
741
|
+
notice: "",
|
|
742
|
+
info: "",
|
|
743
|
+
neutral: "",
|
|
744
|
+
},
|
|
745
|
+
},
|
|
746
|
+
compoundVariants: [
|
|
747
|
+
// Subtle emphasis
|
|
748
|
+
{
|
|
749
|
+
emphasis: "subtle",
|
|
750
|
+
intent: "positive",
|
|
751
|
+
class: "bg-feedback-fill-positive-subtle",
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
emphasis: "subtle",
|
|
755
|
+
intent: "negative",
|
|
756
|
+
class: "bg-feedback-fill-negative-subtle",
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
emphasis: "subtle",
|
|
760
|
+
intent: "notice",
|
|
761
|
+
class: "bg-feedback-fill-notice-subtle",
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
emphasis: "subtle",
|
|
765
|
+
intent: "info",
|
|
766
|
+
class: "bg-feedback-fill-info-subtle",
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
emphasis: "subtle",
|
|
770
|
+
intent: "neutral",
|
|
771
|
+
class: "bg-feedback-fill-neutral-subtle",
|
|
772
|
+
},
|
|
773
|
+
// Intense emphasis
|
|
774
|
+
{
|
|
775
|
+
emphasis: "intense",
|
|
776
|
+
intent: "positive",
|
|
777
|
+
class: "bg-feedback-fill-positive-intense",
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
emphasis: "intense",
|
|
781
|
+
intent: "negative",
|
|
782
|
+
class: "bg-feedback-fill-negative-intense",
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
emphasis: "intense",
|
|
786
|
+
intent: "notice",
|
|
787
|
+
class: "bg-feedback-fill-notice-intense",
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
emphasis: "intense",
|
|
791
|
+
intent: "info",
|
|
792
|
+
class: "bg-feedback-fill-info-intense",
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
emphasis: "intense",
|
|
796
|
+
intent: "neutral",
|
|
797
|
+
class: "bg-feedback-fill-neutral-intense",
|
|
798
|
+
},
|
|
799
|
+
],
|
|
800
|
+
defaultVariants: {
|
|
801
|
+
emphasis: "subtle",
|
|
802
|
+
intent: "info",
|
|
803
|
+
},
|
|
804
|
+
});
|
|
805
|
+
const alertIconVariants = classVarianceAuthority.cva("flex-shrink-0 rounded-full flex items-center justify-center mt-1", {
|
|
806
|
+
variants: {
|
|
807
|
+
emphasis: {
|
|
808
|
+
subtle: "",
|
|
809
|
+
intense: "text-white",
|
|
810
|
+
},
|
|
811
|
+
intent: {
|
|
812
|
+
positive: "",
|
|
813
|
+
negative: "",
|
|
814
|
+
notice: "",
|
|
815
|
+
info: "",
|
|
816
|
+
neutral: "",
|
|
817
|
+
},
|
|
818
|
+
},
|
|
819
|
+
compoundVariants: [
|
|
820
|
+
// Subtle emphasis - colored backgrounds with white icons
|
|
821
|
+
{
|
|
822
|
+
emphasis: "subtle",
|
|
823
|
+
intent: "positive",
|
|
824
|
+
class: "text-action-ink-positive-normal",
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
emphasis: "subtle",
|
|
828
|
+
intent: "negative",
|
|
829
|
+
class: " text-action-ink-negative-normal",
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
emphasis: "subtle",
|
|
833
|
+
intent: "notice",
|
|
834
|
+
class: " text-action-ink-notice-normal",
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
emphasis: "subtle",
|
|
838
|
+
intent: "info",
|
|
839
|
+
class: " text-action-ink-info-normal",
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
emphasis: "subtle",
|
|
843
|
+
intent: "neutral",
|
|
844
|
+
class: " text-action-ink-neutral-normal",
|
|
845
|
+
},
|
|
846
|
+
// Intense emphasis - white backgrounds with colored icons
|
|
847
|
+
{
|
|
848
|
+
emphasis: "intense",
|
|
849
|
+
intent: "positive",
|
|
850
|
+
class: " text-action-ink-on-primary-normal",
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
emphasis: "intense",
|
|
854
|
+
intent: "negative",
|
|
855
|
+
class: " text-action-ink-on-primary-normal",
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
emphasis: "intense",
|
|
859
|
+
intent: "notice",
|
|
860
|
+
class: " text-action-ink-on-primary-normal",
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
emphasis: "intense",
|
|
864
|
+
intent: "info",
|
|
865
|
+
class: " text-action-fill-info-default",
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
emphasis: "intense",
|
|
869
|
+
intent: "neutral",
|
|
870
|
+
class: " text-action-fill-neutral-default",
|
|
871
|
+
},
|
|
872
|
+
],
|
|
873
|
+
defaultVariants: {
|
|
874
|
+
emphasis: "subtle",
|
|
875
|
+
intent: "info",
|
|
876
|
+
},
|
|
877
|
+
});
|
|
878
|
+
const alertTextVariants = classVarianceAuthority.cva("", {
|
|
879
|
+
variants: {
|
|
880
|
+
emphasis: {
|
|
881
|
+
subtle: "",
|
|
882
|
+
intense: "",
|
|
883
|
+
},
|
|
884
|
+
intent: {
|
|
885
|
+
positive: "",
|
|
886
|
+
negative: "",
|
|
887
|
+
notice: "",
|
|
888
|
+
info: "",
|
|
889
|
+
neutral: "",
|
|
890
|
+
},
|
|
891
|
+
},
|
|
892
|
+
compoundVariants: [
|
|
893
|
+
// Subtle emphasis - dark text
|
|
894
|
+
{
|
|
895
|
+
emphasis: "subtle",
|
|
896
|
+
intent: "positive",
|
|
897
|
+
class: "text-surface-ink-neutral-normal",
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
emphasis: "subtle",
|
|
901
|
+
intent: "negative",
|
|
902
|
+
class: "text-surface-ink-neutral-normal",
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
emphasis: "subtle",
|
|
906
|
+
intent: "notice",
|
|
907
|
+
class: "text-surface-ink-neutral-normal",
|
|
908
|
+
},
|
|
909
|
+
{
|
|
910
|
+
emphasis: "subtle",
|
|
911
|
+
intent: "info",
|
|
912
|
+
class: "text-surface-ink-neutral-normal",
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
emphasis: "subtle",
|
|
916
|
+
intent: "neutral",
|
|
917
|
+
class: "text-surface-ink-neutral-normal",
|
|
918
|
+
},
|
|
919
|
+
// Intense emphasis - white text
|
|
920
|
+
{
|
|
921
|
+
emphasis: "intense",
|
|
922
|
+
intent: "positive",
|
|
923
|
+
class: "text-action-ink-on-primary-normal",
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
emphasis: "intense",
|
|
927
|
+
intent: "negative",
|
|
928
|
+
class: "text-action-ink-on-primary-normal",
|
|
929
|
+
},
|
|
930
|
+
{
|
|
931
|
+
emphasis: "intense",
|
|
932
|
+
intent: "notice",
|
|
933
|
+
class: "text-action-ink-on-primary-normal",
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
emphasis: "intense",
|
|
937
|
+
intent: "info",
|
|
938
|
+
class: "text-action-ink-on-primary-normal",
|
|
939
|
+
},
|
|
940
|
+
{
|
|
941
|
+
emphasis: "intense",
|
|
942
|
+
intent: "neutral",
|
|
943
|
+
class: "text-action-ink-on-primary-normal",
|
|
944
|
+
},
|
|
945
|
+
],
|
|
946
|
+
defaultVariants: {
|
|
947
|
+
emphasis: "subtle",
|
|
948
|
+
intent: "info",
|
|
949
|
+
},
|
|
950
|
+
});
|
|
951
|
+
const getDefaultIcon = (intent, emphasis) => {
|
|
952
|
+
const iconSize = 16;
|
|
953
|
+
switch (emphasis) {
|
|
954
|
+
case "intense":
|
|
955
|
+
return (jsxRuntime.jsx(Icon, { name: "info", size: iconSize, className: "text-white", "aria-hidden": "true" }));
|
|
956
|
+
default:
|
|
957
|
+
return jsxRuntime.jsx(Icon, { name: "info", size: iconSize, "aria-hidden": "true" });
|
|
958
|
+
}
|
|
959
|
+
};
|
|
960
|
+
const getButtonColor = (intent) => {
|
|
961
|
+
switch (intent) {
|
|
962
|
+
case "positive":
|
|
963
|
+
return "positive";
|
|
964
|
+
case "negative":
|
|
965
|
+
return "negative";
|
|
966
|
+
case "notice":
|
|
967
|
+
return "notice";
|
|
968
|
+
case "info":
|
|
969
|
+
return "info";
|
|
970
|
+
case "neutral":
|
|
971
|
+
return "neutral";
|
|
972
|
+
default:
|
|
973
|
+
return "neutral";
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
const getActionButton = (actionButtonText, onActionButtonClick, emphasis, intent) => {
|
|
977
|
+
if (!actionButtonText)
|
|
978
|
+
return null;
|
|
979
|
+
// For intense emphasis: secondary variant with white border and white text
|
|
980
|
+
// For subtle emphasis: secondary variant with colored border and colored text (default behavior)
|
|
981
|
+
if (emphasis === "intense") {
|
|
982
|
+
return (jsxRuntime.jsx(Button, { variant: "secondary", color: "white", size: "small", onClick: onActionButtonClick, children: actionButtonText }));
|
|
983
|
+
}
|
|
984
|
+
// Subtle emphasis: use default secondary variant styling
|
|
985
|
+
return (jsxRuntime.jsx(Button, { variant: "secondary", color: intent, size: "small", onClick: onActionButtonClick, children: actionButtonText }));
|
|
986
|
+
};
|
|
987
|
+
const getActionLink = (actionButtonText, onActionLinkClick, emphasis, intent) => {
|
|
988
|
+
if (!actionButtonText)
|
|
989
|
+
return null;
|
|
990
|
+
// For intense emphasis: secondary variant with white border and white text
|
|
991
|
+
// For subtle emphasis: secondary variant with colored border and colored text (default behavior)
|
|
992
|
+
if (emphasis === "intense") {
|
|
993
|
+
return (jsxRuntime.jsx(Link, { type: "action", color: "white", size: "small", onClick: onActionLinkClick, children: actionButtonText }));
|
|
994
|
+
}
|
|
995
|
+
// Subtle emphasis: use default secondary variant styling
|
|
996
|
+
return (jsxRuntime.jsx(Link, { type: "action", color: intent, size: "small", onClick: onActionLinkClick, children: actionButtonText }));
|
|
997
|
+
};
|
|
998
|
+
const Alert = React__namespace.forwardRef(({ className, emphasis = "subtle", intent = "info", title, children, isFullWidth = false, onClose, icon, actionButtonText, onActionButtonClick, actionLinkText, onActionLinkClick, ...props }, ref) => {
|
|
999
|
+
const displayIcon = icon ?? getDefaultIcon(intent, emphasis);
|
|
1000
|
+
const actionButton = getActionButton(actionButtonText, onActionButtonClick, emphasis, intent);
|
|
1001
|
+
const actionLink = getActionLink(actionLinkText, onActionLinkClick, emphasis, intent);
|
|
1002
|
+
const hasActions = actionButton || actionLink;
|
|
1003
|
+
return (jsxRuntime.jsxs("div", { ref: ref, className: cn(alertVariants({ emphasis, intent }), className), role: "alert", ...props, children: [jsxRuntime.jsx("div", { className: cn(alertIconVariants({ emphasis, intent }), "h-5 w-5 shrink-0"), children: displayIcon }), isFullWidth ? (
|
|
1004
|
+
/* Full Width Layout: Icon, Content, Actions/Close in one row */
|
|
1005
|
+
jsxRuntime.jsxs("div", { className: "flex-1 min-w-0 flex items-center justify-between gap-4", children: [jsxRuntime.jsxs("div", { className: "flex-1 min-w-0 flex flex-col gap-1", children: [title && (jsxRuntime.jsx("div", { className: cn("text-body-medium-semibold", alertTextVariants({ emphasis, intent })), children: title })), jsxRuntime.jsx("div", { className: cn("text-body-small-regular", alertTextVariants({ emphasis, intent })), children: children })] }), jsxRuntime.jsxs("div", { className: "flex items-center gap-3 shrink-0", children: [hasActions && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [actionButton, actionLink] })), onClose && (jsxRuntime.jsx(IconButton, { icon: "close", color: emphasis === "intense" ? "white" : getButtonColor(intent), size: "xsmall", onClick: onClose, className: cn("shrink-0 h-5 w-5", emphasis === "intense"
|
|
1006
|
+
? "hover:bg-white/20"
|
|
1007
|
+
: "hover:bg-black/10"), "aria-label": "Close alert" }))] })] })) : (
|
|
1008
|
+
/* Not Full Width Layout: Icon and Content in row, Actions below, Close top-right */
|
|
1009
|
+
jsxRuntime.jsxs("div", { className: "flex-1 min-w-0 relative", children: [onClose && (jsxRuntime.jsx("div", { className: "absolute top-0 right-0", children: jsxRuntime.jsx(IconButton, { icon: "close", color: emphasis === "intense" ? "white" : getButtonColor(intent), size: "xsmall", onClick: onClose, className: cn("shrink-0 h-5 w-5", emphasis === "intense"
|
|
1010
|
+
? "hover:bg-white/20"
|
|
1011
|
+
: "hover:bg-black/10"), "aria-label": "Close alert" }) })), jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 pr-8", children: [title && (jsxRuntime.jsx("div", { className: cn("text-body-medium-semibold", alertTextVariants({ emphasis, intent })), children: title })), jsxRuntime.jsx("div", { className: cn("text-body-small-regular", alertTextVariants({ emphasis, intent })), children: children }), hasActions && (jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [actionButton, actionLink] }))] })] }))] }));
|
|
1012
|
+
});
|
|
1013
|
+
Alert.displayName = "Alert";
|
|
1014
|
+
|
|
1015
|
+
// Helper function to get the text utility class name
|
|
1016
|
+
function getTextClassName(variant = "body", size = "medium", weight = "regular", color = "default") {
|
|
1017
|
+
// Build the base class name
|
|
1018
|
+
let baseClass = `text-${variant}`;
|
|
1019
|
+
// Add size
|
|
1020
|
+
if (size) {
|
|
1021
|
+
baseClass += `-${size}`;
|
|
1022
|
+
}
|
|
1023
|
+
// Add weight
|
|
1024
|
+
if (weight) {
|
|
1025
|
+
baseClass += `-${weight}`;
|
|
1026
|
+
}
|
|
1027
|
+
// Add color class separately
|
|
1028
|
+
const colorClass = `text-color-${color}`;
|
|
1029
|
+
return `${baseClass} ${colorClass}`;
|
|
1030
|
+
}
|
|
1031
|
+
const Text = React__namespace.forwardRef(({ className, variant = "body", size = "medium", weight = "regular", color = "default", as = "p", children, ...props }, ref) => {
|
|
1032
|
+
const Component = as;
|
|
1033
|
+
const textClass = getTextClassName(variant, size, weight, color);
|
|
1034
|
+
return React__namespace.createElement(Component, {
|
|
1035
|
+
className: cn(textClass, className),
|
|
1036
|
+
ref,
|
|
1037
|
+
...props,
|
|
1038
|
+
}, children);
|
|
1039
|
+
});
|
|
1040
|
+
Text.displayName = "Text";
|
|
1041
|
+
|
|
1042
|
+
const inverseColorClasses = {
|
|
1043
|
+
a1: "bg-avatar-fill-a1-on-bg text-avatar-fill-a1-bg",
|
|
1044
|
+
a2: "bg-avatar-fill-a2-on-bg text-avatar-fill-a2-bg",
|
|
1045
|
+
a3: "bg-avatar-fill-a3-on-bg text-avatar-fill-a3-bg",
|
|
1046
|
+
a4: "bg-avatar-fill-a4-on-bg text-avatar-fill-a4-bg",
|
|
1047
|
+
a5: "bg-avatar-fill-a5-on-bg text-avatar-fill-a5-bg",
|
|
1048
|
+
};
|
|
1049
|
+
const avatarVariants = classVarianceAuthority.cva("inline-flex items-center justify-center font-medium text-center select-none", {
|
|
1050
|
+
variants: {
|
|
1051
|
+
color: {
|
|
1052
|
+
a1: "bg-avatar-fill-a1-bg text-avatar-fill-a1-on-bg",
|
|
1053
|
+
a2: "bg-avatar-fill-a2-bg text-avatar-fill-a2-on-bg",
|
|
1054
|
+
a3: "bg-avatar-fill-a3-bg text-avatar-fill-a3-on-bg",
|
|
1055
|
+
a4: "bg-avatar-fill-a4-bg text-avatar-fill-a4-on-bg",
|
|
1056
|
+
a5: "bg-avatar-fill-a5-bg text-avatar-fill-a5-on-bg",
|
|
1057
|
+
},
|
|
1058
|
+
size: {
|
|
1059
|
+
small: "h-[24px] w-[24px] text-body-medium-regular rounded-large",
|
|
1060
|
+
medium: "h-[32px] w-[32px] text-body-medium-regular rounded-xlarge",
|
|
1061
|
+
xlarge: "h-[36px] w-[36px] text-body-medium-regular rounded-xlarge",
|
|
1062
|
+
},
|
|
1063
|
+
},
|
|
1064
|
+
defaultVariants: {
|
|
1065
|
+
color: "a1",
|
|
1066
|
+
size: "medium",
|
|
1067
|
+
},
|
|
1068
|
+
});
|
|
1069
|
+
const statusVariants = classVarianceAuthority.cva("absolute flex items-center justify-center rounded-full border-2 border-surface-fill-neutral-intense", {
|
|
1070
|
+
variants: {
|
|
1071
|
+
size: {
|
|
1072
|
+
small: "h-5 w-5 -bottom-0.5 -right-0.5",
|
|
1073
|
+
medium: "h-6 w-6 -bottom-1 -right-1",
|
|
1074
|
+
xlarge: "h-6 w-6 -bottom-1 -right-1",
|
|
1075
|
+
},
|
|
1076
|
+
statusColor: {
|
|
1077
|
+
positive: "bg-action-fill-positive-default",
|
|
1078
|
+
negative: "bg-action-fill-negative-default",
|
|
1079
|
+
notice: "bg-action-fill-notice-default",
|
|
1080
|
+
info: "bg-action-fill-info-default",
|
|
1081
|
+
neutral: "bg-action-fill-neutral-default",
|
|
1082
|
+
},
|
|
1083
|
+
},
|
|
1084
|
+
defaultVariants: {
|
|
1085
|
+
size: "medium",
|
|
1086
|
+
statusColor: "notice",
|
|
1087
|
+
},
|
|
1088
|
+
});
|
|
1089
|
+
const Avatar = React__namespace.forwardRef(({ className, appearance = "default", color, size, children, src, alt, showStatus = false, statusColor = "notice", statusIcon, label, trailingComponent, containerClassName, ...props }, ref) => {
|
|
1090
|
+
const [imageError, setImageError] = React__namespace.useState(false);
|
|
1091
|
+
const handleImageError = () => {
|
|
1092
|
+
setImageError(true);
|
|
1093
|
+
};
|
|
1094
|
+
const getStatusIconSize = () => {
|
|
1095
|
+
switch (size) {
|
|
1096
|
+
case "small":
|
|
1097
|
+
return "h-3.5 w-3.5";
|
|
1098
|
+
case "medium":
|
|
1099
|
+
return "h-4 w-4";
|
|
1100
|
+
default:
|
|
1101
|
+
return "h-4 w-4";
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
const getTextSize = () => {
|
|
1105
|
+
switch (size) {
|
|
1106
|
+
case "small":
|
|
1107
|
+
return "small";
|
|
1108
|
+
case "medium":
|
|
1109
|
+
return "medium";
|
|
1110
|
+
default:
|
|
1111
|
+
return "medium";
|
|
1112
|
+
}
|
|
1113
|
+
};
|
|
1114
|
+
const resolvedColor = color ?? "a1";
|
|
1115
|
+
const avatarElement = (jsxRuntime.jsxs("div", { className: "relative inline-block", children: [jsxRuntime.jsx("div", { className: cn(avatarVariants({ color: resolvedColor, size }), appearance === "inverse"
|
|
1116
|
+
? inverseColorClasses[resolvedColor]
|
|
1117
|
+
: undefined, className), ...props, children: src && !imageError ? (jsxRuntime.jsx("img", { src: src, alt: alt || "Avatar", className: cn("h-full w-full object-cover", size === "small" ? "rounded-large" : "rounded-xlarge"), onError: handleImageError })) : (children) }), showStatus && (jsxRuntime.jsx("div", { className: cn(statusVariants({ size, statusColor })), children: statusIcon && (jsxRuntime.jsx("span", { className: cn("text-action-ink-on-primary-normal", getStatusIconSize()), children: statusIcon })) }))] }));
|
|
1118
|
+
// If no label or trailing component, return just the avatar
|
|
1119
|
+
if (!label && !trailingComponent) {
|
|
1120
|
+
return jsxRuntime.jsx("div", { ref: ref, children: avatarElement });
|
|
1121
|
+
}
|
|
1122
|
+
// Otherwise, return avatar with label and/or trailing component
|
|
1123
|
+
return (jsxRuntime.jsxs("div", { ref: ref, className: cn("inline-flex items-center gap-3", containerClassName), children: [avatarElement, label && (jsxRuntime.jsx(Text, { variant: "body", size: getTextSize(), weight: "medium", color: "default", as: "span", children: label })), trailingComponent && (jsxRuntime.jsx("span", { className: "ml-auto", children: trailingComponent }))] }));
|
|
1124
|
+
});
|
|
1125
|
+
Avatar.displayName = "Avatar";
|
|
1126
|
+
|
|
1127
|
+
const badgeVariants = classVarianceAuthority.cva("inline-flex items-center whitespace-nowrap transition-colors", {
|
|
1128
|
+
variants: {
|
|
1129
|
+
variant: {
|
|
1130
|
+
light: "",
|
|
1131
|
+
filled: "",
|
|
1132
|
+
},
|
|
1133
|
+
color: {
|
|
1134
|
+
primary: "",
|
|
1135
|
+
positive: "",
|
|
1136
|
+
negative: "",
|
|
1137
|
+
notice: "",
|
|
1138
|
+
info: "",
|
|
1139
|
+
neutral: "",
|
|
1140
|
+
},
|
|
1141
|
+
size: {
|
|
1142
|
+
small: "px-2 h-[var(--size-20)] gap-2 rounded-large text-body-small-medium",
|
|
1143
|
+
medium: "px-3 h-[var(--size-24)] gap-3 rounded-large text-body-medium-medium",
|
|
1144
|
+
large: "px-4 h-[var(--size-28)] gap-3 rounded-xlarge text-body-large-medium",
|
|
1145
|
+
},
|
|
1146
|
+
},
|
|
1147
|
+
compoundVariants: [
|
|
1148
|
+
// Light variant colors
|
|
1149
|
+
{
|
|
1150
|
+
variant: "light",
|
|
1151
|
+
color: "primary",
|
|
1152
|
+
class: "bg-action-fill-primary-faded text-action-ink-primary-normal",
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
variant: "light",
|
|
1156
|
+
color: "positive",
|
|
1157
|
+
class: "bg-action-fill-positive-faded text-action-ink-positive-normal",
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
variant: "light",
|
|
1161
|
+
color: "negative",
|
|
1162
|
+
class: "bg-action-fill-negative-faded text-action-ink-negative-normal",
|
|
1163
|
+
},
|
|
1164
|
+
{
|
|
1165
|
+
variant: "light",
|
|
1166
|
+
color: "notice",
|
|
1167
|
+
class: "bg-action-fill-notice-faded text-action-ink-notice-normal",
|
|
1168
|
+
},
|
|
1169
|
+
{
|
|
1170
|
+
variant: "light",
|
|
1171
|
+
color: "info",
|
|
1172
|
+
class: "bg-action-fill-info-faded text-action-ink-info-normal",
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
variant: "light",
|
|
1176
|
+
color: "neutral",
|
|
1177
|
+
class: "bg-action-fill-neutral-faded text-action-ink-neutral-normal",
|
|
1178
|
+
},
|
|
1179
|
+
// Filled variant colors
|
|
1180
|
+
{
|
|
1181
|
+
variant: "filled",
|
|
1182
|
+
color: "primary",
|
|
1183
|
+
class: "bg-action-fill-primary-default text-action-ink-on-primary-normal",
|
|
1184
|
+
},
|
|
1185
|
+
{
|
|
1186
|
+
variant: "filled",
|
|
1187
|
+
color: "positive",
|
|
1188
|
+
class: "bg-action-fill-positive-default text-action-ink-on-primary-normal",
|
|
1189
|
+
},
|
|
1190
|
+
{
|
|
1191
|
+
variant: "filled",
|
|
1192
|
+
color: "negative",
|
|
1193
|
+
class: "bg-action-fill-negative-default text-action-ink-on-primary-normal",
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
variant: "filled",
|
|
1197
|
+
color: "notice",
|
|
1198
|
+
class: "bg-action-fill-notice-default text-action-ink-on-primary-normal",
|
|
1199
|
+
},
|
|
1200
|
+
{
|
|
1201
|
+
variant: "filled",
|
|
1202
|
+
color: "info",
|
|
1203
|
+
class: "bg-action-fill-info-default text-action-ink-on-primary-normal",
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
variant: "filled",
|
|
1207
|
+
color: "neutral",
|
|
1208
|
+
class: "bg-action-fill-neutral-default text-action-ink-on-primary-normal",
|
|
1209
|
+
},
|
|
1210
|
+
],
|
|
1211
|
+
defaultVariants: {
|
|
1212
|
+
variant: "light",
|
|
1213
|
+
color: "info",
|
|
1214
|
+
size: "medium",
|
|
1215
|
+
},
|
|
1216
|
+
});
|
|
1217
|
+
const Badge = React__namespace.forwardRef(({ className, variant, size, color, showDot = false, children, ...props }, ref) => {
|
|
1218
|
+
const getDotColor = () => {
|
|
1219
|
+
if (variant === "filled") {
|
|
1220
|
+
return "bg-action-ink-on-primary-normal";
|
|
1221
|
+
}
|
|
1222
|
+
// Light variant - use the corresponding action color
|
|
1223
|
+
switch (color) {
|
|
1224
|
+
case "primary":
|
|
1225
|
+
return "bg-action-fill-primary-default";
|
|
1226
|
+
case "positive":
|
|
1227
|
+
return "bg-action-fill-positive-default";
|
|
1228
|
+
case "negative":
|
|
1229
|
+
return "bg-action-fill-negative-default";
|
|
1230
|
+
case "notice":
|
|
1231
|
+
return "bg-action-fill-notice-default";
|
|
1232
|
+
case "info":
|
|
1233
|
+
return "bg-action-fill-info-default";
|
|
1234
|
+
case "neutral":
|
|
1235
|
+
return "bg-action-fill-neutral-default";
|
|
1236
|
+
default:
|
|
1237
|
+
return "bg-action-fill-info-default";
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
const getDotSize = () => {
|
|
1241
|
+
if (size === "small") {
|
|
1242
|
+
return "h-2 w-2";
|
|
1243
|
+
}
|
|
1244
|
+
if (size === "medium") {
|
|
1245
|
+
return "h-[6px] w-[6px]";
|
|
1246
|
+
}
|
|
1247
|
+
return "h-3 w-3";
|
|
1248
|
+
};
|
|
1249
|
+
return (jsxRuntime.jsxs("div", { ref: ref, className: cn(badgeVariants({ variant, size, color }), className), ...props, children: [showDot && (jsxRuntime.jsx("span", { className: cn("rounded-full", getDotColor(), getDotSize()), "aria-hidden": "true" })), children] }));
|
|
1250
|
+
});
|
|
1251
|
+
Badge.displayName = "Badge";
|
|
599
1252
|
|
|
600
1253
|
const buttonGroupVariants = classVarianceAuthority.cva("inline-flex", {
|
|
601
1254
|
variants: {
|
|
@@ -777,99 +1430,6 @@ const FormFooter = React__namespace.forwardRef(({ helperText, trailingText, vali
|
|
|
777
1430
|
});
|
|
778
1431
|
FormFooter.displayName = "FormFooter";
|
|
779
1432
|
|
|
780
|
-
/**
|
|
781
|
-
* ==============================================
|
|
782
|
-
* HOW TO ADD A NEW ICON:
|
|
783
|
-
* ==============================================
|
|
784
|
-
*
|
|
785
|
-
* 1. Add your SVG file to: src/assets/icons/{iconName}.svg
|
|
786
|
-
*
|
|
787
|
-
* 2. Copy the SVG content from the file
|
|
788
|
-
*
|
|
789
|
-
* 3. Add it to the iconRegistry below:
|
|
790
|
-
* iconName: `<svg>...</svg>`,
|
|
791
|
-
*
|
|
792
|
-
* 4. Use it anywhere in your app:
|
|
793
|
-
* <Icon name="iconName" size={24} />
|
|
794
|
-
*
|
|
795
|
-
* The Icon component will automatically:
|
|
796
|
-
* - Replace hardcoded colors with currentColor
|
|
797
|
-
* - Allow you to control color via className or style
|
|
798
|
-
* - Resize based on the size prop
|
|
799
|
-
* ==============================================
|
|
800
|
-
*/
|
|
801
|
-
/**
|
|
802
|
-
* Icon registry - maps icon names to their SVG content
|
|
803
|
-
* Add your icons here by copying the SVG content from your icon files
|
|
804
|
-
*/
|
|
805
|
-
const iconRegistry = {
|
|
806
|
-
// Tick/Check icon
|
|
807
|
-
tick: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
808
|
-
<path d="M10.364 15.1924L19.5564 6L20.9706 7.41421L10.364 18.0208L4 11.6569L5.41422 10.2427L10.364 15.1924Z" fill="#081416"/>
|
|
809
|
-
</svg>`,
|
|
810
|
-
// Alias: check points to the same icon as tick
|
|
811
|
-
check: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
812
|
-
<path d="M10.364 15.1924L19.5564 6L20.9706 7.41421L10.364 18.0208L4 11.6569L5.41422 10.2427L10.364 15.1924Z" fill="#081416"/>
|
|
813
|
-
</svg>`,
|
|
814
|
-
add: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
815
|
-
<path d="M12.9 11.0999L21 11.0997V12.8997L12.9 12.8999V21H11.1V12.8999L3.00004 12.9001L3 11.1001L11.1 11.0999L11.0999 3.00001L12.8999 3L12.9 11.0999Z" fill="#081416"/>
|
|
816
|
-
</svg>`,
|
|
817
|
-
};
|
|
818
|
-
const Icon = ({ name, size = 24, className = "", style = {}, ...props }) => {
|
|
819
|
-
const svgContent = iconRegistry[name];
|
|
820
|
-
if (!svgContent) {
|
|
821
|
-
console.warn(`Icon "${String(name)}" not found in registry.\n` +
|
|
822
|
-
`Available icons: ${Object.keys(iconRegistry).join(", ")}`);
|
|
823
|
-
return null;
|
|
824
|
-
}
|
|
825
|
-
// Parse the SVG content
|
|
826
|
-
const parser = new DOMParser();
|
|
827
|
-
const svgDoc = parser.parseFromString(svgContent, "image/svg+xml");
|
|
828
|
-
const svgElement = svgDoc.querySelector("svg");
|
|
829
|
-
if (!svgElement) {
|
|
830
|
-
console.error(`Invalid SVG content for icon "${String(name)}"`);
|
|
831
|
-
return null;
|
|
832
|
-
}
|
|
833
|
-
// Get the viewBox for proper scaling
|
|
834
|
-
const viewBox = svgElement.getAttribute("viewBox") || "0 0 24 24";
|
|
835
|
-
// Get all SVG content as string and replace hardcoded colors with currentColor
|
|
836
|
-
let innerSVG = svgElement.innerHTML;
|
|
837
|
-
// Replace common hardcoded colors with currentColor
|
|
838
|
-
// This allows the icon to inherit text color from parent
|
|
839
|
-
innerSVG = innerSVG
|
|
840
|
-
.replace(/fill="[^"]*"/g, 'fill="currentColor"')
|
|
841
|
-
.replace(/stroke="[^"]*"/g, 'stroke="currentColor"');
|
|
842
|
-
return (jsxRuntime.jsx("svg", { width: size, height: size, viewBox: viewBox, className: className, style: style, xmlns: "http://www.w3.org/2000/svg", ...props, dangerouslySetInnerHTML: { __html: innerSVG } }));
|
|
843
|
-
};
|
|
844
|
-
/**
|
|
845
|
-
* Get all available icon names from the registry
|
|
846
|
-
* @returns Array of registered icon names
|
|
847
|
-
*
|
|
848
|
-
* @example
|
|
849
|
-
* ```tsx
|
|
850
|
-
* const icons = getAvailableIcons();
|
|
851
|
-
* console.log(icons); // ['tick', 'check', ...]
|
|
852
|
-
* ```
|
|
853
|
-
*/
|
|
854
|
-
function getAvailableIcons() {
|
|
855
|
-
return Object.keys(iconRegistry);
|
|
856
|
-
}
|
|
857
|
-
/**
|
|
858
|
-
* Check if an icon exists in the registry
|
|
859
|
-
* @param name - Icon name to check
|
|
860
|
-
* @returns true if the icon exists
|
|
861
|
-
*
|
|
862
|
-
* @example
|
|
863
|
-
* ```tsx
|
|
864
|
-
* if (hasIcon('tick')) {
|
|
865
|
-
* // Icon exists
|
|
866
|
-
* }
|
|
867
|
-
* ```
|
|
868
|
-
*/
|
|
869
|
-
function hasIcon(name) {
|
|
870
|
-
return name in iconRegistry;
|
|
871
|
-
}
|
|
872
|
-
|
|
873
1433
|
const checkboxVariants = classVarianceAuthority.cva("relative inline-flex items-center justify-center shrink-0 transition-all cursor-pointer", {
|
|
874
1434
|
variants: {
|
|
875
1435
|
size: {
|
|
@@ -1319,141 +1879,6 @@ const ListItem = React__namespace.forwardRef(({ className, type = "single", lead
|
|
|
1319
1879
|
});
|
|
1320
1880
|
ListItem.displayName = "ListItem";
|
|
1321
1881
|
|
|
1322
|
-
const linkVariants = classVarianceAuthority.cva("inline-flex items-center gap-1 whitespace-nowrap transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none decoration-1 underline-offset-4", {
|
|
1323
|
-
variants: {
|
|
1324
|
-
type: {
|
|
1325
|
-
anchor: "hover:underline",
|
|
1326
|
-
action: "no-underline cursor-pointer",
|
|
1327
|
-
},
|
|
1328
|
-
color: {
|
|
1329
|
-
primary: "",
|
|
1330
|
-
positive: "",
|
|
1331
|
-
negative: "",
|
|
1332
|
-
notice: "",
|
|
1333
|
-
info: "",
|
|
1334
|
-
neutral: "",
|
|
1335
|
-
},
|
|
1336
|
-
size: {
|
|
1337
|
-
xsmall: "text-body-xsmall-medium gap-1",
|
|
1338
|
-
small: "text-body-small-medium gap-1",
|
|
1339
|
-
medium: "text-body-medium-medium gap-1.5",
|
|
1340
|
-
large: "text-body-large-medium gap-1.5",
|
|
1341
|
-
},
|
|
1342
|
-
isIconOnly: {
|
|
1343
|
-
true: "no-underline",
|
|
1344
|
-
false: "",
|
|
1345
|
-
},
|
|
1346
|
-
isDisabled: {
|
|
1347
|
-
true: "cursor-not-allowed opacity-50",
|
|
1348
|
-
false: "cursor-pointer",
|
|
1349
|
-
},
|
|
1350
|
-
},
|
|
1351
|
-
compoundVariants: [
|
|
1352
|
-
// Primary color variants
|
|
1353
|
-
{
|
|
1354
|
-
color: "primary",
|
|
1355
|
-
class: `text-action-ink-primary-normal
|
|
1356
|
-
hover:text-action-ink-primary-subtle
|
|
1357
|
-
hover:decoration-action-outline-primary-hover
|
|
1358
|
-
disabled:text-action-ink-primary-disabled
|
|
1359
|
-
focus:text-action-ink-primary-hover
|
|
1360
|
-
`,
|
|
1361
|
-
},
|
|
1362
|
-
// Positive color variants
|
|
1363
|
-
{
|
|
1364
|
-
color: "positive",
|
|
1365
|
-
class: `text-action-ink-positive-normal
|
|
1366
|
-
hover:text-action-ink-positive-subtle
|
|
1367
|
-
hover:decoration-action-outline-positive-hover
|
|
1368
|
-
hover:text-action-ink-positive-hover
|
|
1369
|
-
disabled:text-action-ink-positive-disabled
|
|
1370
|
-
focus:text-action-ink-positive-hover
|
|
1371
|
-
`,
|
|
1372
|
-
},
|
|
1373
|
-
// Negative color variants
|
|
1374
|
-
{
|
|
1375
|
-
color: "negative",
|
|
1376
|
-
class: `text-action-ink-negative-normal
|
|
1377
|
-
hover:text-action-ink-negative-subtle
|
|
1378
|
-
hover:decoration-action-outline-negative-hover
|
|
1379
|
-
hover:text-action-ink-negative-hover
|
|
1380
|
-
disabled:text-action-ink-negative-disabled
|
|
1381
|
-
focus:text-action-ink-negative-hover
|
|
1382
|
-
`,
|
|
1383
|
-
},
|
|
1384
|
-
// Notice color variants
|
|
1385
|
-
{
|
|
1386
|
-
color: "notice",
|
|
1387
|
-
class: `text-action-ink-notice-normal
|
|
1388
|
-
hover:text-action-ink-notice-subtle
|
|
1389
|
-
hover:decoration-action-outline-notice-hover
|
|
1390
|
-
hover:text-action-ink-notice-hover
|
|
1391
|
-
disabled:text-action-ink-notice-disabled
|
|
1392
|
-
focus:text-action-ink-notice-hover
|
|
1393
|
-
`,
|
|
1394
|
-
},
|
|
1395
|
-
// Info color variants
|
|
1396
|
-
{
|
|
1397
|
-
color: "info",
|
|
1398
|
-
class: `text-action-ink-info-normal
|
|
1399
|
-
hover:text-action-ink-info-subtle
|
|
1400
|
-
hover:decoration-action-outline-info-hover
|
|
1401
|
-
hover:text-action-ink-info-hover
|
|
1402
|
-
disabled:text-action-ink-info-disabled
|
|
1403
|
-
focus:text-action-ink-info-hover
|
|
1404
|
-
`,
|
|
1405
|
-
},
|
|
1406
|
-
// Neutral color variants
|
|
1407
|
-
{
|
|
1408
|
-
color: "neutral",
|
|
1409
|
-
class: `text-action-ink-neutral-normal
|
|
1410
|
-
hover:text-action-ink-neutral-subtle
|
|
1411
|
-
hover:decoration-action-outline-neutral-hover
|
|
1412
|
-
hover:text-action-ink-neutral-hover
|
|
1413
|
-
disabled:text-action-ink-neutral-disabled
|
|
1414
|
-
focus:text-action-ink-neutral-hover
|
|
1415
|
-
`,
|
|
1416
|
-
},
|
|
1417
|
-
],
|
|
1418
|
-
defaultVariants: {
|
|
1419
|
-
type: "anchor",
|
|
1420
|
-
color: "primary",
|
|
1421
|
-
size: "medium",
|
|
1422
|
-
isIconOnly: false,
|
|
1423
|
-
isDisabled: false,
|
|
1424
|
-
},
|
|
1425
|
-
});
|
|
1426
|
-
const Link = React__namespace.forwardRef(({ className, type = "anchor", color = "primary", size = "medium", isIconOnly = false, isDisabled = false, asChild = false, showIcon = false, icon, leadingIcon, trailingIcon, children, onClick, ...props }, ref) => {
|
|
1427
|
-
const Comp = asChild ? reactSlot.Slot : "a";
|
|
1428
|
-
const handleClick = (e) => {
|
|
1429
|
-
if (isDisabled) {
|
|
1430
|
-
e.preventDefault();
|
|
1431
|
-
return;
|
|
1432
|
-
}
|
|
1433
|
-
onClick?.(e);
|
|
1434
|
-
};
|
|
1435
|
-
// Icon size based on link size
|
|
1436
|
-
const iconSize = {
|
|
1437
|
-
xsmall: 12,
|
|
1438
|
-
small: 14,
|
|
1439
|
-
medium: 16,
|
|
1440
|
-
large: 18,
|
|
1441
|
-
}[size];
|
|
1442
|
-
// Determine what to show as trailing icon
|
|
1443
|
-
// Priority: trailingIcon > (showIcon && icon) > (showIcon && default ExternalLink)
|
|
1444
|
-
const finalTrailingIcon = trailingIcon || (showIcon && (icon || jsxRuntime.jsx(lucideReact.ExternalLink, { size: iconSize })));
|
|
1445
|
-
const linkContent = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [leadingIcon && !isIconOnly && (jsxRuntime.jsx("span", { className: "inline-flex items-center", children: leadingIcon })), !isIconOnly && children, isIconOnly && children, finalTrailingIcon && !isIconOnly && (jsxRuntime.jsx("span", { className: "inline-flex items-center", children: finalTrailingIcon })), isIconOnly &&
|
|
1446
|
-
(leadingIcon || finalTrailingIcon || (jsxRuntime.jsx(lucideReact.ExternalLink, { size: iconSize })))] }));
|
|
1447
|
-
return (jsxRuntime.jsx(Comp, { className: cn(linkVariants({
|
|
1448
|
-
type,
|
|
1449
|
-
color,
|
|
1450
|
-
size,
|
|
1451
|
-
isIconOnly,
|
|
1452
|
-
isDisabled,
|
|
1453
|
-
}), className), ref: ref, onClick: handleClick, "aria-disabled": isDisabled, tabIndex: isDisabled ? -1 : undefined, ...props, children: linkContent }));
|
|
1454
|
-
});
|
|
1455
|
-
Link.displayName = "Link";
|
|
1456
|
-
|
|
1457
1882
|
const DropdownMenu = React__namespace.forwardRef(({ items = [], customContent, sectionHeading, isLoading = false, isEmpty = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText = "Primary", secondaryButtonText = "Secondary", onPrimaryClick, onSecondaryClick, showChevron = false, emptyIcon, disableFooter = false, showFooter, footerLayout = "horizontal", onClose, focusedIndex = -1, className, width = "auto", }, ref) => {
|
|
1458
1883
|
const renderContent = () => {
|
|
1459
1884
|
if (isLoading) {
|
|
@@ -2860,7 +3285,7 @@ const tableCellVariants = classVarianceAuthority.cva("text-body-medium-regular b
|
|
|
2860
3285
|
},
|
|
2861
3286
|
});
|
|
2862
3287
|
|
|
2863
|
-
function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHeaderBackground, stickyHeader, size, headerClassName,
|
|
3288
|
+
function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHeaderBackground, stickyHeader, size, headerClassName, onToggleAllRows, isAllRowsSelected, isSomeRowsSelected, getColumnStyle, }) {
|
|
2864
3289
|
const headerHeight = {
|
|
2865
3290
|
small: 32,
|
|
2866
3291
|
medium: 40,
|
|
@@ -2869,20 +3294,18 @@ function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHe
|
|
|
2869
3294
|
return (jsxRuntime.jsx("thead", { className: cn(showHeaderBackground ? "bg-surface-fill-neutral-moderate" : "bg-white", stickyHeader && "sticky top-0 z-10"), children: headerGroups.map((headerGroup, groupIndex) => {
|
|
2870
3295
|
const stickyTop = stickyHeader ? groupIndex * headerHeight : undefined;
|
|
2871
3296
|
return (jsxRuntime.jsxs("tr", { children: [enableRowSelection && enableSelectAll && (jsxRuntime.jsx("th", { className: cn(tableHeaderVariants({ size }), showHeaderBackground && "bg-surface-fill-neutral-moderate", stickyHeader && "sticky z-20", "w-10 rounded-tl-xlarge rounded-bl-xlarge", headerClassName), style: { top: stickyTop }, children: jsxRuntime.jsx(Checkbox, { checked: isAllRowsSelected, isIndeterminate: isSomeRowsSelected, onChange: onToggleAllRows, "aria-label": "Select all rows" }) })), headerGroup.headers.map((header, index) => {
|
|
2872
|
-
const
|
|
2873
|
-
const
|
|
2874
|
-
? index === visibleHeadersCount - 1
|
|
2875
|
-
: index === headerGroup.headers.length - 1;
|
|
3297
|
+
const isFirstColumn = index === 0;
|
|
3298
|
+
const isLastColumn = index === headerGroup.headers.length - 1;
|
|
2876
3299
|
return (jsxRuntime.jsx("th", { className: cn(tableHeaderVariants({ size }), showHeaderBackground &&
|
|
2877
|
-
"bg-surface-fill-neutral-moderate border-none", stickyHeader && "sticky z-20", !enableRowSelection && index === 0 && "rounded-tl-xlarge ",
|
|
2878
|
-
? "opacity-0 translate-x-8 pointer-events-none"
|
|
2879
|
-
: "opacity-100 translate-x-0"), style: {
|
|
3300
|
+
"bg-surface-fill-neutral-moderate border-none", stickyHeader && "sticky z-20", !enableRowSelection && index === 0 && "rounded-tl-xlarge ", isLastColumn && "rounded-tr-xlarge", header.column.columnDef.meta?.headerClassName, headerClassName), style: {
|
|
2880
3301
|
...getColumnStyle(header.column.id, {
|
|
2881
3302
|
width: header.getSize(),
|
|
2882
3303
|
minWidth: header.column.columnDef.minSize,
|
|
2883
3304
|
maxWidth: header.column.columnDef.maxSize,
|
|
2884
3305
|
}),
|
|
2885
3306
|
top: stickyTop,
|
|
3307
|
+
...(isFirstColumn && { paddingLeft: "24px" }),
|
|
3308
|
+
...(isLastColumn && { paddingRight: "24px" }),
|
|
2886
3309
|
}, children: header.isPlaceholder ? null : (jsxRuntime.jsxs("div", { className: cn("flex items-center gap-2", header.column.getCanSort() &&
|
|
2887
3310
|
"cursor-pointer select-none"), onClick: header.column.getToggleSortingHandler(), children: [reactTable.flexRender(header.column.columnDef.header, header.getContext()), header.column.getCanSort() && (jsxRuntime.jsx("span", { className: "text-surface-ink-neutral-muted", children: {
|
|
2888
3311
|
asc: "↑",
|
|
@@ -2892,42 +3315,41 @@ function TableHeader({ headerGroups, enableRowSelection, enableSelectAll, showHe
|
|
|
2892
3315
|
}) }));
|
|
2893
3316
|
}
|
|
2894
3317
|
|
|
2895
|
-
function TableBody({ rows, enableRowSelection, size, variant, showRowHover, cellClassName,
|
|
3318
|
+
function TableBody({ rows, enableRowSelection, size, variant, showRowHover, cellClassName, onRowClick, getRowClassName, handleRowClick, getColumnStyle, }) {
|
|
2896
3319
|
const [focusedCell, setFocusedCell] = React__namespace.useState(null);
|
|
2897
3320
|
const [hoveredRow, setHoveredRow] = React__namespace.useState(null);
|
|
2898
3321
|
return (jsxRuntime.jsx("tbody", { className: cn("bg-surface-fill-neutral-intense"), children: rows.map((row) => {
|
|
2899
|
-
const isRowSelected = row.id === effectiveSelectedRowId;
|
|
2900
3322
|
const isRowHovered = hoveredRow === row.id;
|
|
2901
|
-
const handleClick = () => handleRowClick(row.original
|
|
3323
|
+
const handleClick = () => handleRowClick(row.original);
|
|
2902
3324
|
return (jsxRuntime.jsxs("tr", { className: cn(variant === "striped" &&
|
|
2903
3325
|
row.index % 2 === 1 &&
|
|
2904
|
-
"bg-surface-fill-neutral-moderate", onRowClick && "cursor-pointer",
|
|
3326
|
+
"bg-surface-fill-neutral-moderate", onRowClick && "cursor-pointer", isRowHovered &&
|
|
2905
3327
|
showRowHover &&
|
|
2906
|
-
"bg-surface-fill-neutral-moderate", getRowClassName(row.original)), onClick: handleClick, onMouseEnter: () => setHoveredRow(row.id), onMouseLeave: () => setHoveredRow(null), children: [enableRowSelection && (jsxRuntime.jsx("td", { className: cn(tableCellVariants({ size }), "w-10", cellClassName),
|
|
2907
|
-
|
|
3328
|
+
"bg-surface-fill-neutral-moderate", getRowClassName(row.original)), onClick: handleClick, onMouseEnter: () => setHoveredRow(row.id), onMouseLeave: () => setHoveredRow(null), children: [enableRowSelection && (jsxRuntime.jsx("td", { className: cn(tableCellVariants({ size }), "w-10", cellClassName), style: {
|
|
3329
|
+
paddingTop: "20px",
|
|
3330
|
+
paddingBottom: "20px",
|
|
3331
|
+
}, children: jsxRuntime.jsx(Checkbox, { checked: row.getIsSelected(), isIndeterminate: row.getIsSomeSelected(), onChange: row.getToggleSelectedHandler(), onClick: (e) => e.stopPropagation(), "aria-label": `Select row ${row.id}` }) })), row.getVisibleCells().map((cell, cellIndex) => {
|
|
2908
3332
|
const isCellFocused = focusedCell?.rowId === row.id &&
|
|
2909
3333
|
focusedCell?.cellId === cell.id;
|
|
2910
3334
|
const cellState = isCellFocused ? "focus" : "default";
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
3335
|
+
const visibleCells = row.getVisibleCells();
|
|
3336
|
+
const isFirstCell = cellIndex === 0;
|
|
3337
|
+
const isLastCell = cellIndex === visibleCells.length - 1;
|
|
3338
|
+
return (jsxRuntime.jsx("td", { className: cn(tableCellVariants({ size, state: cellState }), cell.column.columnDef.meta?.cellClassName, cellClassName), style: {
|
|
3339
|
+
...getColumnStyle(cell.column.id, {
|
|
3340
|
+
width: cell.column.getSize(),
|
|
3341
|
+
minWidth: cell.column.columnDef.minSize,
|
|
3342
|
+
maxWidth: cell.column.columnDef.maxSize,
|
|
3343
|
+
}),
|
|
3344
|
+
paddingTop: "20px",
|
|
3345
|
+
paddingBottom: "20px",
|
|
3346
|
+
...(isFirstCell && { paddingLeft: "24px" }),
|
|
3347
|
+
...(isLastCell && { paddingRight: "24px" }),
|
|
3348
|
+
}, tabIndex: 0, onFocus: () => setFocusedCell({ rowId: row.id, cellId: cell.id }), onBlur: () => setFocusedCell(null), children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
2918
3349
|
})] }, row.id));
|
|
2919
3350
|
}) }));
|
|
2920
3351
|
}
|
|
2921
3352
|
|
|
2922
|
-
function DetailPanel({ isOpen, content, data, onClose, }) {
|
|
2923
|
-
return (jsxRuntime.jsx("div", { className: cn("absolute top-0 right-0 h-full z-20 transition-all duration-300 ease-in-out", isOpen
|
|
2924
|
-
? "translate-x-0 opacity-100"
|
|
2925
|
-
: "translate-x-full opacity-0 pointer-events-none"), style: { width: "332px", paddingLeft: "12px" }, children: jsxRuntime.jsx("div", { className: "w-full h-full bg-white border border-surface-outline-neutral-muted rounded-tr-xlarge rounded-br-xlarge overflow-hidden", children: jsxRuntime.jsx("div", { className: "w-full h-full overflow-auto", children: data && (jsxRuntime.jsxs("div", { className: "relative h-full", children: [jsxRuntime.jsx("button", { onClick: (e) => {
|
|
2926
|
-
e.stopPropagation();
|
|
2927
|
-
onClose();
|
|
2928
|
-
}, className: "absolute top-4 right-4 z-10 p-2 rounded-medium hover:bg-surface-fill-neutral-faded transition-colors", "aria-label": "Close detail panel", children: jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", className: "text-surface-ink-neutral-muted", children: jsxRuntime.jsx("path", { d: "M12 4L4 12M4 4l8 8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) }), content(data)] })) }) }) }));
|
|
2929
|
-
}
|
|
2930
|
-
|
|
2931
3353
|
function renderDefaultLoadingState({ colSpan }) {
|
|
2932
3354
|
return (jsxRuntime.jsx("tr", { children: jsxRuntime.jsx("td", { colSpan: colSpan, className: "text-center py-12 text-surface-ink-neutral-muted", children: jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-2", children: [jsxRuntime.jsx("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-action-fill-primary-default" }), jsxRuntime.jsx("span", { children: "Loading..." })] }) }) }));
|
|
2933
3355
|
}
|
|
@@ -2936,47 +3358,10 @@ function renderDefaultEmptyState({ colSpan }) {
|
|
|
2936
3358
|
}
|
|
2937
3359
|
|
|
2938
3360
|
// ==================== Component ====================
|
|
2939
|
-
function TableComponent({ className, wrapperClassName, containerClassName, variant, size = "medium", table, enableRowSelection = false, enableSelectAll = false, isLoading = false, loading, loadingComponent, emptyComponent, enableHorizontalScroll = false, stickyHeader = false, maxHeight, showRowHover = true, onRowClick, rowClassName, headerClassName, cellClassName, showHeaderBackground = true,
|
|
2940
|
-
// ==================== State ====================
|
|
2941
|
-
const [internalSelectedRowId, setInternalSelectedRowId] = React__namespace.useState(null);
|
|
2942
|
-
const selectedRowIdRef = React__namespace.useRef(null);
|
|
2943
|
-
const effectiveSelectedRowId = selectedRowId !== undefined ? selectedRowId : internalSelectedRowId;
|
|
2944
|
-
const isDetailPanelOpen = Boolean(effectiveSelectedRowId);
|
|
2945
|
-
// ==================== Effects ====================
|
|
2946
|
-
// Keep ref in sync
|
|
2947
|
-
React__namespace.useEffect(() => {
|
|
2948
|
-
selectedRowIdRef.current = effectiveSelectedRowId;
|
|
2949
|
-
}, [effectiveSelectedRowId]);
|
|
2950
|
-
// Clear selection if selected row is not in current data
|
|
2951
|
-
React__namespace.useEffect(() => {
|
|
2952
|
-
if (effectiveSelectedRowId) {
|
|
2953
|
-
const rowExists = table
|
|
2954
|
-
.getRowModel()
|
|
2955
|
-
.rows.some((r) => r.id === effectiveSelectedRowId);
|
|
2956
|
-
if (!rowExists) {
|
|
2957
|
-
if (selectedRowId === undefined) {
|
|
2958
|
-
setInternalSelectedRowId(null);
|
|
2959
|
-
}
|
|
2960
|
-
if (onRowSelectionChange) {
|
|
2961
|
-
onRowSelectionChange(null);
|
|
2962
|
-
}
|
|
2963
|
-
}
|
|
2964
|
-
}
|
|
2965
|
-
}, [
|
|
2966
|
-
table.getRowModel().rows,
|
|
2967
|
-
effectiveSelectedRowId,
|
|
2968
|
-
selectedRowId,
|
|
2969
|
-
onRowSelectionChange,
|
|
2970
|
-
]);
|
|
3361
|
+
function TableComponent({ className, wrapperClassName, containerClassName, variant, size = "medium", table, enableRowSelection = false, enableSelectAll = false, isLoading = false, loading, loadingComponent, emptyComponent, enableHorizontalScroll = false, stickyHeader = false, maxHeight, showRowHover = true, onRowClick, rowClassName, headerClassName, cellClassName, showHeaderBackground = true, loadingSkeletonRows, loadingSkeletonHeight, columnWidths, columnMinWidths, columnMaxWidths, ...props }, ref) {
|
|
2971
3362
|
// ==================== Computed Values ====================
|
|
2972
3363
|
const hasData = table.getRowModel().rows?.length > 0;
|
|
2973
3364
|
const headerGroups = table.getHeaderGroups();
|
|
2974
|
-
const headers = headerGroups[0]?.headers || [];
|
|
2975
|
-
const visibleHeadersCount = React__namespace.useMemo(() => {
|
|
2976
|
-
return isDetailPanelOpen
|
|
2977
|
-
? headers.length - hideColumnsOnDetailOpen
|
|
2978
|
-
: headers.length;
|
|
2979
|
-
}, [isDetailPanelOpen, headers.length, hideColumnsOnDetailOpen]);
|
|
2980
3365
|
const normalizeSizeValue = (value) => {
|
|
2981
3366
|
if (value === undefined)
|
|
2982
3367
|
return undefined;
|
|
@@ -3043,42 +3428,18 @@ function TableComponent({ className, wrapperClassName, containerClassName, varia
|
|
|
3043
3428
|
}
|
|
3044
3429
|
return rowClassName || "";
|
|
3045
3430
|
}, [rowClassName]);
|
|
3046
|
-
const handleRowClickInternal = React__namespace.useCallback((row
|
|
3047
|
-
const currentSelectedId = selectedRowIdRef.current;
|
|
3048
|
-
const newSelectedId = currentSelectedId === rowId ? null : rowId;
|
|
3049
|
-
if (selectedRowId === undefined) {
|
|
3050
|
-
setInternalSelectedRowId(newSelectedId);
|
|
3051
|
-
}
|
|
3052
|
-
if (onRowSelectionChange) {
|
|
3053
|
-
onRowSelectionChange(newSelectedId);
|
|
3054
|
-
}
|
|
3431
|
+
const handleRowClickInternal = React__namespace.useCallback((row) => {
|
|
3055
3432
|
if (onRowClick) {
|
|
3056
3433
|
onRowClick(row);
|
|
3057
3434
|
}
|
|
3058
|
-
}, [
|
|
3059
|
-
const getSelectedRowData = () => {
|
|
3060
|
-
if (!effectiveSelectedRowId)
|
|
3061
|
-
return null;
|
|
3062
|
-
const row = table
|
|
3063
|
-
.getRowModel()
|
|
3064
|
-
.rows.find((r) => r.id === effectiveSelectedRowId);
|
|
3065
|
-
return row ? row.original : null;
|
|
3066
|
-
};
|
|
3067
|
-
const handleDetailPanelClose = () => {
|
|
3068
|
-
if (selectedRowId === undefined) {
|
|
3069
|
-
setInternalSelectedRowId(null);
|
|
3070
|
-
}
|
|
3071
|
-
if (onRowSelectionChange) {
|
|
3072
|
-
onRowSelectionChange(null);
|
|
3073
|
-
}
|
|
3074
|
-
};
|
|
3435
|
+
}, [onRowClick]);
|
|
3075
3436
|
const renderEmptyState = () => {
|
|
3076
3437
|
if (emptyComponent)
|
|
3077
3438
|
return emptyComponent;
|
|
3078
3439
|
return renderDefaultEmptyState({ colSpan: table.getAllColumns().length });
|
|
3079
3440
|
};
|
|
3080
3441
|
// ==================== Render ====================
|
|
3081
|
-
return (jsxRuntime.jsx("div", { ref: ref, className: cn("w-full", wrapperClassName), ...props, children: jsxRuntime.
|
|
3442
|
+
return (jsxRuntime.jsx("div", { ref: ref, className: cn("w-full", wrapperClassName), ...props, children: jsxRuntime.jsx("div", { className: cn("relative", enableHorizontalScroll ? "overflow-x-auto" : "overflow-x-hidden", maxHeight && "overflow-y-auto", containerClassName), style: containerStyle, children: jsxRuntime.jsxs("table", { className: cn(tableVariants({ variant, size }), className), children: [jsxRuntime.jsx(TableHeader, { headerGroups: headerGroups, enableRowSelection: enableRowSelection, enableSelectAll: enableSelectAll, showHeaderBackground: showHeaderBackground, stickyHeader: stickyHeader, size: size || "medium", headerClassName: headerClassName, onToggleAllRows: (e) => table.getToggleAllRowsSelectedHandler()(e), isAllRowsSelected: table.getIsAllRowsSelected(), isSomeRowsSelected: table.getIsSomeRowsSelected(), getColumnStyle: getColumnStyle }), resolvedLoading ? (jsxRuntime.jsx("tbody", { children: renderLoadingContent() })) : !hasData ? (jsxRuntime.jsx("tbody", { children: renderEmptyState() })) : (jsxRuntime.jsx(TableBody, { rows: table.getRowModel().rows, enableRowSelection: enableRowSelection, size: size || "medium", variant: variant || "default", showRowHover: showRowHover, cellClassName: cellClassName, onRowClick: onRowClick, getRowClassName: getRowClassName, handleRowClick: handleRowClickInternal, getColumnStyle: getColumnStyle }))] }) }) }));
|
|
3082
3443
|
}
|
|
3083
3444
|
// ==================== Export ====================
|
|
3084
3445
|
const Table = React__namespace.forwardRef(TableComponent);
|
|
@@ -3326,6 +3687,7 @@ const TextArea = React__namespace.forwardRef(({ label, helperText, errorText, su
|
|
|
3326
3687
|
});
|
|
3327
3688
|
TextArea.displayName = "TextArea";
|
|
3328
3689
|
|
|
3690
|
+
exports.Alert = Alert;
|
|
3329
3691
|
exports.Avatar = Avatar;
|
|
3330
3692
|
exports.AvatarCell = AvatarCell;
|
|
3331
3693
|
exports.Badge = Badge;
|
|
@@ -3339,6 +3701,7 @@ exports.DropdownMenu = DropdownMenu;
|
|
|
3339
3701
|
exports.FormFooter = FormFooter;
|
|
3340
3702
|
exports.FormHeader = FormHeader;
|
|
3341
3703
|
exports.Icon = Icon;
|
|
3704
|
+
exports.IconButton = IconButton;
|
|
3342
3705
|
exports.IconCell = IconCell;
|
|
3343
3706
|
exports.Link = Link;
|
|
3344
3707
|
exports.ListItem = ListItem;
|
|
@@ -3360,6 +3723,7 @@ exports.Text = Text;
|
|
|
3360
3723
|
exports.TextArea = TextArea;
|
|
3361
3724
|
exports.TextField = TextField;
|
|
3362
3725
|
exports.Tooltip = Tooltip;
|
|
3726
|
+
exports.alertVariants = alertVariants;
|
|
3363
3727
|
exports.avatarVariants = avatarVariants;
|
|
3364
3728
|
exports.badgeVariants = badgeVariants;
|
|
3365
3729
|
exports.buttonGroupVariants = buttonGroupVariants;
|
|
@@ -3370,6 +3734,7 @@ exports.counterVariants = counterVariants;
|
|
|
3370
3734
|
exports.dropdownVariants = dropdownVariants;
|
|
3371
3735
|
exports.getAvailableIcons = getAvailableIcons;
|
|
3372
3736
|
exports.hasIcon = hasIcon;
|
|
3737
|
+
exports.iconButtonVariants = iconButtonVariants;
|
|
3373
3738
|
exports.iconRegistry = iconRegistry;
|
|
3374
3739
|
exports.linkVariants = linkVariants;
|
|
3375
3740
|
exports.listItemVariants = listItemVariants;
|