@appdirect/design-system 0.0.22 → 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.
Files changed (53) hide show
  1. package/README.md +1 -1
  2. package/dist/Combobox/ADMultiselect.js +91 -0
  3. package/dist/Combobox/ADMultiselect.tsx +237 -0
  4. package/dist/Combobox/Select.js +13 -19
  5. package/dist/Combobox/Select.tsx +15 -44
  6. package/dist/Combobox/index.js +1 -1
  7. package/dist/Combobox/index.ts +2 -2
  8. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/CustomBottomToolbar.module.css +1 -24
  9. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +2 -5
  10. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.tsx +15 -22
  11. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +1 -2
  12. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.module.css +2 -9
  13. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.tsx +4 -5
  14. package/dist/ComplexComponents/DataTable/DataTableGrid/DataTableGrid.module.css +2 -6
  15. package/dist/ComplexComponents/DataTable/DataTableGrid/index.js +1 -1
  16. package/dist/ComplexComponents/DataTable/DataTableGrid/index.tsx +1 -1
  17. package/dist/DESIGN.md +7 -7
  18. package/dist/DataDisplay/Pill.js +21 -79
  19. package/dist/DataDisplay/Pill.tsx +34 -116
  20. package/dist/Inputs/ColorInput.js +12 -18
  21. package/dist/Inputs/ColorInput.tsx +13 -41
  22. package/dist/Inputs/NumberInput.js +15 -50
  23. package/dist/Inputs/NumberInput.tsx +18 -117
  24. package/dist/Inputs/Radio.js +1 -1
  25. package/dist/Inputs/Radio.tsx +1 -1
  26. package/dist/Inputs/RadioGroup.js +1 -1
  27. package/dist/Inputs/RadioGroup.tsx +1 -1
  28. package/dist/Inputs/TextArea.js +12 -18
  29. package/dist/Inputs/TextArea.tsx +13 -41
  30. package/dist/Inputs/TextInput.js +12 -18
  31. package/dist/Inputs/TextInput.tsx +13 -41
  32. package/dist/Inputs/inputLabel.js +35 -0
  33. package/dist/Inputs/inputLabel.tsx +83 -0
  34. package/dist/Overlays/Tooltip.js +2 -2
  35. package/dist/Overlays/Tooltip.tsx +4 -1
  36. package/dist/contracts/index.json +1 -1
  37. package/dist/css/foundations.css +44 -2
  38. package/dist/css/mantine.css +236 -43
  39. package/dist/css/tokens.css +58 -26
  40. package/dist/index.js +3 -3
  41. package/dist/index.ts +4 -4
  42. package/dist/stories/Combobox/{Multiselect.stories.tsx → ADMultiselect.stories.tsx} +159 -53
  43. package/dist/stories/Combobox/Select.stories.tsx +1 -1
  44. package/dist/stories/Inputs/ColorInput.stories.tsx +12 -0
  45. package/dist/stories/Inputs/NumberInput.stories.tsx +12 -0
  46. package/dist/stories/Inputs/Radio.stories.tsx +10 -5
  47. package/dist/stories/Inputs/RadioGroup.stories.tsx +122 -80
  48. package/dist/stories/Inputs/TextArea.stories.tsx +12 -0
  49. package/dist/stories/Inputs/TextInput.stories.tsx +12 -0
  50. package/dist/stories/index.json +40 -32
  51. package/package.json +10 -6
  52. package/dist/Combobox/Multiselect.js +0 -31
  53. package/dist/Combobox/Multiselect.tsx +0 -158
@@ -3,7 +3,6 @@
3
3
  import React, { ReactElement, useEffect, useRef, useState } from "react";
4
4
  import { RiSearchLine as SearchIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
5
5
  import { RiCloseLine as CloseIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
6
- import clsx from "clsx";
7
6
  import { TextInput } from "@mantine/core";
8
7
  import { translate } from "../translations"; // DS-ADAPT: translate lives in DataTable/translations
9
8
  import styles from "./SearchFilter.module.css";
@@ -55,16 +54,16 @@ const SearchFilter = ({ searchTerm, onChange }: SearchFilterProps): ReactElement
55
54
  size="xs"
56
55
  placeholder={translate("table.search.placeholder")}
57
56
  flex="1 1 auto"
57
+ classNames={{ section: styles.section }}
58
58
  onChange={(event): void => handleSearchChange(event.target.value)}
59
- classNames={{ section: styles.section }} // DS-ADAPT: icon sizing via tokens in a module
60
59
  rightSection={
61
60
  localSearchTerm === "" ? (
62
- <SearchIcon className={styles.icon} />
61
+ <SearchIcon />
63
62
  ) : (
64
63
  <CloseIcon
64
+ className={styles.clearIcon}
65
65
  data-testid="search-clear"
66
66
  onClick={clearSearch}
67
- className={clsx(styles.icon, styles.clearIcon)}
68
67
  />
69
68
  )
70
69
  }
@@ -73,4 +72,4 @@ const SearchFilter = ({ searchTerm, onChange }: SearchFilterProps): ReactElement
73
72
  );
74
73
  };
