@appdirect/design-system 0.0.22 → 0.0.25

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 (65) hide show
  1. package/README.md +1 -1
  2. package/dist/Combobox/ADMultiselect.js +91 -0
  3. package/dist/Combobox/ADMultiselect.tsx +237 -0
  4. package/dist/Combobox/AutocompleteClearable.js +33 -35
  5. package/dist/Combobox/AutocompleteClearable.tsx +56 -121
  6. package/dist/Combobox/SearchableSelect.js +23 -42
  7. package/dist/Combobox/SearchableSelect.tsx +33 -129
  8. package/dist/Combobox/Select.js +13 -19
  9. package/dist/Combobox/Select.tsx +15 -44
  10. package/dist/Combobox/index.js +1 -1
  11. package/dist/Combobox/index.ts +2 -2
  12. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/CustomBottomToolbar.module.css +1 -24
  13. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +2 -5
  14. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.tsx +15 -22
  15. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +1 -2
  16. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.module.css +2 -9
  17. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.tsx +4 -5
  18. package/dist/ComplexComponents/DataTable/DataTableGrid/DataTableGrid.module.css +2 -6
  19. package/dist/ComplexComponents/DataTable/DataTableGrid/index.js +1 -1
  20. package/dist/ComplexComponents/DataTable/DataTableGrid/index.tsx +1 -1
  21. package/dist/ComplexComponents/Utilities/CopyButton.js +15 -27
  22. package/dist/ComplexComponents/Utilities/CopyButton.tsx +35 -49
  23. package/dist/DESIGN.md +7 -7
  24. package/dist/DataDisplay/Avatar.js +26 -81
  25. package/dist/DataDisplay/Avatar.tsx +35 -93
  26. package/dist/DataDisplay/Pill.js +21 -79
  27. package/dist/DataDisplay/Pill.tsx +34 -116
  28. package/dist/Inputs/ColorInput.js +12 -18
  29. package/dist/Inputs/ColorInput.tsx +13 -41
  30. package/dist/Inputs/NumberInput.js +15 -50
  31. package/dist/Inputs/NumberInput.tsx +18 -117
  32. package/dist/Inputs/Radio.js +1 -1
  33. package/dist/Inputs/Radio.tsx +1 -1
  34. package/dist/Inputs/RadioGroup.js +1 -1
  35. package/dist/Inputs/RadioGroup.tsx +1 -1
  36. package/dist/Inputs/TextArea.js +12 -18
  37. package/dist/Inputs/TextArea.tsx +13 -41
  38. package/dist/Inputs/TextInput.js +12 -18
  39. package/dist/Inputs/TextInput.tsx +13 -41
  40. package/dist/Inputs/inputLabel.js +35 -0
  41. package/dist/Inputs/inputLabel.tsx +83 -0
  42. package/dist/Layout/Inline.js +5 -42
  43. package/dist/Layout/Inline.tsx +6 -79
  44. package/dist/Overlays/Tooltip.js +2 -2
  45. package/dist/Overlays/Tooltip.tsx +4 -1
  46. package/dist/contracts/index.json +1 -1
  47. package/dist/css/foundations.css +44 -2
  48. package/dist/css/mantine.css +236 -43
  49. package/dist/css/tokens.css +58 -26
  50. package/dist/index.js +3 -3
  51. package/dist/index.ts +4 -4
  52. package/dist/stories/Combobox/{Multiselect.stories.tsx → ADMultiselect.stories.tsx} +159 -53
  53. package/dist/stories/Combobox/SearchableSelect.stories.tsx +3 -3
  54. package/dist/stories/Combobox/Select.stories.tsx +1 -1
  55. package/dist/stories/ComplexComponents/Utilities/CopyButton.stories.tsx +4 -14
  56. package/dist/stories/Inputs/ColorInput.stories.tsx +12 -0
  57. package/dist/stories/Inputs/NumberInput.stories.tsx +12 -0
  58. package/dist/stories/Inputs/Radio.stories.tsx +10 -5
  59. package/dist/stories/Inputs/RadioGroup.stories.tsx +122 -80
  60. package/dist/stories/Inputs/TextArea.stories.tsx +12 -0
  61. package/dist/stories/Inputs/TextInput.stories.tsx +12 -0
  62. package/dist/stories/index.json +42 -35
  63. package/package.json +10 -6
  64. package/dist/Combobox/Multiselect.js +0 -31
  65. package/dist/Combobox/Multiselect.tsx +0 -158
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
- import React, { useState } from 'react';
4
- import { ActionIcon } from '@mantine/core';
3
+ import React from 'react';
4
+ import { ActionIcon, CopyButton as MantineCopyButton } from '@mantine/core';
5
5
  import { Tooltip } from '../../Overlays/Tooltip';
