@appdirect/design-system 0.0.0-stage → 0.0.2
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 +12 -2
- package/dist/Buttons/ActionIcon.tsx +37 -0
- package/dist/Buttons/Button.module.css +5 -0
- package/dist/Buttons/Button.tsx +124 -0
- package/dist/Buttons/CloseButton.tsx +83 -0
- package/dist/Buttons/index.ts +20 -0
- package/dist/Combobox/AutocompleteClearable.tsx +128 -0
- package/dist/Combobox/Combobox.tsx +37 -0
- package/dist/Combobox/Multiselect.tsx +158 -0
- package/dist/Combobox/SearchableSelect.tsx +131 -0
- package/dist/Combobox/Select.tsx +154 -0
- package/dist/Combobox/index.ts +20 -0
- package/dist/ComplexComponents/DashboardWidget/DashboardWidget.tsx +313 -0
- package/dist/ComplexComponents/DashboardWidget/index.ts +2 -0
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.tsx +177 -0
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.ts +35 -0
- package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.tsx +74 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.tsx +358 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.tsx +48 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/DateRangeFilter.tsx +26 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterRenderer.tsx +71 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterSystem.tsx +158 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/MultiSelectFilter.tsx +79 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/SingleSelectFilter.tsx +65 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/index.ts +70 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/types.ts +140 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.tsx +76 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.tsx +73 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.tsx +50 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.tsx +788 -0
- package/dist/ComplexComponents/DataTable/DataTable.tsx +582 -0
- package/dist/ComplexComponents/DataTable/ErrorOverlay/index.tsx +29 -0
- package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.tsx +57 -0
- package/dist/ComplexComponents/DataTable/index.ts +2 -0
- package/dist/ComplexComponents/DataTable/translations/en.ts +115 -0
- package/dist/ComplexComponents/DataTable/translations/index.ts +23 -0
- package/dist/ComplexComponents/KeyInsight/KeyInsights.tsx +221 -0
- package/dist/ComplexComponents/KeyInsight/index.ts +2 -0
- package/dist/ComplexComponents/NameValue/NameValue.tsx +175 -0
- package/dist/ComplexComponents/NameValue/NameValueItem.tsx +100 -0
- package/dist/ComplexComponents/NameValue/index.ts +4 -0
- package/dist/ComplexComponents/PageContentHeader/DescriptionBlock.tsx +65 -0
- package/dist/ComplexComponents/PageContentHeader/PageContentHeader.tsx +383 -0
- package/dist/ComplexComponents/PageContentHeader/index.ts +4 -0
- package/dist/ComplexComponents/Utilities/CopyButton.tsx +82 -0
- package/dist/ComplexComponents/Utilities/index.ts +2 -0
- package/dist/DataDisplay/Alert.tsx +130 -0
- package/dist/DataDisplay/Avatar.tsx +216 -0
- package/dist/DataDisplay/Badge.tsx +119 -0
- package/dist/DataDisplay/Card.module.css +26 -0
- package/dist/DataDisplay/Card.tsx +163 -0
- package/dist/DataDisplay/Chip.tsx +66 -0
- package/dist/DataDisplay/Indicator.tsx +122 -0
- package/dist/DataDisplay/List.tsx +90 -0
- package/dist/DataDisplay/Pill.tsx +125 -0
- package/dist/DataDisplay/Progress.tsx +77 -0
- package/dist/DataDisplay/Table.tsx +57 -0
- package/dist/DataDisplay/ThemeIcon.tsx +67 -0
- package/dist/DataDisplay/index.ts +41 -0
- package/dist/Inputs/Checkbox.tsx +94 -0
- package/dist/Inputs/ColorInput.tsx +124 -0
- package/dist/Inputs/DropZone.tsx +78 -0
- package/dist/Inputs/FileInput.tsx +120 -0
- package/dist/Inputs/NumberInput.tsx +125 -0
- package/dist/Inputs/Radio.tsx +86 -0
- package/dist/Inputs/RadioGroup.tsx +90 -0
- package/dist/Inputs/SegmentedControl.tsx +64 -0
- package/dist/Inputs/Slider.tsx +69 -0
- package/dist/Inputs/Switch.tsx +67 -0
- package/dist/Inputs/TextArea.tsx +126 -0
- package/dist/Inputs/TextInput.tsx +167 -0
- package/dist/Inputs/index.ts +51 -0
- package/dist/Layout/Box.tsx +82 -0
- package/dist/Layout/Center.tsx +17 -0
- package/dist/Layout/Container.tsx +17 -0
- package/dist/Layout/Flex.tsx +18 -0
- package/dist/Layout/Grid.tsx +31 -0
- package/dist/Layout/Group.tsx +54 -0
- package/dist/Layout/Inline.tsx +86 -0
- package/dist/Layout/SimpleGrid.tsx +50 -0
- package/dist/Layout/Stack.tsx +86 -0
- package/dist/Layout/index.ts +29 -0
- package/dist/Misc/Divider.tsx +27 -0
- package/dist/Misc/Paper.tsx +47 -0
- package/dist/Misc/index.ts +15 -0
- package/dist/Navigation/Breadcrumb.tsx +138 -0
- package/dist/Navigation/NavLink.tsx +37 -0
- package/dist/Navigation/Stepper.tsx +17 -0
- package/dist/Navigation/Tabs.tsx +29 -0
- package/dist/Navigation/index.ts +17 -0
- package/dist/Overlays/Drawer.tsx +123 -0
- package/dist/Overlays/Menu.tsx +192 -0
- package/dist/Overlays/Modal.tsx +159 -0
- package/dist/Overlays/Popover.tsx +319 -0
- package/dist/Overlays/Tooltip.tsx +131 -0
- package/dist/Overlays/index.ts +19 -0
- package/dist/Shell/AppShellLayout.tsx +56 -0
- package/dist/Shell/HeaderBar.tsx +26 -0
- package/dist/Shell/SidebarNav.tsx +47 -0
- package/dist/Shell/SidebarNavLink.tsx +50 -0
- package/dist/Shell/SingleColumnLayout.tsx +22 -0
- package/dist/Shell/TertiaryColumnLayout.tsx +32 -0
- package/dist/Shell/index.ts +17 -0
- package/dist/Typography/Code.tsx +27 -0
- package/dist/Typography/Kbd.tsx +87 -0
- package/dist/Typography/Text.tsx +27 -0
- package/dist/Typography/Title.tsx +34 -0
- package/dist/Typography/index.ts +21 -0
- package/dist/bin/ds-audit.js +521 -0
- package/dist/config.ts +226 -0
- package/dist/contracts/Alert.json +80 -0
- package/dist/contracts/Badge.json +78 -0
- package/dist/contracts/Box.json +52 -0
- package/dist/contracts/Button.json +111 -0
- package/dist/contracts/DataTable.json +68 -0
- package/dist/contracts/Grid.json +35 -0
- package/dist/contracts/Group.json +44 -0
- package/dist/contracts/Inline.json +73 -0
- package/dist/contracts/PageContentHeader.json +107 -0
- package/dist/contracts/Stack.json +62 -0
- package/dist/contracts/ds-component-contract.v1.json +23 -0
- package/dist/contracts/index.json +55 -0
- package/dist/css/foundations.css +703 -0
- package/dist/css/mantine.css +1777 -0
- package/dist/hooks/useTableHandlers.ts +179 -0
- package/dist/hooks/useTableRenderFunctions.tsx +283 -0
- package/dist/hooks/useTableState.ts +81 -0
- package/dist/index.ts +210 -0
- package/dist/types.ts +202 -0
- package/package.json +56 -4
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Inline } from '../../Layout/Inline';
|
|
3
|
+
import { Title } from '../../Typography/Title';
|
|
4
|
+
import { Text } from '../../Typography/Text';
|
|
5
|
+
|
|
6
|
+
export interface DescriptionBlockProps {
|
|
7
|
+
/** Optional title for the description block */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** Description text content */
|
|
10
|
+
description: string;
|
|
11
|
+
/** Whether description supports HTML/links */
|
|
12
|
+
allowHtml?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* DescriptionBlock Component
|
|
17
|
+
*
|
|
18
|
+
* A component for displaying structured description content with an optional title.
|
|
19
|
+
* Uses Group layout with Title (h4) and Text (md) styling.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Basic usage with title
|
|
23
|
+
* <DescriptionBlock
|
|
24
|
+
* title="This is an optional title"
|
|
25
|
+
* description="This is some descriptive text. Try not to make this too long and don't be too specific to prevent stale documentation."
|
|
26
|
+
* />
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // With HTML content
|
|
30
|
+
* <DescriptionBlock
|
|
31
|
+
* title="Getting Started"
|
|
32
|
+
* description="This is some descriptive text. It's <a href='/docs'>great to link into doc</a> pages!"
|
|
33
|
+
* allowHtml={true}
|
|
34
|
+
* />
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Description only (no title)
|
|
38
|
+
* <DescriptionBlock
|
|
39
|
+
* description="This standalone description provides context without a title."
|
|
40
|
+
* />
|
|
41
|
+
*/
|
|
42
|
+
export function DescriptionBlock({
|
|
43
|
+
title,
|
|
44
|
+
description,
|
|
45
|
+
allowHtml = false,
|
|
46
|
+
}: DescriptionBlockProps) {
|
|
47
|
+
return (
|
|
48
|
+
<Inline gap="xs" align="flex-start" p="sm">
|
|
49
|
+
{title && (
|
|
50
|
+
<Title order={4}>
|
|
51
|
+
{title}
|
|
52
|
+
</Title>
|
|
53
|
+
)}
|
|
54
|
+
{allowHtml ? (
|
|
55
|
+
<Text size="md" style={{ lineHeight: 1.6 }}>
|
|
56
|
+
<div dangerouslySetInnerHTML={{ __html: description }} />
|
|
57
|
+
</Text>
|
|
58
|
+
) : (
|
|
59
|
+
<Text size="md" style={{ lineHeight: 1.6 }}>
|
|
60
|
+
{description}
|
|
61
|
+
</Text>
|
|
62
|
+
)}
|
|
63
|
+
</Inline>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Collapse, rem } from '@mantine/core';
|
|
5
|
+
import { Box } from '../../Layout/Box';
|
|
6
|
+
import { SimpleGrid } from '../../Layout/SimpleGrid';
|
|
7
|
+
import { Inline } from '../../Layout/Inline';
|
|
8
|
+
import { Stack } from '../../Layout/Stack';
|
|
9
|
+
import { Button } from '../../Buttons/Button';
|
|
10
|
+
import { ActionIcon } from '../../Buttons/ActionIcon';
|
|
11
|
+
import { Badge } from '../../DataDisplay/Badge';
|
|
12
|
+
import { ThemeIcon } from '../../DataDisplay/ThemeIcon';
|
|
13
|
+
import { Text } from '../../Typography/Text';
|
|
14
|
+
import { Title } from '../../Typography/Title';
|
|
15
|
+
import { Card } from '../../DataDisplay/Card';
|
|
16
|
+
import { useDisclosure } from '@mantine/hooks';
|
|
17
|
+
import { RiEditLine, RiArrowDownSLine, RiArrowUpSLine } from '@remixicon/react';
|
|
18
|
+
import { KeyInsight, KeyInsightProps } from '../KeyInsight';
|
|
19
|
+
import { NameValue, NameValuePair } from '../NameValue';
|
|
20
|
+
import { DescriptionBlock } from './DescriptionBlock';
|
|
21
|
+
|
|
22
|
+
// ========================== TYPES ==========================
|
|
23
|
+
|
|
24
|
+
export type ContentSection = 'insights' | 'description' | 'descriptionBlock' | 'nameValuePairs' | 'drawer';
|
|
25
|
+
|
|
26
|
+
export interface PageContentHeaderProps {
|
|
27
|
+
// ==================== HEADER SECTION ====================
|
|
28
|
+
/** Subhead text above the title */
|
|
29
|
+
subhead?: string;
|
|
30
|
+
/** Main title/subhead */
|
|
31
|
+
title: string;
|
|
32
|
+
/** Optional badge text */
|
|
33
|
+
badge?: string;
|
|
34
|
+
/** Icon to display (can be component or icon name) */
|
|
35
|
+
icon?: React.ReactNode;
|
|
36
|
+
/** Icon size (for the icon inside the container) */
|
|
37
|
+
iconSize?: number;
|
|
38
|
+
/** Container size for the ThemeIcon */
|
|
39
|
+
iconContainerSize?: number;
|
|
40
|
+
/** Whether the title is editable */
|
|
41
|
+
editable?: boolean;
|
|
42
|
+
/** Callback when edit is clicked */
|
|
43
|
+
onEdit?: () => void;
|
|
44
|
+
|
|
45
|
+
// ==================== ACTION BUTTONS ====================
|
|
46
|
+
/** Array of action buttons. Uses semantic variants instead of explicit colors. */
|
|
47
|
+
actions?: Array<{
|
|
48
|
+
label: string;
|
|
49
|
+
onClick: () => void;
|
|
50
|
+
/** Semantic variant that automatically determines appropriate color */
|
|
51
|
+
variant?: 'primary' | 'secondary' | 'default' | 'disabled' | 'link' | 'secret' | 'outline' | 'danger';
|
|
52
|
+
}>;
|
|
53
|
+
|
|
54
|
+
// ==================== CONTENT SECTIONS (MUTUALLY EXCLUSIVE) ====================
|
|
55
|
+
/** Which content section to display. Content sections bleed to edges like Card.Section */
|
|
56
|
+
contentSection: ContentSection;
|
|
57
|
+
|
|
58
|
+
// Key Insights Section
|
|
59
|
+
/** Array of key insights to display */
|
|
60
|
+
insights?: Omit<KeyInsightProps, 'showBorder'>[];
|
|
61
|
+
|
|
62
|
+
// Description Section
|
|
63
|
+
/** Optional title for description section */
|
|
64
|
+
descriptionTitle?: string;
|
|
65
|
+
/** Description text content */
|
|
66
|
+
description?: string;
|
|
67
|
+
/** Whether description supports markdown/links */
|
|
68
|
+
allowLinks?: boolean;
|
|
69
|
+
|
|
70
|
+
// DescriptionBlock Section
|
|
71
|
+
/** Title for the description block */
|
|
72
|
+
descriptionBlockTitle?: string;
|
|
73
|
+
/** Description text for the description block */
|
|
74
|
+
descriptionBlockText?: string;
|
|
75
|
+
/** Whether description block supports HTML/links */
|
|
76
|
+
descriptionBlockAllowHtml?: boolean;
|
|
77
|
+
|
|
78
|
+
// Name Value Pairs Section
|
|
79
|
+
/** Array of name-value pairs */
|
|
80
|
+
nameValuePairs?: NameValuePair[];
|
|
81
|
+
/** Number of columns for name-value grid */
|
|
82
|
+
nameValueColumns?: number;
|
|
83
|
+
|
|
84
|
+
// Drawer Section
|
|
85
|
+
/** Content to show in expanded drawer */
|
|
86
|
+
drawerContent?: React.ReactNode;
|
|
87
|
+
/** Text for the button when drawer is closed (e.g., "Show More") */
|
|
88
|
+
drawerLabel?: string;
|
|
89
|
+
/** Text for the button when drawer is open (e.g., "Show Less") */
|
|
90
|
+
drawerLabelOpen?: string;
|
|
91
|
+
/** Whether drawer starts open */
|
|
92
|
+
defaultDrawerOpen?: boolean;
|
|
93
|
+
|
|
94
|
+
// ==================== STYLING ====================
|
|
95
|
+
/** Additional styling for the card container */
|
|
96
|
+
cardProps?: Record<string, any>;
|
|
97
|
+
/** Custom spacing */
|
|
98
|
+
spacing?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ========================== CONSTANTS ==========================
|
|
102
|
+
|
|
103
|
+
const ICON_STYLES = {
|
|
104
|
+
width: rem(58),
|
|
105
|
+
height: rem(58),
|
|
106
|
+
minWidth: rem(58),
|
|
107
|
+
minHeight: rem(58),
|
|
108
|
+
borderColor: 'var(--ad-color-border-strong)',
|
|
109
|
+
} as const;
|
|
110
|
+
|
|
111
|
+
// ========================== COMPONENT ==========================
|
|
112
|
+
|
|
113
|
+
export function PageContentHeader({
|
|
114
|
+
// Header props
|
|
115
|
+
subhead,
|
|
116
|
+
title,
|
|
117
|
+
badge,
|
|
118
|
+
icon,
|
|
119
|
+
iconSize = 44,
|
|
120
|
+
iconContainerSize = 58,
|
|
121
|
+
editable = false,
|
|
122
|
+
onEdit,
|
|
123
|
+
|
|
124
|
+
// Action props
|
|
125
|
+
actions = [],
|
|
126
|
+
|
|
127
|
+
// Content props
|
|
128
|
+
contentSection,
|
|
129
|
+
insights = [],
|
|
130
|
+
descriptionTitle,
|
|
131
|
+
description,
|
|
132
|
+
allowLinks = false,
|
|
133
|
+
descriptionBlockTitle,
|
|
134
|
+
descriptionBlockText,
|
|
135
|
+
descriptionBlockAllowHtml,
|
|
136
|
+
nameValuePairs = [],
|
|
137
|
+
nameValueColumns = 2,
|
|
138
|
+
drawerContent,
|
|
139
|
+
drawerLabel = 'Show More',
|
|
140
|
+
drawerLabelOpen = 'Show Less',
|
|
141
|
+
defaultDrawerOpen = false,
|
|
142
|
+
|
|
143
|
+
// Styling props
|
|
144
|
+
cardProps = {},
|
|
145
|
+
spacing = 'sm',
|
|
146
|
+
}: PageContentHeaderProps) {
|
|
147
|
+
|
|
148
|
+
const [drawerOpened, { toggle: toggleDrawer }] = useDisclosure(defaultDrawerOpen);
|
|
149
|
+
|
|
150
|
+
// ==================== RENDER FUNCTIONS ==========================
|
|
151
|
+
|
|
152
|
+
const renderHeader = () => (
|
|
153
|
+
<Inline justify="space-between" align="flex-start">
|
|
154
|
+
<Inline gap="xs" align="flex-start">
|
|
155
|
+
{/* Icon */}
|
|
156
|
+
{icon && (
|
|
157
|
+
<ThemeIcon
|
|
158
|
+
variant="outline"
|
|
159
|
+
c="gray.9"
|
|
160
|
+
size="xxl"
|
|
161
|
+
radius="md"
|
|
162
|
+
style={{
|
|
163
|
+
...ICON_STYLES,
|
|
164
|
+
width: rem(iconContainerSize),
|
|
165
|
+
height: rem(iconContainerSize),
|
|
166
|
+
minWidth: rem(iconContainerSize),
|
|
167
|
+
minHeight: rem(iconContainerSize),
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
{typeof icon === 'string' ? (
|
|
171
|
+
<i className={icon} style={{ fontSize: iconSize }} />
|
|
172
|
+
) : React.isValidElement(icon) && icon.type === 'i' ? (
|
|
173
|
+
React.cloneElement(icon as React.ReactElement, {
|
|
174
|
+
style: { ...((icon as React.ReactElement).props.style || {}), fontSize: iconSize }
|
|
175
|
+
})
|
|
176
|
+
) : (
|
|
177
|
+
React.cloneElement(icon as React.ReactElement, { size: iconSize })
|
|
178
|
+
)}
|
|
179
|
+
</ThemeIcon>
|
|
180
|
+
)}
|
|
181
|
+
|
|
182
|
+
{/* Subhead, Title and Badge */}
|
|
183
|
+
<Stack gap="0" align="flex-start">
|
|
184
|
+
{subhead && (
|
|
185
|
+
<Inline justify="flex-start" align="center" gap="xs">
|
|
186
|
+
<Text size="md">
|
|
187
|
+
{subhead}
|
|
188
|
+
</Text>
|
|
189
|
+
{badge && (
|
|
190
|
+
<Badge size="md" variant="outline" color="default">
|
|
191
|
+
{badge}
|
|
192
|
+
</Badge>
|
|
193
|
+
)}
|
|
194
|
+
</Inline>
|
|
195
|
+
)}
|
|
196
|
+
<Inline gap="xs" align="center">
|
|
197
|
+
<Title order={3}>
|
|
198
|
+
{title}
|
|
199
|
+
</Title>
|
|
200
|
+
{editable && (
|
|
201
|
+
<ActionIcon
|
|
202
|
+
size="sm"
|
|
203
|
+
onClick={onEdit}
|
|
204
|
+
aria-label="Edit title"
|
|
205
|
+
style={{ marginLeft: rem(4) }}
|
|
206
|
+
>
|
|
207
|
+
<RiEditLine size={16} />
|
|
208
|
+
</ActionIcon>
|
|
209
|
+
)}
|
|
210
|
+
</Inline>
|
|
211
|
+
</Stack>
|
|
212
|
+
</Inline>
|
|
213
|
+
</Inline>
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
const renderActions = () => {
|
|
217
|
+
if (actions.length === 0) return null;
|
|
218
|
+
|
|
219
|
+
return (
|
|
220
|
+
<Inline gap="sm">
|
|
221
|
+
{actions.map((action, index) => (
|
|
222
|
+
<Button
|
|
223
|
+
key={index}
|
|
224
|
+
variant={action.variant || 'default'}
|
|
225
|
+
onClick={action.onClick}
|
|
226
|
+
size="sm"
|
|
227
|
+
>
|
|
228
|
+
{action.label}
|
|
229
|
+
</Button>
|
|
230
|
+
))}
|
|
231
|
+
</Inline>
|
|
232
|
+
);
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const renderKeyInsights = () => (
|
|
236
|
+
<Box p={0}>
|
|
237
|
+
<SimpleGrid cols={insights.length} spacing="sm">
|
|
238
|
+
{insights.map((insight, index) => (
|
|
239
|
+
<KeyInsight
|
|
240
|
+
key={index}
|
|
241
|
+
value={insight.value}
|
|
242
|
+
title={insight.title}
|
|
243
|
+
subtitle={insight.subtitle}
|
|
244
|
+
showBorder={index < insights.length - 1}
|
|
245
|
+
/>
|
|
246
|
+
))}
|
|
247
|
+
</SimpleGrid>
|
|
248
|
+
</Box>
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
const renderDescription = () => {
|
|
252
|
+
if (!description && !descriptionTitle) return null;
|
|
253
|
+
return (
|
|
254
|
+
<Box p={spacing}>
|
|
255
|
+
<Stack gap="xs">
|
|
256
|
+
{descriptionTitle && (
|
|
257
|
+
<Title order={5}>
|
|
258
|
+
{descriptionTitle}
|
|
259
|
+
</Title>
|
|
260
|
+
)}
|
|
261
|
+
{allowLinks ? (
|
|
262
|
+
<Text size="sm" c="dimmed" style={{ lineHeight: 1.6 }}>
|
|
263
|
+
<div dangerouslySetInnerHTML={{ __html: description || '' }} />
|
|
264
|
+
</Text>
|
|
265
|
+
) : (
|
|
266
|
+
<Text size="sm" c="dimmed" style={{ lineHeight: 1.6 }}>
|
|
267
|
+
{description}
|
|
268
|
+
</Text>
|
|
269
|
+
)}
|
|
270
|
+
</Stack>
|
|
271
|
+
</Box>
|
|
272
|
+
);
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const renderDescriptionBlock = () => {
|
|
276
|
+
if (!descriptionBlockText) return null;
|
|
277
|
+
|
|
278
|
+
// DescriptionBlock bleeds to edges - no padding wrapper
|
|
279
|
+
return (
|
|
280
|
+
<DescriptionBlock
|
|
281
|
+
title={descriptionBlockTitle}
|
|
282
|
+
description={descriptionBlockText}
|
|
283
|
+
allowHtml={descriptionBlockAllowHtml}
|
|
284
|
+
/>
|
|
285
|
+
);
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const renderNameValuePairs = () => (
|
|
289
|
+
<Box p={spacing}>
|
|
290
|
+
<NameValue
|
|
291
|
+
pairs={nameValuePairs}
|
|
292
|
+
columns={nameValueColumns}
|
|
293
|
+
spacing="md"
|
|
294
|
+
labelSize="xs"
|
|
295
|
+
valueSize="sm"
|
|
296
|
+
/>
|
|
297
|
+
</Box>
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
const renderDrawer = () => (
|
|
301
|
+
<Box p={0}>
|
|
302
|
+
<Stack gap={0}>
|
|
303
|
+
|
|
304
|
+
<Collapse expanded={drawerOpened}>
|
|
305
|
+
<Box
|
|
306
|
+
p={spacing}
|
|
307
|
+
style={{
|
|
308
|
+
backgroundColor: 'white', // Light blue background when open
|
|
309
|
+
}}
|
|
310
|
+
>
|
|
311
|
+
{drawerContent}
|
|
312
|
+
</Box>
|
|
313
|
+
</Collapse>
|
|
314
|
+
{/* Special drawer button - no border, no radius, fills space */}
|
|
315
|
+
<Button
|
|
316
|
+
onClick={toggleDrawer}
|
|
317
|
+
rightSection={
|
|
318
|
+
drawerOpened ? <RiArrowUpSLine size={16} /> : <RiArrowDownSLine size={16} />
|
|
319
|
+
}
|
|
320
|
+
fullWidth
|
|
321
|
+
size="sm"
|
|
322
|
+
style={{
|
|
323
|
+
border: drawerOpened ? '1px solid var(--ad-color-border-default)' : 'none',
|
|
324
|
+
borderRadius: 0,
|
|
325
|
+
backgroundColor: drawerOpened
|
|
326
|
+
? 'var(--ad-color-brand-light)'
|
|
327
|
+
: 'var(--ad-color-bg-subtle)',
|
|
328
|
+
color: 'var(--ad-color-text-default)',
|
|
329
|
+
transition: 'background-color 0.2s ease',
|
|
330
|
+
}}
|
|
331
|
+
>
|
|
332
|
+
{drawerOpened ? drawerLabelOpen : drawerLabel}
|
|
333
|
+
</Button>
|
|
334
|
+
|
|
335
|
+
</Stack>
|
|
336
|
+
</Box>
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
const renderContentSection = () => {
|
|
340
|
+
switch (contentSection) {
|
|
341
|
+
case 'insights':
|
|
342
|
+
return renderKeyInsights();
|
|
343
|
+
case 'description':
|
|
344
|
+
return renderDescription();
|
|
345
|
+
case 'descriptionBlock':
|
|
346
|
+
return renderDescriptionBlock();
|
|
347
|
+
case 'nameValuePairs':
|
|
348
|
+
return renderNameValuePairs();
|
|
349
|
+
case 'drawer':
|
|
350
|
+
return renderDrawer();
|
|
351
|
+
default:
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
// ==================== MAIN RENDER ==========================
|
|
357
|
+
|
|
358
|
+
const contentSection_ = renderContentSection();
|
|
359
|
+
|
|
360
|
+
return (
|
|
361
|
+
<Card pb={contentSection_ ? 0 : undefined} {...cardProps}>
|
|
362
|
+
{/* Header Section */}
|
|
363
|
+
<Stack gap={spacing}>
|
|
364
|
+
<Box>
|
|
365
|
+
{renderHeader()}
|
|
366
|
+
</Box>
|
|
367
|
+
{/* Actions Section */}
|
|
368
|
+
{actions.length > 0 && (
|
|
369
|
+
<Box>
|
|
370
|
+
{renderActions()}
|
|
371
|
+
</Box>
|
|
372
|
+
)}
|
|
373
|
+
</Stack>
|
|
374
|
+
|
|
375
|
+
{/* Content Section - uses Card.Section to bleed to edges */}
|
|
376
|
+
{contentSection_ && (
|
|
377
|
+
<Card.Section withBorder mt="md">
|
|
378
|
+
{contentSection_}
|
|
379
|
+
</Card.Section>
|
|
380
|
+
)}
|
|
381
|
+
</Card>
|
|
382
|
+
);
|
|
383
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { ActionIcon } from '@mantine/core';
|
|
5
|
+
import { Tooltip } from '../../Overlays/Tooltip';
|
|
6
|
+
import { RiFileCopyLine } from '@remixicon/react';
|
|
7
|
+
|
|
8
|
+
export interface CopyButtonProps {
|
|
9
|
+
/** Value to copy to clipboard */
|
|
10
|
+
value: string;
|
|
11
|
+
/** Label for accessibility and tooltip context */
|
|
12
|
+
label: string;
|
|
13
|
+
/** Callback when copy action is performed */
|
|
14
|
+
onCopy?: (value: string) => void;
|
|
15
|
+
/** Size of the copy icon */
|
|
16
|
+
iconSize?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 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
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Basic usage
|
|
27
|
+
* <CopyButton
|
|
28
|
+
* value="Production"
|
|
29
|
+
* label="Environment"
|
|
30
|
+
* onCopy={(value) => navigator.clipboard.writeText(value)}
|
|
31
|
+
* />
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // With custom icon size
|
|
35
|
+
* <CopyButton
|
|
36
|
+
* value="sk-1234567890abcdef"
|
|
37
|
+
* label="API Key"
|
|
38
|
+
* iconSize={16}
|
|
39
|
+
* onCopy={(value) => {
|
|
40
|
+
* navigator.clipboard.writeText(value);
|
|
41
|
+
* console.log('API Key copied');
|
|
42
|
+
* }}
|
|
43
|
+
* />
|
|
44
|
+
*/
|
|
45
|
+
export function CopyButton({
|
|
46
|
+
value,
|
|
47
|
+
label,
|
|
48
|
+
onCopy,
|
|
49
|
+
iconSize = 24,
|
|
50
|
+
}: 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
|
+
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>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Alert as MantineAlert, AlertProps as MantineAlertProps } from '@mantine/core';
|
|
5
|
+
import { RiInformationLine, RiCheckboxCircleLine, RiErrorWarningLine, RiTimeLine } from '@remixicon/react';
|
|
6
|
+
import { ALERT_TO_MANTINE_COLOR, type DSAlertColor } from '../types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Enhanced Alert props extending Mantine's AlertProps
|
|
10
|
+
*/
|
|
11
|
+
export interface DSAlertProps extends Omit<MantineAlertProps, 'color' | 'variant' | 'icon'> {
|
|
12
|
+
/** Alert semantic color */
|
|
13
|
+
color?: DSAlertColor;
|
|
14
|
+
/** Deprecated semantic alias kept for backward compatibility */
|
|
15
|
+
type?: DSAlertColor;
|
|
16
|
+
/** Custom icon (overrides default semantic icon) */
|
|
17
|
+
icon?: React.ReactNode;
|
|
18
|
+
/** Alert title */
|
|
19
|
+
title?: string;
|
|
20
|
+
/** Whether alert can be closed */
|
|
21
|
+
withCloseButton?: boolean;
|
|
22
|
+
/** Close button handler */
|
|
23
|
+
onClose?: () => void;
|
|
24
|
+
/** Alert content */
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* AppDirect Design System Alert Component
|
|
30
|
+
*
|
|
31
|
+
* A semantic alert component built on top of Mantine's Alert with
|
|
32
|
+
* consistent design system styling and semantic color options.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* // Basic usage
|
|
37
|
+
* <Alert color="info" title="Information">
|
|
38
|
+
* This is an informational alert message.
|
|
39
|
+
* </Alert>
|
|
40
|
+
*
|
|
41
|
+
* // Different semantic colors
|
|
42
|
+
* <Alert color="success" title="Success">Operation completed successfully!</Alert>
|
|
43
|
+
* <Alert color="danger" title="Error">Something went wrong.</Alert>
|
|
44
|
+
* <Alert color="pending" title="Processing">Your request is being processed...</Alert>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* // With close button
|
|
50
|
+
* <Alert
|
|
51
|
+
* color="info"
|
|
52
|
+
* title="Notification"
|
|
53
|
+
* withCloseButton
|
|
54
|
+
* onClose={() => console.log('Alert closed')}
|
|
55
|
+
* >
|
|
56
|
+
* This alert can be dismissed.
|
|
57
|
+
* </Alert>
|
|
58
|
+
*
|
|
59
|
+
* // With custom icon
|
|
60
|
+
* <Alert
|
|
61
|
+
* color="info"
|
|
62
|
+
* title="Custom Alert"
|
|
63
|
+
* icon={<RiStarLine size={20} />}
|
|
64
|
+
* >
|
|
65
|
+
* This alert uses a custom star icon instead of the default info icon.
|
|
66
|
+
* </Alert>
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```tsx
|
|
71
|
+
* // Different semantic colors
|
|
72
|
+
* <Alert color="info" title="Information">Info message with light background</Alert>
|
|
73
|
+
* <Alert color="success" title="Success">Success message with light background</Alert>
|
|
74
|
+
* <Alert color="danger" title="Error">Error message with light background</Alert>
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export const Alert = forwardRef<HTMLDivElement, DSAlertProps>(
|
|
78
|
+
(
|
|
79
|
+
{
|
|
80
|
+
color = 'default',
|
|
81
|
+
type,
|
|
82
|
+
icon: customIcon,
|
|
83
|
+
title,
|
|
84
|
+
withCloseButton = false,
|
|
85
|
+
onClose,
|
|
86
|
+
children,
|
|
87
|
+
...props
|
|
88
|
+
},
|
|
89
|
+
ref
|
|
90
|
+
) => {
|
|
91
|
+
// Keep `type` as a deprecated alias while `color` becomes the primary API.
|
|
92
|
+
const semanticColor = color ?? type ?? 'default';
|
|
93
|
+
|
|
94
|
+
// Map semantic colors to Mantine colors and default icons
|
|
95
|
+
const getAlertConfig = (alertColor: DSAlertColor) => {
|
|
96
|
+
const icons: Record<DSAlertColor, React.ReactNode> = {
|
|
97
|
+
info: <RiInformationLine size={20} />,
|
|
98
|
+
success: <RiCheckboxCircleLine size={20} />,
|
|
99
|
+
danger: <RiErrorWarningLine size={20} />,
|
|
100
|
+
pending: <RiTimeLine size={20} />,
|
|
101
|
+
default: <RiInformationLine size={20} />,
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
color: ALERT_TO_MANTINE_COLOR[alertColor],
|
|
105
|
+
icon: icons[alertColor],
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const { color: mantineColor, icon: defaultIcon } = getAlertConfig(semanticColor);
|
|
110
|
+
const alertIcon = customIcon || defaultIcon;
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<MantineAlert
|
|
114
|
+
ref={ref}
|
|
115
|
+
variant="light"
|
|
116
|
+
color={mantineColor}
|
|
117
|
+
radius="sm"
|
|
118
|
+
icon={alertIcon}
|
|
119
|
+
title={title}
|
|
120
|
+
withCloseButton={withCloseButton}
|
|
121
|
+
onClose={onClose}
|
|
122
|
+
{...props}
|
|
123
|
+
>
|
|
124
|
+
{children}
|
|
125
|
+
</MantineAlert>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
Alert.displayName = 'Alert';
|