@appdirect/design-system 0.0.0-stage → 0.0.1

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 (130) hide show
  1. package/README.md +12 -2
  2. package/dist/Buttons/ActionIcon.tsx +37 -0
  3. package/dist/Buttons/Button.module.css +5 -0
  4. package/dist/Buttons/Button.tsx +124 -0
  5. package/dist/Buttons/CloseButton.tsx +83 -0
  6. package/dist/Buttons/index.ts +20 -0
  7. package/dist/Combobox/AutocompleteClearable.tsx +128 -0
  8. package/dist/Combobox/Combobox.tsx +37 -0
  9. package/dist/Combobox/Multiselect.tsx +158 -0
  10. package/dist/Combobox/SearchableSelect.tsx +131 -0
  11. package/dist/Combobox/Select.tsx +154 -0
  12. package/dist/Combobox/index.ts +20 -0
  13. package/dist/ComplexComponents/DashboardWidget/DashboardWidget.tsx +280 -0
  14. package/dist/ComplexComponents/DashboardWidget/index.ts +2 -0
  15. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.tsx +177 -0
  16. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.ts +35 -0
  17. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.tsx +74 -0
  18. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.tsx +358 -0
  19. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.tsx +48 -0
  20. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/DateRangeFilter.tsx +26 -0
  21. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterRenderer.tsx +71 -0
  22. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterSystem.tsx +158 -0
  23. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/MultiSelectFilter.tsx +79 -0
  24. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/SingleSelectFilter.tsx +65 -0
  25. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/index.ts +70 -0
  26. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/types.ts +140 -0
  27. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.tsx +76 -0
  28. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.tsx +73 -0
  29. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.tsx +50 -0
  30. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.tsx +788 -0
  31. package/dist/ComplexComponents/DataTable/DataTable.tsx +582 -0
  32. package/dist/ComplexComponents/DataTable/ErrorOverlay/index.tsx +29 -0
  33. package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.tsx +57 -0
  34. package/dist/ComplexComponents/DataTable/index.ts +2 -0
  35. package/dist/ComplexComponents/DataTable/translations/en.ts +115 -0
  36. package/dist/ComplexComponents/DataTable/translations/index.ts +23 -0
  37. package/dist/ComplexComponents/KeyInsight/KeyInsights.tsx +221 -0
  38. package/dist/ComplexComponents/KeyInsight/index.ts +2 -0
  39. package/dist/ComplexComponents/NameValue/NameValue.tsx +175 -0
  40. package/dist/ComplexComponents/NameValue/NameValueItem.tsx +100 -0
  41. package/dist/ComplexComponents/NameValue/index.ts +4 -0
  42. package/dist/ComplexComponents/PageContentHeader/DescriptionBlock.tsx +65 -0
  43. package/dist/ComplexComponents/PageContentHeader/PageContentHeader.tsx +383 -0
  44. package/dist/ComplexComponents/PageContentHeader/index.ts +4 -0
  45. package/dist/ComplexComponents/Utilities/CopyButton.tsx +82 -0
  46. package/dist/ComplexComponents/Utilities/index.ts +2 -0
  47. package/dist/DataDisplay/Alert.tsx +130 -0
  48. package/dist/DataDisplay/Avatar.tsx +216 -0
  49. package/dist/DataDisplay/Badge.tsx +119 -0
  50. package/dist/DataDisplay/Card.module.css +26 -0
  51. package/dist/DataDisplay/Card.tsx +163 -0
  52. package/dist/DataDisplay/Chip.tsx +66 -0
  53. package/dist/DataDisplay/Indicator.tsx +122 -0
  54. package/dist/DataDisplay/List.tsx +90 -0
  55. package/dist/DataDisplay/Pill.tsx +125 -0
  56. package/dist/DataDisplay/Progress.tsx +77 -0
  57. package/dist/DataDisplay/Table.tsx +57 -0
  58. package/dist/DataDisplay/ThemeIcon.tsx +67 -0
  59. package/dist/DataDisplay/index.ts +41 -0
  60. package/dist/Inputs/Checkbox.tsx +94 -0
  61. package/dist/Inputs/ColorInput.tsx +124 -0
  62. package/dist/Inputs/DropZone.tsx +78 -0
  63. package/dist/Inputs/FileInput.tsx +120 -0
  64. package/dist/Inputs/NumberInput.tsx +125 -0
  65. package/dist/Inputs/Radio.tsx +86 -0
  66. package/dist/Inputs/RadioGroup.tsx +90 -0
  67. package/dist/Inputs/SegmentedControl.tsx +64 -0
  68. package/dist/Inputs/Slider.tsx +69 -0
  69. package/dist/Inputs/Switch.tsx +67 -0
  70. package/dist/Inputs/TextArea.tsx +126 -0
  71. package/dist/Inputs/TextInput.tsx +167 -0
  72. package/dist/Inputs/index.ts +51 -0
  73. package/dist/Layout/Box.tsx +82 -0
  74. package/dist/Layout/Center.tsx +17 -0
  75. package/dist/Layout/Container.tsx +17 -0
  76. package/dist/Layout/Flex.tsx +18 -0
  77. package/dist/Layout/Grid.tsx +31 -0
  78. package/dist/Layout/Group.tsx +54 -0
  79. package/dist/Layout/Inline.tsx +86 -0
  80. package/dist/Layout/SimpleGrid.tsx +50 -0
  81. package/dist/Layout/Stack.tsx +86 -0
  82. package/dist/Layout/index.ts +29 -0
  83. package/dist/Misc/Divider.tsx +27 -0
  84. package/dist/Misc/Paper.tsx +47 -0
  85. package/dist/Misc/index.ts +15 -0
  86. package/dist/Navigation/Breadcrumb.tsx +138 -0
  87. package/dist/Navigation/NavLink.tsx +37 -0
  88. package/dist/Navigation/Stepper.tsx +17 -0
  89. package/dist/Navigation/Tabs.tsx +29 -0
  90. package/dist/Navigation/index.ts +17 -0
  91. package/dist/Overlays/Drawer.tsx +123 -0
  92. package/dist/Overlays/Menu.tsx +192 -0
  93. package/dist/Overlays/Modal.tsx +159 -0
  94. package/dist/Overlays/Popover.tsx +319 -0
  95. package/dist/Overlays/Tooltip.tsx +131 -0
  96. package/dist/Overlays/index.ts +19 -0
  97. package/dist/Shell/AppShellLayout.tsx +56 -0
  98. package/dist/Shell/HeaderBar.tsx +26 -0
  99. package/dist/Shell/SidebarNav.tsx +47 -0
  100. package/dist/Shell/SidebarNavLink.tsx +50 -0
  101. package/dist/Shell/SingleColumnLayout.tsx +22 -0
  102. package/dist/Shell/TertiaryColumnLayout.tsx +32 -0
  103. package/dist/Shell/index.ts +17 -0
  104. package/dist/Typography/Code.tsx +27 -0
  105. package/dist/Typography/Kbd.tsx +87 -0
  106. package/dist/Typography/Text.tsx +27 -0
  107. package/dist/Typography/Title.tsx +34 -0
  108. package/dist/Typography/index.ts +21 -0
  109. package/dist/bin/ds-audit.js +521 -0
  110. package/dist/config.ts +226 -0
  111. package/dist/contracts/Alert.json +80 -0
  112. package/dist/contracts/Badge.json +78 -0
  113. package/dist/contracts/Box.json +52 -0
  114. package/dist/contracts/Button.json +111 -0
  115. package/dist/contracts/DataTable.json +68 -0
  116. package/dist/contracts/Grid.json +35 -0
  117. package/dist/contracts/Group.json +44 -0
  118. package/dist/contracts/Inline.json +73 -0
  119. package/dist/contracts/PageContentHeader.json +107 -0
  120. package/dist/contracts/Stack.json +62 -0
  121. package/dist/contracts/ds-component-contract.v1.json +23 -0
  122. package/dist/contracts/index.json +55 -0
  123. package/dist/css/foundations.css +703 -0
  124. package/dist/css/mantine.css +1797 -0
  125. package/dist/hooks/useTableHandlers.ts +179 -0
  126. package/dist/hooks/useTableRenderFunctions.tsx +283 -0
  127. package/dist/hooks/useTableState.ts +81 -0
  128. package/dist/index.ts +210 -0
  129. package/dist/types.ts +202 -0
  130. package/package.json +56 -4
