@appdirect/design-system 0.0.17 → 0.0.19

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 (90) hide show
  1. package/bin/ad-sync-design-md.mjs +0 -0
  2. package/dist/ComplexComponents/DashboardWidget/DashboardWidget.js +15 -51
  3. package/dist/ComplexComponents/DashboardWidget/DashboardWidget.tsx +91 -139
  4. package/dist/ComplexComponents/DataTable/CellHoverReveal/CellHoverReveal.module.css +25 -0
  5. package/dist/ComplexComponents/DataTable/CellHoverReveal/index.js +24 -0
  6. package/dist/ComplexComponents/DataTable/CellHoverReveal/index.tsx +44 -0
  7. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/CustomBottomToolbar.module.css +7 -0
  8. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +25 -77
  9. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.tsx +101 -157
  10. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.js +14 -7
  11. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.ts +13 -7
  12. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/CustomToolbarAlertBannerContent.module.css +4 -0
  13. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.js +8 -20
  14. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.tsx +40 -58
  15. package/dist/ComplexComponents/DataTable/CustomTopToolbar/CustomTopToolbar.module.css +7 -0
  16. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/DateRangeSelectorFilter.module.css +3 -0
  17. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +50 -154
  18. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.tsx +59 -205
  19. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/utils.js +48 -0
  20. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/utils.ts +51 -0
  21. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.js +5 -25
  22. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.tsx +7 -28
  23. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount.js +16 -0
  24. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount.tsx +26 -0
  25. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +26 -28
  26. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.tsx +38 -38
  27. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.js +8 -18
  28. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.module.css +3 -0
  29. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.tsx +25 -37
  30. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.js +67 -378
  31. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.tsx +170 -711
  32. package/dist/ComplexComponents/DataTable/DataTable.js +74 -393
  33. package/dist/ComplexComponents/DataTable/DataTable.tsx +229 -546
  34. package/dist/ComplexComponents/DataTable/DataTableGrid/DataTableGrid.module.css +85 -0
  35. package/dist/ComplexComponents/DataTable/DataTableGrid/index.js +46 -0
  36. package/dist/ComplexComponents/DataTable/DataTableGrid/index.tsx +143 -0
  37. package/dist/ComplexComponents/DataTable/DataTableShell/DataTableShell.module.css +38 -0
  38. package/dist/ComplexComponents/DataTable/DataTableShell/index.js +9 -0
  39. package/dist/ComplexComponents/DataTable/DataTableShell/index.tsx +47 -0
  40. package/dist/ComplexComponents/DataTable/ErrorOverlay/index.js +6 -6
  41. package/dist/ComplexComponents/DataTable/ErrorOverlay/index.tsx +53 -24
  42. package/dist/ComplexComponents/DataTable/SelectCheckbox/index.js +33 -0
  43. package/dist/ComplexComponents/DataTable/SelectCheckbox/index.tsx +63 -0
  44. package/dist/ComplexComponents/DataTable/SortableHeaderCell/SortableHeaderCell.module.css +3 -0
  45. package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.js +43 -21
  46. package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.tsx +62 -38
  47. package/dist/ComplexComponents/DataTable/ToggleDensityButton/index.js +18 -0
  48. package/dist/ComplexComponents/DataTable/ToggleDensityButton/index.tsx +47 -0
  49. package/dist/ComplexComponents/DataTable/ToggleFullScreenButton/index.js +19 -0
  50. package/dist/ComplexComponents/DataTable/ToggleFullScreenButton/index.tsx +59 -0
  51. package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/ToolbarAlertBanner.module.css +15 -0
  52. package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/index.js +8 -0
  53. package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/index.tsx +20 -0
  54. package/dist/ComplexComponents/DataTable/hooks/useClickOutside.js +27 -0
  55. package/dist/ComplexComponents/DataTable/hooks/useClickOutside.ts +39 -0
  56. package/dist/ComplexComponents/DataTable/index.js +5 -1
  57. package/dist/ComplexComponents/DataTable/index.ts +13 -2
  58. package/dist/ComplexComponents/DataTable/table.module.css +9 -0
  59. package/dist/ComplexComponents/DataTable/tableFeatures.js +6 -0
  60. package/dist/ComplexComponents/DataTable/tableFeatures.ts +7 -0
  61. package/dist/ComplexComponents/DataTable/translations/en.js +16 -4
  62. package/dist/ComplexComponents/DataTable/translations/en.ts +16 -4
  63. package/dist/ComplexComponents/DataTable/translations/index.js +5 -0
  64. package/dist/ComplexComponents/DataTable/translations/index.ts +11 -1
  65. package/dist/ComplexComponents/DataTable/types.js +5 -0
  66. package/dist/ComplexComponents/DataTable/types.ts +17 -0
  67. package/dist/ComplexComponents/DataTable/utils/parseCSSVarId.js +3 -0
  68. package/dist/ComplexComponents/DataTable/utils/parseCSSVarId.ts +4 -0
  69. package/dist/ComplexComponents/KeyInsight/index.ts +1 -1
  70. package/dist/DESIGN.md +9 -10
  71. package/dist/contracts/DashboardWidget.json +92 -0
  72. package/dist/contracts/DataTable.json +83 -6
  73. package/dist/contracts/index.json +6 -1
  74. package/dist/css/foundations.css +4 -0
  75. package/dist/css/mantine.css +173 -7
  76. package/dist/css/tokens.css +3195 -0
  77. package/dist/index.js +3 -0
  78. package/dist/index.ts +14 -1
  79. package/dist/stories/ComplexComponents/DashboardWidget/DashboardWidget.stories.tsx +76 -1
  80. package/dist/stories/ComplexComponents/DataTable/DataTable.stories.tsx +216 -458
  81. package/dist/stories/index.json +16 -15
  82. package/package.json +5 -3
  83. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.js +0 -31
  84. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.tsx +0 -76
  85. package/dist/hooks/useTableHandlers.js +0 -136
  86. package/dist/hooks/useTableHandlers.ts +0 -179
  87. package/dist/hooks/useTableRenderFunctions.js +0 -164
  88. package/dist/hooks/useTableRenderFunctions.tsx +0 -283
  89. package/dist/hooks/useTableState.js +0 -70
  90. package/dist/hooks/useTableState.ts +0 -81
