@appdirect/design-system 0.0.4 → 0.0.6

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.
@@ -14,10 +14,10 @@ export interface NameValuePair {
14
14
  valueColor?: string;
15
15
  /** Optional weight for the value text */
16
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;
17
+ /** Render this pair's value as a Badge instead of plain text */
18
+ valueAsBadge?: boolean;
19
+ /** Icon-triggered action for this pair (overrides the group-level `action`) */
20
+ action?: NameValueItemProps['action'];
21
21
  }
22
22
 
23
23
  export interface NameValueProps {
@@ -41,12 +41,10 @@ export interface NameValueProps {
41
41
  valueColor?: string;
42
42
  /** Weight for value text */
43
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;
44
+ /** Render all values as badges (can be overridden per pair) */
45
+ valueAsBadge?: boolean;
46
+ /** Icon-triggered action for all values (for single name/value usage, or as a default for all pairs) */
47
+ action?: NameValueItemProps['action'];
50
48
  }
51
49
 
52
50
  /**
@@ -57,62 +55,55 @@ export interface NameValueProps {
57
55
  * Perfect for metadata display, specifications, statistics, or any key-value information.
58
56
  *
59
57
  * @example
60
- * // Single name-value pair with copy functionality
61
- * <NameValue
62
- * name="API Key"
63
- * value="sk-1234567890abcdef"
58
+ * // Single name-value pair with the default copy action
59
+ * <NameValue
60
+ * name="API Key"
61
+ * value="sk-1234567890abcdef"
64
62
  * valueColor="green"
65
- * showCopy={true}
66
- * onCopy={(value) => navigator.clipboard.writeText(value)}
63
+ * action={{ onClick: (value) => navigator.clipboard.writeText(value) }}
67
64
  * />
68
- *
65
+ *
69
66
  * @example
70
- * // Multiple pairs with selective copy functionality
67
+ * // Multiple pairs with selective copy actions
71
68
  * const userInfo = [
72
69
  * { 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) },
70
+ * { name: "Email", value: "john@example.com", action: { onClick: (v) => navigator.clipboard.writeText(v) } },
71
+ * { name: "User ID", value: "usr_123456", action: { onClick: (v) => navigator.clipboard.writeText(v) } },
75
72
  * { name: "Last Login", value: "2 hours ago" }
76
73
  * ];
77
- *
78
- * <NameValue
74
+ *
75
+ * <NameValue
79
76
  * pairs={userInfo}
80
77
  * spacing="md"
81
78
  * />
82
- *
79
+ *
83
80
  * @example
84
- * // SimpleGrid layout with copy functionality
81
+ * // Status values as badges
85
82
  * 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" },
83
+ * { name: "Status", value: "Running", valueAsBadge: true },
84
+ * { name: "IP Address", value: "192.168.1.100", action: { onClick: (v) => navigator.clipboard.writeText(v) } },
85
+ * { name: "Port", value: "8080" },
90
86
  * { name: "Uptime", value: "15 days" },
91
- * { name: "Load", value: "0.68" }
92
87
  * ];
93
- *
94
- * <NameValue
88
+ *
89
+ * <NameValue
95
90
  * pairs={serverInfo}
96
91
  * columns={3}
97
92
  * spacing="sm"
98
93
  * />
99
- *
94
+ *
100
95
  * @example
101
- * // All values copyable by default
96
+ * // All values copyable by default, with a custom action icon for one
102
97
  * const credentials = [
103
98
  * { name: "Username", value: "admin" },
104
99
  * { name: "Password", value: "secret123" },
105
100
  * { name: "Token", value: "eyJhbGciOiJIUzI1NiIs..." },
106
- * { name: "Database URL", value: "postgresql://localhost:5432/db" }
101
+ * { name: "Database URL", value: "postgresql://localhost:5432/db", action: { icon: <RiEditLine size={16} />, onClick: openEditDialog, label: "Edit" } },
107
102
  * ];
108
- *
109
- * <NameValue
103
+ *
104
+ * <NameValue
110
105
  * pairs={credentials}
111
- * showCopy={true}
112
- * onCopy={(value) => {
113
- * navigator.clipboard.writeText(value);
114
- * console.log('Copied:', value);
115
- * }}
106
+ * action={{ onClick: (value) => navigator.clipboard.writeText(value) }}
116
107
  * columns={2}
117
108
  * />
118
109
  */
@@ -127,14 +118,13 @@ export function NameValue({
127
118
  nameColor = 'dimmed',
128
119
  valueColor,
129
120
  valueWeight = 500,
130
- showCopy = false,
131
- onCopy,
132
- copyIconSize = 24,
121
+ valueAsBadge = false,
122
+ action,
133
123
  }: NameValueProps) {
134
-
124
+
135
125
  // Create pairs array from individual props if provided
136
- const allPairs = pairs || (name && value ? [{ name, value, showCopy, onCopy }] : []);
137
-
126
+ const allPairs = pairs || (name && value ? [{ name, value, valueAsBadge, action }] : []);
127
+
138
128
  if (allPairs.length === 0) {
139
129
  return null;
140
130
  }
@@ -149,9 +139,8 @@ export function NameValue({
149
139
  nameColor,
150
140
  valueColor: pair.valueColor || valueColor,
151
141
  valueWeight: pair.valueWeight || valueWeight,
152
- showCopy: pair.showCopy ?? showCopy,
153
- onCopy: pair.onCopy || onCopy,
154
- copyIconSize,
142
+ valueAsBadge: pair.valueAsBadge ?? valueAsBadge,
143
+ action: pair.action ?? action,
155
144
  };
156
145
 
157
146
  return <NameValueItem key={index} {...itemProps} />;
@@ -2,7 +2,10 @@ import React from 'react';
2
2
  import { Inline } from '../../Layout/Inline';
3
3
  import { Stack } from '../../Layout/Stack';
4
4
  import { Text } from '../../Typography/Text';
5
- import { CopyButton } from '../Utilities/CopyButton';
5
+ import { Badge } from '../../DataDisplay/Badge';
6
+ import { ActionIcon } from '../../Buttons/ActionIcon';
7
+ import { Tooltip } from '../../Overlays/Tooltip';
8
+ import { RiFileCopyLine } from '@remixicon/react';
6
9
 
7
10
  export interface NameValueItemProps {
8
11
  /** Name/label for the pair */
@@ -19,37 +22,63 @@ export interface NameValueItemProps {
19
22
  valueColor?: string;
20
23
  /** Optional weight for the value text */
21
24
  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;
25
+ /** Render the value as a Badge instead of plain text */
26
+ valueAsBadge?: boolean;
27
+ /**
28
+ * Icon-triggered action next to the value — the designer can assign any
29
+ * icon here (copy-to-clipboard, edit, etc.); this component just renders
30
+ * whichever icon is given and wires up the click. Omit entirely to show
31
+ * no action. Defaults to a copy icon when `icon` isn't provided, since
32
+ * copy-to-clipboard is the most common case.
33
+ */
34
+ action?: {
35
+ /** Called with the item's value when the action icon is clicked */
36
+ onClick: (value: string) => void;
37
+ /** Custom icon to render (defaults to a copy icon) */
38
+ icon?: React.ReactNode;
39
+ /** Size of the icon itself */
40
+ iconSize?: number;
41
+ /** Accessible label / tooltip text */
42
+ label?: string;
43
+ };
28
44
  }
29
45
 
30
46
  /**
31
47
  * 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
- *
48
+ *
49
+ * A component for displaying a single name-value pair with an optional
50
+ * icon-triggered action (copy-to-clipboard by default, or any icon the
51
+ * designer assigns). Designed to be used within the NameValue component or
52
+ * as a standalone item.
53
+ *
36
54
  * @example
37
55
  * // Basic name-value pair
38
56
  * <NameValueItem
39
57
  * name="Status"
40
58
  * value="Active"
41
59
  * />
42
- *
60
+ *
43
61
  * @example
44
- * // With copy functionality
62
+ * // With the default copy action
45
63
  * <NameValueItem
46
64
  * name="API Key"
47
65
  * value="sk-1234567890abcdef"
48
66
  * valueColor="green"
49
- * showCopy={true}
50
- * onCopy={(value) => navigator.clipboard.writeText(value)}
67
+ * action={{ onClick: (value) => navigator.clipboard.writeText(value) }}
51
68
  * />
52
- *
69
+ *
70
+ * @example
71
+ * // With a custom action icon
72
+ * <NameValueItem
73
+ * name="Server Name"
74
+ * value="prod-web-01"
75
+ * action={{ icon: <RiEditLine size={16} />, onClick: openEditDialog, label: 'Edit' }}
76
+ * />
77
+ *
78
+ * @example
79
+ * // Value as a badge
80
+ * <NameValueItem name="Status" value="Active" valueAsBadge />
81
+ *
53
82
  * @example
54
83
  * // Custom styling
55
84
  * <NameValueItem
@@ -69,9 +98,8 @@ export function NameValueItem({
69
98
  nameColor = 'dimmed',
70
99
  valueColor,
71
100
  valueWeight = 500,
72
- showCopy = false,
73
- onCopy,
74
- copyIconSize = 24,
101
+ valueAsBadge = false,
102
+ action,
75
103
  }: NameValueItemProps) {
76
104
  return (
77
105
  <Stack gap={0} p="xs">
@@ -79,22 +107,33 @@ export function NameValueItem({
79
107
  {name}
80
108
  </Text>
81
109
  <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
- />
110
+ {valueAsBadge ? (
111
+ <Badge size={valueSize} variant="outline" color="default">
112
+ {value}
113
+ </Badge>
114
+ ) : (
115
+ <Text
116
+ size={valueSize}
117
+ fw={valueWeight}
118
+ c={valueColor}
119
+ >
120
+ {value}
121
+ </Text>
122
+ )}
123
+ {action && (
124
+ <Tooltip label={action.label ?? 'Copy'} position="top" withArrow>
125
+ <ActionIcon
126
+ variant="link"
127
+ color="gray"
128
+ size="xs"
129
+ onClick={() => action.onClick(value)}
130
+ aria-label={action.label ?? `Action for ${name}`}
131
+ >
132
+ {action.icon ?? <RiFileCopyLine size={action.iconSize ?? 16} />}
133
+ </ActionIcon>
134
+ </Tooltip>
96
135
  )}
97
136
  </Inline>
98
137
  </Stack>
99
138
  );
100
- }
139
+ }
@@ -0,0 +1,113 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+ import { ThemeIcon } from '../../DataDisplay/ThemeIcon';
5
+ import { Title } from '../../Typography/Title';
6
+ import { Text } from '../../Typography/Text';
7
+ import { Button } from '../../Buttons/Button';
8
+ import { Stack } from '../../Layout/Stack';
9
+ import { Inline } from '../../Layout/Inline';
10
+
11
+ export type PlaceholderSize = 'sm' | 'md' | 'lg';
12
+
13
+ export interface PlaceholderAction {
14
+ /** Button label */
15
+ label: string;
16
+ /** Click handler */
17
+ onClick: () => void;
18
+ }
19
+
20
+ export interface PlaceholderProps {
21
+ /** Icon shown above the title — the designer can assign any icon; this component just renders whichever one is given */
22
+ icon?: React.ReactNode;
23
+ /** Title text */
24
+ title: string;
25
+ /** Optional description text below the title */
26
+ description?: string;
27
+ /** Up to two link-style action buttons */
28
+ actions?: PlaceholderAction[];
29
+ /** Size of the placeholder — controls title/description typography and action button size */
30
+ size?: PlaceholderSize;
31
+ }
32
+
33
+ const titleOrderBySize: Record<PlaceholderSize, 3 | 4 | 5> = {
34
+ sm: 5, // h5, 16px
35
+ md: 4, // h4, 18px
36
+ lg: 3, // h3, 22px
37
+ };
38
+
39
+ const descriptionSizeBySize: Record<PlaceholderSize, 'sm' | 'md' | 'lg'> = {
40
+ sm: 'sm',
41
+ md: 'md',
42
+ lg: 'lg',
43
+ };
44
+
45
+ const actionSizeBySize: Record<PlaceholderSize, 'xs' | 'sm' | 'md'> = {
46
+ sm: 'xs',
47
+ md: 'sm',
48
+ lg: 'md',
49
+ };
50
+
51
+ /**
52
+ * Placeholder Component
53
+ *
54
+ * An empty-state message: icon, title, optional description, and up to two
55
+ * link-style actions. All typography reuses the existing heading/body scale
56
+ * directly (headings h3/h4/h5, Text sm/md/lg) — no new tokens needed. The
57
+ * icon is a fixed ThemeIcon size (lg, 34px) regardless of the placeholder's
58
+ * own size, matching the live Figma design.
59
+ *
60
+ * @example
61
+ * <Placeholder
62
+ * icon={<RiErrorWarningLine size={24} />}
63
+ * title="This is the Title"
64
+ * description="This is the optional description of the placeholder"
65
+ * actions={[
66
+ * { label: 'Button One', onClick: () => {} },
67
+ * { label: 'Button Two', onClick: () => {} },
68
+ * ]}
69
+ * />
70
+ *
71
+ * @example
72
+ * // Large size, no description or actions
73
+ * <Placeholder icon={<RiInboxLine size={24} />} title="No results found" size="lg" />
74
+ */
75
+ export function Placeholder({
76
+ icon,
77
+ title,
78
+ description,
79
+ actions = [],
80
+ size = 'sm',
81
+ }: PlaceholderProps) {
82
+ return (
83
+ <Stack align="center" gap="md" p="xl">
84
+ {icon && (
85
+ <ThemeIcon variant="default" size="lg">
86
+ {icon}
87
+ </ThemeIcon>
88
+ )}
89
+ <Stack align="center" gap={0} ta="center">
90
+ <Title order={titleOrderBySize[size]}>{title}</Title>
91
+ {description && (
92
+ <Text size={descriptionSizeBySize[size]} c="dimmed">
93
+ {description}
94
+ </Text>
95
+ )}
96
+ </Stack>
97
+ {actions.length > 0 && (
98
+ <Inline gap="xs" justify="center">
99
+ {actions.map((action, index) => (
100
+ <Button
101
+ key={index}
102
+ variant="link"
103
+ size={actionSizeBySize[size]}
104
+ onClick={action.onClick}
105
+ >
106
+ {action.label}
107
+ </Button>
108
+ ))}
109
+ </Inline>
110
+ )}
111
+ </Stack>
112
+ );
113
+ }
@@ -0,0 +1,2 @@
1
+ export { Placeholder } from './Placeholder';
2
+ export type { PlaceholderProps, PlaceholderAction, PlaceholderSize } from './Placeholder';
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.4",
2
+ "version": "0.0.6",
3
3
  "contracts": [
4
4
  {
5
5
  "id": "Alert",
package/dist/index.ts CHANGED
@@ -31,6 +31,7 @@ import { CopyButton } from './ComplexComponents/Utilities';
31
31
  import { PageContentHeader, DescriptionBlock } from './ComplexComponents/PageContentHeader';
32
32
  import { DataTable } from './ComplexComponents/DataTable';
33
33
  import { DashboardWidget } from './ComplexComponents/DashboardWidget';
34
+ import { Placeholder } from './ComplexComponents/Placeholder';
34
35
 
35
36
  // ========================== INPUTS ==========================
36
37
  export { TextInput, TextArea, NumberInput, ColorInput, Slider, SliderWithLabel, Switch, SegmentedControl, Checkbox, Radio, RadioGroup, DropZone, FileInput } from './Inputs';
@@ -97,6 +98,8 @@ export { DataTable } from './ComplexComponents/DataTable';
97
98
  export type { DataTableProps, DataTableColumn, PageInfo } from './ComplexComponents/DataTable';
98
99
  export { DashboardWidget } from './ComplexComponents/DashboardWidget';
99
100
  export type { DashboardWidgetProps, DashboardWidgetLink } from './ComplexComponents/DashboardWidget';
101
+ export { Placeholder } from './ComplexComponents/Placeholder';
102
+ export type { PlaceholderProps, PlaceholderAction, PlaceholderSize } from './ComplexComponents/Placeholder';
100
103
 
101
104
  // ========================== CATEGORY EXPORTS ==========================
102
105
  // Export components grouped by category for convenient importing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appdirect/design-system",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "AppDirect Design System components. Wraps Mantine v9 with standardized props, variants, and tokens.",
5
5
  "main": "./dist/index.ts",
6
6
  "types": "./dist/index.ts",
@@ -37,7 +37,7 @@
37
37
  "prepublishOnly": "npm run build"
38
38
  },
39
39
  "dependencies": {
40
- "@appdirect/ad-design-tokens": "0.0.4",
40
+ "@appdirect/ad-design-tokens": "0.0.6",
41
41
  "@mantine/dropzone": "^9.6.0",
42
42
  "@remixicon/react": "^4.6.0",
43
43
  "@tabler/icons-react": "^3.33.0",