@appdirect/design-system 0.0.20 → 0.0.22

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.
Files changed (35) hide show
  1. package/dist/Combobox/Select.js +11 -2
  2. package/dist/Combobox/Select.module.css +8 -0
  3. package/dist/Combobox/Select.tsx +16 -3
  4. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/CustomBottomToolbar.module.css +24 -1
  5. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +2 -1
  6. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.tsx +3 -0
  7. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/CustomToolbarAlertBannerContent.module.css +9 -1
  8. package/dist/ComplexComponents/DataTable/CustomTopToolbar/CustomTopToolbar.module.css +7 -0
  9. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/DateRangeSelectorFilter.module.css +7 -0
  10. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +1 -1
  11. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.tsx +1 -0
  12. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +4 -2
  13. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.module.css +16 -0
  14. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.tsx +6 -3
  15. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.js +2 -2
  16. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.tsx +11 -8
  17. package/dist/ComplexComponents/DataTable/DataTableGrid/DataTableGrid.module.css +17 -3
  18. package/dist/ComplexComponents/DataTable/DataTableGrid/index.js +1 -1
  19. package/dist/ComplexComponents/DataTable/DataTableGrid/index.tsx +2 -2
  20. package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/ToolbarAlertBanner.module.css +4 -1
  21. package/dist/DESIGN.md +6 -2
  22. package/dist/DataDisplay/Alert.js +3 -2
  23. package/dist/DataDisplay/Alert.tsx +4 -1
  24. package/dist/DataDisplay/Badge.js +37 -12
  25. package/dist/DataDisplay/Badge.tsx +42 -12
  26. package/dist/Inputs/NumberInput.js +40 -28
  27. package/dist/Inputs/NumberInput.tsx +93 -32
  28. package/dist/Overlays/Modal.js +2 -2
  29. package/dist/Overlays/Modal.tsx +2 -2
  30. package/dist/contracts/index.json +1 -1
  31. package/dist/css/mantine.css +1503 -39
  32. package/dist/stories/Overlays/Drawer.stories.tsx +2 -2
  33. package/dist/stories/Overlays/Modal.stories.tsx +2 -2
  34. package/dist/stories/index.json +1 -1
  35. package/package.json +2 -2
@@ -64,31 +64,57 @@ export const Badge = forwardRef<HTMLDivElement, DSBadgeProps>(
64
64
  },
65
65
  ref
