@appdirect/design-system 0.0.25 → 0.0.28
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 +11 -0
- package/dist/ComplexComponents/DashboardWidget/DashboardWidget.js +1 -1
- package/dist/ComplexComponents/DashboardWidget/DashboardWidget.tsx +9 -7
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +1 -1
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.tsx +1 -1
- package/dist/ComplexComponents/KeyInsight/KeyInsights.js +6 -1
- package/dist/ComplexComponents/KeyInsight/KeyInsights.tsx +12 -2
- package/dist/ComplexComponents/PageContentHeader/PageContentHeader.js +1 -1
- package/dist/ComplexComponents/PageContentHeader/PageContentHeader.tsx +16 -11
- package/dist/ComplexComponents/Slat/Slat.js +14 -7
- package/dist/ComplexComponents/Slat/Slat.tsx +31 -19
- package/dist/DESIGN.md +4 -0
- package/dist/DataDisplay/Alert.js +2 -2
- package/dist/DataDisplay/Alert.tsx +7 -0
- package/dist/DataDisplay/Card.js +5 -4
- package/dist/DataDisplay/Card.tsx +5 -11
- package/dist/Overlays/Modal.js +2 -2
- package/dist/Overlays/Modal.tsx +4 -4
- package/dist/contracts/Alert.json +5 -0
- package/dist/contracts/index.json +1 -1
- package/dist/css/mantine.css +120 -12
- package/dist/css/tokens.css +52 -14
- package/dist/hooks/index.js +18 -0
- package/dist/hooks/index.ts +28 -0
- package/dist/hooks/useSelectedRowsText.js +73 -0
- package/dist/hooks/useSelectedRowsText.ts +74 -0
- package/dist/stories/ComplexComponents/DashboardWidget/DashboardWidget.stories.tsx +7 -0
- package/dist/stories/ComplexComponents/PageContentHeader/PageContentHeader.stories.tsx +21 -21
- package/dist/stories/DataDisplay/Progress.stories.tsx +11 -27
- package/dist/stories/Navigation/Stepper.stories.tsx +25 -21
- package/dist/stories/Overlays/Drawer.stories.tsx +6 -6
- package/dist/stories/Overlays/Modal.stories.tsx +31 -11
- package/dist/stories/index.json +4 -3
- package/package.json +97 -3
package/README.md
CHANGED
|
@@ -97,6 +97,17 @@ export function Example() {
|
|
|
97
97
|
}
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
+
Prefer the barrel for everyday use. For a single complex or `AD*` component without pulling the rest of the barrel, use a subpath export:
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import { PageContentHeader } from '@appdirect/design-system/ComplexComponents/PageContentHeader';
|
|
104
|
+
import { KeyInsight } from '@appdirect/design-system/ComplexComponents/KeyInsight';
|
|
105
|
+
import { ADMultiselect } from '@appdirect/design-system/Combobox/ADMultiselect';
|
|
106
|
+
import { Button } from '@appdirect/design-system/Buttons';
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Category folders (`Buttons`, `Inputs`, `Layout`, …), `ComplexComponents/<Name>`, and `AD*` modules (e.g. `Combobox/ADMultiselect`) are listed in `package.json` `exports`. `npm run test:build` discovers every ComplexComponent folder and every `AD*.tsx` and asserts barrel + subpath resolve.
|
|
110
|
+
|
|
100
111
|
Use AppDirect button variants (`primary`, `secondary`, `default`, `outline`, `danger`, `link`, `secret`), not Mantine `filled` / `light` / `subtle`. Prefer `--ad-*` tokens for colour; avoid palette props like `color="blue"`.
|
|
101
112
|
|
|
102
113
|
Shared helpers:
|
|
@@ -56,5 +56,5 @@ export function DashboardWidget({ title, editable = false, onEdit, panelNotifica
|
|
|
56
56
|
const hasFooterLinks = Boolean(footerLinks && footerLinks.length > 0);
|
|
57
57
|
const renderHeader = () => (_jsxs("div", { className: "ad-DashboardWidget-header", children: [_jsxs("div", { className: "ad-DashboardWidget-titleGroup", children: [_jsx(Title, { order: 4, className: "ad-DashboardWidget-title", children: title }), editable && (_jsx(ActionIcon, { size: "sm", onClick: onEdit, "aria-label": "Edit title", children: _jsx(RiEditLine, { size: 16 }) }))] }), _jsxs("div", { className: "ad-DashboardWidget-controls", children: [switchConfig && (_jsxs("div", { className: "ad-DashboardWidget-switch", children: [switchConfig.label ? _jsx(Text, { size: "sm", children: switchConfig.label }) : null, _jsx(Switch, { checked: switchConfig.checked, onChange: (event) => switchConfig.onChange(event.currentTarget.checked), disabled: switchConfig.disabled, size: "sm" })] })), headerSelect && (_jsx(Select, { data: headerSelect.data, value: headerSelect.value, onChange: headerSelect.onChange, placeholder: headerSelect.placeholder, disabled: headerSelect.disabled, searchable: headerSelect.searchable, clearable: headerSelect.clearable, borderless: true, size: "sm" })), actionsMenu && !headerSelect && (_jsx(Menu, { trigger: _jsx(ActionIcon, { size: "sm", "aria-label": "Widget actions", children: _jsx(RiMore2Fill, { size: 16 }) }), position: "bottom-end", sections: actionsMenu.sections }))] })] }));
|
|
58
58
|
const renderFooter = () => (_jsx("div", { className: "ad-DashboardWidget-footer", children: hasFooterLinks ? (_jsx("div", { className: "ad-DashboardWidget-footerLinks", children: footerLinks.map((link, index) => (_jsxs("button", { type: "button", className: "ad-DashboardWidget-footerLink", "data-disabled": link.disabled ? '' : undefined, disabled: link.disabled, onClick: link.disabled ? undefined : link.onClick, children: [_jsx(Text, { span: true, size: "sm", children: link.label }), _jsx(RiArrowRightSLine, { size: 14 })] }, index))) })) : (_jsx("div", { className: "ad-DashboardWidget-footerSpacer" })) }));
|
|
59
|
-
return (_jsxs(Card, { ...restCardProps, style: cardStyle, className: ['ad-DashboardWidget', cardClassName].filter(Boolean).join(' '), "data-interactive": interactive ? '' : undefined, "data-selected": selected ? '' : undefined, children: [_jsxs("div", { className: "ad-DashboardWidget-body", "data-spacing": spacing === 'lg' ? undefined : spacing, children: [renderHeader(),
|
|
59
|
+
return (_jsxs(Card, { ...restCardProps, style: cardStyle, className: ['ad-DashboardWidget', cardClassName].filter(Boolean).join(' '), "data-interactive": interactive ? '' : undefined, "data-selected": selected ? '' : undefined, children: [panelNotification && (_jsx("div", { className: "ad-DashboardWidget-notification", children: _jsx(Alert, { panel: true, color: "info", children: panelNotificationMessage }) })), _jsxs("div", { className: "ad-DashboardWidget-body", "data-spacing": spacing === 'lg' ? undefined : spacing, children: [renderHeader(), _jsx("div", { className: "ad-DashboardWidget-content", children: children })] }), renderFooter()] }));
|
|
60
60
|
}
|
|
@@ -31,7 +31,7 @@ export interface DashboardWidgetProps {
|
|
|
31
31
|
onEdit?: () => void;
|
|
32
32
|
|
|
33
33
|
// ==================== PANEL NOTIFICATION ====================
|
|
34
|
-
/** Whether to show a panel notification
|
|
34
|
+
/** Whether to show a panel notification bar flush at the top of the widget, above the header */
|
|
35
35
|
panelNotification?: boolean;
|
|
36
36
|
/** Content for the panel notification (ignored when panelNotification is false) */
|
|
37
37
|
panelNotificationMessage?: React.ReactNode;
|
|
@@ -242,18 +242,20 @@ export function DashboardWidget({
|
|
|
242
242
|
data-interactive={interactive ? '' : undefined}
|
|
243
243
|
data-selected={selected ? '' : undefined}
|
|
244
244
|
>
|
|
245
|
+
{panelNotification && (
|
|
246
|
+
<div className="ad-DashboardWidget-notification">
|
|
247
|
+
<Alert panel color="info">
|
|
248
|
+
{panelNotificationMessage}
|
|
249
|
+
</Alert>
|
|
250
|
+
</div>
|
|
251
|
+
)}
|
|
252
|
+
|
|
245
253
|
<div
|
|
246
254
|
className="ad-DashboardWidget-body"
|
|
247
255
|
data-spacing={spacing === 'lg' ? undefined : spacing}
|
|
248
256
|
>
|
|
249
257
|
{renderHeader()}
|
|
250
258
|
|
|
251
|
-
{panelNotification && (
|
|
252
|
-
<Alert color="info">
|
|
253
|
-
{panelNotificationMessage}
|
|
254
|
-
</Alert>
|
|
255
|
-
)}
|
|
256
|
-
|
|
257
259
|
<div className="ad-DashboardWidget-content">
|
|
258
260
|
{children}
|
|
259
261
|
</div>
|
|
@@ -6,7 +6,7 @@ import { CloseButton, Combobox, InputBase, InputPlaceholder, Popover, useCombobo
|
|
|
6
6
|
import { DatePicker } from "@mantine/dates";
|
|
7
7
|
import { translate } from "../../translations/index.js"; // DS-ADAPT: translate lives in DataTable/translations
|
|
8
8
|
import { Preset, getPresetLabel, getPresets, getDateRangeFromPreset } from "./utils.js";
|
|
9
|
-
import useClickOutside from
|
|
9
|
+
import useClickOutside from "../../hooks/useClickOutside.js";
|
|
10
10
|
import styles from "./DateRangeSelectorFilter.module.css";
|
|
11
11
|
/** Parse a local `YYYY-MM-DD` string (or Date) to a local-midnight Date. */
|
|
12
12
|
const toLocalDate = (value) => {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import { DatePicker, DatesRangeValue } from "@mantine/dates";
|
|
13
13
|
import { translate } from "../../translations"; // DS-ADAPT: translate lives in DataTable/translations
|
|
14
14
|
import { Preset, getPresetLabel, getPresets, getDateRangeFromPreset } from "./utils";
|
|
15
|
-
import useClickOutside from
|
|
15
|
+
import useClickOutside from "../../hooks/useClickOutside";
|
|
16
16
|
import styles from "./DateRangeSelectorFilter.module.css";
|
|
17
17
|
|
|
18
18
|
/** DS-ADAPT: Mantine 9 DatePicker works with local `YYYY-MM-DD` strings; presets emit Dates. */
|
|
@@ -24,6 +24,11 @@ function resolveSize(size) {
|
|
|
24
24
|
}
|
|
25
25
|
return size;
|
|
26
26
|
}
|
|
27
|
+
// Fixed locale so server and client render identically (no hydration mismatch).
|
|
28
|
+
const numberFormatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
|
|
29
|
+
function formatValue(value) {
|
|
30
|
+
return typeof value === 'number' && Number.isFinite(value) ? numberFormatter.format(value) : value;
|
|
31
|
+
}
|
|
27
32
|
/**
|
|
28
33
|
* KeyInsight Component
|
|
29
34
|
*
|
|
@@ -36,5 +41,5 @@ function resolveSize(size) {
|
|
|
36
41
|
export function KeyInsight({ value, title, subtitle, showBorder = false, size = 'level-2', valueAs, leftSection, rightSection, }) {
|
|
37
42
|
const canonicalSize = resolveSize(size);
|
|
38
43
|
const ValueElement = valueAs ?? DEFAULT_VALUE_ELEMENT[canonicalSize];
|
|
39
|
-
return (_jsxs(Box, { className: "ad-KeyInsight", "data-size": canonicalSize, "data-border": showBorder ? '' : undefined, children: [_jsxs(Box, { className: "ad-KeyInsight-valueRow", children: [leftSection, _jsx(ValueElement, { className: "ad-KeyInsight-value", children: value }), rightSection] }), _jsx("p", { className: "ad-KeyInsight-title", children: title }), subtitle ? _jsx("p", { className: "ad-KeyInsight-subtitle", children: subtitle }) : null] }));
|
|
44
|
+
return (_jsxs(Box, { className: "ad-KeyInsight", "data-size": canonicalSize, "data-border": showBorder ? '' : undefined, children: [_jsxs(Box, { className: "ad-KeyInsight-valueRow", children: [leftSection, _jsx(ValueElement, { className: "ad-KeyInsight-value", children: formatValue(value) }), rightSection] }), _jsx("p", { className: "ad-KeyInsight-title", children: title }), subtitle ? _jsx("p", { className: "ad-KeyInsight-subtitle", children: subtitle }) : null] }));
|
|
40
45
|
}
|
|
@@ -24,7 +24,10 @@ export type KeyInsightSize = KeyInsightCanonicalSize | KeyInsightLegacySize;
|
|
|
24
24
|
export type KeyInsightValueAs = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span';
|
|
25
25
|
|
|
26
26
|
export interface KeyInsightProps {
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Value to display. Numbers are shown with thousands separators (`11987` → `11,987`).
|
|
29
|
+
* Strings are rendered as-is, so pre-formatted values like `"95%"` or IDs are never altered.
|
|
30
|
+
*/
|
|
28
31
|
value: string | number;
|
|
29
32
|
/** Title/label for the insight */
|
|
30
33
|
title: string;
|
|
@@ -76,6 +79,13 @@ function resolveSize(size: KeyInsightSize): KeyInsightCanonicalSize {
|
|
|
76
79
|
return size as KeyInsightCanonicalSize;
|
|
77
80
|
}
|
|
78
81
|
|
|
82
|
+
// Fixed locale so server and client render identically (no hydration mismatch).
|
|
83
|
+
const numberFormatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
|
|
84
|
+
|
|
85
|
+
function formatValue(value: string | number): string | number {
|
|
86
|
+
return typeof value === 'number' && Number.isFinite(value) ? numberFormatter.format(value) : value;
|
|
87
|
+
}
|
|
88
|
+
|
|
79
89
|
/**
|
|
80
90
|
* KeyInsight Component
|
|
81
91
|
*
|
|
@@ -106,7 +116,7 @@ export function KeyInsight({
|
|
|
106
116
|
>
|
|
107
117
|
<Box className="ad-KeyInsight-valueRow">
|
|
108
118
|
{leftSection}
|
|
109
|
-
<ValueElement className="ad-KeyInsight-value">{value}</ValueElement>
|
|
119
|
+
<ValueElement className="ad-KeyInsight-value">{formatValue(value)}</ValueElement>
|
|
110
120
|
{rightSection}
|
|
111
121
|
</Box>
|
|
112
122
|
<p className="ad-KeyInsight-title">{title}</p>
|
|
@@ -88,5 +88,5 @@ cardProps = {}, spacing = 'sm', }) {
|
|
|
88
88
|
};
|
|
89
89
|
// ==================== MAIN RENDER ==========================
|
|
90
90
|
const contentSection_ = renderContentSection();
|
|
91
|
-
return (_jsxs(Card, {
|
|
91
|
+
return (_jsxs(Card, { ...cardProps, children: [panelNotification && (_jsx(Card.Section, { children: _jsx(Alert, { panel: true, color: "info", children: panelNotificationMessage }) })), _jsxs(Stack, { gap: spacing, mt: panelNotification ? 'var(--card-padding)' : undefined, children: [_jsx(Box, { children: renderHeader() }), actions.length > 0 && (_jsx(Box, { children: renderActions() }))] }), contentSection_ && (_jsx(Card.Section, { withBorder: true, mt: "md", children: contentSection_ }))] }));
|
|
92
92
|
}
|
|
@@ -43,7 +43,10 @@ export interface PageContentHeaderProps {
|
|
|
43
43
|
onEdit?: () => void;
|
|
44
44
|
|
|
45
45
|
// ==================== ACTION BUTTONS ====================
|
|
46
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Array of action buttons, rendered left-aligned in array order. List the primary action first,
|
|
48
|
+
* then the rest in descending importance. Uses semantic variants instead of explicit colors.
|
|
49
|
+
*/
|
|
47
50
|
actions?: Array<{
|
|
48
51
|
label: string;
|
|
49
52
|
onClick: () => void;
|
|
@@ -52,7 +55,7 @@ export interface PageContentHeaderProps {
|
|
|
52
55
|
}>;
|
|
53
56
|
|
|
54
57
|
// ==================== PANEL NOTIFICATION ====================
|
|
55
|
-
/** Whether to show a panel notification
|
|
58
|
+
/** Whether to show a panel notification bar flush at the top of the card, above the header */
|
|
56
59
|
panelNotification?: boolean;
|
|
57
60
|
/** Content for the panel notification (ignored when panelNotification is false) */
|
|
58
61
|
panelNotificationMessage?: React.ReactNode;
|
|
@@ -342,9 +345,17 @@ export function PageContentHeader({
|
|
|
342
345
|
const contentSection_ = renderContentSection();
|
|
343
346
|
|
|
344
347
|
return (
|
|
345
|
-
<Card
|
|
346
|
-
{/*
|
|
347
|
-
|
|
348
|
+
<Card {...cardProps}>
|
|
349
|
+
{/* Panel notification: compact bar flush to the top and sides of the card (Figma puts it above the header) */}
|
|
350
|
+
{panelNotification && (
|
|
351
|
+
<Card.Section>
|
|
352
|
+
<Alert panel color="info">
|
|
353
|
+
{panelNotificationMessage}
|
|
354
|
+
</Alert>
|
|
355
|
+
</Card.Section>
|
|
356
|
+
)}
|
|
357
|
+
{/* Header Section. After the bar, the card's own padding is restored above it. */}
|
|
358
|
+
<Stack gap={spacing} mt={panelNotification ? 'var(--card-padding)' : undefined}>
|
|
348
359
|
<Box>
|
|
349
360
|
{renderHeader()}
|
|
350
361
|
</Box>
|
|
@@ -354,12 +365,6 @@ export function PageContentHeader({
|
|
|
354
365
|
{renderActions()}
|
|
355
366
|
</Box>
|
|
356
367
|
)}
|
|
357
|
-
{/* Panel notification */}
|
|
358
|
-
{panelNotification && (
|
|
359
|
-
<Alert color="info">
|
|
360
|
-
{panelNotificationMessage}
|
|
361
|
-
</Alert>
|
|
362
|
-
)}
|
|
363
368
|
</Stack>
|
|
364
369
|
|
|
365
370
|
{/* Content Section - uses Card.Section to bleed to edges */}
|
|
@@ -18,18 +18,24 @@ const TITLE_ORDER_BY_SIZE = {
|
|
|
18
18
|
lg: 3,
|
|
19
19
|
xl: 2,
|
|
20
20
|
};
|
|
21
|
-
//
|
|
22
|
-
// indicator has no real child to overlay, so
|
|
23
|
-
// footprint the dot/pill occupies, keeping it in flow instead of collapsing
|
|
21
|
+
// Indicator px size per Slat size (slat.sizes.*.indicatorSize, the Indicator scale 8-24px).
|
|
22
|
+
// The standalone subhead indicator has no real child to overlay, so a box of the same size
|
|
23
|
+
// reserves the footprint the dot/pill occupies, keeping it in flow instead of collapsing
|
|
24
24
|
// to zero size and overlapping neighboring subtitle/badge content.
|
|
25
|
-
const
|
|
25
|
+
const INDICATOR_SIZE_BY_SIZE = {
|
|
26
|
+
xs: 8,
|
|
27
|
+
sm: 12,
|
|
28
|
+
md: 16,
|
|
29
|
+
lg: 20,
|
|
30
|
+
xl: 24,
|
|
31
|
+
};
|
|
26
32
|
// ========================== COMPONENT ==========================
|
|
27
33
|
/**
|
|
28
34
|
* Slat Component
|
|
29
35
|
*
|
|
30
36
|
* A compact row for listing items (e.g. in a feed or list), with a leading
|
|
31
37
|
* icon, title/subtitle, optional status indicator or badge, a trailing
|
|
32
|
-
* action, and an optional notification banner
|
|
38
|
+
* action, and an optional notification banner on top.
|
|
33
39
|
*
|
|
34
40
|
* @example
|
|
35
41
|
* <Slat
|
|
@@ -48,6 +54,7 @@ const INDICATOR_DOT_SIZE = 12;
|
|
|
48
54
|
* action={{ label: 'Review', onClick: () => {} }}
|
|
49
55
|
* />
|
|
50
56
|
*/
|
|
51
|
-
export function Slat({ size = 'xs', icon, showIcon = true, title, subtitle, indicator, badge, action, notification, rightSection, shadow, withBorder = false, }) {
|
|
52
|
-
|
|
57
|
+
export function Slat({ size = 'xs', icon, showIcon = true, title, subtitle, indicator, badge, action, notification, rightSection, shadow = 'xs', withBorder = false, }) {
|
|
58
|
+
const indicatorSize = INDICATOR_SIZE_BY_SIZE[size];
|
|
59
|
+
return (_jsxs(Paper, { className: "ad-Slat", "data-size": size, shadow: shadow, withBorder: withBorder, children: [notification && (_jsx(Alert, { panel: true, color: "info", children: notification })), _jsxs(Stack, { gap: "xs", children: [_jsxs(Inline, { gap: "sm", align: "center", p: "sm", children: [_jsxs(Inline, { gap: "xs", align: "center", style: { flex: 1, minWidth: 0 }, children: [showIcon && icon && (_jsx(ThemeIcon, { className: "ad-Slat-icon", children: icon })), _jsxs(Stack, { gap: 0, style: { flex: 1, minWidth: 0 }, children: [_jsx(Title, { className: "ad-Slat-title", order: TITLE_ORDER_BY_SIZE[size], children: title }), (subtitle || indicator || badge) && (_jsxs(Inline, { className: "ad-Slat-subhead", align: "center", children: [indicator && (_jsx(Indicator, { type: indicator.variant ?? 'default', label: indicator.label, withBorder: indicator.withBorder, size: indicatorSize, position: "middle-center", offset: 0, inline: true, children: _jsx("div", { style: { width: indicatorSize, height: indicatorSize } }) })), subtitle && _jsx(Text, { className: "ad-Slat-subtitle", size: size, children: subtitle }), badge && (_jsx(Badge, { size: size, variant: badge.variant ?? 'outline', color: badge.color ?? 'default', children: badge.label }))] }))] })] }), action && (_jsx(Button, { variant: action.variant ?? 'default', size: size, onClick: action.onClick, children: action.label }))] }), rightSection && _jsx(Box, { children: rightSection })] })] }));
|
|
53
60
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Paper } from '../../Misc/Paper';
|
|
5
5
|
import { type DSPaperProps } from '../../Misc/Paper';
|
|
6
|
-
import { ThemeIcon
|
|
6
|
+
import { ThemeIcon } from '../../DataDisplay/ThemeIcon';
|
|
7
7
|
import { Indicator } from '../../DataDisplay/Indicator';
|
|
8
8
|
import { Badge } from '../../DataDisplay/Badge';
|
|
9
9
|
import { Alert } from '../../DataDisplay/Alert';
|
|
@@ -55,17 +55,17 @@ export interface SlatProps {
|
|
|
55
55
|
title: string;
|
|
56
56
|
/** Optional subtitle below the title */
|
|
57
57
|
subtitle?: string;
|
|
58
|
-
/** Optional status indicator shown
|
|
58
|
+
/** Optional status indicator shown before the subtitle */
|
|
59
59
|
indicator?: SlatIndicator;
|
|
60
60
|
/** Optional badge shown next to the subtitle */
|
|
61
61
|
badge?: SlatBadge;
|
|
62
62
|
/** Optional trailing action button */
|
|
63
63
|
action?: SlatAction;
|
|
64
|
-
/** Optional notification banner rendered
|
|
64
|
+
/** Optional notification banner rendered flush at the top of the slat, above the main row */
|
|
65
65
|
notification?: React.ReactNode;
|
|
66
66
|
/** Optional custom content rendered below the main row (e.g. metadata, controls) */
|
|
67
67
|
rightSection?: React.ReactNode;
|
|
68
|
-
/** Paper shadow */
|
|
68
|
+
/** Paper shadow (defaults to `xs`, matching the Figma Slat) */
|
|
69
69
|
shadow?: DSPaperProps['shadow'];
|
|
70
70
|
/** Whether the slat has a border */
|
|
71
71
|
withBorder?: boolean;
|
|
@@ -80,11 +80,17 @@ const TITLE_ORDER_BY_SIZE: Record<SlatSize, 1 | 2 | 3 | 4 | 5 | 6> = {
|
|
|
80
80
|
xl: 2,
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
//
|
|
84
|
-
// indicator has no real child to overlay, so
|
|
85
|
-
// footprint the dot/pill occupies, keeping it in flow instead of collapsing
|
|
83
|
+
// Indicator px size per Slat size (slat.sizes.*.indicatorSize, the Indicator scale 8-24px).
|
|
84
|
+
// The standalone subhead indicator has no real child to overlay, so a box of the same size
|
|
85
|
+
// reserves the footprint the dot/pill occupies, keeping it in flow instead of collapsing
|
|
86
86
|
// to zero size and overlapping neighboring subtitle/badge content.
|
|
87
|
-
const
|
|
87
|
+
const INDICATOR_SIZE_BY_SIZE: Record<SlatSize, number> = {
|
|
88
|
+
xs: 8,
|
|
89
|
+
sm: 12,
|
|
90
|
+
md: 16,
|
|
91
|
+
lg: 20,
|
|
92
|
+
xl: 24,
|
|
93
|
+
};
|
|
88
94
|
|
|
89
95
|
// ========================== COMPONENT ==========================
|
|
90
96
|
|
|
@@ -93,7 +99,7 @@ const INDICATOR_DOT_SIZE = 12;
|
|
|
93
99
|
*
|
|
94
100
|
* A compact row for listing items (e.g. in a feed or list), with a leading
|
|
95
101
|
* icon, title/subtitle, optional status indicator or badge, a trailing
|
|
96
|
-
* action, and an optional notification banner
|
|
102
|
+
* action, and an optional notification banner on top.
|
|
97
103
|
*
|
|
98
104
|
* @example
|
|
99
105
|
* <Slat
|
|
@@ -123,39 +129,46 @@ export function Slat({
|
|
|
123
129
|
action,
|
|
124
130
|
notification,
|
|
125
131
|
rightSection,
|
|
126
|
-
shadow,
|
|
132
|
+
shadow = 'xs',
|
|
127
133
|
withBorder = false,
|
|
128
134
|
}: SlatProps) {
|
|
135
|
+
const indicatorSize = INDICATOR_SIZE_BY_SIZE[size];
|
|
136
|
+
|
|
129
137
|
return (
|
|
130
|
-
<Paper shadow={shadow} withBorder={withBorder}>
|
|
138
|
+
<Paper className="ad-Slat" data-size={size} shadow={shadow} withBorder={withBorder}>
|
|
139
|
+
{notification && (
|
|
140
|
+
<Alert panel color="info">
|
|
141
|
+
{notification}
|
|
142
|
+
</Alert>
|
|
143
|
+
)}
|
|
131
144
|
<Stack gap="xs">
|
|
132
145
|
<Inline gap="sm" align="center" p="sm">
|
|
133
146
|
<Inline gap="xs" align="center" style={{ flex: 1, minWidth: 0 }}>
|
|
134
147
|
{showIcon && icon && (
|
|
135
|
-
<ThemeIcon
|
|
148
|
+
<ThemeIcon className="ad-Slat-icon">
|
|
136
149
|
{icon}
|
|
137
150
|
</ThemeIcon>
|
|
138
151
|
)}
|
|
139
152
|
<Stack gap={0} style={{ flex: 1, minWidth: 0 }}>
|
|
140
|
-
<Title order={TITLE_ORDER_BY_SIZE[size]}>{title}</Title>
|
|
153
|
+
<Title className="ad-Slat-title" order={TITLE_ORDER_BY_SIZE[size]}>{title}</Title>
|
|
141
154
|
{(subtitle || indicator || badge) && (
|
|
142
|
-
<Inline
|
|
143
|
-
{subtitle && <Text size={size}>{subtitle}</Text>}
|
|
155
|
+
<Inline className="ad-Slat-subhead" align="center">
|
|
144
156
|
{indicator && (
|
|
145
157
|
<Indicator
|
|
146
158
|
type={indicator.variant ?? 'default'}
|
|
147
159
|
label={indicator.label}
|
|
148
160
|
withBorder={indicator.withBorder}
|
|
149
|
-
size={
|
|
161
|
+
size={indicatorSize}
|
|
150
162
|
position="middle-center"
|
|
151
163
|
offset={0}
|
|
152
164
|
inline
|
|
153
165
|
>
|
|
154
|
-
<div style={{ width:
|
|
166
|
+
<div style={{ width: indicatorSize, height: indicatorSize }} />
|
|
155
167
|
</Indicator>
|
|
156
168
|
)}
|
|
169
|
+
{subtitle && <Text className="ad-Slat-subtitle" size={size}>{subtitle}</Text>}
|
|
157
170
|
{badge && (
|
|
158
|
-
<Badge variant={badge.variant ?? 'outline'} color={badge.color ?? 'default'}>
|
|
171
|
+
<Badge size={size} variant={badge.variant ?? 'outline'} color={badge.color ?? 'default'}>
|
|
159
172
|
{badge.label}
|
|
160
173
|
</Badge>
|
|
161
174
|
)}
|
|
@@ -169,7 +182,6 @@ export function Slat({
|
|
|
169
182
|
</Button>
|
|
170
183
|
)}
|
|
171
184
|
</Inline>
|
|
172
|
-
{notification && <Alert color="info">{notification}</Alert>}
|
|
173
185
|
{rightSection && <Box>{rightSection}</Box>}
|
|
174
186
|
</Stack>
|
|
175
187
|
</Paper>
|
package/dist/DESIGN.md
CHANGED
|
@@ -339,6 +339,8 @@ The AppDirect DS layer wraps Mantine 9 components under `components/DesignSystem
|
|
|
339
339
|
- `secret` — no background, no border; contextual actions that should recede visually
|
|
340
340
|
- `disabled` — maps to Mantine `default` variant + sets `disabled=true`; prefer passing `disabled` prop directly
|
|
341
341
|
|
|
342
|
+
**Disabled buttons:** do not show them as a rule — a greyed-out button hides why it can't be used and is a dark pattern. Leave submit and primary actions enabled and validate on click with inline field errors (e.g. `error="Name is required"`). When an action doesn't apply (Previous on the first step, Next on the last), don't render it. The `disabled` prop exists only for cases where the action is genuinely unavailable and the reason is shown next to it.
|
|
343
|
+
|
|
342
344
|
**Button sizes:** `xs` · `sm` (default) · `md` · `lg` · `xl`
|
|
343
345
|
|
|
344
346
|
---
|
|
@@ -375,6 +377,8 @@ All inputs default to `radius="sm"` and `size="sm"` matching the button default.
|
|
|
375
377
|
|
|
376
378
|
- `ConfirmationModal` — preconfigured two-button (confirm/cancel) modal. Use for **bulk, high-stakes, or multi-item** destructive actions that need full-screen focus. Pass `confirmVariant="danger"` and irreversible copy (e.g. “cannot be undone”); set `confirmLabel` to the action (e.g. Delete).
|
|
377
379
|
- `ConfirmationPopover` — inline confirm/cancel popover. **Preferred** for single-item, lower-stakes confirmations that do not need full-screen focus. Same `confirmVariant="danger"` / irreversible-copy rules for deletes.
|
|
380
|
+
- Dialog and drawer footers are left-aligned with the primary action first: `Confirm` `Cancel`, `Save Changes` `Cancel`. `ConfirmationModal` and `ConfirmationPopover` already do this; when composing your own footer in a `Modal` or `Drawer`, put the primary `Button` before the outline Cancel.
|
|
381
|
+
- `PageContentHeader` `actions` follow the same rule: left-aligned, rendered in array order, primary action first and the rest in descending importance (`Refresh` `Export Data`, not the reverse).
|
|
378
382
|
- Destructive flows are always two-step: the user chooses Delete, then confirms in Modal or Popover. Never delete on the first click. There is no type-to-confirm or second dialog in the DS.
|
|
379
383
|
- `Menu` accepts typed `MenuItem` and `MenuSection` arrays for structured dropdowns. Use for overflow / row-action menus; mark destructive items with the menu’s danger affordance and open confirm (above) instead of deleting immediately.
|
|
380
384
|
|
|
@@ -53,7 +53,7 @@ import { ALERT_TO_MANTINE_COLOR } from '../types.js';
|
|
|
53
53
|
* <Alert color="danger" title="Error">Error message with light background</Alert>
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
|
-
export const Alert = forwardRef(({ color, type, icon: customIcon, title, withCloseButton = false, onClose, children, ...props }, ref) => {
|
|
56
|
+
export const Alert = forwardRef(({ color, type, icon: customIcon, title, panel = false, withCloseButton = false, onClose, children, ...props }, ref) => {
|
|
57
57
|
// Keep `type` as a deprecated alias while `color` becomes the primary API.
|
|
58
58
|
// Do not default `color` in destructuring — that would shadow `type="info"` etc.
|
|
59
59
|
const semanticColor = color ?? type ?? 'default';
|
|
@@ -73,6 +73,6 @@ export const Alert = forwardRef(({ color, type, icon: customIcon, title, withClo
|
|
|
73
73
|
};
|
|
74
74
|
const { color: mantineColor, icon: defaultIcon } = getAlertConfig(semanticColor);
|
|
75
75
|
const alertIcon = customIcon || defaultIcon;
|
|
76
|
-
return (_jsx(MantineAlert, { ref: ref, variant: "light", color: mantineColor, radius: "sm", icon: alertIcon, title: title, withCloseButton: withCloseButton, onClose: onClose, ...props, "data-color": semanticColor, children: children }));
|
|
76
|
+
return (_jsx(MantineAlert, { ref: ref, variant: "light", color: mantineColor, radius: "sm", icon: alertIcon, title: title, withCloseButton: withCloseButton, onClose: onClose, ...props, "data-panel": panel ? '' : undefined, "data-color": semanticColor, children: children }));
|
|
77
77
|
});
|
|
78
78
|
Alert.displayName = 'Alert';
|
|
@@ -17,6 +17,11 @@ export interface DSAlertProps extends Omit<MantineAlertProps, 'color' | 'variant
|
|
|
17
17
|
icon?: React.ReactNode;
|
|
18
18
|
/** Alert title */
|
|
19
19
|
title?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Render as Figma's Panel Notification: a compact bar (10px / 4px padding, 16px icon, square corners)
|
|
22
|
+
* meant to sit flush at the top of a card or slat. Values come from the `alert.panel` tokens.
|
|
23
|
+
*/
|
|
24
|
+
panel?: boolean;
|
|
20
25
|
/** Whether alert can be closed */
|
|
21
26
|
withCloseButton?: boolean;
|
|
22
27
|
/** Close button handler */
|
|
@@ -81,6 +86,7 @@ export const Alert = forwardRef<HTMLDivElement, DSAlertProps>(
|
|
|
81
86
|
type,
|
|
82
87
|
icon: customIcon,
|
|
83
88
|
title,
|
|
89
|
+
panel = false,
|
|
84
90
|
withCloseButton = false,
|
|
85
91
|
onClose,
|
|
86
92
|
children,
|
|
@@ -121,6 +127,7 @@ export const Alert = forwardRef<HTMLDivElement, DSAlertProps>(
|
|
|
121
127
|
withCloseButton={withCloseButton}
|
|
122
128
|
onClose={onClose}
|
|
123
129
|
{...props}
|
|
130
|
+
data-panel={panel ? '' : undefined}
|
|
124
131
|
// Semantic name for mantine.css ([data-color=info|…]); must win over props.
|
|
125
132
|
data-color={semanticColor}
|
|
126
133
|
>
|
package/dist/DataDisplay/Card.js
CHANGED
|
@@ -21,10 +21,11 @@ import classes from './Card.module.css';
|
|
|
21
21
|
* </Card>
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
// Mantine's Card finds its sections by element type and marks the first and last ones
|
|
25
|
+
// (`data-first-section` / `data-last-section`), which is what makes a section bleed through the
|
|
26
|
+
// card padding at the top and bottom. A forwardRef wrapper is a different type and is never
|
|
27
|
+
// marked, so the section would leave a gap above it. Use Mantine's component directly.
|
|
28
|
+
const CardSection = MantineCard.Section;
|
|
28
29
|
/**
|
|
29
30
|
* Card Component
|
|
30
31
|
*
|
|
@@ -45,17 +45,11 @@ export interface DSCardSectionProps extends
|
|
|
45
45
|
* </Card>
|
|
46
46
|
* ```
|
|
47
47
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</MantineCard.Section>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
CardSection.displayName = 'Card.Section';
|
|
48
|
+
// Mantine's Card finds its sections by element type and marks the first and last ones
|
|
49
|
+
// (`data-first-section` / `data-last-section`), which is what makes a section bleed through the
|
|
50
|
+
// card padding at the top and bottom. A forwardRef wrapper is a different type and is never
|
|
51
|
+
// marked, so the section would leave a gap above it. Use Mantine's component directly.
|
|
52
|
+
const CardSection: typeof MantineCard.Section = MantineCard.Section;
|
|
59
53
|
|
|
60
54
|
/**
|
|
61
55
|
* Card Component
|
package/dist/Overlays/Modal.js
CHANGED
|
@@ -34,8 +34,8 @@ import { Button } from '../Buttons/index.js';
|
|
|
34
34
|
* <Stack gap="md">
|
|
35
35
|
* <Text>Are you sure you want to perform this action?</Text>
|
|
36
36
|
* <Inline justify="flex-start" gap="sm">
|
|
37
|
-
* <Button variant="outline">Cancel</Button>
|
|
38
37
|
* <Button variant="primary">Confirm</Button>
|
|
38
|
+
* <Button variant="outline">Cancel</Button>
|
|
39
39
|
* </Inline>
|
|
40
40
|
* </Stack>
|
|
41
41
|
* </Modal>
|
|
@@ -56,6 +56,6 @@ export const ConfirmationModal = forwardRef(({ confirmLabel = 'Confirm', cancelL
|
|
|
56
56
|
onClose();
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
-
return (_jsx(Modal, { ref: ref, onClose: onClose, ...props, children: _jsxs(Stack, { gap: "md", children: [children, _jsxs(Inline, { justify: "flex-start", gap: "sm", children: [_jsx(Button, { variant:
|
|
59
|
+
return (_jsx(Modal, { ref: ref, onClose: onClose, ...props, children: _jsxs(Stack, { gap: "md", children: [children, _jsxs(Inline, { justify: "flex-start", gap: "sm", children: [_jsx(Button, { variant: confirmVariant, onClick: handleConfirm, loading: confirmLoading, children: confirmLabel }), _jsx(Button, { variant: "outline", onClick: handleCancel, children: cancelLabel })] })] }) }));
|
|
60
60
|
});
|
|
61
61
|
ConfirmationModal.displayName = 'ConfirmationModal';
|
package/dist/Overlays/Modal.tsx
CHANGED
|
@@ -46,8 +46,8 @@ export interface DSModalProps extends Omit<MantineModalProps, 'title'> {
|
|
|
46
46
|
* <Stack gap="md">
|
|
47
47
|
* <Text>Are you sure you want to perform this action?</Text>
|
|
48
48
|
* <Inline justify="flex-start" gap="sm">
|
|
49
|
-
* <Button variant="outline">Cancel</Button>
|
|
50
49
|
* <Button variant="primary">Confirm</Button>
|
|
50
|
+
* <Button variant="outline">Cancel</Button>
|
|
51
51
|
* </Inline>
|
|
52
52
|
* </Stack>
|
|
53
53
|
* </Modal>
|
|
@@ -143,12 +143,12 @@ export const ConfirmationModal = forwardRef<HTMLDivElement, ConfirmationModalPro
|
|
|
143
143
|
<Stack gap="md">
|
|
144
144
|
{children}
|
|
145
145
|
<Inline justify="flex-start" gap="sm">
|
|
146
|
-
<Button variant="outline" onClick={handleCancel}>
|
|
147
|
-
{cancelLabel}
|
|
148
|
-
</Button>
|
|
149
146
|
<Button variant={confirmVariant} onClick={handleConfirm} loading={confirmLoading}>
|
|
150
147
|
{confirmLabel}
|
|
151
148
|
</Button>
|
|
149
|
+
<Button variant="outline" onClick={handleCancel}>
|
|
150
|
+
{cancelLabel}
|
|
151
|
+
</Button>
|
|
152
152
|
</Inline>
|
|
153
153
|
</Stack>
|
|
154
154
|
</Modal>
|
|
@@ -50,6 +50,11 @@
|
|
|
50
50
|
"title": {
|
|
51
51
|
"type": "string"
|
|
52
52
|
},
|
|
53
|
+
"panel": {
|
|
54
|
+
"type": "boolean",
|
|
55
|
+
"default": false,
|
|
56
|
+
"notes": "Figma Panel Notification: compact 30px bar for the top of a card, slat or widget. Place it flush to the container's top and sides (Card.Section)."
|
|
57
|
+
},
|
|
53
58
|
"withCloseButton": {
|
|
54
59
|
"type": "boolean",
|
|
55
60
|
"default": false
|