@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
|
@@ -1,125 +1,43 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { forwardRef } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Pill as MantinePill, PillProps as MantinePillProps } from '@mantine/core';
|
|
5
|
+
import { ComponentSize } from '../config';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
size?:
|
|
12
|
-
/** Whether the pill can be removed */
|
|
13
|
-
withRemoveButton?: boolean;
|
|
14
|
-
/** Called when remove button is clicked */
|
|
15
|
-
onRemove?: () => void;
|
|
7
|
+
// ========================== TYPES ==========================
|
|
8
|
+
|
|
9
|
+
export interface DSPillProps extends Omit<MantinePillProps, 'size'> {
|
|
10
|
+
/** Pill size from design system scale */
|
|
11
|
+
size?: ComponentSize;
|
|
16
12
|
}
|
|
17
13
|
|
|
18
|
-
//
|
|
19
|
-
const sizeConfig = {
|
|
20
|
-
xs: {
|
|
21
|
-
height: 18,
|
|
22
|
-
fontSize: 10,
|
|
23
|
-
lineHeight: 10,
|
|
24
|
-
letterSpacing: 0.1563,
|
|
25
|
-
px: 8,
|
|
26
|
-
gap: 0,
|
|
27
|
-
closeSize: 18,
|
|
28
|
-
},
|
|
29
|
-
sm: {
|
|
30
|
-
height: 24,
|
|
31
|
-
fontSize: 11,
|
|
32
|
-
lineHeight: 12,
|
|
33
|
-
letterSpacing: 0.17,
|
|
34
|
-
px: 8,
|
|
35
|
-
gap: 6,
|
|
36
|
-
closeSize: 14,
|
|
37
|
-
},
|
|
38
|
-
md: {
|
|
39
|
-
height: 25,
|
|
40
|
-
fontSize: 14,
|
|
41
|
-
lineHeight: 14,
|
|
42
|
-
letterSpacing: 0.2184,
|
|
43
|
-
px: 11.2,
|
|
44
|
-
gap: 8,
|
|
45
|
-
closeSize: 25,
|
|
46
|
-
},
|
|
47
|
-
lg: {
|
|
48
|
-
height: 32,
|
|
49
|
-
fontSize: 13,
|
|
50
|
-
lineHeight: 14,
|
|
51
|
-
letterSpacing: 0.2,
|
|
52
|
-
px: 12,
|
|
53
|
-
gap: 8,
|
|
54
|
-
closeSize: 18,
|
|
55
|
-
},
|
|
56
|
-
xl: {
|
|
57
|
-
height: 36,
|
|
58
|
-
fontSize: 14,
|
|
59
|
-
lineHeight: 16,
|
|
60
|
-
letterSpacing: 0.22,
|
|
61
|
-
px: 14,
|
|
62
|
-
gap: 8,
|
|
63
|
-
closeSize: 20,
|
|
64
|
-
},
|
|
65
|
-
};
|
|
14
|
+
// ========================== COMPONENT ==========================
|
|
66
15
|
|
|
16
|
+
/**
|
|
17
|
+
* AppDirect Design System Pill Component
|
|
18
|
+
*
|
|
19
|
+
* A thin wrapper over Mantine's Pill. Colors, radius, height and font size
|
|
20
|
+
* come from the `pill` / `multiselect.pill` component tokens, not from this file.
|
|
21
|
+
*
|
|
22
|
+
* Inside a `PillsInput` / `MultiSelect`, pass `size` explicitly so the pill
|
|
23
|
+
* matches the field: the DS default of `md` takes precedence over the size
|
|
24
|
+
* Mantine would otherwise inherit from the field.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <Pill>Design</Pill>
|
|
29
|
+
* <Pill withRemoveButton onRemove={() => remove('design')}>Design</Pill>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
67
32
|
export const Pill = forwardRef<HTMLDivElement, DSPillProps>(
|
|
68
|
-
({
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const config = sizeConfig[size];
|
|
77
|
-
|
|
78
|
-
const colors = {
|
|
79
|
-
backgroundColor: 'var(--ad-color-bg-subtle)',
|
|
80
|
-
color: 'var(--ad-color-text-dimmed)',
|
|
81
|
-
border: 'none',
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<Box
|
|
86
|
-
ref={ref}
|
|
87
|
-
style={{
|
|
88
|
-
display: 'inline-flex',
|
|
89
|
-
alignItems: 'center',
|
|
90
|
-
height: config.height,
|
|
91
|
-
paddingLeft: config.px,
|
|
92
|
-
paddingRight: withRemoveButton ? 0 : config.px,
|
|
93
|
-
borderRadius: config.height / 2,
|
|
94
|
-
fontSize: config.fontSize,
|
|
95
|
-
fontWeight: 400,
|
|
96
|
-
lineHeight: `${config.lineHeight}px`,
|
|
97
|
-
letterSpacing: config.letterSpacing,
|
|
98
|
-
userSelect: 'none',
|
|
99
|
-
...colors,
|
|
100
|
-
...style,
|
|
101
|
-
}}
|
|
102
|
-
{...others}
|
|
103
|
-
>
|
|
104
|
-
<Inline gap={config.gap} wrap="nowrap">
|
|
105
|
-
<span>{children}</span>
|
|
106
|
-
{withRemoveButton && (
|
|
107
|
-
<CloseButton
|
|
108
|
-
size={config.closeSize}
|
|
109
|
-
onClick={onRemove}
|
|
110
|
-
variant="transparent"
|
|
111
|
-
style={{
|
|
112
|
-
color: 'currentColor',
|
|
113
|
-
minWidth: config.closeSize,
|
|
114
|
-
minHeight: config.closeSize,
|
|
115
|
-
}}
|
|
116
|
-
aria-label="Remove"
|
|
117
|
-
/>
|
|
118
|
-
)}
|
|
119
|
-
</Inline>
|
|
120
|
-
</Box>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
33
|
+
({ size = 'md', removeButtonProps, ...props }, ref) => (
|
|
34
|
+
<MantinePill
|
|
35
|
+
ref={ref}
|
|
36
|
+
size={size}
|
|
37
|
+
removeButtonProps={{ 'aria-label': 'Remove', ...removeButtonProps }}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
)
|
|
123
41
|
);
|
|
124
42
|
|
|
125
|
-
Pill.displayName = 'Pill';
|
|
43
|
+
Pill.displayName = 'Pill';
|
|
@@ -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 { ColorInput as MantineColorInput
|
|
5
|
-
import {
|
|
6
|
-
import { Text } from '../Typography/Text.js';
|
|
7
|
-
import { Tooltip } from '../Overlays/Tooltip.js';
|
|
4
|
+
import { ColorInput as MantineColorInput } from '@mantine/core';
|
|
5
|
+
import { getInputLabelProps } from './inputLabel.js';
|
|
8
6
|
// ========================== COMPONENT ==========================
|
|
9
7
|
/**
|
|
10
8
|
* AppDirect Design System ColorInput Component
|
|
@@ -31,18 +29,14 @@ import { Tooltip } from '../Overlays/Tooltip.js';
|
|
|
31
29
|
*/
|
|
32
30
|
export const ColorInput = forwardRef(({ size = 'md', showOptional = false, required, label, hasHelpIcon = false, helpIconLabel, onHelpIconClick, rightSection, error, errorCaption, ...props }, ref) => {
|
|
33
31
|
const effectiveError = error === true ? (errorCaption ?? true) : error;
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const composedRightSection = (helpIconElement && rightSection)
|
|
44
|
-
? _jsxs(Group, { gap: 4, wrap: "nowrap", children: [rightSection, helpIconElement] })
|
|
45
|
-
: helpIconElement || rightSection;
|
|
46
|
-
return (_jsx(MantineColorInput, { ref: ref, size: size, radius: "sm", required: required, label: enhancedLabel, rightSection: composedRightSection, error: effectiveError, ...props }));
|
|
32
|
+
const labelProps = getInputLabelProps({
|
|
33
|
+
label,
|
|
34
|
+
required,
|
|
35
|
+
showOptional,
|
|
36
|
+
hasHelpIcon,
|
|
37
|
+
helpIconLabel,
|
|
38
|
+
onHelpIconClick,
|
|
39
|
+
});
|
|
40
|
+
return (_jsx(MantineColorInput, { ref: ref, size: size, radius: "sm", required: required, rightSection: rightSection, ...labelProps, error: effectiveError, ...props }));
|
|
47
41
|
});
|
|
48
42
|
ColorInput.displayName = 'ColorInput';
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import React, { forwardRef } from 'react';
|
|
4
|
-
import { ColorInput as MantineColorInput, ColorInputProps as MantineColorInputProps
|
|
5
|
-
import { IconInfoCircle } from '@tabler/icons-react';
|
|
4
|
+
import { ColorInput as MantineColorInput, ColorInputProps as MantineColorInputProps } 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 DSColorInputProps extends Omit<MantineColorInputProps, 'size' |
|
|
|
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;
|
|
@@ -71,40 +69,14 @@ export const ColorInput = forwardRef<HTMLInputElement, DSColorInputProps>(
|
|
|
71
69
|
) => {
|
|
72
70
|
const effectiveError = error === true ? (errorCaption ?? true) : error;
|
|
73
71
|
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
return label;
|
|
84
|
-
}, [label, showOptional, required]);
|
|
85
|
-
|
|
86
|
-
const helpIconElement = hasHelpIcon ? (
|
|
87
|
-
<Tooltip
|
|
88
|
-
label={helpIconLabel ?? 'Help'}
|
|
89
|
-
position="top"
|
|
90
|
-
withArrow
|
|
91
|
-
>
|
|
92
|
-
<ActionIcon
|
|
93
|
-
variant="transparent"
|
|
94
|
-
size="xs"
|
|
95
|
-
aria-label={helpIconLabel ?? 'Help'}
|
|
96
|
-
onClick={onHelpIconClick}
|
|
97
|
-
color="gray"
|
|
98
|
-
style={{ cursor: onHelpIconClick ? 'pointer' : 'default' }}
|
|
99
|
-
>
|
|
100
|
-
<IconInfoCircle size={14} aria-hidden />
|
|
101
|
-
</ActionIcon>
|
|
102
|
-
</Tooltip>
|
|
103
|
-
) : null;
|
|
104
|
-
|
|
105
|
-
const composedRightSection = (helpIconElement && rightSection)
|
|
106
|
-
? <Group gap={4} wrap="nowrap">{rightSection}{helpIconElement}</Group>
|
|
107
|
-
: helpIconElement || rightSection;
|
|
72
|
+
const labelProps = getInputLabelProps({
|
|
73
|
+
label,
|
|
74
|
+
required,
|
|
75
|
+
showOptional,
|
|
76
|
+
hasHelpIcon,
|
|
77
|
+
helpIconLabel,
|
|
78
|
+
onHelpIconClick,
|
|
79
|
+
});
|
|
108
80
|
|
|
109
81
|
return (
|
|
110
82
|
<MantineColorInput
|
|
@@ -112,8 +84,8 @@ export const ColorInput = forwardRef<HTMLInputElement, DSColorInputProps>(
|
|
|
112
84
|
size={size}
|
|
113
85
|
radius="sm"
|
|
114
86
|
required={required}
|
|
115
|
-
|
|
116
|
-
|
|
87
|
+
rightSection={rightSection}
|
|
88
|
+
{...labelProps}
|
|
117
89
|
error={effectiveError}
|
|
118
90
|
{...props}
|
|
119
91
|
/>
|
|
@@ -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 { NumberInput as MantineNumberInput,
|
|
5
|
-
import {
|
|
6
|
-
import { Text } from '../Typography/Text.js';
|
|
7
|
-
import { Tooltip } from '../Overlays/Tooltip.js';
|
|
4
|
+
import { NumberInput as MantineNumberInput, } from '@mantine/core';
|
|
5
|
+
import { getInputLabelProps } from './inputLabel.js';
|
|
8
6
|
// ========================== COMPONENT ==========================
|
|
9
7
|
/**
|
|
10
8
|
* AppDirect Design System NumberInput Component
|
|
@@ -15,36 +13,14 @@ import { Tooltip } from '../Overlays/Tooltip.js';
|
|
|
15
13
|
*/
|
|
16
14
|
export const NumberInput = forwardRef(({ size = 'md', showOptional = false, required, label, hasHelpIcon = false, helpIconLabel, onHelpIconClick, leftSection, rightSection, error, errorCaption, hideControls, ...props }, ref) => {
|
|
17
15
|
const effectiveError = error === true ? (errorCaption ?? true) : error;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const nativeControlsVisible = !hideControls && !props.readOnly && !props.disabled;
|
|
28
|
-
const composedLeftSection = React.useMemo(() => {
|
|
29
|
-
if (!helpIconElement)
|
|
30
|
-
return leftSection;
|
|
31
|
-
if (nativeControlsVisible) {
|
|
32
|
-
if (leftSection) {
|
|
33
|
-
return (_jsxs(Group, { gap: 4, wrap: "nowrap", children: [helpIconElement, leftSection] }));
|
|
34
|
-
}
|
|
35
|
-
return helpIconElement;
|
|
36
|
-
}
|
|
37
|
-
return leftSection;
|
|
38
|
-
}, [helpIconElement, leftSection, nativeControlsVisible]);
|
|
39
|
-
const composedRightSection = React.useMemo(() => {
|
|
40
|
-
if (!helpIconElement || nativeControlsVisible) {
|
|
41
|
-
return rightSection;
|
|
42
|
-
}
|
|
43
|
-
if (rightSection) {
|
|
44
|
-
return (_jsxs(Group, { gap: 4, wrap: "nowrap", children: [rightSection, helpIconElement] }));
|
|
45
|
-
}
|
|
46
|
-
return helpIconElement;
|
|
47
|
-
}, [helpIconElement, nativeControlsVisible, rightSection]);
|
|
48
|
-
return (_jsx(MantineNumberInput, { ref: ref, size: size, radius: "sm", required: required, label: enhancedLabel, error: effectiveError, hideControls: hideControls, leftSection: composedLeftSection, rightSection: composedRightSection, ...props }));
|
|
16
|
+
const labelProps = getInputLabelProps({
|
|
17
|
+
label,
|
|
18
|
+
required,
|
|
19
|
+
showOptional,
|
|
20
|
+
hasHelpIcon,
|
|
21
|
+
helpIconLabel,
|
|
22
|
+
onHelpIconClick,
|
|
23
|
+
});
|
|
24
|
+
return (_jsx(MantineNumberInput, { ref: ref, size: size, radius: "sm", required: required, error: effectiveError, hideControls: hideControls, leftSection: leftSection, rightSection: rightSection, ...labelProps, ...props }));
|
|
49
25
|
});
|
|
50
26
|
NumberInput.displayName = 'NumberInput';
|
|
@@ -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';
|