66
66
  ) => {
67
- // Map design system colors to Mantine colors
68
- const getMantineColor = (dsColor: DSBadgeProps['color'], dsVariant: DSBadgeProps['variant']) => {
69
- const resolvedColor = dsColor === 'default' && ['info', 'success', 'danger', 'pending', 'warning'].includes(dsVariant || '')
70
- ? (dsVariant === 'warning' ? 'pending' : dsVariant)
71
- : dsColor;
67
+ // Legacy: variant used as semantic color when color stays default.
68
+ const resolvedColor: DSBadgeColor =
69
+ color === 'default' &&
70
+ ['info', 'success', 'danger', 'pending', 'warning'].includes(variant || '')
71
+ ? variant === 'warning'
72
+ ? 'pending'
73
+ : (variant as DSBadgeColor)
74
+ : color;
72
75
 
76
+ // Normalize aliases (blue/green/…) to semantic names for mantine.css [data-color].
77
+ const semanticDataColor = (() => {
73
78
  switch (resolvedColor) {
74
79
  case 'info':
75
80
  case 'blue':
76
- return 'blue';
81
+ return 'info' as const;
77
82
  case 'success':
78
83
  case 'green':
79
- return 'green';
84
+ return 'success' as const;
80
85
  case 'danger':
81
86
  case 'red':
82
- return 'red';
87
+ return 'danger' as const;
83
88
  case 'pending':
84
89
  case 'warning':
85
90
  case 'yellow':
86
- return 'yellow';
91
+ return 'pending' as const;
87
92
  case 'default':
88
93
  case 'gray':
94
+ return 'default' as const;
95
+ default: {
96
+ const _exhaustive: never = resolvedColor;
97
+ return _exhaustive;
98
+ }
99
+ }
100
+ })();
101
+
102
+ const getMantineColor = (semantic: typeof semanticDataColor) => {
103
+ switch (semantic) {
104
+ case 'info':
105
+ return 'blue';
106
+ case 'success':
107
+ return 'green';
108
+ case 'danger':
109
+ return 'red';
110
+ case 'pending':
111
+ return 'yellow';
112
+ case 'default':
89
113
  return 'gray';
90
- default:
91
- return 'gray';
114
+ default: {
115
+ const _exhaustive: never = semantic;
116
+ return _exhaustive;
117
+ }
92
118
  }
93
119
  };
94
120
 
@@ -101,14 +127,18 @@ export const Badge = forwardRef<HTMLDivElement, DSBadgeProps>(
101
127
  }
102
128
  };
103
129
 
130
+ const mantineColor = getMantineColor(semanticDataColor);
131
+
104
132
  return (
105
133
  <MantineBadge
106
134
  ref={ref}
107
135
  variant={getMantineVariant(variant)}
108
136
  size={size}
109
- color={getMantineColor(color, variant)}
137
+ color={mantineColor}
110
138
  radius="sm"
111
139
  {...props}
140
+ // Semantic name for mantine.css ([data-color=info|…]); must win over props.
141
+ data-color={semanticDataColor}
112
142
  >
113
143
  {children}
114
144
  </MantineBadge>
@@ -1,49 +1,61 @@
1
1
  'use client';
2
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';
3
+ import React, { forwardRef, useRef } from 'react';
4
+ import { NumberInput as MantineNumberInput, ActionIcon, Group, Stack, } from '@mantine/core';
5
+ import { RiAddLine, RiInformationLine, RiSubtractLine } from '@remixicon/react';
6
6
  import { Text } from '../Typography/Text.js';
7
7
  import { Tooltip } from '../Overlays/Tooltip.js';
8
+ const CONTROL_ICON_SIZE = {
9
+ xs: 10,
10
+ sm: 12,
11
+ md: 14,
12
+ lg: 16,
13
+ xl: 18,
14
+ };
8
15
  // ========================== COMPONENT ==========================
9
16
  /**
10
17
  * AppDirect Design System NumberInput Component
11
18
  *
12
19
  * A numeric input built on top of Mantine's NumberInput with
13
20
  * 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
- * ```
21
+ * Increment/decrement use Remix +/- icons (not Mantine chevrons).
32
22
  */
33
- export const NumberInput = forwardRef(({ size = 'md', showOptional = false, required, label, hasHelpIcon = false, helpIconLabel, onHelpIconClick, rightSection, error, errorCaption, ...props }, ref) => {
23
+ export const NumberInput = forwardRef(({ size = 'md', showOptional = false, required, label, hasHelpIcon = false, helpIconLabel, onHelpIconClick, rightSection, error, errorCaption, hideControls, readOnly, disabled, handlersRef: handlersRefProp, ...props }, ref) => {
34
24
  const effectiveError = error === true ? (errorCaption ?? true) : error;
25
+ const internalHandlersRef = useRef(null);
26
+ const setHandlersRef = (handlers) => {
27
+ internalHandlersRef.current = handlers ?? null;
28
+ if (!handlersRefProp)
29
+ return;
30
+ if (typeof handlersRefProp === 'function') {
31
+ handlersRefProp(handlers);
32
+ }
33
+ else {
34
+ handlersRefProp.current =
35
+ handlers;
36
+ }
37
+ };
35
38
  const enhancedLabel = React.useMemo(() => {
36
39
  if (!label)
37
40
  return label;
38
41
  if (showOptional && !required) {
39
- return (_jsxs(_Fragment, { children: [label, " ", _jsx(Text, { span: true, c: "dimmed", fw: "normal", children: "(Optional)" })] }));
42
+ return (_jsxs(_Fragment, { children: [label, ' ', _jsx(Text, { span: true, c: "dimmed", fw: "normal", children: "(Optional)" })] }));
40
43
  }
41
44
  return label;
42
45
  }, [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 }));
46
+ 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(RiInformationLine, { size: 14, "aria-hidden": true }) }) })) : null;
47
+ const iconSize = CONTROL_ICON_SIZE[size] ?? 14;
48
+ const showDsControls = !hideControls && !readOnly && !disabled && rightSection == null;
49
+ const dsControls = showDsControls ? (_jsxs(Stack, { gap: 0, justify: "center", children: [_jsx(ActionIcon, { variant: "transparent", size: "xs", tabIndex: -1, "aria-hidden": true, onMouseDown: (event) => event.preventDefault(), onClick: () => internalHandlersRef.current?.increment(), children: _jsx(RiAddLine, { size: iconSize, "aria-hidden": true }) }), _jsx(ActionIcon, { variant: "transparent", size: "xs", tabIndex: -1, "aria-hidden": true, onMouseDown: (event) => event.preventDefault(), onClick: () => internalHandlersRef.current?.decrement(), children: _jsx(RiSubtractLine, { size: iconSize, "aria-hidden": true }) })] })) : null;
50
+ const composedRightSection = (() => {
51
+ if (rightSection && helpIconElement) {
52
+ return (_jsxs(Group, { gap: 4, wrap: "nowrap", children: [rightSection, helpIconElement] }));
53
+ }
54
+ if (dsControls && helpIconElement) {
55
+ return (_jsxs(Group, { gap: 4, wrap: "nowrap", children: [dsControls, helpIconElement] }));
56
+ }
57
+ return helpIconElement || rightSection || dsControls;
58
+ })();
59
+ return (_jsx(MantineNumberInput, { ref: ref, size: size, radius: "sm", required: required, label: enhancedLabel, error: effectiveError, hideControls: true, readOnly: readOnly, disabled: disabled, handlersRef: setHandlersRef, rightSection: composedRightSection, ...props }));
48
60
  });
