@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.
- package/dist/Combobox/ADMultiselect.js +91 -0
- package/dist/Combobox/ADMultiselect.tsx +237 -0
- package/dist/Combobox/Select.js +13 -19
- package/dist/Combobox/Select.tsx +15 -44
- package/dist/Combobox/index.js +1 -1
- package/dist/Combobox/index.ts +2 -2
- package/dist/DESIGN.md +2 -2
- package/dist/DataDisplay/Pill.js +21 -79
- package/dist/DataDisplay/Pill.tsx +34 -116
- package/dist/Inputs/ColorInput.js +12 -18
- package/dist/Inputs/ColorInput.tsx +13 -41
- package/dist/Inputs/NumberInput.js +12 -36
- package/dist/Inputs/NumberInput.tsx +13 -72
- package/dist/Inputs/TextArea.js +12 -18
- package/dist/Inputs/TextArea.tsx +13 -41
- package/dist/Inputs/TextInput.js +12 -18
- package/dist/Inputs/TextInput.tsx +13 -41
- package/dist/Inputs/inputLabel.js +35 -0
- package/dist/Inputs/inputLabel.tsx +83 -0
- package/dist/Overlays/Tooltip.js +2 -2
- package/dist/Overlays/Tooltip.tsx +4 -1
- package/dist/contracts/index.json +1 -1
- package/dist/css/mantine.css +193 -29
- package/dist/css/tokens.css +58 -18
- package/dist/index.js +3 -3
- package/dist/index.ts +4 -4
- package/dist/stories/Combobox/{Multiselect.stories.tsx → ADMultiselect.stories.tsx} +159 -53
- package/dist/stories/Combobox/Select.stories.tsx +1 -1
- package/dist/stories/Inputs/ColorInput.stories.tsx +12 -0
- package/dist/stories/Inputs/NumberInput.stories.tsx +12 -0
- package/dist/stories/Inputs/TextArea.stories.tsx +12 -0
- package/dist/stories/Inputs/TextInput.stories.tsx +12 -0
- package/dist/stories/index.json +40 -32
- package/package.json +2 -2
- package/dist/Combobox/Multiselect.js +0 -31
- package/dist/Combobox/Multiselect.tsx +0 -158
package/dist/stories/index.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.24",
|
|
3
3
|
"stories": [
|
|
4
4
|
{
|
|
5
5
|
"title": "Design System/Buttons/ActionIcon",
|
|
@@ -67,6 +67,40 @@
|
|
|
67
67
|
"Stack"
|
|
68
68
|
]
|
|
69
69
|
},
|
|
70
|
+
{
|
|
71
|
+
"title": "Design System/Combobox/ADMultiselect",
|
|
72
|
+
"component": "ADMultiselect",
|
|
73
|
+
"description": "Mantine MultiSelect with checkbox options and a \"+N more\" pill. Hovering \"+N more\" lists the hidden values. All core MultiSelect props (value, onChange, searchable, clearable, name, ...) are supported.",
|
|
74
|
+
"stories": [
|
|
75
|
+
"Default",
|
|
76
|
+
"WithHelpIcon",
|
|
77
|
+
"WithErrorCaption",
|
|
78
|
+
"Sizes",
|
|
79
|
+
"WithDescription",
|
|
80
|
+
"RequiredAndOptional",
|
|
81
|
+
"WithError",
|
|
82
|
+
"DisabledState",
|
|
83
|
+
"MaxDisplayedValues",
|
|
84
|
+
"DifferentDataTypes",
|
|
85
|
+
"FormIntegration",
|
|
86
|
+
"TagSelection",
|
|
87
|
+
"TeamAndPermissions",
|
|
88
|
+
"UseCases",
|
|
89
|
+
"Controlled",
|
|
90
|
+
"GroupedAndSearchable",
|
|
91
|
+
"Interactive"
|
|
92
|
+
],
|
|
93
|
+
"file": "Combobox/ADMultiselect.stories.tsx",
|
|
94
|
+
"designSystem": [
|
|
95
|
+
"ADMultiselect",
|
|
96
|
+
"Text",
|
|
97
|
+
"Title"
|
|
98
|
+
],
|
|
99
|
+
"mantine": [
|
|
100
|
+
"Box",
|
|
101
|
+
"Stack"
|
|
102
|
+
]
|
|
103
|
+
},
|
|
70
104
|
{
|
|
71
105
|
"title": "Design System/Combobox/AutocompleteClearable",
|
|
72
106
|
"component": "AutocompleteClearable",
|
|
@@ -113,36 +147,6 @@
|
|
|
113
147
|
],
|
|
114
148
|
"mantine": []
|
|
115
149
|
},
|
|
116
|
-
{
|
|
117
|
-
"title": "Design System/Combobox/Multiselect",
|
|
118
|
-
"component": "Multiselect",
|
|
119
|
-
"description": "Multi-selection input with pills display and checkbox options.",
|
|
120
|
-
"stories": [
|
|
121
|
-
"Default",
|
|
122
|
-
"Sizes",
|
|
123
|
-
"WithDescription",
|
|
124
|
-
"RequiredAndOptional",
|
|
125
|
-
"WithError",
|
|
126
|
-
"DisabledState",
|
|
127
|
-
"MaxDisplayedValues",
|
|
128
|
-
"DifferentDataTypes",
|
|
129
|
-
"FormIntegration",
|
|
130
|
-
"TagSelection",
|
|
131
|
-
"TeamAndPermissions",
|
|
132
|
-
"UseCases",
|
|
133
|
-
"Interactive"
|
|
134
|
-
],
|
|
135
|
-
"file": "Combobox/Multiselect.stories.tsx",
|
|
136
|
-
"designSystem": [
|
|
137
|
-
"Inline",
|
|
138
|
-
"Multiselect",
|
|
139
|
-
"Text",
|
|
140
|
-
"Title"
|
|
141
|
-
],
|
|
142
|
-
"mantine": [
|
|
143
|
-
"Stack"
|
|
144
|
-
]
|
|
145
|
-
},
|
|
146
150
|
{
|
|
147
151
|
"title": "Design System/Combobox/SearchableSelect",
|
|
148
152
|
"component": "SearchableSelect",
|
|
@@ -176,7 +180,7 @@
|
|
|
176
180
|
{
|
|
177
181
|
"title": "Design System/Combobox/Select",
|
|
178
182
|
"component": "Select",
|
|
179
|
-
"description": "A flexible select component built on Mantine's Select with design system defaults. **Features:** - **Regular mode**: Standard select with borders, labels, and validation - **Borderless mode**: Clean, minimal appearance for dashboard widgets - **Searchable / Clearable**: Optional search and clear functionality - **Help icon**: Tooltip-based contextual help
|
|
183
|
+
"description": "A flexible select component built on Mantine's Select with design system defaults. **Features:** - **Regular mode**: Standard select with borders, labels, and validation - **Borderless mode**: Clean, minimal appearance for dashboard widgets - **Searchable / Clearable**: Optional search and clear functionality - **Help icon**: Tooltip-based contextual help, a (?) icon to the right of the label - **Optional label**: Shows \"(Optional)\" text next to the label - **Error caption**: Separate error message prop for controlled error display",
|
|
180
184
|
"stories": [
|
|
181
185
|
"Default",
|
|
182
186
|
"WithObjectData",
|
|
@@ -767,6 +771,7 @@
|
|
|
767
771
|
"description": "ColorInput component for color selection with consistent design system styling and multiple format support.",
|
|
768
772
|
"stories": [
|
|
769
773
|
"Default",
|
|
774
|
+
"WithHelpIcon",
|
|
770
775
|
"Sizes",
|
|
771
776
|
"LabelVariants",
|
|
772
777
|
"States",
|
|
@@ -846,6 +851,7 @@
|
|
|
846
851
|
"description": "NumberInput component for numeric values with consistent design system styling and validation.",
|
|
847
852
|
"stories": [
|
|
848
853
|
"Default",
|
|
854
|
+
"WithHelpIcon",
|
|
849
855
|
"Sizes",
|
|
850
856
|
"LabelVariants",
|
|
851
857
|
"States",
|
|
@@ -1002,6 +1008,7 @@
|
|
|
1002
1008
|
"description": "TextArea component for multi-line text input with consistent design system styling and auto-sizing capabilities.",
|
|
1003
1009
|
"stories": [
|
|
1004
1010
|
"Default",
|
|
1011
|
+
"WithHelpIcon",
|
|
1005
1012
|
"Sizes",
|
|
1006
1013
|
"LabelVariants",
|
|
1007
1014
|
"States",
|
|
@@ -1028,6 +1035,7 @@
|
|
|
1028
1035
|
"description": "TextInput component with design system sizing, consistent styling, and enhanced label options.",
|
|
1029
1036
|
"stories": [
|
|
1030
1037
|
"Default",
|
|
1038
|
+
"WithHelpIcon",
|
|
1031
1039
|
"Sizes",
|
|
1032
1040
|
"LabelVariants",
|
|
1033
1041
|
"WithIcons",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appdirect/design-system",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "AppDirect Design System components. Wraps Mantine v9 with standardized props, variants, and tokens.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.ts",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"prepublishOnly": "npm run build"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@appdirect/ad-design-tokens": "0.0.
|
|
52
|
+
"@appdirect/ad-design-tokens": "0.0.24",
|
|
53
53
|
"@remixicon/react": "^4.6.0",
|
|
54
54
|
"@tabler/icons-react": "^3.33.0",
|
|
55
55
|
"@tanstack/react-table": "^9.2.4",
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
import { Checkbox, Combobox,Input, Pill as MantinePill, PillsInput, useCombobox, InputWrapper } from '@mantine/core';
|
|
5
|
-
import { Inline } from '..';
|
|
6
|
-
import { Pill } from '../DataDisplay/Pill';
|
|
7
|
-
|
|
8
|
-
const technologies = ['React', 'Vue', 'Angular', 'Node.js', 'Docker', 'Kubernetes', 'AWS', 'MongoDB'];
|
|
9
|
-
|
|
10
|
-
const MAX_DISPLAYED_VALUES = 2;
|
|
11
|
-
|
|
12
|
-
export interface DSMultiselectProps {
|
|
13
|
-
/** Label for the input */
|
|
14
|
-
label?: string;
|
|
15
|
-
/** Placeholder text */
|
|
16
|
-
placeholder?: string;
|
|
17
|
-
/** Data array for options - can be strings or objects with value/label */
|
|
18
|
-
data?: string[] | { value: string; label: string }[];
|
|
19
|
-
/** Description text displayed below the input */
|
|
20
|
-
description?: string;
|
|
21
|
-
/** Error message */
|
|
22
|
-
error?: string;
|
|
23
|
-
/** Whether the field is required */
|
|
24
|
-
required?: boolean;
|
|
25
|
-
/** Whether to show "(optional)" next to the label */
|
|
26
|
-
showOptional?: boolean;
|
|
27
|
-
/** Whether the input is disabled */
|
|
28
|
-
disabled?: boolean;
|
|
29
|
-
/** Whether the select is searchable */
|
|
30
|
-
searchable?: boolean;
|
|
31
|
-
/** Input size */
|
|
32
|
-
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
33
|
-
/** Style object for the component */
|
|
34
|
-
style?: React.CSSProperties;
|
|
35
|
-
/** Maximum number of pills to display before showing "+X more" */
|
|
36
|
-
maxDisplayedValues?: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function Multiselect({
|
|
40
|
-
label,
|
|
41
|
-
placeholder = "Pick one or more technologies",
|
|
42
|
-
data = technologies,
|
|
43
|
-
description,
|
|
44
|
-
error,
|
|
45
|
-
required = false,
|
|
46
|
-
showOptional = false,
|
|
47
|
-
disabled = false,
|
|
48
|
-
searchable = true,
|
|
49
|
-
size = 'md',
|
|
50
|
-
style,
|
|
51
|
-
maxDisplayedValues = MAX_DISPLAYED_VALUES,
|
|
52
|
-
...props
|
|
53
|
-
}: DSMultiselectProps) {
|
|
54
|
-
const combobox = useCombobox({
|
|
55
|
-
onDropdownClose: () => combobox.resetSelectedOption(),
|
|
56
|
-
onDropdownOpen: () => combobox.updateSelectedOptionIndex('active'),
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const [value, setValue] = useState<string[]>([]);
|
|
60
|
-
|
|
61
|
-
const handleValueSelect = (val: string) =>
|
|
62
|
-
setValue((current) =>
|
|
63
|
-
current.includes(val) ? current.filter((v) => v !== val) : [...current, val]
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const handleValueRemove = (val: string) =>
|
|
67
|
-
setValue((current) => current.filter((v) => v !== val));
|
|
68
|
-
|
|
69
|
-
const values = value
|
|
70
|
-
.slice(
|
|
71
|
-
0,
|
|
72
|
-
maxDisplayedValues === value.length ? maxDisplayedValues : maxDisplayedValues - 1
|
|
73
|
-
)
|
|
74
|
-
.map((item) => (
|
|
75
|
-
<Pill key={item} withRemoveButton onRemove={() => handleValueRemove(item)} size={size}>
|
|
76
|
-
{item}
|
|
77
|
-
</Pill>
|
|
78
|
-
));
|
|
79
|
-
|
|
80
|
-
// Convert data to consistent format
|
|
81
|
-
const normalizedData = data.map(item =>
|
|
82
|
-
typeof item === 'string' ? { value: item, label: item } : item
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const options = normalizedData.map((item) => (
|
|
86
|
-
<Combobox.Option value={item.value} key={item.value} active={value.includes(item.value)}>
|
|
87
|
-
<Inline gap="sm">
|
|
88
|
-
<Checkbox
|
|
89
|
-
checked={value.includes(item.value)}
|
|
90
|
-
onChange={() => {}} // Handled by onOptionSubmit
|
|
91
|
-
aria-hidden
|
|
92
|
-
tabIndex={-1}
|
|
93
|
-
style={{ pointerEvents: 'none' }}
|
|
94
|
-
/>
|
|
95
|
-
<span>{item.label}</span>
|
|
96
|
-
</Inline>
|
|
97
|
-
</Combobox.Option>
|
|
98
|
-
));
|
|
99
|
-
|
|
100
|
-
// Determine the display label
|
|
101
|
-
const displayLabel = showOptional && !required && label ? `${label} (optional)` : label;
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<div style={style}>
|
|
105
|
-
<InputWrapper
|
|
106
|
-
label={displayLabel}
|
|
107
|
-
description={description}
|
|
108
|
-
error={error}
|
|
109
|
-
required={required && !showOptional}
|
|
110
|
-
size={size}
|
|
111
|
-
withAsterisk={required && !showOptional}
|
|
112
|
-
>
|
|
113
|
-
<Combobox store={combobox} onOptionSubmit={handleValueSelect} withinPortal={false} disabled={disabled}>
|
|
114
|
-
<Combobox.DropdownTarget>
|
|
115
|
-
<PillsInput
|
|
116
|
-
pointer
|
|
117
|
-
onClick={() => !disabled && combobox.toggleDropdown()}
|
|
118
|
-
size={size}
|
|
119
|
-
disabled={disabled}
|
|
120
|
-
error={!!error}
|
|
121
|
-
>
|
|
122
|
-
<MantinePill.Group>
|
|
123
|
-
{value.length > 0 ? (
|
|
124
|
-
<>
|
|
125
|
-
{values}
|
|
126
|
-
{value.length > maxDisplayedValues && (
|
|
127
|
-
<Pill size={size}>+{value.length - (maxDisplayedValues - 1)} more</Pill>
|
|
128
|
-
)}
|
|
129
|
-
</>
|
|
130
|
-
) : (
|
|
131
|
-
<Input.Placeholder>{placeholder}</Input.Placeholder>
|
|
132
|
-
)}
|
|
133
|
-
|
|
134
|
-
<Combobox.EventsTarget>
|
|
135
|
-
<PillsInput.Field
|
|
136
|
-
type="hidden"
|
|
137
|
-
onBlur={() => combobox.closeDropdown()}
|
|
138
|
-
onKeyDown={(event) => {
|
|
139
|
-
if (event.key === 'Backspace' && !disabled) {
|
|
140
|
-
event.preventDefault();
|
|
141
|
-
handleValueRemove(value[value.length - 1]);
|
|
142
|
-
}
|
|
143
|
-
}}
|
|
144
|
-
disabled={disabled}
|
|
145
|
-
/>
|
|
146
|
-
</Combobox.EventsTarget>
|
|
147
|
-
</MantinePill.Group>
|
|
148
|
-
</PillsInput>
|
|
149
|
-
</Combobox.DropdownTarget>
|
|
150
|
-
|
|
151
|
-
<Combobox.Dropdown>
|
|
152
|
-
<Combobox.Options>{options}</Combobox.Options>
|
|
153
|
-
</Combobox.Dropdown>
|
|
154
|
-
</Combobox>
|
|
155
|
-
</InputWrapper>
|
|
156
|
-
</div>
|
|
157
|
-
);
|
|
158
|
-
}
|