@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,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,280 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+ import { Card } from '../../DataDisplay/Card';
5
+ import { Stack, Inline, Box } from '../../Layout';
6
+ import { Title } from '../../Typography/Title';
7
+ import { Text } from '../../Typography/Text';
8
+ import { Switch } from '../../Inputs/Switch';
9
+ import { Select } from '../../Combobox/Select';
10
+ import { Menu } from '../../Overlays/Menu';
11
+ import { ActionIcon } from '../../Buttons/ActionIcon';
12
+ import { RiMore2Fill, RiArrowRightSLine } from '@remixicon/react';
13
+
14
+ // ========================== TYPES ==========================
15
+
16
+ export interface DashboardWidgetLink {
17
+ /** Link text */
18
+ label: string;
19
+ /** Click handler */
20
+ onClick: () => void;
21
+ /** Whether link is disabled */
22
+ disabled?: boolean;
23
+ }
24
+
25
+ export interface DashboardWidgetProps {
26
+ /** Widget title */
27
+ title: string;
28
+
29
+ // ==================== HEADER CONTROLS ====================
30
+ /** Optional switch with label and handler */
31
+ switch?: {
32
+ label: string;
33
+ checked: boolean;
34
+ onChange: (checked: boolean) => void;
35
+ disabled?: boolean;
36
+ };
37
+
38
+ /** Optional actions menu */
39
+ actionsMenu?: {
40
+ sections: Array<{
41
+ items: Array<{
42
+ id: string;
43
+ label: string;
44
+ onClick: () => void;
45
+ disabled?: boolean;
46
+ }>;
47
+ }>;
48
+ };
49
+
50
+ // ==================== CONTENT AREA ====================
51
+ /** Main content area - can be any React node */
52
+ children: React.ReactNode;
53
+
54
+ // ==================== OPTIONAL CONTROLS ====================
55
+ /** Optional select dropdown in the header (top-right) */
56
+ headerSelect?: {
57
+ placeholder?: string;
58
+ data: string[] | { value: string; label: string }[];
59
+ disabled?: boolean;
60
+ /** Current selected value (for controlled component) */
61
+ value?: string | null;
62
+ /** Change handler (for controlled component) */
63
+ onChange?: (value: string | null) => void;
64
+ /** Whether the select is searchable */
65
+ searchable?: boolean;
66
+ /** Whether the select is clearable */
67
+ clearable?: boolean;
68
+ };
69
+
70
+ /** Optional footer links */
71
+ footerLinks?: DashboardWidgetLink[];
72
+
73
+ // ==================== STYLING ====================
74
+ /** Additional card props */
75
+ cardProps?: Record<string, any>;
76
+ /** Custom spacing */
77
+ spacing?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
78
+ }
79
+
80
+ // ========================== COMPONENT ==========================
81
+
82
+ /**
83
+ * DashboardWidget Component
84
+ *
85
+ * A flexible widget container for dashboard content with optional controls.
86
+ * Built on top of the Card component with consistent spacing and styling.
87
+ *
88
+ * @example
89
+ * // Basic widget with content
90
+ * <DashboardWidget title="A widget title">
91
+ * <Text>This is a slot. To use it:</Text>
92
+ * <ul>
93
+ * <li>Create a local component with autolayout on</li>
94
+ * <li>Switch out this slot with that component using the component instance switcher</li>
95
+ * </ul>
96
+ * </DashboardWidget>
97
+ *
98
+ * @example
99
+ * // Widget with all features
100
+ * <DashboardWidget
101
+ * title="Analytics Widget"
102
+ * switch={{
103
+ * label: "Live updates",
104
+ * checked: true,
105
+ * onChange: (checked) => console.log(checked)
106
+ * }}
107
+ * actionsMenu={{
108
+ * sections: [{
109
+ * items: [
110
+ * { label: "Export", onClick: () => console.log("Export") },
111
+ * { label: "Settings", onClick: () => console.log("Settings") }
112
+ * ]
113
+ * }]
114
+ * }}
115
+ * headerSelect={{
116
+ * placeholder: "Select filter",
117
+ * data: ["Option 1", "Option 2", "Option 3"],
118
+ * onChange: (value) => console.log(value)
119
+ * }}
120
+ * footerLinks={[
121
+ * { label: "Link 1", onClick: () => console.log("Link 1") },
122
+ * { label: "Link 2", onClick: () => console.log("Link 2") },
123
+ * { label: "Link 3", onClick: () => console.log("Link 3") }
124
+ * ]}
125
+ * >
126
+ * <YourCustomContent />
127
+ * </DashboardWidget>
128
+ */
129
+ export function DashboardWidget({
130
+ title,
131
+ switch: switchConfig,
132
+ actionsMenu,
133
+ children,
134
+ headerSelect,
135
+ footerLinks,
136
+ cardProps = {},
137
+ spacing = 'xs',
138
+ }: DashboardWidgetProps) {
139
+
140
+ // ==================== RENDER FUNCTIONS ==========================
141
+
142
+ const renderHeader = () => (
143
+ <Inline justify="space-between" align="flex-start">
144
+ {/* Title */}
145
+ <Stack gap="xs">
146
+ <Title order={4}>
147
+ {title}
148
+ </Title>
149
+ </Stack>
150
+ {/* Header controls */}
151
+ <Inline gap="sm" align="center">
152
+ {/* Switch */}
153
+ {switchConfig && (
154
+ <Inline gap="xs" align="center">
155
+ <Text size="sm">{switchConfig.label}</Text>
156
+ <Switch
157
+ checked={switchConfig.checked}
158
+ onChange={(event) => switchConfig.onChange(event.currentTarget.checked)}
159
+ disabled={switchConfig.disabled}
160
+ size="sm"
161
+ />
162
+ </Inline>
163
+ )}
164
+
165
+ {/* Header select (borderless select in top-right) */}
166
+ {headerSelect && (
167
+ <Select
168
+ data={headerSelect.data}
169
+ value={headerSelect.value}
170
+ onChange={headerSelect.onChange}
171
+ placeholder={headerSelect.placeholder}
172
+ disabled={headerSelect.disabled}
173
+ searchable={headerSelect.searchable}
174
+ clearable={headerSelect.clearable}
175
+ borderless
176
+ size="sm"
177
+ />
178
+ )}
179
+
180
+ {/* Actions menu - only show if no header select */}
181
+ {actionsMenu && !headerSelect && (
182
+ <Menu
183
+ trigger={
184
+ <ActionIcon size="sm" aria-label="Widget actions">
185
+ <RiMore2Fill size={16} />
186
+ </ActionIcon>
187
+ }
188
+ position="bottom-end"
189
+ sections={actionsMenu.sections}
190
+ />
191
+ )}
192
+ </Inline>
193
+ </Inline>
194
+ );
195
+
196
+ const renderFooterLinks = () => {
197
+ return (
198
+ <Box p="sm" pl="lg" pr="lg">
199
+ {footerLinks && footerLinks.length > 0 ? (
200
+ <Inline gap="xs" >
201
+ {footerLinks.map((link, index) => (
202
+ <Inline
203
+ key={index}
204
+ gap="xs"
205
+ align="center"
206
+ onClick={link.disabled ? undefined : link.onClick}
207
+ style={{
208
+ cursor: link.disabled ? 'not-allowed' : 'pointer',
209
+ opacity: link.disabled ? 0.5 : 1,
210
+ color: link.disabled ? 'var(--ad-color-text-dimmed)' : 'var(--ad-color-brand-primary)',
211
+
212
+
213
+ transition: 'color 0.2s ease',
214
+ }}
215
+ >
216
+ <Text size="sm" c={link.disabled ? 'dimmed' : 'blue'}>
217
+ {link.label}
218
+ </Text>
219
+ <RiArrowRightSLine size={14} />
220
+ </Inline>
221
+ ))}
222
+ </Inline>
223
+ ) : (
224
+ // Empty footer that maintains the same height
225
+ <Box style={{ height: '21px' }} />
226
+ )}
227
+ </Box>
228
+ );
229
+ };
230
+
231
+ // ==================== MAIN RENDER ==========================
232
+
233
+ return (
234
+ <Card
235
+ {...cardProps}
236
+ pl="lg"
237
+ pr="lg"
238
+ pt="sm"
239
+ pb={0} // Remove bottom padding as footer will handle it
240
+ style={{
241
+ position: 'relative',
242
+ height: '100%',
243
+ overflow: 'hidden',
244
+ ...cardProps.style,
245
+ }}
246
+ >
247
+ {/* Header and scrollable content area */}
248
+ <Stack
249
+ gap={spacing}
250
+ style={{
251
+ height: '100%',
252
+ paddingBottom: '60px', // Space for fixed footer
253
+ }}
254
+ >
255
+ {renderHeader()}
256
+
257
+ {/* Main content area - scrollable */}
258
+ <Box style={{
259
+ flex: 1,
260
+ overflowY: 'auto',
261
+ overflowX: 'hidden',
262
+ paddingRight: '4px', // Space for scrollbar
263
+ }}>
264
+ {children}
265
+ </Box>
266
+ </Stack>
267
+
268
+ {/* Footer area - fixed at bottom */}
269
+ <div style={{
270
+ position: 'absolute',
271
+ bottom: 0,
272
+ left: 0,
273
+ right: 0,
274
+ backgroundColor: 'var(--ad-color-bg-default)',
275
+ }}>
276
+ {renderFooterLinks()}
277
+ </div>
278
+ </Card>
279
+ );
280
+ }
@@ -0,0 +1,2 @@
1
+ export { DashboardWidget } from './DashboardWidget';
2
+ export type { DashboardWidgetProps, DashboardWidgetLink } from './DashboardWidget';