@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,77 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Alert as MantineAlert } from '@mantine/core';
|
|
5
|
+
import { RiInformationLine, RiCheckboxCircleLine, RiErrorWarningLine, RiTimeLine } from '@remixicon/react';
|
|
6
|
+
import { ALERT_TO_MANTINE_COLOR } from '../types.js';
|
|
7
|
+
/**
|
|
8
|
+
* AppDirect Design System Alert Component
|
|
9
|
+
*
|
|
10
|
+
* A semantic alert component built on top of Mantine's Alert with
|
|
11
|
+
* consistent design system styling and semantic color options.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* // Basic usage
|
|
16
|
+
* <Alert color="info" title="Information">
|
|
17
|
+
* This is an informational alert message.
|
|
18
|
+
* </Alert>
|
|
19
|
+
*
|
|
20
|
+
* // Different semantic colors
|
|
21
|
+
* <Alert color="success" title="Success">Operation completed successfully!</Alert>
|
|
22
|
+
* <Alert color="danger" title="Error">Something went wrong.</Alert>
|
|
23
|
+
* <Alert color="pending" title="Processing">Your request is being processed...</Alert>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* // With close button
|
|
29
|
+
* <Alert
|
|
30
|
+
* color="info"
|
|
31
|
+
* title="Notification"
|
|
32
|
+
* withCloseButton
|
|
33
|
+
* onClose={() => console.log('Alert closed')}
|
|
34
|
+
* >
|
|
35
|
+
* This alert can be dismissed.
|
|
36
|
+
* </Alert>
|
|
37
|
+
*
|
|
38
|
+
* // With custom icon
|
|
39
|
+
* <Alert
|
|
40
|
+
* color="info"
|
|
41
|
+
* title="Custom Alert"
|
|
42
|
+
* icon={<RiStarLine size={20} />}
|
|
43
|
+
* >
|
|
44
|
+
* This alert uses a custom star icon instead of the default info icon.
|
|
45
|
+
* </Alert>
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* // Different semantic colors
|
|
51
|
+
* <Alert color="info" title="Information">Info message with light background</Alert>
|
|
52
|
+
* <Alert color="success" title="Success">Success message with light background</Alert>
|
|
53
|
+
* <Alert color="danger" title="Error">Error message with light background</Alert>
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export const Alert = forwardRef(({ color = 'default', type, icon: customIcon, title, withCloseButton = false, onClose, children, ...props }, ref) => {
|
|
57
|
+
// Keep `type` as a deprecated alias while `color` becomes the primary API.
|
|
58
|
+
const semanticColor = color ?? type ?? 'default';
|
|
59
|
+
// Map semantic colors to Mantine colors and default icons
|
|
60
|
+
const getAlertConfig = (alertColor) => {
|
|
61
|
+
const icons = {
|
|
62
|
+
info: _jsx(RiInformationLine, { size: 20 }),
|
|
63
|
+
success: _jsx(RiCheckboxCircleLine, { size: 20 }),
|
|
64
|
+
danger: _jsx(RiErrorWarningLine, { size: 20 }),
|
|
65
|
+
pending: _jsx(RiTimeLine, { size: 20 }),
|
|
66
|
+
default: _jsx(RiInformationLine, { size: 20 }),
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
color: ALERT_TO_MANTINE_COLOR[alertColor],
|
|
70
|
+
icon: icons[alertColor],
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
const { color: mantineColor, icon: defaultIcon } = getAlertConfig(semanticColor);
|
|
74
|
+
const alertIcon = customIcon || defaultIcon;
|
|
75
|
+
return (_jsx(MantineAlert, { ref: ref, variant: "light", color: mantineColor, radius: "sm", icon: alertIcon, title: title, withCloseButton: withCloseButton, onClose: onClose, ...props, children: children }));
|
|
76
|
+
});
|
|
77
|
+
Alert.displayName = 'Alert';
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef, useState, useCallback } from 'react';
|
|
4
|
+
import { Avatar as MantineAvatar } from '@mantine/core';
|
|
5
|
+
import { RiUser3Fill } from '@remixicon/react';
|
|
6
|
+
// ========================== CONSTANTS ==========================
|
|
7
|
+
// Mantine's default avatar sizes
|
|
8
|
+
const AVATAR_SIZES = {
|
|
9
|
+
xs: 16,
|
|
10
|
+
sm: 26,
|
|
11
|
+
md: 38,
|
|
12
|
+
lg: 56,
|
|
13
|
+
xl: 84,
|
|
14
|
+
};
|
|
15
|
+
// Icon sizes proportional to avatar sizes (roughly 70% of avatar size)
|
|
16
|
+
const ICON_SIZES = {
|
|
17
|
+
xs: 11,
|
|
18
|
+
sm: 18,
|
|
19
|
+
md: 27,
|
|
20
|
+
lg: 39,
|
|
21
|
+
xl: 59,
|
|
22
|
+
};
|
|
23
|
+
// ========================== COMPONENT ==========================
|
|
24
|
+
/**
|
|
25
|
+
* Avatar Component
|
|
26
|
+
*
|
|
27
|
+
* Built on top of Mantine's Avatar component with design system styling.
|
|
28
|
+
* Supports three variants: icon, image, and initials with all Mantine t-shirt sizes.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // Icon avatar (default)
|
|
32
|
+
* <Avatar variant="icon" size="md" />
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Image avatar
|
|
36
|
+
* <Avatar
|
|
37
|
+
* variant="image"
|
|
38
|
+
* src="/user-photo.jpg"
|
|
39
|
+
* alt="John Doe"
|
|
40
|
+
* size="lg"
|
|
41
|
+
* fallback="initials"
|
|
42
|
+
* fallbackInitials="JD"
|
|
43
|
+
* />
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // Initials avatar
|
|
47
|
+
* <Avatar
|
|
48
|
+
* variant="initials"
|
|
49
|
+
* initials="AB"
|
|
50
|
+
* size="xl"
|
|
51
|
+
* />
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* // Custom icon
|
|
55
|
+
* <Avatar
|
|
56
|
+
* variant="icon"
|
|
57
|
+
* icon={<RiUserLine />}
|
|
58
|
+
* size="sm"
|
|
59
|
+
* />
|
|
60
|
+
*/
|
|
61
|
+
export const Avatar = forwardRef(({ variant, size = 'md', src, alt, initials, icon, fallback = 'icon', fallbackInitials, ...props }, ref) => {
|
|
62
|
+
// Track image loading state
|
|
63
|
+
const [imageError, setImageError] = useState(false);
|
|
64
|
+
// Check if URL is obviously invalid
|
|
65
|
+
const isInvalidUrl = (url) => {
|
|
66
|
+
if (!url || url.trim() === '')
|
|
67
|
+
return true;
|
|
68
|
+
try {
|
|
69
|
+
const hostname = new URL(url, 'https://local.invalid').hostname;
|
|
70
|
+
if (hostname === 'example.com' || hostname.endsWith('.example.com'))
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
if (url.includes('broken-image'))
|
|
77
|
+
return true;
|
|
78
|
+
return false;
|
|
79
|
+
};
|
|
80
|
+
// Reset image error when src changes
|
|
81
|
+
React.useEffect(() => {
|
|
82
|
+
if (src && isInvalidUrl(src)) {
|
|
83
|
+
setImageError(true);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
setImageError(false);
|
|
87
|
+
}
|
|
88
|
+
}, [src]);
|
|
89
|
+
// Handle image load error
|
|
90
|
+
const handleImageError = useCallback(() => {
|
|
91
|
+
setImageError(true);
|
|
92
|
+
}, []);
|
|
93
|
+
if (process.env.NODE_ENV === 'development') {
|
|
94
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
95
|
+
React.useEffect(() => {
|
|
96
|
+
if (variant === 'image' && !src) {
|
|
97
|
+
console.warn('Avatar: src is required when variant is "image"');
|
|
98
|
+
}
|
|
99
|
+
if (variant === 'initials' && !initials) {
|
|
100
|
+
console.warn('Avatar: initials is required when variant is "initials"');
|
|
101
|
+
}
|
|
102
|
+
if (variant === 'initials' && initials && initials.length !== 2) {
|
|
103
|
+
console.warn('Avatar: initials should be exactly 2 characters');
|
|
104
|
+
}
|
|
105
|
+
}, [variant, src, initials]);
|
|
106
|
+
}
|
|
107
|
+
// Render icon content
|
|
108
|
+
const renderIcon = () => {
|
|
109
|
+
const iconSize = ICON_SIZES[size];
|
|
110
|
+
if (icon) {
|
|
111
|
+
return React.isValidElement(icon)
|
|
112
|
+
? React.cloneElement(icon, {
|
|
113
|
+
size: iconSize,
|
|
114
|
+
color: 'var(--ad-color-text-default)',
|
|
115
|
+
})
|
|
116
|
+
: icon;
|
|
117
|
+
}
|
|
118
|
+
return _jsx(RiUser3Fill, { size: iconSize, color: "var(--ad-color-text-default)" });
|
|
119
|
+
};
|
|
120
|
+
// Render initials content
|
|
121
|
+
const renderInitials = (text) => {
|
|
122
|
+
return text.substring(0, 2).toUpperCase();
|
|
123
|
+
};
|
|
124
|
+
// Handle different variants
|
|
125
|
+
const getAvatarContent = () => {
|
|
126
|
+
switch (variant) {
|
|
127
|
+
case 'image':
|
|
128
|
+
// For image variant, always check if we should show fallback first
|
|
129
|
+
if (!src || imageError) {
|
|
130
|
+
// Show fallback content instead of trying to load image
|
|
131
|
+
return {
|
|
132
|
+
children: fallback === 'initials' && fallbackInitials
|
|
133
|
+
? renderInitials(fallbackInitials)
|
|
134
|
+
: renderIcon(),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// Only try to load image if we have src and no error yet
|
|
138
|
+
return {
|
|
139
|
+
src: src,
|
|
140
|
+
alt: alt,
|
|
141
|
+
onError: handleImageError,
|
|
142
|
+
};
|
|
143
|
+
case 'initials':
|
|
144
|
+
return {
|
|
145
|
+
children: initials ? renderInitials(initials) : '??',
|
|
146
|
+
};
|
|
147
|
+
case 'icon':
|
|
148
|
+
default:
|
|
149
|
+
return {
|
|
150
|
+
children: renderIcon(),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const avatarContent = getAvatarContent();
|
|
155
|
+
return (_jsx(MantineAvatar, { ref: ref, size: AVATAR_SIZES[size], radius: 1000, ...avatarContent, ...props }));
|
|
156
|
+
});
|
|
157
|
+
Avatar.displayName = 'Avatar';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Badge as MantineBadge } from '@mantine/core';
|
|
5
|
+
/**
|
|
6
|
+
* AppDirect Design System Badge Component
|
|
7
|
+
*
|
|
8
|
+
* A semantic badge component built on top of Mantine's Badge with
|
|
9
|
+
* consistent design system styling and restricted color options.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // Basic usage
|
|
14
|
+
* <Badge>Default</Badge>
|
|
15
|
+
*
|
|
16
|
+
* // Different variants
|
|
17
|
+
* <Badge variant="filled" color="info">Info</Badge>
|
|
18
|
+
* <Badge variant="outline" color="success">Success</Badge>
|
|
19
|
+
* <Badge variant="filled" color="danger">Danger</Badge>
|
|
20
|
+
* <Badge variant="outline" color="pending">Pending</Badge>
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* // Different sizes
|
|
26
|
+
* <Badge size="sm" color="info">Small</Badge>
|
|
27
|
+
* <Badge size="md" color="success">Medium</Badge>
|
|
28
|
+
* <Badge size="lg" color="danger">Large</Badge>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* // All color variants
|
|
34
|
+
* <Badge color="default">Default</Badge>
|
|
35
|
+
* <Badge color="info">Info</Badge>
|
|
36
|
+
* <Badge color="success">Success</Badge>
|
|
37
|
+
* <Badge color="danger">Danger</Badge>
|
|
38
|
+
* <Badge color="pending">Pending</Badge>
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export const Badge = forwardRef(({ variant = 'filled', size = 'md', color = 'default', children, ...props }, ref) => {
|
|
42
|
+
// Map design system colors to Mantine colors
|
|
43
|
+
const getMantineColor = (dsColor, dsVariant) => {
|
|
44
|
+
const resolvedColor = dsColor === 'default' && ['info', 'success', 'danger', 'pending', 'warning'].includes(dsVariant || '')
|
|
45
|
+
? (dsVariant === 'warning' ? 'pending' : dsVariant)
|
|
46
|
+
: dsColor;
|
|
47
|
+
switch (resolvedColor) {
|
|
48
|
+
case 'info':
|
|
49
|
+
case 'blue':
|
|
50
|
+
return 'blue';
|
|
51
|
+
case 'success':
|
|
52
|
+
case 'green':
|
|
53
|
+
return 'green';
|
|
54
|
+
case 'danger':
|
|
55
|
+
case 'red':
|
|
56
|
+
return 'red';
|
|
57
|
+
case 'pending':
|
|
58
|
+
case 'warning':
|
|
59
|
+
case 'yellow':
|
|
60
|
+
return 'yellow';
|
|
61
|
+
case 'default':
|
|
62
|
+
case 'gray':
|
|
63
|
+
return 'gray';
|
|
64
|
+
default:
|
|
65
|
+
return 'gray';
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const getMantineVariant = (dsVariant) => {
|
|
69
|
+
switch (dsVariant) {
|
|
70
|
+
case 'outline':
|
|
71
|
+
return 'outline';
|
|
72
|
+
default:
|
|
73
|
+
return 'filled';
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return (_jsx(MantineBadge, { ref: ref, variant: getMantineVariant(variant), size: size, color: getMantineColor(color, variant), radius: "sm", ...props, children: children }));
|
|
77
|
+
});
|
|
78
|
+
Badge.displayName = 'Badge';
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Card as MantineCard } from '@mantine/core';
|
|
5
|
+
import classes from './Card.module.css';
|
|
6
|
+
// ========================== COMPONENTS ==========================
|
|
7
|
+
/**
|
|
8
|
+
* Card.Section Component
|
|
9
|
+
*
|
|
10
|
+
* Use to create full-bleed sections within a card that extend to the edges.
|
|
11
|
+
* Perfect for images, headers, or other content that should span the full width.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <Card>
|
|
16
|
+
* <Card.Section>
|
|
17
|
+
* <img src="image.jpg" alt="Full width image" />
|
|
18
|
+
* </Card.Section>
|
|
19
|
+
* <Title>Card Content</Title>
|
|
20
|
+
* <Text>Regular padded content</Text>
|
|
21
|
+
* </Card>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
const CardSection = forwardRef(({ children, ...props }, ref) => {
|
|
25
|
+
return (_jsx(MantineCard.Section, { ref: ref, ...props, children: children }));
|
|
26
|
+
});
|
|
27
|
+
CardSection.displayName = 'Card.Section';
|
|
28
|
+
/**
|
|
29
|
+
* Card Component
|
|
30
|
+
*
|
|
31
|
+
* Built on top of Mantine's Card component with design system styling.
|
|
32
|
+
* Provides a consistent container for content with fixed styling options:
|
|
33
|
+
* - Shadow: xs (subtle shadow)
|
|
34
|
+
* - Padding: md (16px)
|
|
35
|
+
* - Border: always enabled
|
|
36
|
+
* - Radius: sm (4px)
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* // Basic card
|
|
40
|
+
* <Card>
|
|
41
|
+
* <h3>Card Title</h3>
|
|
42
|
+
* <p>Card content goes here.</p>
|
|
43
|
+
* </Card>
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // Interactive card
|
|
47
|
+
* <Card
|
|
48
|
+
* interactive
|
|
49
|
+
* onClick={() => console.log('Card clicked')}
|
|
50
|
+
* >
|
|
51
|
+
* <h3>Clickable Card</h3>
|
|
52
|
+
* <p>This card responds to clicks and hover.</p>
|
|
53
|
+
* </Card>
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Card with full bleed image
|
|
57
|
+
* <Card>
|
|
58
|
+
* <Card.Section>
|
|
59
|
+
* <img src="image.jpg" alt="Full width" />
|
|
60
|
+
* </Card.Section>
|
|
61
|
+
* <h3>Card Title</h3>
|
|
62
|
+
* <p>Content with padding</p>
|
|
63
|
+
* </Card>
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* // Card with custom styling
|
|
67
|
+
* <Card
|
|
68
|
+
* style={{ backgroundColor: 'var(--ad-color-brand-light)' }}
|
|
69
|
+
* >
|
|
70
|
+
* <h3>Custom Styled Card</h3>
|
|
71
|
+
* <p>With custom background color.</p>
|
|
72
|
+
* </Card>
|
|
73
|
+
*/
|
|
74
|
+
const CardRoot = forwardRef(({ interactive = false, children, onClick, style, className, ...props }, ref) => {
|
|
75
|
+
// Runtime validation
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
if (interactive && !onClick) {
|
|
78
|
+
console.warn('Card: interactive is true but no onClick handler provided');
|
|
79
|
+
}
|
|
80
|
+
}, [interactive, onClick]);
|
|
81
|
+
// Determine if card should be clickable
|
|
82
|
+
const isClickable = Boolean(onClick);
|
|
83
|
+
// Build class names - add interactive/clickable classes when needed
|
|
84
|
+
const cardClassName = [
|
|
85
|
+
className,
|
|
86
|
+
interactive && classes.interactive,
|
|
87
|
+
isClickable && classes.clickable,
|
|
88
|
+
].filter(Boolean).join(' ');
|
|
89
|
+
return (_jsx(MantineCard, { ref: ref, padding: "md", radius: "sm", shadow: "xs", withBorder: true, style: style, className: cardClassName, onClick: onClick, ...props, children: children }));
|
|
90
|
+
});
|
|
91
|
+
CardRoot.displayName = 'Card';
|
|
92
|
+
// ========================== COMPOUND COMPONENT ==========================
|
|
93
|
+
/**
|
|
94
|
+
* Compound Card component with Section support
|
|
95
|
+
*/
|
|
96
|
+
export const Card = Object.assign(CardRoot, {
|
|
97
|
+
Section: CardSection,
|
|
98
|
+
});
|
|
99
|
+
// Export the Section component separately for named imports
|
|
100
|
+
export { CardSection };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Chip as MantineChip } from '@mantine/core';
|
|
5
|
+
// Map semantic variants to Mantine colors
|
|
6
|
+
const variantToColor = {
|
|
7
|
+
info: 'blue',
|
|
8
|
+
success: 'green',
|
|
9
|
+
danger: 'red',
|
|
10
|
+
pending: 'yellow',
|
|
11
|
+
default: 'gray',
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Chip component with semantic color variants and selection states.
|
|
15
|
+
* Built on top of Mantine's Chip component with consistent styling.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* // Basic chip
|
|
20
|
+
* <Chip>Default</Chip>
|
|
21
|
+
*
|
|
22
|
+
* // Colored variants
|
|
23
|
+
* <Chip variant="info">Info</Chip>
|
|
24
|
+
* <Chip variant="success">Success</Chip>
|
|
25
|
+
* <Chip variant="danger">Danger</Chip>
|
|
26
|
+
*
|
|
27
|
+
* // Controlled selection
|
|
28
|
+
* <Chip checked={selected} onChange={setSelected}>
|
|
29
|
+
* Toggle me
|
|
30
|
+
* </Chip>
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export const Chip = ({ variant = 'default', checked, onChange, ...props }) => {
|
|
34
|
+
return (_jsx(MantineChip, { color: variantToColor[variant], variant: "outline", radius: "sm", checked: checked, onChange: onChange, ...props }));
|
|
35
|
+
};
|
|
36
|
+
export default Chip;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Indicator as MantineIndicator } from '@mantine/core';
|
|
5
|
+
// ========================== COMPONENT ==========================
|
|
6
|
+
/**
|
|
7
|
+
* Indicator Component
|
|
8
|
+
*
|
|
9
|
+
* Built on top of Mantine's Indicator component with design system styling.
|
|
10
|
+
* Used to show notifications, status, or other supplementary information.
|
|
11
|
+
*
|
|
12
|
+
* Mantine's Indicator automatically handles:
|
|
13
|
+
* - Minimum size constraints (always at least a circle)
|
|
14
|
+
* - Pill shape when content is added (label/count)
|
|
15
|
+
* - Proper sizing and positioning
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Basic semantic indicators (dots)
|
|
19
|
+
* <Indicator type="success" size={12}>
|
|
20
|
+
* <Avatar />
|
|
21
|
+
* </Indicator>
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // With count (pill-shaped)
|
|
25
|
+
* <Indicator type="danger" count={5} size={16}>
|
|
26
|
+
* <Button>Messages</Button>
|
|
27
|
+
* </Indicator>
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // With outline variant
|
|
31
|
+
* <Indicator type="info" count={12} withOutline size={20}>
|
|
32
|
+
* <IconBell />
|
|
33
|
+
* </Indicator>
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // Processing/animated indicator
|
|
37
|
+
* <Indicator type="pending" processing size={14}>
|
|
38
|
+
* <Avatar />
|
|
39
|
+
* </Indicator>
|
|
40
|
+
*/
|
|
41
|
+
export const Indicator = forwardRef(({ type = 'default', color, size = 12, position = 'top-end', withBorder = false, disabled = false, processing = false, count, label, withOutline = false, children, ...props }, ref) => {
|
|
42
|
+
// Map semantic types to colors
|
|
43
|
+
const getTypeColor = (type) => {
|
|
44
|
+
switch (type) {
|
|
45
|
+
case 'success': return 'green';
|
|
46
|
+
case 'danger': return 'red';
|
|
47
|
+
case 'pending': return 'yellow';
|
|
48
|
+
case 'info': return 'blue';
|
|
49
|
+
case 'default': return 'gray';
|
|
50
|
+
default: return 'gray';
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const indicatorColor = color || getTypeColor(type);
|
|
54
|
+
const indicatorLabel = label || (count !== undefined ? count.toString() : undefined);
|
|
55
|
+
return (_jsx(MantineIndicator, { ref: ref, color: indicatorColor, size: size, position: position, withBorder: withBorder || withOutline, disabled: disabled, processing: processing, label: indicatorLabel, ...props, children: children }));
|
|
56
|
+
});
|
|
57
|
+
Indicator.displayName = 'Indicator';
|
|
58
|
+
// Default export for convenience
|
|
59
|
+
export default Indicator;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { List as MantineList } from '@mantine/core';
|
|
5
|
+
/**
|
|
6
|
+
* AppDirect Design System List Component
|
|
7
|
+
*
|
|
8
|
+
* A semantic list component built on top of Mantine's List with
|
|
9
|
+
* consistent design system styling and spacing options.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // Basic usage
|
|
14
|
+
* <List>
|
|
15
|
+
* <List.Item>First item</List.Item>
|
|
16
|
+
* <List.Item>Second item</List.Item>
|
|
17
|
+
* <List.Item>Third item</List.Item>
|
|
18
|
+
* </List>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* // With custom icon
|
|
24
|
+
* <List
|
|
25
|
+
* icon={<IconCheck size={16} />}
|
|
26
|
+
* spacing="md"
|
|
27
|
+
* size="sm"
|
|
28
|
+
* >
|
|
29
|
+
* <List.Item>Task completed</List.Item>
|
|
30
|
+
* <List.Item>Another task done</List.Item>
|
|
31
|
+
* </List>
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* // Ordered list
|
|
37
|
+
* <List type="ordered" spacing="sm">
|
|
38
|
+
* <List.Item>Step one</List.Item>
|
|
39
|
+
* <List.Item>Step two</List.Item>
|
|
40
|
+
* <List.Item>Step three</List.Item>
|
|
41
|
+
* </List>
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* // Different sizes and spacing
|
|
47
|
+
* <List size="lg" spacing="xl">
|
|
48
|
+
* <List.Item>Large spaced item</List.Item>
|
|
49
|
+
* <List.Item>Another large item</List.Item>
|
|
50
|
+
* </List>
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
const ListComponent = forwardRef(({ size = 'md', spacing = 'sm', ...props }, ref) => {
|
|
54
|
+
return (_jsx(MantineList, { ref: ref, size: size, spacing: spacing, ...props }));
|
|
55
|
+
});
|
|
56
|
+
ListComponent.displayName = 'List';
|
|
57
|
+
// Create a compound component with Item attached
|
|
58
|
+
export const List = Object.assign(ListComponent, {
|
|
59
|
+
Item: MantineList.Item,
|
|
60
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { Box, CloseButton } from '@mantine/core';
|
|
5
|
+
import { Inline } from '../Layout/index.js';
|
|
6
|
+
// Size configurations
|
|
7
|
+
const sizeConfig = {
|
|
8
|
+
xs: {
|
|
9
|
+
height: 18,
|
|
10
|
+
fontSize: 10,
|
|
11
|
+
lineHeight: 10,
|
|
12
|
+
letterSpacing: 0.1563,
|
|
13
|
+
px: 8,
|
|
14
|
+
gap: 0,
|
|
15
|
+
closeSize: 18,
|
|
16
|
+
},
|
|
17
|
+
sm: {
|
|
18
|
+
height: 24,
|
|
19
|
+
fontSize: 11,
|
|
20
|
+
lineHeight: 12,
|
|
21
|
+
letterSpacing: 0.17,
|
|
22
|
+
px: 8,
|
|
23
|
+
gap: 6,
|
|
24
|
+
closeSize: 14,
|
|
25
|
+
},
|
|
26
|
+
md: {
|
|
27
|
+
height: 25,
|
|
28
|
+
fontSize: 14,
|
|
29
|
+
lineHeight: 14,
|
|
30
|
+
letterSpacing: 0.2184,
|
|
31
|
+
px: 11.2,
|
|
32
|
+
gap: 8,
|
|
33
|
+
closeSize: 25,
|
|
34
|
+
},
|
|
35
|
+
lg: {
|
|
36
|
+
height: 32,
|
|
37
|
+
fontSize: 13,
|
|
38
|
+
lineHeight: 14,
|
|
39
|
+
letterSpacing: 0.2,
|
|
40
|
+
px: 12,
|
|
41
|
+
gap: 8,
|
|
42
|
+
closeSize: 18,
|
|
43
|
+
},
|
|
44
|
+
xl: {
|
|
45
|
+
height: 36,
|
|
46
|
+
fontSize: 14,
|
|
47
|
+
lineHeight: 16,
|
|
48
|
+
letterSpacing: 0.22,
|
|
49
|
+
px: 14,
|
|
50
|
+
gap: 8,
|
|
51
|
+
closeSize: 20,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
export const Pill = forwardRef(({ children, size = 'md', withRemoveButton = false, onRemove, style, ...others }, ref) => {
|
|
55
|
+
const config = sizeConfig[size];
|
|
56
|
+
const colors = {
|
|
57
|
+
backgroundColor: 'var(--ad-color-bg-subtle)',
|
|
58
|
+
color: 'var(--ad-color-text-dimmed)',
|
|
59
|
+
border: 'none',
|
|
60
|
+
};
|
|
61
|
+
return (_jsx(Box, { ref: ref, style: {
|
|
62
|
+
display: 'inline-flex',
|
|
63
|
+
alignItems: 'center',
|
|
64
|
+
height: config.height,
|
|
65
|
+
paddingLeft: config.px,
|
|
66
|
+
paddingRight: withRemoveButton ? 0 : config.px,
|
|
67
|
+
borderRadius: config.height / 2,
|
|
68
|
+
fontSize: config.fontSize,
|
|
69
|
+
fontWeight: 400,
|
|
70
|
+
lineHeight: `${config.lineHeight}px`,
|
|
71
|
+
letterSpacing: config.letterSpacing,
|
|
72
|
+
userSelect: 'none',
|
|
73
|
+
...colors,
|
|
74
|
+
...style,
|
|
75
|
+
}, ...others, children: _jsxs(Inline, { gap: config.gap, wrap: "nowrap", children: [_jsx("span", { children: children }), withRemoveButton && (_jsx(CloseButton, { size: config.closeSize, onClick: onRemove, variant: "transparent", style: {
|
|
76
|
+
color: 'currentColor',
|
|
77
|
+
minWidth: config.closeSize,
|
|
78
|
+
minHeight: config.closeSize,
|
|
79
|
+
}, "aria-label": "Remove" }))] }) }));
|
|
80
|
+
});
|
|
81
|
+
Pill.displayName = 'Pill';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Progress as MantineProgress } from '@mantine/core';
|
|
5
|
+
/**
|
|
6
|
+
* AppDirect Design System Progress Component
|
|
7
|
+
*
|
|
8
|
+
* A progress bar component built on top of Mantine's Progress with
|
|
9
|
+
* consistent design system styling and blue color scheme.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // Basic usage
|
|
14
|
+
* <Progress value={60} />
|
|
15
|
+
*
|
|
16
|
+
* // Different sizes
|
|
17
|
+
* <Progress value={30} size="xs" />
|
|
18
|
+
* <Progress value={50} size="sm" />
|
|
19
|
+
* <Progress value={70} size="md" />
|
|
20
|
+
* <Progress value={80} size="lg" />
|
|
21
|
+
* <Progress value={90} size="xl" />
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* // With animation
|
|
27
|
+
* <Progress value={75} animated />
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* // Different progress levels
|
|
33
|
+
* <Progress value={25} /> // Low progress
|
|
34
|
+
* <Progress value={60} /> // Medium progress
|
|
35
|
+
* <Progress value={90} /> // High progress
|
|
36
|
+
* <Progress value={100} /> // Complete
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export const Progress = forwardRef(({ size = 'md', value, animated = false, ...props }, ref) => {
|
|
40
|
+
return (_jsx(MantineProgress, { ref: ref, size: size, value: value, color: "blue", radius: "xl", animated: animated, ...props }));
|
|
41
|
+
});
|
|
42
|
+
Progress.displayName = 'Progress';
|