@appdirect/design-system 0.0.10 → 0.0.12

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 (179) hide show
  1. package/README.md +85 -5
  2. package/dist/Buttons/ActionIcon.js +14 -0
  3. package/dist/Buttons/Button.js +66 -0
  4. package/dist/Buttons/CloseButton.js +48 -0
  5. package/dist/Buttons/index.js +13 -0
  6. package/dist/Combobox/AutocompleteClearable.js +36 -0
  7. package/dist/Combobox/Combobox.js +28 -0
  8. package/dist/Combobox/Multiselect.js +31 -0
  9. package/dist/Combobox/SearchableSelect.js +43 -0
  10. package/dist/Combobox/Select.js +72 -0
  11. package/dist/Combobox/index.js +10 -0
  12. package/dist/ComplexComponents/DashboardWidget/DashboardWidget.js +96 -0
  13. package/dist/ComplexComponents/DashboardWidget/index.js +1 -0
  14. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +82 -0
  15. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.js +23 -0
  16. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.js +23 -0
  17. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +230 -0
  18. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.js +30 -0
  19. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/DateRangeFilter.js +12 -0
  20. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterRenderer.js +32 -0
  21. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterSystem.js +90 -0
  22. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/MultiSelectFilter.js +43 -0
  23. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/SingleSelectFilter.js +30 -0
  24. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/index.js +39 -0
  25. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/types.js +9 -0
  26. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.js +31 -0
  27. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +42 -0
  28. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.js +21 -0
  29. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.js +410 -0
  30. package/dist/ComplexComponents/DataTable/DataTable.js +405 -0
  31. package/dist/ComplexComponents/DataTable/ErrorOverlay/index.js +9 -0
  32. package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.js +27 -0
  33. package/dist/ComplexComponents/DataTable/index.js +1 -0
  34. package/dist/ComplexComponents/DataTable/translations/en.js +99 -0
  35. package/dist/ComplexComponents/DataTable/translations/index.js +17 -0
  36. package/dist/ComplexComponents/KeyInsight/KeyInsights.js +176 -0
  37. package/dist/ComplexComponents/KeyInsight/index.js +1 -0
  38. package/dist/ComplexComponents/NameValue/NameValue.js +94 -0
  39. package/dist/ComplexComponents/NameValue/NameValueItem.js +59 -0
  40. package/dist/ComplexComponents/NameValue/index.js +2 -0
  41. package/dist/ComplexComponents/PageContentHeader/PageContentHeader.js +92 -0
  42. package/dist/ComplexComponents/PageContentHeader/PageContentHeader.tsx +24 -34
  43. package/dist/ComplexComponents/PageContentHeader/index.js +1 -0
  44. package/dist/ComplexComponents/PageContentHeader/index.ts +0 -2
  45. package/dist/ComplexComponents/Placeholder/Placeholder.js +51 -0
  46. package/dist/ComplexComponents/Placeholder/index.js +1 -0
  47. package/dist/ComplexComponents/Slat/Slat.js +53 -0
  48. package/dist/ComplexComponents/Slat/index.js +1 -0
  49. package/dist/ComplexComponents/Utilities/CopyButton.js +45 -0
  50. package/dist/ComplexComponents/Utilities/index.js +1 -0
  51. package/dist/DataDisplay/Alert.js +77 -0
  52. package/dist/DataDisplay/Avatar.js +157 -0
  53. package/dist/DataDisplay/Badge.js +78 -0
  54. package/dist/DataDisplay/Card.js +100 -0
  55. package/dist/DataDisplay/Chip.js +36 -0
  56. package/dist/DataDisplay/Indicator.js +59 -0
  57. package/dist/DataDisplay/List.js +60 -0
  58. package/dist/DataDisplay/Pill.js +81 -0
  59. package/dist/DataDisplay/Progress.js +42 -0
  60. package/dist/DataDisplay/Table.js +38 -0
  61. package/dist/DataDisplay/ThemeIcon.js +31 -0
  62. package/dist/DataDisplay/index.js +18 -0
  63. package/dist/Inputs/Checkbox.js +62 -0
  64. package/dist/Inputs/ColorInput.js +48 -0
  65. package/dist/Inputs/DropZone.js +12 -0
  66. package/dist/Inputs/FileInput.js +77 -0
  67. package/dist/Inputs/NumberInput.js +49 -0
  68. package/dist/Inputs/Radio.js +55 -0
  69. package/dist/Inputs/RadioGroup.js +59 -0
  70. package/dist/Inputs/SegmentedControl.js +50 -0
  71. package/dist/Inputs/Slider.js +50 -0
  72. package/dist/Inputs/SliderWithLabel.js +32 -0
  73. package/dist/Inputs/Switch.js +47 -0
  74. package/dist/Inputs/TextArea.js +50 -0
  75. package/dist/Inputs/TextInput.js +87 -0
  76. package/dist/Inputs/index.js +27 -0
  77. package/dist/Layout/Box.js +39 -0
  78. package/dist/Layout/Center.js +11 -0
  79. package/dist/Layout/Container.js +11 -0
  80. package/dist/Layout/Flex.js +12 -0
  81. package/dist/Layout/Grid.js +13 -0
  82. package/dist/Layout/Group.js +14 -0
  83. package/dist/Layout/Inline.js +46 -0
  84. package/dist/Layout/SimpleGrid.js +14 -0
  85. package/dist/Layout/Stack.js +45 -0
  86. package/dist/Layout/index.js +10 -0
  87. package/dist/Misc/Divider.js +8 -0
  88. package/dist/Misc/Paper.js +24 -0
  89. package/dist/Misc/index.js +10 -0
  90. package/dist/Navigation/Breadcrumb.js +60 -0
  91. package/dist/Navigation/NavLink.js +28 -0
  92. package/dist/Navigation/Stepper.js +8 -0
  93. package/dist/Navigation/Tabs.js +22 -0
  94. package/dist/Navigation/index.js +9 -0
  95. package/dist/Overlays/Drawer.js +63 -0
  96. package/dist/Overlays/Menu.js +85 -0
  97. package/dist/Overlays/Modal.js +61 -0
  98. package/dist/Overlays/Popover.js +118 -0
  99. package/dist/Overlays/Tooltip.js +71 -0
  100. package/dist/Overlays/index.js +12 -0
  101. package/dist/Shell/AppShellLayout.js +13 -0
  102. package/dist/Shell/HeaderBar.js +8 -0
  103. package/dist/Shell/SidebarNav.js +9 -0
  104. package/dist/Shell/SidebarNavLink.js +17 -0
  105. package/dist/Shell/SingleColumnLayout.js +11 -0
  106. package/dist/Shell/TertiaryColumnLayout.js +12 -0
  107. package/dist/Shell/index.js +6 -0
  108. package/dist/Typography/Code.js +8 -0
  109. package/dist/Typography/Kbd.js +58 -0
  110. package/dist/Typography/Text.js +8 -0
  111. package/dist/Typography/Title.js +11 -0
  112. package/dist/Typography/index.js +12 -0
  113. package/dist/config.js +202 -0
  114. package/dist/contracts/PageContentHeader.json +10 -5
  115. package/dist/contracts/index.json +1 -1
  116. package/dist/hooks/useTableHandlers.js +136 -0
  117. package/dist/hooks/useTableRenderFunctions.js +164 -0
  118. package/dist/hooks/useTableState.js +70 -0
  119. package/dist/index.js +162 -0
  120. package/dist/index.ts +3 -4
  121. package/dist/stories/Buttons/ActionIcon.stories.tsx +159 -0
  122. package/dist/stories/Buttons/Button.stories.tsx +145 -0
  123. package/dist/stories/Buttons/CloseButton.stories.tsx +121 -0
  124. package/dist/stories/Combobox/AutocompleteClearable.stories.tsx +554 -0
  125. package/dist/stories/Combobox/Combobox.stories.tsx +106 -0
  126. package/dist/stories/Combobox/Multiselect.stories.tsx +664 -0
  127. package/dist/stories/Combobox/SearchableSelect.stories.tsx +640 -0
  128. package/dist/stories/Combobox/Select.stories.tsx +311 -0
  129. package/dist/stories/ComplexComponents/DashboardWidget/DashboardWidget.stories.tsx +822 -0
  130. package/dist/stories/ComplexComponents/DataTable/DataTable.stories.tsx +502 -0
  131. package/dist/stories/ComplexComponents/KeyInsight/KeyInsights.stories.tsx +386 -0
  132. package/dist/stories/ComplexComponents/NameValue/NameValue.stories.tsx +405 -0
  133. package/dist/stories/ComplexComponents/PageContentHeader/PageContentHeader.stories.tsx +527 -0
  134. package/dist/stories/ComplexComponents/Placeholder/Placeholder.stories.tsx +76 -0
  135. package/dist/stories/ComplexComponents/Slat/Slat.stories.tsx +79 -0
  136. package/dist/stories/ComplexComponents/Utilities/CopyButton.stories.tsx +479 -0
  137. package/dist/stories/DataDisplay/Alert.stories.tsx +296 -0
  138. package/dist/stories/DataDisplay/Avatar.stories.tsx +251 -0
  139. package/dist/stories/DataDisplay/Badge.stories.tsx +176 -0
  140. package/dist/stories/DataDisplay/Card.stories.tsx +406 -0
  141. package/dist/stories/DataDisplay/Chip.stories.tsx +495 -0
  142. package/dist/stories/DataDisplay/Indicator.stories.tsx +571 -0
  143. package/dist/stories/DataDisplay/List.stories.tsx +376 -0
  144. package/dist/stories/DataDisplay/Pill.stories.tsx +506 -0
  145. package/dist/stories/DataDisplay/Progress.stories.tsx +352 -0
  146. package/dist/stories/DataDisplay/Table.stories.tsx +346 -0
  147. package/dist/stories/DataDisplay/ThemeIcon.stories.tsx +125 -0
  148. package/dist/stories/Inputs/Checkbox.stories.tsx +263 -0
  149. package/dist/stories/Inputs/ColorInput.stories.tsx +434 -0
  150. package/dist/stories/Inputs/DropZone.stories.tsx +401 -0
  151. package/dist/stories/Inputs/FileInput.stories.tsx +383 -0
  152. package/dist/stories/Inputs/NumberInput.stories.tsx +342 -0
  153. package/dist/stories/Inputs/Radio.stories.tsx +437 -0
  154. package/dist/stories/Inputs/RadioGroup.stories.tsx +526 -0
  155. package/dist/stories/Inputs/SegmentedControl.stories.tsx +60 -0
  156. package/dist/stories/Inputs/Slider.stories.tsx +22 -0
  157. package/dist/stories/Inputs/SliderWithLabel.stories.tsx +37 -0
  158. package/dist/stories/Inputs/Switch.stories.tsx +361 -0
  159. package/dist/stories/Inputs/TextArea.stories.tsx +355 -0
  160. package/dist/stories/Inputs/TextInput.stories.tsx +266 -0
  161. package/dist/stories/Misc/Divider.stories.tsx +581 -0
  162. package/dist/stories/Misc/Paper.stories.tsx +557 -0
  163. package/dist/stories/Navigation/Breadcrumb.stories.tsx +489 -0
  164. package/dist/stories/Navigation/NavLink.stories.tsx +601 -0
  165. package/dist/stories/Navigation/Stepper.stories.tsx +413 -0
  166. package/dist/stories/Navigation/Tabs.stories.tsx +528 -0
  167. package/dist/stories/Overlays/Drawer.stories.tsx +802 -0
  168. package/dist/stories/Overlays/Menu.stories.tsx +941 -0
  169. package/dist/stories/Overlays/Modal.stories.tsx +249 -0
  170. package/dist/stories/Overlays/Popover.stories.tsx +780 -0
  171. package/dist/stories/Overlays/Tooltip.stories.tsx +52 -0
  172. package/dist/stories/Typography/Code.stories.tsx +368 -0
  173. package/dist/stories/Typography/Kbd.stories.tsx +514 -0
  174. package/dist/stories/Typography/Text.stories.tsx +117 -0
  175. package/dist/stories/Typography/Title.stories.tsx +112 -0
  176. package/dist/stories/index.json +1435 -0
  177. package/dist/types.js +127 -0
  178. package/package.json +12 -7
  179. package/dist/ComplexComponents/PageContentHeader/DescriptionBlock.tsx +0 -65