49
61
  NumberInput.displayName = 'NumberInput';
@@ -1,8 +1,15 @@
1
1
  'use client';
2
2
 
3
- import React, { forwardRef } from 'react';
4
- import { NumberInput as MantineNumberInput, NumberInputProps as MantineNumberInputProps, ActionIcon, Group } from '@mantine/core';
5
- import { IconInfoCircle } from '@tabler/icons-react';
3
+ import React, { forwardRef, useRef } from 'react';
4
+ import {
5
+ NumberInput as MantineNumberInput,
6
+ NumberInputProps as MantineNumberInputProps,
7
+ NumberInputHandlers,
8
+ ActionIcon,
9
+ Group,
10
+ Stack,
11
+ } from '@mantine/core';
12
+ import { RiAddLine, RiInformationLine, RiSubtractLine } from '@remixicon/react';
6
13
  import { ComponentSize } from '../config';
7
14
  import { Text } from '../Typography/Text';
8
15
  import { Tooltip } from '../Overlays/Tooltip';
@@ -27,6 +34,14 @@ export interface DSNumberInputProps extends Omit<MantineNumberInputProps, 'size'
27
34
  errorCaption?: string;
28
35
  }
29
36
 
37
+ const CONTROL_ICON_SIZE: Record<ComponentSize, number> = {
38
+ xs: 10,
39
+ sm: 12,
40
+ md: 14,
41
+ lg: 16,
42
+ xl: 18,
43
+ };
44
+
30
45
  // ========================== COMPONENT ==========================
31
46
 
32
47
  /**
@@ -34,24 +49,7 @@ export interface DSNumberInputProps extends Omit<MantineNumberInputProps, 'size'
34
49
  *
35
50
  * A numeric input built on top of Mantine's NumberInput with
36
51
  * consistent design system styling and enforced radius.
37
- *
38
- * @example
39
- * ```tsx
40
- * <NumberInput label="Quantity" placeholder="Enter a number" />
41
- * ```
42
- *
43
- * @example
44
- * ```tsx
45
- * <NumberInput
46
- * label="Price"
47
- * prefix="$"
48
- * decimalScale={2}
49
- * fixedDecimalScale
50
- * showOptional
51
- * hasHelpIcon
52
- * helpIconLabel="Enter the item price"
53
- * />
54
- * ```
52
+ * Increment/decrement use Remix +/- icons (not Mantine chevrons).
55
53
  */
