@appdirect/design-system 0.0.24 → 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.
Files changed (46) hide show
  1. package/README.md +11 -0
  2. package/dist/Combobox/AutocompleteClearable.js +33 -35
  3. package/dist/Combobox/AutocompleteClearable.tsx +56 -121
  4. package/dist/Combobox/SearchableSelect.js +23 -42
  5. package/dist/Combobox/SearchableSelect.tsx +33 -129
  6. package/dist/ComplexComponents/DashboardWidget/DashboardWidget.js +1 -1
  7. package/dist/ComplexComponents/DashboardWidget/DashboardWidget.tsx +9 -7
  8. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +1 -1
  9. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.tsx +1 -1
  10. package/dist/ComplexComponents/KeyInsight/KeyInsights.js +6 -1
  11. package/dist/ComplexComponents/KeyInsight/KeyInsights.tsx +12 -2
  12. package/dist/ComplexComponents/PageContentHeader/PageContentHeader.js +1 -1
  13. package/dist/ComplexComponents/PageContentHeader/PageContentHeader.tsx +16 -11
  14. package/dist/ComplexComponents/Slat/Slat.js +14 -7
  15. package/dist/ComplexComponents/Slat/Slat.tsx +31 -19
  16. package/dist/ComplexComponents/Utilities/CopyButton.js +15 -27
  17. package/dist/ComplexComponents/Utilities/CopyButton.tsx +35 -49
  18. package/dist/DESIGN.md +4 -0
  19. package/dist/DataDisplay/Alert.js +2 -2
  20. package/dist/DataDisplay/Alert.tsx +7 -0
  21. package/dist/DataDisplay/Avatar.js +26 -81
  22. package/dist/DataDisplay/Avatar.tsx +35 -93
  23. package/dist/DataDisplay/Card.js +5 -4
  24. package/dist/DataDisplay/Card.tsx +5 -11
  25. package/dist/Layout/Inline.js +5 -42
  26. package/dist/Layout/Inline.tsx +6 -79
  27. package/dist/Overlays/Modal.js +2 -2
  28. package/dist/Overlays/Modal.tsx +4 -4
  29. package/dist/contracts/Alert.json +5 -0
  30. package/dist/contracts/index.json +1 -1
  31. package/dist/css/mantine.css +120 -12
  32. package/dist/css/tokens.css +52 -14
  33. package/dist/hooks/index.js +18 -0
  34. package/dist/hooks/index.ts +28 -0
  35. package/dist/hooks/useSelectedRowsText.js +73 -0
  36. package/dist/hooks/useSelectedRowsText.ts +74 -0
  37. package/dist/stories/Combobox/SearchableSelect.stories.tsx +3 -3
  38. package/dist/stories/ComplexComponents/DashboardWidget/DashboardWidget.stories.tsx +7 -0
  39. package/dist/stories/ComplexComponents/PageContentHeader/PageContentHeader.stories.tsx +21 -21
  40. package/dist/stories/ComplexComponents/Utilities/CopyButton.stories.tsx +4 -14
  41. package/dist/stories/DataDisplay/Progress.stories.tsx +11 -27
  42. package/dist/stories/Navigation/Stepper.stories.tsx +25 -21
  43. package/dist/stories/Overlays/Drawer.stories.tsx +6 -6
  44. package/dist/stories/Overlays/Modal.stories.tsx +31 -11
  45. package/dist/stories/index.json +6 -6
  46. package/package.json +97 -3
@@ -43,7 +43,10 @@ export interface PageContentHeaderProps {
43
43
  onEdit?: () => void;
44
44
 
45
45
  // ==================== ACTION BUTTONS ====================
46
- /** Array of action buttons. Uses semantic variants instead of explicit colors. */
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 banner below the header */
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 pb={contentSection_ ? 0 : undefined} {...cardProps}>
346
- {/* Header Section */}
347
- <Stack gap={spacing}>
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
- // Matches Indicator's own default `size` (12px). The standalone subhead
22
- // indicator has no real child to overlay, so this box reserves the same
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 INDICATOR_DOT_SIZE = 12;
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 below.
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
- return (_jsx(Paper, { shadow: shadow, withBorder: withBorder, children: _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, { size: size, children: icon })), _jsxs(Stack, { gap: 0, style: { flex: 1, minWidth: 0 }, children: [_jsx(Title, { order: TITLE_ORDER_BY_SIZE[size], children: title }), (subtitle || indicator || badge) && (_jsxs(Inline, { gap: 5, align: "center", children: [subtitle && _jsx(Text, { size: size, children: subtitle }), indicator && (_jsx(Indicator, { type: indicator.variant ?? 'default', label: indicator.label, withBorder: indicator.withBorder, size: INDICATOR_DOT_SIZE, position: "middle-center", offset: 0, inline: true, children: _jsx("div", { style: { width: INDICATOR_DOT_SIZE, height: INDICATOR_DOT_SIZE } }) })), badge && (_jsx(Badge, { 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 }))] }), notification && _jsx(Alert, { color: "info", children: notification }), rightSection && _jsx(Box, { children: rightSection })] }) }));
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, type ThemeIconSize } from '../../DataDisplay/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 next to the subtitle */
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 below the main row */
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
- // Matches Indicator's own default `size` (12px). The standalone subhead
84
- // indicator has no real child to overlay, so this box reserves the same
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 INDICATOR_DOT_SIZE = 12;
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 below.
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 size={size as ThemeIconSize}>
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 gap={5} align="center">
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={INDICATOR_DOT_SIZE}
161
+ size={indicatorSize}
150
162
  position="middle-center"