75
74
 
76
- export default SearchFilter;
75
+ export default SearchFilter;
@@ -38,12 +38,8 @@
38
38
  box-sizing: border-box;
39
39
  }
40
40
 
41
- /* The bottom toolbar owns the line under the table (its border-top) in every layout, including
42
- fullscreen, where a short grid leaves blank space above the footer and a tall one sits flush
43
- against it. The last row therefore never draws its own border: that is the only way to get
44
- exactly one line when flush, and a blank gap above the footer line is the normal table look. */
45
- .body > .bodyRow:last-of-type .bodyCell,
46
- .body > .bodyRow:last-of-type .emptyCell {
41
+ /* Toolbar border-top is the line under the grid; tokens drop the last tbody row border. */
42
+ .body > .bodyRow:last-of-type[data-with-row-border] {
47
43
  border-bottom: none;
48
44
  }
49
45
 
@@ -41,6 +41,6 @@ const DataTableGrid = ({ table, density, rowSelection, isLoading, pageSize, empt
41
41
  }
42
42
  return (_jsx(_Fragment, { children: rows.map(row => (_jsx(TableTr, { className: clsx(styles.bodyRow, rowStyles["table-row"]), "data-selected": rowSelection[row.id] ? "true" : undefined, children: row.getAllCells().map(cell => (_jsx(TableTd, { className: styles.bodyCell, ...getCellSizeProps(cell.column.id, cell.column.columnDef.minSize ?? 40), children: _jsx(table.FlexRender, { cell: cell }) }, cell.id))) }, row.id))) }));
43
43
  };
44
- return (_jsxs(Table, { className: styles.rootGrid, highlightOnHover: false, "data-density": density, withRowBorders: false, withTableBorder: false, __vars: columnSizeVars, children: [_jsx(TableThead, { className: styles.head, children: table.getHeaderGroups().map(headerGroup => (_jsx(TableTr, { className: styles.headRow, children: headerGroup.headers.map(header => (_jsx(TableTh, { className: styles.headCell, ...getCellSizeProps(header.column.id, header.column.columnDef.minSize ?? 40), children: header.isPlaceholder ? null : _jsx(table.FlexRender, { header: header }) }, header.id))) }, headerGroup.id))) }), _jsx(TableTbody, { className: styles.body, children: renderBody() })] }));
44
+ return (_jsxs(Table, { className: styles.rootGrid, highlightOnHover: false, "data-density": density, withRowBorders: true, withTableBorder: false, __vars: columnSizeVars, children: [_jsx(TableThead, { className: styles.head, children: table.getHeaderGroups().map(headerGroup => (_jsx(TableTr, { className: styles.headRow, children: headerGroup.headers.map(header => (_jsx(TableTh, { className: styles.headCell, ...getCellSizeProps(header.column.id, header.column.columnDef.minSize ?? 40), children: header.isPlaceholder ? null : _jsx(table.FlexRender, { header: header }) }, header.id))) }, headerGroup.id))) }), _jsx(TableTbody, { className: styles.body, children: renderBody() })] }));
45
45
  };
46
46
  export default DataTableGrid;