package/README.md CHANGED
@@ -2,12 +2,92 @@
2
2
 
3
3
  AppDirect Design System components. Thin wrappers around Mantine v9.
4
4
 
5
- Peer dependencies: `@mantine/core`, `@mantine/dates`, `@mantine/hooks`, `react`, and `react-dom` at the versions declared by this package.
5
+ ## Install
6
6
 
7
- CSS variables come from `@appdirect/ad-design-tokens`:
7
+ ```bash
8
+ npm install @appdirect/design-system
9
+ ```
10
+
11
+ Peer dependencies (install at the versions declared by this package):
12
+
13
+ - `react`, `react-dom`
14
+ - `@mantine/core`, `@mantine/dates`, `@mantine/hooks`
15
+
16
+ ## What ships in the package
17
+
18
+ | What | Path / export | Use for |
19
+ | --- | --- | --- |
20
+ | Runtime JS | `main` / `exports["."].default` → `dist/index.js` | App and bundler imports |
21
+ | TypeScript source | `exports["."].types` → `dist/index.ts` (+ component `.ts`/`.tsx`) | Editor types; do not point bundlers at these for runtime |
22
+ | Token CSS | `@appdirect/design-system/css/foundations.css`, `.../mantine.css` | Theme variables (`--ad-*`) |
23
+ | Config / shared types | `@appdirect/design-system/config`, `@appdirect/design-system/types` | Scales, variant unions |
24
+ | Stories (source) | `@appdirect/design-system/stories`, `.../stories/*` | Agent / designer reference patterns (`add-feature`) |
25
+ | Contracts | `@appdirect/design-system/contracts`, `.../contracts/*` | `ds-audit` and enforcement |
26
+ | CLI | `ds-audit` | Audit a prototype or app against contracts |
27
+
28
+ Bundlers (Rspack, webpack, Vite, Next) should resolve the package entry to **`.js`**. You do **not** need `transpilePackages` / SWC includes for this package’s TypeScript. Keep loading `*.module.css` from the package with your CSS-modules rule.
29
+
30
+ ## App usage
31
+
32
+ Load token CSS once near the app root (standalone prototypes often use this package’s CSS re-exports; the tokens package is the same files):
8
33
 
