@appdirect/design-system 0.0.0-stage → 0.0.1
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/README.md +12 -2
- package/dist/Buttons/ActionIcon.tsx +37 -0
- package/dist/Buttons/Button.module.css +5 -0
- package/dist/Buttons/Button.tsx +124 -0
- package/dist/Buttons/CloseButton.tsx +83 -0
- package/dist/Buttons/index.ts +20 -0
- package/dist/Combobox/AutocompleteClearable.tsx +128 -0
- package/dist/Combobox/Combobox.tsx +37 -0
- package/dist/Combobox/Multiselect.tsx +158 -0
- package/dist/Combobox/SearchableSelect.tsx +131 -0
- package/dist/Combobox/Select.tsx +154 -0
- package/dist/Combobox/index.ts +20 -0
- package/dist/ComplexComponents/DashboardWidget/DashboardWidget.tsx +280 -0
- package/dist/ComplexComponents/DashboardWidget/index.ts +2 -0
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.tsx +177 -0
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.ts +35 -0
- package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.tsx +74 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.tsx +358 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.tsx +48 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/DateRangeFilter.tsx +26 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterRenderer.tsx +71 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterSystem.tsx +158 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/MultiSelectFilter.tsx +79 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/SingleSelectFilter.tsx +65 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/index.ts +70 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/types.ts +140 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.tsx +76 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.tsx +73 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.tsx +50 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.tsx +788 -0
- package/dist/ComplexComponents/DataTable/DataTable.tsx +582 -0
- package/dist/ComplexComponents/DataTable/ErrorOverlay/index.tsx +29 -0
- package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.tsx +57 -0
- package/dist/ComplexComponents/DataTable/index.ts +2 -0
- package/dist/ComplexComponents/DataTable/translations/en.ts +115 -0
- package/dist/ComplexComponents/DataTable/translations/index.ts +23 -0
- package/dist/ComplexComponents/KeyInsight/KeyInsights.tsx +221 -0
- package/dist/ComplexComponents/KeyInsight/index.ts +2 -0
- package/dist/ComplexComponents/NameValue/NameValue.tsx +175 -0
- package/dist/ComplexComponents/NameValue/NameValueItem.tsx +100 -0
- package/dist/ComplexComponents/NameValue/index.ts +4 -0
- package/dist/ComplexComponents/PageContentHeader/DescriptionBlock.tsx +65 -0
- package/dist/ComplexComponents/PageContentHeader/PageContentHeader.tsx +383 -0
- package/dist/ComplexComponents/PageContentHeader/index.ts +4 -0
- package/dist/ComplexComponents/Utilities/CopyButton.tsx +82 -0
- package/dist/ComplexComponents/Utilities/index.ts +2 -0
- package/dist/DataDisplay/Alert.tsx +130 -0
- package/dist/DataDisplay/Avatar.tsx +216 -0
- package/dist/DataDisplay/Badge.tsx +119 -0
- package/dist/DataDisplay/Card.module.css +26 -0
- package/dist/DataDisplay/Card.tsx +163 -0
- package/dist/DataDisplay/Chip.tsx +66 -0
- package/dist/DataDisplay/Indicator.tsx +122 -0
- package/dist/DataDisplay/List.tsx +90 -0
- package/dist/DataDisplay/Pill.tsx +125 -0
- package/dist/DataDisplay/Progress.tsx +77 -0
- package/dist/DataDisplay/Table.tsx +57 -0
- package/dist/DataDisplay/ThemeIcon.tsx +67 -0
- package/dist/DataDisplay/index.ts +41 -0
- package/dist/Inputs/Checkbox.tsx +94 -0
- package/dist/Inputs/ColorInput.tsx +124 -0
- package/dist/Inputs/DropZone.tsx +78 -0
- package/dist/Inputs/FileInput.tsx +120 -0
- package/dist/Inputs/NumberInput.tsx +125 -0
- package/dist/Inputs/Radio.tsx +86 -0
- package/dist/Inputs/RadioGroup.tsx +90 -0
- package/dist/Inputs/SegmentedControl.tsx +64 -0
- package/dist/Inputs/Slider.tsx +69 -0
- package/dist/Inputs/Switch.tsx +67 -0
- package/dist/Inputs/TextArea.tsx +126 -0
- package/dist/Inputs/TextInput.tsx +167 -0
- package/dist/Inputs/index.ts +51 -0
- package/dist/Layout/Box.tsx +82 -0
- package/dist/Layout/Center.tsx +17 -0
- package/dist/Layout/Container.tsx +17 -0
- package/dist/Layout/Flex.tsx +18 -0
- package/dist/Layout/Grid.tsx +31 -0
- package/dist/Layout/Group.tsx +54 -0
- package/dist/Layout/Inline.tsx +86 -0
- package/dist/Layout/SimpleGrid.tsx +50 -0
- package/dist/Layout/Stack.tsx +86 -0
- package/dist/Layout/index.ts +29 -0
- package/dist/Misc/Divider.tsx +27 -0
- package/dist/Misc/Paper.tsx +47 -0
- package/dist/Misc/index.ts +15 -0
- package/dist/Navigation/Breadcrumb.tsx +138 -0
- package/dist/Navigation/NavLink.tsx +37 -0
- package/dist/Navigation/Stepper.tsx +17 -0
- package/dist/Navigation/Tabs.tsx +29 -0
- package/dist/Navigation/index.ts +17 -0
- package/dist/Overlays/Drawer.tsx +123 -0
- package/dist/Overlays/Menu.tsx +192 -0
- package/dist/Overlays/Modal.tsx +159 -0
- package/dist/Overlays/Popover.tsx +319 -0
- package/dist/Overlays/Tooltip.tsx +131 -0
- package/dist/Overlays/index.ts +19 -0
- package/dist/Shell/AppShellLayout.tsx +56 -0
- package/dist/Shell/HeaderBar.tsx +26 -0
- package/dist/Shell/SidebarNav.tsx +47 -0
- package/dist/Shell/SidebarNavLink.tsx +50 -0
- package/dist/Shell/SingleColumnLayout.tsx +22 -0
- package/dist/Shell/TertiaryColumnLayout.tsx +32 -0
- package/dist/Shell/index.ts +17 -0
- package/dist/Typography/Code.tsx +27 -0
- package/dist/Typography/Kbd.tsx +87 -0
- package/dist/Typography/Text.tsx +27 -0
- package/dist/Typography/Title.tsx +34 -0
- package/dist/Typography/index.ts +21 -0
- package/dist/bin/ds-audit.js +521 -0
- package/dist/config.ts +226 -0
- package/dist/contracts/Alert.json +80 -0
- package/dist/contracts/Badge.json +78 -0
- package/dist/contracts/Box.json +52 -0
- package/dist/contracts/Button.json +111 -0
- package/dist/contracts/DataTable.json +68 -0
- package/dist/contracts/Grid.json +35 -0
- package/dist/contracts/Group.json +44 -0
- package/dist/contracts/Inline.json +73 -0
- package/dist/contracts/PageContentHeader.json +107 -0
- package/dist/contracts/Stack.json +62 -0
- package/dist/contracts/ds-component-contract.v1.json +23 -0
- package/dist/contracts/index.json +55 -0
- package/dist/css/foundations.css +703 -0
- package/dist/css/mantine.css +1797 -0
- package/dist/hooks/useTableHandlers.ts +179 -0
- package/dist/hooks/useTableRenderFunctions.tsx +283 -0
- package/dist/hooks/useTableState.ts +81 -0
- package/dist/index.ts +210 -0
- package/dist/types.ts +202 -0
- package/package.json +56 -4
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Slider as MantineSlider, SliderProps as MantineSliderProps } from '@mantine/core';
|
|
5
|
+
|
|
6
|
+
// Define the DS Slider props interface
|
|
7
|
+
export interface DSSliderProps extends Omit<MantineSliderProps, 'radius'> {
|
|
8
|
+
/** Show "(Optional)" text after label */
|
|
9
|
+
showOptional?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Slider component with consistent design system styling.
|
|
14
|
+
* Built on top of Mantine's Slider component with enforced xl radius.
|
|
15
|
+
*
|
|
16
|
+
* NOTE: Prefer using Mantine's built-in props over CSS overrides when possible.
|
|
17
|
+
* Only add CSS overrides as a last resort when built-in props don't achieve the desired result.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* // Basic slider
|
|
22
|
+
* <Slider label="Volume" defaultValue={50} />
|
|
23
|
+
*
|
|
24
|
+
* // Optional field (shows gray optional text)
|
|
25
|
+
* <Slider label="Opacity" showOptional min={0} max={100} />
|
|
26
|
+
*
|
|
27
|
+
* // With min/max and step
|
|
28
|
+
* <Slider
|
|
29
|
+
* label="Rating"
|
|
30
|
+
* min={1}
|
|
31
|
+
* max={10}
|
|
32
|
+
* step={0.5}
|
|
33
|
+
* defaultValue={5}
|
|
34
|
+
* marks={[
|
|
35
|
+
* { value: 1, label: '1' },
|
|
36
|
+
* { value: 5, label: '5' },
|
|
37
|
+
* { value: 10, label: '10' }
|
|
38
|
+
* ]}
|
|
39
|
+
* />
|
|
40
|
+
*
|
|
41
|
+
* // Range slider
|
|
42
|
+
* <Slider
|
|
43
|
+
* label="Price Range"
|
|
44
|
+
* min={0}
|
|
45
|
+
* max={1000}
|
|
46
|
+
* defaultValue={[200, 800]}
|
|
47
|
+
* />
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export const Slider: React.FC<DSSliderProps> = ({
|
|
51
|
+
label,
|
|
52
|
+
showOptional = false,
|
|
53
|
+
...props
|
|
54
|
+
}) => {
|
|
55
|
+
// Create the label with optional indicator if needed
|
|
56
|
+
const labelWithOptional = showOptional && label
|
|
57
|
+
? `${label} (Optional)`
|
|
58
|
+
: label;
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<MantineSlider
|
|
62
|
+
label={labelWithOptional}
|
|
63
|
+
radius="xl"
|
|
64
|
+
{...props}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default Slider;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Switch as MantineSwitch, SwitchProps as MantineSwitchProps } from '@mantine/core';
|
|
5
|
+
|
|
6
|
+
// Define the DS Switch props interface
|
|
7
|
+
export interface DSSwitchProps extends Omit<MantineSwitchProps, 'color' | 'radius'> {
|
|
8
|
+
/** Show "(Optional)" text after label */
|
|
9
|
+
showOptional?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Switch component with consistent design system styling.
|
|
14
|
+
* Built on top of Mantine's Switch component with enforced green color and xl radius.
|
|
15
|
+
*
|
|
16
|
+
* NOTE: Prefer using Mantine's built-in props over CSS overrides when possible.
|
|
17
|
+
* Only add CSS overrides as a last resort when built-in props don't achieve the desired result.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* // Basic switch
|
|
22
|
+
* <Switch label="Enable notifications" />
|
|
23
|
+
*
|
|
24
|
+
* // Different sizes
|
|
25
|
+
* <Switch label="Small" size="sm" />
|
|
26
|
+
* <Switch label="Large" size="lg" />
|
|
27
|
+
*
|
|
28
|
+
* // Optional field (shows gray optional text)
|
|
29
|
+
* <Switch label="Auto-save" showOptional />
|
|
30
|
+
*
|
|
31
|
+
* // Controlled switch
|
|
32
|
+
* <Switch
|
|
33
|
+
* label="Dark mode"
|
|
34
|
+
* checked={darkMode}
|
|
35
|
+
* onChange={setDarkMode}
|
|
36
|
+
* />
|
|
37
|
+
*
|
|
38
|
+
* // Disabled states
|
|
39
|
+
* <Switch label="Disabled" disabled />
|
|
40
|
+
* <Switch label="Disabled Checked" disabled checked />
|
|
41
|
+
*
|
|
42
|
+
* // With on/off labels inside
|
|
43
|
+
* <Switch label="Power" onLabel="ON" offLabel="OFF" />
|
|
44
|
+
* <Switch label="WiFi" onLabel="CONNECTED" offLabel="DISCONNECTED" />
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export const Switch: React.FC<DSSwitchProps> = ({
|
|
48
|
+
label,
|
|
49
|
+
showOptional = false,
|
|
50
|
+
...props
|
|
51
|
+
}) => {
|
|
52
|
+
// Create the label with optional indicator if needed
|
|
53
|
+
const labelWithOptional = showOptional && label
|
|
54
|
+
? `${label} (Optional)`
|
|
55
|
+
: label;
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<MantineSwitch
|
|
59
|
+
label={labelWithOptional}
|
|
60
|
+
color="green"
|
|
61
|
+
radius="xl"
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default Switch;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Textarea as MantineTextarea, TextareaProps as MantineTextareaProps, ActionIcon, Group } from '@mantine/core';
|
|
5
|
+
import { IconInfoCircle } from '@tabler/icons-react';
|
|
6
|
+
import { ComponentSize } from '../config';
|
|
7
|
+
import { Text } from '../Typography/Text';
|
|
8
|
+
import { Tooltip } from '../Overlays/Tooltip';
|
|
9
|
+
|
|
10
|
+
// ========================== TYPES ==========================
|
|
11
|
+
|
|
12
|
+
export interface DSTextAreaProps extends Omit<MantineTextareaProps, 'size' | 'radius'> {
|
|
13
|
+
/** Input size from design system scale */
|
|
14
|
+
size?: ComponentSize;
|
|
15
|
+
/** Whether to show "(Optional)" text after label */
|
|
16
|
+
showOptional?: boolean;
|
|
17
|
+
/** Whether to show a help icon with a tooltip in the right section */
|
|
18
|
+
hasHelpIcon?: boolean;
|
|
19
|
+
/** Tooltip label shown when hovering the help icon. Also used as aria-label for a11y */
|
|
20
|
+
helpIconLabel?: string;
|
|
21
|
+
/** Optional click handler for the help icon */
|
|
22
|
+
onHelpIconClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
23
|
+
/**
|
|
24
|
+
* Optional error message text shown below the input when in error state.
|
|
25
|
+
* Used with error={true} (from state) for red border + message; omit for red border only.
|
|
26
|
+
*/
|
|
27
|
+
errorCaption?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// ========================== COMPONENT ==========================
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* AppDirect Design System TextArea Component
|
|
34
|
+
*
|
|
35
|
+
* A multi-line text input built on top of Mantine's Textarea with
|
|
36
|
+
* consistent design system styling and enforced radius.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* <TextArea label="Comments" placeholder="Enter your comments..." />
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* <TextArea
|
|
46
|
+
* label="Description"
|
|
47
|
+
* placeholder="Add more details"
|
|
48
|
+
* minRows={3}
|
|
49
|
+
* maxRows={10}
|
|
50
|
+
* autosize
|
|
51
|
+
* showOptional
|
|
52
|
+
* hasHelpIcon
|
|
53
|
+
* helpIconLabel="Provide a detailed description"
|
|
54
|
+
* />
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export const TextArea = forwardRef<HTMLTextAreaElement, DSTextAreaProps>(
|
|
58
|
+
(
|
|
59
|
+
{
|
|
60
|
+
size = 'md',
|
|
61
|
+
showOptional = false,
|
|
62
|
+
required,
|
|
63
|
+
label,
|
|
64
|
+
hasHelpIcon = false,
|
|
65
|
+
helpIconLabel,
|
|
66
|
+
onHelpIconClick,
|
|
67
|
+
rightSection,
|
|
68
|
+
error,
|
|
69
|
+
errorCaption,
|
|
70
|
+
...props
|
|
71
|
+
},
|
|
72
|
+
ref
|
|
73
|
+
) => {
|
|
74
|
+
const effectiveError = error === true ? (errorCaption ?? true) : error;
|
|
75
|
+
|
|
76
|
+
const enhancedLabel = React.useMemo(() => {
|
|
77
|
+
if (!label) return label;
|
|
78
|
+
if (showOptional && !required) {
|
|
79
|
+
return (
|
|
80
|
+
<>
|
|
81
|
+
{label} <Text span c="dimmed" fw="normal">(Optional)</Text>
|
|
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;
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<MantineTextarea
|
|
113
|
+
ref={ref}
|
|
114
|
+
size={size}
|
|
115
|
+
radius="sm"
|
|
116
|
+
required={required}
|
|
117
|
+
label={enhancedLabel}
|
|
118
|
+
rightSection={composedRightSection}
|
|
119
|
+
error={effectiveError}
|
|
120
|
+
{...props}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
TextArea.displayName = 'TextArea';
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { TextInput as MantineTextInput, TextInputProps as MantineTextInputProps, ActionIcon, Group } from '@mantine/core';
|
|
5
|
+
import { IconInfoCircle } from '@tabler/icons-react';
|
|
6
|
+
import { ComponentSize } from '../config';
|
|
7
|
+
import { Text } from '../Typography/Text';
|
|
8
|
+
import { Tooltip } from '../Overlays/Tooltip';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Enhanced TextInput props extending Mantine's TextInputProps
|
|
12
|
+
*/
|
|
13
|
+
export interface DSTextInputProps extends Omit<MantineTextInputProps, 'size' | 'radius'> {
|
|
14
|
+
/** Input size from design system scale */
|
|
15
|
+
size?: ComponentSize;
|
|
16
|
+
/** Whether input is required (shows asterisk) */
|
|
17
|
+
required?: boolean;
|
|
18
|
+
/** Whether to show "(Optional)" text after label */
|
|
19
|
+
showOptional?: boolean;
|
|
20
|
+
/** Whether to show a help icon with a tooltip in the right section */
|
|
21
|
+
hasHelpIcon?: boolean;
|
|
22
|
+
/** Tooltip label shown when hovering the help icon. Also used as aria-label for a11y */
|
|
23
|
+
helpIconLabel?: string;
|
|
24
|
+
/** Optional click handler for the help icon */
|
|
25
|
+
onHelpIconClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
26
|
+
/**
|
|
27
|
+
* Optional error message text shown below the input when in error state.
|
|
28
|
+
* Used with error={true} (from state) for red border + message; omit for red border only.
|
|
29
|
+
*/
|
|
30
|
+
errorCaption?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* AppDirect Design System TextInput Component
|
|
35
|
+
*
|
|
36
|
+
* A clean text input component built on top of Mantine's TextInput with
|
|
37
|
+
* consistent design system styling and enforced radius.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* // Basic usage (no indication)
|
|
42
|
+
* <TextInput label="Name" placeholder="Enter your name" />
|
|
43
|
+
*
|
|
44
|
+
* // Required field (shows asterisk)
|
|
45
|
+
* <TextInput
|
|
46
|
+
* label="Email"
|
|
47
|
+
* placeholder="Enter email"
|
|
48
|
+
* required
|
|
49
|
+
* />
|
|
50
|
+
*
|
|
51
|
+
* // Optional field (shows "(Optional)")
|
|
52
|
+
* <TextInput
|
|
53
|
+
* label="Phone"
|
|
54
|
+
* placeholder="Enter phone"
|
|
55
|
+
* showOptional
|
|
56
|
+
* />
|
|
57
|
+
*
|
|
58
|
+
* // With error
|
|
59
|
+
* <TextInput
|
|
60
|
+
* label="Password"
|
|
61
|
+
* error="Password is required"
|
|
62
|
+
* />
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* // Different sizes
|
|
68
|
+
* <TextInput size="xs" placeholder="Extra small" />
|
|
69
|
+
* <TextInput size="sm" placeholder="Small" />
|
|
70
|
+
* <TextInput size="md" placeholder="Medium" />
|
|
71
|
+
* <TextInput size="lg" placeholder="Large" />
|
|
72
|
+
* <TextInput size="xl" placeholder="Extra large" />
|
|
73
|
+
*
|
|
74
|
+
* // With icons
|
|
75
|
+
* <TextInput
|
|
76
|
+
* leftSection={<IconUser />}
|
|
77
|
+
* placeholder="Username"
|
|
78
|
+
* />
|
|
79
|
+
*
|
|
80
|
+
* // With help icon tooltip (hover)
|
|
81
|
+
* <TextInput
|
|
82
|
+
* label="API Key"
|
|
83
|
+
* hasHelpIcon
|
|
84
|
+
* helpIconLabel="Your API key can be found in account settings"
|
|
85
|
+
* />
|
|
86
|
+
*
|
|
87
|
+
* // With help icon click handler
|
|
88
|
+
* <TextInput
|
|
89
|
+
* label="API Key"
|
|
90
|
+
* hasHelpIcon
|
|
91
|
+
* helpIconLabel="Learn more about API keys"
|
|
92
|
+
* onHelpIconClick={() => openHelpDrawer()}
|
|
93
|
+
* />
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export const TextInput = forwardRef<HTMLInputElement, DSTextInputProps>(
|
|
97
|
+
(
|
|
98
|
+
{
|
|
99
|
+
size = 'md',
|
|
100
|
+
leftSection,
|
|
101
|
+
rightSection,
|
|
102
|
+
showOptional = false,
|
|
103
|
+
required,
|
|
104
|
+
label,
|
|
105
|
+
hasHelpIcon = false,
|
|
106
|
+
helpIconLabel,
|
|
107
|
+
onHelpIconClick,
|
|
108
|
+
error,
|
|
109
|
+
errorCaption,
|
|
110
|
+
...props
|
|
111
|
+
},
|
|
112
|
+
ref
|
|
113
|
+
) => {
|
|
114
|
+
const effectiveError = error === true ? (errorCaption ?? true) : error;
|
|
115
|
+
|
|
116
|
+
const enhancedLabel = React.useMemo(() => {
|
|
117
|
+
if (!label) return label;
|
|
118
|
+
if (showOptional && !required) {
|
|
119
|
+
return (
|
|
120
|
+
<>
|
|
121
|
+
{label} <Text span c="dimmed" fw="normal">(Optional)</Text>
|
|
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;
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<MantineTextInput
|
|
153
|
+
ref={ref}
|
|
154
|
+
size={size}
|
|
155
|
+
radius="sm"
|
|
156
|
+
required={required}
|
|
157
|
+
leftSection={leftSection}
|
|
158
|
+
rightSection={composedRightSection}
|
|
159
|
+
label={enhancedLabel}
|
|
160
|
+
error={effectiveError}
|
|
161
|
+
{...props}
|
|
162
|
+
/>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
TextInput.displayName = 'TextInput';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input Components
|
|
3
|
+
*
|
|
4
|
+
* Form input components with consistent styling and behavior.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { TextInput } from './TextInput';
|
|
8
|
+
export type { DSTextInputProps } from './TextInput';
|
|
9
|
+
|
|
10
|
+
export { TextArea } from './TextArea';
|
|
11
|
+
export type { DSTextAreaProps } from './TextArea';
|
|
12
|
+
|
|
13
|
+
export { NumberInput } from './NumberInput';
|
|
14
|
+
export type { DSNumberInputProps } from './NumberInput';
|
|
15
|
+
|
|
16
|
+
export { ColorInput } from './ColorInput';
|
|
17
|
+
export type { DSColorInputProps } from './ColorInput';
|
|
18
|
+
|
|
19
|
+
export { Slider } from './Slider';
|
|
20
|
+
export type { DSSliderProps } from './Slider';
|
|
21
|
+
|
|
22
|
+
export { Switch } from './Switch';
|
|
23
|
+
export type { DSSwitchProps } from './Switch';
|
|
24
|
+
|
|
25
|
+
export { SegmentedControl } from './SegmentedControl';
|
|
26
|
+
export type { DSSegmentedControlProps } from './SegmentedControl';
|
|
27
|
+
|
|
28
|
+
export { Checkbox } from './Checkbox';
|
|
29
|
+
export type { DSCheckboxProps } from './Checkbox';
|
|
30
|
+
|
|
31
|
+
export { Radio } from './Radio';
|
|
32
|
+
export type { DSRadioProps } from './Radio';
|
|
33
|
+
|
|
34
|
+
export { RadioGroup } from './RadioGroup';
|
|
35
|
+
export type { DSRadioGroupProps } from './RadioGroup';
|
|
36
|
+
|
|
37
|
+
export { DropZone } from './DropZone';
|
|
38
|
+
export type { DropZoneProps } from './DropZone';
|
|
39
|
+
|
|
40
|
+
export { FileInput } from './FileInput';
|
|
41
|
+
export type { DSFileInputProps } from './FileInput';
|
|
42
|
+
|
|
43
|
+
// Future input component exports will go here:
|
|
44
|
+
// export { ADDSCheckbox } from './Checkbox';
|
|
45
|
+
// export { ADDSNumberInput } from './NumberInput';
|
|
46
|
+
// export { ADDSTextarea } from './Textarea';
|
|
47
|
+
// export { ADDSSwitch } from './Switch';
|
|
48
|
+
// export { ADDSSlider } from './Slider';
|
|
49
|
+
// export { ADDSRadio } from './Radio';
|
|
50
|
+
// export { ADDSSegmentedControl } from './SegmentedControl';
|
|
51
|
+
// export { ADDSChip } from './Chip';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Box as MantineBox, BoxProps as MantineBoxProps } from '@mantine/core';
|
|
5
|
+
import { ComponentColor } from '../config';
|
|
6
|
+
import { SpacingScale } from './Stack';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Enhanced Box props extending Mantine's BoxProps
|
|
10
|
+
*/
|
|
11
|
+
export interface DSBoxProps extends MantineBoxProps {
|
|
12
|
+
/** Padding using design system scale */
|
|
13
|
+
p?: SpacingScale | string | number;
|
|
14
|
+
/** Margin using design system scale */
|
|
15
|
+
m?: SpacingScale | string | number;
|
|
16
|
+
/** Background color from design system palette */
|
|
17
|
+
bg?: ComponentColor | string;
|
|
18
|
+
/** Text color from design system palette */
|
|
19
|
+
c?: ComponentColor | string;
|
|
20
|
+
/** Children elements */
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* AppDirect Design System Box Component
|
|
26
|
+
*
|
|
27
|
+
* A flexible container primitive that provides easy access to design system tokens
|
|
28
|
+
* for spacing, colors, and other styling properties. Built on top of Mantine's Box.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* // Basic container with padding
|
|
33
|
+
* <Box p="md">
|
|
34
|
+
* <Text>Content with medium padding</Text>
|
|
35
|
+
* </Box>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* // Styled container with background and radius
|
|
41
|
+
* <Box p="lg" bg="gray.1" radius="md">
|
|
42
|
+
* <Title>Card-like container</Title>
|
|
43
|
+
* <Text>With background and rounded corners</Text>
|
|
44
|
+
* </Box>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* // Polymorphic usage as different elements
|
|
50
|
+
* <Box component="section" p="xl" m="md">
|
|
51
|
+
* <Text>Semantic section element</Text>
|
|
52
|
+
* </Box>
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export const Box = forwardRef<HTMLDivElement, DSBoxProps>(
|
|
56
|
+
(
|
|
57
|
+
{
|
|
58
|
+
p,
|
|
59
|
+
m,
|
|
60
|
+
bg,
|
|
61
|
+
c,
|
|
62
|
+
children,
|
|
63
|
+
...props
|
|
64
|
+
},
|
|
65
|
+
ref
|
|
66
|
+
) => {
|
|
67
|
+
return (
|
|
68
|
+
<MantineBox
|
|
69
|
+
ref={ref}
|
|
70
|
+
p={p}
|
|
71
|
+
m={m}
|
|
72
|
+
bg={bg}
|
|
73
|
+
c={c}
|
|
74
|
+
{...props}
|
|
75
|
+
>
|
|
76
|
+
{children}
|
|
77
|
+
</MantineBox>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
Box.displayName = 'Box';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Center as MantineCenter, CenterProps as MantineCenterProps } from '@mantine/core';
|
|
5
|
+
|
|
6
|
+
export interface DSCenterProps extends MantineCenterProps {}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* AppDirect Design System Center Component
|
|
10
|
+
*
|
|
11
|
+
* Centers content horizontally and vertically using Mantine's Center API.
|
|
12
|
+
*/
|
|
13
|
+
export const Center = forwardRef<HTMLDivElement, DSCenterProps>(
|
|
14
|
+
({ ...props }, ref) => <MantineCenter ref={ref} {...props} />
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
Center.displayName = 'Center';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Container as MantineContainer, ContainerProps as MantineContainerProps } from '@mantine/core';
|
|
5
|
+
|
|
6
|
+
export interface DSContainerProps extends MantineContainerProps {}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* AppDirect Design System Container Component
|
|
10
|
+
*
|
|
11
|
+
* Centers content and constrains max width using Mantine's Container API.
|
|
12
|
+
*/
|
|
13
|
+
export const Container = forwardRef<HTMLDivElement, DSContainerProps>(
|
|
14
|
+
({ ...props }, ref) => <MantineContainer ref={ref} {...props} />
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
Container.displayName = 'Container';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Flex as MantineFlex, FlexProps as MantineFlexProps } from '@mantine/core';
|
|
5
|
+
|
|
6
|
+
export interface DSFlexProps extends MantineFlexProps {}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* AppDirect Design System Flex Component
|
|
10
|
+
*
|
|
11
|
+
* A lower-level flexbox primitive aligned with Mantine's Flex API. Use it when
|
|
12
|
+
* Group or Stack are not expressive enough for the desired layout.
|
|
13
|
+
*/
|
|
14
|
+
export const Flex = forwardRef<HTMLDivElement, DSFlexProps>(
|
|
15
|
+
({ ...props }, ref) => <MantineFlex ref={ref} {...props} />
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
Flex.displayName = 'Flex';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import {
|
|
5
|
+
Grid as MantineGrid,
|
|
6
|
+
GridProps as MantineGridProps,
|
|
7
|
+
GridColProps as MantineGridColProps,
|
|
8
|
+
} from '@mantine/core';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Enhanced Grid props extending Mantine's GridProps
|
|
12
|
+
*/
|
|
13
|
+
export interface DSGridProps extends MantineGridProps {}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Enhanced Grid.Col props extending Mantine's GridColProps
|
|
17
|
+
*/
|
|
18
|
+
export interface DSGridColProps extends MantineGridColProps {}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* AppDirect Design System Grid Component
|
|
22
|
+
*
|
|
23
|
+
* A responsive 12-column grid aligned with Mantine's Grid API. Use `Grid.Col`
|
|
24
|
+
* when layouts need explicit spans instead of equal-width columns.
|
|
25
|
+
*/
|
|
26
|
+
export const Grid = forwardRef<HTMLDivElement, DSGridProps>(
|
|
27
|
+
({ ...props }, ref) => <MantineGrid ref={ref} {...props} />
|
|
28
|
+
) as typeof MantineGrid;
|
|
29
|
+
|
|
30
|
+
Grid.displayName = 'Grid';
|
|
31
|
+
Grid.Col = MantineGrid.Col;
|