@appdirect/design-system 0.0.23 → 0.0.24

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 (36) hide show
  1. package/dist/Combobox/ADMultiselect.js +91 -0
  2. package/dist/Combobox/ADMultiselect.tsx +237 -0
  3. package/dist/Combobox/Select.js +13 -19
  4. package/dist/Combobox/Select.tsx +15 -44
  5. package/dist/Combobox/index.js +1 -1
  6. package/dist/Combobox/index.ts +2 -2
  7. package/dist/DESIGN.md +2 -2
  8. package/dist/DataDisplay/Pill.js +21 -79
  9. package/dist/DataDisplay/Pill.tsx +34 -116
  10. package/dist/Inputs/ColorInput.js +12 -18
  11. package/dist/Inputs/ColorInput.tsx +13 -41
  12. package/dist/Inputs/NumberInput.js +12 -36
  13. package/dist/Inputs/NumberInput.tsx +13 -72
  14. package/dist/Inputs/TextArea.js +12 -18
  15. package/dist/Inputs/TextArea.tsx +13 -41
  16. package/dist/Inputs/TextInput.js +12 -18
  17. package/dist/Inputs/TextInput.tsx +13 -41
  18. package/dist/Inputs/inputLabel.js +35 -0
  19. package/dist/Inputs/inputLabel.tsx +83 -0
  20. package/dist/Overlays/Tooltip.js +2 -2
  21. package/dist/Overlays/Tooltip.tsx +4 -1
  22. package/dist/contracts/index.json +1 -1
  23. package/dist/css/mantine.css +193 -29
  24. package/dist/css/tokens.css +58 -18
  25. package/dist/index.js +3 -3
  26. package/dist/index.ts +4 -4
  27. package/dist/stories/Combobox/{Multiselect.stories.tsx → ADMultiselect.stories.tsx} +159 -53
  28. package/dist/stories/Combobox/Select.stories.tsx +1 -1
  29. package/dist/stories/Inputs/ColorInput.stories.tsx +12 -0
  30. package/dist/stories/Inputs/NumberInput.stories.tsx +12 -0
  31. package/dist/stories/Inputs/TextArea.stories.tsx +12 -0
  32. package/dist/stories/Inputs/TextInput.stories.tsx +12 -0
  33. package/dist/stories/index.json +40 -32
  34. package/package.json +2 -2
  35. package/dist/Combobox/Multiselect.js +0 -31
  36. package/dist/Combobox/Multiselect.tsx +0 -158
