@appdirect/design-system 0.0.22 → 0.0.25

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 (65) 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/AutocompleteClearable.js +33 -35
  5. package/dist/Combobox/AutocompleteClearable.tsx +56 -121
  6. package/dist/Combobox/SearchableSelect.js +23 -42
  7. package/dist/Combobox/SearchableSelect.tsx +33 -129
  8. package/dist/Combobox/Select.js +13 -19
  9. package/dist/Combobox/Select.tsx +15 -44
  10. package/dist/Combobox/index.js +1 -1
  11. package/dist/Combobox/index.ts +2 -2
  12. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/CustomBottomToolbar.module.css +1 -24
  13. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +2 -5
  14. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.tsx +15 -22
  15. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +1 -2
  16. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.module.css +2 -9
  17. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.tsx +4 -5
  18. package/dist/ComplexComponents/DataTable/DataTableGrid/DataTableGrid.module.css +2 -6
  19. package/dist/ComplexComponents/DataTable/DataTableGrid/index.js +1 -1
  20. package/dist/ComplexComponents/DataTable/DataTableGrid/index.tsx +1 -1
  21. package/dist/ComplexComponents/Utilities/CopyButton.js +15 -27
  22. package/dist/ComplexComponents/Utilities/CopyButton.tsx +35 -49
  23. package/dist/DESIGN.md +7 -7
  24. package/dist/DataDisplay/Avatar.js +26 -81
  25. package/dist/DataDisplay/Avatar.tsx +35 -93
  26. package/dist/DataDisplay/Pill.js +21 -79
  27. package/dist/DataDisplay/Pill.tsx +34 -116
  28. package/dist/Inputs/ColorInput.js +12 -18
  29. package/dist/Inputs/ColorInput.tsx +13 -41
  30. package/dist/Inputs/NumberInput.js +15 -50
  31. package/dist/Inputs/NumberInput.tsx +18 -117
  32. package/dist/Inputs/Radio.js +1 -1
  33. package/dist/Inputs/Radio.tsx +1 -1
  34. package/dist/Inputs/RadioGroup.js +1 -1
  35. package/dist/Inputs/RadioGroup.tsx +1 -1
  36. package/dist/Inputs/TextArea.js +12 -18
  37. package/dist/Inputs/TextArea.tsx +13 -41
  38. package/dist/Inputs/TextInput.js +12 -18
  39. package/dist/Inputs/TextInput.tsx +13 -41
  40. package/dist/Inputs/inputLabel.js +35 -0
  41. package/dist/Inputs/inputLabel.tsx +83 -0
  42. package/dist/Layout/Inline.js +5 -42
  43. package/dist/Layout/Inline.tsx +6 -79
  44. package/dist/Overlays/Tooltip.js +2 -2
  45. package/dist/Overlays/Tooltip.tsx +4 -1
  46. package/dist/contracts/index.json +1 -1
  47. package/dist/css/foundations.css +44 -2
  48. package/dist/css/mantine.css +236 -43
  49. package/dist/css/tokens.css +58 -26
  50. package/dist/index.js +3 -3
  51. package/dist/index.ts +4 -4
  52. package/dist/stories/Combobox/{Multiselect.stories.tsx → ADMultiselect.stories.tsx} +159 -53
  53. package/dist/stories/Combobox/SearchableSelect.stories.tsx +3 -3
  54. package/dist/stories/Combobox/Select.stories.tsx +1 -1
  55. package/dist/stories/ComplexComponents/Utilities/CopyButton.stories.tsx +4 -14
  56. package/dist/stories/Inputs/ColorInput.stories.tsx +12 -0
  57. package/dist/stories/Inputs/NumberInput.stories.tsx +12 -0
  58. package/dist/stories/Inputs/Radio.stories.tsx +10 -5
  59. package/dist/stories/Inputs/RadioGroup.stories.tsx +122 -80
  60. package/dist/stories/Inputs/TextArea.stories.tsx +12 -0
  61. package/dist/stories/Inputs/TextInput.stories.tsx +12 -0
  62. package/dist/stories/index.json +42 -35
  63. package/package.json +10 -6
  64. package/dist/Combobox/Multiselect.js +0 -31
  65. package/dist/Combobox/Multiselect.tsx +0 -158