@@ -0,0 +1,48 @@
1
+ // Source of truth: micro-ui-ts/src/components/Table/CustomTopToolbar/DateRangeSelectorFilter/utils.ts. Keep in sync; DS-only changes are marked DS-ADAPT.
2
+ import { translate } from "../../translations/index.js"; // DS-ADAPT: translate lives in DataTable/translations
3
+ export var Preset;
4
+ (function (Preset) {
5
+ Preset["WEEK"] = "week";
6
+ Preset["MONTH"] = "month";
7
+ Preset["QUARTER"] = "quarter";
8
+ Preset["CUSTOM"] = "custom";
9
+ })(Preset || (Preset = {}));
10
+ export const getPresets = () => [
11
+ {
12
+ label: translate("table.filters.date.range.week"),
13
+ value: Preset.WEEK,
14
+ },
15
+ {
16
+ label: translate("table.filters.date.range.month"),
17
+ value: Preset.MONTH,
18
+ },
19
+ {
20
+ label: translate("table.filters.date.range.quarter"),
21
+ value: Preset.QUARTER,
22
+ },
23
+ {
24
+ label: translate("table.filters.date.range.custom"),
25
+ value: Preset.CUSTOM,
26
+ },
27
+ ];
28
+ export const getPresetLabel = (value) => {
29
+ return getPresets().find(item => item.value === value)?.label || "";
30
+ };
31
+ export const getDateRangeFromPreset = (preset) => {
32
+ const now = new Date();
33
+ const start = new Date();
34
+ switch (preset) {
35
+ case Preset.WEEK:
36
+ start.setDate(now.getDate() - 7);
37
+ break;
38
+ case Preset.MONTH:
39
+ start.setMonth(now.getMonth() - 1);
40
+ break;
41
+ case Preset.QUARTER:
42
+ start.setMonth(now.getMonth() - 3);
43
+ break;
44
+ default:
45
+ return null;
46
+ }
47
+ return [start, now];
48
+ };
@@ -0,0 +1,51 @@
1
+ // Source of truth: micro-ui-ts/src/components/Table/CustomTopToolbar/DateRangeSelectorFilter/utils.ts. Keep in sync; DS-only changes are marked DS-ADAPT.
2
+ import { translate } from "../../translations"; // DS-ADAPT: translate lives in DataTable/translations
3
+
4
+ export enum Preset {
5
+ WEEK = "week",
6
+ MONTH = "month",
7
+ QUARTER = "quarter",
8
+ CUSTOM = "custom",
9
+ }
10
+
11
+ export const getPresets = (): { label: string; value: Preset }[] => [
12
+ {
13
+ label: translate("table.filters.date.range.week"),
14
+ value: Preset.WEEK,
15
+ },
16
+ {
17
+ label: translate("table.filters.date.range.month"),
18
+ value: Preset.MONTH,
19
+ },
20
+ {
21
+ label: translate("table.filters.date.range.quarter"),
22
+ value: Preset.QUARTER,
23
+ },
24
+ {
25
+ label: translate("table.filters.date.range.custom"),
26
+ value: Preset.CUSTOM,
27
+ },
28
+ ];
29
+
30
+ export const getPresetLabel = (value: string): string => {
31
+ return getPresets().find(item => item.value === value)?.label || "";
32
+ };
33
+
34
+ export const getDateRangeFromPreset = (preset: string): [Date | null, Date | null] | null => {
35
+ const now = new Date();
36
+ const start = new Date();
37
+ switch (preset) {
38
+ case Preset.WEEK:
39
+ start.setDate(now.getDate() - 7);
40
+ break;
41
+ case Preset.MONTH:
42
+ start.setMonth(now.getMonth() - 1);
43
+ break;
44
+ case Preset.QUARTER:
45
+ start.setMonth(now.getMonth() - 3);
46
+ break;
47
+ default:
48
+ return null;
49
+ }
50
+ return [start, now];
51
+ };
@@ -1,30 +1,10 @@
1
+ 'use client'; // DS-ADAPT: Next.js App Router
1
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
+ // Source of truth: micro-ui-ts/src/components/Table/CustomTopToolbar/FilterChip.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
2
4
  import React from "react";