@@ -0,0 +1,91 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import React, { forwardRef, useMemo } from 'react';
4
+ import { MultiSelect as MantineMultiSelect, } from '@mantine/core';
5
+ import { useUncontrolled } from '@mantine/hooks';
6
+ import { IconSelector } from '@tabler/icons-react';
7
+ import { Checkbox } from '../Inputs/Checkbox.js';
8
+ import { Inline } from '../Layout/index.js';
9
+ import { Pill } from '../DataDisplay/Pill.js';
10
+ import { getInputLabelProps } from '../Inputs/inputLabel.js';
11
+ import { Tooltip } from '../Overlays/Tooltip.js';
12
+ const MAX_DISPLAYED_VALUES = 2;
13
+ // ========================== HELPERS ==========================
14
+ /** Flatten ComboboxData (strings, items and groups) into a flat item list. */
15
+ function flattenData(data) {
16
+ const items = [];
17
+ const push = (item) => items.push(typeof item === 'string'
18
+ ? { value: item, label: item }
19
+ : { value: item.value, label: item.label ?? item.value });
20
+ data?.forEach((entry) => {
21
+ if (typeof entry !== 'string' && 'group' in entry)
22
+ entry.items.forEach(push);
23
+ else
24
+ push(entry);
25
+ });
26
+ return items;
27
+ }
28
+ // ========================== COMPONENT ==========================
29
+ /**
30
+ * AppDirect multi-value select.
31
+ *
32
+ * Mantine's `MultiSelect` with two DS customizations, everything else
33
+ * (value/onChange, search, clearable, hidden form input, ARIA, keyboard
34
+ * handling, ...) is core behavior and every core prop is supported:
35
+ *
36
+ * - **"+N more" pill:** only `maxDisplayedValues` pill slots are shown; the
37
+ * remaining values collapse into a "+N more" pill whose tooltip lists them.
38
+ * - **Checkbox options:** options render with a checkbox instead of a check icon.
39
+ *
40
+ * Design hand-off: there is intentionally no Figma component. It looks the same as
41
+ * `Combobox`, so designers use that and engineering swaps this in for multi-value fields.
42
+ *
43
+ * @example
44
+ * ```tsx
45
+ * <ADMultiselect
46
+ * label="Technologies"
47
+ * placeholder="Pick one or more"
48
+ * data={['React', 'Vue', 'Angular']}
49
+ * value={value}
50
+ * onChange={setValue}
51
+ * maxDisplayedValues={2}
52
+ * />
53
+ * ```
54
+ */
55
+ export const ADMultiselect = forwardRef(({ size = 'md', label, required, showOptional = false, hasHelpIcon = false, helpIconLabel, onHelpIconClick, error, errorCaption, maxDisplayedValues = MAX_DISPLAYED_VALUES, value, defaultValue, onChange, data, placeholder, readOnly, withCheckIcon = false, renderOption, variant, ...props }, ref) => {
56
+ const [selected, setSelected] = useUncontrolled({
57
+ value,
58
+ defaultValue,
59
+ finalValue: [],
60
+ onChange,
61
+ });
62
+ const effectiveError = error === true ? (errorCaption ?? true) : error;
63
+ const labelProps = getInputLabelProps({
64
+ label,
65
+ required,
66
+ showOptional,
67
+ hasHelpIcon,
68
+ helpIconLabel,
69
+ onHelpIconClick,
70
+ });
71
+ const labelsByValue = useMemo(() => new Map(flattenData(data).map((item) => [item.value, item.label])), [data]);
72
+ // The "+N more" pill occupies the last visible slot once values overflow.
73
+ const hasOverflow = selected.length > maxDisplayedValues;
74
+ const visibleCount = hasOverflow ? Math.max(maxDisplayedValues - 1, 0) : selected.length;
75
+ const hiddenValues = selected.slice(visibleCount);
76
+ const renderPill = ({ option, value: pillValue, onRemove, disabled, }) => {
77
+ const index = pillValue === undefined ? -1 : selected.indexOf(pillValue);
78
+ if (index < visibleCount) {
79
+ return (_jsx(Pill, { size: size, disabled: disabled, withRemoveButton: !readOnly && !option?.disabled, onRemove: onRemove, children: option?.label ?? pillValue }));
80
+ }
81
+ if (index === visibleCount) {
82
+ return (_jsx(Tooltip, { position: "top", maxWidth: 420, label: _jsx(Inline, { gap: 4, children: hiddenValues.map((hidden, i) => (_jsxs("span", { children: [labelsByValue.get(hidden) ?? hidden, i < hiddenValues.length - 1 ? ',' : ''] }, hidden))) }), children: _jsxs(Pill, { size: size, disabled: disabled, children: ["+", hiddenValues.length, " more"] }) }));
83
+ }
84
+ return null;
85
+ };
86
+ const renderCheckboxOption = ({ option, checked }) => (_jsxs(Inline, { gap: "sm", wrap: "nowrap", children: [_jsx(Checkbox, { checked: !!checked, disabled: option.disabled, onChange: () => { }, "aria-hidden": true, tabIndex: -1, style: { pointerEvents: 'none' } }), _jsx("span", { children: option.label })] }));
87
+ return (_jsx(MantineMultiSelect, { ...props, ref: ref, size: size, radius: "sm", variant: variant ?? 'default', ...labelProps, required: required, data: data,
88
+ // Core keeps the placeholder visible next to the pills; the DS shows it only when empty.
89
+ placeholder: selected.length > 0 ? undefined : placeholder, value: selected, onChange: setSelected, readOnly: readOnly, withCheckIcon: withCheckIcon, renderOption: renderOption ?? renderCheckboxOption, renderPill: renderPill, rightSection: _jsx(IconSelector, { size: 14, "aria-hidden": true }), rightSectionPointerEvents: props.clearable ? 'auto' : 'none', error: effectiveError }));
90
+ });
91
+ ADMultiselect.displayName = 'ADMultiselect';
@@ -0,0 +1,237 @@
1
+ 'use client';
2
+
3
+ import React, { forwardRef, useMemo } from 'react';
4
+ import {
5
+ MultiSelect as MantineMultiSelect,
6
+ MultiSelectProps as MantineMultiSelectProps,
7
+ ComboboxData,
8
+ ComboboxItem,
9
+ } from '@mantine/core';
10
+ import { useUncontrolled } from '@mantine/hooks';
11
+ import { IconSelector } from '@tabler/icons-react';
12
+ import { ComponentSize } from '../config';
13
+ import { Checkbox } from '../Inputs/Checkbox';
14
+ import { Inline } from '../Layout';
15
+ import { Pill } from '../DataDisplay/Pill';
16
+ import { getInputLabelProps } from '../Inputs/inputLabel';
17
+ import { Tooltip } from '../Overlays/Tooltip';
18
+
19
+ const MAX_DISPLAYED_VALUES = 2;
20
+
21
+ // ========================== TYPES ==========================
22
+
23
+ export interface ADMultiselectProps
24
+ extends Omit<MantineMultiSelectProps, 'size' | 'radius' | 'rightSection' | 'renderPill'> {
25
+ /** Input size from design system scale */
26
+ size?: ComponentSize;
27
+ /** Whether to show "(Optional)" text after the label */
28
+ showOptional?: boolean;
29
+ /** Whether to show a (?) help icon with a tooltip to the right of the label */
30
+ hasHelpIcon?: boolean;
31
+ /** Tooltip label shown when hovering the help icon. Also used as aria-label for a11y */
32
+ helpIconLabel?: string;
33
+ /** Optional click handler for the help icon */
34
+ onHelpIconClick?: React.MouseEventHandler<HTMLButtonElement>;
35
+ /**
36
+ * Optional error message text shown below the input when in error state.
37
+ * Used with error={true} for red border + message; omit for red border only.
38
+ */
39
+ errorCaption?: string;
40
+ /**
41
+ * Maximum number of pills shown before the rest collapse into a "+N more"
42
+ * pill. The "+N more" pill takes the last slot, so `2` shows one value pill
43
+ * plus "+N more" once more than two values are selected. Hovering it lists
44
+ * the hidden values.
45
+ */
46
+ maxDisplayedValues?: number;
47
+ }
48
+
49
+ // ========================== HELPERS ==========================
50
+
51
+ /** Flatten ComboboxData (strings, items and groups) into a flat item list. */
52
+ function flattenData(data: ComboboxData | undefined): ComboboxItem[] {
53
+ const items: ComboboxItem[] = [];
54
+ const push = (item: string | { value: string; label?: string }) =>
55
+ items.push(
56
+ typeof item === 'string'
57
+ ? { value: item, label: item }
58
+ : { value: item.value, label: item.label ?? item.value }
59
+ );
60
+
61
+ data?.forEach((entry) => {
62
+ if (typeof entry !== 'string' && 'group' in entry) entry.items.forEach(push);
63
+ else push(entry as string | { value: string; label?: string });
64
+ });
65
+ return items;
66
+ }
67
+
68
+ // ========================== COMPONENT ==========================
69
+
70
+ /**
71
+ * AppDirect multi-value select.
72
+ *
73
+ * Mantine's `MultiSelect` with two DS customizations, everything else
74
+ * (value/onChange, search, clearable, hidden form input, ARIA, keyboard
75
+ * handling, ...) is core behavior and every core prop is supported:
76
+ *
77
+ * - **"+N more" pill:** only `maxDisplayedValues` pill slots are shown; the
78
+ * remaining values collapse into a "+N more" pill whose tooltip lists them.
79
+ * - **Checkbox options:** options render with a checkbox instead of a check icon.
80
+ *
81
+ * Design hand-off: there is intentionally no Figma component. It looks the same as
82
+ * `Combobox`, so designers use that and engineering swaps this in for multi-value fields.
83
+ *
84
+ * @example
85
+ * ```tsx
86
+ * <ADMultiselect
87
+ * label="Technologies"
88
+ * placeholder="Pick one or more"
89
+ * data={['React', 'Vue', 'Angular']}
90
+ * value={value}
91
+ * onChange={setValue}
92
+ * maxDisplayedValues={2}
93
+ * />
94
+ * ```
95
+ */
96
+ export const ADMultiselect = forwardRef<HTMLInputElement, ADMultiselectProps>(
97
+ (
98
+ {
99
+ size = 'md',
100
+ label,
101
+ required,
102
+ showOptional = false,
103
+ hasHelpIcon = false,
104
+ helpIconLabel,
105
+ onHelpIconClick,
106
+ error,
107
+ errorCaption,
108
+ maxDisplayedValues = MAX_DISPLAYED_VALUES,
109
+ value,
110
+ defaultValue,
111
+ onChange,
112
+ data,
113
+ placeholder,
114
+ readOnly,
115
+ withCheckIcon = false,
116
+ renderOption,
117
+ variant,
118
+ ...props
119
+ },
120
+ ref
121
+ ) => {
122
+ const [selected, setSelected] = useUncontrolled<string[]>({
123
+ value,
124
+ defaultValue,
125
+ finalValue: [],
126
+ onChange,
127
+ });
128
+
129
+ const effectiveError = error === true ? (errorCaption ?? true) : error;
130
+
131
+ const labelProps = getInputLabelProps({
132
+ label,
133
+ required,
134
+ showOptional,
135
+ hasHelpIcon,
136
+ helpIconLabel,
137
+ onHelpIconClick,
138
+ });
139
+
140
+ const labelsByValue = useMemo(
141
+ () => new Map(flattenData(data).map((item) => [item.value, item.label])),
142
+ [data]
143
+ );
144
+
145
+ // The "+N more" pill occupies the last visible slot once values overflow.
146
+ const hasOverflow = selected.length > maxDisplayedValues;
147
+ const visibleCount = hasOverflow ? Math.max(maxDisplayedValues - 1, 0) : selected.length;
148
+ const hiddenValues = selected.slice(visibleCount);
149
+
150
+ const renderPill: MantineMultiSelectProps['renderPill'] = ({
151
+ option,
152
+ value: pillValue,
153
+ onRemove,
154
+ disabled,
155
+ }) => {
156
+ const index = pillValue === undefined ? -1 : selected.indexOf(pillValue);
157
+
158
+ if (index < visibleCount) {
159
+ return (
160
+ <Pill
161
+ size={size}
162
+ disabled={disabled}
163
+ withRemoveButton={!readOnly && !option?.disabled}
164
+ onRemove={onRemove}
165
+ >
166
+ {option?.label ?? pillValue}
167
+ </Pill>
168
+ );
169
+ }
170
+
171
+ if (index === visibleCount) {
172
+ return (
173
+ <Tooltip
174
+ position="top"
175
+ maxWidth={420}
176
+ label={
177
+ <Inline gap={4}>
178
+ {hiddenValues.map((hidden, i) => (
179
+ <span key={hidden}>
180
+ {labelsByValue.get(hidden) ?? hidden}
181
+ {i < hiddenValues.length - 1 ? ',' : ''}
182
+ </span>
183
+ ))}
184
+ </Inline>
185
+ }
186
+ >
187
+ <Pill size={size} disabled={disabled}>
188
+ +{hiddenValues.length} more
189
+ </Pill>
190
+ </Tooltip>
191
+ );
192
+ }
193
+
194
+ return null;
195
+ };
196
+
197
+ const renderCheckboxOption: MantineMultiSelectProps['renderOption'] = ({ option, checked }) => (
198
+ <Inline gap="sm" wrap="nowrap">
199
+ <Checkbox
200
+ checked={!!checked}
201
+ disabled={option.disabled}
202
+ onChange={() => {}} // Selection is handled by the option click
203
+ aria-hidden
204
+ tabIndex={-1}
205
+ style={{ pointerEvents: 'none' }}
206
+ />
207
+ <span>{option.label}</span>
208
+ </Inline>
209
+ );
210
+
211
+ return (
212
+ <MantineMultiSelect
213
+ {...props}
214
+ ref={ref}
215
+ size={size}
216
+ radius="sm"
217
+ variant={variant ?? 'default'}
218
+ {...labelProps}
219
+ required={required}
220
+ data={data}
221
+ // Core keeps the placeholder visible next to the pills; the DS shows it only when empty.
222
+ placeholder={selected.length > 0 ? undefined : placeholder}
223
+ value={selected}
224
+ onChange={setSelected}
225
+ readOnly={readOnly}
226
+ withCheckIcon={withCheckIcon}
227
+ renderOption={renderOption ?? renderCheckboxOption}
228
+ renderPill={renderPill}
229
+ rightSection={<IconSelector size={14} aria-hidden />}
230
+ rightSectionPointerEvents={props.clearable ? 'auto' : 'none'}
231
+ error={effectiveError}
232
+ />
233
+ );
234
+ }
235
+ );
236
+
237
+ ADMultiselect.displayName = 'ADMultiselect';
@@ -1,10 +1,9 @@
1
1
  'use client';
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
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';
4
+ import { Select as MantineSelect } from '@mantine/core';
5
+ import { IconSelector } from '@tabler/icons-react';
6
+ import { getInputLabelProps } from '../Inputs/inputLabel.js';
8
7
  import styles from './Select.module.css';