@@ -1,131 +1,35 @@
1
1
  'use client';
2
2
 
3
- import { useState } from 'react';
4
- import { Combobox, InputBase, useCombobox } from '@mantine/core';
5
-
6
- const languages = [
7
- 'JavaScript',
8
- 'TypeScript',
9
- 'Python',
10
- 'Java',
11
- 'C++',
12
- 'Go',
13
- 'Rust',
14
- 'Swift',
15
- ];
16
-
17
- export interface DSSearchableSelectProps {
18
- /** Label for the input */
19
- label?: string;
20
- /** Placeholder text */
21
- placeholder?: string;
22
- /** Data array for options - can be strings or objects with value/label */
23
- data?: string[] | { value: string; label: string }[];
24
- /** Description text displayed below the input */
25
- description?: string;
26
- /** Error message */
27
- error?: string;
28
- /** Whether the field is required */
29
- required?: boolean;
30
- /** Whether to show "(optional)" next to the label */
31
- showOptional?: boolean;
32
- /** Whether the input is disabled */
33
- disabled?: boolean;
34
- /** Whether the select is searchable */
35
- searchable?: boolean;
36
- /** Input size */
37
- size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
38
- /** Style object for the component */
39
- style?: React.CSSProperties;
40
- }
41
-
42
- export function SearchableSelect({
43
- label,
44
- placeholder = "Search programming languages",
45
- data = languages,
46
- description,
47
- error,
48
- required = false,
49
- showOptional = false,
50
- disabled = false,
51
- searchable = true,
52
- size = 'md',
53
- style,
54
- ...props
55
- }: DSSearchableSelectProps) {
56
- const combobox = useCombobox({
57
- onDropdownClose: () => combobox.resetSelectedOption(),
58
- });
59
-
60
- const [value, setValue] = useState<string | null>(null);
61
- const [search, setSearch] = useState('');
62
-
63
- // Convert data to consistent format
64
- const normalizedData = data.map(item =>
65
- typeof item === 'string' ? { value: item, label: item } : item
66
- );
67
-
68
- const shouldFilterOptions = normalizedData.every((item) => item.value !== search);
69
- const filteredOptions = shouldFilterOptions && searchable
70
- ? normalizedData.filter((item) =>
71
- item.label.toLowerCase().includes(search.toLowerCase().trim()) ||
72
- item.value.toLowerCase().includes(search.toLowerCase().trim())
73
- )
74
- : normalizedData;
75
-
76
- const options = filteredOptions.map((item) => (
77
- <Combobox.Option value={item.value} key={item.value}>
78
- {item.label}
79
- </Combobox.Option>
80
- ));
81
-
82
- return (
83
- <div style={style}>
84
- <Combobox
85
- store={combobox}
86
- withinPortal={false}
87
- onOptionSubmit={(val) => {
88
- setValue(val);
89
- setSearch(val);
90
- combobox.closeDropdown();
91
- }}
92
- >
93
- <Combobox.Target>
94
- <InputBase
95
- label={label}
96
- description={description}
97
- error={error}
98
- required={required}
99
- size={size}
100
- disabled={disabled}
101
- rightSection={<Combobox.Chevron />}
102
- value={search}
103
- onChange={(event) => {
104
- combobox.openDropdown();
105
- combobox.updateSelectedOptionIndex();
106
- setSearch(event.currentTarget.value);
107
- }}
108
- onClick={() => combobox.openDropdown()}
109
- onFocus={() => combobox.openDropdown()}
110
- onBlur={() => {
111
- combobox.closeDropdown();
112
- setSearch(value || '');
113
- }}
114
- placeholder={placeholder}
115
- rightSectionPointerEvents="none"
116
- withAsterisk={required && !showOptional}
117
- {...(showOptional && !required && {
118
- label: label ? `${label} (optional)` : undefined
119
- })}
120
- />
121
- </Combobox.Target>
122
-
123
- <Combobox.Dropdown>
124
- <Combobox.Options>
125
- {options.length > 0 ? options : <Combobox.Empty>Nothing found</Combobox.Empty>}
126
- </Combobox.Options>
127
- </Combobox.Dropdown>
128
- </Combobox>
129
- </div>
130
- );
131
- }
3
+ import React, { forwardRef } from 'react';
4
+ import { Select, DSSelectProps } from './Select';
5
+
6
+ // ========================== TYPES ==========================
7
+
8
+ export type DSSearchableSelectProps = DSSelectProps;
9
+
10
+ // ========================== COMPONENT ==========================
11
+
12
+ /**
13
+ * AppDirect Design System SearchableSelect
14
+ *
15
+ * The DS `Select` (Mantine's `Select`) with `searchable` on by default, so the
16
+ * field is typeable and filters its options. Search, filtering, controlled and
17
+ * uncontrolled value, clearable, grouping and every other `Select` prop are Mantine
18
+ * core behavior.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * <SearchableSelect
23
+ * label="Language"
24
+ * placeholder="Search languages"
25
+ * data={['JavaScript', 'TypeScript', 'Python']}
26
+ * />
27
+ * ```
28
+ */
29
+ export const SearchableSelect = forwardRef<HTMLInputElement, DSSearchableSelectProps>(
30
+ ({ searchable = true, size = 'md', ...props }, ref) => (
31
+ <Select ref={ref} searchable={searchable} size={size} {...props} />
32
+ )
33
+ );
34
+
35
+ SearchableSelect.displayName = 'SearchableSelect';
@@ -1,10 +1,9 @@
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 { Select as MantineSelect, ActionIcon, Group } from '@mantine/core';
5
- import { IconInfoCircle, IconSelector } from '@tabler/icons-react';
6
- import { Text } from '../Typography/Text.js';
7
- import { Tooltip } from '../Overlays/Tooltip.js';
4
+ import { Select as MantineSelect } from '@mantine/core';
5
+ import { IconSelector } from '@tabler/icons-react';
6
+ import { getInputLabelProps } from '../Inputs/inputLabel.js';
8
7
  import styles from './Select.module.css';