9
34
  ```tsx
10
- import '@appdirect/ad-design-tokens/css/foundations.css';
11
- import '@appdirect/ad-design-tokens/css/mantine.css';
12
- import { Button, TextInput, Stack } from '@appdirect/design-system';
35
+ import '@appdirect/design-system/css/foundations.css';
36
+ import '@appdirect/design-system/css/mantine.css';
37
+ // or:
38
+ // import '@appdirect/ad-design-tokens/css/foundations.css';
39
+ // import '@appdirect/ad-design-tokens/css/mantine.css';
40
+ ```
41
+
42
+ Import product UI from this package, not raw `@mantine/core`, when a DS wrapper exists:
43
+
44
+ ```tsx
45
+ import { Button, TextInput, Stack, Card, PageContentHeader } from '@appdirect/design-system';
46
+
47
+ export function Example() {
48
+ return (
49
+ <Stack gap="md">
50
+ <PageContentHeader title="Invoices" description="Open billing period" />
51
+ <Card padding="md">
52
+ <TextInput label="Search" />
53
+ <Button variant="primary">Save</Button>
54
+ </Card>
55
+ </Stack>
56
+ );
57
+ }
58
+ ```
59
+
60
+ Use AppDirect button variants (`primary`, `secondary`, `default`, `outline`, `danger`, `link`, `secret`), not Mantine `filled` / `light` / `subtle`. Prefer `--ad-*` tokens for colour; avoid palette props like `color="blue"`.
61
+
62
+ Shared helpers:
63
+
64
+ ```ts
65
+ import { /* sizes, etc. */ } from '@appdirect/design-system/config';
66
+ import type { DSButtonVariant } from '@appdirect/design-system/types';
67
+ ```
68
+
69
+ ## Stories (tooling only)
70
+
71
+ Storybook stories ship as **reference source** under `dist/stories/`. They are not a runtime export of React components.
72
+
73
+ ```ts
74
+ // Index of every story: title, component, description, story names, imports
75
+ import stories from '@appdirect/design-system/stories';
76
+ // or open files via the package export:
77
+ // @appdirect/design-system/stories/Buttons/Button.stories.tsx
13
78
  ```