6
6
  import { RiFileCopyLine } from '@remixicon/react';
7
7
 
@@ -10,36 +10,30 @@ export interface CopyButtonProps {
10
10
  value: string;
11
11
  /** Label for accessibility and tooltip context */
12
12
  label: string;
13
- /** Callback when copy action is performed */
13
+ /** Called with the value after it has been copied (for analytics or toasts; copying is already done) */
14
14
  onCopy?: (value: string) => void;
15
15
  /** Size of the copy icon */
16
16
  iconSize?: number;
17
+ /** Time in ms the "Copied" state stays visible */
18
+ timeout?: number;
17
19
  }
18
20
 
19
21
  /**
20
22
  * CopyButton Component
21
- *
22
- * A reusable button component with copy-to-clipboard functionality and interactive tooltips.
23
- * Shows "Copy" on hover and "Copied" after clicking, resetting when cursor leaves.
24
- *
23
+ *
24
+ * Built on Mantine's `CopyButton`: clicking writes `value` to the clipboard and the
25
+ * tooltip switches from "Copy" to "Copied" for `timeout` ms.
26
+ *
25
27
  * @example
26
- * // Basic usage
27
- * <CopyButton
28
- * value="Production"
29
- * label="Environment"
30
- * onCopy={(value) => navigator.clipboard.writeText(value)}
31
- * />
32
- *
28
+ * <CopyButton value="Production" label="Environment" />
29
+ *
33
30
  * @example
34
- * // With custom icon size
31
+ * // With custom icon size and a callback
35
32
  * <CopyButton
36
33
  * value="sk-1234567890abcdef"
37
34
  * label="API Key"
38
35
  * iconSize={16}
39
- * onCopy={(value) => {
40
- * navigator.clipboard.writeText(value);
41
- * console.log('API Key copied');
42
- * }}
36
+ * onCopy={() => console.log('API Key copied')}
43
37
  * />
44
38
  */