9
8
  // ========================== COMPONENT ==========================
10
9
  /**
@@ -55,19 +54,14 @@ import styles from './Select.module.css';
55
54
  */
56
55
  export const Select = forwardRef(({ size = 'sm', borderless = false, showOptional = false, required, label, hasHelpIcon = false, helpIconLabel, onHelpIconClick, error, errorCaption, variant, classNames, ...props }, ref) => {
57
56
  const effectiveError = error === true ? (errorCaption ?? true) : error;
58
- const enhancedLabel = React.useMemo(() => {
59
- if (!label)
60
- return label;
61
- if (showOptional && !required) {
62
- return (_jsxs(_Fragment, { children: [label, " ", _jsx(Text, { span: true, c: "dimmed", fw: "normal", children: "(Optional)" })] }));
63
- }
64
- return label;
65
- }, [label, showOptional, required]);
66
- 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;
67
- const selectorIcon = _jsx(IconSelector, { size: 14, "aria-hidden": true });
68
- const composedRightSection = helpIconElement
69
- ? _jsxs(Group, { gap: 4, wrap: "nowrap", children: [selectorIcon, helpIconElement] })
70
- : selectorIcon;
57
+ const labelProps = getInputLabelProps({
58
+ label,
59
+ required,
60
+ showOptional,
61
+ hasHelpIcon,
62
+ helpIconLabel,
63
+ onHelpIconClick,
64
+ });
71
65
  const mergedClassNames = typeof classNames === 'function'
72
66
  ? classNames
73
67
  : {
@@ -76,6 +70,6 @@ export const Select = forwardRef(({ size = 'sm', borderless = false, showOptiona
76
70
  .filter(Boolean)
77
71
  .join(' '),
78
72
  };
79
- return (_jsx(MantineSelect, { ...props, ref: ref, size: size, radius: "sm", required: required, label: enhancedLabel, rightSection: composedRightSection, rightSectionPointerEvents: hasHelpIcon || props.clearable ? 'auto' : 'none', variant: variant ?? 'default', classNames: mergedClassNames, error: effectiveError }));
73
+ return (_jsx(MantineSelect, { ...props, ref: ref, size: size, radius: "sm", required: required, ...labelProps, rightSection: _jsx(IconSelector, { size: 14, "aria-hidden": true }), rightSectionPointerEvents: props.clearable ? 'auto' : 'none', variant: variant ?? 'default', classNames: mergedClassNames, error: effectiveError }));
80
74
  });
81
75
  Select.displayName = 'Select';
@@ -1,11 +1,10 @@
1
1
  'use client';
2
2
 
3
3
  import React, { forwardRef } from 'react';
4
- import { Select as MantineSelect, SelectProps as MantineSelectProps, ActionIcon, Group } from '@mantine/core';
5
- import { IconInfoCircle, IconSelector } from '@tabler/icons-react';
4
+ import { Select as MantineSelect, SelectProps as MantineSelectProps } from '@mantine/core';
5
+ import { IconSelector } from '@tabler/icons-react';
6
6
  import { ComponentSize } from '../config';
7
- import { Text } from '../Typography/Text';
8
- import { Tooltip } from '../Overlays/Tooltip';
7
+ import { getInputLabelProps } from '../Inputs/inputLabel';
9
8
  import styles from './Select.module.css';
10
9
 
11
10
  // ========================== TYPES ==========================
@@ -17,7 +16,7 @@ export interface DSSelectProps extends Omit<MantineSelectProps, 'size' | 'radius
17
16
  borderless?: boolean;
18
17
  /** Whether to show "(Optional)" text after label */
19
18
  showOptional?: boolean;
20
- /** Whether to show a help icon with a tooltip in the right section */
19
+ /** Whether to show a (?) help icon with a tooltip to the right of the label */
21
20
  hasHelpIcon?: boolean;
22
21
  /** Tooltip label shown when hovering the help icon. Also used as aria-label for a11y */
23
22
  helpIconLabel?: string;
@@ -99,42 +98,14 @@ export const Select = forwardRef<HTMLInputElement, DSSelectProps>(
99
98
  ) => {
100
99
  const effectiveError = error === true ? (errorCaption ?? true) : error;
101
100
 
102
- const enhancedLabel = React.useMemo(() => {
103
- if (!label) return label;
104
- if (showOptional && !required) {
105
- return (
106
- <>
107
- {label} <Text span c="dimmed" fw="normal">(Optional)</Text>
108
- </>
109
- );
110
- }
111
- return label;
112
- }, [label, showOptional, required]);
113
-
114
- const helpIconElement = hasHelpIcon ? (
115
- <Tooltip
116
- label={helpIconLabel ?? 'Help'}
117
- position="top"
118
- withArrow
119
- >
120
- <ActionIcon
121
- variant="transparent"
122
- size="xs"
123
- aria-label={helpIconLabel ?? 'Help'}
124
- onClick={onHelpIconClick}
125
- color="gray"
126
- style={{ cursor: onHelpIconClick ? 'pointer' : 'default' }}
127
- >
128
- <IconInfoCircle size={14} aria-hidden />
129
- </ActionIcon>
130
- </Tooltip>
131
- ) : null;
132
-
133
- const selectorIcon = <IconSelector size={14} aria-hidden />;
134
-
135
- const composedRightSection = helpIconElement
136
- ? <Group gap={4} wrap="nowrap">{selectorIcon}{helpIconElement}</Group>
137
- : selectorIcon;
101
+ const labelProps = getInputLabelProps({
102
+ label,
103
+ required,
104
+ showOptional,
105
+ hasHelpIcon,
106
+ helpIconLabel,
107
+ onHelpIconClick,
108
+ });
138
109
 
139
110
  const mergedClassNames =
140
111
  typeof classNames === 'function'
@@ -153,9 +124,9 @@ export const Select = forwardRef<HTMLInputElement, DSSelectProps>(
153
124
  size={size}
154
125
  radius="sm"
155
126
  required={required}
156
- label={enhancedLabel}
157
- rightSection={composedRightSection}
158
- rightSectionPointerEvents={hasHelpIcon || props.clearable ? 'auto' : 'none'}
127
+ {...labelProps}
128
+ rightSection={<IconSelector size={14} aria-hidden />}
129
+ rightSectionPointerEvents={props.clearable ? 'auto' : 'none'}
159
130
  variant={variant ?? 'default'}
160
131
  classNames={mergedClassNames}
161
132
  error={effectiveError}
@@ -5,6 +5,6 @@
5
5
  */
6
6
  export { SearchableSelect } from './SearchableSelect.js';
7
7
  export { AutocompleteClearable } from './AutocompleteClearable.js';
8
- export { Multiselect } from './Multiselect.js';
8
+ export { ADMultiselect } from './ADMultiselect.js';
9
9
  export { Select } from './Select.js';
10
10
  export { Combobox } from './Combobox.js';
@@ -10,8 +10,8 @@ export type { DSSearchableSelectProps } from './SearchableSelect';
10
10
  export { AutocompleteClearable } from './AutocompleteClearable';
11
11
  export type { DSAutocompleteClearableProps } from './AutocompleteClearable';
12
12
 
13
- export { Multiselect } from './Multiselect';
14
- export type { DSMultiselectProps } from './Multiselect';
13
+ export { ADMultiselect } from './ADMultiselect';
14
+ export type { ADMultiselectProps } from './ADMultiselect';
15
15
 
16
16
  export { Select } from './Select';
17
17
  export type { DSSelectProps } from './Select';
@@ -4,27 +4,4 @@
4
4
 
5
5
  .pageSize {
6
6
  flex-shrink: 0;
7
- }
8
-
9
- /* The page-size select reads as plain text with a chevron: no fill or border, even on hover and
10
- focus. The selectors are deliberately as specific as the global Input state rules
11
- (:hover / :focus) so they win without !important. */
12
- .pageSize .pageSizeInput[data-variant="unstyled"]:not([data-error]):not([data-disabled]) {
13
- background: transparent;
14
- border-color: transparent;
15
- padding-inline-start: 0;
16
- cursor: pointer;
17
- }
18
-
19
- .pageSizeChevron {
20
- width: var(--ad-icon-size-lg);
21
- height: var(--ad-icon-size-lg);
22
- flex-shrink: 0;
23
- color: var(--ad-color-text-default);
24
- }
25
-
26
- /* The global Input section rule pads both sides, which squeezes the chevron to a few px. */
27
- .pageSize .pageSizeSection[data-position] {
28
- padding-inline: 0;
29
- justify-content: flex-end;
30
- }
7
+ }
@@ -2,15 +2,12 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  // Source of truth: micro-ui-ts/src/components/Table/CustomBottomToolbar/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
4
4
  import React, { useMemo } from "react";
5
- import { Box, Flex, Select, ActionIcon, Text } from "@mantine/core";
5
+ import { Flex, Select, ActionIcon, Text } from "@mantine/core";
6
6
  import { RiArrowLeftSLine as PreviousPageIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
7
7
  import { RiArrowRightSLine as NextPageIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
8
- import { RiArrowDropDownFill as DropdownIcon } from "@remixicon/react"; // DS-ADAPT: down triangle for the page-size select
9
8
  import { translate } from "../translations/index.js"; // DS-ADAPT: translate lives in DataTable/translations
10
9
  import { getFormattedPageCount, getFormattedPageSize, getNumOfRowsPerPageOptions } from "./utils.js";
11
10
  import styles from "./CustomBottomToolbar.module.css";
12
- /** Keeps the page-size control compact; value is max two digits (e.g. 40). */
13
- const PAGE_SIZE_SELECT_WIDTH = "var(--ad-table-toolbar-page-size-width)";
14
11
  const CustomBottomToolbar = ({ paginationState, onPageSizeChange, onNextPage, onPreviousPage, isDisabled = false, hasNextPage, hasPreviousPage, totalNumOfRows = 0, isFetching = false, numberOfSelectedRowsText, }) => {
15
12
  const rowCount = totalNumOfRows; // DS-ADAPT: derive directly; copying in an effect lags one render
16
13
  const onPageSizeChangeHandler = (newPageSize) => {
@@ -18,7 +15,7 @@ const CustomBottomToolbar = ({ paginationState, onPageSizeChange, onNextPage, on
18
15
  };
19
16
  const formattedPageLegend = getFormattedPageCount(paginationState.pageIndex, paginationState.pageSize, rowCount);
20
17
  const numOfRowsPerPageOptions = useMemo(() => getNumOfRowsPerPageOptions(rowCount, undefined, paginationState.pageSize), [rowCount, paginationState.pageSize]);
21
- return (_jsxs(Flex, { className: styles.toolbar, bg: "var(--ad-color-bg-subtle)", px: "md", py: "xshalf", justify: "space-between", align: "center", children: [_jsxs(Flex, { align: "center", gap: "sm", w: "fit-content", flex: "none", children: [_jsx(Text, { size: "xs", children: translate("table.rows.per.page") }), _jsx(Box, { w: PAGE_SIZE_SELECT_WIDTH, className: styles.pageSize, children: _jsx(Select, { disabled: !rowCount || isDisabled, "aria-label": translate("table.rows.per.page"), data: numOfRowsPerPageOptions, value: paginationState.pageSize.toString(), onChange: onPageSizeChangeHandler, size: "xs", w: "100%", rightSectionWidth: 22, variant: "unstyled", rightSection: _jsx(DropdownIcon, { className: styles.pageSizeChevron }), classNames: { input: styles.pageSizeInput, section: styles.pageSizeSection }, comboboxProps: { withinPortal: false, width: "max-content" } }) })] }), numberOfSelectedRowsText && _jsx(Text, { size: "xs", children: numberOfSelectedRowsText }), _jsxs(Flex, { align: "center", gap: "xs", children: [_jsx(Text, { size: "xs", children: formattedPageLegend }), _jsx(ActionIcon, { "data-testid": "previous-page-btn", disabled: !hasPreviousPage || isDisabled, onClick: () => {
18
+ return (_jsxs(Flex, { className: styles.toolbar, bg: "var(--ad-color-bg-subtle)", px: "md", py: "xshalf", justify: "space-between", align: "center", children: [_jsxs(Flex, { align: "center", gap: "sm", w: "fit-content", flex: "none", children: [_jsx(Text, { size: "xs", children: translate("table.rows.per.page") }), _jsx(Select, { className: styles.pageSize, disabled: !rowCount || isDisabled, "aria-label": translate("table.rows.per.page"), data: numOfRowsPerPageOptions, value: paginationState.pageSize.toString(), onChange: onPageSizeChangeHandler, size: "xs", w: "var(--ad-table-toolbar-page-size-width)", flex: "0 0 auto", allowDeselect: false, comboboxProps: { withinPortal: false, width: "max-content" } })] }), numberOfSelectedRowsText && _jsx(Text, { size: "xs", children: numberOfSelectedRowsText }), _jsxs(Flex, { align: "center", gap: "xs", children: [_jsx(Text, { size: "xs", children: formattedPageLegend }), _jsx(ActionIcon, { "data-testid": "previous-page-btn", disabled: !hasPreviousPage || isDisabled, onClick: () => {
22
19
  if (!isFetching && onPreviousPage) {
23
20
  onPreviousPage();
24
21
  }
@@ -1,10 +1,9 @@
1
1
  'use client'; // DS-ADAPT: Next.js App Router
2
2
  // Source of truth: micro-ui-ts/src/components/Table/CustomBottomToolbar/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
3
3
  import React, { useMemo, ReactElement } from "react";
4
- import { Box, Flex, Select, ActionIcon, Text } from "@mantine/core";
4
+ import { Flex, Select, ActionIcon, Text } from "@mantine/core";
5
5
  import { RiArrowLeftSLine as PreviousPageIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
6
6
  import { RiArrowRightSLine as NextPageIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
7
- import { RiArrowDropDownFill as DropdownIcon } from "@remixicon/react"; // DS-ADAPT: down triangle for the page-size select
8
7
  import { PaginationState } from "../types";
9
8
  import { translate } from "../translations"; // DS-ADAPT: translate lives in DataTable/translations
10
9
  import { getFormattedPageCount, getFormattedPageSize, getNumOfRowsPerPageOptions } from "./utils";
@@ -23,9 +22,6 @@ export interface CustomBottomToolbarProps {
23
22
  numberOfSelectedRowsText?: string; // if row selection is enabled
24
23
  }
25
24
 
26
- /** Keeps the page-size control compact; value is max two digits (e.g. 40). */
27
- const PAGE_SIZE_SELECT_WIDTH = "var(--ad-table-toolbar-page-size-width)";
28
-
29
25
  const CustomBottomToolbar = ({
30
26
  paginationState,
31
27
  onPageSizeChange,
@@ -66,22 +62,19 @@ const CustomBottomToolbar = ({
66
62
  >
67
63
  <Flex align="center" gap="sm" w="fit-content" flex="none">
68
64
  <Text size="xs">{translate("table.rows.per.page")}</Text>
69
- <Box w={PAGE_SIZE_SELECT_WIDTH} className={styles.pageSize}>
70
- <Select
71
- disabled={!rowCount || isDisabled}
72
- aria-label={translate("table.rows.per.page")}
73
- data={numOfRowsPerPageOptions}
74
- value={paginationState.pageSize.toString()}
75
- onChange={onPageSizeChangeHandler}
76
- size="xs"
77
- w="100%"
78
- rightSectionWidth={22}
79
- variant="unstyled"
80
- rightSection={<DropdownIcon className={styles.pageSizeChevron} />} // DS-ADAPT: down triangle marks the select as interactive
81
- classNames={{ input: styles.pageSizeInput, section: styles.pageSizeSection }} // DS-ADAPT: chevron, no fill or border
82
- comboboxProps={{ withinPortal: false, width: "max-content" }}
83
- />
84
- </Box>
65
+ <Select
66
+ className={styles.pageSize}
67
+ disabled={!rowCount || isDisabled}
68
+ aria-label={translate("table.rows.per.page")}
69
+ data={numOfRowsPerPageOptions}
70
+ value={paginationState.pageSize.toString()}
71
+ onChange={onPageSizeChangeHandler}
72
+ size="xs"
73
+ w="var(--ad-table-toolbar-page-size-width)"
74
+ flex="0 0 auto"
75
+ allowDeselect={false}
76
+ comboboxProps={{ withinPortal: false, width: "max-content" }}
77
+ />
85
78
  </Flex>
86
79
  {numberOfSelectedRowsText && <Text size="xs">{numberOfSelectedRowsText}</Text>}
87
80
  <Flex align="center" gap="xs">
@@ -121,4 +114,4 @@ const CustomBottomToolbar = ({
121
114
  );
122
115
  };
123
116
 
124
- export default CustomBottomToolbar;
117
+ export default CustomBottomToolbar;
@@ -4,7 +4,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  import React, { useEffect, useRef, useState } from "react";
5
5
  import { RiSearchLine as SearchIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
6
6
  import { RiCloseLine as CloseIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
7
- import clsx from "clsx";
8
7
  import { TextInput } from "@mantine/core";
9
8
  import { translate } from "../translations/index.js"; // DS-ADAPT: translate lives in DataTable/translations
10
9
  import styles from "./SearchFilter.module.css";
@@ -37,6 +36,6 @@ const SearchFilter = ({ searchTerm, onChange }) => {
37
36
  useEffect(() => {
38
37
  setLocalSearchTerm(searchTerm);
39
38
  }, [searchTerm]);
40
- return (_jsx(TextInput, { size: "xs", placeholder: translate("table.search.placeholder"), flex: "1 1 auto", onChange: (event) => handleSearchChange(event.target.value), classNames: { section: styles.section }, rightSection: localSearchTerm === "" ? (_jsx(SearchIcon, { className: styles.icon })) : (_jsx(CloseIcon, { "data-testid": "search-clear", onClick: clearSearch, className: clsx(styles.icon, styles.clearIcon) })), value: localSearchTerm }));
39
+ return (_jsx(TextInput, { size: "xs", placeholder: translate("table.search.placeholder"), flex: "1 1 auto", classNames: { section: styles.section }, onChange: (event) => handleSearchChange(event.target.value), rightSection: localSearchTerm === "" ? (_jsx(SearchIcon, {})) : (_jsx(CloseIcon, { className: styles.clearIcon, "data-testid": "search-clear", onClick: clearSearch })), value: localSearchTerm }));
41
40
  };
42
41
  export default SearchFilter;
@@ -1,16 +1,9 @@
1
- /* The global Input section rule pads the section on both sides, which squeezes a bare icon down to
2
- a few px. The icon fills the section instead. */
1
+ /* Section slot sizing comes from Mantine; icon size from mantine.css input.section tokens. */
3
2
  .section[data-position] {
4
3
  padding-inline: 0;
5
4
  justify-content: center;
6
5
  }
7
6
 
8
- .icon {
9
- width: var(--ad-icon-size-md);
10
- height: var(--ad-icon-size-md);
11
- flex-shrink: 0;
12
- }
13
-
14
7
  .clearIcon {
15
8
  cursor: pointer;
16
- }
9
+ }
@@ -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
  >
@@ -1,45 +1,33 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import React, { useState } from 'react';
4
- import { ActionIcon } from '@mantine/core';
3
+ import React from 'react';
4
+ import { ActionIcon, CopyButton as MantineCopyButton } from '@mantine/core';
5
5
  import { Tooltip } from '../../Overlays/Tooltip.js';
6
6
  import { RiFileCopyLine } from '@remixicon/react';
7
7
  /**
8
8
  * CopyButton Component
9
9
  *
10
- * A reusable button component with copy-to-clipboard functionality and interactive tooltips.
11
- * Shows "Copy" on hover and "Copied" after clicking, resetting when cursor leaves.
10
+ * Built on Mantine's `CopyButton`: clicking writes `value` to the clipboard and the
11
+ * tooltip switches from "Copy" to "Copied" for `timeout` ms.
12
12
  *
13
13
  * @example
14
- * // Basic usage
15
- * <CopyButton
16
- * value="Production"
17
- * label="Environment"
18
- * onCopy={(value) => navigator.clipboard.writeText(value)}
19
- * />
14
+ * <CopyButton value="Production" label="Environment" />
20
15
  *
21
16
  * @example
22
- * // With custom icon size
17
+ * // With custom icon size and a callback
23
18
  * <CopyButton
24
19
  * value="sk-1234567890abcdef"
25
20
  * label="API Key"
26
21
  * iconSize={16}
27
- * onCopy={(value) => {
28
- * navigator.clipboard.writeText(value);
29
- * console.log('API Key copied');
30
- * }}
22
+ * onCopy={() => console.log('API Key copied')}
31
23
  * />
32
24
  */
33
- export function CopyButton({ value, label, onCopy, iconSize = 24, }) {
34
- const [isCopied, setIsCopied] = useState(false);
35
- const handleCopy = () => {
36
- if (onCopy) {
37
- onCopy(value);
38
- setIsCopied(true);
39
- }
40
- };
41
- const handleMouseLeave = () => {
42
- setIsCopied(false);
43
- };
44
- return (_jsx(Tooltip, { label: isCopied ? "Copied" : "Copy", position: "top", withArrow: true, children: _jsx(ActionIcon, { variant: "subtle", size: "xs", c: "blue", onClick: handleCopy, onMouseLeave: handleMouseLeave, "aria-label": `Copy ${label}`, children: _jsx(RiFileCopyLine, { size: iconSize }) }) }));
25
+ export function CopyButton({ value, label, onCopy, iconSize = 24, timeout = 1500, }) {
26
+ return (_jsx(MantineCopyButton, { value: value, timeout: timeout, children: ({ copied, copy }) => (_jsx(Tooltip, { label: copied ? 'Copied' : 'Copy', position: "top", withArrow: true, children: _jsx(ActionIcon, { variant: "subtle",
27
+ // Numeric size on purpose: t-shirt sizes get a token rule that pins the svg size,
28
+ // which would override `iconSize`. The button is the icon plus 4px padding per side.
29
+ size: iconSize + 8, c: "blue", onClick: () => {
30
+ copy();
31
+ onCopy?.(value);
32
+ }, "aria-label": `Copy ${label}`, children: _jsx(RiFileCopyLine, { size: iconSize }) }) })) }));
45
33
  }