@attrus-ds/core 0.1.1 → 0.2.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/README.md +63 -9
- package/dist/css/components/buttons.css +1 -1
- package/dist/css/components/combobox.css +17 -1
- package/dist/css/components/inputs.css +3 -55
- package/dist/css/components/overlays.css +28 -59
- package/dist/css/components/primitives.css +10 -1
- package/dist/css/components/sidebar.css +3 -3
- package/dist/css/components/smart-search.css +91 -0
- package/dist/css/components/table.css +10 -8
- package/dist/css/components/tabs.css +2 -2
- package/dist/css/components/toast.css +4 -0
- package/dist/css/components/tooltip.css +5 -0
- package/dist/css/index.css +1 -0
- package/dist/react/AppSidebar/AppSidebar.d.ts +50 -0
- package/dist/react/AppSidebar/AppSidebar.tsx +197 -0
- package/dist/react/AppTopbar/AppTopbar.d.ts +58 -0
- package/dist/react/AppTopbar/AppTopbar.tsx +203 -0
- package/dist/react/Atoms/Atoms.d.ts +149 -0
- package/dist/react/Atoms/Atoms.tsx +407 -0
- package/dist/react/Button/Button.d.ts +25 -0
- package/dist/react/Button/Button.tsx +83 -0
- package/dist/react/Callout/Callout.d.ts +29 -0
- package/dist/react/Callout/Callout.tsx +98 -0
- package/dist/react/Card/Card.d.ts +38 -0
- package/dist/react/Card/Card.tsx +93 -0
- package/dist/react/Combobox/Combobox.d.ts +52 -0
- package/dist/react/Combobox/Combobox.tsx +254 -0
- package/dist/react/DataTable/DataTable.d.ts +81 -0
- package/dist/react/DataTable/DataTable.tsx +308 -0
- package/dist/react/Drawer/Drawer.d.ts +35 -0
- package/dist/react/Drawer/Drawer.tsx +226 -0
- package/dist/react/Input/Input.d.ts +155 -0
- package/dist/react/Input/Input.tsx +478 -0
- package/dist/react/Modal/Modal.d.ts +27 -0
- package/dist/react/Modal/Modal.tsx +173 -0
- package/dist/react/NumberInput/NumberInput.d.ts +25 -0
- package/dist/react/NumberInput/NumberInput.tsx +117 -0
- package/dist/react/Pill/Pill.d.ts +31 -0
- package/dist/react/Pill/Pill.tsx +104 -0
- package/dist/react/SearchPill/SearchPill.d.ts +14 -0
- package/dist/react/SearchPill/SearchPill.tsx +40 -0
- package/dist/react/SmartSearch/SmartSearch.d.ts +65 -0
- package/dist/react/SmartSearch/SmartSearch.tsx +271 -0
- package/dist/react/Stepper/Stepper.d.ts +25 -0
- package/dist/react/Stepper/Stepper.tsx +94 -0
- package/dist/react/Tabs/Tabs.d.ts +32 -0
- package/dist/react/Tabs/Tabs.tsx +147 -0
- package/dist/react/Toast/Toast.d.ts +30 -0
- package/dist/react/Toast/Toast.tsx +94 -0
- package/dist/react/Tooltip/Tooltip.d.ts +23 -0
- package/dist/react/Tooltip/Tooltip.tsx +80 -0
- package/dist/react/ZeroState/ZeroState.d.ts +17 -0
- package/dist/react/ZeroState/ZeroState.tsx +45 -0
- package/dist/react/index.ts +35 -0
- package/package.json +12 -2
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ATTRUS Atoms — typed wrappers over primitives.css atoms.
|
|
5
|
+
* Money · Metric · Avatar/AvatarGroup · Eyebrow · Flag · Icon.
|
|
6
|
+
* CSS stays the visual source of truth; these compose class names.
|
|
7
|
+
* (Module named Atoms — "Primitives" collides with the legacy
|
|
8
|
+
* ui_kits/dashboard/Primitives.jsx still consumed by the app.)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/* ---------- Money — mono, inline (tables, rows, receipts) ---------- */
|
|
12
|
+
|
|
13
|
+
export type MoneySize = 'sm' | 'md' | 'lg' | 'xl' | 'display';
|
|
14
|
+
export type MoneyTone = 'pos' | 'neg' | 'muted';
|
|
15
|
+
|
|
16
|
+
export interface MoneyProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
17
|
+
/** Currency code, dimmed uppercase prefix (e.g. "USD"). */
|
|
18
|
+
cur?: string;
|
|
19
|
+
/** Main figure including separators (e.g. "1,000"). */
|
|
20
|
+
amount: React.ReactNode;
|
|
21
|
+
/** Dimmed decimals, rendered after the amount (e.g. ".00"). */
|
|
22
|
+
frac?: React.ReactNode;
|
|
23
|
+
size?: MoneySize;
|
|
24
|
+
tone?: MoneyTone;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const Money: React.FC<MoneyProps> = ({ cur, amount, frac, size = 'md', tone, className, ...rest }) => (
|
|
28
|
+
<span
|
|
29
|
+
className={['money', size !== 'md' ? `money-${size}` : '', tone ? `money-${tone}` : '', className || '']
|
|
30
|
+
.filter(Boolean)
|
|
31
|
+
.join(' ')}
|
|
32
|
+
{...rest}
|
|
33
|
+
>
|
|
34
|
+
{cur ? <span className="money-cur">{cur}</span> : null}
|
|
35
|
+
{amount}
|
|
36
|
+
{frac != null ? <span className="money-frac">{frac}</span> : null}
|
|
37
|
+
</span>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
/* ---------- Metric — sans display number (heroes, KPIs) ---------- */
|
|
41
|
+
|
|
42
|
+
export type MetricSize = 'sm' | 'md' | 'lg';
|
|
43
|
+
export type MetricTone = 'pos' | 'neg';
|
|
44
|
+
|
|
45
|
+
export interface MetricProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
46
|
+
/** Currency code, dimmed prefix. */
|
|
47
|
+
cur?: string;
|
|
48
|
+
/** Main figure (include the trailing dot when using frac: "48,920."). */
|
|
49
|
+
amount: React.ReactNode;
|
|
50
|
+
/** Dimmed decimals (e.g. "56"). */
|
|
51
|
+
frac?: React.ReactNode;
|
|
52
|
+
size?: MetricSize;
|
|
53
|
+
/** Colour inherits by default (works on light + inverse). */
|
|
54
|
+
tone?: MetricTone;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const Metric: React.FC<MetricProps> = ({ cur, amount, frac, size = 'md', tone, className, ...rest }) => (
|
|
58
|
+
<span
|
|
59
|
+
className={['metric', size !== 'md' ? `metric-${size}` : '', tone ? `metric-${tone}` : '', className || '']
|
|
60
|
+
.filter(Boolean)
|
|
61
|
+
.join(' ')}
|
|
62
|
+
{...rest}
|
|
63
|
+
>
|
|
64
|
+
{cur ? <span className="metric-cur">{cur}</span> : null}
|
|
65
|
+
{amount}
|
|
66
|
+
{frac != null ? <span className="metric-frac">{frac}</span> : null}
|
|
67
|
+
</span>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
/* ---------- Avatar ---------- */
|
|
71
|
+
|
|
72
|
+
export type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
73
|
+
export type AvatarTone = 'brand' | 'success' | 'warning' | 'danger' | 'info' | 'neutral';
|
|
74
|
+
export type AvatarDot = boolean | 'busy' | 'away' | 'off';
|
|
75
|
+
|
|
76
|
+
export interface AvatarProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
77
|
+
/** Full name — initials are derived (first + last word). */
|
|
78
|
+
name?: string;
|
|
79
|
+
/** Image avatar; falls back to initials while absent. */
|
|
80
|
+
src?: string;
|
|
81
|
+
size?: AvatarSize;
|
|
82
|
+
tone?: AvatarTone;
|
|
83
|
+
/** Presence dot: true=online, 'busy' | 'away' | 'off'. */
|
|
84
|
+
dot?: AvatarDot;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function initials(name?: string): string {
|
|
88
|
+
if (!name) return '';
|
|
89
|
+
const parts = name.trim().split(/\s+/);
|
|
90
|
+
const first = parts[0] ? parts[0].charAt(0) : '';
|
|
91
|
+
const last = parts.length > 1 ? parts[parts.length - 1].charAt(0) : '';
|
|
92
|
+
return (first + last).toUpperCase();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const Avatar: React.FC<AvatarProps> = ({ name, src, size = 'md', tone = 'brand', dot, className, children, ...rest }) => (
|
|
96
|
+
<span
|
|
97
|
+
className={['av', `av-${size}`, `av-${tone}`, className || ''].filter(Boolean).join(' ')}
|
|
98
|
+
aria-label={name}
|
|
99
|
+
{...rest}
|
|
100
|
+
>
|
|
101
|
+
{src ? <img src={src} alt={name || ''} /> : children != null ? children : initials(name)}
|
|
102
|
+
{dot ? <span className={['av-dot', typeof dot === 'string' ? `av-dot-${dot}` : ''].filter(Boolean).join(' ')} /> : null}
|
|
103
|
+
</span>
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
export interface AvatarGroupProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
107
|
+
/** Render "+N" overflow chip after the avatars. */
|
|
108
|
+
more?: number;
|
|
109
|
+
/** Size applied to the overflow chip. */
|
|
110
|
+
size?: AvatarSize;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const AvatarGroup: React.FC<AvatarGroupProps> = ({ more, size = 'md', className, children, ...rest }) => (
|
|
114
|
+
<span className={['av-group', className || ''].filter(Boolean).join(' ')} {...rest}>
|
|
115
|
+
{children}
|
|
116
|
+
{more ? <span className={`av av-${size} av-more`}>+{more}</span> : null}
|
|
117
|
+
</span>
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
/* ---------- Eyebrow — uppercase micro-label ---------- */
|
|
121
|
+
|
|
122
|
+
export type EyebrowSize = 'xs' | 'sm' | 'md';
|
|
123
|
+
export type EyebrowTone = 'muted' | 'secondary' | 'default' | 'brand' | 'inverse';
|
|
124
|
+
|
|
125
|
+
export interface EyebrowProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
126
|
+
size?: EyebrowSize;
|
|
127
|
+
tone?: EyebrowTone;
|
|
128
|
+
/** Inline icon — adds .has-icon for the flex layout. */
|
|
129
|
+
icon?: React.ReactNode;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const Eyebrow: React.FC<EyebrowProps> = ({ size = 'md', tone = 'muted', icon, className, children, ...rest }) => (
|
|
133
|
+
<span
|
|
134
|
+
className={['eyebrow', `eyebrow-${size}`, `eyebrow-${tone}`, icon != null ? 'has-icon' : '', className || '']
|
|
135
|
+
.filter(Boolean)
|
|
136
|
+
.join(' ')}
|
|
137
|
+
{...rest}
|
|
138
|
+
>
|
|
139
|
+
{icon}
|
|
140
|
+
{children}
|
|
141
|
+
</span>
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
/* ---------- Flag — brand flag SVGs from assets/flags ---------- */
|
|
145
|
+
|
|
146
|
+
export type FlagCountry = 'BR' | 'MX' | 'CO' | 'CL' | 'US' | 'EU';
|
|
147
|
+
export type FlagShape = 'rounded' | 'square';
|
|
148
|
+
|
|
149
|
+
const FLAG_FILE: Record<FlagCountry, string> = {
|
|
150
|
+
BR: 'Brazil',
|
|
151
|
+
MX: 'Mexico',
|
|
152
|
+
CO: 'Colombia',
|
|
153
|
+
CL: 'Chile',
|
|
154
|
+
US: 'EUA',
|
|
155
|
+
EU: 'EUR',
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export interface FlagProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, 'src'> {
|
|
159
|
+
country: FlagCountry;
|
|
160
|
+
/** Pixel size (width = height). Default 16. */
|
|
161
|
+
size?: number;
|
|
162
|
+
/** rounded (circular) | square. Default rounded. */
|
|
163
|
+
shape?: FlagShape;
|
|
164
|
+
/** Base path to assets/flags — default works two levels below root
|
|
165
|
+
(component benches and ui_kits/dashboard). Override elsewhere. */
|
|
166
|
+
assetsBase?: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export const Flag: React.FC<FlagProps> = ({ country, size = 16, shape = 'rounded', assetsBase = '../../assets/flags', style, ...rest }) => (
|
|
170
|
+
<img
|
|
171
|
+
src={`${assetsBase}/${FLAG_FILE[country]}-${shape}.svg`}
|
|
172
|
+
alt={country}
|
|
173
|
+
width={size}
|
|
174
|
+
height={size}
|
|
175
|
+
style={{ borderRadius: shape === 'rounded' ? '50%' : 'var(--radius-2xs)', display: 'inline-block', verticalAlign: '-0.18em', ...style }}
|
|
176
|
+
{...rest}
|
|
177
|
+
/>
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
/* ---------- Icon — canonical Lucide glyphs ---------- */
|
|
181
|
+
|
|
182
|
+
export interface IconProps extends React.SVGAttributes<SVGSVGElement> {
|
|
183
|
+
/** Lucide name — kebab-case ("arrow-left-right") or PascalCase. */
|
|
184
|
+
name: string;
|
|
185
|
+
/** Pixel size. Default 18. */
|
|
186
|
+
size?: number;
|
|
187
|
+
/** Stroke width. Default 1.75 (matches the system). */
|
|
188
|
+
stroke?: number;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
type LucideNode = Array<unknown>;
|
|
192
|
+
|
|
193
|
+
function lucideLookup(name: string): LucideNode | null {
|
|
194
|
+
const lucide = (window as unknown as { lucide?: { icons?: Record<string, LucideNode> } }).lucide;
|
|
195
|
+
if (!lucide || !lucide.icons) return null;
|
|
196
|
+
const pascal = name
|
|
197
|
+
.split('-')
|
|
198
|
+
.map((p) => p.charAt(0).toUpperCase() + p.slice(1))
|
|
199
|
+
.join('');
|
|
200
|
+
return lucide.icons[pascal] || lucide.icons[name] || null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/* Lucide UMD ships two icon-data shapes depending on version:
|
|
204
|
+
- pair list: [['path', {...}], ['line', {...}]] (newer)
|
|
205
|
+
- triple: ['svg', {...attrs}, [['path', {...}], ...]] (0.4xx)
|
|
206
|
+
Render both, recursively (children may themselves be triples). */
|
|
207
|
+
function renderLucideChildren(nodes: unknown, keyPrefix: string): React.ReactNode[] {
|
|
208
|
+
if (!Array.isArray(nodes)) return [];
|
|
209
|
+
return (nodes as Array<unknown>).map((child, i) => {
|
|
210
|
+
if (!Array.isArray(child) || typeof child[0] !== 'string') return null;
|
|
211
|
+
const tag = child[0] as string;
|
|
212
|
+
const attrs = (child[1] && typeof child[1] === 'object' ? child[1] : {}) as Record<string, string>;
|
|
213
|
+
const kids = renderLucideChildren(child[2], `${keyPrefix}${i}-`);
|
|
214
|
+
return React.createElement(tag, { ...attrs, key: `${keyPrefix}${i}` }, kids.length ? kids : undefined);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export const Icon: React.FC<IconProps> = ({ name, size = 18, stroke = 1.75, ...rest }) => {
|
|
219
|
+
const node = lucideLookup(name);
|
|
220
|
+
if (!node) return <span style={{ display: 'inline-block', width: size, height: size }} aria-hidden="true" />;
|
|
221
|
+
// Triple form: ['svg', attrs, children] — unwrap to the children list.
|
|
222
|
+
const children =
|
|
223
|
+
node.length >= 2 && node[0] === 'svg' ? (node[2] as unknown) : (node as unknown);
|
|
224
|
+
return (
|
|
225
|
+
<svg
|
|
226
|
+
width={size}
|
|
227
|
+
height={size}
|
|
228
|
+
viewBox="0 0 24 24"
|
|
229
|
+
fill="none"
|
|
230
|
+
stroke="currentColor"
|
|
231
|
+
strokeWidth={stroke}
|
|
232
|
+
strokeLinecap="round"
|
|
233
|
+
strokeLinejoin="round"
|
|
234
|
+
aria-hidden="true"
|
|
235
|
+
{...rest}
|
|
236
|
+
>
|
|
237
|
+
{renderLucideChildren(children, 'n')}
|
|
238
|
+
</svg>
|
|
239
|
+
);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
/* ---------- Divider ---------- */
|
|
243
|
+
|
|
244
|
+
export type DividerWeight = 'default' | 'subtle' | 'strong';
|
|
245
|
+
|
|
246
|
+
export interface DividerProps extends React.HTMLAttributes<HTMLElement> {
|
|
247
|
+
weight?: DividerWeight;
|
|
248
|
+
dashed?: boolean;
|
|
249
|
+
/** Vertical hairline for inline rows (1px × 1em). */
|
|
250
|
+
vertical?: boolean;
|
|
251
|
+
/** Midline label — renders the `.divider-labelled` layout. */
|
|
252
|
+
label?: React.ReactNode;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export const Divider: React.FC<DividerProps> = ({ weight = 'default', dashed = false, vertical = false, label, className, ...rest }) => {
|
|
256
|
+
const mods = [weight !== 'default' ? `divider-${weight}` : '', dashed ? 'divider-dashed' : '', className || ''];
|
|
257
|
+
if (label != null) {
|
|
258
|
+
return (
|
|
259
|
+
<div className={['divider-labelled', ...mods].filter(Boolean).join(' ')} {...rest}>
|
|
260
|
+
<span>{label}</span>
|
|
261
|
+
</div>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
if (vertical) return <span className={['divider-vertical', ...mods].filter(Boolean).join(' ')} {...(rest as React.HTMLAttributes<HTMLSpanElement>)} />;
|
|
265
|
+
return <hr className={['divider', ...mods].filter(Boolean).join(' ')} {...(rest as React.HTMLAttributes<HTMLHRElement>)} />;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
/* ---------- FilterChip — pill button for filter rows (40px) ---------- */
|
|
269
|
+
|
|
270
|
+
export interface FilterChipProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
271
|
+
/** Selected state (aria-pressed + active styling from CSS). */
|
|
272
|
+
selected?: boolean;
|
|
273
|
+
icon?: React.ReactNode;
|
|
274
|
+
/** Trailing dropdown indicator (`.chip-chevron`). */
|
|
275
|
+
chevron?: boolean;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export const FilterChip: React.FC<FilterChipProps> = ({ selected = false, icon, chevron = false, className, children, ...rest }) => (
|
|
279
|
+
<button type="button" className={['filter-chip', className || ''].filter(Boolean).join(' ')} aria-pressed={selected} {...rest}>
|
|
280
|
+
{icon}
|
|
281
|
+
{children}
|
|
282
|
+
{chevron ? (
|
|
283
|
+
<svg className="chip-chevron" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
284
|
+
<polyline points="6 9 12 15 18 9" />
|
|
285
|
+
</svg>
|
|
286
|
+
) : null}
|
|
287
|
+
</button>
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
/* ---------- ProgressBar — slim track + data-driven fill ---------- */
|
|
291
|
+
|
|
292
|
+
export interface ProgressBarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
293
|
+
/** 0–100. */
|
|
294
|
+
value: number;
|
|
295
|
+
/** Fill color — any token/var; defaults to the CSS fallback. */
|
|
296
|
+
fill?: string;
|
|
297
|
+
/** Track height px — feeds `--progress-h` (default 6). */
|
|
298
|
+
height?: number;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export const ProgressBar: React.FC<ProgressBarProps> = ({ value, fill, height, style, className, ...rest }) => (
|
|
302
|
+
<div
|
|
303
|
+
className={['progress', className || ''].filter(Boolean).join(' ')}
|
|
304
|
+
role="progressbar"
|
|
305
|
+
aria-valuenow={Math.round(value)}
|
|
306
|
+
aria-valuemin={0}
|
|
307
|
+
aria-valuemax={100}
|
|
308
|
+
style={{ ...(height != null ? ({ '--progress-h': `${height}px` } as React.CSSProperties) : null), ...style }}
|
|
309
|
+
{...rest}
|
|
310
|
+
>
|
|
311
|
+
<span className="progress-fill" style={{ width: `${Math.max(0, Math.min(100, value))}%`, ...(fill ? { background: fill } : null) }} />
|
|
312
|
+
</div>
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
/* ---------- DescTerm — labelled term/definition pair ---------- */
|
|
316
|
+
|
|
317
|
+
export interface DescTermProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
318
|
+
label: React.ReactNode;
|
|
319
|
+
children?: React.ReactNode;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export const DescTerm: React.FC<DescTermProps> = ({ label, className, children, ...rest }) => (
|
|
323
|
+
<div className={['desc-term', className || ''].filter(Boolean).join(' ')} {...rest}>
|
|
324
|
+
<span className="desc-term-label">{label}</span>
|
|
325
|
+
<span className="desc-term-value">{children}</span>
|
|
326
|
+
</div>
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
/* ---------- Stat — standalone KPI tile ---------- */
|
|
330
|
+
|
|
331
|
+
export type StatDeltaDirection = 'up' | 'down' | 'flat';
|
|
332
|
+
|
|
333
|
+
export interface StatProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
334
|
+
/** Mono overline label. */
|
|
335
|
+
label: React.ReactNode;
|
|
336
|
+
/** Big tabular figure. */
|
|
337
|
+
value: React.ReactNode;
|
|
338
|
+
/** Delta text, e.g. "+8.2%". Arrow glyph derives from deltaDirection. */
|
|
339
|
+
delta?: React.ReactNode;
|
|
340
|
+
/** up=success ↑ · down=danger ↓ · flat=muted. Default: 'flat'. */
|
|
341
|
+
deltaDirection?: StatDeltaDirection;
|
|
342
|
+
/** Footnote line (.stat-foot) — context under the figure. */
|
|
343
|
+
foot?: React.ReactNode;
|
|
344
|
+
/** Leading icon beside the label. */
|
|
345
|
+
icon?: React.ReactNode;
|
|
346
|
+
/** No tile chrome (bg/border/padding) — for use INSIDE a Card. */
|
|
347
|
+
bare?: boolean;
|
|
348
|
+
/** Dense paddings (.stat-compact). */
|
|
349
|
+
compact?: boolean;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const STAT_ARROW: Record<StatDeltaDirection, string> = { up: '↑ ', down: '↓ ', flat: '' };
|
|
353
|
+
|
|
354
|
+
export const Stat: React.FC<StatProps> = ({
|
|
355
|
+
label,
|
|
356
|
+
value,
|
|
357
|
+
delta,
|
|
358
|
+
deltaDirection = 'flat',
|
|
359
|
+
foot,
|
|
360
|
+
icon,
|
|
361
|
+
bare = false,
|
|
362
|
+
compact = false,
|
|
363
|
+
className,
|
|
364
|
+
children,
|
|
365
|
+
...rest
|
|
366
|
+
}) => (
|
|
367
|
+
<div
|
|
368
|
+
className={['stat', bare ? 'is-bare' : '', compact ? 'stat-compact' : '', className || ''].filter(Boolean).join(' ')}
|
|
369
|
+
{...rest}
|
|
370
|
+
>
|
|
371
|
+
<span className="stat-label" style={icon != null ? { display: 'inline-flex', alignItems: 'center', gap: 'var(--space-2)' } : undefined}>
|
|
372
|
+
{icon}
|
|
373
|
+
{label}
|
|
374
|
+
</span>
|
|
375
|
+
<span style={{ display: 'flex', alignItems: 'baseline', gap: 'var(--space-3)' }}>
|
|
376
|
+
<span className="stat-value">{value}</span>
|
|
377
|
+
{delta != null ? (
|
|
378
|
+
<span className={`stat-delta stat-delta-${deltaDirection}`}>
|
|
379
|
+
{STAT_ARROW[deltaDirection]}
|
|
380
|
+
{delta}
|
|
381
|
+
</span>
|
|
382
|
+
) : null}
|
|
383
|
+
</span>
|
|
384
|
+
{foot != null ? <div className="stat-foot">{foot}</div> : null}
|
|
385
|
+
{children}
|
|
386
|
+
</div>
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
export interface StatRowProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
390
|
+
/** Equal columns — feeds `--stat-cols`. Default 3. */
|
|
391
|
+
cols?: number;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export const StatRow: React.FC<StatRowProps> = ({ cols, className, style, children, ...rest }) => (
|
|
395
|
+
<div
|
|
396
|
+
className={['stat-row', className || ''].filter(Boolean).join(' ')}
|
|
397
|
+
style={cols != null ? ({ '--stat-cols': cols, ...style } as React.CSSProperties) : style}
|
|
398
|
+
{...rest}
|
|
399
|
+
>
|
|
400
|
+
{children}
|
|
401
|
+
</div>
|
|
402
|
+
);
|
|
403
|
+
|
|
404
|
+
/* Collection export — the bundler requires the module-name symbol. */
|
|
405
|
+
export const Atoms = { Money, Metric, Avatar, AvatarGroup, Eyebrow, Flag, Icon, Divider, FilterChip, ProgressBar, DescTerm, Stat, StatRow };
|
|
406
|
+
|
|
407
|
+
export default Atoms;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
export type ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'ghost' | 'danger' | 'danger-outline' | 'success' | 'link' | 'inverse';
|
|
4
|
+
export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
5
|
+
|
|
6
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
7
|
+
/** Visual emphasis. Default: 'primary'. */
|
|
8
|
+
variant?: ButtonVariant;
|
|
9
|
+
/** Control height: xs=24, sm=32, md=40 (default), lg=48. */
|
|
10
|
+
size?: ButtonSize;
|
|
11
|
+
/** Shows the canonical spinner and disables interaction. */
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
/** Square icon-only button (.btn-icon) — width locks to the height. */
|
|
14
|
+
iconOnly?: boolean;
|
|
15
|
+
/** Leading slot — typically an <Icon/>. */
|
|
16
|
+
icon?: React.ReactNode;
|
|
17
|
+
/** Trailing slot — e.g. a chevron. */
|
|
18
|
+
iconRight?: React.ReactNode;
|
|
19
|
+
/** On dark/brand panels: remaps ghost/secondary to the inverse foreground scale (`.on-inverse`). */
|
|
20
|
+
onInverse?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export declare const Button: React.FC<ButtonProps>;
|
|
24
|
+
export declare const ButtonGroup: React.FC<React.HTMLAttributes<HTMLDivElement>>;
|
|
25
|
+
export default Button;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ATTRUS Button — typed wrapper over the canonical `.btn` system
|
|
5
|
+
* (preview/components/buttons.css). The CSS stays the single source
|
|
6
|
+
* of visual truth; this component only composes class names.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export type ButtonVariant =
|
|
10
|
+
| 'primary' /* brand fill — main action */
|
|
11
|
+
| 'secondary' /* neutral fill + hairline border — alternative actions */
|
|
12
|
+
| 'tertiary' /* soft neutral fill, borderless — quiet affirmative */
|
|
13
|
+
| 'ghost' /* nothing until hover — toolbars, table rows */
|
|
14
|
+
| 'danger' /* destructive solid */
|
|
15
|
+
| 'danger-outline' /* destructive contextual — outline, surface bg */
|
|
16
|
+
| 'success' /* strong positive (rare) */
|
|
17
|
+
| 'link' /* looks like an inline text link */
|
|
18
|
+
| 'inverse'; /* white on dark/brand panels */
|
|
19
|
+
|
|
20
|
+
export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
21
|
+
|
|
22
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
23
|
+
/** Visual emphasis. Default: 'primary'. */
|
|
24
|
+
variant?: ButtonVariant;
|
|
25
|
+
/** Control height: xs=24, sm=32, md=40 (default), lg=48. */
|
|
26
|
+
size?: ButtonSize;
|
|
27
|
+
/** Shows the canonical spinner and disables interaction. */
|
|
28
|
+
loading?: boolean;
|
|
29
|
+
/** Square icon-only button (.btn-icon) — width locks to the height. */
|
|
30
|
+
iconOnly?: boolean;
|
|
31
|
+
/** Leading slot — typically an <Icon/>. */
|
|
32
|
+
icon?: React.ReactNode;
|
|
33
|
+
/** Trailing slot — e.g. a chevron. */
|
|
34
|
+
iconRight?: React.ReactNode;
|
|
35
|
+
/** On dark/brand panels: remaps ghost/secondary to the inverse foreground
|
|
36
|
+
* scale (`.on-inverse`). Only meaningful with variant 'ghost' | 'secondary'. */
|
|
37
|
+
onInverse?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const Button: React.FC<ButtonProps> = ({
|
|
41
|
+
variant = 'primary',
|
|
42
|
+
size = 'md',
|
|
43
|
+
loading = false,
|
|
44
|
+
iconOnly = false,
|
|
45
|
+
icon,
|
|
46
|
+
iconRight,
|
|
47
|
+
onInverse = false,
|
|
48
|
+
className,
|
|
49
|
+
children,
|
|
50
|
+
disabled,
|
|
51
|
+
type = 'button',
|
|
52
|
+
...rest
|
|
53
|
+
}) => {
|
|
54
|
+
const cls = [
|
|
55
|
+
'btn',
|
|
56
|
+
`btn-${variant}`,
|
|
57
|
+
size !== 'md' ? `btn-${size}` : '',
|
|
58
|
+
iconOnly ? 'btn-icon' : '',
|
|
59
|
+
loading ? 'is-loading' : '',
|
|
60
|
+
onInverse ? 'on-inverse' : '',
|
|
61
|
+
className || '',
|
|
62
|
+
]
|
|
63
|
+
.filter(Boolean)
|
|
64
|
+
.join(' ');
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<button type={type} className={cls} disabled={disabled || loading} aria-busy={loading || undefined} {...rest}>
|
|
68
|
+
{icon}
|
|
69
|
+
{children}
|
|
70
|
+
{iconRight}
|
|
71
|
+
</button>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default Button;
|
|
76
|
+
|
|
77
|
+
/** Segmented / toolbar cluster — children must be <Button>s (`.btn-group`):
|
|
78
|
+
* outer corners pill-rounded, inner seams collapsed. */
|
|
79
|
+
export const ButtonGroup: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({ className, children, ...rest }) => (
|
|
80
|
+
<div role="group" className={['btn-group', className || ''].filter(Boolean).join(' ')} {...rest}>
|
|
81
|
+
{children}
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
export type CalloutTone = 'info' | 'warn' | 'success' | 'danger' | 'neutral';
|
|
4
|
+
|
|
5
|
+
export interface CalloutProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
/** Semantic tone. Default 'info' (brand royal tint). */
|
|
7
|
+
tone?: CalloutTone;
|
|
8
|
+
/** Compact density for dense panels & forms. */
|
|
9
|
+
small?: boolean;
|
|
10
|
+
/** Leading icon slot (18px, 16px when small). */
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
/** Bold heading line — wraps content in the rich vertical layout. */
|
|
13
|
+
title?: React.ReactNode;
|
|
14
|
+
/** Action row (canonical Buttons). Implies the rich layout. */
|
|
15
|
+
actions?: React.ReactNode;
|
|
16
|
+
/** Full-width alert bar: centered row, left accent rule, actions inline-right. */
|
|
17
|
+
bar?: boolean;
|
|
18
|
+
/** On a bar: re-adds radius + full border for in-container use. */
|
|
19
|
+
rounded?: boolean;
|
|
20
|
+
/** Content-sized, single line (badges, hero notices). */
|
|
21
|
+
inline?: boolean;
|
|
22
|
+
/** Glassy translucent tint + light text for dark surfaces. */
|
|
23
|
+
onInverse?: boolean;
|
|
24
|
+
/** When set, renders the × dismiss button and calls back on click. */
|
|
25
|
+
onDismiss?: () => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export declare const Callout: React.FC<CalloutProps>;
|
|
29
|
+
export default Callout;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ATTRUS Callout — typed wrapper over the canonical `.callout` system
|
|
5
|
+
* (preview/components/callout.css). Scales from a one-line note up to a
|
|
6
|
+
* rich panel (title + body + actions + dismiss) and a full-width alert bar.
|
|
7
|
+
* CSS stays the visual source of truth.
|
|
8
|
+
*
|
|
9
|
+
* Action buttons convention: keep them SMALL and DISCREET — Button
|
|
10
|
+
* size="xs" with ghost/tertiary/secondary; reserve solid fills and
|
|
11
|
+
* danger for destructive actions.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export type CalloutTone = 'info' | 'warn' | 'success' | 'danger' | 'neutral';
|
|
15
|
+
|
|
16
|
+
export interface CalloutProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
17
|
+
/** Semantic tone. Default 'info' (brand royal tint). */
|
|
18
|
+
tone?: CalloutTone;
|
|
19
|
+
/** Compact density for dense panels & forms. */
|
|
20
|
+
small?: boolean;
|
|
21
|
+
/** Leading icon slot (18px, 16px when small). */
|
|
22
|
+
icon?: React.ReactNode;
|
|
23
|
+
/** Bold heading line — wraps content in the rich vertical layout. */
|
|
24
|
+
title?: React.ReactNode;
|
|
25
|
+
/** Action row (canonical Buttons). Implies the rich layout. */
|
|
26
|
+
actions?: React.ReactNode;
|
|
27
|
+
/** Full-width alert bar: centered row, left accent rule, actions inline-right. */
|
|
28
|
+
bar?: boolean;
|
|
29
|
+
/** On a bar: re-adds radius + full border for in-container use. */
|
|
30
|
+
rounded?: boolean;
|
|
31
|
+
/** Content-sized, single line (badges, hero notices). */
|
|
32
|
+
inline?: boolean;
|
|
33
|
+
/** Glassy translucent tint + light text for dark surfaces. */
|
|
34
|
+
onInverse?: boolean;
|
|
35
|
+
/** When set, renders the × dismiss button and calls back on click. */
|
|
36
|
+
onDismiss?: () => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const DismissGlyph: React.FC = () => (
|
|
40
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" aria-hidden="true">
|
|
41
|
+
<line x1="6" y1="6" x2="18" y2="18" />
|
|
42
|
+
<line x1="18" y1="6" x2="6" y2="18" />
|
|
43
|
+
</svg>
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export const Callout: React.FC<CalloutProps> = ({
|
|
47
|
+
tone = 'info',
|
|
48
|
+
small = false,
|
|
49
|
+
icon,
|
|
50
|
+
title,
|
|
51
|
+
actions,
|
|
52
|
+
bar = false,
|
|
53
|
+
rounded = false,
|
|
54
|
+
inline = false,
|
|
55
|
+
onInverse = false,
|
|
56
|
+
onDismiss,
|
|
57
|
+
className,
|
|
58
|
+
children,
|
|
59
|
+
...rest
|
|
60
|
+
}) => {
|
|
61
|
+
const cls = [
|
|
62
|
+
'callout',
|
|
63
|
+
`callout-${tone}`, /* always emitted — .callout-info pairs with .on-inverse in CSS */
|
|
64
|
+
small ? 'callout-sm' : '',
|
|
65
|
+
bar ? 'callout-bar' : '',
|
|
66
|
+
bar && rounded ? 'callout-rounded' : '',
|
|
67
|
+
inline ? 'callout-inline' : '',
|
|
68
|
+
onInverse ? 'on-inverse' : '',
|
|
69
|
+
className || '',
|
|
70
|
+
]
|
|
71
|
+
.filter(Boolean)
|
|
72
|
+
.join(' ');
|
|
73
|
+
|
|
74
|
+
const rich = Boolean(title || actions);
|
|
75
|
+
const body = children != null ? <div className="callout-body">{children}</div> : null;
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div className={cls} role={tone === 'danger' ? 'alert' : 'status'} {...rest}>
|
|
79
|
+
{icon}
|
|
80
|
+
{rich ? (
|
|
81
|
+
<div className="callout-content">
|
|
82
|
+
{title ? <div className="callout-title">{title}</div> : null}
|
|
83
|
+
{body}
|
|
84
|
+
{actions ? <div className="callout-actions">{actions}</div> : null}
|
|
85
|
+
</div>
|
|
86
|
+
) : (
|
|
87
|
+
body
|
|
88
|
+
)}
|
|
89
|
+
{onDismiss ? (
|
|
90
|
+
<button type="button" className="callout-dismiss" aria-label="Dismiss" onClick={onDismiss}>
|
|
91
|
+
<DismissGlyph />
|
|
92
|
+
</button>
|
|
93
|
+
) : null}
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default Callout;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
export type CardVariant = 'default' | 'flat' | 'subtle' | 'sunken' | 'raised' | 'floating' | 'hero' | 'inverse';
|
|
4
|
+
export type CardAccent = 'success' | 'warning' | 'danger' | 'info';
|
|
5
|
+
export type CardDensity = 'compact' | 'default' | 'spacious';
|
|
6
|
+
|
|
7
|
+
export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
/** Surface role. Default: surface + hairline + xs shadow. */
|
|
9
|
+
variant?: CardVariant;
|
|
10
|
+
/** Semantic banner tint (success/warning/danger/info). */
|
|
11
|
+
accent?: CardAccent;
|
|
12
|
+
/** Padding density for the card and its slots. */
|
|
13
|
+
density?: CardDensity;
|
|
14
|
+
/** Clip children to the rounded corners (tables, images). */
|
|
15
|
+
clip?: boolean;
|
|
16
|
+
/** Hover/press affordance (`.card.interactive`). */
|
|
17
|
+
interactive?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface CardStatProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
21
|
+
label: React.ReactNode;
|
|
22
|
+
value: React.ReactNode;
|
|
23
|
+
/** Delta text, e.g. "+8.2%". */
|
|
24
|
+
delta?: React.ReactNode;
|
|
25
|
+
/** up=success, down=danger, flat=muted. Default: 'flat'. */
|
|
26
|
+
deltaDirection?: 'up' | 'down' | 'flat';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface CardSlotProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
30
|
+
|
|
31
|
+
export declare const Card: React.FC<CardProps>;
|
|
32
|
+
export declare const CardHeader: React.FC<CardSlotProps>;
|
|
33
|
+
export declare const CardBody: React.FC<CardSlotProps>;
|
|
34
|
+
export declare const CardFooter: React.FC<CardSlotProps>;
|
|
35
|
+
export declare const CardCanvas: React.FC<CardSlotProps>;
|
|
36
|
+
export declare const CardDivider: React.FC<CardSlotProps>;
|
|
37
|
+
export declare const CardStat: React.FC<CardStatProps>;
|
|
38
|
+
export default Card;
|