3
- import { Chip } from "@mantine/core";
4
- import { RiCloseLine } from '@remixicon/react';
5
- /**
6
- * FilterChip component for displaying active filters with remove functionality
7
- * Shows as an outlined chip with a close icon for easy removal
8
- */
5
+ import { Chip, rem } from "@mantine/core";
6
+ import { RiCloseLine as CloseIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
9
7
  const FilterChip = ({ label, onClick }) => {
10
- return (_jsx(Chip, { color: "gray", size: "xs", variant: "outline", checked: true, onChange: onClick, icon: _jsx(RiCloseLine, { size: 12 }), styles: {
11
- root: {
12
- cursor: 'pointer',
13
- '&[dataChecked="true"]': {
14
- backgroundColor: 'transparent',
15
- border: '1px solid var(--ad-color-border-default)',
16
- color: 'var(--ad-color-text-dimmed)',
17
- },
18
- '&:hover': {
19
- backgroundColor: 'var(--ad-color-bg-subtle)',
20
- },
21
- },
22
- label: {
23
- cursor: 'pointer',
24
- },
25
- iconWrapper: {
26
- color: 'var(--ad-color-text-dimmed)',
27
- },
28
- }, children: label }));
8
+ return (_jsx(Chip, { color: "gray.3", size: "xs", icon: _jsx(CloseIcon, { style: { width: rem(10), height: rem(10) } }), variant: "outline", checked: true, onChange: onClick, children: label }));
29
9
  };
30
10
  export default FilterChip;
@@ -1,44 +1,23 @@
1
+ 'use client'; // DS-ADAPT: Next.js App Router
2
+ // Source of truth: micro-ui-ts/src/components/Table/CustomTopToolbar/FilterChip.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
1
3
  import React from "react";
2
- import { Chip } from "@mantine/core";
3
- import { RiCloseLine } from '@remixicon/react';
4
+ import { Chip, rem } from "@mantine/core";
5
+ import { RiCloseLine as CloseIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
4
6
 
5
7
  interface FilterChipProps {
6
8
  label: string;
7
9
  onClick: () => void;
8
10
  }
9
11
 
10
- /**
11
- * FilterChip component for displaying active filters with remove functionality
12
- * Shows as an outlined chip with a close icon for easy removal
13
- */
14
12
  const FilterChip = ({ label, onClick }: FilterChipProps): JSX.Element => {
15
13
  return (
16
14
  <Chip
17
- color="gray"
15
+ color="gray.3"
18
16
  size="xs"
17
+ icon={<CloseIcon style={{ width: rem(10), height: rem(10) }} />}
19
18
  variant="outline"
20
- checked={true}
19
+ checked
21
20
  onChange={onClick}
22
- icon={<RiCloseLine size={12} />}
23
- styles={{
24
- root: {
25
- cursor: 'pointer',
26
- '&[dataChecked="true"]': {
27
- backgroundColor: 'transparent',
28
- border: '1px solid var(--ad-color-border-default)',
29
- color: 'var(--ad-color-text-dimmed)',
30
- },
31
- '&:hover': {
32
- backgroundColor: 'var(--ad-color-bg-subtle)',
33
- },
34
- },
35
- label: {
36
- cursor: 'pointer',
37
- },
38
- iconWrapper: {
39
- color: 'var(--ad-color-text-dimmed)',
40
- },
41
- }}
42
21
  >
43
22
  {label}
44
23
  </Chip>
@@ -0,0 +1,16 @@
1
+ 'use client'; // DS-ADAPT: Next.js App Router
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ // Source of truth: micro-ui-ts/src/components/Table/CustomTopToolbar/ResultCount.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
4
+ import React from "react";
5
+ import { Loader, Text } from "@mantine/core";
6
+ import { translate } from "../translations/index.js"; // DS-ADAPT: translate lives in DataTable/translations
7
+ const ResultCount = ({ resultCount, isLoading = false }) => {
8
+ const getResultCountText = () => {
9
+ if (resultCount === 1) {
10
+ return translate("table.filters.result.count.one");
11
+ }
12
+ return translate("table.filters.result.count.many", { count: resultCount });
13
+ };
14
+ return isLoading ? (_jsx(Loader, { color: "gray", size: "xs" })) : (_jsx(Text, { size: "sm", children: getResultCountText() }));
15
+ };
16
+ export default ResultCount;
@@ -0,0 +1,26 @@
1
+ 'use client'; // DS-ADAPT: Next.js App Router
2
+ // Source of truth: micro-ui-ts/src/components/Table/CustomTopToolbar/ResultCount.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
3
+ import React, { ReactElement } from "react";
4
+ import { Loader, Text } from "@mantine/core";
5
+ import { translate } from "../translations"; // DS-ADAPT: translate lives in DataTable/translations
6
+
7
+ interface ResultCountProps {
8
+ resultCount: number;
9
+ isLoading?: boolean;
10
+ }
11
+
12
+ const ResultCount = ({ resultCount, isLoading = false }: ResultCountProps): ReactElement => {
13
+ const getResultCountText = (): string => {
14
+ if (resultCount === 1) {
15
+ return translate("table.filters.result.count.one");
16
+ }
17
+ return translate("table.filters.result.count.many", { count: resultCount });
18
+ };
19
+ return isLoading ? (
20
+ <Loader color="gray" size="xs" />
21
+ ) : (
22
+ <Text size="sm">{getResultCountText()}</Text>
23
+ );
24
+ };
25
+
26
+ export default ResultCount;
@@ -1,42 +1,40 @@
1
+ 'use client'; // DS-ADAPT: Next.js App Router
1
2
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import React, { useCallback, useState } from "react";
3
+ // Source of truth: micro-ui-ts/src/components/Table/CustomTopToolbar/SearchFilter.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
4
+ import React, { useEffect, useRef, useState } from "react";
5
+ import { RiSearchLine as SearchIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
6
+ import { RiCloseLine as CloseIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
3
7
  import { rem, TextInput } from "@mantine/core";
4
- import { IconSearch, IconX } from '@tabler/icons-react';
5
- // Local translation function
6
- const translate = (key, params) => {
7
- if (!params)
8
- return key;
9
- return Object.entries(params).reduce((str, [key, value]) => {
10
- return str.replace(`{${key}}`, String(value));
11
- }, key);
12
- };
8
+ import { translate } from "../translations/index.js"; // DS-ADAPT: translate lives in DataTable/translations
13
9
  const debounce = (fn, timeout = 1000) => {
14
10
  let timer;
15
11
  return (value) => {
16
- if (timer) {
12
+ if (timer)
17
13
  clearTimeout(timer);
18
- }
19
- timer = setTimeout(() => {
20
- fn(value);
21
- }, timeout);
14
+ timer = setTimeout(() => fn(value), timeout);
22
15
  };
23
16
  };
24
17
  const SearchFilter = ({ searchTerm, onChange }) => {
25
- const [value, setValue] = useState(searchTerm);
26
- const debouncedOnChange = useCallback(debounce(onChange), [onChange]);
27
- const handleChange = (event) => {
28
- const newValue = event.currentTarget.value;
29
- setValue(newValue);
30
- debouncedOnChange(newValue);
18
+ const [localSearchTerm, setLocalSearchTerm] = useState(searchTerm);
19
+ // DS-ADAPT: always call the latest onChange; the debounced fn is created once.
20
+ const onChangeRef = useRef(onChange);
21
+ useEffect(() => {
22
+ onChangeRef.current = onChange;
23
+ });
24
+ const debouncedSearch = useRef(debounce(value => {
25
+ onChangeRef.current(value);
26
+ }, 300)).current;
27
+ const handleSearchChange = (value) => {
28
+ setLocalSearchTerm(value);
29
+ debouncedSearch(value);
31
30
  };
32
- const handleClear = () => {
33
- setValue("");
31
+ const clearSearch = () => {
32
+ setLocalSearchTerm("");
34
33
  onChange("");
35
34
  };
36
- return (_jsx(TextInput, { size: "xs", placeholder: translate("table.search.placeholder"), style: { flexGrow: "1" }, onChange: handleChange, rightSection: value ? (_jsx(IconX, { "data-testid": "search-clear", onClick: handleClear, style: { width: rem(14), height: rem(14), cursor: "pointer" } })) : (_jsx(IconSearch, { style: { width: rem(14), height: rem(14) } })), value: value, styles: {
37
- wrapper: {
38
- fontSize: "var(--mantine-font-size-xs)",
39
- },
40
- } }));
35
+ useEffect(() => {
36
+ setLocalSearchTerm(searchTerm);
37
+ }, [searchTerm]);
38
+ return (_jsx(TextInput, { size: "xs", placeholder: translate("table.search.placeholder"), flex: "1 1 auto", onChange: (event) => handleSearchChange(event.target.value), rightSection: localSearchTerm === "" ? (_jsx(SearchIcon, { style: { width: rem(14), height: rem(14) } })) : (_jsx(CloseIcon, { "data-testid": "search-clear", onClick: clearSearch, style: { width: rem(14), height: rem(14), cursor: "pointer" } })), value: localSearchTerm }));
41
39
  };
42
40
  export default SearchFilter;
@@ -1,24 +1,16 @@
1
- import React, { ReactElement, useCallback, useState } from "react";
1
+ 'use client'; // DS-ADAPT: Next.js App Router
2
+ // Source of truth: micro-ui-ts/src/components/Table/CustomTopToolbar/SearchFilter.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
3
+ import React, { ReactElement, useEffect, useRef, useState } from "react";
4
+ import { RiSearchLine as SearchIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
5
+ import { RiCloseLine as CloseIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
2
6
  import { rem, TextInput } from "@mantine/core";
3
- import { IconSearch, IconX } from '@tabler/icons-react';
4
-
5
- // Local translation function
6
- const translate = (key: string, params?: Record<string, any>) => {
7
- if (!params) return key;
8
- return Object.entries(params).reduce((str, [key, value]) => {
9
- return str.replace(`{${key}}`, String(value));
10
- }, key);
11
- };
7
+ import { translate } from "../translations"; // DS-ADAPT: translate lives in DataTable/translations
12
8
 
13
9
  const debounce = (fn: (value: string) => void, timeout = 1000): ((value: string) => void) => {
14
10
  let timer: NodeJS.Timeout | undefined;
15
- return (value: string) => {
16
- if (timer) {
17
- clearTimeout(timer);
18
- }
19
- timer = setTimeout(() => {
20
- fn(value);
21
- }, timeout);
11
+ return (value: string): void => {
12
+ if (timer) clearTimeout(timer);
13
+ timer = setTimeout(() => fn(value), timeout);
22
14
  };
23
15
  };
24
16
 
@@ -28,44 +20,52 @@ interface SearchFilterProps {
28
20
  }
29
21
 
30
22
  const SearchFilter = ({ searchTerm, onChange }: SearchFilterProps): ReactElement => {
31
- const [value, setValue] = useState(searchTerm);
23
+ const [localSearchTerm, setLocalSearchTerm] = useState<string>(searchTerm);
24
+
25
+ // DS-ADAPT: always call the latest onChange; the debounced fn is created once.
26
+ const onChangeRef = useRef(onChange);
27
+ useEffect(() => {
28
+ onChangeRef.current = onChange;
29
+ });
32
30
 
33
- const debouncedOnChange = useCallback(debounce(onChange), [onChange]);
31
+ const debouncedSearch = useRef(
32
+ debounce(value => {
33
+ onChangeRef.current(value);
34
+ }, 300)
35
+ ).current;
34
36
 
35
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
36
- const newValue = event.currentTarget.value;
37
- setValue(newValue);
38
- debouncedOnChange(newValue);
37
+ const handleSearchChange = (value: string): void => {
38
+ setLocalSearchTerm(value);
39
+ debouncedSearch(value);
39
40
  };
40
41
 
41
- const handleClear = (): void => {
42
- setValue("");
42
+ const clearSearch = (): void => {
43
+ setLocalSearchTerm("");
43
44
  onChange("");
44
45
  };
45
46
 
47
+ useEffect(() => {
48
+ setLocalSearchTerm(searchTerm);
49
+ }, [searchTerm]);
50
+
46
51
  return (
47
52
  <TextInput
48
53
  size="xs"
49
54
  placeholder={translate("table.search.placeholder")}
50
- style={{ flexGrow: "1" }}
51
- onChange={handleChange}
55
+ flex="1 1 auto"
56
+ onChange={(event): void => handleSearchChange(event.target.value)}
52
57
  rightSection={
53
- value ? (
54
- <IconX
58
+ localSearchTerm === "" ? (
59
+ <SearchIcon style={{ width: rem(14), height: rem(14) }} />
60
+ ) : (
61
+ <CloseIcon
55
62
  data-testid="search-clear"
56
- onClick={handleClear}
63
+ onClick={clearSearch}
57
64
  style={{ width: rem(14), height: rem(14), cursor: "pointer" }}
58
65
  />
59
- ) : (
60
- <IconSearch style={{ width: rem(14), height: rem(14) }} />
61
66
  )
62
67
  }
63
- value={value}
64
- styles={{
65
- wrapper: {
66
- fontSize: "var(--mantine-font-size-xs)",
67
- },
68
- }}
68
+ value={localSearchTerm}
69
69
  />
70
70
  );
71
71
  };
@@ -1,21 +1,11 @@
1
+ 'use client'; // DS-ADAPT: Next.js App Router
1
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
+ // Source of truth: micro-ui-ts/src/components/Table/CustomTopToolbar/SelectFilter.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
2
4
  import React from "react";
3
- import { MultiSelect } from "@mantine/core";
4
- // Local translation function
5
- const translate = (key, params) => {
6
- if (!params)
7
- return key;
8
- return Object.entries(params).reduce((str, [key, value]) => {
9
- return str.replace(`{${key}}`, String(value));
10
- }, key);
11
- };
12
- const SelectFilter = ({ label, data, selectedValue, onChange, placeholderEmpty = "All", placeholderWithSelection = "Select more" }) => {
13
- const hasSelection = selectedValue && selectedValue.length > 0;
14
- const placeholder = hasSelection ? placeholderWithSelection : placeholderEmpty;
15
- return (_jsx(MultiSelect, { size: "xs", label: label, placeholder: placeholder, data: data, value: selectedValue || [], onChange: (value) => onChange(value.length > 0 ? value : null), clearable: true, styles: {
16
- label: {
17
- fontWeight: 600,
18
- },
19
- } }));
20
- };
5
+ import { Select } from "@mantine/core";
6
+ import { translate } from "../translations/index.js"; // DS-ADAPT: translate lives in DataTable/translations
7
+ import styles from "./SelectFilter.module.css";
8
+ const SelectFilter = ({ selectedValue, data, onChange, label, }) => (_jsx("div", { role: "menuitem", children: _jsx(Select, { className: styles.field, "data-testid": "select-filter", clearable: true, size: "xs", label: label, placeholder: translate("table.filters.show.all"), data: data, onChange: (value) => {
9
+ onChange(value);
10
+ }, value: selectedValue }) }));
21
11
  export default SelectFilter;
@@ -0,0 +1,3 @@
1
+ .field label {
2
+ font-weight: 600;
3
+ }
@@ -1,50 +1,38 @@
1
+ 'use client'; // DS-ADAPT: Next.js App Router
2
+ // Source of truth: micro-ui-ts/src/components/Table/CustomTopToolbar/SelectFilter.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
1
3
  import React, { ReactElement } from "react";
2
- import { ComboboxData, MultiSelect } from "@mantine/core";
3
-
4
- // Local translation function
5
- const translate = (key: string, params?: Record<string, any>) => {
6
- if (!params) return key;
7
- return Object.entries(params).reduce((str, [key, value]) => {
8
- return str.replace(`{${key}}`, String(value));
9
- }, key);
10
- };
4
+ import { ComboboxData, Select } from "@mantine/core";
5
+ import { translate } from "../translations"; // DS-ADAPT: translate lives in DataTable/translations
6
+ import styles from "./SelectFilter.module.css";
11
7
 
12
8
  export interface SelectFilterProps {
13
9
  label: string;
14
- data: ComboboxData;
15
- selectedValue: string[] | null;
16
- onChange: (value: string[] | null) => void;
17
- placeholderEmpty?: string;
18
- placeholderWithSelection?: string;
10
+ selectedValue: string | null;
11
+ onChange: (value: string | null) => void;
12
+ data?: ComboboxData;
19
13
  }
20
14
 
21
- const SelectFilter = ({
22
- label,
23
- data,
24
- selectedValue,
25
- onChange,
26
- placeholderEmpty = "All",
27
- placeholderWithSelection = "Select more"
28
- }: SelectFilterProps): ReactElement => {
29
- const hasSelection = selectedValue && selectedValue.length > 0;
30
- const placeholder = hasSelection ? placeholderWithSelection : placeholderEmpty;
31
-
32
- return (
33
- <MultiSelect
15
+ const SelectFilter = ({
16
+ selectedValue,
17
+ data,
18
+ onChange,
19
+ label,
20
+ }: SelectFilterProps): ReactElement => (
21
+ <div role="menuitem">
22
+ <Select
23
+ className={styles.field}
24
+ data-testid="select-filter"
25
+ clearable
34
26
  size="xs"
35
27
  label={label}
36
- placeholder={placeholder}
28
+ placeholder={translate("table.filters.show.all")}
37
29
  data={data}
38
- value={selectedValue || []}
39
- onChange={(value) => onChange(value.length > 0 ? value : null)}
40
- clearable
41
- styles={{
42
- label: {
43
- fontWeight: 600,
44
- },
30
+ onChange={(value): void => {
31
+ onChange(value);
45
32
  }}
33
+ value={selectedValue}
46
34
  />
47
- );
48
- };
35
+ </div>
36
+ );
49
37
 
50
38
  export default SelectFilter;