9
8
  // ========================== COMPONENT ==========================
10
9
  /**
@@ -55,19 +54,14 @@ import styles from './Select.module.css';
55
54
  */
56
55
  export const Select = forwardRef(({ size = 'sm', borderless = false, showOptional = false, required, label, hasHelpIcon = false, helpIconLabel, onHelpIconClick, error, errorCaption, variant, classNames, ...props }, ref) => {
57
56
  const effectiveError = error === true ? (errorCaption ?? true) : error;
58
- const enhancedLabel = React.useMemo(() => {
59
- if (!label)
60
- return label;
61
- if (showOptional && !required) {
62
- return (_jsxs(_Fragment, { children: [label, " ", _jsx(Text, { span: true, c: "dimmed", fw: "normal", children: "(Optional)" })] }));
63
- }
64
- return label;
65
- }, [label, showOptional, required]);
66
- 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;
67
- const selectorIcon = _jsx(IconSelector, { size: 14, "aria-hidden": true });
68
- const composedRightSection = helpIconElement
69
- ? _jsxs(Group, { gap: 4, wrap: "nowrap", children: [selectorIcon, helpIconElement] })
70
- : selectorIcon;
57
+ const labelProps = getInputLabelProps({
58
+ label,
59
+ required,
60
+ showOptional,
61
+ hasHelpIcon,
62
+ helpIconLabel,
63
+ onHelpIconClick,
64
+ });
71
65
  const mergedClassNames = typeof classNames === 'function'
72
66
  ? classNames
73
67
  : {
@@ -76,6 +70,6 @@ export const Select = forwardRef(({ size = 'sm', borderless = false, showOptiona
76
70
  .filter(Boolean)
77
71
  .join(' '),
78
72
  };
79
- return (_jsx(MantineSelect, { ...props, ref: ref, size: size, radius: "sm", required: required, label: enhancedLabel, rightSection: composedRightSection, rightSectionPointerEvents: hasHelpIcon || props.clearable ? 'auto' : 'none', variant: variant ?? 'default', classNames: mergedClassNames, error: effectiveError }));
73
+ return (_jsx(MantineSelect, { ...props, ref: ref, size: size, radius: "sm", required: required, ...labelProps, rightSection: _jsx(IconSelector, { size: 14, "aria-hidden": true }), rightSectionPointerEvents: props.clearable ? 'auto' : 'none', variant: variant ?? 'default', classNames: mergedClassNames, error: effectiveError }));
80
74
  });
81
75
  Select.displayName = 'Select';
@@ -1,11 +1,10 @@
1
1
  'use client';
2
2
 
3
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';
4
+ import { Select as MantineSelect, SelectProps as MantineSelectProps } from '@mantine/core';
5
+ import { IconSelector } from '@tabler/icons-react';
6
6
  import { ComponentSize } from '../config';
7
- import { Text } from '../Typography/Text';
8
- import { Tooltip } from '../Overlays/Tooltip';
7
+ import { getInputLabelProps } from '../Inputs/inputLabel';
9
8
  import styles from './Select.module.css';
10
9
 
11
10
  // ========================== TYPES ==========================
@@ -17,7 +16,7 @@ export interface DSSelectProps extends Omit<MantineSelectProps, 'size' | 'radius
17
16
  borderless?: boolean;
18
17
  /** Whether to show "(Optional)" text after label */
19
18
  showOptional?: boolean;
20
- /** Whether to show a help icon with a tooltip in the right section */
19
+ /** Whether to show a (?) help icon with a tooltip to the right of the label */
21
20
  hasHelpIcon?: boolean;
22
21
  /** Tooltip label shown when hovering the help icon. Also used as aria-label for a11y */
23
22
  helpIconLabel?: string;
@@ -99,42 +98,14 @@ export const Select = forwardRef<HTMLInputElement, DSSelectProps>(
99
98
  ) => {
100
99
  const effectiveError = error === true ? (errorCaption ?? true) : error;
101
100
 
102
- const enhancedLabel = React.useMemo(() => {
103
- if (!label) return label;
104
- if (showOptional && !required) {
105
- return (
106
- <>
107
- {label} <Text span c="dimmed" fw="normal">(Optional)</Text>
108
- </>
109
- );
110
- }
111
- return label;
112
- }, [label, showOptional, required]);
113
-
114
- const helpIconElement = hasHelpIcon ? (
115
- <Tooltip
116
- label={helpIconLabel ?? 'Help'}
117
- position="top"
118
- withArrow
119
- >
120
- <ActionIcon
121
- variant="transparent"
122
- size="xs"
123
- aria-label={helpIconLabel ?? 'Help'}
124
- onClick={onHelpIconClick}
125
- color="gray"
126
- style={{ cursor: onHelpIconClick ? 'pointer' : 'default' }}
127
- >
128
- <IconInfoCircle size={14} aria-hidden />
129
- </ActionIcon>
130
- </Tooltip>
131
- ) : null;
132
-
133
- const selectorIcon = <IconSelector size={14} aria-hidden />;
134
-
135
- const composedRightSection = helpIconElement
136
- ? <Group gap={4} wrap="nowrap">{selectorIcon}{helpIconElement}</Group>
137
- : selectorIcon;
101
+ const labelProps = getInputLabelProps({
102
+ label,
103
+ required,
104
+ showOptional,
105
+ hasHelpIcon,
106
+ helpIconLabel,
107
+ onHelpIconClick,
108
+ });
138
109
 
139
110
  const mergedClassNames =
140
111
  typeof classNames === 'function'
@@ -153,9 +124,9 @@ export const Select = forwardRef<HTMLInputElement, DSSelectProps>(
153
124
  size={size}
154
125
  radius="sm"
155
126
  required={required}
156
- label={enhancedLabel}
157
- rightSection={composedRightSection}
158
- rightSectionPointerEvents={hasHelpIcon || props.clearable ? 'auto' : 'none'}
127
+ {...labelProps}
128
+ rightSection={<IconSelector size={14} aria-hidden />}
129
+ rightSectionPointerEvents={props.clearable ? 'auto' : 'none'}
159
130
  variant={variant ?? 'default'}
160
131
  classNames={mergedClassNames}
161
132
  error={effectiveError}
@@ -5,6 +5,6 @@
5
5
  */
6
6
  export { SearchableSelect } from './SearchableSelect.js';
7
7
  export { AutocompleteClearable } from './AutocompleteClearable.js';
8
- export { Multiselect } from './Multiselect.js';
8
+ export { ADMultiselect } from './ADMultiselect.js';
9
9
  export { Select } from './Select.js';
10
10
  export { Combobox } from './Combobox.js';
@@ -10,8 +10,8 @@ export type { DSSearchableSelectProps } from './SearchableSelect';
10
10
  export { AutocompleteClearable } from './AutocompleteClearable';
11
11
  export type { DSAutocompleteClearableProps } from './AutocompleteClearable';
12
12
 
13
- export { Multiselect } from './Multiselect';
14
- export type { DSMultiselectProps } from './Multiselect';
13
+ export { ADMultiselect } from './ADMultiselect';
14
+ export type { ADMultiselectProps } from './ADMultiselect';
15
15
 
16
16
  export { Select } from './Select';
17
17
  export type { DSSelectProps } from './Select';
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
 
@@ -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';