@appdirect/design-system 0.0.16 → 0.0.18

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 (85) hide show
  1. package/bin/ad-sync-design-md.mjs +0 -0
  2. package/dist/ComplexComponents/DataTable/CellHoverReveal/CellHoverReveal.module.css +25 -0
  3. package/dist/ComplexComponents/DataTable/CellHoverReveal/index.js +24 -0
  4. package/dist/ComplexComponents/DataTable/CellHoverReveal/index.tsx +44 -0
  5. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/CustomBottomToolbar.module.css +7 -0
  6. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +25 -77
  7. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.tsx +101 -157
  8. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.js +14 -7
  9. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.ts +13 -7
  10. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/CustomToolbarAlertBannerContent.module.css +4 -0
  11. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.js +8 -20
  12. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.tsx +40 -58
  13. package/dist/ComplexComponents/DataTable/CustomTopToolbar/CustomTopToolbar.module.css +7 -0
  14. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/DateRangeSelectorFilter.module.css +3 -0
  15. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +50 -154
  16. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.tsx +59 -205
  17. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/utils.js +48 -0
  18. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/utils.ts +51 -0
  19. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.js +5 -25
  20. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.tsx +7 -28
  21. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount.js +16 -0
  22. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount.tsx +26 -0
  23. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +26 -28
  24. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.tsx +38 -38
  25. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.js +8 -18
  26. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.module.css +3 -0
  27. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.tsx +25 -37
  28. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.js +67 -378
  29. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.tsx +170 -711
  30. package/dist/ComplexComponents/DataTable/DataTable.js +74 -393
  31. package/dist/ComplexComponents/DataTable/DataTable.tsx +229 -546
  32. package/dist/ComplexComponents/DataTable/DataTableGrid/DataTableGrid.module.css +85 -0
  33. package/dist/ComplexComponents/DataTable/DataTableGrid/index.js +46 -0
  34. package/dist/ComplexComponents/DataTable/DataTableGrid/index.tsx +143 -0
  35. package/dist/ComplexComponents/DataTable/DataTableShell/DataTableShell.module.css +38 -0
  36. package/dist/ComplexComponents/DataTable/DataTableShell/index.js +9 -0
  37. package/dist/ComplexComponents/DataTable/DataTableShell/index.tsx +47 -0
  38. package/dist/ComplexComponents/DataTable/ErrorOverlay/index.js +6 -6
  39. package/dist/ComplexComponents/DataTable/ErrorOverlay/index.tsx +53 -24
  40. package/dist/ComplexComponents/DataTable/SelectCheckbox/index.js +33 -0
  41. package/dist/ComplexComponents/DataTable/SelectCheckbox/index.tsx +63 -0
  42. package/dist/ComplexComponents/DataTable/SortableHeaderCell/SortableHeaderCell.module.css +3 -0
  43. package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.js +43 -21
  44. package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.tsx +62 -38
  45. package/dist/ComplexComponents/DataTable/ToggleDensityButton/index.js +18 -0
  46. package/dist/ComplexComponents/DataTable/ToggleDensityButton/index.tsx +47 -0
  47. package/dist/ComplexComponents/DataTable/ToggleFullScreenButton/index.js +19 -0
  48. package/dist/ComplexComponents/DataTable/ToggleFullScreenButton/index.tsx +59 -0
  49. package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/ToolbarAlertBanner.module.css +15 -0
  50. package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/index.js +8 -0
  51. package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/index.tsx +20 -0
  52. package/dist/ComplexComponents/DataTable/hooks/useClickOutside.js +27 -0
  53. package/dist/ComplexComponents/DataTable/hooks/useClickOutside.ts +39 -0
  54. package/dist/ComplexComponents/DataTable/index.js +5 -1
  55. package/dist/ComplexComponents/DataTable/index.ts +13 -2
  56. package/dist/ComplexComponents/DataTable/table.module.css +9 -0
  57. package/dist/ComplexComponents/DataTable/tableFeatures.js +6 -0
  58. package/dist/ComplexComponents/DataTable/tableFeatures.ts +7 -0
  59. package/dist/ComplexComponents/DataTable/translations/en.js +16 -4
  60. package/dist/ComplexComponents/DataTable/translations/en.ts +16 -4
  61. package/dist/ComplexComponents/DataTable/translations/index.js +5 -0
  62. package/dist/ComplexComponents/DataTable/translations/index.ts +11 -1
  63. package/dist/ComplexComponents/DataTable/types.js +5 -0
  64. package/dist/ComplexComponents/DataTable/types.ts +17 -0
  65. package/dist/ComplexComponents/DataTable/utils/parseCSSVarId.js +3 -0
  66. package/dist/ComplexComponents/DataTable/utils/parseCSSVarId.ts +4 -0
  67. package/dist/DESIGN.md +9 -10
  68. package/dist/contracts/DataTable.json +83 -6
  69. package/dist/contracts/index.json +1 -1
  70. package/dist/css/foundations.css +4 -0
  71. package/dist/css/mantine.css +1 -1
  72. package/dist/css/tokens.css +3145 -0
  73. package/dist/index.js +3 -0
  74. package/dist/index.ts +14 -1
  75. package/dist/stories/ComplexComponents/DataTable/DataTable.stories.tsx +216 -458
  76. package/dist/stories/index.json +13 -15
  77. package/package.json +5 -3
  78. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.js +0 -31
  79. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.tsx +0 -76
  80. package/dist/hooks/useTableHandlers.js +0 -136
  81. package/dist/hooks/useTableHandlers.ts +0 -179
  82. package/dist/hooks/useTableRenderFunctions.js +0 -164
  83. package/dist/hooks/useTableRenderFunctions.tsx +0 -283
  84. package/dist/hooks/useTableState.js +0 -70
  85. package/dist/hooks/useTableState.ts +0 -81
@@ -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;