@appdirect/design-system 0.0.11 → 0.0.13
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 +84 -6
- package/dist/Buttons/ActionIcon.js +14 -0
- package/dist/Buttons/Button.js +66 -0
- package/dist/Buttons/CloseButton.js +48 -0
- package/dist/Buttons/index.js +13 -0
- package/dist/Combobox/AutocompleteClearable.js +36 -0
- package/dist/Combobox/Combobox.js +28 -0
- package/dist/Combobox/Multiselect.js +31 -0
- package/dist/Combobox/SearchableSelect.js +43 -0
- package/dist/Combobox/Select.js +72 -0
- package/dist/Combobox/index.js +10 -0
- package/dist/ComplexComponents/DashboardWidget/DashboardWidget.js +96 -0
- package/dist/ComplexComponents/DashboardWidget/index.js +1 -0
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +82 -0
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.js +23 -0
- package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.js +23 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +230 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.js +30 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/DateRangeFilter.js +12 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterRenderer.js +32 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterSystem.js +90 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/MultiSelectFilter.js +43 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/SingleSelectFilter.js +30 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/index.js +39 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/types.js +9 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.js +31 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +42 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.js +21 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.js +410 -0
- package/dist/ComplexComponents/DataTable/DataTable.js +405 -0
- package/dist/ComplexComponents/DataTable/ErrorOverlay/index.js +9 -0
- package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.js +27 -0
- package/dist/ComplexComponents/DataTable/index.js +1 -0
- package/dist/ComplexComponents/DataTable/translations/en.js +99 -0
- package/dist/ComplexComponents/DataTable/translations/index.js +17 -0
- package/dist/ComplexComponents/KeyInsight/KeyInsights.js +176 -0
- package/dist/ComplexComponents/KeyInsight/index.js +1 -0
- package/dist/ComplexComponents/NameValue/NameValue.js +94 -0
- package/dist/ComplexComponents/NameValue/NameValueItem.js +59 -0
- package/dist/ComplexComponents/NameValue/index.js +2 -0
- package/dist/ComplexComponents/PageContentHeader/PageContentHeader.js +92 -0
- package/dist/ComplexComponents/PageContentHeader/index.js +1 -0
- package/dist/ComplexComponents/Placeholder/Placeholder.js +51 -0
- package/dist/ComplexComponents/Placeholder/index.js +1 -0
- package/dist/ComplexComponents/Slat/Slat.js +53 -0
- package/dist/ComplexComponents/Slat/index.js +1 -0
- package/dist/ComplexComponents/Utilities/CopyButton.js +45 -0
- package/dist/ComplexComponents/Utilities/index.js +1 -0
- package/dist/DataDisplay/Alert.js +77 -0
- package/dist/DataDisplay/Avatar.js +157 -0
- package/dist/DataDisplay/Badge.js +78 -0
- package/dist/DataDisplay/Card.js +100 -0
- package/dist/DataDisplay/Chip.js +36 -0
- package/dist/DataDisplay/Indicator.js +59 -0
- package/dist/DataDisplay/List.js +60 -0
- package/dist/DataDisplay/Pill.js +81 -0
- package/dist/DataDisplay/Progress.js +42 -0
- package/dist/DataDisplay/Table.js +38 -0
- package/dist/DataDisplay/ThemeIcon.js +31 -0
- package/dist/DataDisplay/index.js +18 -0
- package/dist/Inputs/Checkbox.js +62 -0
- package/dist/Inputs/ColorInput.js +48 -0
- package/dist/Inputs/DropZone.js +12 -0
- package/dist/Inputs/FileInput.js +77 -0
- package/dist/Inputs/NumberInput.js +49 -0
- package/dist/Inputs/Radio.js +55 -0
- package/dist/Inputs/RadioGroup.js +59 -0
- package/dist/Inputs/SegmentedControl.js +50 -0
- package/dist/Inputs/Slider.js +50 -0
- package/dist/Inputs/SliderWithLabel.js +32 -0
- package/dist/Inputs/Switch.js +47 -0
- package/dist/Inputs/TextArea.js +50 -0
- package/dist/Inputs/TextInput.js +87 -0
- package/dist/Inputs/index.js +27 -0
- package/dist/Layout/Box.js +39 -0
- package/dist/Layout/Center.js +11 -0
- package/dist/Layout/Container.js +11 -0
- package/dist/Layout/Flex.js +12 -0
- package/dist/Layout/Grid.js +13 -0
- package/dist/Layout/Group.js +14 -0
- package/dist/Layout/Inline.js +46 -0
- package/dist/Layout/SimpleGrid.js +14 -0
- package/dist/Layout/Stack.js +45 -0
- package/dist/Layout/index.js +10 -0
- package/dist/Misc/Divider.js +8 -0
- package/dist/Misc/Paper.js +24 -0
- package/dist/Misc/index.js +10 -0
- package/dist/Navigation/Breadcrumb.js +60 -0
- package/dist/Navigation/NavLink.js +28 -0
- package/dist/Navigation/Stepper.js +8 -0
- package/dist/Navigation/Tabs.js +22 -0
- package/dist/Navigation/index.js +9 -0
- package/dist/Overlays/Drawer.js +63 -0
- package/dist/Overlays/Menu.js +85 -0
- package/dist/Overlays/Modal.js +61 -0
- package/dist/Overlays/Popover.js +118 -0
- package/dist/Overlays/Tooltip.js +71 -0
- package/dist/Overlays/index.js +12 -0
- package/dist/Shell/AppShellLayout.js +13 -0
- package/dist/Shell/HeaderBar.js +8 -0
- package/dist/Shell/SidebarNav.js +9 -0
- package/dist/Shell/SidebarNavLink.js +17 -0
- package/dist/Shell/SingleColumnLayout.js +11 -0
- package/dist/Shell/TertiaryColumnLayout.js +12 -0
- package/dist/Shell/index.js +6 -0
- package/dist/Typography/Code.js +8 -0
- package/dist/Typography/Kbd.js +58 -0
- package/dist/Typography/Text.js +8 -0
- package/dist/Typography/Title.js +11 -0
- package/dist/Typography/index.js +12 -0
- package/dist/config.js +202 -0
- package/dist/contracts/index.json +1 -1
- package/dist/css/mantine.css +2 -2
- package/dist/hooks/useTableHandlers.js +136 -0
- package/dist/hooks/useTableRenderFunctions.js +164 -0
- package/dist/hooks/useTableState.js +70 -0
- package/dist/index.js +162 -0
- package/dist/stories/index.json +1 -1
- package/dist/types.js +127 -0
- package/package.json +9 -6
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Box } from '../../Layout/Box.js';
|
|
5
|
+
import { Text } from '../../Typography/Text.js';
|
|
6
|
+
import { Title } from '../../Typography/Title.js';
|
|
7
|
+
import { Inline } from '../../Layout/Inline.js';
|
|
8
|
+
// Size mappings for different elements
|
|
9
|
+
const sizeConfig = {
|
|
10
|
+
xs: {
|
|
11
|
+
valueOrder: 4, // h4
|
|
12
|
+
titleSize: 'xs',
|
|
13
|
+
subtitleSize: 'xs',
|
|
14
|
+
padding: 'xs',
|
|
15
|
+
customValueStyle: undefined,
|
|
16
|
+
customTitleStyle: undefined,
|
|
17
|
+
customSubtitleStyle: undefined,
|
|
18
|
+
},
|
|
19
|
+
sm: {
|
|
20
|
+
valueOrder: 3, // h3
|
|
21
|
+
titleSize: 'sm',
|
|
22
|
+
subtitleSize: 'sm',
|
|
23
|
+
padding: 'xs',
|
|
24
|
+
customValueStyle: undefined,
|
|
25
|
+
customTitleStyle: undefined,
|
|
26
|
+
customSubtitleStyle: undefined,
|
|
27
|
+
},
|
|
28
|
+
md: {
|
|
29
|
+
valueOrder: 2, // h2
|
|
30
|
+
titleSize: 'md',
|
|
31
|
+
subtitleSize: 'md',
|
|
32
|
+
padding: 'sm',
|
|
33
|
+
customValueStyle: undefined,
|
|
34
|
+
customTitleStyle: undefined,
|
|
35
|
+
customSubtitleStyle: undefined,
|
|
36
|
+
},
|
|
37
|
+
lg: {
|
|
38
|
+
valueOrder: 1, // h1
|
|
39
|
+
titleSize: 'lg',
|
|
40
|
+
subtitleSize: 'lg',
|
|
41
|
+
padding: 'sm',
|
|
42
|
+
customValueStyle: undefined,
|
|
43
|
+
customTitleStyle: undefined,
|
|
44
|
+
customSubtitleStyle: undefined,
|
|
45
|
+
},
|
|
46
|
+
jumbo: {
|
|
47
|
+
valueOrder: 1, // h1 as base, but will be overridden
|
|
48
|
+
titleSize: 'xl',
|
|
49
|
+
subtitleSize: 'xl',
|
|
50
|
+
padding: 'md',
|
|
51
|
+
customValueStyle: {
|
|
52
|
+
fontSize: '96px',
|
|
53
|
+
lineHeight: '130%',
|
|
54
|
+
},
|
|
55
|
+
customTitleStyle: undefined,
|
|
56
|
+
customSubtitleStyle: undefined,
|
|
57
|
+
},
|
|
58
|
+
'super-jumbo': {
|
|
59
|
+
valueOrder: 1, // h1 as base, but will be overridden
|
|
60
|
+
titleSize: 'xl', // Will be overridden
|
|
61
|
+
subtitleSize: 'xl', // Will be overridden
|
|
62
|
+
padding: 'lg',
|
|
63
|
+
customValueStyle: {
|
|
64
|
+
fontSize: '128px',
|
|
65
|
+
lineHeight: '130%',
|
|
66
|
+
},
|
|
67
|
+
customTitleStyle: {
|
|
68
|
+
fontSize: '32px',
|
|
69
|
+
lineHeight: '116%',
|
|
70
|
+
},
|
|
71
|
+
customSubtitleStyle: {
|
|
72
|
+
fontSize: '32px',
|
|
73
|
+
lineHeight: '116%',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* KeyInsight Component
|
|
79
|
+
*
|
|
80
|
+
* A reusable component for displaying key metrics or insights with a title, value, and optional subtitle.
|
|
81
|
+
* Commonly used in dashboards, analytics pages, or summary sections.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* // Basic usage
|
|
85
|
+
* <KeyInsight
|
|
86
|
+
* value={1250}
|
|
87
|
+
* title="Total Users"
|
|
88
|
+
* />
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* // With subtitle and custom size
|
|
92
|
+
* <KeyInsight
|
|
93
|
+
* value="95%"
|
|
94
|
+
* title="Success Rate"
|
|
95
|
+
* subtitle="Last 30 days"
|
|
96
|
+
* size="lg"
|
|
97
|
+
* />
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* // Different sizes showcase
|
|
101
|
+
* <Stack gap="md">
|
|
102
|
+
* <KeyInsight value={1250} title="Extra Small" size="xs" />
|
|
103
|
+
* <KeyInsight value={1250} title="Small" size="sm" />
|
|
104
|
+
* <KeyInsight value={1250} title="Medium" size="md" />
|
|
105
|
+
* <KeyInsight value={1250} title="Large" size="lg" />
|
|
106
|
+
* <KeyInsight value={1250} title="Jumbo" size="jumbo" />
|
|
107
|
+
* <KeyInsight value={1250} title="Super Jumbo" size="super-jumbo" />
|
|
108
|
+
* </Stack>
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* // With a trend indicator next to the value
|
|
112
|
+
* <KeyInsight
|
|
113
|
+
* value="42%"
|
|
114
|
+
* title="Conversion Rate"
|
|
115
|
+
* rightSection={<RiArrowUpLine size={16} color="var(--ad-color-status-success)" />}
|
|
116
|
+
* />
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* // Hero metrics with jumbo size
|
|
120
|
+
* <KeyInsight
|
|
121
|
+
* value="$2.4M"
|
|
122
|
+
* title="Annual Revenue"
|
|
123
|
+
* subtitle="2024 Performance"
|
|
124
|
+
* size="jumbo"
|
|
125
|
+
* />
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* // In a simple grid layout with borders
|
|
129
|
+
* <SimpleGrid cols={3} spacing="sm">
|
|
130
|
+
* <KeyInsight
|
|
131
|
+
* value={1250}
|
|
132
|
+
* title="Total Users"
|
|
133
|
+
* size="lg"
|
|
134
|
+
* showBorder={true}
|
|
135
|
+
* />
|
|
136
|
+
* <KeyInsight
|
|
137
|
+
* value={987}
|
|
138
|
+
* title="Active Users"
|
|
139
|
+
* size="lg"
|
|
140
|
+
* showBorder={true}
|
|
141
|
+
* />
|
|
142
|
+
* <KeyInsight
|
|
143
|
+
* value={263}
|
|
144
|
+
* title="New Users"
|
|
145
|
+
* subtitle="This month"
|
|
146
|
+
* size="lg"
|
|
147
|
+
* showBorder={false}
|
|
148
|
+
* />
|
|
149
|
+
* </SimpleGrid>
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* // Dynamic usage with data
|
|
153
|
+
* const insights = [
|
|
154
|
+
* { value: userData.length, title: "Total Users" },
|
|
155
|
+
* { value: activeUsers.length, title: "Active Users" },
|
|
156
|
+
* { value: newUsers.length, title: "New Users" },
|
|
157
|
+
* ];
|
|
158
|
+
*
|
|
159
|
+
* <Inline>
|
|
160
|
+
* {insights.map((insight, index) => (
|
|
161
|
+
* <KeyInsight
|
|
162
|
+
* key={index}
|
|
163
|
+
* value={insight.value}
|
|
164
|
+
* title={insight.title}
|
|
165
|
+
* size="md"
|
|
166
|
+
* showBorder={index < insights.length - 1}
|
|
167
|
+
* />
|
|
168
|
+
* ))}
|
|
169
|
+
* </Inline>
|
|
170
|
+
*/
|
|
171
|
+
export function KeyInsight({ value, title, subtitle, showBorder = false, size = 'md', leftSection, rightSection, }) {
|
|
172
|
+
const config = sizeConfig[size];
|
|
173
|
+
return (_jsxs(Box, { ta: "center", p: config.padding, style: {
|
|
174
|
+
borderRight: showBorder ? '1px solid var(--ad-color-border-subtle)' : undefined
|
|
175
|
+
}, children: [_jsxs(Inline, { gap: "xxs", align: "center", justify: "center", children: [leftSection, _jsx(Title, { order: config.valueOrder, style: config.customValueStyle, children: value }), rightSection] }), _jsx(Text, { size: config.titleSize, mt: 0, style: config.customTitleStyle, children: title }), subtitle && (_jsx(Text, { size: config.subtitleSize, c: "dimmed", style: config.customSubtitleStyle, children: subtitle }))] }));
|
|
176
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { KeyInsight } from './KeyInsights.js';
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { SimpleGrid } from '../../Layout/SimpleGrid.js';
|
|
5
|
+
import { Stack } from '../../Layout/Stack.js';
|
|
6
|
+
import { NameValueItem } from './NameValueItem.js';
|
|
7
|
+
/**
|
|
8
|
+
* NameValue Component
|
|
9
|
+
*
|
|
10
|
+
* A component for displaying name-value pairs in vertical layout.
|
|
11
|
+
* Can be arranged in a grid format for multiple pairs using the columns prop.
|
|
12
|
+
* Perfect for metadata display, specifications, statistics, or any key-value information.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Single name-value pair with the default copy action
|
|
16
|
+
* <NameValue
|
|
17
|
+
* name="API Key"
|
|
18
|
+
* value="sk-1234567890abcdef"
|
|
19
|
+
* valueColor="green"
|
|
20
|
+
* action={{ onClick: (value) => navigator.clipboard.writeText(value) }}
|
|
21
|
+
* />
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Multiple pairs with selective copy actions
|
|
25
|
+
* const userInfo = [
|
|
26
|
+
* { name: "Name", value: "John Doe" },
|
|
27
|
+
* { name: "Email", value: "john@example.com", action: { onClick: (v) => navigator.clipboard.writeText(v) } },
|
|
28
|
+
* { name: "User ID", value: "usr_123456", action: { onClick: (v) => navigator.clipboard.writeText(v) } },
|
|
29
|
+
* { name: "Last Login", value: "2 hours ago" }
|
|
30
|
+
* ];
|
|
31
|
+
*
|
|
32
|
+
* <NameValue
|
|
33
|
+
* pairs={userInfo}
|
|
34
|
+
* spacing="md"
|
|
35
|
+
* />
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Status values as badges
|
|
39
|
+
* const serverInfo = [
|
|
40
|
+
* { name: "Status", value: "Running", valueAsBadge: true },
|
|
41
|
+
* { name: "IP Address", value: "192.168.1.100", action: { onClick: (v) => navigator.clipboard.writeText(v) } },
|
|
42
|
+
* { name: "Port", value: "8080" },
|
|
43
|
+
* { name: "Uptime", value: "15 days" },
|
|
44
|
+
* ];
|
|
45
|
+
*
|
|
46
|
+
* <NameValue
|
|
47
|
+
* pairs={serverInfo}
|
|
48
|
+
* columns={3}
|
|
49
|
+
* spacing="sm"
|
|
50
|
+
* />
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // All values copyable by default, with a custom action icon for one
|
|
54
|
+
* const credentials = [
|
|
55
|
+
* { name: "Username", value: "admin" },
|
|
56
|
+
* { name: "Password", value: "secret123" },
|
|
57
|
+
* { name: "Token", value: "eyJhbGciOiJIUzI1NiIs..." },
|
|
58
|
+
* { name: "Database URL", value: "postgresql://localhost:5432/db", action: { icon: <RiEditLine size={16} />, onClick: openEditDialog, label: "Edit" } },
|
|
59
|
+
* ];
|
|
60
|
+
*
|
|
61
|
+
* <NameValue
|
|
62
|
+
* pairs={credentials}
|
|
63
|
+
* action={{ onClick: (value) => navigator.clipboard.writeText(value) }}
|
|
64
|
+
* columns={2}
|
|
65
|
+
* />
|
|
66
|
+
*/
|
|
67
|
+
export function NameValue({ name, value, pairs, columns, labelSize = 'xs', valueSize = 'sm', spacing = 'sm', nameColor = 'dimmed', valueColor, valueWeight = 500, valueAsBadge = false, action, }) {
|
|
68
|
+
// Create pairs array from individual props if provided
|
|
69
|
+
const allPairs = pairs || (name && value ? [{ name, value, valueAsBadge, action }] : []);
|
|
70
|
+
if (allPairs.length === 0) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
// Render a single name-value pair using NameValueItem
|
|
74
|
+
const renderPair = (pair, index) => {
|
|
75
|
+
const itemProps = {
|
|
76
|
+
name: pair.name,
|
|
77
|
+
value: pair.value,
|
|
78
|
+
labelSize,
|
|
79
|
+
valueSize,
|
|
80
|
+
nameColor,
|
|
81
|
+
valueColor: pair.valueColor || valueColor,
|
|
82
|
+
valueWeight: pair.valueWeight || valueWeight,
|
|
83
|
+
valueAsBadge: pair.valueAsBadge ?? valueAsBadge,
|
|
84
|
+
action: pair.action ?? action,
|
|
85
|
+
};
|
|
86
|
+
return _jsx(NameValueItem, { ...itemProps }, index);
|
|
87
|
+
};
|
|
88
|
+
// Use equal-width grid layout if columns prop is provided
|
|
89
|
+
if (columns) {
|
|
90
|
+
return (_jsx(SimpleGrid, { cols: columns, spacing: 0, children: allPairs.map((pair, index) => renderPair(pair, index)) }));
|
|
91
|
+
}
|
|
92
|
+
// Default: render all pairs in a vertical stack
|
|
93
|
+
return (_jsx(Stack, { gap: spacing, children: allPairs.map((pair, index) => renderPair(pair, index)) }));
|
|
94
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Inline } from '../../Layout/Inline.js';
|
|
4
|
+
import { Stack } from '../../Layout/Stack.js';
|
|
5
|
+
import { Text } from '../../Typography/Text.js';
|
|
6
|
+
import { Badge } from '../../DataDisplay/Badge.js';
|
|
7
|
+
import { ActionIcon } from '../../Buttons/ActionIcon.js';
|
|
8
|
+
import { Tooltip } from '../../Overlays/Tooltip.js';
|
|
9
|
+
import { RiFileCopyLine } from '@remixicon/react';
|
|
10
|
+
/**
|
|
11
|
+
* NameValueItem Component
|
|
12
|
+
*
|
|
13
|
+
* A component for displaying a single name-value pair with an optional
|
|
14
|
+
* icon-triggered action (copy-to-clipboard by default, or any icon the
|
|
15
|
+
* designer assigns). Designed to be used within the NameValue component or
|
|
16
|
+
* as a standalone item.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Basic name-value pair
|
|
20
|
+
* <NameValueItem
|
|
21
|
+
* name="Status"
|
|
22
|
+
* value="Active"
|
|
23
|
+
* />
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // With the default copy action
|
|
27
|
+
* <NameValueItem
|
|
28
|
+
* name="API Key"
|
|
29
|
+
* value="sk-1234567890abcdef"
|
|
30
|
+
* valueColor="green"
|
|
31
|
+
* action={{ onClick: (value) => navigator.clipboard.writeText(value) }}
|
|
32
|
+
* />
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // With a custom action icon
|
|
36
|
+
* <NameValueItem
|
|
37
|
+
* name="Server Name"
|
|
38
|
+
* value="prod-web-01"
|
|
39
|
+
* action={{ icon: <RiEditLine size={16} />, onClick: openEditDialog, label: 'Edit' }}
|
|
40
|
+
* />
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Value as a badge
|
|
44
|
+
* <NameValueItem name="Status" value="Active" valueAsBadge />
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // Custom styling
|
|
48
|
+
* <NameValueItem
|
|
49
|
+
* name="Revenue"
|
|
50
|
+
* value="$125,430"
|
|
51
|
+
* labelSize="sm"
|
|
52
|
+
* valueSize="lg"
|
|
53
|
+
* valueColor="green"
|
|
54
|
+
* valueWeight="bold"
|
|
55
|
+
* />
|
|
56
|
+
*/
|
|
57
|
+
export function NameValueItem({ name, value, labelSize = 'xs', valueSize = 'sm', nameColor = 'dimmed', valueColor, valueWeight = 500, valueAsBadge = false, action, }) {
|
|
58
|
+
return (_jsxs(Stack, { gap: 0, p: "xs", children: [_jsx(Text, { size: labelSize, c: nameColor, children: name }), _jsxs(Inline, { gap: "xs", align: "center", children: [valueAsBadge ? (_jsx(Badge, { size: valueSize, variant: "outline", color: "default", children: value })) : (_jsx(Text, { size: valueSize, fw: valueWeight, c: valueColor, children: value })), action && (_jsx(Tooltip, { label: action.label ?? 'Copy', position: "top", withArrow: true, children: _jsx(ActionIcon, { variant: "link", color: "gray", size: "xs", onClick: () => action.onClick(value), "aria-label": action.label ?? `Action for ${name}`, children: action.icon ?? _jsx(RiFileCopyLine, { size: action.iconSize ?? 16 }) }) }))] })] }));
|
|
59
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Collapse, rem } from '@mantine/core';
|
|
5
|
+
import { Box } from '../../Layout/Box.js';
|
|
6
|
+
import { SimpleGrid } from '../../Layout/SimpleGrid.js';
|
|
7
|
+
import { Inline } from '../../Layout/Inline.js';
|
|
8
|
+
import { Stack } from '../../Layout/Stack.js';
|
|
9
|
+
import { Button } from '../../Buttons/Button.js';
|
|
10
|
+
import { ActionIcon } from '../../Buttons/ActionIcon.js';
|
|
11
|
+
import { Badge } from '../../DataDisplay/Badge.js';
|
|
12
|
+
import { ThemeIcon } from '../../DataDisplay/ThemeIcon.js';
|
|
13
|
+
import { Text } from '../../Typography/Text.js';
|
|
14
|
+
import { Title } from '../../Typography/Title.js';
|
|
15
|
+
import { Card } from '../../DataDisplay/Card.js';
|
|
16
|
+
import { Alert } from '../../DataDisplay/Alert.js';
|
|
17
|
+
import { useDisclosure } from '@mantine/hooks';
|
|
18
|
+
import { RiEditLine, RiArrowDownSLine, RiArrowUpSLine } from '@remixicon/react';
|
|
19
|
+
import { KeyInsight } from '../KeyInsight/index.js';
|
|
20
|
+
import { NameValue } from '../NameValue/index.js';
|
|
21
|
+
// ========================== CONSTANTS ==========================
|
|
22
|
+
const ICON_STYLES = {
|
|
23
|
+
width: rem(58),
|
|
24
|
+
height: rem(58),
|
|
25
|
+
minWidth: rem(58),
|
|
26
|
+
minHeight: rem(58),
|
|
27
|
+
borderColor: 'var(--ad-color-border-strong)',
|
|
28
|
+
};
|
|
29
|
+
// ========================== COMPONENT ==========================
|
|
30
|
+
export function PageContentHeader({
|
|
31
|
+
// Header props
|
|
32
|
+
subhead, title, badge, icon, iconSize = 44, iconContainerSize = 58, editable = false, onEdit,
|
|
33
|
+
// Action props
|
|
34
|
+
actions = [],
|
|
35
|
+
// Panel notification props
|
|
36
|
+
panelNotification = false, panelNotificationMessage,
|
|
37
|
+
// Content props
|
|
38
|
+
contentSection, insights = [], descriptionTitle, description, allowLinks = false, nameValuePairs = [], nameValueColumns = 2, drawerContent, drawerLabel = 'Show More', drawerLabelOpen = 'Show Less', defaultDrawerOpen = false,
|
|
39
|
+
// Styling props
|
|
40
|
+
cardProps = {}, spacing = 'sm', }) {
|
|
41
|
+
const [drawerOpened, { toggle: toggleDrawer }] = useDisclosure(defaultDrawerOpen);
|
|
42
|
+
// ==================== RENDER FUNCTIONS ==========================
|
|
43
|
+
const renderHeader = () => (_jsx(Inline, { justify: "space-between", align: "flex-start", children: _jsxs(Inline, { gap: "xs", align: "flex-start", children: [icon && (_jsx(ThemeIcon, { variant: "outline", c: "gray.9", size: "xxl", radius: "md", style: {
|
|
44
|
+
...ICON_STYLES,
|
|
45
|
+
width: rem(iconContainerSize),
|
|
46
|
+
height: rem(iconContainerSize),
|
|
47
|
+
minWidth: rem(iconContainerSize),
|
|
48
|
+
minHeight: rem(iconContainerSize),
|
|
49
|
+
}, children: typeof icon === 'string' ? (_jsx("i", { className: icon, style: { fontSize: iconSize } })) : React.isValidElement(icon) && icon.type === 'i' ? (React.cloneElement(icon, {
|
|
50
|
+
style: { ...(icon.props.style || {}), fontSize: iconSize }
|
|
51
|
+
})) : (React.cloneElement(icon, { size: iconSize })) })), _jsxs(Stack, { gap: "0", align: "flex-start", children: [subhead && (_jsxs(Inline, { justify: "flex-start", align: "center", gap: "xs", children: [_jsx(Text, { size: "md", children: subhead }), badge && (_jsx(Badge, { size: "md", variant: "outline", color: "default", children: badge }))] })), _jsxs(Inline, { gap: "xs", align: "center", children: [_jsx(Title, { order: 3, children: title }), editable && (_jsx(ActionIcon, { size: "sm", onClick: onEdit, "aria-label": "Edit title", style: { marginLeft: rem(4) }, children: _jsx(RiEditLine, { size: 16 }) }))] })] })] }) }));
|
|
52
|
+
const renderActions = () => {
|
|
53
|
+
if (actions.length === 0)
|
|
54
|
+
return null;
|
|
55
|
+
return (_jsx(Inline, { gap: "sm", children: actions.map((action, index) => (_jsx(Button, { variant: action.variant || 'default', onClick: action.onClick, size: "sm", children: action.label }, index))) }));
|
|
56
|
+
};
|
|
57
|
+
const renderKeyInsights = () => (_jsx(Box, { p: 0, children: _jsx(SimpleGrid, { cols: insights.length, spacing: "sm", children: insights.map((insight, index) => (_jsx(KeyInsight, { value: insight.value, title: insight.title, subtitle: insight.subtitle, showBorder: index < insights.length - 1 }, index))) }) }));
|
|
58
|
+
const renderDescription = () => {
|
|
59
|
+
if (!description && !descriptionTitle)
|
|
60
|
+
return null;
|
|
61
|
+
return (_jsx(Box, { p: spacing, children: _jsxs(Stack, { gap: "xs", children: [descriptionTitle && (_jsx(Title, { order: 5, children: descriptionTitle })), allowLinks ? (_jsx(Text, { size: "sm", c: "dimmed", style: { lineHeight: 1.6 }, children: _jsx("div", { dangerouslySetInnerHTML: { __html: description || '' } }) })) : (_jsx(Text, { size: "sm", c: "dimmed", style: { lineHeight: 1.6 }, children: description }))] }) }));
|
|
62
|
+
};
|
|
63
|
+
const renderNameValuePairs = () => (_jsx(Box, { p: spacing, children: _jsx(NameValue, { pairs: nameValuePairs, columns: nameValueColumns, spacing: "md", labelSize: "xs", valueSize: "sm" }) }));
|
|
64
|
+
const renderDrawer = () => (_jsx(Box, { p: 0, children: _jsxs(Stack, { gap: 0, children: [_jsx(Collapse, { expanded: drawerOpened, children: _jsx(Box, { p: spacing, style: {
|
|
65
|
+
backgroundColor: 'white', // Light blue background when open
|
|
66
|
+
}, children: drawerContent }) }), _jsx(Button, { onClick: toggleDrawer, rightSection: drawerOpened ? _jsx(RiArrowUpSLine, { size: 16 }) : _jsx(RiArrowDownSLine, { size: 16 }), fullWidth: true, size: "sm", style: {
|
|
67
|
+
border: drawerOpened ? '1px solid var(--ad-color-border-default)' : 'none',
|
|
68
|
+
borderRadius: 0,
|
|
69
|
+
backgroundColor: drawerOpened
|
|
70
|
+
? 'var(--ad-color-brand-light)'
|
|
71
|
+
: 'var(--ad-color-bg-subtle)',
|
|
72
|
+
color: 'var(--ad-color-text-default)',
|
|
73
|
+
transition: 'background-color 0.2s ease',
|
|
74
|
+
}, children: drawerOpened ? drawerLabelOpen : drawerLabel })] }) }));
|
|
75
|
+
const renderContentSection = () => {
|
|
76
|
+
switch (contentSection) {
|
|
77
|
+
case 'insights':
|
|
78
|
+
return renderKeyInsights();
|
|
79
|
+
case 'description':
|
|
80
|
+
return renderDescription();
|
|
81
|
+
case 'nameValuePairs':
|
|
82
|
+
return renderNameValuePairs();
|
|
83
|
+
case 'drawer':
|
|
84
|
+
return renderDrawer();
|
|
85
|
+
default:
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
// ==================== MAIN RENDER ==========================
|
|
90
|
+
const contentSection_ = renderContentSection();
|
|
91
|
+
return (_jsxs(Card, { pb: contentSection_ ? 0 : undefined, ...cardProps, children: [_jsxs(Stack, { gap: spacing, children: [_jsx(Box, { children: renderHeader() }), actions.length > 0 && (_jsx(Box, { children: renderActions() })), panelNotification && (_jsx(Alert, { color: "info", children: panelNotificationMessage }))] }), contentSection_ && (_jsx(Card.Section, { withBorder: true, mt: "md", children: contentSection_ }))] }));
|
|
92
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PageContentHeader } from './PageContentHeader.js';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { ThemeIcon } from '../../DataDisplay/ThemeIcon.js';
|
|
5
|
+
import { Title } from '../../Typography/Title.js';
|
|
6
|
+
import { Text } from '../../Typography/Text.js';
|
|
7
|
+
import { Button } from '../../Buttons/Button.js';
|
|
8
|
+
import { Stack } from '../../Layout/Stack.js';
|
|
9
|
+
import { Inline } from '../../Layout/Inline.js';
|
|
10
|
+
const titleOrderBySize = {
|
|
11
|
+
sm: 5, // h5, 16px
|
|
12
|
+
md: 4, // h4, 18px
|
|
13
|
+
lg: 3, // h3, 22px
|
|
14
|
+
};
|
|
15
|
+
const descriptionSizeBySize = {
|
|
16
|
+
sm: 'sm',
|
|
17
|
+
md: 'md',
|
|
18
|
+
lg: 'lg',
|
|
19
|
+
};
|
|
20
|
+
const actionSizeBySize = {
|
|
21
|
+
sm: 'xs',
|
|
22
|
+
md: 'sm',
|
|
23
|
+
lg: 'md',
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Placeholder Component
|
|
27
|
+
*
|
|
28
|
+
* An empty-state message: icon, title, optional description, and up to two
|
|
29
|
+
* link-style actions. All typography reuses the existing heading/body scale
|
|
30
|
+
* directly (headings h3/h4/h5, Text sm/md/lg) — no new tokens needed. The
|
|
31
|
+
* icon is a fixed ThemeIcon size (lg, 34px) regardless of the placeholder's
|
|
32
|
+
* own size, matching the live Figma design.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* <Placeholder
|
|
36
|
+
* icon={<RiErrorWarningLine size={24} />}
|
|
37
|
+
* title="This is the Title"
|
|
38
|
+
* description="This is the optional description of the placeholder"
|
|
39
|
+
* actions={[
|
|
40
|
+
* { label: 'Button One', onClick: () => {} },
|
|
41
|
+
* { label: 'Button Two', onClick: () => {} },
|
|
42
|
+
* ]}
|
|
43
|
+
* />
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // Large size, no description or actions
|
|
47
|
+
* <Placeholder icon={<RiInboxLine size={24} />} title="No results found" size="lg" />
|
|
48
|
+
*/
|
|
49
|
+
export function Placeholder({ icon, title, description, actions = [], size = 'sm', }) {
|
|
50
|
+
return (_jsxs(Stack, { align: "center", gap: "md", p: "xl", children: [icon && (_jsx(ThemeIcon, { variant: "default", size: "lg", children: icon })), _jsxs(Stack, { align: "center", gap: 0, ta: "center", children: [_jsx(Title, { order: titleOrderBySize[size], children: title }), description && (_jsx(Text, { size: descriptionSizeBySize[size], c: "dimmed", children: description }))] }), actions.length > 0 && (_jsx(Inline, { gap: "xs", justify: "center", children: actions.map((action, index) => (_jsx(Button, { variant: "link", size: actionSizeBySize[size], onClick: action.onClick, children: action.label }, index))) }))] }));
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Placeholder } from './Placeholder.js';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Paper } from '../../Misc/Paper.js';
|
|
5
|
+
import { ThemeIcon } from '../../DataDisplay/ThemeIcon.js';
|
|
6
|
+
import { Indicator } from '../../DataDisplay/Indicator.js';
|
|
7
|
+
import { Badge } from '../../DataDisplay/Badge.js';
|
|
8
|
+
import { Alert } from '../../DataDisplay/Alert.js';
|
|
9
|
+
import { Button } from '../../Buttons/Button.js';
|
|
10
|
+
import { Stack, Inline, Box } from '../../Layout/index.js';
|
|
11
|
+
import { Title } from '../../Typography/Title.js';
|
|
12
|
+
import { Text } from '../../Typography/Text.js';
|
|
13
|
+
// Title order (h6-h2) per Slat size, matching Figma's Components/Slat/h6-h2 styles
|
|
14
|
+
const TITLE_ORDER_BY_SIZE = {
|
|
15
|
+
xs: 6,
|
|
16
|
+
sm: 5,
|
|
17
|
+
md: 4,
|
|
18
|
+
lg: 3,
|
|
19
|
+
xl: 2,
|
|
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
|
|
24
|
+
// to zero size and overlapping neighboring subtitle/badge content.
|
|
25
|
+
const INDICATOR_DOT_SIZE = 12;
|
|
26
|
+
// ========================== COMPONENT ==========================
|
|
27
|
+
/**
|
|
28
|
+
* Slat Component
|
|
29
|
+
*
|
|
30
|
+
* A compact row for listing items (e.g. in a feed or list), with a leading
|
|
31
|
+
* icon, title/subtitle, optional status indicator or badge, a trailing
|
|
32
|
+
* action, and an optional notification banner below.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* <Slat
|
|
36
|
+
* title="This is the title"
|
|
37
|
+
* subtitle="and this is the subhead"
|
|
38
|
+
* icon={<RiStarLine size={16} />}
|
|
39
|
+
* />
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // With status indicator, badge, and action
|
|
43
|
+
* <Slat
|
|
44
|
+
* title="Invoice #1024"
|
|
45
|
+
* subtitle="Due in 3 days"
|
|
46
|
+
* indicator={{ variant: 'pending' }}
|
|
47
|
+
* badge={{ label: 'Draft', color: 'default' }}
|
|
48
|
+
* action={{ label: 'Review', onClick: () => {} }}
|
|
49
|
+
* />
|
|
50
|
+
*/
|
|
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 })] }) }));
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Slat } from './Slat.js';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { ActionIcon } from '@mantine/core';
|
|
5
|
+
import { Tooltip } from '../../Overlays/Tooltip.js';
|
|
6
|
+
import { RiFileCopyLine } from '@remixicon/react';
|
|
7
|
+
/**
|
|
8
|
+
* CopyButton Component
|
|
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.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Basic usage
|
|
15
|
+
* <CopyButton
|
|
16
|
+
* value="Production"
|
|
17
|
+
* label="Environment"
|
|
18
|
+
* onCopy={(value) => navigator.clipboard.writeText(value)}
|
|
19
|
+
* />
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // With custom icon size
|
|
23
|
+
* <CopyButton
|
|
24
|
+
* value="sk-1234567890abcdef"
|
|
25
|
+
* label="API Key"
|
|
26
|
+
* iconSize={16}
|
|
27
|
+
* onCopy={(value) => {
|
|
28
|
+
* navigator.clipboard.writeText(value);
|
|
29
|
+
* console.log('API Key copied');
|
|
30
|
+
* }}
|
|
31
|
+
* />
|
|
32
|
+
*/
|
|
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 }) }) }));
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CopyButton } from './CopyButton.js';
|