@@ -0,0 +1,115 @@
1
+ const translations = {
2
+ // Result count translations
3
+ "table.filters.result.count.many": "{count} results",
4
+ "table.filters.result.count.one": "1 result",
5
+ "table.filters.result.count.loading": "Loading results...",
6
+
7
+ // Total count translations (no filters active)
8
+ "table.filters.result.count.total.many": "{count} records",
9
+ "table.filters.result.count.total.one": "1 record",
10
+
11
+ // Filtered count translations (filters active)
12
+ "table.filters.result.count.filtered.many": "{count} records",
13
+ "table.filters.result.count.filtered.one": "1 record",
14
+ "table.filters.result.count.filtered.none": "0 records",
15
+
16
+ // Filter translations
17
+ "table.filters.toggle.aria": "Toggle filters panel",
18
+ "table.filters.clear.filters": "Clear filters",
19
+ "table.filters.chip.date.range.label": "{startDate} - {endDate}",
20
+ "table.filters.date.range.week": "This week",
21
+ "table.filters.date.range.month": "This month",
22
+ "table.filters.date.range.quarter": "This quarter",
23
+ "table.filters.date.range.custom": "Custom",
24
+ "table.filters.date.range.select": "Select a date",
25
+ "table.filters.applied.on": "Applied On",
26
+ "table.filters.city": "City",
27
+ "table.filters.city.atlanta": "Atlanta",
28
+ "table.filters.city.austin": "Austin",
29
+ "table.filters.city.boston": "Boston",
30
+ "table.filters.city.charlotte": "Charlotte",
31
+ "table.filters.city.chicago": "Chicago",
32
+ "table.filters.city.columbus": "Columbus",
33
+ "table.filters.city.denver": "Denver",
34
+ "table.filters.city.detroit": "Detroit",
35
+ "table.filters.city.indianapolis": "Indianapolis",
36
+ "table.filters.city.las.vegas": "Las Vegas",
37
+ "table.filters.city.los.angeles": "Los Angeles",
38
+ "table.filters.city.miami": "Miami",
39
+ "table.filters.city.nashville": "Nashville",
40
+ "table.filters.city.new.york": "New York",
41
+ "table.filters.city.orlando": "Orlando",
42
+ "table.filters.city.phoenix": "Phoenix",
43
+ "table.filters.city.portland": "Portland",
44
+ "table.filters.city.san.francisco": "San Francisco",
45
+ "table.filters.city.seattle": "Seattle",
46
+ "table.filters.city.tampa": "Tampa",
47
+ "table.filters.show.all": "Show all",
48
+ "table.filters.placeholder.all": "All",
49
+ "table.filters.placeholder.select.more": "Select more",
50
+ "table.search.placeholder": "Search...",
51
+
52
+ // FilterSystem translations
53
+ "table.filters.system.validation.max.exceeded": "Maximum {maxFilters} filters allowed, but {filterCount} provided",
54
+ "table.filters.system.validation.duplicate.ids": "Duplicate filter IDs found: {duplicateIds}",
55
+ "table.filters.system.validation.missing.id": "Filter missing required \"id\" field",
56
+ "table.filters.system.validation.missing.label": "Filter \"{filterId}\" missing label",
57
+ "table.filters.system.validation.title": "Filter Configuration Error",
58
+ "table.filters.system.overflow.warning": "Only first {maxFilters} filters shown. {hiddenCount} filters hidden.",
59
+ "table.filters.system.clear.aria": "Clear {filterLabel}",
60
+
61
+ // Generic filter placeholders
62
+ "table.filters.placeholder.select.option": "Select an option",
63
+ "table.filters.placeholder.select.options": "Select options",
64
+ "table.filters.placeholder.date.range": "Select date range",
65
+
66
+ // Example filter labels (for demonstration)
67
+ "table.filters.label.status": "Status",
68
+ "table.filters.label.department": "Department",
69
+ "table.filters.label.skills": "Skills",
70
+ "table.filters.label.date.applied": "Date Applied",
71
+ "table.filters.label.last.login": "Last Login",
72
+
73
+ // Example filter options
74
+ "table.filters.status.active": "Active",
75
+ "table.filters.status.inactive": "Inactive",
76
+ "table.filters.status.pending": "Pending",
77
+ "table.filters.status.suspended": "Suspended",
78
+
79
+ "table.filters.department.engineering": "Engineering",
80
+ "table.filters.department.sales": "Sales",
81
+ "table.filters.department.marketing": "Marketing",
82
+ "table.filters.department.hr": "Human Resources",
83
+
84
+ "table.filters.skills.javascript": "JavaScript",
85
+ "table.filters.skills.typescript": "TypeScript",
86
+ "table.filters.skills.react": "React",
87
+ "table.filters.skills.node": "Node.js",
88
+ "table.filters.skills.python": "Python",
89
+
90
+ // Sort translations
91
+ "table.sort.aria": "Sort {column} {direction}",
92
+ "table.sort.asc": "ascending",
93
+ "table.sort.desc": "descending",
94
+ "table.sort.none": "none",
95
+
96
+ // Pagination translations
97
+ "table.pagination.showing": "Showing {start}-{end} of {total}",
98
+ "table.pagination.page": "Page {current} of {total}",
99
+ "table.rows.per.page": "Rows per page",
100
+ "table.row.count": "Showing {start}-{end} of {total}",
101
+
102
+ // Error translations
103
+ "table.error.title": "Unable to load table",
104
+ "table.error.default": "Something went wrong while loading data.",
105
+ "table.error.retry": "Try again",
106
+
107
+ // Selection translations
108
+ "table.selected.rows": "{count} rows selected",
109
+ "table.selected.row": "1 row selected",
110
+ "table.clear.selection": "Clear selection",
111
+ } as const;
112
+
113
+ export type TranslationKey = keyof typeof translations;
114
+ export type TranslationValue = typeof translations[TranslationKey];
115
+ export { translations };
@@ -0,0 +1,23 @@
1
+ import { translations, TranslationKey } from './en';
2
+
3
+ export const translate = (key: TranslationKey, params?: Record<string, string | number>): string => {
4
+ const translation = translations[key];
5
+
6
+ if (!translation) {
7
+ console.warn('translate - No translation found for key:', key);
8
+ return key;
9
+ }
10
+
11
+ if (!params) {
12
+ return translation as string;
13
+ }
14
+
15
+ let result: string = translation;
16
+ for (const [paramKey, value] of Object.entries(params)) {
17
+ result = result.replace(`{${paramKey}}`, String(value));
18
+ }
19
+ return result;
20
+ };
21
+
22
+ export { translations };
23
+ export type { TranslationKey };
@@ -0,0 +1,221 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+ import { Box } from '../../Layout/Box';
5
+ import { Text } from '../../Typography/Text';
6
+ import { Title } from '../../Typography/Title';
7
+
8
+ export type KeyInsightSize = 'xs' | 'sm' | 'md' | 'lg' | 'jumbo' | 'super-jumbo';
9
+
10
+ export interface KeyInsightProps {
11
+ /** Value to display (can be number or string) */
12
+ value: string | number;
13
+ /** Title/label for the insight */
14
+ title: string;
15
+ /** Optional subtitle or description */
16
+ subtitle?: string;
17
+ /** Whether to show border on the right */
18
+ showBorder?: boolean;
19
+ /** Size of the KeyInsight component */
20
+ size?: KeyInsightSize;
21
+ }
22
+
23
+ // Size mappings for different elements
24
+ const sizeConfig = {
25
+ xs: {
26
+ valueOrder: 4 as const, // h4
27
+ titleSize: 'xs' as const,
28
+ subtitleSize: 'xs' as const,
29
+ padding: 'xs' as const,
30
+ customValueStyle: undefined,
31
+ customTitleStyle: undefined,
32
+ customSubtitleStyle: undefined,
33
+ },
34
+ sm: {
35
+ valueOrder: 3 as const, // h3
36
+ titleSize: 'sm' as const,
37
+ subtitleSize: 'sm' as const,
38
+ padding: 'xs' as const,
39
+ customValueStyle: undefined,
40
+ customTitleStyle: undefined,
41
+ customSubtitleStyle: undefined,
42
+ },
43
+ md: {
44
+ valueOrder: 2 as const, // h2
45
+ titleSize: 'md' as const,
46
+ subtitleSize: 'md' as const,
47
+ padding: 'sm' as const,
48
+ customValueStyle: undefined,
49
+ customTitleStyle: undefined,
50
+ customSubtitleStyle: undefined,
51
+ },
52
+ lg: {
53
+ valueOrder: 1 as const, // h1
54
+ titleSize: 'lg' as const,
55
+ subtitleSize: 'lg' as const,
56
+ padding: 'sm' as const,
57
+ customValueStyle: undefined,
58
+ customTitleStyle: undefined,
59
+ customSubtitleStyle: undefined,
60
+ },
61
+ jumbo: {
62
+ valueOrder: 1 as const, // h1 as base, but will be overridden
63
+ titleSize: 'xl' as const,
64
+ subtitleSize: 'xl' as const,
65
+ padding: 'md' as const,
66
+ customValueStyle: {
67
+ fontSize: '96px',
68
+ lineHeight: '130%',
69
+ },
70
+ customTitleStyle: undefined,
71
+ customSubtitleStyle: undefined,
72
+ },
73
+ 'super-jumbo': {
74
+ valueOrder: 1 as const, // h1 as base, but will be overridden
75
+ titleSize: 'xl' as const, // Will be overridden
76
+ subtitleSize: 'xl' as const, // Will be overridden
77
+ padding: 'lg' as const,
78
+ customValueStyle: {
79
+ fontSize: '128px',
80
+ lineHeight: '130%',
81
+ },
82
+ customTitleStyle: {
83
+ fontSize: '32px',
84
+ lineHeight: '116%',
85
+ },
86
+ customSubtitleStyle: {
87
+ fontSize: '32px',
88
+ lineHeight: '116%',
89
+ },
90
+ },
91
+ } as const;
92
+
93
+ /**
94
+ * KeyInsight Component
95
+ *
96
+ * A reusable component for displaying key metrics or insights with a title, value, and optional subtitle.
97
+ * Commonly used in dashboards, analytics pages, or summary sections.
98
+ *
99
+ * @example
100
+ * // Basic usage
101
+ * <KeyInsight
102
+ * value={1250}
103
+ * title="Total Users"
104
+ * />
105
+ *
106
+ * @example
107
+ * // With subtitle and custom size
108
+ * <KeyInsight
109
+ * value="95%"
110
+ * title="Success Rate"
111
+ * subtitle="Last 30 days"
112
+ * size="lg"
113
+ * />
114
+ *
115
+ * @example
116
+ * // Different sizes showcase
117
+ * <Stack gap="md">
118
+ * <KeyInsight value={1250} title="Extra Small" size="xs" />
119
+ * <KeyInsight value={1250} title="Small" size="sm" />
120
+ * <KeyInsight value={1250} title="Medium" size="md" />
121
+ * <KeyInsight value={1250} title="Large" size="lg" />
122
+ * <KeyInsight value={1250} title="Jumbo" size="jumbo" />
123
+ * <KeyInsight value={1250} title="Super Jumbo" size="super-jumbo" />
124
+ * </Stack>
125
+ *
126
+ * @example
127
+ * // Hero metrics with jumbo size
128
+ * <KeyInsight
129
+ * value="$2.4M"
130
+ * title="Annual Revenue"
131
+ * subtitle="2024 Performance"
132
+ * size="jumbo"
133
+ * />
134
+ *
135
+ * @example
136
+ * // In a simple grid layout with borders
137
+ * <SimpleGrid cols={3} spacing="sm">
138
+ * <KeyInsight
139
+ * value={1250}
140
+ * title="Total Users"
141
+ * size="lg"
142
+ * showBorder={true}
143
+ * />
144
+ * <KeyInsight
145
+ * value={987}
146
+ * title="Active Users"
147
+ * size="lg"
148
+ * showBorder={true}
149
+ * />
150
+ * <KeyInsight
151
+ * value={263}
152
+ * title="New Users"
153
+ * subtitle="This month"
154
+ * size="lg"
155
+ * showBorder={false}
156
+ * />
157
+ * </SimpleGrid>
158
+ *
159
+ * @example
160
+ * // Dynamic usage with data
161
+ * const insights = [
162
+ * { value: userData.length, title: "Total Users" },
163
+ * { value: activeUsers.length, title: "Active Users" },
164
+ * { value: newUsers.length, title: "New Users" },
165
+ * ];
166
+ *
167
+ * <Inline>
168
+ * {insights.map((insight, index) => (
169
+ * <KeyInsight
170
+ * key={index}
171
+ * value={insight.value}
172
+ * title={insight.title}
173
+ * size="md"
174
+ * showBorder={index < insights.length - 1}
175
+ * />
176
+ * ))}
177
+ * </Inline>
178
+ */
179
+ export function KeyInsight({
180
+ value,
181
+ title,
182
+ subtitle,
183
+ showBorder = false,
184
+ size = 'md',
185
+ }: KeyInsightProps) {
186
+ const config = sizeConfig[size];
187
+
188
+ return (
189
+ <Box
190
+ ta="center"
191
+ p={config.padding}
192
+ style={{
193
+ borderRight: showBorder ? '1px solid var(--ad-color-border-subtle)' : undefined
194
+ }}
195
+ >
196
+ <Title
197
+ order={config.valueOrder}
198
+ c="dark"
199
+ style={config.customValueStyle}
200
+ >
201
+ {value}
202
+ </Title>
203
+ <Text
204
+ size={config.titleSize}
205
+ mt={0}
206
+ style={config.customTitleStyle}
207
+ >
208
+ {title}
209
+ </Text>
210
+ {subtitle && (
211
+ <Text
212
+ size={config.subtitleSize}
213
+ c="dimmed"
214
+ style={config.customSubtitleStyle}
215
+ >
216
+ {subtitle}
217
+ </Text>
218
+ )}
219
+ </Box>
220
+ );
221
+ }
@@ -0,0 +1,2 @@
1
+ export { KeyInsight } from './KeyInsights';
2
+ export type { KeyInsightProps } from './KeyInsights';
@@ -0,0 +1,175 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+ import { SimpleGrid } from '../../Layout/SimpleGrid';
5
+ import { Stack } from '../../Layout/Stack';
6
+ import { NameValueItem, NameValueItemProps } from './NameValueItem';
7
+
8
+ export interface NameValuePair {
9
+ /** Name/label for the pair */
10
+ name: string;
11
+ /** Value for the pair */
12
+ value: string;
13
+ /** Optional color for the value text */
14
+ valueColor?: string;
15
+ /** Optional weight for the value text */
16
+ valueWeight?: number | 'normal' | 'bold';
17
+ /** Whether to show copy icon for this value */
18
+ showCopy?: boolean;
19
+ /** Callback when copy icon is clicked */
20
+ onCopy?: (value: string) => void;
21
+ }
22
+
23
+ export interface NameValueProps {
24
+ /** Single name-value pair (when used individually) */
25
+ name?: string;
26
+ /** Single value (when used individually) */
27
+ value?: string;
28
+ /** Array of name-value pairs (when used in groups) */
29
+ pairs?: NameValuePair[];
30
+ /** Number of columns for grid layout (when provided, uses grid instead of stack) */
31
+ columns?: number;
32
+ /** Size of the label text */
33
+ labelSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
34
+ /** Size of the value text */
35
+ valueSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
36
+ /** Spacing between pairs */
37
+ spacing?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
38
+ /** Color for name/label text */
39
+ nameColor?: string;
40
+ /** Color for value text (applies to all if pairs don't specify individual colors) */
41
+ valueColor?: string;
42
+ /** Weight for value text */
43
+ valueWeight?: number | 'normal' | 'bold';
44
+ /** Whether to show copy icon for all values (can be overridden per pair) */
45
+ showCopy?: boolean;
46
+ /** Callback when copy icon is clicked (for single name/value usage) */
47
+ onCopy?: (value: string) => void;
48
+ /** Size of the copy icons */
49
+ copyIconSize?: number;
50
+ }
51
+
52
+ /**
53
+ * NameValue Component
54
+ *
55
+ * A component for displaying name-value pairs in vertical layout.
56
+ * Can be arranged in a grid format for multiple pairs using the columns prop.
57
+ * Perfect for metadata display, specifications, statistics, or any key-value information.
58
+ *
59
+ * @example
60
+ * // Single name-value pair with copy functionality
61
+ * <NameValue
62
+ * name="API Key"
63
+ * value="sk-1234567890abcdef"
64
+ * valueColor="green"
65
+ * showCopy={true}
66
+ * onCopy={(value) => navigator.clipboard.writeText(value)}
67
+ * />
68
+ *
69
+ * @example
70
+ * // Multiple pairs with selective copy functionality
71
+ * const userInfo = [
72
+ * { name: "Name", value: "John Doe" },
73
+ * { name: "Email", value: "john@example.com", showCopy: true, onCopy: (v) => navigator.clipboard.writeText(v) },
74
+ * { name: "User ID", value: "usr_123456", showCopy: true, onCopy: (v) => navigator.clipboard.writeText(v) },
75
+ * { name: "Last Login", value: "2 hours ago" }
76
+ * ];
77
+ *
78
+ * <NameValue
79
+ * pairs={userInfo}
80
+ * spacing="md"
81
+ * />
82
+ *
83
+ * @example
84
+ * // SimpleGrid layout with copy functionality
85
+ * const serverInfo = [
86
+ * { name: "Server ID", value: "srv-abc123", showCopy: true, onCopy: (v) => navigator.clipboard.writeText(v) },
87
+ * { name: "IP Address", value: "192.168.1.100", showCopy: true, onCopy: (v) => navigator.clipboard.writeText(v) },
88
+ * { name: "Port", value: "8080", showCopy: true, onCopy: (v) => navigator.clipboard.writeText(v) },
89
+ * { name: "Status", value: "Running" },
90
+ * { name: "Uptime", value: "15 days" },
91
+ * { name: "Load", value: "0.68" }
92
+ * ];
93
+ *
94
+ * <NameValue
95
+ * pairs={serverInfo}
96
+ * columns={3}
97
+ * spacing="sm"
98
+ * />
99
+ *
100
+ * @example
101
+ * // All values copyable by default
102
+ * const credentials = [
103
+ * { name: "Username", value: "admin" },
104
+ * { name: "Password", value: "secret123" },
105
+ * { name: "Token", value: "eyJhbGciOiJIUzI1NiIs..." },
106
+ * { name: "Database URL", value: "postgresql://localhost:5432/db" }
107
+ * ];
108
+ *
109
+ * <NameValue
110
+ * pairs={credentials}
111
+ * showCopy={true}
112
+ * onCopy={(value) => {
113
+ * navigator.clipboard.writeText(value);
114
+ * console.log('Copied:', value);
115
+ * }}
116
+ * columns={2}
117
+ * />
118
+ */
119
+ export function NameValue({
120
+ name,
121
+ value,
122
+ pairs,
123
+ columns,
124
+ labelSize = 'xs',
125
+ valueSize = 'sm',
126
+ spacing = 'sm',
127
+ nameColor = 'dimmed',
128
+ valueColor,
129
+ valueWeight = 500,
130
+ showCopy = false,
131
+ onCopy,
132
+ copyIconSize = 24,
133
+ }: NameValueProps) {
134
+
135
+ // Create pairs array from individual props if provided
136
+ const allPairs = pairs || (name && value ? [{ name, value, showCopy, onCopy }] : []);
137
+
138
+ if (allPairs.length === 0) {
139
+ return null;
140
+ }
141
+
142
+ // Render a single name-value pair using NameValueItem
143
+ const renderPair = (pair: NameValuePair, index: number) => {
144
+ const itemProps: NameValueItemProps = {
145
+ name: pair.name,
146
+ value: pair.value,
147
+ labelSize,
148
+ valueSize,
149
+ nameColor,
150
+ valueColor: pair.valueColor || valueColor,
151
+ valueWeight: pair.valueWeight || valueWeight,
152
+ showCopy: pair.showCopy ?? showCopy,
153
+ onCopy: pair.onCopy || onCopy,
154
+ copyIconSize,
155
+ };
156
+
157
+ return <NameValueItem key={index} {...itemProps} />;
158
+ };
159
+
160
+ // Use equal-width grid layout if columns prop is provided
161
+ if (columns) {
162
+ return (
163
+ <SimpleGrid cols={columns} spacing={0}>
164
+ {allPairs.map((pair, index) => renderPair(pair, index))}
165
+ </SimpleGrid>
166
+ );
167
+ }
168
+
169
+ // Default: render all pairs in a vertical stack
170
+ return (
171
+ <Stack gap={spacing}>
172
+ {allPairs.map((pair, index) => renderPair(pair, index))}
173
+ </Stack>
174
+ );
175
+ }
@@ -0,0 +1,100 @@
1
+ import React from 'react';
2
+ import { Inline } from '../../Layout/Inline';
3
+ import { Stack } from '../../Layout/Stack';
4
+ import { Text } from '../../Typography/Text';
5
+ import { CopyButton } from '../Utilities/CopyButton';
6
+
7
+ export interface NameValueItemProps {
8
+ /** Name/label for the pair */
9
+ name: string;
10
+ /** Value for the pair */
11
+ value: string;
12
+ /** Size of the label text */
13
+ labelSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
14
+ /** Size of the value text */
15
+ valueSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
16
+ /** Color for name/label text */
17
+ nameColor?: string;
18
+ /** Optional color for the value text */
19
+ valueColor?: string;
20
+ /** Optional weight for the value text */
21
+ valueWeight?: number | 'normal' | 'bold';
22
+ /** Whether to show copy icon for this value */
23
+ showCopy?: boolean;
24
+ /** Callback when copy icon is clicked */
25
+ onCopy?: (value: string) => void;
26
+ /** Size of the copy icon */
27
+ copyIconSize?: number;
28
+ }
29
+
30
+ /**
31
+ * NameValueItem Component
32
+ *
33
+ * A component for displaying a single name-value pair with optional copy functionality.
34
+ * Designed to be used within the NameValue component or as a standalone item.
35
+ *
36
+ * @example
37
+ * // Basic name-value pair
38
+ * <NameValueItem
39
+ * name="Status"
40
+ * value="Active"
41
+ * />
42
+ *
43
+ * @example
44
+ * // With copy functionality
45
+ * <NameValueItem
46
+ * name="API Key"
47
+ * value="sk-1234567890abcdef"
48
+ * valueColor="green"
49
+ * showCopy={true}
50
+ * onCopy={(value) => navigator.clipboard.writeText(value)}
51
+ * />
52
+ *
53
+ * @example
54
+ * // Custom styling
55
+ * <NameValueItem
56
+ * name="Revenue"
57
+ * value="$125,430"
58
+ * labelSize="sm"
59
+ * valueSize="lg"
60
+ * valueColor="green"
61
+ * valueWeight="bold"
62
+ * />
63
+ */
64
+ export function NameValueItem({
65
+ name,
66
+ value,
67
+ labelSize = 'xs',
68
+ valueSize = 'sm',
69
+ nameColor = 'dimmed',
70
+ valueColor,
71
+ valueWeight = 500,
72
+ showCopy = false,
73
+ onCopy,
74
+ copyIconSize = 24,
75
+ }: NameValueItemProps) {
76
+ return (
77
+ <Stack gap={0} p="xs">
78
+ <Text size={labelSize} c={nameColor}>
79
+ {name}
80
+ </Text>
81
+ <Inline gap="xs" align="center">
82
+ <Text
83
+ size={valueSize}
84
+ fw={valueWeight}
85
+ c={valueColor}
86
+ >
87
+ {value}
88
+ </Text>
89
+ {showCopy && onCopy && (
90
+ <CopyButton
91
+ value={value}
92
+ label={name}
93
+ onCopy={onCopy}
94
+ iconSize={copyIconSize}
95
+ />
96
+ )}
97
+ </Inline>
98
+ </Stack>
99
+ );
100
+ }
@@ -0,0 +1,4 @@
1
+ export { NameValue } from './NameValue';
2
+ export type { NameValueProps, NameValuePair } from './NameValue';
3
+ export { NameValueItem } from './NameValueItem';
4
+ export type { NameValueItemProps } from './NameValueItem';