@@ -116,7 +116,7 @@ const DataTableGrid = <TData extends RowData>({
116
116
  className={styles.rootGrid}
117
117
  highlightOnHover={false}
118
118
  data-density={density}
119
- withRowBorders={false}
119
+ withRowBorders
120
120
  withTableBorder={false}
121
121
  __vars={columnSizeVars as unknown as ComponentProps<typeof Table>["__vars"]} // DS-ADAPT: Mantine 9 CssVarsProp typing
122
122
  >
package/dist/DESIGN.md CHANGED
@@ -353,9 +353,9 @@ All inputs default to `radius="sm"` and `size="sm"` matching the button default.
353
353
 
354
354
  ### Combobox
355
355
 
356
- `Select` · `SearchableSelect` · `AutocompleteClearable` · `Multiselect` · `Combobox`
356
+ `Select` · `SearchableSelect` · `AutocompleteClearable` · `ADMultiselect` · `Combobox`
357
357
 
358
- `SearchableSelect` and `AutocompleteClearable` are opinionated wrappers with built-in clear affordance. Use `Multiselect` for tag-style multi-value selection.
358
+ `SearchableSelect` and `AutocompleteClearable` are opinionated wrappers with built-in clear affordance. Use `ADMultiselect` for tag-style multi-value selection.
359
359
 
360
360
  **Toolbar vs tag-editor chips** — in dense table toolbars, multi-select values belong in the **chip row above the table**, with a **count** in the control (see **DataTable patterns**). Do not pile chips inside the combobox there; it breaks horizontal layouts. Standalone tag editors (e.g. form fields that edit a list of tags) may keep chips in the field.
361
361
 
@@ -640,11 +640,11 @@ Do **not** import `tokens.css` in Mantine apps (duplicates foundations; unused b
640
640
 
641
641
  | Package | Version | Role |
642
642
  |---|---|---|
643
- | `@mantine/core` | `^9.6.0` | Base component library |
644
- | `@mantine/hooks` | `^9.6.0` | Utility hooks (useDisclosure, etc.) |
645
- | `@mantine/dates` | `^9.6.0` | Date/time inputs |
646
- | `@mantine/notifications` | `^9.6.0` | Do not use in apps — prefer micro-container `ad-toast` (see Alert vs Notification) |
647
- | `@mantine/dropzone` | `^9.6.0` | File drag-and-drop |
643
+ | `@mantine/core` | `^9.8.2` | Base component library (peer of `@appdirect/design-system`) |
644
+ | `@mantine/hooks` | `^9.8.2` | Utility hooks (useDisclosure, etc.) |
645
+ | `@mantine/dates` | `^9.8.2` | Date/time inputs |
646
+ | `@mantine/notifications` | `^9.8.2` | Do not use in apps — prefer micro-container `ad-toast` (see Alert vs Notification) |
647
+ | `@mantine/dropzone` | `^9.8.2` | File drag-and-drop |
648
648
  | `@appdirect/design-tokens` | `^0.0.6` | AppDirect token CSS variables (`--ad-*`) |
649
649
  | `@tabler/icons-react` | `^3.33.0` | Icon library (supplementary) |
650
650
  | `@remixicon/react` | `^4.6.0` | Primary icon library; default avatar icon |
@@ -1,81 +1,23 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { forwardRef } from 'react';
4
- import { Box, CloseButton } from '@mantine/core';
5
- import { Inline } from '../Layout/index.js';
6
- // Size configurations
7
- const sizeConfig = {
8
- xs: {
9
- height: 18,
10
- fontSize: 10,
11
- lineHeight: 10,
12
- letterSpacing: 0.1563,
13
- px: 8,
14
- gap: 0,
15
- closeSize: 18,
16
- },
17
- sm: {
18
- height: 24,
19
- fontSize: 11,
20
- lineHeight: 12,
21
- letterSpacing: 0.17,
22
- px: 8,
23
- gap: 6,
24
- closeSize: 14,
25
- },
26
- md: {
27
- height: 25,
28
- fontSize: 14,
29
- lineHeight: 14,
30
- letterSpacing: 0.2184,
31
- px: 11.2,
32
- gap: 8,
33
- closeSize: 25,
34
- },
35
- lg: {
36
- height: 32,
37
- fontSize: 13,
38
- lineHeight: 14,
39
- letterSpacing: 0.2,
40
- px: 12,
41
- gap: 8,
42
- closeSize: 18,
43
- },
44
- xl: {
45
- height: 36,
46
- fontSize: 14,
47
- lineHeight: 16,
48
- letterSpacing: 0.22,
49
- px: 14,
50
- gap: 8,
51
- closeSize: 20,
52
- },
53
- };
54
- export const Pill = forwardRef(({ children, size = 'md', withRemoveButton = false, onRemove, style, ...others }, ref) => {
55
- const config = sizeConfig[size];
56
- const colors = {
57
- backgroundColor: 'var(--ad-color-bg-subtle)',
58
- color: 'var(--ad-color-text-dimmed)',
59
- border: 'none',
60
- };
61
- return (_jsx(Box, { ref: ref, style: {
62
- display: 'inline-flex',
63
- alignItems: 'center',
64
- height: config.height,
65
- paddingLeft: config.px,
66
- paddingRight: withRemoveButton ? 0 : config.px,
67
- borderRadius: config.height / 2,
68
- fontSize: config.fontSize,
69
- fontWeight: 400,
70
- lineHeight: `${config.lineHeight}px`,
71
- letterSpacing: config.letterSpacing,
72
- userSelect: 'none',
73
- ...colors,
74
- ...style,
75
- }, ...others, children: _jsxs(Inline, { gap: config.gap, wrap: "nowrap", children: [_jsx("span", { children: children }), withRemoveButton && (_jsx(CloseButton, { size: config.closeSize, onClick: onRemove, variant: "transparent", style: {
76
- color: 'currentColor',
77
- minWidth: config.closeSize,
78
- minHeight: config.closeSize,
79
- }, "aria-label": "Remove" }))] }) }));
80
- });
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import React, { forwardRef } from 'react';
4
+ import { Pill as MantinePill } from '@mantine/core';
5
+ // ========================== COMPONENT ==========================
6
+ /**
7
+ * AppDirect Design System Pill Component
8
+ *
9
+ * A thin wrapper over Mantine's Pill. Colors, radius, height and font size
10
+ * come from the `pill` / `multiselect.pill` component tokens, not from this file.
11
+ *
12
+ * Inside a `PillsInput` / `MultiSelect`, pass `size` explicitly so the pill
13
+ * matches the field: the DS default of `md` takes precedence over the size
14
+ * Mantine would otherwise inherit from the field.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * <Pill>Design</Pill>
19
+ * <Pill withRemoveButton onRemove={() => remove('design')}>Design</Pill>
20
+ * ```
21
+ */
22
+ export const Pill = forwardRef(({ size = 'md', removeButtonProps, ...props }, ref) => (_jsx(MantinePill, { ref: ref, size: size, removeButtonProps: { 'aria-label': 'Remove', ...removeButtonProps }, ...props })));
81
23
  Pill.displayName = 'Pill';
@@ -1,125 +1,43 @@
1
1
  'use client';
2
2
 
3
- import { forwardRef } from 'react';
4
- import { Box, CloseButton } from '@mantine/core';
5
- import { Inline } from '../Layout';
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
- export interface DSPillProps extends React.ComponentPropsWithoutRef<'div'> {
8
- /** Pill content */
9
- children: React.ReactNode;
10
- /** Size of the pill */
11
- size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
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
- // Size configurations
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
- children,
70
- size = 'md',
71
- withRemoveButton = false,
72
- onRemove,
73
- style,
74
- ...others
75
- }, ref) => {
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, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
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';
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 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 }));
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, ActionIcon, Group } from '@mantine/core';
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 { Text } from '../Typography/Text';
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 in the right section */
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 enhancedLabel = React.useMemo(() => {
75
- if (!label) return label;
76
- if (showOptional && !required) {
77
- return (
78
- <>
79
- {label} <Text span c="dimmed" fw="normal">(Optional)</Text>
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
- label={enhancedLabel}
116
- rightSection={composedRightSection}
87
+ rightSection={rightSection}
88
+ {...labelProps}
117
89
  error={effectiveError}
118
90
  {...props}
119
91
  />
@@ -1,61 +1,26 @@
1
1
  'use client';
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
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
- import { Text } from '../Typography/Text.js';
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
- };
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import React, { forwardRef } from 'react';
4
+ import { NumberInput as MantineNumberInput, } from '@mantine/core';
5
+ import { getInputLabelProps } from './inputLabel.js';
15
6
  // ========================== COMPONENT ==========================
16
7
  /**
17
8
  * AppDirect Design System NumberInput Component
18
9
  *
19
10
  * A numeric input built on top of Mantine's NumberInput with
20
11
  * consistent design system styling and enforced radius.
21
- * Increment/decrement use Remix +/- icons (not Mantine chevrons).
12
+ * Increment/decrement uses Mantine's native stacked chevron controls (styled via mantine.css).
22
13
  */
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) => {
14
+ export const NumberInput = forwardRef(({ size = 'md', showOptional = false, required, label, hasHelpIcon = false, helpIconLabel, onHelpIconClick, leftSection, rightSection, error, errorCaption, hideControls, ...props }, ref) => {
24
15
  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
- };
38
- const enhancedLabel = React.useMemo(() => {
39
- if (!label)
40
- return label;
41
- if (showOptional && !required) {
42
- return (_jsxs(_Fragment, { children: [label, ' ', _jsx(Text, { span: true, c: "dimmed", fw: "normal", children: "(Optional)" })] }));
43
- }
44
- return label;
45
- }, [label, showOptional, required]);
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 }));
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 }));
60
25
  });
61
26
  NumberInput.displayName = 'NumberInput';