79
+
80
+ Prototype agents (`add-feature`) read `node_modules/@appdirect/design-system/dist/stories/` (and the `stories` export) to copy composition patterns. The build fails when a story imports a Mantine component the design system has not adopted.
81
+
82
+ ## Contracts and `ds-audit`
83
+
84
+ ```bash
85
+ npx ds-audit
86
+ # or: ./node_modules/.bin/ds-audit
87
+ ```
88
+
89
+ Contracts live at `@appdirect/design-system/contracts` (index) and `@appdirect/design-system/contracts/<id>`. Use them with `@appdirect/ds-enforce` ESLint rules in apps that adopt the system.
90
+
91
+ ## Provider note
92
+
93
+ `MantineProvider` / theme setup stays in the host app (for example `src/providers/` in micro-ui / prototype apps). This package does not export a provider.
@@ -0,0 +1,14 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from 'react';
4
+ import { ActionIcon as MantineActionIcon } from '@mantine/core';
5
+ const variantMap = {
6
+ default: { variant: 'light', color: 'blue' },
7
+ outline: { variant: 'default', color: 'gray' },
8
+ link: { variant: 'subtle', color: 'blue' },
9
+ };
10
+ export const ActionIcon = forwardRef(({ variant = 'default', ...props }, ref) => {
11
+ const mapped = variantMap[variant];
12
+ return (_jsx(MantineActionIcon, { ref: ref, variant: mapped.variant, color: mapped.color, radius: "sm", ...props }));
13
+ });
14
+ ActionIcon.displayName = 'ActionIcon';
@@ -0,0 +1,66 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import React, { forwardRef } from 'react';
4
+ import { Button as MantineButton } from '@mantine/core';
5
+ import styles from './Button.module.css';
6
+ /**
7
+ * AppDirect Design System Button Component
8
+ *
9
+ * A enhanced button component built on top of Mantine's Button with
10
+ * consistent design system styling and additional functionality.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * // Basic usage
15
+ * <Button>Click me</Button>
16
+ *
17
+ * // Primary button with icon
18
+ * <Button variant="primary" leftSection={<Icon />}>
19
+ * Save Changes
20
+ * </Button>
21
+ *
22
+ * // Loading state
23
+ * <Button loading>Processing...</Button>
24
+ * ```
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * // Different variants
29
+ * <Button variant="primary">Primary</Button>
30
+ * <Button variant="secondary">Secondary</Button>
31
+ * <Button variant="default">Default</Button>
32
+ * <Button variant="outline">Outline</Button>
33
+ * <Button variant="danger">Danger</Button>
34
+ * <Button variant="link">Link</Button>
35
+ * <Button variant="secret">Secret</Button>
36
+ * <Button variant="disabled">Disabled</Button>
37
+ * ```
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * // Sizes and colors
42
+ * <ADDSButton size="sm" color="primary">Small Primary</ADDSButton>
43
+ * <ADDSButton size="lg" color="secondary">Large Secondary</ADDSButton>
44
+ * <ADDSButton fullWidth>Full Width Button</ADDSButton>
45
+ * ```
46
+ */
47
+ export const Button = forwardRef(({ variant = 'default', size = 'sm', className, children, leftSection, rightSection, ...props }, ref) => {
48
+ // Pass our DS variant name directly — mantine.css adapter targets
49
+ // data-variant="primary" etc. via higher-specificity selectors.
50
+ // "disabled" is a state, not a Mantine variant, so map it to "default".
51
+ const mantineVariant = variant === 'disabled' ? 'default' : (variant ?? 'default');
52
+ // Determine if button should be disabled
53
+ const isDisabled = props.disabled || variant === 'disabled';
54
+ // Generate component class names
55
+ const componentClassName = [
56
+ styles.addsButton,
57
+ styles[`addsButton--${variant}`],
58
+ styles[`addsButton--${size}`],
59
+ leftSection && styles.hasLeftSection,
60
+ className,
61
+ ]
62
+ .filter(Boolean)
63
+ .join(' ');
64
+ return (_jsx(MantineButton, { ref: ref, variant: mantineVariant, size: size, disabled: isDisabled, radius: "sm", className: componentClassName, leftSection: leftSection, rightSection: rightSection, ...props, children: children }));
65
+ });
66
+ Button.displayName = 'Button';
@@ -0,0 +1,48 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from 'react';
4
+ import { CloseButton as MantineCloseButton } from '@mantine/core';
5
+ // Size configurations
6
+ const sizeConfig = {
7
+ xs: {
8
+ size: 20,
9
+ iconSize: 10,
10
+ },
11
+ sm: {
12
+ size: 24,
13
+ iconSize: 12,
14
+ },
15
+ md: {
16
+ size: 28,
17
+ iconSize: 14,
18
+ },
19
+ lg: {
20
+ size: 32,
21
+ iconSize: 16,
22
+ },
23
+ xl: {
24
+ size: 36,
25
+ iconSize: 18,
26
+ },
27
+ };
28
+ export const CloseButton = forwardRef(({ size = 'md', color = 'black', disabled = false, style, ...others }, ref) => {
29
+ const config = sizeConfig[size];
30
+ // Define the color styling (let Mantine handle hover backgrounds)
31
+ const iconColor = disabled
32
+ ? 'var(--ad-color-state-disabled-text)'
33
+ : color === 'blue'
34
+ ? 'var(--ad-color-brand-primary)'
35
+ : color === 'gray'
36
+ ? 'var(--ad-color-text-dimmed)'
37
+ : 'var(--ad-color-text-default)';
38
+ return (_jsx(MantineCloseButton, { ref: ref, variant: "subtle", size: config.size, disabled: disabled, style: {
39
+ color: iconColor,
40
+ borderRadius: 'var(--mantine-radius-sm)',
41
+ minWidth: config.size,
42
+ minHeight: config.size,
43
+ width: config.size,
44
+ height: config.size,
45
+ ...style,
46
+ }, ...others }));
47
+ });
48
+ CloseButton.displayName = 'CloseButton';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Buttons AppDirect Design System Components
3
+ *
4
+ * This module exports all button-related components from the design system.
5
+ */
6
+ export { Button } from './Button.js';
7
+ export { ActionIcon } from './ActionIcon.js';
8
+ export { CloseButton } from './CloseButton.js';
9
+ // Future button component exports will go here:
10
+ // export { ADDSActionIcon } from './ActionIcon.js';
11
+ // export { ADDSCloseButton } from './CloseButton.js';
12
+ // export type { ADDSActionIconProps } from './ActionIcon.js';
13
+ // export type { ADDSCloseButtonProps } from './CloseButton.js';
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import { CloseButton, Combobox, TextInput, useCombobox } from '@mantine/core';
5
+ const countries = [
6
+ 'United States',
7
+ 'Canada',
8
+ 'United Kingdom',
9
+ 'Germany',
10
+ 'France',
11
+ 'Australia',
12
+ 'Japan',
13
+ 'Singapore',
14
+ ];
15
+ export function AutocompleteClearable({ label, placeholder = "Pick a country or type anything", data = countries, description, error, required = false, showOptional = false, disabled = false, size = 'md', style, ...props }) {
16
+ const combobox = useCombobox();
17
+ const [value, setValue] = useState('');
18
+ // Convert data to consistent format
19
+ const normalizedData = data.map(item => typeof item === 'string' ? { value: item, label: item } : item);
20
+ const shouldFilterOptions = !normalizedData.some((item) => item.value === value);
21
+ const filteredOptions = shouldFilterOptions
22
+ ? normalizedData.filter((item) => item.label.toLowerCase().includes(value.toLowerCase().trim()) ||
23
+ item.value.toLowerCase().includes(value.toLowerCase().trim()))
24
+ : normalizedData;
25
+ const options = filteredOptions.map((item) => (_jsx(Combobox.Option, { value: item.value, children: item.label }, item.value)));
26
+ return (_jsx("div", { style: style, children: _jsxs(Combobox, { onOptionSubmit: (optionValue) => {
27
+ setValue(optionValue);
28
+ combobox.closeDropdown();
29
+ }, store: combobox, withinPortal: false, children: [_jsx(Combobox.Target, { children: _jsx(TextInput, { label: label, description: description, error: error, required: required, size: size, disabled: disabled, placeholder: placeholder, value: value, onChange: (event) => {
30
+ setValue(event.currentTarget.value);
31
+ combobox.openDropdown();
32
+ combobox.updateSelectedOptionIndex();
33
+ }, onClick: () => combobox.openDropdown(), onFocus: () => combobox.openDropdown(), onBlur: () => combobox.closeDropdown(), withAsterisk: required && !showOptional, ...(showOptional && !required && {
34
+ label: label ? `${label} (optional)` : undefined
35
+ }), rightSection: value !== '' && !disabled && (_jsx(CloseButton, { size: "sm", onMouseDown: (event) => event.preventDefault(), onClick: () => setValue(''), "aria-label": "Clear value" })) }) }), _jsx(Combobox.Dropdown, { children: _jsx(Combobox.Options, { children: options.length === 0 ? _jsx(Combobox.Empty, { children: "Nothing found" }) : options }) })] }) }));
36
+ }
@@ -0,0 +1,28 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import React, { forwardRef } from 'react';
4
+ import { Select } from './Select.js';
5
+ // ========================== COMPONENT ==========================
6
+ /**
7
+ * AppDirect Design System Combobox Component
8
+ *
9
+ * Identical to Select — a single-selection dropdown built on Mantine's Select
10
+ * with DS defaults (radius, IconSelector, label enhancements). This component
11
+ * exists as a separate identity for Figma Code Connect, where the Combobox
12
+ * Figma component maps to this wrapper.
13
+ *
14
+ * For basic single-select use cases, use either Select or Combobox.
15
+ * For advanced use cases, use SearchableSelect or build on Mantine's
16
+ * Combobox primitives directly.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * <Combobox
21
+ * data={['Option 1', 'Option 2', 'Option 3']}
22
+ * placeholder="Select option"
23
+ * label="Choose an option"
24
+ * />
25
+ * ```
26
+ */
27
+ export const Combobox = forwardRef((props, ref) => _jsx(Select, { ref: ref, ...props }));
28
+ Combobox.displayName = 'Combobox';
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import { Checkbox, Combobox, Input, Pill as MantinePill, PillsInput, useCombobox, InputWrapper } from '@mantine/core';
5
+ import { Inline } from '../index.js';
6
+ import { Pill } from '../DataDisplay/Pill.js';
7
+ const technologies = ['React', 'Vue', 'Angular', 'Node.js', 'Docker', 'Kubernetes', 'AWS', 'MongoDB'];
8
+ const MAX_DISPLAYED_VALUES = 2;
9
+ export function Multiselect({ label, placeholder = "Pick one or more technologies", data = technologies, description, error, required = false, showOptional = false, disabled = false, searchable = true, size = 'md', style, maxDisplayedValues = MAX_DISPLAYED_VALUES, ...props }) {
10
+ const combobox = useCombobox({
11
+ onDropdownClose: () => combobox.resetSelectedOption(),
12
+ onDropdownOpen: () => combobox.updateSelectedOptionIndex('active'),
13
+ });
14
+ const [value, setValue] = useState([]);
15
+ const handleValueSelect = (val) => setValue((current) => current.includes(val) ? current.filter((v) => v !== val) : [...current, val]);
16
+ const handleValueRemove = (val) => setValue((current) => current.filter((v) => v !== val));
17
+ const values = value
18
+ .slice(0, maxDisplayedValues === value.length ? maxDisplayedValues : maxDisplayedValues - 1)
19
+ .map((item) => (_jsx(Pill, { withRemoveButton: true, onRemove: () => handleValueRemove(item), size: size, children: item }, item)));
20
+ // Convert data to consistent format
21
+ const normalizedData = data.map(item => typeof item === 'string' ? { value: item, label: item } : item);
22
+ const options = normalizedData.map((item) => (_jsx(Combobox.Option, { value: item.value, active: value.includes(item.value), children: _jsxs(Inline, { gap: "sm", children: [_jsx(Checkbox, { checked: value.includes(item.value), onChange: () => { }, "aria-hidden": true, tabIndex: -1, style: { pointerEvents: 'none' } }), _jsx("span", { children: item.label })] }) }, item.value)));
23
+ // Determine the display label
24
+ const displayLabel = showOptional && !required && label ? `${label} (optional)` : label;
25
+ return (_jsx("div", { style: style, children: _jsx(InputWrapper, { label: displayLabel, description: description, error: error, required: required && !showOptional, size: size, withAsterisk: required && !showOptional, children: _jsxs(Combobox, { store: combobox, onOptionSubmit: handleValueSelect, withinPortal: false, disabled: disabled, children: [_jsx(Combobox.DropdownTarget, { children: _jsx(PillsInput, { pointer: true, onClick: () => !disabled && combobox.toggleDropdown(), size: size, disabled: disabled, error: !!error, children: _jsxs(MantinePill.Group, { children: [value.length > 0 ? (_jsxs(_Fragment, { children: [values, value.length > maxDisplayedValues && (_jsxs(Pill, { size: size, children: ["+", value.length - (maxDisplayedValues - 1), " more"] }))] })) : (_jsx(Input.Placeholder, { children: placeholder })), _jsx(Combobox.EventsTarget, { children: _jsx(PillsInput.Field, { type: "hidden", onBlur: () => combobox.closeDropdown(), onKeyDown: (event) => {
26
+ if (event.key === 'Backspace' && !disabled) {
27
+ event.preventDefault();
28
+ handleValueRemove(value[value.length - 1]);
29
+ }
30
+ }, disabled: disabled }) })] }) }) }), _jsx(Combobox.Dropdown, { children: _jsx(Combobox.Options, { children: options }) })] }) }) }));
31
+ }
@@ -0,0 +1,43 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import { Combobox, InputBase, useCombobox } from '@mantine/core';
5
+ const languages = [
6
+ 'JavaScript',
7
+ 'TypeScript',
8
+ 'Python',
9
+ 'Java',
10
+ 'C++',
11
+ 'Go',
12
+ 'Rust',
13
+ 'Swift',
14
+ ];
15
+ export function SearchableSelect({ label, placeholder = "Search programming languages", data = languages, description, error, required = false, showOptional = false, disabled = false, searchable = true, size = 'md', style, ...props }) {
16
+ const combobox = useCombobox({
17
+ onDropdownClose: () => combobox.resetSelectedOption(),
18
+ });
19
+ const [value, setValue] = useState(null);
20
+ const [search, setSearch] = useState('');
21
+ // Convert data to consistent format
22
+ const normalizedData = data.map(item => typeof item === 'string' ? { value: item, label: item } : item);
23
+ const shouldFilterOptions = normalizedData.every((item) => item.value !== search);
24
+ const filteredOptions = shouldFilterOptions && searchable
25
+ ? normalizedData.filter((item) => item.label.toLowerCase().includes(search.toLowerCase().trim()) ||
26
+ item.value.toLowerCase().includes(search.toLowerCase().trim()))
27
+ : normalizedData;
28
+ const options = filteredOptions.map((item) => (_jsx(Combobox.Option, { value: item.value, children: item.label }, item.value)));
29
+ return (_jsx("div", { style: style, children: _jsxs(Combobox, { store: combobox, withinPortal: false, onOptionSubmit: (val) => {
30
+ setValue(val);
31
+ setSearch(val);
32
+ combobox.closeDropdown();
33
+ }, children: [_jsx(Combobox.Target, { children: _jsx(InputBase, { label: label, description: description, error: error, required: required, size: size, disabled: disabled, rightSection: _jsx(Combobox.Chevron, {}), value: search, onChange: (event) => {
34
+ combobox.openDropdown();
35
+ combobox.updateSelectedOptionIndex();
36
+ setSearch(event.currentTarget.value);
37
+ }, onClick: () => combobox.openDropdown(), onFocus: () => combobox.openDropdown(), onBlur: () => {
38
+ combobox.closeDropdown();
39
+ setSearch(value || '');
40
+ }, placeholder: placeholder, rightSectionPointerEvents: "none", withAsterisk: required && !showOptional, ...(showOptional && !required && {
41
+ label: label ? `${label} (optional)` : undefined
42
+ }) }) }), _jsx(Combobox.Dropdown, { children: _jsx(Combobox.Options, { children: options.length > 0 ? options : _jsx(Combobox.Empty, { children: "Nothing found" }) }) })] }) }));
43
+ }
@@ -0,0 +1,72 @@
1
+ 'use client';
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import React, { forwardRef } from 'react';
4
+ import { Select as MantineSelect, ActionIcon, Group } from '@mantine/core';
5
+ import { IconInfoCircle, IconSelector } from '@tabler/icons-react';
6
+ import { Text } from '../Typography/Text.js';
7
+ import { Tooltip } from '../Overlays/Tooltip.js';
8
+ // ========================== COMPONENT ==========================
9
+ /**
10
+ * AppDirect Design System Select Component
11
+ *
12
+ * A select/dropdown component built on top of Mantine's Select with
13
+ * consistent design system styling and enforced radius. Supports both
14
+ * regular and borderless styles for different use cases.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * // Basic usage
19
+ * <Select
20
+ * data={['Option 1', 'Option 2', 'Option 3']}
21
+ * placeholder="Select option"
22
+ * label="Choose an option"
23
+ * />
24
+ * ```
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * // Borderless select for dashboard widgets
29
+ * <Select
30
+ * data={[
31
+ * { value: 'today', label: 'Today' },
32
+ * { value: 'week', label: 'This Week' },
33
+ * { value: 'month', label: 'This Month' },
34
+ * ]}
35
+ * value={period}
36
+ * onChange={setPeriod}
37
+ * borderless
38
+ * searchable
39
+ * clearable
40
+ * />
41
+ * ```
42
+ *
43
+ * @example
44
+ * ```tsx
45
+ * // With help icon and optional label
46
+ * <Select
47
+ * data={['Admin', 'Editor', 'Viewer']}
48
+ * label="Role"
49
+ * showOptional
50
+ * hasHelpIcon
51
+ * helpIconLabel="Select the user's permission level"
52
+ * />
53
+ * ```
54
+ */
55
+ export const Select = forwardRef(({ size = 'sm', borderless = false, showOptional = false, required, label, hasHelpIcon = false, helpIconLabel, onHelpIconClick, error, errorCaption, variant, ...props }, ref) => {
56
+ const effectiveError = error === true ? (errorCaption ?? true) : error;
57
+ const enhancedLabel = React.useMemo(() => {
58
+ if (!label)
59
+ return label;
60
+ if (showOptional && !required) {
61
+ return (_jsxs(_Fragment, { children: [label, " ", _jsx(Text, { span: true, c: "dimmed", fw: "normal", children: "(Optional)" })] }));
62
+ }
63
+ return label;
64
+ }, [label, showOptional, required]);
65
+ const helpIconElement = hasHelpIcon ? (_jsx(Tooltip, { label: helpIconLabel ?? 'Help', position: "top", withArrow: true, children: _jsx(ActionIcon, { variant: "transparent", size: "xs", "aria-label": helpIconLabel ?? 'Help', onClick: onHelpIconClick, color: "gray", style: { cursor: onHelpIconClick ? 'pointer' : 'default' }, children: _jsx(IconInfoCircle, { size: 14, "aria-hidden": true }) }) })) : null;
66
+ const selectorIcon = _jsx(IconSelector, { size: 14, "aria-hidden": true });
67
+ const composedRightSection = helpIconElement
68
+ ? _jsxs(Group, { gap: 4, wrap: "nowrap", children: [selectorIcon, helpIconElement] })
69
+ : selectorIcon;
70
+ return (_jsx(MantineSelect, { ref: ref, size: size, radius: "sm", required: required, label: enhancedLabel, rightSection: composedRightSection, rightSectionPointerEvents: hasHelpIcon || props.clearable ? 'auto' : 'none', variant: borderless ? 'unstyled' : (variant ?? 'default'), error: effectiveError, ...props }));
71
+ });
72
+ Select.displayName = 'Select';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Combobox Components
3
+ *
4
+ * Collection of combobox/select components with different behaviors and use cases.
5
+ */
6
+ export { SearchableSelect } from './SearchableSelect.js';
7
+ export { AutocompleteClearable } from './AutocompleteClearable.js';
8
+ export { Multiselect } from './Multiselect.js';
9
+ export { Select } from './Select.js';
10
+ export { Combobox } from './Combobox.js';
@@ -0,0 +1,96 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import React from 'react';
4
+ import { Card } from '../../DataDisplay/Card.js';
5
+ import { Alert } from '../../DataDisplay/Alert.js';
6
+ import { Stack, Inline, Box } from '../../Layout/index.js';
7
+ import { Title } from '../../Typography/Title.js';
8
+ import { Text } from '../../Typography/Text.js';
9
+ import { Switch } from '../../Inputs/Switch.js';
10
+ import { Select } from '../../Combobox/Select.js';
11
+ import { Menu } from '../../Overlays/Menu.js';
12
+ import { ActionIcon } from '../../Buttons/ActionIcon.js';
13
+ import { RiMore2Fill, RiArrowRightSLine, RiEditLine } from '@remixicon/react';
14
+ // ========================== COMPONENT ==========================
15
+ /**
16
+ * DashboardWidget Component
17
+ *
18
+ * A flexible widget container for dashboard content with optional controls.
19
+ * Built on top of the Card component with consistent spacing and styling.
20
+ *
21
+ * @example
22
+ * // Basic widget with content
23
+ * <DashboardWidget title="A widget title">
24
+ * <Text>This is a slot. To use it:</Text>
25
+ * <ul>
26
+ * <li>Create a local component with autolayout on</li>
27
+ * <li>Switch out this slot with that component using the component instance switcher</li>
28
+ * </ul>
29
+ * </DashboardWidget>
30
+ *
31
+ * @example
32
+ * // Widget with all features
33
+ * <DashboardWidget
34
+ * title="Analytics Widget"
35
+ * switch={{
36
+ * label: "Live updates",
37
+ * checked: true,
38
+ * onChange: (checked) => console.log(checked)
39
+ * }}
40
+ * actionsMenu={{
41
+ * sections: [{
42
+ * items: [
43
+ * { label: "Export", onClick: () => console.log("Export") },
44
+ * { label: "Settings", onClick: () => console.log("Settings") }
45
+ * ]
46
+ * }]
47
+ * }}
48
+ * headerSelect={{
49
+ * placeholder: "Select filter",
50
+ * data: ["Option 1", "Option 2", "Option 3"],
51
+ * onChange: (value) => console.log(value)
52
+ * }}
53
+ * footerLinks={[
54
+ * { label: "Link 1", onClick: () => console.log("Link 1") },
55
+ * { label: "Link 2", onClick: () => console.log("Link 2") },
56
+ * { label: "Link 3", onClick: () => console.log("Link 3") }
57
+ * ]}
58
+ * >
59
+ * <YourCustomContent />
60
+ * </DashboardWidget>
61
+ */
62
+ export function DashboardWidget({ title, editable = false, onEdit, panelNotification = false, panelNotificationMessage, switch: switchConfig, actionsMenu, children, headerSelect, footerLinks, cardProps = {}, spacing = 'xs', }) {
63
+ // ==================== RENDER FUNCTIONS ==========================
64
+ const renderHeader = () => (_jsxs(Inline, { justify: "space-between", align: "flex-start", children: [_jsx(Stack, { gap: "xs", children: _jsxs(Inline, { gap: "xs", align: "center", children: [_jsx(Title, { order: 4, children: title }), editable && (_jsx(ActionIcon, { size: "sm", onClick: onEdit, "aria-label": "Edit title", children: _jsx(RiEditLine, { size: 16 }) }))] }) }), _jsxs(Inline, { gap: "sm", align: "center", children: [switchConfig && (_jsxs(Inline, { gap: "xs", align: "center", children: [_jsx(Text, { size: "sm", children: switchConfig.label }), _jsx(Switch, { checked: switchConfig.checked, onChange: (event) => switchConfig.onChange(event.currentTarget.checked), disabled: switchConfig.disabled, size: "sm" })] })), headerSelect && (_jsx(Select, { data: headerSelect.data, value: headerSelect.value, onChange: headerSelect.onChange, placeholder: headerSelect.placeholder, disabled: headerSelect.disabled, searchable: headerSelect.searchable, clearable: headerSelect.clearable, borderless: true, size: "sm" })), actionsMenu && !headerSelect && (_jsx(Menu, { trigger: _jsx(ActionIcon, { size: "sm", "aria-label": "Widget actions", children: _jsx(RiMore2Fill, { size: 16 }) }), position: "bottom-end", sections: actionsMenu.sections }))] })] }));
65
+ const renderFooterLinks = () => {
66
+ return (_jsx(Box, { p: "sm", pl: "lg", pr: "lg", children: footerLinks && footerLinks.length > 0 ? (_jsx(Inline, { gap: "xs", children: footerLinks.map((link, index) => (_jsxs(Inline, { gap: "xs", align: "center", onClick: link.disabled ? undefined : link.onClick, style: {
67
+ cursor: link.disabled ? 'not-allowed' : 'pointer',
68
+ opacity: link.disabled ? 0.5 : 1,
69
+ color: link.disabled ? 'var(--ad-color-text-dimmed)' : 'var(--ad-color-brand-primary)',
70
+ transition: 'color 0.2s ease',
71
+ }, children: [_jsx(Text, { size: "sm", c: link.disabled ? 'dimmed' : 'blue', children: link.label }), _jsx(RiArrowRightSLine, { size: 14 })] }, index))) })) : (
72
+ // Empty footer that maintains the same height
73
+ _jsx(Box, { style: { height: '21px' } })) }));
74
+ };
75
+ // ==================== MAIN RENDER ==========================
76
+ return (_jsxs(Card, { ...cardProps, pl: "lg", pr: "lg", pt: "sm", pb: 0, style: {
77
+ position: 'relative',
78
+ height: '100%',
79
+ overflow: 'hidden',
80
+ ...cardProps.style,
81
+ }, children: [_jsxs(Stack, { gap: spacing, style: {
82
+ height: '100%',
83
+ paddingBottom: '60px', // Space for fixed footer
84
+ }, children: [renderHeader(), panelNotification && (_jsx(Alert, { color: "info", children: panelNotificationMessage })), _jsx(Box, { style: {
85
+ flex: 1,
86
+ overflowY: 'auto',
87
+ overflowX: 'hidden',
88
+ paddingRight: '4px', // Space for scrollbar
89
+ }, children: children })] }), _jsx("div", { style: {
90
+ position: 'absolute',
91
+ bottom: 0,
92
+ left: 0,
93
+ right: 0,
94
+ backgroundColor: 'var(--ad-color-bg-default)',
95
+ }, children: renderFooterLinks() })] }));
96
+ }
@@ -0,0 +1 @@
1
+ export { DashboardWidget } from './DashboardWidget.js';