@appdirect/design-system 0.0.11 → 0.0.12
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 +84 -6
- package/dist/Buttons/ActionIcon.js +14 -0
- package/dist/Buttons/Button.js +66 -0
- package/dist/Buttons/CloseButton.js +48 -0
- package/dist/Buttons/index.js +13 -0
- package/dist/Combobox/AutocompleteClearable.js +36 -0
- package/dist/Combobox/Combobox.js +28 -0
- package/dist/Combobox/Multiselect.js +31 -0
- package/dist/Combobox/SearchableSelect.js +43 -0
- package/dist/Combobox/Select.js +72 -0
- package/dist/Combobox/index.js +10 -0
- package/dist/ComplexComponents/DashboardWidget/DashboardWidget.js +96 -0
- package/dist/ComplexComponents/DashboardWidget/index.js +1 -0
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +82 -0
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.js +23 -0
- package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.js +23 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +230 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.js +30 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/DateRangeFilter.js +12 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterRenderer.js +32 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterSystem.js +90 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/MultiSelectFilter.js +43 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/SingleSelectFilter.js +30 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/index.js +39 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/types.js +9 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.js +31 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +42 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.js +21 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.js +410 -0
- package/dist/ComplexComponents/DataTable/DataTable.js +405 -0
- package/dist/ComplexComponents/DataTable/ErrorOverlay/index.js +9 -0
- package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.js +27 -0
- package/dist/ComplexComponents/DataTable/index.js +1 -0
- package/dist/ComplexComponents/DataTable/translations/en.js +99 -0
- package/dist/ComplexComponents/DataTable/translations/index.js +17 -0
- package/dist/ComplexComponents/KeyInsight/KeyInsights.js +176 -0
- package/dist/ComplexComponents/KeyInsight/index.js +1 -0
- package/dist/ComplexComponents/NameValue/NameValue.js +94 -0
- package/dist/ComplexComponents/NameValue/NameValueItem.js +59 -0
- package/dist/ComplexComponents/NameValue/index.js +2 -0
- package/dist/ComplexComponents/PageContentHeader/PageContentHeader.js +92 -0
- package/dist/ComplexComponents/PageContentHeader/index.js +1 -0
- package/dist/ComplexComponents/Placeholder/Placeholder.js +51 -0
- package/dist/ComplexComponents/Placeholder/index.js +1 -0
- package/dist/ComplexComponents/Slat/Slat.js +53 -0
- package/dist/ComplexComponents/Slat/index.js +1 -0
- package/dist/ComplexComponents/Utilities/CopyButton.js +45 -0
- package/dist/ComplexComponents/Utilities/index.js +1 -0
- package/dist/DataDisplay/Alert.js +77 -0
- package/dist/DataDisplay/Avatar.js +157 -0
- package/dist/DataDisplay/Badge.js +78 -0
- package/dist/DataDisplay/Card.js +100 -0
- package/dist/DataDisplay/Chip.js +36 -0
- package/dist/DataDisplay/Indicator.js +59 -0
- package/dist/DataDisplay/List.js +60 -0
- package/dist/DataDisplay/Pill.js +81 -0
- package/dist/DataDisplay/Progress.js +42 -0
- package/dist/DataDisplay/Table.js +38 -0
- package/dist/DataDisplay/ThemeIcon.js +31 -0
- package/dist/DataDisplay/index.js +18 -0
- package/dist/Inputs/Checkbox.js +62 -0
- package/dist/Inputs/ColorInput.js +48 -0
- package/dist/Inputs/DropZone.js +12 -0
- package/dist/Inputs/FileInput.js +77 -0
- package/dist/Inputs/NumberInput.js +49 -0
- package/dist/Inputs/Radio.js +55 -0
- package/dist/Inputs/RadioGroup.js +59 -0
- package/dist/Inputs/SegmentedControl.js +50 -0
- package/dist/Inputs/Slider.js +50 -0
- package/dist/Inputs/SliderWithLabel.js +32 -0
- package/dist/Inputs/Switch.js +47 -0
- package/dist/Inputs/TextArea.js +50 -0
- package/dist/Inputs/TextInput.js +87 -0
- package/dist/Inputs/index.js +27 -0
- package/dist/Layout/Box.js +39 -0
- package/dist/Layout/Center.js +11 -0
- package/dist/Layout/Container.js +11 -0
- package/dist/Layout/Flex.js +12 -0
- package/dist/Layout/Grid.js +13 -0
- package/dist/Layout/Group.js +14 -0
- package/dist/Layout/Inline.js +46 -0
- package/dist/Layout/SimpleGrid.js +14 -0
- package/dist/Layout/Stack.js +45 -0
- package/dist/Layout/index.js +10 -0
- package/dist/Misc/Divider.js +8 -0
- package/dist/Misc/Paper.js +24 -0
- package/dist/Misc/index.js +10 -0
- package/dist/Navigation/Breadcrumb.js +60 -0
- package/dist/Navigation/NavLink.js +28 -0
- package/dist/Navigation/Stepper.js +8 -0
- package/dist/Navigation/Tabs.js +22 -0
- package/dist/Navigation/index.js +9 -0
- package/dist/Overlays/Drawer.js +63 -0
- package/dist/Overlays/Menu.js +85 -0
- package/dist/Overlays/Modal.js +61 -0
- package/dist/Overlays/Popover.js +118 -0
- package/dist/Overlays/Tooltip.js +71 -0
- package/dist/Overlays/index.js +12 -0
- package/dist/Shell/AppShellLayout.js +13 -0
- package/dist/Shell/HeaderBar.js +8 -0
- package/dist/Shell/SidebarNav.js +9 -0
- package/dist/Shell/SidebarNavLink.js +17 -0
- package/dist/Shell/SingleColumnLayout.js +11 -0
- package/dist/Shell/TertiaryColumnLayout.js +12 -0
- package/dist/Shell/index.js +6 -0
- package/dist/Typography/Code.js +8 -0
- package/dist/Typography/Kbd.js +58 -0
- package/dist/Typography/Text.js +8 -0
- package/dist/Typography/Title.js +11 -0
- package/dist/Typography/index.js +12 -0
- package/dist/config.js +202 -0
- package/dist/contracts/index.json +1 -1
- package/dist/hooks/useTableHandlers.js +136 -0
- package/dist/hooks/useTableRenderFunctions.js +164 -0
- package/dist/hooks/useTableState.js +70 -0
- package/dist/index.js +162 -0
- package/dist/stories/index.json +1 -1
- package/dist/types.js +127 -0
- package/package.json +9 -6
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Table as MantineTable } from '@mantine/core';
|
|
5
|
+
// ========================== COMPONENT ==========================
|
|
6
|
+
/**
|
|
7
|
+
* Table Component
|
|
8
|
+
*
|
|
9
|
+
* A simple table component for displaying tabular data with consistent styling.
|
|
10
|
+
* Built on top of Mantine's Table component with Design System patterns.
|
|
11
|
+
*
|
|
12
|
+
* For complex data tables with features like sorting, filtering, and pagination,
|
|
13
|
+
* use the ComplexComponents/DataTable component instead.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* Basic table usage with compound components
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* Table with data prop for simple data
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* Styled table with borders and spacing
|
|
23
|
+
*/
|
|
24
|
+
const TableBase = forwardRef((props, ref) => {
|
|
25
|
+
return (_jsx(MantineTable, { ref: ref, horizontalSpacing: "sm", verticalSpacing: "xs", ...props }));
|
|
26
|
+
});
|
|
27
|
+
TableBase.displayName = 'DSTable';
|
|
28
|
+
// Create compound component with proper typing
|
|
29
|
+
export const Table = Object.assign(TableBase, {
|
|
30
|
+
Thead: MantineTable.Thead,
|
|
31
|
+
Tbody: MantineTable.Tbody,
|
|
32
|
+
Tfoot: MantineTable.Tfoot,
|
|
33
|
+
Tr: MantineTable.Tr,
|
|
34
|
+
Th: MantineTable.Th,
|
|
35
|
+
Td: MantineTable.Td,
|
|
36
|
+
Caption: MantineTable.Caption,
|
|
37
|
+
ScrollContainer: MantineTable.ScrollContainer,
|
|
38
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { ThemeIcon as MantineThemeIcon } from '@mantine/core';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
export const ThemeIcon = forwardRef(({ children, size = 'md', color = 'default', variant = 'default', style, ...props }, ref) => {
|
|
6
|
+
// Handle xxl size which should be 58x58px
|
|
7
|
+
const getSize = () => {
|
|
8
|
+
if (size === 'xxl') {
|
|
9
|
+
return 58;
|
|
10
|
+
}
|
|
11
|
+
return size;
|
|
12
|
+
};
|
|
13
|
+
const resolvedVariant = variant === 'info' || variant === 'success' || variant === 'danger' || variant === 'pending'
|
|
14
|
+
? 'light'
|
|
15
|
+
: variant;
|
|
16
|
+
const resolvedColor = color !== 'default'
|
|
17
|
+
? color
|
|
18
|
+
: variant === 'info'
|
|
19
|
+
? 'blue'
|
|
20
|
+
: variant === 'success'
|
|
21
|
+
? 'green'
|
|
22
|
+
: variant === 'danger'
|
|
23
|
+
? 'red'
|
|
24
|
+
: variant === 'pending'
|
|
25
|
+
? 'yellow'
|
|
26
|
+
: 'default';
|
|
27
|
+
// For blue/default semantic variants, prefer explicit icon color
|
|
28
|
+
const iconStyle = resolvedColor === 'blue' ? { color: 'var(--ad-color-brand-primary)', ...style } : style;
|
|
29
|
+
return (_jsx(MantineThemeIcon, { ref: ref, size: getSize(), variant: resolvedVariant, color: resolvedColor === 'default' ? undefined : resolvedColor, style: iconStyle, ...props, children: children }));
|
|
30
|
+
});
|
|
31
|
+
ThemeIcon.displayName = 'ThemeIcon';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataDisplay Components
|
|
3
|
+
*
|
|
4
|
+
* Components for displaying and organizing data in various formats.
|
|
5
|
+
*/
|
|
6
|
+
export { Alert } from './Alert.js';
|
|
7
|
+
export { Avatar } from './Avatar.js';
|
|
8
|
+
export { Badge } from './Badge.js';
|
|
9
|
+
export { Card, CardSection } from './Card.js';
|
|
10
|
+
export { Chip } from './Chip.js';
|
|
11
|
+
export { Pill } from './Pill.js';
|
|
12
|
+
export { Indicator } from './Indicator.js';
|
|
13
|
+
export { Progress } from './Progress.js';
|
|
14
|
+
export { ThemeIcon } from './ThemeIcon.js';
|
|
15
|
+
export { List } from './List.js';
|
|
16
|
+
export { Table } from './Table.js';
|
|
17
|
+
// Future data display component exports will go here:
|
|
18
|
+
// export { ADDSKbd } from './Kbd';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Checkbox as MantineCheckbox } from '@mantine/core';
|
|
5
|
+
/**
|
|
6
|
+
* AppDirect Design System Checkbox Component
|
|
7
|
+
*
|
|
8
|
+
* A clean checkbox component built on top of Mantine's Checkbox with
|
|
9
|
+
* consistent design system styling and enforced radius.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // Basic usage
|
|
14
|
+
* <Checkbox label="Accept terms" />
|
|
15
|
+
*
|
|
16
|
+
* // Controlled
|
|
17
|
+
* <Checkbox
|
|
18
|
+
* label="Subscribe to newsletter"
|
|
19
|
+
* checked={subscribed}
|
|
20
|
+
* onChange={(event) => setSubscribed(event.currentTarget.checked)}
|
|
21
|
+
* />
|
|
22
|
+
*
|
|
23
|
+
* // Required
|
|
24
|
+
* <Checkbox
|
|
25
|
+
* label="I agree to the terms"
|
|
26
|
+
* required
|
|
27
|
+
* />
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* // Different sizes
|
|
33
|
+
* <Checkbox size="xs" label="Extra small" />
|
|
34
|
+
* <Checkbox size="sm" label="Small" />
|
|
35
|
+
* <Checkbox size="md" label="Medium" />
|
|
36
|
+
* <Checkbox size="lg" label="Large" />
|
|
37
|
+
* <Checkbox size="xl" label="Extra large" />
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* // States
|
|
43
|
+
* <Checkbox label="Default checkbox" />
|
|
44
|
+
* <Checkbox label="Checked" defaultChecked />
|
|
45
|
+
* <Checkbox label="Disabled" disabled />
|
|
46
|
+
* <Checkbox label="Disabled checked" disabled defaultChecked />
|
|
47
|
+
* <Checkbox label="Indeterminate" indeterminate />
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export const Checkbox = forwardRef(({ size = 'md', label, ...props }, ref) => {
|
|
51
|
+
// Construct label with required asterisk if needed
|
|
52
|
+
const enhancedLabel = React.useMemo(() => {
|
|
53
|
+
if (!label)
|
|
54
|
+
return label;
|
|
55
|
+
if (props.required) {
|
|
56
|
+
return (_jsxs(_Fragment, { children: [label, " ", _jsx("span", { style: { color: 'var(--ad-color-status-error)' }, children: "*" })] }));
|
|
57
|
+
}
|
|
58
|
+
return label;
|
|
59
|
+
}, [label, props.required]);
|
|
60
|
+
return (_jsx(MantineCheckbox, { ref: ref, size: size, radius: "sm", label: enhancedLabel, ...props }));
|
|
61
|
+
});
|
|
62
|
+
Checkbox.displayName = 'Checkbox';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { ColorInput as MantineColorInput, ActionIcon, Group } from '@mantine/core';
|
|
5
|
+
import { IconInfoCircle } from '@tabler/icons-react';
|
|
6
|
+
import { Text } from '../Typography/Text.js';
|
|
7
|
+
import { Tooltip } from '../Overlays/Tooltip.js';
|
|
8
|
+
// ========================== COMPONENT ==========================
|
|
9
|
+
/**
|
|
10
|
+
* AppDirect Design System ColorInput Component
|
|
11
|
+
*
|
|
12
|
+
* A color picker input built on top of Mantine's ColorInput with
|
|
13
|
+
* consistent design system styling and enforced radius.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <ColorInput label="Brand Color" placeholder="#000000" format="hex" />
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <ColorInput
|
|
23
|
+
* label="Theme Color"
|
|
24
|
+
* format="hex"
|
|
25
|
+
* swatches={['#FF0000', '#00FF00', '#0000FF']}
|
|
26
|
+
* showOptional
|
|
27
|
+
* hasHelpIcon
|
|
28
|
+
* helpIconLabel="Choose the primary brand color"
|
|
29
|
+
* />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export const ColorInput = forwardRef(({ size = 'md', showOptional = false, required, label, hasHelpIcon = false, helpIconLabel, onHelpIconClick, rightSection, error, errorCaption, ...props }, ref) => {
|
|
33
|
+
const effectiveError = error === true ? (errorCaption ?? true) : error;
|
|
34
|
+
const enhancedLabel = React.useMemo(() => {
|
|
35
|
+
if (!label)
|
|
36
|
+
return label;
|
|
37
|
+
if (showOptional && !required) {
|
|
38
|
+
return (_jsxs(_Fragment, { children: [label, " ", _jsx(Text, { span: true, c: "dimmed", fw: "normal", children: "(Optional)" })] }));
|
|
39
|
+
}
|
|
40
|
+
return label;
|
|
41
|
+
}, [label, showOptional, required]);
|
|
42
|
+
const helpIconElement = hasHelpIcon ? (_jsx(Tooltip, { label: helpIconLabel ?? 'Help', position: "top", withArrow: true, children: _jsx(ActionIcon, { variant: "transparent", size: "xs", "aria-label": helpIconLabel ?? 'Help', onClick: onHelpIconClick, color: "gray", style: { cursor: onHelpIconClick ? 'pointer' : 'default' }, children: _jsx(IconInfoCircle, { size: 14, "aria-hidden": true }) }) })) : null;
|
|
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 }));
|
|
47
|
+
});
|
|
48
|
+
ColorInput.displayName = 'ColorInput';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Dropzone, IMAGE_MIME_TYPE } from '@mantine/dropzone';
|
|
4
|
+
import { Text } from '@mantine/core';
|
|
5
|
+
import { Inline } from '../Layout/Inline.js';
|
|
6
|
+
import { IconUpload, IconX } from '@tabler/icons-react';
|
|
7
|
+
import { forwardRef } from 'react';
|
|
8
|
+
export const DropZone = forwardRef(({ title = "This is the title", description = "This is the description for the Dropzone component", maxSize = 5 * 1024 ** 2, // 5MB
|
|
9
|
+
accept = IMAGE_MIME_TYPE, onDrop, onReject, ...props }, ref) => {
|
|
10
|
+
return (_jsx(Dropzone, { ref: ref, onDrop: onDrop || ((files) => console.log('accepted files', files)), onReject: onReject || ((files) => console.log('rejected files', files)), maxSize: maxSize, accept: accept, ...props, children: _jsxs(Inline, { justify: "flex-start", gap: "md", mih: 80, style: { pointerEvents: 'none' }, children: [_jsx(Dropzone.Accept, { children: _jsx(IconUpload, { size: 32, color: "var(--ad-color-brand-primary)", stroke: 1.5 }) }), _jsx(Dropzone.Reject, { children: _jsx(IconX, { size: 32, color: "var(--ad-color-status-error)", stroke: 1.5 }) }), _jsx(Dropzone.Idle, { children: _jsx(IconUpload, { size: 32, color: "var(--ad-color-text-dimmed)", stroke: 1.5 }) }), _jsxs("div", { children: [_jsx(Text, { size: "md", fw: 500, mb: 4, children: title }), _jsx(Text, { size: "sm", c: "dimmed", children: description })] })] }) }));
|
|
11
|
+
});
|
|
12
|
+
DropZone.displayName = 'DropZone';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { FileInput as MantineFileInput } from '@mantine/core';
|
|
5
|
+
/**
|
|
6
|
+
* AppDirect Design System FileInput Component
|
|
7
|
+
*
|
|
8
|
+
* A clean file input component built on top of Mantine's FileInput with
|
|
9
|
+
* consistent design system styling and enforced radius.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // Basic usage (no indication)
|
|
14
|
+
* <FileInput label="Upload File" placeholder="Choose file" />
|
|
15
|
+
*
|
|
16
|
+
* // Required field (shows asterisk)
|
|
17
|
+
* <FileInput
|
|
18
|
+
* label="Resume"
|
|
19
|
+
* placeholder="Upload your resume"
|
|
20
|
+
* required
|
|
21
|
+
* />
|
|
22
|
+
*
|
|
23
|
+
* // Optional field (shows "(Optional)")
|
|
24
|
+
* <FileInput
|
|
25
|
+
* label="Profile Picture"
|
|
26
|
+
* placeholder="Upload image"
|
|
27
|
+
* showOptional
|
|
28
|
+
* />
|
|
29
|
+
*
|
|
30
|
+
* // With error
|
|
31
|
+
* <FileInput
|
|
32
|
+
* label="Document"
|
|
33
|
+
* error="File is required"
|
|
34
|
+
* />
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* // Different sizes
|
|
40
|
+
* <FileInput size="xs" placeholder="Extra small" />
|
|
41
|
+
* <FileInput size="sm" placeholder="Small" />
|
|
42
|
+
* <FileInput size="md" placeholder="Medium" />
|
|
43
|
+
* <FileInput size="lg" placeholder="Large" />
|
|
44
|
+
* <FileInput size="xl" placeholder="Extra large" />
|
|
45
|
+
*
|
|
46
|
+
* // With file type restrictions
|
|
47
|
+
* <FileInput
|
|
48
|
+
* accept="image/png,image/jpeg"
|
|
49
|
+
* placeholder="Upload image"
|
|
50
|
+
* />
|
|
51
|
+
*
|
|
52
|
+
* // Multiple files
|
|
53
|
+
* <FileInput
|
|
54
|
+
* multiple
|
|
55
|
+
* placeholder="Upload multiple files"
|
|
56
|
+
* />
|
|
57
|
+
*
|
|
58
|
+
* // With clearable option
|
|
59
|
+
* <FileInput
|
|
60
|
+
* clearable
|
|
61
|
+
* placeholder="Upload file (clearable)"
|
|
62
|
+
* />
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export const FileInput = forwardRef(({ size = 'md', className, leftSection, rightSection, showOptional = false, label, ...props }, ref) => {
|
|
66
|
+
// Construct label with optional text if needed
|
|
67
|
+
const enhancedLabel = React.useMemo(() => {
|
|
68
|
+
if (!label)
|
|
69
|
+
return label;
|
|
70
|
+
if (showOptional && !props.required) {
|
|
71
|
+
return (_jsxs(_Fragment, { children: [label, " ", _jsx("span", { style: { fontWeight: 'normal', color: 'var(--ad-color-text-dimmed)' }, children: "(Optional)" })] }));
|
|
72
|
+
}
|
|
73
|
+
return label;
|
|
74
|
+
}, [label, showOptional, props.required]);
|
|
75
|
+
return (_jsx(MantineFileInput, { ref: ref, size: size, radius: "sm", className: className, leftSection: leftSection, rightSection: rightSection, label: enhancedLabel, ...props }));
|
|
76
|
+
});
|
|
77
|
+
FileInput.displayName = 'FileInput';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { NumberInput as MantineNumberInput, ActionIcon, Group } from '@mantine/core';
|
|
5
|
+
import { IconInfoCircle } from '@tabler/icons-react';
|
|
6
|
+
import { Text } from '../Typography/Text.js';
|
|
7
|
+
import { Tooltip } from '../Overlays/Tooltip.js';
|
|
8
|
+
// ========================== COMPONENT ==========================
|
|
9
|
+
/**
|
|
10
|
+
* AppDirect Design System NumberInput Component
|
|
11
|
+
*
|
|
12
|
+
* A numeric input built on top of Mantine's NumberInput with
|
|
13
|
+
* consistent design system styling and enforced radius.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <NumberInput label="Quantity" placeholder="Enter a number" />
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <NumberInput
|
|
23
|
+
* label="Price"
|
|
24
|
+
* prefix="$"
|
|
25
|
+
* decimalScale={2}
|
|
26
|
+
* fixedDecimalScale
|
|
27
|
+
* showOptional
|
|
28
|
+
* hasHelpIcon
|
|
29
|
+
* helpIconLabel="Enter the item price"
|
|
30
|
+
* />
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export const NumberInput = forwardRef(({ size = 'md', showOptional = false, required, label, hasHelpIcon = false, helpIconLabel, onHelpIconClick, rightSection, error, errorCaption, ...props }, ref) => {
|
|
34
|
+
const effectiveError = error === true ? (errorCaption ?? true) : error;
|
|
35
|
+
const enhancedLabel = React.useMemo(() => {
|
|
36
|
+
if (!label)
|
|
37
|
+
return label;
|
|
38
|
+
if (showOptional && !required) {
|
|
39
|
+
return (_jsxs(_Fragment, { children: [label, " ", _jsx(Text, { span: true, c: "dimmed", fw: "normal", children: "(Optional)" })] }));
|
|
40
|
+
}
|
|
41
|
+
return label;
|
|
42
|
+
}, [label, showOptional, required]);
|
|
43
|
+
const helpIconElement = hasHelpIcon ? (_jsx(Tooltip, { label: helpIconLabel ?? 'Help', position: "top", withArrow: true, children: _jsx(ActionIcon, { variant: "transparent", size: "xs", "aria-label": helpIconLabel ?? 'Help', onClick: onHelpIconClick, color: "gray", style: { cursor: onHelpIconClick ? 'pointer' : 'default' }, children: _jsx(IconInfoCircle, { size: 14, "aria-hidden": true }) }) })) : null;
|
|
44
|
+
const composedRightSection = (helpIconElement && rightSection)
|
|
45
|
+
? _jsxs(Group, { gap: 4, wrap: "nowrap", children: [rightSection, helpIconElement] })
|
|
46
|
+
: helpIconElement || rightSection;
|
|
47
|
+
return (_jsx(MantineNumberInput, { ref: ref, size: size, radius: "sm", required: required, label: enhancedLabel, rightSection: composedRightSection, error: effectiveError, ...props }));
|
|
48
|
+
});
|
|
49
|
+
NumberInput.displayName = 'NumberInput';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Radio as MantineRadio } from '@mantine/core';
|
|
5
|
+
/**
|
|
6
|
+
* AppDirect Design System Radio Component
|
|
7
|
+
*
|
|
8
|
+
* A clean radio button component built on top of Mantine's Radio with
|
|
9
|
+
* consistent design system styling and enforced radius.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // Basic usage
|
|
14
|
+
* <Radio label="Option 1" value="option1" />
|
|
15
|
+
*
|
|
16
|
+
* // In a Radio.Group
|
|
17
|
+
* <Radio.Group label="Choose an option" value={value} onChange={setValue}>
|
|
18
|
+
* <Radio value="option1" label="First option" />
|
|
19
|
+
* <Radio value="option2" label="Second option" />
|
|
20
|
+
* <Radio value="option3" label="Third option" />
|
|
21
|
+
* </Radio.Group>
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* // Different sizes
|
|
27
|
+
* <Radio size="xs" label="Extra small" value="xs" />
|
|
28
|
+
* <Radio size="sm" label="Small" value="sm" />
|
|
29
|
+
* <Radio size="md" label="Medium" value="md" />
|
|
30
|
+
* <Radio size="lg" label="Large" value="lg" />
|
|
31
|
+
* <Radio size="xl" label="Extra large" value="xl" />
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* // States
|
|
37
|
+
* <Radio label="Default radio" value="default" />
|
|
38
|
+
* <Radio label="Checked radio" value="checked" defaultChecked />
|
|
39
|
+
* <Radio label="Disabled radio" value="disabled" disabled />
|
|
40
|
+
* <Radio label="Required radio" value="required" required />
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export const Radio = forwardRef(({ size = 'md', label, ...props }, ref) => {
|
|
44
|
+
// Construct label with required asterisk if needed
|
|
45
|
+
const enhancedLabel = React.useMemo(() => {
|
|
46
|
+
if (!label)
|
|
47
|
+
return label;
|
|
48
|
+
if (props.required) {
|
|
49
|
+
return (_jsxs(_Fragment, { children: [label, " ", _jsx("span", { style: { color: 'var(--ad-color-status-error)' }, children: "*" })] }));
|
|
50
|
+
}
|
|
51
|
+
return label;
|
|
52
|
+
}, [label, props.required]);
|
|
53
|
+
return (_jsx(MantineRadio, { ref: ref, size: size, label: enhancedLabel, ...props }));
|
|
54
|
+
});
|
|
55
|
+
Radio.displayName = 'Radio';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { Radio as MantineRadio } from '@mantine/core';
|
|
5
|
+
/**
|
|
6
|
+
* AppDirect Design System RadioGroup Component
|
|
7
|
+
*
|
|
8
|
+
* A radio group component built on top of Mantine's Radio.Group with
|
|
9
|
+
* consistent design system styling and required asterisk support.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // Basic usage
|
|
14
|
+
* <RadioGroup label="Choose an option" value={value} onChange={setValue}>
|
|
15
|
+
* <Radio value="option1" label="First option" />
|
|
16
|
+
* <Radio value="option2" label="Second option" />
|
|
17
|
+
* <Radio value="option3" label="Third option" />
|
|
18
|
+
* </RadioGroup>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* // Required group
|
|
24
|
+
* <RadioGroup label="Payment method" required value={payment} onChange={setPayment}>
|
|
25
|
+
* <Radio value="card" label="Credit Card" />
|
|
26
|
+
* <Radio value="paypal" label="PayPal" />
|
|
27
|
+
* <Radio value="bank" label="Bank Transfer" />
|
|
28
|
+
* </RadioGroup>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* // With description and error
|
|
34
|
+
* <RadioGroup
|
|
35
|
+
* label="Subscription plan"
|
|
36
|
+
* description="Choose your preferred plan"
|
|
37
|
+
* error="Please select a plan"
|
|
38
|
+
* value={plan}
|
|
39
|
+
* onChange={setPlan}
|
|
40
|
+
* >
|
|
41
|
+
* <Radio value="basic" label="Basic - $9/month" />
|
|
42
|
+
* <Radio value="pro" label="Pro - $29/month" />
|
|
43
|
+
* <Radio value="enterprise" label="Enterprise - $99/month" />
|
|
44
|
+
* </RadioGroup>
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export const RadioGroup = forwardRef(({ size = 'md', label, ...props }, ref) => {
|
|
48
|
+
// Construct label with required asterisk if needed
|
|
49
|
+
const enhancedLabel = React.useMemo(() => {
|
|
50
|
+
if (!label)
|
|
51
|
+
return label;
|
|
52
|
+
if (props.required) {
|
|
53
|
+
return (_jsxs(_Fragment, { children: [label, " ", _jsx("span", { style: { color: 'var(--ad-color-status-error)' }, children: "*" })] }));
|
|
54
|
+
}
|
|
55
|
+
return label;
|
|
56
|
+
}, [label, props.required]);
|
|
57
|
+
return (_jsx(MantineRadio.Group, { ref: ref, size: size, label: enhancedLabel, ...props }));
|
|
58
|
+
});
|
|
59
|
+
RadioGroup.displayName = 'RadioGroup';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { SegmentedControl as MantineSegmentedControl } from '@mantine/core';
|
|
5
|
+
/**
|
|
6
|
+
* SegmentedControl component with consistent design system styling.
|
|
7
|
+
* Built on top of Mantine's SegmentedControl component with enforced radius.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* // Basic segmented control
|
|
12
|
+
* <SegmentedControl
|
|
13
|
+
* data={['Segment 1', 'Segment 2', 'Segment 3']}
|
|
14
|
+
* defaultValue="Segment 1"
|
|
15
|
+
* />
|
|
16
|
+
*
|
|
17
|
+
* // With different sizes
|
|
18
|
+
* <SegmentedControl
|
|
19
|
+
* size="sm"
|
|
20
|
+
* data={['Small', 'Medium', 'Large']}
|
|
21
|
+
* />
|
|
22
|
+
*
|
|
23
|
+
* // With custom data structure
|
|
24
|
+
* <SegmentedControl
|
|
25
|
+
* data={[
|
|
26
|
+
* { label: 'React', value: 'react' },
|
|
27
|
+
* { label: 'Vue', value: 'vue' },
|
|
28
|
+
* { label: 'Angular', value: 'angular' }
|
|
29
|
+
* ]}
|
|
30
|
+
* defaultValue="react"
|
|
31
|
+
* />
|
|
32
|
+
*
|
|
33
|
+
* // Controlled component
|
|
34
|
+
* <SegmentedControl
|
|
35
|
+
* value={value}
|
|
36
|
+
* onChange={setValue}
|
|
37
|
+
* data={['Option 1', 'Option 2', 'Option 3']}
|
|
38
|
+
* />
|
|
39
|
+
*
|
|
40
|
+
* // Disabled state
|
|
41
|
+
* <SegmentedControl
|
|
42
|
+
* disabled
|
|
43
|
+
* data={['Disabled', 'Control']}
|
|
44
|
+
* />
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export const SegmentedControl = ({ ...props }) => {
|
|
48
|
+
return (_jsx(MantineSegmentedControl, { radius: "sm", ...props }));
|
|
49
|
+
};
|
|
50
|
+
export default SegmentedControl;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Slider as MantineSlider } from '@mantine/core';
|
|
5
|
+
/**
|
|
6
|
+
* Slider component with consistent design system styling.
|
|
7
|
+
* Built on top of Mantine's Slider component with enforced xl radius.
|
|
8
|
+
*
|
|
9
|
+
* NOTE: Prefer using Mantine's built-in props over CSS overrides when possible.
|
|
10
|
+
* Only add CSS overrides as a last resort when built-in props don't achieve the desired result.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* // Basic slider
|
|
15
|
+
* <Slider label="Volume" defaultValue={50} />
|
|
16
|
+
*
|
|
17
|
+
* // Optional field (shows gray optional text)
|
|
18
|
+
* <Slider label="Opacity" showOptional min={0} max={100} />
|
|
19
|
+
*
|
|
20
|
+
* // With min/max and step
|
|
21
|
+
* <Slider
|
|
22
|
+
* label="Rating"
|
|
23
|
+
* min={1}
|
|
24
|
+
* max={10}
|
|
25
|
+
* step={0.5}
|
|
26
|
+
* defaultValue={5}
|
|
27
|
+
* marks={[
|
|
28
|
+
* { value: 1, label: '1' },
|
|
29
|
+
* { value: 5, label: '5' },
|
|
30
|
+
* { value: 10, label: '10' }
|
|
31
|
+
* ]}
|
|
32
|
+
* />
|
|
33
|
+
*
|
|
34
|
+
* // Range slider
|
|
35
|
+
* <Slider
|
|
36
|
+
* label="Price Range"
|
|
37
|
+
* min={0}
|
|
38
|
+
* max={1000}
|
|
39
|
+
* defaultValue={[200, 800]}
|
|
40
|
+
* />
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export const Slider = ({ label, showOptional = false, ...props }) => {
|
|
44
|
+
// Create the label with optional indicator if needed
|
|
45
|
+
const labelWithOptional = showOptional && label
|
|
46
|
+
? `${label} (Optional)`
|
|
47
|
+
: label;
|
|
48
|
+
return (_jsx(MantineSlider, { label: labelWithOptional, radius: "xl", ...props }));
|
|
49
|
+
};
|
|
50
|
+
export default Slider;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { InputWrapper } from '@mantine/core';
|
|
5
|
+
import { Slider } from './Slider.js';
|
|
6
|
+
/**
|
|
7
|
+
* SliderWithLabel Component
|
|
8
|
+
*
|
|
9
|
+
* A Slider with a static field label above it (e.g. "Volume *"), matching
|
|
10
|
+
* the label treatment used by TextInput/NumberInput/etc. Uses Mantine's
|
|
11
|
+
* own Input.Wrapper so the label/required/error styling is identical to
|
|
12
|
+
* every other labeled input in the DS — not a bespoke label implementation.
|
|
13
|
+
*
|
|
14
|
+
* Not to be confused with Slider's own `label` prop, which is Mantine's
|
|
15
|
+
* floating value tooltip shown above the thumb while dragging — a
|
|
16
|
+
* different concept from this component's static field label.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* <SliderWithLabel fieldLabel="Volume" required defaultValue={40} />
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* <SliderWithLabel
|
|
23
|
+
* fieldLabel="Price Range"
|
|
24
|
+
* description="Set your budget"
|
|
25
|
+
* min={0}
|
|
26
|
+
* max={1000}
|
|
27
|
+
* defaultValue={[200, 800]}
|
|
28
|
+
* />
|
|
29
|
+
*/
|
|
30
|
+
export function SliderWithLabel({ fieldLabel, required, description, error, ...sliderProps }) {
|
|
31
|
+
return (_jsx(InputWrapper, { label: fieldLabel, description: description, error: error, required: required, withAsterisk: required, children: _jsx(Slider, { ...sliderProps }) }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Switch as MantineSwitch } from '@mantine/core';
|
|
5
|
+
/**
|
|
6
|
+
* Switch component with consistent design system styling.
|
|
7
|
+
* Built on top of Mantine's Switch component with enforced green color and xl radius.
|
|
8
|
+
*
|
|
9
|
+
* NOTE: Prefer using Mantine's built-in props over CSS overrides when possible.
|
|
10
|
+
* Only add CSS overrides as a last resort when built-in props don't achieve the desired result.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* // Basic switch
|
|
15
|
+
* <Switch label="Enable notifications" />
|
|
16
|
+
*
|
|
17
|
+
* // Different sizes
|
|
18
|
+
* <Switch label="Small" size="sm" />
|
|
19
|
+
* <Switch label="Large" size="lg" />
|
|
20
|
+
*
|
|
21
|
+
* // Optional field (shows gray optional text)
|
|
22
|
+
* <Switch label="Auto-save" showOptional />
|
|
23
|
+
*
|
|
24
|
+
* // Controlled switch
|
|
25
|
+
* <Switch
|
|
26
|
+
* label="Dark mode"
|
|
27
|
+
* checked={darkMode}
|
|
28
|
+
* onChange={setDarkMode}
|
|
29
|
+
* />
|
|
30
|
+
*
|
|
31
|
+
* // Disabled states
|
|
32
|
+
* <Switch label="Disabled" disabled />
|
|
33
|
+
* <Switch label="Disabled Checked" disabled checked />
|
|
34
|
+
*
|
|
35
|
+
* // With on/off labels inside
|
|
36
|
+
* <Switch label="Power" onLabel="ON" offLabel="OFF" />
|
|
37
|
+
* <Switch label="WiFi" onLabel="CONNECTED" offLabel="DISCONNECTED" />
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export const Switch = ({ label, showOptional = false, ...props }) => {
|
|
41
|
+
// Create the label with optional indicator if needed
|
|
42
|
+
const labelWithOptional = showOptional && label
|
|
43
|
+
? `${label} (Optional)`
|
|
44
|
+
: label;
|
|
45
|
+
return (_jsx(MantineSwitch, { label: labelWithOptional, color: "green", radius: "xl", ...props }));
|
|
46
|
+
};
|
|
47
|
+
export default Switch;
|