@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,216 @@
1
+ 'use client';
2
+
3
+ import React, { forwardRef, useState, useCallback } from 'react';
4
+ import { Avatar as MantineAvatar, AvatarProps as MantineAvatarProps } from '@mantine/core';
5
+ import { RiUser3Fill } from '@remixicon/react';
6
+
7
+ // ========================== TYPES ==========================
8
+
9
+ export type AvatarVariant = 'icon' | 'image' | 'initials';
10
+ export type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
11
+
12
+ export interface DSAvatarProps extends Omit<MantineAvatarProps, 'size' | 'src' | 'children'> {
13
+ /** Avatar variant type */
14
+ variant: AvatarVariant;
15
+ /** Avatar size following Mantine t-shirt sizing */
16
+ size?: AvatarSize;
17
+ /** Image source URL (required for 'image' variant) */
18
+ src?: string;
19
+ /** Alt text for image (recommended for 'image' variant) */
20
+ alt?: string;
21
+ /** Two character initials (required for 'initials' variant) */
22
+ initials?: string;
23
+ /** Custom icon component (optional for 'icon' variant) */
24
+ icon?: React.ReactNode;
25
+ /** Fallback variant when image fails to load */
26
+ fallback?: 'icon' | 'initials';
27
+ /** Fallback initials when image fails and fallback is 'initials' */
28
+ fallbackInitials?: string;
29
+ }
30
+
31
+ // ========================== CONSTANTS ==========================
32
+
33
+ // Mantine's default avatar sizes
34
+ const AVATAR_SIZES = {
35
+ xs: 16,
36
+ sm: 26,
37
+ md: 38,
38
+ lg: 56,
39
+ xl: 84,
40
+ } as const;
41
+
42
+ // Icon sizes proportional to avatar sizes (roughly 70% of avatar size)
43
+ const ICON_SIZES = {
44
+ xs: 11,
45
+ sm: 18,
46
+ md: 27,
47
+ lg: 39,
48
+ xl: 59,
49
+ } as const;
50
+
51
+ // ========================== COMPONENT ==========================
52
+
53
+ /**
54
+ * Avatar Component
55
+ *
56
+ * Built on top of Mantine's Avatar component with design system styling.
57
+ * Supports three variants: icon, image, and initials with all Mantine t-shirt sizes.
58
+ *
59
+ * @example
60
+ * // Icon avatar (default)
61
+ * <Avatar variant="icon" size="md" />
62
+ *
63
+ * @example
64
+ * // Image avatar
65
+ * <Avatar
66
+ * variant="image"
67
+ * src="/user-photo.jpg"
68
+ * alt="John Doe"
69
+ * size="lg"
70
+ * fallback="initials"
71
+ * fallbackInitials="JD"
72
+ * />
73
+ *
74
+ * @example
75
+ * // Initials avatar
76
+ * <Avatar
77
+ * variant="initials"
78
+ * initials="AB"
79
+ * size="xl"
80
+ * />
81
+ *
82
+ * @example
83
+ * // Custom icon
84
+ * <Avatar
85
+ * variant="icon"
86
+ * icon={<RiUserLine />}
87
+ * size="sm"
88
+ * />
89
+ */
90
+ export const Avatar = forwardRef<HTMLDivElement, DSAvatarProps>(
91
+ ({
92
+ variant,
93
+ size = 'md',
94
+ src,
95
+ alt,
96
+ initials,
97
+ icon,
98
+ fallback = 'icon',
99
+ fallbackInitials,
100
+ ...props
101
+ }, ref) => {
102
+
103
+ // Track image loading state
104
+ const [imageError, setImageError] = useState(false);
105
+
106
+ // Check if URL is obviously invalid
107
+ const isInvalidUrl = (url: string) => {
108
+ if (!url || url.trim() === '') return true;
109
+ try {
110
+ const hostname = new URL(url, 'https://local.invalid').hostname;
111
+ if (hostname === 'example.com' || hostname.endsWith('.example.com')) return true;
112
+ } catch {
113
+ return true;
114
+ }
115
+ if (url.includes('broken-image')) return true;
116
+ return false;
117
+ };
118
+
119
+ // Reset image error when src changes
120
+ React.useEffect(() => {
121
+ if (src && isInvalidUrl(src)) {
122
+ setImageError(true);
123
+ } else {
124
+ setImageError(false);
125
+ }
126
+ }, [src]);
127
+
128
+ // Handle image load error
129
+ const handleImageError = useCallback(() => {
130
+ setImageError(true);
131
+ }, []);
132
+
133
+ if (process.env.NODE_ENV === 'development') {
134
+ // eslint-disable-next-line react-hooks/rules-of-hooks
135
+ React.useEffect(() => {
136
+ if (variant === 'image' && !src) {
137
+ console.warn('Avatar: src is required when variant is "image"');
138
+ }
139
+ if (variant === 'initials' && !initials) {
140
+ console.warn('Avatar: initials is required when variant is "initials"');
141
+ }
142
+ if (variant === 'initials' && initials && initials.length !== 2) {
143
+ console.warn('Avatar: initials should be exactly 2 characters');
144
+ }
145
+ }, [variant, src, initials]);
146
+ }
147
+
148
+ // Render icon content
149
+ const renderIcon = () => {
150
+ const iconSize = ICON_SIZES[size];
151
+
152
+ if (icon) {
153
+ return React.isValidElement(icon)
154
+ ? React.cloneElement(icon as React.ReactElement, {
155
+ size: iconSize,
156
+ color: 'var(--ad-color-text-default)',
157
+ })
158
+ : icon;
159
+ }
160
+
161
+ return <RiUser3Fill size={iconSize} color="var(--ad-color-text-default)" />;
162
+ };
163
+
164
+ // Render initials content
165
+ const renderInitials = (text: string) => {
166
+ return text.substring(0, 2).toUpperCase();
167
+ };
168
+
169
+ // Handle different variants
170
+ const getAvatarContent = () => {
171
+ switch (variant) {
172
+ case 'image':
173
+ // For image variant, always check if we should show fallback first
174
+ if (!src || imageError) {
175
+ // Show fallback content instead of trying to load image
176
+ return {
177
+ children: fallback === 'initials' && fallbackInitials
178
+ ? renderInitials(fallbackInitials)
179
+ : renderIcon(),
180
+ };
181
+ }
182
+ // Only try to load image if we have src and no error yet
183
+ return {
184
+ src: src,
185
+ alt: alt,
186
+ onError: handleImageError,
187
+ };
188
+
189
+ case 'initials':
190
+ return {
191
+ children: initials ? renderInitials(initials) : '??',
192
+ };
193
+
194
+ case 'icon':
195
+ default:
196
+ return {
197
+ children: renderIcon(),
198
+ };
199
+ }
200
+ };
201
+
202
+ const avatarContent = getAvatarContent();
203
+
204
+ return (
205
+ <MantineAvatar
206
+ ref={ref}
207
+ size={AVATAR_SIZES[size]}
208
+ radius={1000} // Perfect circle - large enough radius to ensure circular shape at all sizes
209
+ {...avatarContent}
210
+ {...props}
211
+ />
212
+ );
213
+ }
214
+ );
215
+
216
+ Avatar.displayName = 'Avatar';
@@ -0,0 +1,119 @@
1
+ 'use client';
2
+
3
+ import React, { forwardRef } from 'react';
4
+ import { Badge as MantineBadge, BadgeProps as MantineBadgeProps } from '@mantine/core';
5
+ import { ComponentSize } from '../config';
6
+ import { type DSBadgeColor, type DSBadgeVariant } from '../types';
7
+
8
+ /**
9
+ * Enhanced Badge props extending Mantine's BadgeProps
10
+ */
11
+ export interface DSBadgeProps extends Omit<MantineBadgeProps, 'size' | 'color' | 'variant'> {
12
+ /** Badge size from design system scale */
13
+ size?: ComponentSize;
14
+ /** Badge style variant */
15
+ variant?: DSBadgeVariant;
16
+ /** Badge semantic color variant */
17
+ color?: DSBadgeColor;
18
+ }
19
+
20
+ /**
21
+ * AppDirect Design System Badge Component
22
+ *
23
+ * A semantic badge component built on top of Mantine's Badge with
24
+ * consistent design system styling and restricted color options.
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * // Basic usage
29
+ * <Badge>Default</Badge>
30
+ *
31
+ * // Different variants
32
+ * <Badge variant="filled" color="info">Info</Badge>
33
+ * <Badge variant="outline" color="success">Success</Badge>
34
+ * <Badge variant="filled" color="danger">Danger</Badge>
35
+ * <Badge variant="outline" color="pending">Pending</Badge>
36
+ * ```
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * // Different sizes
41
+ * <Badge size="sm" color="info">Small</Badge>
42
+ * <Badge size="md" color="success">Medium</Badge>
43
+ * <Badge size="lg" color="danger">Large</Badge>
44
+ * ```
45
+ *
46
+ * @example
47
+ * ```tsx
48
+ * // All color variants
49
+ * <Badge color="default">Default</Badge>
50
+ * <Badge color="info">Info</Badge>
51
+ * <Badge color="success">Success</Badge>
52
+ * <Badge color="danger">Danger</Badge>
53
+ * <Badge color="pending">Pending</Badge>
54
+ * ```
55
+ */
56
+ export const Badge = forwardRef<HTMLDivElement, DSBadgeProps>(
57
+ (
58
+ {
59
+ variant = 'filled',
60
+ size = 'md',
61
+ color = 'default',
62
+ children,
63
+ ...props
64
+ },
65
+ ref
66
+ ) => {
67
+ // Map design system colors to Mantine colors
68
+ const getMantineColor = (dsColor: DSBadgeProps['color'], dsVariant: DSBadgeProps['variant']) => {
69
+ const resolvedColor = dsColor === 'default' && ['info', 'success', 'danger', 'pending', 'warning'].includes(dsVariant || '')
70
+ ? (dsVariant === 'warning' ? 'pending' : dsVariant)
71
+ : dsColor;
72
+
73
+ switch (resolvedColor) {
74
+ case 'info':
75
+ case 'blue':
76
+ return 'blue';
77
+ case 'success':
78
+ case 'green':
79
+ return 'green';
80
+ case 'danger':
81
+ case 'red':
82
+ return 'red';
83
+ case 'pending':
84
+ case 'warning':
85
+ case 'yellow':
86
+ return 'yellow';
87
+ case 'default':
88
+ case 'gray':
89
+ return 'gray';
90
+ default:
91
+ return 'gray';
92
+ }
93
+ };
94
+
95
+ const getMantineVariant = (dsVariant: DSBadgeProps['variant']) => {
96
+ switch (dsVariant) {
97
+ case 'outline':
98
+ return 'outline';
99
+ default:
100
+ return 'filled';
101
+ }
102
+ };
103
+
104
+ return (
105
+ <MantineBadge
106
+ ref={ref}
107
+ variant={getMantineVariant(variant)}
108
+ size={size}
109
+ color={getMantineColor(color, variant)}
110
+ radius="sm"
111
+ {...props}
112
+ >
113
+ {children}
114
+ </MantineBadge>
115
+ );
116
+ }
117
+ );
118
+
119
+ Badge.displayName = 'Badge';
@@ -0,0 +1,26 @@
1
+ .interactive {
2
+ transition:
3
+ transform 200ms cubic-bezier(0.4, 0, 0.2, 1),
4
+ box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1),
5
+ border-color 200ms cubic-bezier(0.4, 0, 0.2, 1);
6
+ }
7
+
8
+ .interactive:hover {
9
+ transform: translateY(-2px);
10
+ box-shadow: var(--mantine-shadow-md);
11
+ border-color: var(--ad-color-border-default);
12
+ }
13
+
14
+ .interactive:active {
15
+ transform: translateY(-1px);
16
+ box-shadow: var(--mantine-shadow-sm);
17
+ }
18
+
19
+ .interactive:focus-visible {
20
+ outline: 2px solid var(--ad-color-brand-primary);
21
+ outline-offset: 2px;
22
+ }
23
+
24
+ .clickable {
25
+ cursor: pointer;
26
+ }
@@ -0,0 +1,163 @@
1
+ 'use client';
2
+
3
+ import React, { forwardRef } from 'react';
4
+ import { Card as MantineCard, CardProps as MantineCardProps, BoxProps } from '@mantine/core';
5
+ import classes from './Card.module.css';
6
+
7
+ // ========================== TYPES ==========================
8
+
9
+ export interface DSCardProps extends Omit<MantineCardProps, 'size' | 'variant' | 'padding' | 'shadow' | 'withBorder' | 'radius'> {
10
+ /** Whether the card should be interactive (adds hover effects) */
11
+ interactive?: boolean;
12
+ /** Card content */
13
+ children: React.ReactNode;
14
+ /** Click handler (makes card clickable when provided) */
15
+ onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
16
+ }
17
+
18
+ // Card.Section props - extend Mantine's CardSection props fully with spacing support
19
+ export interface DSCardSectionProps extends
20
+ React.ComponentPropsWithoutRef<typeof MantineCard.Section>,
21
+ Pick<BoxProps, 'py' | 'px' | 'pt' | 'pb' | 'pl' | 'pr' | 'mt' | 'mb' | 'ml' | 'mr' | 'm' | 'p'> {
22
+ children: React.ReactNode;
23
+ /** Adds top and bottom border to the section */
24
+ withBorder?: boolean;
25
+ /** Adds same left and right padding as the Card component */
26
+ inheritPadding?: boolean;
27
+ }
28
+
29
+ // ========================== COMPONENTS ==========================
30
+
31
+ /**
32
+ * Card.Section Component
33
+ *
34
+ * Use to create full-bleed sections within a card that extend to the edges.
35
+ * Perfect for images, headers, or other content that should span the full width.
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * <Card>
40
+ * <Card.Section>
41
+ * <img src="image.jpg" alt="Full width image" />
42
+ * </Card.Section>
43
+ * <Title>Card Content</Title>
44
+ * <Text>Regular padded content</Text>
45
+ * </Card>
46
+ * ```
47
+ */
48
+ const CardSection = forwardRef<HTMLDivElement, DSCardSectionProps>(
49
+ ({ children, ...props }, ref) => {
50
+ return (
51
+ <MantineCard.Section ref={ref} {...props}>
52
+ {children}
53
+ </MantineCard.Section>
54
+ );
55
+ }
56
+ );
57
+
58
+ CardSection.displayName = 'Card.Section';
59
+
60
+ /**
61
+ * Card Component
62
+ *
63
+ * Built on top of Mantine's Card component with design system styling.
64
+ * Provides a consistent container for content with fixed styling options:
65
+ * - Shadow: xs (subtle shadow)
66
+ * - Padding: md (16px)
67
+ * - Border: always enabled
68
+ * - Radius: sm (4px)
69
+ *
70
+ * @example
71
+ * // Basic card
72
+ * <Card>
73
+ * <h3>Card Title</h3>
74
+ * <p>Card content goes here.</p>
75
+ * </Card>
76
+ *
77
+ * @example
78
+ * // Interactive card
79
+ * <Card
80
+ * interactive
81
+ * onClick={() => console.log('Card clicked')}
82
+ * >
83
+ * <h3>Clickable Card</h3>
84
+ * <p>This card responds to clicks and hover.</p>
85
+ * </Card>
86
+ *
87
+ * @example
88
+ * // Card with full bleed image
89
+ * <Card>
90
+ * <Card.Section>
91
+ * <img src="image.jpg" alt="Full width" />
92
+ * </Card.Section>
93
+ * <h3>Card Title</h3>
94
+ * <p>Content with padding</p>
95
+ * </Card>
96
+ *
97
+ * @example
98
+ * // Card with custom styling
99
+ * <Card
100
+ * style={{ backgroundColor: 'var(--ad-color-brand-light)' }}
101
+ * >
102
+ * <h3>Custom Styled Card</h3>
103
+ * <p>With custom background color.</p>
104
+ * </Card>
105
+ */
106
+ const CardRoot = forwardRef<HTMLDivElement, DSCardProps>(
107
+ ({
108
+ interactive = false,
109
+ children,
110
+ onClick,
111
+ style,
112
+ className,
113
+ ...props
114
+ }, ref) => {
115
+
116
+ // Runtime validation
117
+ React.useEffect(() => {
118
+ if (interactive && !onClick) {
119
+ console.warn('Card: interactive is true but no onClick handler provided');
120
+ }
121
+ }, [interactive, onClick]);
122
+
123
+ // Determine if card should be clickable
124
+ const isClickable = Boolean(onClick);
125
+
126
+ // Build class names - add interactive/clickable classes when needed
127
+ const cardClassName = [
128
+ className,
129
+ interactive && classes.interactive,
130
+ isClickable && classes.clickable,
131
+ ].filter(Boolean).join(' ');
132
+
133
+ return (
134
+ <MantineCard
135
+ ref={ref}
136
+ padding="md"
137
+ radius="sm"
138
+ shadow="xs"
139
+ withBorder={true}
140
+ style={style}
141
+ className={cardClassName}
142
+ onClick={onClick}
143
+ {...props}
144
+ >
145
+ {children}
146
+ </MantineCard>
147
+ );
148
+ }
149
+ );
150
+
151
+ CardRoot.displayName = 'Card';
152
+
153
+ // ========================== COMPOUND COMPONENT ==========================
154
+
155
+ /**
156
+ * Compound Card component with Section support
157
+ */
158
+ export const Card = Object.assign(CardRoot, {
159
+ Section: CardSection,
160
+ });
161
+
162
+ // Export the Section component separately for named imports
163
+ export { CardSection };
@@ -0,0 +1,66 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+ import { Chip as MantineChip, ChipProps as MantineChipProps } from '@mantine/core';
5
+
6
+ // Define allowed chip variants
7
+ export type ChipVariant = 'info' | 'success' | 'danger' | 'pending' | 'default';
8
+
9
+ // Define the DS Chip props interface
10
+ export interface DSChipProps extends Omit<MantineChipProps, 'variant' | 'color' | 'radius'> {
11
+ /** Semantic variant that determines color */
12
+ variant?: ChipVariant;
13
+ /** Whether the chip is selected */
14
+ checked?: boolean;
15
+ /** Called when chip selection changes */
16
+ onChange?: (checked: boolean) => void;
17
+ }
18
+
19
+ // Map semantic variants to Mantine colors
20
+ const variantToColor: Record<ChipVariant, string> = {
21
+ info: 'blue',
22
+ success: 'green',
23
+ danger: 'red',
24
+ pending: 'yellow',
25
+ default: 'gray',
26
+ };
27
+
28
+ /**
29
+ * Chip component with semantic color variants and selection states.
30
+ * Built on top of Mantine's Chip component with consistent styling.
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * // Basic chip
35
+ * <Chip>Default</Chip>
36
+ *
37
+ * // Colored variants
38
+ * <Chip variant="info">Info</Chip>
39
+ * <Chip variant="success">Success</Chip>
40
+ * <Chip variant="danger">Danger</Chip>
41
+ *
42
+ * // Controlled selection
43
+ * <Chip checked={selected} onChange={setSelected}>
44
+ * Toggle me
45
+ * </Chip>
46
+ * ```
47
+ */
48
+ export const Chip: React.FC<DSChipProps> = ({
49
+ variant = 'default',
50
+ checked,
51
+ onChange,
52
+ ...props
53
+ }) => {
54
+ return (
55
+ <MantineChip
56
+ color={variantToColor[variant]}
57
+ variant="outline"
58
+ radius="sm"
59
+ checked={checked}
60
+ onChange={onChange}
61
+ {...props}
62
+ />
63
+ );
64
+ };
65
+
66
+ export default Chip;