@appdirect/design-system 0.0.0-stage → 0.0.2

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 +313 -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 +1777 -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,131 @@
1
+ 'use client';
2
+
3
+ import { useState } from 'react';
4
+ import { Combobox, InputBase, useCombobox } from '@mantine/core';
5
+
6
+ const languages = [
7
+ 'JavaScript',
8
+ 'TypeScript',
9
+ 'Python',
10
+ 'Java',
11
+ 'C++',
12
+ 'Go',
13
+ 'Rust',
14
+ 'Swift',
15
+ ];
16
+
17
+ export interface DSSearchableSelectProps {
18
+ /** Label for the input */
19
+ label?: string;
20
+ /** Placeholder text */
21
+ placeholder?: string;
22
+ /** Data array for options - can be strings or objects with value/label */
23
+ data?: string[] | { value: string; label: string }[];
24
+ /** Description text displayed below the input */
25
+ description?: string;
26
+ /** Error message */
27
+ error?: string;
28
+ /** Whether the field is required */
29
+ required?: boolean;
30
+ /** Whether to show "(optional)" next to the label */
31
+ showOptional?: boolean;
32
+ /** Whether the input is disabled */
33
+ disabled?: boolean;
34
+ /** Whether the select is searchable */
35
+ searchable?: boolean;
36
+ /** Input size */
37
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
38
+ /** Style object for the component */
39
+ style?: React.CSSProperties;
40
+ }
41
+
42
+ export function SearchableSelect({
43
+ label,
44
+ placeholder = "Search programming languages",
45
+ data = languages,
46
+ description,
47
+ error,
48
+ required = false,
49
+ showOptional = false,
50
+ disabled = false,
51
+ searchable = true,
52
+ size = 'md',
53
+ style,
54
+ ...props
55
+ }: DSSearchableSelectProps) {
56
+ const combobox = useCombobox({
57
+ onDropdownClose: () => combobox.resetSelectedOption(),
58
+ });
59
+
60
+ const [value, setValue] = useState<string | null>(null);
61
+ const [search, setSearch] = useState('');
62
+
63
+ // Convert data to consistent format
64
+ const normalizedData = data.map(item =>
65
+ typeof item === 'string' ? { value: item, label: item } : item
66
+ );
67
+
68
+ const shouldFilterOptions = normalizedData.every((item) => item.value !== search);
69
+ const filteredOptions = shouldFilterOptions && searchable
70
+ ? normalizedData.filter((item) =>
71
+ item.label.toLowerCase().includes(search.toLowerCase().trim()) ||
72
+ item.value.toLowerCase().includes(search.toLowerCase().trim())
73
+ )
74
+ : normalizedData;
75
+
76
+ const options = filteredOptions.map((item) => (
77
+ <Combobox.Option value={item.value} key={item.value}>
78
+ {item.label}
79
+ </Combobox.Option>
80
+ ));
81
+
82
+ return (
83
+ <div style={style}>
84
+ <Combobox
85
+ store={combobox}
86
+ withinPortal={false}
87
+ onOptionSubmit={(val) => {
88
+ setValue(val);
89
+ setSearch(val);
90
+ combobox.closeDropdown();
91
+ }}
92
+ >
93
+ <Combobox.Target>
94
+ <InputBase
95
+ label={label}
96
+ description={description}
97
+ error={error}
98
+ required={required}
99
+ size={size}
100
+ disabled={disabled}
101
+ rightSection={<Combobox.Chevron />}
102
+ value={search}
103
+ onChange={(event) => {
104
+ combobox.openDropdown();
105
+ combobox.updateSelectedOptionIndex();
106
+ setSearch(event.currentTarget.value);
107
+ }}
108
+ onClick={() => combobox.openDropdown()}
109
+ onFocus={() => combobox.openDropdown()}
110
+ onBlur={() => {
111
+ combobox.closeDropdown();
112
+ setSearch(value || '');
113
+ }}
114
+ placeholder={placeholder}
115
+ rightSectionPointerEvents="none"
116
+ withAsterisk={required && !showOptional}
117
+ {...(showOptional && !required && {
118
+ label: label ? `${label} (optional)` : undefined
119
+ })}
120
+ />
121
+ </Combobox.Target>
122
+
123
+ <Combobox.Dropdown>
124
+ <Combobox.Options>
125
+ {options.length > 0 ? options : <Combobox.Empty>Nothing found</Combobox.Empty>}
126
+ </Combobox.Options>
127
+ </Combobox.Dropdown>
128
+ </Combobox>
129
+ </div>
130
+ );
131
+ }
@@ -0,0 +1,154 @@
1
+ 'use client';
2
+
3
+ import React, { forwardRef } from 'react';
4
+ import { Select as MantineSelect, SelectProps as MantineSelectProps, ActionIcon, Group } from '@mantine/core';
5
+ import { IconInfoCircle, IconSelector } from '@tabler/icons-react';
6
+ import { ComponentSize } from '../config';
7
+ import { Text } from '../Typography/Text';
8
+ import { Tooltip } from '../Overlays/Tooltip';
9
+
10
+ // ========================== TYPES ==========================
11
+
12
+ export interface DSSelectProps extends Omit<MantineSelectProps, 'size' | 'radius' | 'rightSection'> {
13
+ /** Input size from design system scale */
14
+ size?: ComponentSize;
15
+ /** Whether to use borderless style (unstyled variant) */
16
+ borderless?: boolean;
17
+ /** Whether to show "(Optional)" text after label */
18
+ showOptional?: boolean;
19
+ /** Whether to show a help icon with a tooltip in the right section */
20
+ hasHelpIcon?: boolean;
21
+ /** Tooltip label shown when hovering the help icon. Also used as aria-label for a11y */
22
+ helpIconLabel?: string;
23
+ /** Optional click handler for the help icon */
24
+ onHelpIconClick?: React.MouseEventHandler<HTMLButtonElement>;
25
+ /**
26
+ * Optional error message text shown below the input when in error state.
27
+ * Used with error={true} (from state) for red border + message; omit for red border only.
28
+ */
29
+ errorCaption?: string;
30
+ }
31
+
32
+ // ========================== COMPONENT ==========================
33
+
34
+ /**
35
+ * AppDirect Design System Select Component
36
+ *
37
+ * A select/dropdown component built on top of Mantine's Select with
38
+ * consistent design system styling and enforced radius. Supports both
39
+ * regular and borderless styles for different use cases.
40
+ *
41
+ * @example
42
+ * ```tsx
43
+ * // Basic usage
44
+ * <Select
45
+ * data={['Option 1', 'Option 2', 'Option 3']}
46
+ * placeholder="Select option"
47
+ * label="Choose an option"
48
+ * />
49
+ * ```
50
+ *
51
+ * @example
52
+ * ```tsx
53
+ * // Borderless select for dashboard widgets
54
+ * <Select
55
+ * data={[
56
+ * { value: 'today', label: 'Today' },
57
+ * { value: 'week', label: 'This Week' },
58
+ * { value: 'month', label: 'This Month' },
59
+ * ]}
60
+ * value={period}
61
+ * onChange={setPeriod}
62
+ * borderless
63
+ * searchable
64
+ * clearable
65
+ * />
66
+ * ```
67
+ *
68
+ * @example
69
+ * ```tsx
70
+ * // With help icon and optional label
71
+ * <Select
72
+ * data={['Admin', 'Editor', 'Viewer']}
73
+ * label="Role"
74
+ * showOptional
75
+ * hasHelpIcon
76
+ * helpIconLabel="Select the user's permission level"
77
+ * />
78
+ * ```
79
+ */
80
+ export const Select = forwardRef<HTMLInputElement, DSSelectProps>(
81
+ (
82
+ {
83
+ size = 'sm',
84
+ borderless = false,
85
+ showOptional = false,
86
+ required,
87
+ label,
88
+ hasHelpIcon = false,
89
+ helpIconLabel,
90
+ onHelpIconClick,
91
+ error,
92
+ errorCaption,
93
+ variant,
94
+ ...props
95
+ },
96
+ ref
97
+ ) => {
98
+ const effectiveError = error === true ? (errorCaption ?? true) : error;
99
+
100
+ const enhancedLabel = React.useMemo(() => {
101
+ if (!label) return label;
102
+ if (showOptional && !required) {
103
+ return (
104
+ <>
105
+ {label} <Text span c="dimmed" fw="normal">(Optional)</Text>
106
+ </>
107
+ );
108
+ }
109
+ return label;
110
+ }, [label, showOptional, required]);
111
+
112
+ const helpIconElement = hasHelpIcon ? (
113
+ <Tooltip
114
+ label={helpIconLabel ?? 'Help'}
115
+ position="top"
116
+ withArrow
117
+ >
118
+ <ActionIcon
119
+ variant="transparent"
120
+ size="xs"
121
+ aria-label={helpIconLabel ?? 'Help'}
122
+ onClick={onHelpIconClick}
123
+ color="gray"
124
+ style={{ cursor: onHelpIconClick ? 'pointer' : 'default' }}
125
+ >
126
+ <IconInfoCircle size={14} aria-hidden />
127
+ </ActionIcon>
128
+ </Tooltip>
129
+ ) : null;
130
+
131
+ const selectorIcon = <IconSelector size={14} aria-hidden />;
132
+
133
+ const composedRightSection = helpIconElement
134
+ ? <Group gap={4} wrap="nowrap">{selectorIcon}{helpIconElement}</Group>
135
+ : selectorIcon;
136
+
137
+ return (
138
+ <MantineSelect
139
+ ref={ref}
140
+ size={size}
141
+ radius="sm"
142
+ required={required}
143
+ label={enhancedLabel}
144
+ rightSection={composedRightSection}
145
+ rightSectionPointerEvents={hasHelpIcon || props.clearable ? 'auto' : 'none'}
146
+ variant={borderless ? 'unstyled' : (variant ?? 'default')}
147
+ error={effectiveError}
148
+ {...props}
149
+ />
150
+ );
151
+ }
152
+ );
153
+
154
+ Select.displayName = 'Select';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Combobox Components
3
+ *
4
+ * Collection of combobox/select components with different behaviors and use cases.
5
+ */
6
+
7
+ export { SearchableSelect } from './SearchableSelect';
8
+ export type { DSSearchableSelectProps } from './SearchableSelect';
9
+
10
+ export { AutocompleteClearable } from './AutocompleteClearable';
11
+ export type { DSAutocompleteClearableProps } from './AutocompleteClearable';
12
+
13
+ export { Multiselect } from './Multiselect';
14
+ export type { DSMultiselectProps } from './Multiselect';
15
+
16
+ export { Select } from './Select';
17
+ export type { DSSelectProps } from './Select';
18
+
19
+ export { Combobox } from './Combobox';
20
+ export type { DSComboboxProps } from './Combobox';
@@ -0,0 +1,313 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+ import { Card } from '../../DataDisplay/Card';
5
+ import { Alert } from '../../DataDisplay/Alert';
6
+ import { Stack, Inline, Box } from '../../Layout';
7
+ import { Title } from '../../Typography/Title';
8
+ import { Text } from '../../Typography/Text';
9
+ import { Switch } from '../../Inputs/Switch';
10
+ import { Select } from '../../Combobox/Select';
11
+ import { Menu } from '../../Overlays/Menu';
12
+ import { ActionIcon } from '../../Buttons/ActionIcon';
13
+ import { RiMore2Fill, RiArrowRightSLine, RiEditLine } from '@remixicon/react';
14
+
15
+ // ========================== TYPES ==========================
16
+
17
+ export interface DashboardWidgetLink {
18
+ /** Link text */
19
+ label: string;
20
+ /** Click handler */
21
+ onClick: () => void;
22
+ /** Whether link is disabled */
23
+ disabled?: boolean;
24
+ }
25
+
26
+ export interface DashboardWidgetProps {
27
+ /** Widget title */
28
+ title: string;
29
+ /** Whether the title shows an edit affordance */
30
+ editable?: boolean;
31
+ /** Callback when the edit icon is clicked */
32
+ onEdit?: () => void;
33
+
34
+ // ==================== PANEL NOTIFICATION ====================
35
+ /** Whether to show a panel notification banner below the header */
36
+ panelNotification?: boolean;
37
+ /** Content for the panel notification (ignored when panelNotification is false) */
38
+ panelNotificationMessage?: React.ReactNode;
39
+
40
+ // ==================== HEADER CONTROLS ====================
41
+ /** Optional switch with label and handler */
42
+ switch?: {
43
+ label: string;
44
+ checked: boolean;
45
+ onChange: (checked: boolean) => void;
46
+ disabled?: boolean;
47
+ };
48
+
49
+ /** Optional actions menu */
50
+ actionsMenu?: {
51
+ sections: Array<{
52
+ items: Array<{
53
+ id: string;
54
+ label: string;
55
+ onClick: () => void;
56
+ disabled?: boolean;
57
+ }>;
58
+ }>;
59
+ };
60
+
61
+ // ==================== CONTENT AREA ====================
62
+ /** Main content area - can be any React node */
63
+ children: React.ReactNode;
64
+
65
+ // ==================== OPTIONAL CONTROLS ====================
66
+ /** Optional select dropdown in the header (top-right) */
67
+ headerSelect?: {
68
+ placeholder?: string;
69
+ data: string[] | { value: string; label: string }[];
70
+ disabled?: boolean;
71
+ /** Current selected value (for controlled component) */
72
+ value?: string | null;
73
+ /** Change handler (for controlled component) */
74
+ onChange?: (value: string | null) => void;
75
+ /** Whether the select is searchable */
76
+ searchable?: boolean;
77
+ /** Whether the select is clearable */
78
+ clearable?: boolean;
79
+ };
80
+
81
+ /** Optional footer links */
82
+ footerLinks?: DashboardWidgetLink[];
83
+
84
+ // ==================== STYLING ====================
85
+ /** Additional card props */
86
+ cardProps?: Record<string, any>;
87
+ /** Custom spacing */
88
+ spacing?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
89
+ }
90
+
91
+ // ========================== COMPONENT ==========================
92
+
93
+ /**
94
+ * DashboardWidget Component
95
+ *
96
+ * A flexible widget container for dashboard content with optional controls.
97
+ * Built on top of the Card component with consistent spacing and styling.
98
+ *
99
+ * @example
100
+ * // Basic widget with content
101
+ * <DashboardWidget title="A widget title">
102
+ * <Text>This is a slot. To use it:</Text>
103
+ * <ul>
104
+ * <li>Create a local component with autolayout on</li>
105
+ * <li>Switch out this slot with that component using the component instance switcher</li>
106
+ * </ul>
107
+ * </DashboardWidget>
108
+ *
109
+ * @example
110
+ * // Widget with all features
111
+ * <DashboardWidget
112
+ * title="Analytics Widget"
113
+ * switch={{
114
+ * label: "Live updates",
115
+ * checked: true,
116
+ * onChange: (checked) => console.log(checked)
117
+ * }}
118
+ * actionsMenu={{
119
+ * sections: [{
120
+ * items: [
121
+ * { label: "Export", onClick: () => console.log("Export") },
122
+ * { label: "Settings", onClick: () => console.log("Settings") }
123
+ * ]
124
+ * }]
125
+ * }}
126
+ * headerSelect={{
127
+ * placeholder: "Select filter",
128
+ * data: ["Option 1", "Option 2", "Option 3"],
129
+ * onChange: (value) => console.log(value)
130
+ * }}
131
+ * footerLinks={[
132
+ * { label: "Link 1", onClick: () => console.log("Link 1") },
133
+ * { label: "Link 2", onClick: () => console.log("Link 2") },
134
+ * { label: "Link 3", onClick: () => console.log("Link 3") }
135
+ * ]}
136
+ * >
137
+ * <YourCustomContent />
138
+ * </DashboardWidget>
139
+ */
140
+ export function DashboardWidget({
141
+ title,
142
+ editable = false,
143
+ onEdit,
144
+ panelNotification = false,
145
+ panelNotificationMessage,
146
+ switch: switchConfig,
147
+ actionsMenu,
148
+ children,
149
+ headerSelect,
150
+ footerLinks,
151
+ cardProps = {},
152
+ spacing = 'xs',
153
+ }: DashboardWidgetProps) {
154
+
155
+ // ==================== RENDER FUNCTIONS ==========================
156
+
157
+ const renderHeader = () => (
158
+ <Inline justify="space-between" align="flex-start">
159
+ {/* Title */}
160
+ <Stack gap="xs">
161
+ <Inline gap="xs" align="center">
162
+ <Title order={4}>
163
+ {title}
164
+ </Title>
165
+ {editable && (
166
+ <ActionIcon
167
+ size="sm"
168
+ onClick={onEdit}
169
+ aria-label="Edit title"
170
+ >
171
+ <RiEditLine size={16} />
172
+ </ActionIcon>
173
+ )}
174
+ </Inline>
175
+ </Stack>
176
+ {/* Header controls */}
177
+ <Inline gap="sm" align="center">
178
+ {/* Switch */}
179
+ {switchConfig && (
180
+ <Inline gap="xs" align="center">
181
+ <Text size="sm">{switchConfig.label}</Text>
182
+ <Switch
183
+ checked={switchConfig.checked}
184
+ onChange={(event) => switchConfig.onChange(event.currentTarget.checked)}
185
+ disabled={switchConfig.disabled}
186
+ size="sm"
187
+ />
188
+ </Inline>
189
+ )}
190
+
191
+ {/* Header select (borderless select in top-right) */}
192
+ {headerSelect && (
193
+ <Select
194
+ data={headerSelect.data}
195
+ value={headerSelect.value}
196
+ onChange={headerSelect.onChange}
197
+ placeholder={headerSelect.placeholder}
198
+ disabled={headerSelect.disabled}
199
+ searchable={headerSelect.searchable}
200
+ clearable={headerSelect.clearable}
201
+ borderless
202
+ size="sm"
203
+ />
204
+ )}
205
+
206
+ {/* Actions menu - only show if no header select */}
207
+ {actionsMenu && !headerSelect && (
208
+ <Menu
209
+ trigger={
210
+ <ActionIcon size="sm" aria-label="Widget actions">
211
+ <RiMore2Fill size={16} />
212
+ </ActionIcon>
213
+ }
214
+ position="bottom-end"
215
+ sections={actionsMenu.sections}
216
+ />
217
+ )}
218
+ </Inline>
219
+ </Inline>
220
+ );
221
+
222
+ const renderFooterLinks = () => {
223
+ return (
224
+ <Box p="sm" pl="lg" pr="lg">
225
+ {footerLinks && footerLinks.length > 0 ? (
226
+ <Inline gap="xs" >
227
+ {footerLinks.map((link, index) => (
228
+ <Inline
229
+ key={index}
230
+ gap="xs"
231
+ align="center"
232
+ onClick={link.disabled ? undefined : link.onClick}
233
+ style={{
234
+ cursor: link.disabled ? 'not-allowed' : 'pointer',
235
+ opacity: link.disabled ? 0.5 : 1,
236
+ color: link.disabled ? 'var(--ad-color-text-dimmed)' : 'var(--ad-color-brand-primary)',
237
+
238
+
239
+ transition: 'color 0.2s ease',
240
+ }}
241
+ >
242
+ <Text size="sm" c={link.disabled ? 'dimmed' : 'blue'}>
243
+ {link.label}
244
+ </Text>
245
+ <RiArrowRightSLine size={14} />
246
+ </Inline>
247
+ ))}
248
+ </Inline>
249
+ ) : (
250
+ // Empty footer that maintains the same height
251
+ <Box style={{ height: '21px' }} />
252
+ )}
253
+ </Box>
254
+ );
255
+ };
256
+
257
+ // ==================== MAIN RENDER ==========================
258
+
259
+ return (
260
+ <Card
261
+ {...cardProps}
262
+ pl="lg"
263
+ pr="lg"
264
+ pt="sm"
265
+ pb={0} // Remove bottom padding as footer will handle it
266
+ style={{
267
+ position: 'relative',
268
+ height: '100%',
269
+ overflow: 'hidden',
270
+ ...cardProps.style,
271
+ }}
272
+ >
273
+ {/* Header and scrollable content area */}
274
+ <Stack
275
+ gap={spacing}
276
+ style={{
277
+ height: '100%',
278
+ paddingBottom: '60px', // Space for fixed footer
279
+ }}
280
+ >
281
+ {renderHeader()}
282
+
283
+ {/* Panel notification */}
284
+ {panelNotification && (
285
+ <Alert color="info">
286
+ {panelNotificationMessage}
287
+ </Alert>
288
+ )}
289
+
290
+ {/* Main content area - scrollable */}
291
+ <Box style={{
292
+ flex: 1,
293
+ overflowY: 'auto',
294
+ overflowX: 'hidden',
295
+ paddingRight: '4px', // Space for scrollbar
296
+ }}>
297
+ {children}
298
+ </Box>
299
+ </Stack>
300
+
301
+ {/* Footer area - fixed at bottom */}
302
+ <div style={{
303
+ position: 'absolute',
304
+ bottom: 0,
305
+ left: 0,
306
+ right: 0,
307
+ backgroundColor: 'var(--ad-color-bg-default)',
308
+ }}>
309
+ {renderFooterLinks()}
310
+ </div>
311
+ </Card>
312
+ );
313
+ }
@@ -0,0 +1,2 @@
1
+ export { DashboardWidget } from './DashboardWidget';
2
+ export type { DashboardWidgetProps, DashboardWidgetLink } from './DashboardWidget';