56
54
  export const NumberInput = forwardRef<HTMLInputElement, DSNumberInputProps>(
57
55
  (
@@ -66,18 +64,37 @@ export const NumberInput = forwardRef<HTMLInputElement, DSNumberInputProps>(
66
64
  rightSection,
67
65
  error,
68
66
  errorCaption,
67
+ hideControls,
68
+ readOnly,
69
+ disabled,
70
+ handlersRef: handlersRefProp,
69
71
  ...props
70
72
  },
71
73
  ref
72
74
  ) => {
73
75
  const effectiveError = error === true ? (errorCaption ?? true) : error;
76
+ const internalHandlersRef = useRef<NumberInputHandlers | null>(null);
77
+
78
+ const setHandlersRef = (handlers: NumberInputHandlers | undefined) => {
79
+ internalHandlersRef.current = handlers ?? null;
80
+ if (!handlersRefProp) return;
81
+ if (typeof handlersRefProp === 'function') {
82
+ handlersRefProp(handlers);
83
+ } else {
84
+ (handlersRefProp as React.MutableRefObject<NumberInputHandlers | undefined>).current =
85
+ handlers;
86
+ }
87
+ };
74
88
 
75
89
  const enhancedLabel = React.useMemo(() => {
76
90
  if (!label) return label;
77
91
  if (showOptional && !required) {
78
92
  return (
79
93
  <>
80
- {label} <Text span c="dimmed" fw="normal">(Optional)</Text>
94
+ {label}{' '}
95
+ <Text span c="dimmed" fw="normal">
96
+ (Optional)
97
+ </Text>
81
98
  </>
82
99
  );
83
100
  }
@@ -85,11 +102,7 @@ export const NumberInput = forwardRef<HTMLInputElement, DSNumberInputProps>(
85
102
  }, [label, showOptional, required]);
86
103
 
87
104
  const helpIconElement = hasHelpIcon ? (
88
- <Tooltip
89
- label={helpIconLabel ?? 'Help'}
90
- position="top"
91
- withArrow
92
- >
105
+ <Tooltip label={helpIconLabel ?? 'Help'} position="top" withArrow>
93
106
  <ActionIcon
94
107
  variant="transparent"
95
108
  size="xs"
@@ -98,14 +111,58 @@ export const NumberInput = forwardRef<HTMLInputElement, DSNumberInputProps>(
98
111
  color="gray"
99
112
  style={{ cursor: onHelpIconClick ? 'pointer' : 'default' }}
100
113
  >
101
- <IconInfoCircle size={14} aria-hidden />
114
+ <RiInformationLine size={14} aria-hidden />
102
115
  </ActionIcon>
103
116
  </Tooltip>
104
117
  ) : null;
105
118
 
106
- const composedRightSection = (helpIconElement && rightSection)
107
- ? <Group gap={4} wrap="nowrap">{rightSection}{helpIconElement}</Group>
108
- : helpIconElement || rightSection;
119
+ const iconSize = CONTROL_ICON_SIZE[size] ?? 14;
120
+ const showDsControls = !hideControls && !readOnly && !disabled && rightSection == null;
121
+
122
+ const dsControls = showDsControls ? (
123
+ <Stack gap={0} justify="center">
124
+ <ActionIcon
125
+ variant="transparent"
126
+ size="xs"
127
+ tabIndex={-1}
128
+ aria-hidden
129
+ onMouseDown={(event) => event.preventDefault()}
130
+ onClick={() => internalHandlersRef.current?.increment()}
131
+ >
132
+ <RiAddLine size={iconSize} aria-hidden />
133
+ </ActionIcon>
134
+ <ActionIcon
135
+ variant="transparent"
136
+ size="xs"
137
+ tabIndex={-1}
138
+ aria-hidden
139
+ onMouseDown={(event) => event.preventDefault()}
140
+ onClick={() => internalHandlersRef.current?.decrement()}
141
+ >
142
+ <RiSubtractLine size={iconSize} aria-hidden />
143
+ </ActionIcon>
144
+ </Stack>
145
+ ) : null;
146
+
147
+ const composedRightSection = (() => {
148
+ if (rightSection && helpIconElement) {
149
+ return (
150
+ <Group gap={4} wrap="nowrap">
151
+ {rightSection}
152
+ {helpIconElement}
153
+ </Group>
154
+ );
155
+ }
156
+ if (dsControls && helpIconElement) {
157
+ return (
158
+ <Group gap={4} wrap="nowrap">
159
+ {dsControls}
160
+ {helpIconElement}
161
+ </Group>
162
+ );
163
+ }
164
+ return helpIconElement || rightSection || dsControls;
165
+ })();
109
166
 
110
167
  return (
111
168
  <MantineNumberInput
@@ -114,8 +171,12 @@ export const NumberInput = forwardRef<HTMLInputElement, DSNumberInputProps>(
114
171
  radius="sm"
115
172
  required={required}
116
173
  label={enhancedLabel}
117
- rightSection={composedRightSection}
118
174
  error={effectiveError}
175
+ hideControls
176
+ readOnly={readOnly}
177
+ disabled={disabled}
178
+ handlersRef={setHandlersRef}
179
+ rightSection={composedRightSection}
119
180
  {...props}
120
181
  />
121
182
  );
@@ -33,7 +33,7 @@ import { Button } from '../Buttons/index.js';
33
33
  * >
34
34
  * <Stack gap="md">
35
35
  * <Text>Are you sure you want to perform this action?</Text>
36
- * <Inline justify="flex-end" gap="sm">
36
+ * <Inline justify="flex-start" gap="sm">
37
37
  * <Button variant="outline">Cancel</Button>
38
38
  * <Button variant="primary">Confirm</Button>
39
39
  * </Inline>
@@ -56,6 +56,6 @@ export const ConfirmationModal = forwardRef(({ confirmLabel = 'Confirm', cancelL
56
56
  onClose();
57
57
  }
58
58
  };
59
- return (_jsx(Modal, { ref: ref, onClose: onClose, ...props, children: _jsxs(Stack, { gap: "md", children: [children, _jsxs(Inline, { justify: "flex-end", gap: "sm", children: [_jsx(Button, { variant: "outline", onClick: handleCancel, children: cancelLabel }), _jsx(Button, { variant: confirmVariant, onClick: handleConfirm, loading: confirmLoading, children: confirmLabel })] })] }) }));
59
+ return (_jsx(Modal, { ref: ref, onClose: onClose, ...props, children: _jsxs(Stack, { gap: "md", children: [children, _jsxs(Inline, { justify: "flex-start", gap: "sm", children: [_jsx(Button, { variant: "outline", onClick: handleCancel, children: cancelLabel }), _jsx(Button, { variant: confirmVariant, onClick: handleConfirm, loading: confirmLoading, children: confirmLabel })] })] }) }));
60
60
  });
61
61
  ConfirmationModal.displayName = 'ConfirmationModal';
@@ -45,7 +45,7 @@ export interface DSModalProps extends Omit<MantineModalProps, 'title'> {
45
45
  * >
46
46
  * <Stack gap="md">
47
47
  * <Text>Are you sure you want to perform this action?</Text>
48
- * <Inline justify="flex-end" gap="sm">
48
+ * <Inline justify="flex-start" gap="sm">
49
49
  * <Button variant="outline">Cancel</Button>
50
50
  * <Button variant="primary">Confirm</Button>
51
51
  * </Inline>
@@ -142,7 +142,7 @@ export const ConfirmationModal = forwardRef<HTMLDivElement, ConfirmationModalPro
142
142
  >
143
143
  <Stack gap="md">
144
144
  {children}
145
- <Inline justify="flex-end" gap="sm">
145
+ <Inline justify="flex-start" gap="sm">
146
146
  <Button variant="outline" onClick={handleCancel}>
147
147
  {cancelLabel}
148
148
  </Button>
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.20",
2
+ "version": "0.0.22",
3
3
  "contracts": [
4
4
  {
5
5
  "id": "Alert",