151
163
  offset={0}
152
164
  inline
153
165
  >
154
- <div style={{ width: INDICATOR_DOT_SIZE, height: INDICATOR_DOT_SIZE }} />
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>
@@ -1,45 +1,33 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import React, { useState } from 'react';
4
- import { ActionIcon } from '@mantine/core';
3
+ import React from 'react';
4
+ import { ActionIcon, CopyButton as MantineCopyButton } from '@mantine/core';
5
5
  import { Tooltip } from '../../Overlays/Tooltip.js';
6
6
  import { RiFileCopyLine } from '@remixicon/react';
7
7
  /**
8
8
  * CopyButton Component
9
9
  *
10
- * A reusable button component with copy-to-clipboard functionality and interactive tooltips.
11
- * Shows "Copy" on hover and "Copied" after clicking, resetting when cursor leaves.
10
+ * Built on Mantine's `CopyButton`: clicking writes `value` to the clipboard and the
11
+ * tooltip switches from "Copy" to "Copied" for `timeout` ms.
12
12
  *
13
13
  * @example
14
- * // Basic usage
15
- * <CopyButton
16
- * value="Production"
17
- * label="Environment"
18
- * onCopy={(value) => navigator.clipboard.writeText(value)}
19
- * />
14
+ * <CopyButton value="Production" label="Environment" />
20
15
  *
21
16
  * @example
22
- * // With custom icon size
17
+ * // With custom icon size and a callback
23
18
  * <CopyButton
24
19
  * value="sk-1234567890abcdef"
25
20
  * label="API Key"
26
21
  * iconSize={16}
27
- * onCopy={(value) => {
28
- * navigator.clipboard.writeText(value);
29
- * console.log('API Key copied');
30
- * }}
22
+ * onCopy={() => console.log('API Key copied')}
31
23
  * />
32
24
  */
