@appdirect/design-system 0.0.8 → 0.0.10

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.
@@ -0,0 +1,177 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+ import { Paper } from '../../Misc/Paper';
5
+ import { type DSPaperProps } from '../../Misc/Paper';
6
+ import { ThemeIcon, type ThemeIconSize } from '../../DataDisplay/ThemeIcon';
7
+ import { Indicator } from '../../DataDisplay/Indicator';
8
+ import { Badge } from '../../DataDisplay/Badge';
9
+ import { Alert } from '../../DataDisplay/Alert';
10
+ import { Button } from '../../Buttons/Button';
11
+ import { type DSButtonVariant } from '../../types';
12
+ import { Stack, Inline, Box } from '../../Layout';
13
+ import { Title } from '../../Typography/Title';
14
+ import { Text } from '../../Typography/Text';
15
+
16
+ // ========================== TYPES ==========================
17
+
18
+ export type SlatSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
19
+
20
+ export interface SlatIndicator {
21
+ /** Semantic status color */
22
+ variant?: 'success' | 'danger' | 'pending' | 'info' | 'default';
23
+ /** Optional label rendered inside the indicator (omit for a plain dot) */
24
+ label?: string;
25
+ /** Whether the indicator has a contrasting border */
26
+ withBorder?: boolean;
27
+ }
28
+
29
+ export interface SlatBadge {
30
+ /** Badge text */
31
+ label: string;
32
+ /** Badge style variant */
33
+ variant?: 'filled' | 'outline';
34
+ /** Badge semantic color */
35
+ color?: 'info' | 'success' | 'danger' | 'pending' | 'default';
36
+ }
37
+
38
+ export interface SlatAction {
39
+ /** Button label */
40
+ label: string;
41
+ /** Click handler */
42
+ onClick: () => void;
43
+ /** Button style variant */
44
+ variant?: DSButtonVariant;
45
+ }
46
+
47
+ export interface SlatProps {
48
+ /** Overall size of the slat - scales title, subtitle, and icon together */
49
+ size?: SlatSize;
50
+ /** Icon rendered inside the leading ThemeIcon */
51
+ icon?: React.ReactNode;
52
+ /** Whether to show the leading ThemeIcon (has no effect unless `icon` is also provided) */
53
+ showIcon?: boolean;
54
+ /** Slat title */
55
+ title: string;
56
+ /** Optional subtitle below the title */
57
+ subtitle?: string;
58
+ /** Optional status indicator shown next to the subtitle */
59
+ indicator?: SlatIndicator;
60
+ /** Optional badge shown next to the subtitle */
61
+ badge?: SlatBadge;
62
+ /** Optional trailing action button */
63
+ action?: SlatAction;
64
+ /** Optional notification banner rendered below the main row */
65
+ notification?: React.ReactNode;
66
+ /** Optional custom content rendered below the main row (e.g. metadata, controls) */
67
+ rightSection?: React.ReactNode;
68
+ /** Paper shadow */
69
+ shadow?: DSPaperProps['shadow'];
70
+ /** Whether the slat has a border */
71
+ withBorder?: boolean;
72
+ }
73
+
74
+ // Title order (h6-h2) per Slat size, matching Figma's Components/Slat/h6-h2 styles
75
+ const TITLE_ORDER_BY_SIZE: Record<SlatSize, 1 | 2 | 3 | 4 | 5 | 6> = {
76
+ xs: 6,
77
+ sm: 5,
78
+ md: 4,
79
+ lg: 3,
80
+ xl: 2,
81
+ };
82
+
83
+ // Matches Indicator's own default `size` (12px). The standalone subhead
84
+ // indicator has no real child to overlay, so this box reserves the same
85
+ // footprint the dot/pill occupies, keeping it in flow instead of collapsing
86
+ // to zero size and overlapping neighboring subtitle/badge content.
87
+ const INDICATOR_DOT_SIZE = 12;
88
+
89
+ // ========================== COMPONENT ==========================
90
+
91
+ /**
92
+ * Slat Component
93
+ *
94
+ * A compact row for listing items (e.g. in a feed or list), with a leading
95
+ * icon, title/subtitle, optional status indicator or badge, a trailing
96
+ * action, and an optional notification banner below.
97
+ *
98
+ * @example
99
+ * <Slat
100
+ * title="This is the title"
101
+ * subtitle="and this is the subhead"
102
+ * icon={<RiStarLine size={16} />}
103
+ * />
104
+ *
105
+ * @example
106
+ * // With status indicator, badge, and action
107
+ * <Slat
108
+ * title="Invoice #1024"
109
+ * subtitle="Due in 3 days"
110
+ * indicator={{ variant: 'pending' }}
111
+ * badge={{ label: 'Draft', color: 'default' }}
112
+ * action={{ label: 'Review', onClick: () => {} }}
113
+ * />
114
+ */
115
+ export function Slat({
116
+ size = 'xs',
117
+ icon,
118
+ showIcon = true,
119
+ title,
120
+ subtitle,
121
+ indicator,
122
+ badge,
123
+ action,
124
+ notification,
125
+ rightSection,
126
+ shadow,
127
+ withBorder = false,
128
+ }: SlatProps) {
129
+ return (
130
+ <Paper shadow={shadow} withBorder={withBorder}>
131
+ <Stack gap="xs">
132
+ <Inline gap="sm" align="center" p="sm">
133
+ <Inline gap="xs" align="center" style={{ flex: 1, minWidth: 0 }}>
134
+ {showIcon && icon && (
135
+ <ThemeIcon size={size as ThemeIconSize}>
136
+ {icon}
137
+ </ThemeIcon>
138
+ )}
139
+ <Stack gap={0} style={{ flex: 1, minWidth: 0 }}>
140
+ <Title order={TITLE_ORDER_BY_SIZE[size]}>{title}</Title>
141
+ {(subtitle || indicator || badge) && (
142
+ <Inline gap={5} align="center">
143
+ {subtitle && <Text size={size}>{subtitle}</Text>}
144
+ {indicator && (
145
+ <Indicator
146
+ type={indicator.variant ?? 'default'}
147
+ label={indicator.label}
148
+ withBorder={indicator.withBorder}
149
+ size={INDICATOR_DOT_SIZE}
150
+ position="middle-center"
151
+ offset={0}
152
+ inline
153
+ >
154
+ <div style={{ width: INDICATOR_DOT_SIZE, height: INDICATOR_DOT_SIZE }} />
155
+ </Indicator>
156
+ )}
157
+ {badge && (
158
+ <Badge variant={badge.variant ?? 'outline'} color={badge.color ?? 'default'}>
159
+ {badge.label}
160
+ </Badge>
161
+ )}
162
+ </Inline>
163
+ )}
164
+ </Stack>
165
+ </Inline>
166
+ {action && (
167
+ <Button variant={action.variant ?? 'default'} size={size} onClick={action.onClick}>
168
+ {action.label}
169
+ </Button>
170
+ )}
171
+ </Inline>
172
+ {notification && <Alert color="info">{notification}</Alert>}
173
+ {rightSection && <Box>{rightSection}</Box>}
174
+ </Stack>
175
+ </Paper>
176
+ );
177
+ }
@@ -0,0 +1,2 @@
1
+ export { Slat } from './Slat';
2
+ export type { SlatProps, SlatSize, SlatIndicator, SlatBadge, SlatAction } from './Slat';
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.8",
2
+ "version": "0.0.10",
3
3
  "contracts": [
4
4
  {
5
5
  "id": "Alert",
package/dist/index.ts CHANGED
@@ -32,6 +32,7 @@ import { PageContentHeader, DescriptionBlock } from './ComplexComponents/PageCon
32
32
  import { DataTable } from './ComplexComponents/DataTable';
33
33
  import { DashboardWidget } from './ComplexComponents/DashboardWidget';
34
34
  import { Placeholder } from './ComplexComponents/Placeholder';
35
+ import { Slat } from './ComplexComponents/Slat';
35
36
 
36
37
  // ========================== INPUTS ==========================
37
38
  export { TextInput, TextArea, NumberInput, ColorInput, Slider, SliderWithLabel, Switch, SegmentedControl, Checkbox, Radio, RadioGroup, DropZone, FileInput } from './Inputs';
@@ -100,6 +101,8 @@ export { DashboardWidget } from './ComplexComponents/DashboardWidget';
100
101
  export type { DashboardWidgetProps, DashboardWidgetLink } from './ComplexComponents/DashboardWidget';
101
102
  export { Placeholder } from './ComplexComponents/Placeholder';
102
103
  export type { PlaceholderProps, PlaceholderAction, PlaceholderSize } from './ComplexComponents/Placeholder';
104
+ export { Slat } from './ComplexComponents/Slat';
105
+ export type { SlatProps, SlatSize, SlatIndicator, SlatBadge, SlatAction } from './ComplexComponents/Slat';
103
106
 
104
107
  // ========================== CATEGORY EXPORTS ==========================
105
108
  // Export components grouped by category for convenient importing
@@ -208,6 +211,8 @@ export const ComplexComponents = {
208
211
  DescriptionBlock,
209
212
  DataTable,
210
213
  DashboardWidget,
214
+ Placeholder,
215
+ Slat,
211
216
  };
212
217
 
213
218
  // Placeholder export to prevent empty module errors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appdirect/design-system",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
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.8",
40
+ "@appdirect/ad-design-tokens": "0.0.10",
41
41
  "@mantine/dropzone": "^9.6.0",
42
42
  "@remixicon/react": "^4.6.0",
43
43
  "@tabler/icons-react": "^3.33.0",