@appdirect/design-system 0.0.23 → 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.
- package/dist/Combobox/ADMultiselect.js +91 -0
- package/dist/Combobox/ADMultiselect.tsx +237 -0
- package/dist/Combobox/AutocompleteClearable.js +33 -35
- package/dist/Combobox/AutocompleteClearable.tsx +56 -121
- package/dist/Combobox/SearchableSelect.js +23 -42
- package/dist/Combobox/SearchableSelect.tsx +33 -129
- 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/ComplexComponents/Utilities/CopyButton.js +15 -27
- package/dist/ComplexComponents/Utilities/CopyButton.tsx +35 -49
- package/dist/DESIGN.md +2 -2
- package/dist/DataDisplay/Avatar.js +26 -81
- package/dist/DataDisplay/Avatar.tsx +35 -93
- 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/Layout/Inline.js +5 -42
- package/dist/Layout/Inline.tsx +6 -79
- 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/SearchableSelect.stories.tsx +3 -3
- package/dist/stories/Combobox/Select.stories.tsx +1 -1
- package/dist/stories/ComplexComponents/Utilities/CopyButton.stories.tsx +4 -14
- 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 +42 -35
- package/package.json +2 -2
- package/dist/Combobox/Multiselect.js +0 -31
- package/dist/Combobox/Multiselect.tsx +0 -158
|
@@ -4,13 +4,9 @@ import React, { forwardRef } from 'react';
|
|
|
4
4
|
import {
|
|
5
5
|
NumberInput as MantineNumberInput,
|
|
6
6
|
NumberInputProps as MantineNumberInputProps,
|
|
7
|
-
ActionIcon,
|
|
8
|
-
Group,
|
|
9
7
|
} from '@mantine/core';
|
|
10
|
-
import { RiInformationLine } from '@remixicon/react';
|
|
11
8
|
import { ComponentSize } from '../config';
|
|
12
|
-
import {
|
|
13
|
-
import { Tooltip } from '../Overlays/Tooltip';
|
|
9
|
+
import { getInputLabelProps } from './inputLabel';
|
|
14
10
|
|
|
15
11
|
// ========================== TYPES ==========================
|
|
16
12
|
|
|
@@ -19,7 +15,7 @@ export interface DSNumberInputProps extends Omit<MantineNumberInputProps, 'size'
|
|
|
19
15
|
size?: ComponentSize;
|
|
20
16
|
/** Whether to show "(Optional)" text after label */
|
|
21
17
|
showOptional?: boolean;
|
|
22
|
-
/** Whether to show a help icon with a tooltip
|
|
18
|
+
/** Whether to show a (?) help icon with a tooltip to the right of the label */
|
|
23
19
|
hasHelpIcon?: boolean;
|
|
24
20
|
/** Tooltip label shown when hovering the help icon. Also used as aria-label for a11y */
|
|
25
21
|
helpIconLabel?: string;
|
|
@@ -62,69 +58,14 @@ export const NumberInput = forwardRef<HTMLInputElement, DSNumberInputProps>(
|
|
|
62
58
|
) => {
|
|
63
59
|
const effectiveError = error === true ? (errorCaption ?? true) : error;
|
|
64
60
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
</Text>
|
|
74
|
-
</>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
return label;
|
|
78
|
-
}, [label, showOptional, required]);
|
|
79
|
-
|
|
80
|
-
const helpIconElement = hasHelpIcon ? (
|
|
81
|
-
<Tooltip label={helpIconLabel ?? 'Help'} position="top" withArrow>
|
|
82
|
-
<ActionIcon
|
|
83
|
-
variant="transparent"
|
|
84
|
-
size="xs"
|
|
85
|
-
aria-label={helpIconLabel ?? 'Help'}
|
|
86
|
-
onClick={onHelpIconClick}
|
|
87
|
-
color="gray"
|
|
88
|
-
style={{ cursor: onHelpIconClick ? 'pointer' : 'default' }}
|
|
89
|
-
>
|
|
90
|
-
<RiInformationLine size={14} aria-hidden />
|
|
91
|
-
</ActionIcon>
|
|
92
|
-
</Tooltip>
|
|
93
|
-
) : null;
|
|
94
|
-
|
|
95
|
-
const nativeControlsVisible =
|
|
96
|
-
!hideControls && !props.readOnly && !props.disabled;
|
|
97
|
-
|
|
98
|
-
const composedLeftSection = React.useMemo(() => {
|
|
99
|
-
if (!helpIconElement) return leftSection;
|
|
100
|
-
if (nativeControlsVisible) {
|
|
101
|
-
if (leftSection) {
|
|
102
|
-
return (
|
|
103
|
-
<Group gap={4} wrap="nowrap">
|
|
104
|
-
{helpIconElement}
|
|
105
|
-
{leftSection}
|
|
106
|
-
</Group>
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
return helpIconElement;
|
|
110
|
-
}
|
|
111
|
-
return leftSection;
|
|
112
|
-
}, [helpIconElement, leftSection, nativeControlsVisible]);
|
|
113
|
-
|
|
114
|
-
const composedRightSection = React.useMemo(() => {
|
|
115
|
-
if (!helpIconElement || nativeControlsVisible) {
|
|
116
|
-
return rightSection;
|
|
117
|
-
}
|
|
118
|
-
if (rightSection) {
|
|
119
|
-
return (
|
|
120
|
-
<Group gap={4} wrap="nowrap">
|
|
121
|
-
{rightSection}
|
|
122
|
-
{helpIconElement}
|
|
123
|
-
</Group>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
return helpIconElement;
|
|
127
|
-
}, [helpIconElement, nativeControlsVisible, rightSection]);
|
|
61
|
+
const labelProps = getInputLabelProps({
|
|
62
|
+
label,
|
|
63
|
+
required,
|
|
64
|
+
showOptional,
|
|
65
|
+
hasHelpIcon,
|
|
66
|
+
helpIconLabel,
|
|
67
|
+
onHelpIconClick,
|
|
68
|
+
});
|
|
128
69
|
|
|
129
70
|
return (
|
|
130
71
|
<MantineNumberInput
|
|
@@ -132,11 +73,11 @@ export const NumberInput = forwardRef<HTMLInputElement, DSNumberInputProps>(
|
|
|
132
73
|
size={size}
|
|
133
74
|
radius="sm"
|
|
134
75
|
required={required}
|
|
135
|
-
label={enhancedLabel}
|
|
136
76
|
error={effectiveError}
|
|
137
77
|
hideControls={hideControls}
|
|
138
|
-
leftSection={
|
|
139
|
-
rightSection={
|
|
78
|
+
leftSection={leftSection}
|
|
79
|
+
rightSection={rightSection}
|
|
80
|
+
{...labelProps}
|
|
140
81
|
{...props}
|
|
141
82
|
/>
|
|
142
83
|
);
|
package/dist/Inputs/TextArea.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import React, { forwardRef } from 'react';
|
|
4
|
-
import { Textarea as MantineTextarea
|
|
5
|
-
import {
|
|
6
|
-
import { Text } from '../Typography/Text.js';
|
|
7
|
-
import { Tooltip } from '../Overlays/Tooltip.js';
|
|
4
|
+
import { Textarea as MantineTextarea } from '@mantine/core';
|
|
5
|
+
import { getInputLabelProps } from './inputLabel.js';
|
|
8
6
|
// ========================== COMPONENT ==========================
|
|
9
7
|
/**
|
|
10
8
|
* AppDirect Design System TextArea Component
|
|
@@ -33,18 +31,14 @@ import { Tooltip } from '../Overlays/Tooltip.js';
|
|
|
33
31
|
*/
|
|
34
32
|
export const TextArea = forwardRef(({ size = 'md', showOptional = false, required, label, hasHelpIcon = false, helpIconLabel, onHelpIconClick, rightSection, error, errorCaption, ...props }, ref) => {
|
|
35
33
|
const effectiveError = error === true ? (errorCaption ?? true) : error;
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const composedRightSection = (helpIconElement && rightSection)
|
|
46
|
-
? _jsxs(Group, { gap: 4, wrap: "nowrap", children: [rightSection, helpIconElement] })
|
|
47
|
-
: helpIconElement || rightSection;
|
|
48
|
-
return (_jsx(MantineTextarea, { ref: ref, size: size, radius: "sm", required: required, label: enhancedLabel, rightSection: composedRightSection, error: effectiveError, ...props }));
|
|
34
|
+
const labelProps = getInputLabelProps({
|
|
35
|
+
label,
|
|
36
|
+
required,
|
|
37
|
+
showOptional,
|
|
38
|
+
hasHelpIcon,
|
|
39
|
+
helpIconLabel,
|
|
40
|
+
onHelpIconClick,
|
|
41
|
+
});
|
|
42
|
+
return (_jsx(MantineTextarea, { ref: ref, size: size, radius: "sm", required: required, rightSection: rightSection, ...labelProps, error: effectiveError, ...props }));
|
|
49
43
|
});
|
|
50
44
|
TextArea.displayName = 'TextArea';
|
package/dist/Inputs/TextArea.tsx
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import React, { forwardRef } from 'react';
|
|
4
|
-
import { Textarea as MantineTextarea, TextareaProps as MantineTextareaProps
|
|
5
|
-
import { IconInfoCircle } from '@tabler/icons-react';
|
|
4
|
+
import { Textarea as MantineTextarea, TextareaProps as MantineTextareaProps } from '@mantine/core';
|
|
6
5
|
import { ComponentSize } from '../config';
|
|
7
|
-
import {
|
|
8
|
-
import { Tooltip } from '../Overlays/Tooltip';
|
|
6
|
+
import { getInputLabelProps } from './inputLabel';
|
|
9
7
|
|
|
10
8
|
// ========================== TYPES ==========================
|
|
11
9
|
|
|
@@ -14,7 +12,7 @@ export interface DSTextAreaProps extends Omit<MantineTextareaProps, 'size' | 'ra
|
|
|
14
12
|
size?: ComponentSize;
|
|
15
13
|
/** Whether to show "(Optional)" text after label */
|
|
16
14
|
showOptional?: boolean;
|
|
17
|
-
/** Whether to show a help icon with a tooltip
|
|
15
|
+
/** Whether to show a (?) help icon with a tooltip to the right of the label */
|
|
18
16
|
hasHelpIcon?: boolean;
|
|
19
17
|
/** Tooltip label shown when hovering the help icon. Also used as aria-label for a11y */
|
|
20
18
|
helpIconLabel?: string;
|
|
@@ -73,40 +71,14 @@ export const TextArea = forwardRef<HTMLTextAreaElement, DSTextAreaProps>(
|
|
|
73
71
|
) => {
|
|
74
72
|
const effectiveError = error === true ? (errorCaption ?? true) : error;
|
|
75
73
|
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
return label;
|
|
86
|
-
}, [label, showOptional, required]);
|
|
87
|
-
|
|
88
|
-
const helpIconElement = hasHelpIcon ? (
|
|
89
|
-
<Tooltip
|
|
90
|
-
label={helpIconLabel ?? 'Help'}
|
|
91
|
-
position="top"
|
|
92
|
-
withArrow
|
|
93
|
-
>
|
|
94
|
-
<ActionIcon
|
|
95
|
-
variant="transparent"
|
|
96
|
-
size="xs"
|
|
97
|
-
aria-label={helpIconLabel ?? 'Help'}
|
|
98
|
-
onClick={onHelpIconClick}
|
|
99
|
-
color="gray"
|
|
100
|
-
style={{ cursor: onHelpIconClick ? 'pointer' : 'default' }}
|
|
101
|
-
>
|
|
102
|
-
<IconInfoCircle size={14} aria-hidden />
|
|
103
|
-
</ActionIcon>
|
|
104
|
-
</Tooltip>
|
|
105
|
-
) : null;
|
|
106
|
-
|
|
107
|
-
const composedRightSection = (helpIconElement && rightSection)
|
|
108
|
-
? <Group gap={4} wrap="nowrap">{rightSection}{helpIconElement}</Group>
|
|
109
|
-
: helpIconElement || rightSection;
|
|
74
|
+
const labelProps = getInputLabelProps({
|
|
75
|
+
label,
|
|
76
|
+
required,
|
|
77
|
+
showOptional,
|
|
78
|
+
hasHelpIcon,
|
|
79
|
+
helpIconLabel,
|
|
80
|
+
onHelpIconClick,
|
|
81
|
+
});
|
|
110
82
|
|
|
111
83
|
return (
|
|
112
84
|
<MantineTextarea
|
|
@@ -114,8 +86,8 @@ export const TextArea = forwardRef<HTMLTextAreaElement, DSTextAreaProps>(
|
|
|
114
86
|
size={size}
|
|
115
87
|
radius="sm"
|
|
116
88
|
required={required}
|
|
117
|
-
|
|
118
|
-
|
|
89
|
+
rightSection={rightSection}
|
|
90
|
+
{...labelProps}
|
|
119
91
|
error={effectiveError}
|
|
120
92
|
{...props}
|
|
121
93
|
/>
|
package/dist/Inputs/TextInput.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import React, { forwardRef } from 'react';
|
|
4
|
-
import { TextInput as MantineTextInput
|
|
5
|
-
import {
|
|
6
|
-
import { Text } from '../Typography/Text.js';
|
|
7
|
-
import { Tooltip } from '../Overlays/Tooltip.js';
|
|
4
|
+
import { TextInput as MantineTextInput } from '@mantine/core';
|
|
5
|
+
import { getInputLabelProps } from './inputLabel.js';
|
|
8
6
|
/**
|
|
9
7
|
* AppDirect Design System TextInput Component
|
|
10
8
|
*
|
|
@@ -70,18 +68,14 @@ import { Tooltip } from '../Overlays/Tooltip.js';
|
|
|
70
68
|
*/
|
|
71
69
|
export const TextInput = forwardRef(({ size = 'md', leftSection, rightSection, showOptional = false, required, label, hasHelpIcon = false, helpIconLabel, onHelpIconClick, error, errorCaption, ...props }, ref) => {
|
|
72
70
|
const effectiveError = error === true ? (errorCaption ?? true) : error;
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const composedRightSection = (helpIconElement && rightSection)
|
|
83
|
-
? _jsxs(Group, { gap: 4, wrap: "nowrap", children: [rightSection, helpIconElement] })
|
|
84
|
-
: helpIconElement || rightSection;
|
|
85
|
-
return (_jsx(MantineTextInput, { ref: ref, size: size, radius: "sm", required: required, leftSection: leftSection, rightSection: composedRightSection, label: enhancedLabel, error: effectiveError, ...props }));
|
|
71
|
+
const labelProps = getInputLabelProps({
|
|
72
|
+
label,
|
|
73
|
+
required,
|
|
74
|
+
showOptional,
|
|
75
|
+
hasHelpIcon,
|
|
76
|
+
helpIconLabel,
|
|
77
|
+
onHelpIconClick,
|
|
78
|
+
});
|
|
79
|
+
return (_jsx(MantineTextInput, { ref: ref, size: size, radius: "sm", required: required, leftSection: leftSection, rightSection: rightSection, ...labelProps, error: effectiveError, ...props }));
|
|
86
80
|
});
|
|
87
81
|
TextInput.displayName = 'TextInput';
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import React, { forwardRef } from 'react';
|
|
4
|
-
import { TextInput as MantineTextInput, TextInputProps as MantineTextInputProps
|
|
5
|
-
import { IconInfoCircle } from '@tabler/icons-react';
|
|
4
|
+
import { TextInput as MantineTextInput, TextInputProps as MantineTextInputProps } from '@mantine/core';
|
|
6
5
|
import { ComponentSize } from '../config';
|
|
7
|
-
import {
|
|
8
|
-
import { Tooltip } from '../Overlays/Tooltip';
|
|
6
|
+
import { getInputLabelProps } from './inputLabel';
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
9
|
* Enhanced TextInput props extending Mantine's TextInputProps
|
|
@@ -17,7 +15,7 @@ export interface DSTextInputProps extends Omit<MantineTextInputProps, 'size' | '
|
|
|
17
15
|
required?: boolean;
|
|
18
16
|
/** Whether to show "(Optional)" text after label */
|
|
19
17
|
showOptional?: boolean;
|
|
20
|
-
/** Whether to show a help icon with a tooltip
|
|
18
|
+
/** Whether to show a (?) help icon with a tooltip to the right of the label */
|
|
21
19
|
hasHelpIcon?: boolean;
|
|
22
20
|
/** Tooltip label shown when hovering the help icon. Also used as aria-label for a11y */
|
|
23
21
|
helpIconLabel?: string;
|
|
@@ -113,40 +111,14 @@ export const TextInput = forwardRef<HTMLInputElement, DSTextInputProps>(
|
|
|
113
111
|
) => {
|
|
114
112
|
const effectiveError = error === true ? (errorCaption ?? true) : error;
|
|
115
113
|
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
return label;
|
|
126
|
-
}, [label, showOptional, required]);
|
|
127
|
-
|
|
128
|
-
const helpIconElement = hasHelpIcon ? (
|
|
129
|
-
<Tooltip
|
|
130
|
-
label={helpIconLabel ?? 'Help'}
|
|
131
|
-
position="top"
|
|
132
|
-
withArrow
|
|
133
|
-
>
|
|
134
|
-
<ActionIcon
|
|
135
|
-
variant="transparent"
|
|
136
|
-
size="xs"
|
|
137
|
-
aria-label={helpIconLabel ?? 'Help'}
|
|
138
|
-
onClick={onHelpIconClick}
|
|
139
|
-
color="gray"
|
|
140
|
-
style={{ cursor: onHelpIconClick ? 'pointer' : 'default' }}
|
|
141
|
-
>
|
|
142
|
-
<IconInfoCircle size={14} aria-hidden />
|
|
143
|
-
</ActionIcon>
|
|
144
|
-
</Tooltip>
|
|
145
|
-
) : null;
|
|
146
|
-
|
|
147
|
-
const composedRightSection = (helpIconElement && rightSection)
|
|
148
|
-
? <Group gap={4} wrap="nowrap">{rightSection}{helpIconElement}</Group>
|
|
149
|
-
: helpIconElement || rightSection;
|
|
114
|
+
const labelProps = getInputLabelProps({
|
|
115
|
+
label,
|
|
116
|
+
required,
|
|
117
|
+
showOptional,
|
|
118
|
+
hasHelpIcon,
|
|
119
|
+
helpIconLabel,
|
|
120
|
+
onHelpIconClick,
|
|
121
|
+
});
|
|
150
122
|
|
|
151
123
|
return (
|
|
152
124
|
<MantineTextInput
|
|
@@ -155,8 +127,8 @@ export const TextInput = forwardRef<HTMLInputElement, DSTextInputProps>(
|
|
|
155
127
|
radius="sm"
|
|
156
128
|
required={required}
|
|
157
129
|
leftSection={leftSection}
|
|
158
|
-
rightSection={
|
|
159
|
-
|
|
130
|
+
rightSection={rightSection}
|
|
131
|
+
{...labelProps}
|
|
160
132
|
error={effectiveError}
|
|
161
133
|
{...props}
|
|
162
134
|
/>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ActionIcon } from '@mantine/core';
|
|
4
|
+
import { IconHelp } from '@tabler/icons-react';
|
|
5
|
+
import { Text } from '../Typography/Text.js';
|
|
6
|
+
import { Tooltip } from '../Overlays/Tooltip.js';
|
|
7
|
+
/**
|
|
8
|
+
* Shared label for DS form inputs: label, required asterisk or "(Optional)", then
|
|
9
|
+
* the (?) help icon, the order used by the Figma input label.
|
|
10
|
+
*
|
|
11
|
+
* Returns the props to spread onto the Mantine input. `withAsterisk` is only set
|
|
12
|
+
* when a help icon is shown: Mantine renders its asterisk inside the label after
|
|
13
|
+
* the content, which would put it behind the icon, so in that case the asterisk is
|
|
14
|
+
* rendered here instead. The help icon needs a label to attach to.
|
|
15
|
+
*
|
|
16
|
+
* Sizing follows Mantine core: the label font-size tracks the field `size`, set by the
|
|
17
|
+
* input tokens (`input.label.sizes`) on `.mantine-InputWrapper-label[data-size]`. The
|
|
18
|
+
* "(Optional)" text inherits it and the (?) icon is sized by the same tokens.
|
|
19
|
+
*/
|
|
20
|
+
export function getInputLabelProps({ label, required, showOptional, hasHelpIcon, helpIconLabel, onHelpIconClick, }) {
|
|
21
|
+
if (!label)
|
|
22
|
+
return { label };
|
|
23
|
+
const optional = showOptional && !required && (_jsxs(_Fragment, { children: [' ', _jsx(Text, { span: true, fz: "inherit", c: "dimmed", fw: "normal", children: "(Optional)" })] }));
|
|
24
|
+
if (!hasHelpIcon) {
|
|
25
|
+
return optional ? { label: _jsxs(_Fragment, { children: [label, optional] }) } : { label };
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
withAsterisk: false,
|
|
29
|
+
label: (_jsxs(_Fragment, { children: [label, required && (_jsx("span", { className: "mantine-InputWrapper-required", "aria-hidden": true, children: ' *' })), optional, ' ', _jsx(Tooltip, { label: helpIconLabel ?? 'Help', position: "top", withArrow: true, children: _jsx(ActionIcon, { variant: "transparent", size: "xs", color: "gray", "aria-label": helpIconLabel ?? 'Help', onClick: (event) => {
|
|
30
|
+
// The icon lives inside the <label>; don't let the click focus the field.
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
onHelpIconClick?.(event);
|
|
33
|
+
}, children: _jsx(IconHelp, { size: 16, "aria-hidden": true }) }) })] })),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ActionIcon } from '@mantine/core';
|
|
3
|
+
import { IconHelp } from '@tabler/icons-react';
|
|
4
|
+
import { Text } from '../Typography/Text';
|
|
5
|
+
import { Tooltip } from '../Overlays/Tooltip';
|
|
6
|
+
|
|
7
|
+
export interface InputLabelOptions {
|
|
8
|
+
label?: React.ReactNode;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
/** Show "(Optional)" after the label when the field is not required */
|
|
11
|
+
showOptional?: boolean;
|
|
12
|
+
/** Show a (?) help icon with a tooltip to the right of the label */
|
|
13
|
+
hasHelpIcon?: boolean;
|
|
14
|
+
/** Tooltip text for the help icon; also its aria-label */
|
|
15
|
+
helpIconLabel?: string;
|
|
16
|
+
/** Click handler for the help icon */
|
|
17
|
+
onHelpIconClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Shared label for DS form inputs: label, required asterisk or "(Optional)", then
|
|
22
|
+
* the (?) help icon, the order used by the Figma input label.
|
|
23
|
+
*
|
|
24
|
+
* Returns the props to spread onto the Mantine input. `withAsterisk` is only set
|
|
25
|
+
* when a help icon is shown: Mantine renders its asterisk inside the label after
|
|
26
|
+
* the content, which would put it behind the icon, so in that case the asterisk is
|
|
27
|
+
* rendered here instead. The help icon needs a label to attach to.
|
|
28
|
+
*
|
|
29
|
+
* Sizing follows Mantine core: the label font-size tracks the field `size`, set by the
|
|
30
|
+
* input tokens (`input.label.sizes`) on `.mantine-InputWrapper-label[data-size]`. The
|
|
31
|
+
* "(Optional)" text inherits it and the (?) icon is sized by the same tokens.
|
|
32
|
+
*/
|
|
33
|
+
export function getInputLabelProps({
|
|
34
|
+
label,
|
|
35
|
+
required,
|
|
36
|
+
showOptional,
|
|
37
|
+
hasHelpIcon,
|
|
38
|
+
helpIconLabel,
|
|
39
|
+
onHelpIconClick,
|
|
40
|
+
}: InputLabelOptions): { label: React.ReactNode; withAsterisk?: boolean } {
|
|
41
|
+
if (!label) return { label };
|
|
42
|
+
|
|
43
|
+
const optional = showOptional && !required && (
|
|
44
|
+
<>
|
|
45
|
+
{' '}
|
|
46
|
+
<Text span fz="inherit" c="dimmed" fw="normal">(Optional)</Text>
|
|
47
|
+
</>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
if (!hasHelpIcon) {
|
|
51
|
+
return optional ? { label: <>{label}{optional}</> } : { label };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
withAsterisk: false,
|
|
56
|
+
label: (
|
|
57
|
+
<>
|
|
58
|
+
{label}
|
|
59
|
+
{required && (
|
|
60
|
+
<span className="mantine-InputWrapper-required" aria-hidden>
|
|
61
|
+
{' *'}
|
|
62
|
+
</span>
|
|
63
|
+
)}
|
|
64
|
+
{optional}{' '}
|
|
65
|
+
<Tooltip label={helpIconLabel ?? 'Help'} position="top" withArrow>
|
|
66
|
+
<ActionIcon
|
|
67
|
+
variant="transparent"
|
|
68
|
+
size="xs"
|
|
69
|
+
color="gray"
|
|
70
|
+
aria-label={helpIconLabel ?? 'Help'}
|
|
71
|
+
onClick={(event) => {
|
|
72
|
+
// The icon lives inside the <label>; don't let the click focus the field.
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
onHelpIconClick?.(event);
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
<IconHelp size={16} aria-hidden />
|
|
78
|
+
</ActionIcon>
|
|
79
|
+
</Tooltip>
|
|
80
|
+
</>
|
|
81
|
+
),
|
|
82
|
+
};
|
|
83
|
+
}
|
package/dist/Layout/Inline.js
CHANGED
|
@@ -1,46 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import React, { forwardRef } from 'react';
|
|
4
|
-
import { Group as MantineGroup } from '@mantine/core';
|
|
2
|
+
import { Group } from './Group.js';
|
|
5
3
|
/**
|
|
6
|
-
*
|
|
4
|
+
* Inline
|
|
7
5
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* same primitive — do not mix both in new code.
|
|
11
|
-
*
|
|
12
|
-
* Arranges children horizontally with design-system spacing. Built on Mantine Group.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```tsx
|
|
16
|
-
* // Basic horizontal layout
|
|
17
|
-
* <Inline gap="md">
|
|
18
|
-
* <Button>First</Button>
|
|
19
|
-
* <Button>Second</Button>
|
|
20
|
-
* <Button>Third</Button>
|
|
21
|
-
* </Inline>
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```tsx
|
|
26
|
-
* // Inline with alignment and wrapping
|
|
27
|
-
* <Inline gap="sm" align="center" wrap="wrap">
|
|
28
|
-
* <Badge>Tag 1</Badge>
|
|
29
|
-
* <Badge>Tag 2</Badge>
|
|
30
|
-
* <Badge>Tag 3</Badge>
|
|
31
|
-
* </Inline>
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```tsx
|
|
36
|
-
* // Justified inline layout
|
|
37
|
-
* <Inline justify="space-between">
|
|
38
|
-
* <Text>Left content</Text>
|
|
39
|
-
* <Button>Right action</Button>
|
|
40
|
-
* </Inline>
|
|
41
|
-
* ```
|
|
6
|
+
* The DS name for a horizontal flex row (Figma `flex-direction: row`). It is the same
|
|
7
|
+
* component as `Group` (Mantine's `Group` with DS defaults), not a separate implementation.
|
|
42
8
|
*/
|
|
43
|
-
export const Inline =
|
|
44
|
-
return (_jsx(MantineGroup, { ref: ref, gap: gap, align: align, justify: justify, wrap: wrap, ...props, children: children }));
|
|
45
|
-
});
|
|
46
|
-
Inline.displayName = 'Inline';
|
|
9
|
+
export const Inline = Group;
|
package/dist/Layout/Inline.tsx
CHANGED
|
@@ -1,86 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { Group as MantineGroup, GroupProps as MantineGroupProps } from '@mantine/core';
|
|
5
|
-
import { SpacingScale } from './Stack';
|
|
3
|
+
import { Group, DSGroupProps } from './Group';
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
* Enhanced Inline props extending Mantine's GroupProps
|
|
9
|
-
*/
|
|
10
|
-
export interface DSInlineProps extends Omit<MantineGroupProps, 'gap'> {
|
|
11
|
-
/** Spacing between inline items using design system scale */
|
|
12
|
-
gap?: SpacingScale | string | number;
|
|
13
|
-
/** Alignment of items along the cross axis */
|
|
14
|
-
align?: 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch';
|
|
15
|
-
/** Distribution of items along the main axis */
|
|
16
|
-
justify?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';
|
|
17
|
-
/** Whether items should wrap to new lines */
|
|
18
|
-
wrap?: 'nowrap' | 'wrap' | 'wrap-reverse';
|
|
19
|
-
}
|
|
5
|
+
export type DSInlineProps = DSGroupProps;
|
|
20
6
|
|
|
21
7
|
/**
|
|
22
|
-
*
|
|
8
|
+
* Inline
|
|
23
9
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* same primitive — do not mix both in new code.
|
|
27
|
-
*
|
|
28
|
-
* Arranges children horizontally with design-system spacing. Built on Mantine Group.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```tsx
|
|
32
|
-
* // Basic horizontal layout
|
|
33
|
-
* <Inline gap="md">
|
|
34
|
-
* <Button>First</Button>
|
|
35
|
-
* <Button>Second</Button>
|
|
36
|
-
* <Button>Third</Button>
|
|
37
|
-
* </Inline>
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```tsx
|
|
42
|
-
* // Inline with alignment and wrapping
|
|
43
|
-
* <Inline gap="sm" align="center" wrap="wrap">
|
|
44
|
-
* <Badge>Tag 1</Badge>
|
|
45
|
-
* <Badge>Tag 2</Badge>
|
|
46
|
-
* <Badge>Tag 3</Badge>
|
|
47
|
-
* </Inline>
|
|
48
|
-
* ```
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```tsx
|
|
52
|
-
* // Justified inline layout
|
|
53
|
-
* <Inline justify="space-between">
|
|
54
|
-
* <Text>Left content</Text>
|
|
55
|
-
* <Button>Right action</Button>
|
|
56
|
-
* </Inline>
|
|
57
|
-
* ```
|
|
10
|
+
* The DS name for a horizontal flex row (Figma `flex-direction: row`). It is the same
|
|
11
|
+
* component as `Group` (Mantine's `Group` with DS defaults), not a separate implementation.
|
|
58
12
|
*/
|
|
59
|
-
export const Inline =
|
|
60
|
-
(
|
|
61
|
-
{
|
|
62
|
-
gap = 'md',
|
|
63
|
-
align = 'center',
|
|
64
|
-
justify = 'flex-start',
|
|
65
|
-
wrap = 'wrap',
|
|
66
|
-
children,
|
|
67
|
-
...props
|
|
68
|
-
},
|
|
69
|
-
ref
|
|
70
|
-
) => {
|
|
71
|
-
return (
|
|
72
|
-
<MantineGroup
|
|
73
|
-
ref={ref}
|
|
74
|
-
gap={gap}
|
|
75
|
-
align={align}
|
|
76
|
-
justify={justify}
|
|
77
|
-
wrap={wrap}
|
|
78
|
-
{...props}
|
|
79
|
-
>
|
|
80
|
-
{children}
|
|
81
|
-
</MantineGroup>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
Inline.displayName = 'Inline';
|
|
13
|
+
export const Inline = Group;
|
package/dist/Overlays/Tooltip.js
CHANGED
|
@@ -41,7 +41,7 @@ import { Tooltip as MantineTooltip } from '@mantine/core';
|
|
|
41
41
|
* <Button>Delayed</Button>
|
|
42
42
|
* </Tooltip>
|
|
43
43
|
*/
|
|
44
|
-
export const Tooltip = forwardRef(({ label, children, position = 'top', disabled = false, openDelay = 0, closeDelay = 0, keepMounted = false, width = 'auto', withArrow = true, arrowSize = 6, ...props }, ref) => {
|
|
44
|
+
export const Tooltip = forwardRef(({ label, children, position = 'top', disabled = false, openDelay = 0, closeDelay = 0, keepMounted = false, width = 'auto', maxWidth = 300, withArrow = true, arrowSize = 6, ...props }, ref) => {
|
|
45
45
|
return (_jsx(MantineTooltip, { ref: ref, label: label, position: position, disabled: disabled, openDelay: openDelay, closeDelay: closeDelay, keepMounted: keepMounted, withArrow: withArrow, arrowSize: arrowSize,
|
|
46
46
|
// Design system styling from Figma
|
|
47
47
|
color: "dark", radius: "sm",
|
|
@@ -58,7 +58,7 @@ export const Tooltip = forwardRef(({ label, children, position = 'top', disabled
|
|
|
58
58
|
borderRadius: '4px',
|
|
59
59
|
border: 'none',
|
|
60
60
|
width: width !== 'auto' ? width : undefined,
|
|
61
|
-
maxWidth: width === 'auto' ?
|
|
61
|
+
maxWidth: width === 'auto' ? `${maxWidth}px` : undefined,
|
|
62
62
|
},
|
|
63
63
|
arrow: {
|
|
64
64
|
backgroundColor: '#212529',
|