33
- export function CopyButton({ value, label, onCopy, iconSize = 24, }) {
34
- const [isCopied, setIsCopied] = useState(false);
35
- const handleCopy = () => {
36
- if (onCopy) {
37
- onCopy(value);
38
- setIsCopied(true);
39
- }
40
- };
41
- const handleMouseLeave = () => {
42
- setIsCopied(false);
43
- };
44
- return (_jsx(Tooltip, { label: isCopied ? "Copied" : "Copy", position: "top", withArrow: true, children: _jsx(ActionIcon, { variant: "subtle", size: "xs", c: "blue", onClick: handleCopy, onMouseLeave: handleMouseLeave, "aria-label": `Copy ${label}`, children: _jsx(RiFileCopyLine, { size: iconSize }) }) }));
25
+ export function CopyButton({ value, label, onCopy, iconSize = 24, timeout = 1500, }) {
26
+ return (_jsx(MantineCopyButton, { value: value, timeout: timeout, children: ({ copied, copy }) => (_jsx(Tooltip, { label: copied ? 'Copied' : 'Copy', position: "top", withArrow: true, children: _jsx(ActionIcon, { variant: "subtle",
27
+ // Numeric size on purpose: t-shirt sizes get a token rule that pins the svg size,
28
+ // which would override `iconSize`. The button is the icon plus 4px padding per side.
29
+ size: iconSize + 8, c: "blue", onClick: () => {
30
+ copy();
31
+ onCopy?.(value);
32
+ }, "aria-label": `Copy ${label}`, children: _jsx(RiFileCopyLine, { size: iconSize }) }) })) }));
45
33
  }
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
- import React, { useState } from 'react';
4
- import { ActionIcon } from '@mantine/core';
3
+ import React from 'react';
4
+ import { ActionIcon, CopyButton as MantineCopyButton } from '@mantine/core';
5
5
  import { Tooltip } from '../../Overlays/Tooltip';
6
6
  import { RiFileCopyLine } from '@remixicon/react';
7
7
 
@@ -10,36 +10,30 @@ export interface CopyButtonProps {
10
10
  value: string;
11
11
  /** Label for accessibility and tooltip context */
12
12
  label: string;
13
- /** Callback when copy action is performed */
13
+ /** Called with the value after it has been copied (for analytics or toasts; copying is already done) */
14
14
  onCopy?: (value: string) => void;
15
15
  /** Size of the copy icon */
16
16
  iconSize?: number;
17
+ /** Time in ms the "Copied" state stays visible */
18
+ timeout?: number;
17
19
  }
18
20
 
19
21
  /**
20
22
  * CopyButton Component
21
- *
22
- * A reusable button component with copy-to-clipboard functionality and interactive tooltips.
23
- * Shows "Copy" on hover and "Copied" after clicking, resetting when cursor leaves.
24
- *
23
+ *
24
+ * Built on Mantine's `CopyButton`: clicking writes `value` to the clipboard and the
25
+ * tooltip switches from "Copy" to "Copied" for `timeout` ms.
26
+ *
25
27
  * @example
26
- * // Basic usage
27
- * <CopyButton
28
- * value="Production"
29
- * label="Environment"
30
- * onCopy={(value) => navigator.clipboard.writeText(value)}
31
- * />
32
- *
28
+ * <CopyButton value="Production" label="Environment" />
29
+ *
33
30
  * @example
34
- * // With custom icon size
31
+ * // With custom icon size and a callback
35
32
  * <CopyButton
36
33
  * value="sk-1234567890abcdef"
37
34
  * label="API Key"
38
35
  * iconSize={16}
39
- * onCopy={(value) => {
40
- * navigator.clipboard.writeText(value);
41
- * console.log('API Key copied');
42
- * }}
36
+ * onCopy={() => console.log('API Key copied')}
43
37
  * />
44
38
  */
45
39
  export function CopyButton({
@@ -47,36 +41,28 @@ export function CopyButton({
47
41
  label,
48
42
  onCopy,
49
43
  iconSize = 24,
44
+ timeout = 1500,
50
45
  }: CopyButtonProps) {
51
- const [isCopied, setIsCopied] = useState(false);
52
-
53
- const handleCopy = () => {
54
- if (onCopy) {
55
- onCopy(value);
56
- setIsCopied(true);
57
- }
58
- };
59
-
60
- const handleMouseLeave = () => {
61
- setIsCopied(false);
62
- };
63
-
64
46
  return (
65
- <Tooltip
66
- label={isCopied ? "Copied" : "Copy"}
67
- position="top"
68
- withArrow
69
- >
70
- <ActionIcon
71
- variant="subtle"
72
- size="xs"
73
- c="blue"
74
- onClick={handleCopy}
75
- onMouseLeave={handleMouseLeave}
76
- aria-label={`Copy ${label}`}
77
- >
78
- <RiFileCopyLine size={iconSize} />
79
- </ActionIcon>
80
- </Tooltip>
47
+ <MantineCopyButton value={value} timeout={timeout}>
48
+ {({ copied, copy }) => (
49
+ <Tooltip label={copied ? 'Copied' : 'Copy'} position="top" withArrow>
50
+ <ActionIcon
51
+ variant="subtle"
52
+ // Numeric size on purpose: t-shirt sizes get a token rule that pins the svg size,
53
+ // which would override `iconSize`. The button is the icon plus 4px padding per side.
54
+ size={iconSize + 8}
55
+ c="blue"
56
+ onClick={() => {
57
+ copy();
58
+ onCopy?.(value);
59
+ }}
60
+ aria-label={`Copy ${label}`}
61
+ >
62
+ <RiFileCopyLine size={iconSize} />
63
+ </ActionIcon>
64
+ </Tooltip>
65
+ )}
66
+ </MantineCopyButton>
81
67
  );
82
- }
68
+ }
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
  >
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import React, { forwardRef, useState, useCallback } from 'react';
3
+ import React, { forwardRef, useEffect } from 'react';
4
4
  import { Avatar as MantineAvatar } from '@mantine/core';
5
5
  import { RiUser3Fill } from '@remixicon/react';
6
6
  // ========================== CONSTANTS ==========================
@@ -24,7 +24,8 @@ const ICON_SIZES = {
24
24
  /**
25
25
  * Avatar Component
26
26
  *
27
- * Built on top of Mantine's Avatar component with design system styling.
27
+ * Built on top of Mantine's Avatar component with design system styling. Image load
28
+ * failures fall back to the placeholder content (icon or initials) via Mantine core.
28
29
  * Supports three variants: icon, image, and initials with all Mantine t-shirt sizes.
29
30
  *
30
31
  * @example
@@ -59,52 +60,19 @@ const ICON_SIZES = {
59
60
  * />
60
61
  */
61
62
  export const Avatar = forwardRef(({ variant, size = 'md', src, alt, initials, icon, fallback = 'icon', fallbackInitials, ...props }, ref) => {
62
- // Track image loading state
63
- const [imageError, setImageError] = useState(false);
64
- // Check if URL is obviously invalid
65
- const isInvalidUrl = (url) => {
66
- if (!url || url.trim() === '')
67
- return true;
68
- try {
69
- const hostname = new URL(url, 'https://local.invalid').hostname;
70
- if (hostname === 'example.com' || hostname.endsWith('.example.com'))
71
- return true;
63
+ useEffect(() => {
64
+ if (process.env.NODE_ENV !== 'development')
65
+ return;
66
+ if (variant === 'image' && !src) {
67
+ console.warn('Avatar: src is required when variant is "image"');
72
68
  }
73
- catch {
74
- return true;
69
+ if (variant === 'initials' && !initials) {
70
+ console.warn('Avatar: initials is required when variant is "initials"');
75
71
  }
76
- if (url.includes('broken-image'))
77
- return true;
78
- return false;
79
- };
80
- // Reset image error when src changes
81
- React.useEffect(() => {
82
- if (src && isInvalidUrl(src)) {
83
- setImageError(true);
84
- }
85
- else {
86
- setImageError(false);
72
+ if (variant === 'initials' && initials && initials.length !== 2) {
73
+ console.warn('Avatar: initials should be exactly 2 characters');
87
74
  }
88
- }, [src]);
89
- // Handle image load error
90
- const handleImageError = useCallback(() => {
91
- setImageError(true);
92
- }, []);
93
- if (process.env.NODE_ENV === 'development') {
94
- // eslint-disable-next-line react-hooks/rules-of-hooks
95
- React.useEffect(() => {
96
- if (variant === 'image' && !src) {
97
- console.warn('Avatar: src is required when variant is "image"');
98
- }
99
- if (variant === 'initials' && !initials) {
100
- console.warn('Avatar: initials is required when variant is "initials"');
101
- }
102
- if (variant === 'initials' && initials && initials.length !== 2) {
103
- console.warn('Avatar: initials should be exactly 2 characters');
104
- }
105
- }, [variant, src, initials]);
106
- }
107
- // Render icon content
75
+ }, [variant, src, initials]);
108
76
  const renderIcon = () => {
109
77
  const iconSize = ICON_SIZES[size];
110
78
  if (icon) {
@@ -117,41 +85,18 @@ export const Avatar = forwardRef(({ variant, size = 'md', src, alt, initials, ic
117
85
  }
118
86
  return _jsx(RiUser3Fill, { size: iconSize, color: "var(--ad-color-text-default)" });
119
87
  };
120
- // Render initials content
121
- const renderInitials = (text) => {
122
- return text.substring(0, 2).toUpperCase();
123
- };
124
- // Handle different variants
125
- const getAvatarContent = () => {
126
- switch (variant) {
127
- case 'image':
128
- // For image variant, always check if we should show fallback first
129
- if (!src || imageError) {
130
- // Show fallback content instead of trying to load image
131
- return {
132
- children: fallback === 'initials' && fallbackInitials
133
- ? renderInitials(fallbackInitials)
134
- : renderIcon(),
135
- };
136
- }
137
- // Only try to load image if we have src and no error yet
138
- return {
139
- src: src,
140
- alt: alt,
141
- onError: handleImageError,
142
- };
143
- case 'initials':
144
- return {
145
- children: initials ? renderInitials(initials) : '??',
146
- };
147
- case 'icon':
148
- default:
149
- return {
150
- children: renderIcon(),
151
- };
152
- }
153
- };
154
- const avatarContent = getAvatarContent();
155
- return (_jsx(MantineAvatar, { ref: ref, size: AVATAR_SIZES[size], radius: 1000, ...avatarContent, ...props }));
88
+ const renderInitials = (text) => text.substring(0, 2).toUpperCase();
89
+ // Mantine renders `children` whenever there is no `src` or the image fails to load.
90
+ let placeholder;
91
+ if (variant === 'initials') {
92
+ placeholder = initials ? renderInitials(initials) : '??';
93
+ }
94
+ else if (variant === 'image' && fallback === 'initials' && fallbackInitials) {
95
+ placeholder = renderInitials(fallbackInitials);
96
+ }
97
+ else {
98
+ placeholder = renderIcon();
99
+ }
100
+ return (_jsx(MantineAvatar, { ref: ref, size: AVATAR_SIZES[size], radius: 1000, src: variant === 'image' ? src : undefined, alt: alt, ...props, children: placeholder }));
156
101
  });
157
102
  Avatar.displayName = 'Avatar';