45
39
  export function CopyButton({
@@ -47,36 +41,28 @@ export function CopyButton({
47
41
  label,
48
42
  onCopy,
49
43
  iconSize = 24,
44
+ timeout = 1500,
50
45
  }: CopyButtonProps) {
51
- const [isCopied, setIsCopied] = useState(false);
52
-
53
- const handleCopy = () => {
54
- if (onCopy) {
55
- onCopy(value);
56
- setIsCopied(true);
57
- }
58
- };
59
-
60
- const handleMouseLeave = () => {
61
- setIsCopied(false);
62
- };
63
-
64
46
  return (
65
- <Tooltip
66
- label={isCopied ? "Copied" : "Copy"}
67
- position="top"
68
- withArrow
69
- >
70
- <ActionIcon
71
- variant="subtle"
72
- size="xs"
73
- c="blue"
74
- onClick={handleCopy}
75
- onMouseLeave={handleMouseLeave}
76
- aria-label={`Copy ${label}`}
77
- >
78
- <RiFileCopyLine size={iconSize} />
79
- </ActionIcon>
80
- </Tooltip>
47
+ <MantineCopyButton value={value} timeout={timeout}>
48
+ {({ copied, copy }) => (
49
+ <Tooltip label={copied ? 'Copied' : 'Copy'} position="top" withArrow>
50
+ <ActionIcon
51
+ variant="subtle"
52
+ // Numeric size on purpose: t-shirt sizes get a token rule that pins the svg size,
53
+ // which would override `iconSize`. The button is the icon plus 4px padding per side.
54
+ size={iconSize + 8}
55
+ c="blue"
56
+ onClick={() => {
57
+ copy();
58
+ onCopy?.(value);
59
+ }}
60
+ aria-label={`Copy ${label}`}
61
+ >
62
+ <RiFileCopyLine size={iconSize} />
63
+ </ActionIcon>
64
+ </Tooltip>
65
+ )}
66
+ </MantineCopyButton>
81
67
  );
82
- }
68
+ }
package/dist/DESIGN.md CHANGED
@@ -353,9 +353,9 @@ All inputs default to `radius="sm"` and `size="sm"` matching the button default.
353
353
 
354
354
  ### Combobox
355
355
 
356
- `Select` · `SearchableSelect` · `AutocompleteClearable` · `Multiselect` · `Combobox`
356
+ `Select` · `SearchableSelect` · `AutocompleteClearable` · `ADMultiselect` · `Combobox`
357
357
 
358
- `SearchableSelect` and `AutocompleteClearable` are opinionated wrappers with built-in clear affordance. Use `Multiselect` for tag-style multi-value selection.
358
+ `SearchableSelect` and `AutocompleteClearable` are opinionated wrappers with built-in clear affordance. Use `ADMultiselect` for tag-style multi-value selection.
359
359
 
360
360
  **Toolbar vs tag-editor chips** — in dense table toolbars, multi-select values belong in the **chip row above the table**, with a **count** in the control (see **DataTable patterns**). Do not pile chips inside the combobox there; it breaks horizontal layouts. Standalone tag editors (e.g. form fields that edit a list of tags) may keep chips in the field.
361
361
 
@@ -640,11 +640,11 @@ Do **not** import `tokens.css` in Mantine apps (duplicates foundations; unused b
640
640
 
641
641
  | Package | Version | Role |
642
642
  |---|---|---|
643
- | `@mantine/core` | `^9.6.0` | Base component library |
644
- | `@mantine/hooks` | `^9.6.0` | Utility hooks (useDisclosure, etc.) |
645
- | `@mantine/dates` | `^9.6.0` | Date/time inputs |
646
- | `@mantine/notifications` | `^9.6.0` | Do not use in apps — prefer micro-container `ad-toast` (see Alert vs Notification) |
647
- | `@mantine/dropzone` | `^9.6.0` | File drag-and-drop |
643
+ | `@mantine/core` | `^9.8.2` | Base component library (peer of `@appdirect/design-system`) |
644
+ | `@mantine/hooks` | `^9.8.2` | Utility hooks (useDisclosure, etc.) |
645
+ | `@mantine/dates` | `^9.8.2` | Date/time inputs |
646
+ | `@mantine/notifications` | `^9.8.2` | Do not use in apps — prefer micro-container `ad-toast` (see Alert vs Notification) |
647
+ | `@mantine/dropzone` | `^9.8.2` | File drag-and-drop |
648
648
  | `@appdirect/design-tokens` | `^0.0.6` | AppDirect token CSS variables (`--ad-*`) |
649
649
  | `@tabler/icons-react` | `^3.33.0` | Icon library (supplementary) |
650
650
  | `@remixicon/react` | `^4.6.0` | Primary icon library; default avatar icon |
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import React, { forwardRef, useState, useCallback } from 'react';
3
+ import React, { forwardRef, useEffect } from 'react';
4
4
  import { Avatar as MantineAvatar } from '@mantine/core';
5
5
  import { RiUser3Fill } from '@remixicon/react';
6
6
  // ========================== CONSTANTS ==========================
@@ -24,7 +24,8 @@ const ICON_SIZES = {
24
24
  /**
25
25
  * Avatar Component
26
26
  *
27
- * Built on top of Mantine's Avatar component with design system styling.
27
+ * Built on top of Mantine's Avatar component with design system styling. Image load
28
+ * failures fall back to the placeholder content (icon or initials) via Mantine core.
28
29
  * Supports three variants: icon, image, and initials with all Mantine t-shirt sizes.
29
30
  *
30
31
  * @example
@@ -59,52 +60,19 @@ const ICON_SIZES = {
59
60
  * />
60
61
  */
61
62
  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;
63
+ useEffect(() => {
64
+ if (process.env.NODE_ENV !== 'development')
65
+ return;
66
+ if (variant === 'image' && !src) {
67
+ console.warn('Avatar: src is required when variant is "image"');
72
68
  }
73
- catch {
74
- return true;
69
+ if (variant === 'initials' && !initials) {
70
+ console.warn('Avatar: initials is required when variant is "initials"');
75
71
  }
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);
72
+ if (variant === 'initials' && initials && initials.length !== 2) {
73
+ console.warn('Avatar: initials should be exactly 2 characters');
87
74
  }
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
75
+ }, [variant, src, initials]);
108
76
  const renderIcon = () => {
109
77
  const iconSize = ICON_SIZES[size];
110
78
  if (icon) {
@@ -117,41 +85,18 @@ export const Avatar = forwardRef(({ variant, size = 'md', src, alt, initials, ic
117
85
  }
118
86
  return _jsx(RiUser3Fill, { size: iconSize, color: "var(--ad-color-text-default)" });
119
87
  };
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 }));
88
+ const renderInitials = (text) => text.substring(0, 2).toUpperCase();
89
+ // Mantine renders `children` whenever there is no `src` or the image fails to load.
90
+ let placeholder;
91
+ if (variant === 'initials') {
92
+ placeholder = initials ? renderInitials(initials) : '??';
93
+ }
94
+ else if (variant === 'image' && fallback === 'initials' && fallbackInitials) {
95
+ placeholder = renderInitials(fallbackInitials);
96
+ }
97
+ else {
98
+ placeholder = renderIcon();
99
+ }
100
+ return (_jsx(MantineAvatar, { ref: ref, size: AVATAR_SIZES[size], radius: 1000, src: variant === 'image' ? src : undefined, alt: alt, ...props, children: placeholder }));
156
101
  });
157
102
  Avatar.displayName = 'Avatar';
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import React, { forwardRef, useState, useCallback } from 'react';
3
+ import React, { forwardRef, useEffect } from 'react';
4
4
  import { Avatar as MantineAvatar, AvatarProps as MantineAvatarProps } from '@mantine/core';
5
5
  import { RiUser3Fill } from '@remixicon/react';
6
6
 
@@ -53,7 +53,8 @@ const ICON_SIZES = {
53
53
  /**
54
54
  * Avatar Component
55
55
  *
56
- * Built on top of Mantine's Avatar component with design system styling.
56
+ * Built on top of Mantine's Avatar component with design system styling. Image load
57
+ * failures fall back to the placeholder content (icon or initials) via Mantine core.
57
58
  * Supports three variants: icon, image, and initials with all Mantine t-shirt sizes.
58
59
  *
59
60
  * @example
@@ -88,7 +89,7 @@ const ICON_SIZES = {
88
89
  * />
89
90
  */
90
91
  export const Avatar = forwardRef<HTMLDivElement, DSAvatarProps>(
91
- ({
92
+ ({
92
93
  variant,
93
94
  size = 'md',
94
95
  src,
@@ -97,120 +98,61 @@ export const Avatar = forwardRef<HTMLDivElement, DSAvatarProps>(
97
98
  icon,
98
99
  fallback = 'icon',
99
100
  fallbackInitials,
100
- ...props
101
+ ...props
101
102
  }, ref) => {
102
-
103
- // Track image loading state
104
- const [imageError, setImageError] = useState(false);
105
-
106
- // Check if URL is obviously invalid
107
- const isInvalidUrl = (url: string) => {
108
- if (!url || url.trim() === '') return true;
109
- try {
110
- const hostname = new URL(url, 'https://local.invalid').hostname;
111
- if (hostname === 'example.com' || hostname.endsWith('.example.com')) return true;
112
- } catch {
113
- return true;
103
+ useEffect(() => {
104
+ if (process.env.NODE_ENV !== 'development') return;
105
+ if (variant === 'image' && !src) {
106
+ console.warn('Avatar: src is required when variant is "image"');
114
107
  }
115
- if (url.includes('broken-image')) return true;
116
- return false;
117
- };
118
-
119
- // Reset image error when src changes
120
- React.useEffect(() => {
121
- if (src && isInvalidUrl(src)) {
122
- setImageError(true);
123
- } else {
124
- setImageError(false);
108
+ if (variant === 'initials' && !initials) {
109
+ console.warn('Avatar: initials is required when variant is "initials"');
125
110
  }
126
- }, [src]);
127
-
128
- // Handle image load error
129
- const handleImageError = useCallback(() => {
130
- setImageError(true);
131
- }, []);
132
-
133
- if (process.env.NODE_ENV === 'development') {
134
- // eslint-disable-next-line react-hooks/rules-of-hooks
135
- React.useEffect(() => {
136
- if (variant === 'image' && !src) {
137
- console.warn('Avatar: src is required when variant is "image"');
138
- }
139
- if (variant === 'initials' && !initials) {
140
- console.warn('Avatar: initials is required when variant is "initials"');
141
- }
142
- if (variant === 'initials' && initials && initials.length !== 2) {
143
- console.warn('Avatar: initials should be exactly 2 characters');
144
- }
145
- }, [variant, src, initials]);
146
- }
111
+ if (variant === 'initials' && initials && initials.length !== 2) {
112
+ console.warn('Avatar: initials should be exactly 2 characters');
113
+ }
114
+ }, [variant, src, initials]);
147
115
 
148
- // Render icon content
149
116
  const renderIcon = () => {
150
117
  const iconSize = ICON_SIZES[size];
151
-
118
+
152
119
  if (icon) {
153
- return React.isValidElement(icon)
154
- ? React.cloneElement(icon as React.ReactElement, {
120
+ return React.isValidElement(icon)
121
+ ? React.cloneElement(icon as React.ReactElement<{ size?: number; color?: string }>, {
155
122
  size: iconSize,
156
123
  color: 'var(--ad-color-text-default)',
157
124
  })
158
125
  : icon;
159
126
  }
160
-
161
- return <RiUser3Fill size={iconSize} color="var(--ad-color-text-default)" />;
162
- };
163
127
 
164
- // Render initials content
165
- const renderInitials = (text: string) => {
166
- return text.substring(0, 2).toUpperCase();
128
+ return <RiUser3Fill size={iconSize} color="var(--ad-color-text-default)" />;
167
129
  };
168
130
 
169
- // Handle different variants
170
- const getAvatarContent = () => {
171
- switch (variant) {
172
- case 'image':
173
- // For image variant, always check if we should show fallback first
174
- if (!src || imageError) {
175
- // Show fallback content instead of trying to load image
176
- return {
177
- children: fallback === 'initials' && fallbackInitials
178
- ? renderInitials(fallbackInitials)
179
- : renderIcon(),
180
- };
181
- }
182
- // Only try to load image if we have src and no error yet
183
- return {
184
- src: src,
185
- alt: alt,
186
- onError: handleImageError,
187
- };
188
-
189
- case 'initials':
190
- return {
191
- children: initials ? renderInitials(initials) : '??',
192
- };
193
-
194
- case 'icon':
195
- default:
196
- return {
197
- children: renderIcon(),
198
- };
199
- }
200
- };
131
+ const renderInitials = (text: string) => text.substring(0, 2).toUpperCase();
201
132
 
202
- const avatarContent = getAvatarContent();
133
+ // Mantine renders `children` whenever there is no `src` or the image fails to load.
134
+ let placeholder: React.ReactNode;
135
+ if (variant === 'initials') {
136
+ placeholder = initials ? renderInitials(initials) : '??';
137
+ } else if (variant === 'image' && fallback === 'initials' && fallbackInitials) {
138
+ placeholder = renderInitials(fallbackInitials);
139
+ } else {
140
+ placeholder = renderIcon();
141
+ }
203
142
 
204
143
  return (
205
144
  <MantineAvatar
206
145
  ref={ref}
207
146
  size={AVATAR_SIZES[size]}
208
147
  radius={1000} // Perfect circle - large enough radius to ensure circular shape at all sizes
209
- {...avatarContent}
148
+ src={variant === 'image' ? src : undefined}
149
+ alt={alt}
210
150
  {...props}
211
- />
151
+ >
152
+ {placeholder}
153
+ </MantineAvatar>
212
154
  );
213
155
  }
214
156
  );
215
157
 
216
- Avatar.displayName = 'Avatar';
158
+ Avatar.displayName = 'Avatar';
@@ -1,81 +1,23 @@
1
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
- });
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import React, { forwardRef } from 'react';
4
+ import { Pill as MantinePill } from '@mantine/core';
5
+ // ========================== COMPONENT ==========================
6
+ /**
7
+ * AppDirect Design System Pill Component
8
+ *
9
+ * A thin wrapper over Mantine's Pill. Colors, radius, height and font size
10
+ * come from the `pill` / `multiselect.pill` component tokens, not from this file.
11
+ *
12
+ * Inside a `PillsInput` / `MultiSelect`, pass `size` explicitly so the pill
13
+ * matches the field: the DS default of `md` takes precedence over the size
14
+ * Mantine would otherwise inherit from the field.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * <Pill>Design</Pill>
19
+ * <Pill withRemoveButton onRemove={() => remove('design')}>Design</Pill>
20
+ * ```
21
+ */
22
+ export const Pill = forwardRef(({ size = 'md', removeButtonProps, ...props }, ref) => (_jsx(MantinePill, { ref: ref, size: size, removeButtonProps: { 'aria-label': 'Remove', ...removeButtonProps }, ...props })));
81
23
  Pill.displayName = 'Pill';