@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,55 +1,79 @@
1
- import React, { ReactElement } from "react";
2
- import { UnstyledButton,Text, Center, rem } from '@mantine/core';
3
- import { Inline } from '../../..';
4
- import { IconArrowUp, IconArrowDown, IconArrowsSort } from '@tabler/icons-react';
5
- import { translate } from '../translations';
1
+ 'use client'; // DS-ADAPT: Next.js App Router
2
+ // Source of truth: micro-ui-ts/src/components/Table/SortableHeaderCell/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
3
+ import React, { type ReactElement } from "react";
4
+ import { Flex, rem, UnstyledButton } from "@mantine/core";
5
+ import { translate } from "../translations"; // DS-ADAPT: translate lives in DataTable/translations
6
+ import { RiSortAsc as SortAscIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
7
+ import { RiSortDesc as SortDescIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
8
+ import { RiArrowUpDownLine as UpDownIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
9
+ import styles from "./SortableHeaderCell.module.css";
10
+
11
+ export enum SortDirection {
12
+ ASC = "asc",
13
+ DESC = "desc",
14
+ DEFAULT = "default",
15
+ }
16
+
17
+ const iconSize = {
18
+ width: rem(12),
19
+ height: rem(12),
20
+ };
21
+
22
+ const iconDirectionMap = {
23
+ [SortDirection.ASC]: (
24
+ <SortAscIcon style={{ color: "var(--ad-table-header-sort-active-fg)", ...iconSize }} />
25
+ ),
26
+ [SortDirection.DESC]: (
27
+ <SortDescIcon style={{ color: "var(--ad-table-header-sort-active-fg)", ...iconSize }} />
28
+ ),
29
+ [SortDirection.DEFAULT]: <UpDownIcon data-testid="default-sort-icon" style={iconSize} />,
30
+ };
6
31
 
7
32
  interface SortableHeaderCellProps {
33
+ id: string;
8
34
  label: string;
9
- sortDirection?: 'asc' | 'desc' | null;
10
- onSort?: () => void;
11
- isSortable?: boolean;
35
+ sortingState: { direction: SortDirection; field?: string };
36
+ onSort: (sortingState: { direction: SortDirection; field: string }) => void;
12
37
  }
13
38
 
14
39
  const SortableHeaderCell = ({
40
+ id,
15
41
  label,
16
- sortDirection = null,
42
+ sortingState,
17
43
  onSort,
18
- isSortable = true,
19
44
  }: SortableHeaderCellProps): ReactElement => {
20
- const renderSortIcon = () => {
21
- if (!isSortable) return null;
22
-
23
- switch (sortDirection) {
24
- case 'asc':
25
- return <IconArrowUp style={{ width: rem(16), height: rem(16) }} stroke={1.5} />;
26
- case 'desc':
27
- return <IconArrowDown style={{ width: rem(16), height: rem(16) }} stroke={1.5} />;
28
- default:
29
- return <IconArrowsSort style={{ width: rem(16), height: rem(16) }} stroke={1.5} />;
45
+ const sortDirection = sortingState.field === id ? sortingState.direction : SortDirection.DEFAULT;
46
+
47
+ const onSortClick = (): void => {
48
+ let newSortDirection;
49
+ if (sortDirection === SortDirection.DEFAULT) {
50
+ newSortDirection = SortDirection.ASC;
51
+ } else if (sortDirection === SortDirection.ASC) {
52
+ newSortDirection = SortDirection.DESC;
53
+ } else {
54
+ newSortDirection = SortDirection.DEFAULT;
30
55
  }
56
+ onSort({ direction: newSortDirection, field: id });
31
57
  };
32
58
 
33
- const directionText = sortDirection ? translate(`table.sort.${sortDirection}`) : translate("table.sort.none");
34
- const ariaLabel = translate("table.sort.aria", {
35
- column: label,
36
- direction: directionText
37
- });
38
-
59
+ // DS-ADAPT: keyboard-focusable button with a sort aria-label (a11y)
60
+ const nextDirectionLabel = {
61
+ [SortDirection.DEFAULT]: translate("table.sort.asc"),
62
+ [SortDirection.ASC]: translate("table.sort.desc"),
63
+ [SortDirection.DESC]: translate("table.sort.none"),
64
+ }[sortDirection];
65
+
39
66
  return (
40
- <UnstyledButton
41
- onClick={isSortable ? onSort : undefined}
42
- disabled={!isSortable}
43
- aria-label={ariaLabel}
67
+ <UnstyledButton
68
+ type="button"
69
+ className={styles.header}
70
+ onClick={onSortClick}
71
+ aria-label={translate("table.sort.aria", { column: label, direction: nextDirectionLabel })}
44
72
  >
45
- <Inline justify="space-between">
46
- <Text fw={500} fz="sm">
47
- {label}
48
- </Text>
49
- <Center>
50
- {renderSortIcon()}
51
- </Center>
52
- </Inline>
73
+ <Flex align="center" justify="center" gap="xs">
74
+ {label}
75
+ {iconDirectionMap[sortDirection]}
76
+ </Flex>
53
77
  </UnstyledButton>
54
78
  );
55
79
  };
@@ -0,0 +1,18 @@
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/ToggleDensityButton/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
4
+ import React from "react";
5
+ import { ActionIcon, rem, Tooltip } from "@mantine/core";
6
+ import { RiAlignJustify as AlignJustifyIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
7
+ import { translate } from "../translations/index.js"; // DS-ADAPT: translate lives in DataTable/translations
8
+ import { DENSITY_CYCLE } from "../types.js";
9
+ const IconWrapper = ({ ...props }) => (_jsx(AlignJustifyIcon, { ...props, style: { width: rem(14), height: rem(14) }, color: "var(--ad-color-text-default)" }));
10
+ const ToggleDensityButton = ({ density, onChange, ...rest }) => {
11
+ const label = translate("table.toggle.density");
12
+ const handleClick = () => {
13
+ const next = DENSITY_CYCLE[density] ?? "xs";
14
+ onChange(next);
15
+ };
16
+ return (_jsx(Tooltip, { label: label, withinPortal: true, children: _jsx(ActionIcon, { "aria-label": label, color: "gray", onClick: handleClick, size: "var(--ad-table-toolbar-action-icon-size)", variant: "outline", "data-testid": "toggle-dense-padding", ...rest, children: _jsx(IconWrapper, {}) }) }));
17
+ };
18
+ export default ToggleDensityButton;
@@ -0,0 +1,47 @@
1
+ 'use client'; // DS-ADAPT: Next.js App Router
2
+ // Source of truth: micro-ui-ts/src/components/Table/ToggleDensityButton/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
3
+ import React, { type ReactElement } from "react";
4
+ import { ActionIcon, rem, Tooltip, type ActionIconProps } from "@mantine/core";
5
+ import { RiAlignJustify as AlignJustifyIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
6
+ import { translate } from "../translations"; // DS-ADAPT: translate lives in DataTable/translations
7
+ import { DENSITY_CYCLE, type DensityState } from "../types";
8
+
9
+ interface ToggleDensityButtonProps extends Omit<ActionIconProps, "onChange"> {
10
+ density: DensityState;
11
+ onChange: (density: DensityState) => void;
12
+ }
13
+
14
+ const IconWrapper = ({ ...props }): ReactElement => (
15
+ <AlignJustifyIcon {...props} style={{ width: rem(14), height: rem(14) }} color="var(--ad-color-text-default)" />
16
+ );
17
+
18
+ const ToggleDensityButton = ({
19
+ density,
20
+ onChange,
21
+ ...rest
22
+ }: ToggleDensityButtonProps): ReactElement => {
23
+ const label = translate("table.toggle.density");
24
+
25
+ const handleClick = (): void => {
26
+ const next = DENSITY_CYCLE[density as keyof typeof DENSITY_CYCLE] ?? "xs";
27
+ onChange(next);
28
+ };
29
+
30
+ return (
31
+ <Tooltip label={label} withinPortal>
32
+ <ActionIcon
33
+ aria-label={label}
34
+ color="gray"
35
+ onClick={handleClick}
36
+ size="var(--ad-table-toolbar-action-icon-size)"
37
+ variant="outline"
38
+ data-testid="toggle-dense-padding"
39
+ {...rest}
40
+ >
41
+ <IconWrapper />
42
+ </ActionIcon>
43
+ </Tooltip>
44
+ );
45
+ };
46
+
47
+ export default ToggleDensityButton;
@@ -0,0 +1,19 @@
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/ToggleFullScreenButton/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
4
+ import React, { useState } from "react";
5
+ import { ActionIcon, rem, Tooltip } from "@mantine/core";
6
+ import { RiFullscreenLine as FullscreenIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
7
+ import { RiFullscreenExitLine as FullscreenExitIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
8
+ import { translate } from "../translations/index.js"; // DS-ADAPT: translate lives in DataTable/translations
9
+ const IconWrapper = ({ IconComponent, ...props }) => (_jsx(IconComponent, { ...props, style: { width: rem(14), height: rem(14) }, color: "var(--ad-color-text-default)" }));
10
+ const ToggleFullScreenButton = ({ isFullScreen, onChange, ...rest }) => {
11
+ const label = translate("table.toggle.fullscreen");
12
+ const [tooltipOpened, setTooltipOpened] = useState(false);
13
+ const handleToggle = () => {
14
+ setTooltipOpened(false);
15
+ onChange(!isFullScreen);
16
+ };
17
+ return (_jsx(Tooltip, { label: label, opened: tooltipOpened, withinPortal: true, children: _jsx(ActionIcon, { "aria-label": label, color: "gray", onClick: handleToggle, onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false), size: "var(--ad-table-toolbar-action-icon-size)", variant: "outline", "data-testid": "toggle-fullscreen", ...rest, children: isFullScreen ? (_jsx(IconWrapper, { IconComponent: FullscreenExitIcon })) : (_jsx(IconWrapper, { IconComponent: FullscreenIcon })) }) }));
18
+ };
19
+ export default ToggleFullScreenButton;
@@ -0,0 +1,59 @@
1
+ 'use client'; // DS-ADAPT: Next.js App Router
2
+ // Source of truth: micro-ui-ts/src/components/Table/ToggleFullScreenButton/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
3
+ import React, { useState, type ReactElement } from "react";
4
+ import { ActionIcon, rem, Tooltip, type ActionIconProps } from "@mantine/core";
5
+ import { RiFullscreenLine as FullscreenIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
6
+ import { RiFullscreenExitLine as FullscreenExitIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
7
+ import { translate } from "../translations"; // DS-ADAPT: translate lives in DataTable/translations
8
+
9
+ interface ToggleFullScreenButtonProps extends Omit<ActionIconProps, "onChange"> {
10
+ isFullScreen: boolean;
11
+ onChange: (isFullScreen: boolean) => void;
12
+ }
13
+
14
+ const IconWrapper = ({
15
+ IconComponent,
16
+ ...props
17
+ }: {
18
+ IconComponent: React.ElementType; // DS-ADAPT: accepts @remixicon/react components
19
+ }): ReactElement => (
20
+ <IconComponent {...props} style={{ width: rem(14), height: rem(14) }} color="var(--ad-color-text-default)" />
21
+ );
22
+
23
+ const ToggleFullScreenButton = ({
24
+ isFullScreen,
25
+ onChange,
26
+ ...rest
27
+ }: ToggleFullScreenButtonProps): ReactElement => {
28
+ const label = translate("table.toggle.fullscreen");
29
+ const [tooltipOpened, setTooltipOpened] = useState(false);
30
+
31
+ const handleToggle = (): void => {
32
+ setTooltipOpened(false);
33
+ onChange(!isFullScreen);
34
+ };
35
+
36
+ return (
37
+ <Tooltip label={label} opened={tooltipOpened} withinPortal>
38
+ <ActionIcon
39
+ aria-label={label}
40
+ color="gray"
41
+ onClick={handleToggle}
42
+ onMouseEnter={(): void => setTooltipOpened(true)}
43
+ onMouseLeave={(): void => setTooltipOpened(false)}
44
+ size="var(--ad-table-toolbar-action-icon-size)"
45
+ variant="outline"
46
+ data-testid="toggle-fullscreen"
47
+ {...rest}
48
+ >
49
+ {isFullScreen ? (
50
+ <IconWrapper IconComponent={FullscreenExitIcon} />
51
+ ) : (
52
+ <IconWrapper IconComponent={FullscreenIcon} />
53
+ )}
54
+ </ActionIcon>
55
+ </Tooltip>
56
+ );
57
+ };
58
+
59
+ export default ToggleFullScreenButton;
@@ -0,0 +1,15 @@
1
+ .alert {
2
+ background-color: var(--ad-table-toolbar-selection-banner-bg);
3
+ color: var(--ad-table-toolbar-selection-banner-fg);
4
+ border: 0;
5
+ }
6
+
7
+ .alert :global(.mantine-Alert-icon) {
8
+ display: none;
9
+ }
10
+
11
+ .alert :global(.mantine-Alert-body),
12
+ .alert :global(.mantine-Alert-message) {
13
+ width: 100%;
14
+ color: inherit;
15
+ }
@@ -0,0 +1,8 @@
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/ToolbarAlertBanner/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
4
+ import React from "react";
5
+ import { Alert, Collapse } from "@mantine/core";
6
+ import styles from "./ToolbarAlertBanner.module.css";
7
+ const ToolbarAlertBanner = ({ selectedCount, children }) => (_jsx(Collapse, { expanded: selectedCount > 0, transitionDuration: 200, children: _jsx(Alert, { className: styles.alert, variant: "light", color: "info", icon: null, radius: 0, p: "xs", children: children }) }));
8
+ export default ToolbarAlertBanner;
@@ -0,0 +1,20 @@
1
+ 'use client'; // DS-ADAPT: Next.js App Router
2
+ // Source of truth: micro-ui-ts/src/components/Table/ToolbarAlertBanner/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
3
+ import React, { type ReactElement, type ReactNode } from "react";
4
+ import { Alert, Collapse } from "@mantine/core";
5
+ import styles from "./ToolbarAlertBanner.module.css";
6
+
7
+ interface ToolbarAlertBannerProps {
8
+ selectedCount: number;
9
+ children: ReactNode;
10
+ }
11
+
12
+ const ToolbarAlertBanner = ({ selectedCount, children }: ToolbarAlertBannerProps): ReactElement => (
13
+ <Collapse expanded={selectedCount > 0} transitionDuration={200}>
14
+ <Alert className={styles.alert} variant="light" color="info" icon={null} radius={0} p="xs">
15
+ {children}
16
+ </Alert>
17
+ </Collapse>
18
+ );
19
+
20
+ export default ToolbarAlertBanner;
@@ -0,0 +1,27 @@
1
+ // Source of truth: micro-ui-ts/src/hooks/useClickOutside.ts. Keep in sync; DS-only changes are marked DS-ADAPT.
2
+ import { useEffect, useRef } from "react";
3
+ const useClickOutside = (handleFn, safeElementIds) => {
4
+ const elementRef = useRef(null);
5
+ const isChildOfSafeElement = (id, target) => {
6
+ const safeElement = document.getElementById(id);
7
+ return (safeElement && safeElement.contains(target)) ?? false;
8
+ };
9
+ useEffect(() => {
10
+ const handleClickOutside = (event) => {
11
+ if (!elementRef?.current || elementRef?.current.contains(event.target)) {
12
+ return;
13
+ }
14
+ const hasSafeElementBeenClicked = safeElementIds?.some(safeElementId => event.target?.id === safeElementId ||
15
+ isChildOfSafeElement(safeElementId, event.target));
16
+ if (!hasSafeElementBeenClicked) {
17
+ handleFn(event);
18
+ }
19
+ };
20
+ document.addEventListener("mousedown", handleClickOutside);
21
+ return () => {
22
+ document.removeEventListener("mousedown", handleClickOutside);
23
+ };
24
+ }, [handleFn, safeElementIds]);
25
+ return elementRef;
26
+ };
27
+ export default useClickOutside;
@@ -0,0 +1,39 @@
1
+ // Source of truth: micro-ui-ts/src/hooks/useClickOutside.ts. Keep in sync; DS-only changes are marked DS-ADAPT.
2
+ import { useEffect, useRef, MutableRefObject } from "react";
3
+
4
+ const useClickOutside = (
5
+ handleFn: (e: MouseEvent) => void,
6
+ safeElementIds?: string[]
7
+ ): MutableRefObject<HTMLElement | null> => {
8
+ const elementRef = useRef<HTMLElement>(null);
9
+
10
+ const isChildOfSafeElement = (id: string, target: EventTarget | null): boolean => {
11
+ const safeElement = document.getElementById(id);
12
+ return (safeElement && safeElement.contains(target as Element)) ?? false;
13
+ };
14
+
15
+ useEffect(() => {
16
+ const handleClickOutside = (event: MouseEvent): void => {
17
+ if (!elementRef?.current || elementRef?.current.contains(event.target as Node)) {
18
+ return;
19
+ }
20
+ const hasSafeElementBeenClicked = safeElementIds?.some(
21
+ safeElementId =>
22
+ (event.target as Element)?.id === safeElementId ||
23
+ isChildOfSafeElement(safeElementId, event.target)
24
+ );
25
+ if (!hasSafeElementBeenClicked) {
26
+ handleFn(event);
27
+ }
28
+ };
29
+
30
+ document.addEventListener("mousedown", handleClickOutside);
31
+ return (): void => {
32
+ document.removeEventListener("mousedown", handleClickOutside);
33
+ };
34
+ }, [handleFn, safeElementIds]);
35
+
36
+ return elementRef;
37
+ };
38
+
39
+ export default useClickOutside;
@@ -1 +1,5 @@
1
- export { DataTable } from './DataTable.js';
1
+ export { DataTable, createDataTableColumnHelper } from './DataTable.js';
2
+ export { City } from './CustomTopToolbar/index.js';
3
+ export { dataTableFeatures } from './tableFeatures.js';
4
+ export { default as SortableHeaderCell, SortDirection } from './SortableHeaderCell/index.js';
5
+ export { default as CellHoverReveal } from './CellHoverReveal/index.js';
@@ -1,2 +1,13 @@
1
- export { DataTable } from './DataTable';
2
- export type { DataTableProps, DataTableColumn, PageInfo, Filters, DateRange, City } from './DataTable';
1
+ export { DataTable, createDataTableColumnHelper } from './DataTable';
2
+ export type {
3
+ DataTableProps,
4
+ DataTableColumnDef,
5
+ DataTableSelectionAction,
6
+ PageInfo,
7
+ } from './DataTable';
8
+ export type { Filters, DateRange } from './CustomTopToolbar';
9
+ export { City } from './CustomTopToolbar';
10
+ export { dataTableFeatures } from './tableFeatures';
11
+ export type { DensityState, PaginationState, RowSelectionState } from './types';
12
+ export { default as SortableHeaderCell, SortDirection } from './SortableHeaderCell';
13
+ export { default as CellHoverReveal } from './CellHoverReveal';
@@ -0,0 +1,9 @@
1
+ .table-row {
2
+ &[data-selected="true"] {
3
+ background-color: var(--ad-table-row-selected-bg);
4
+ }
5
+
6
+ &[data-selected="true"] td {
7
+ background-color: var(--ad-table-row-selected-bg);
8
+ }
9
+ }
@@ -0,0 +1,6 @@
1
+ // Source of truth: micro-ui-ts/src/components/Table/tableFeatures.ts. Keep in sync; DS-only changes are marked DS-ADAPT.
2
+ import { columnSizingFeature, rowSelectionFeature, tableFeatures } from "@tanstack/react-table";
3
+ export const dataTableFeatures = tableFeatures({
4
+ rowSelectionFeature,
5
+ columnSizingFeature,
6
+ });
@@ -0,0 +1,7 @@
1
+ // Source of truth: micro-ui-ts/src/components/Table/tableFeatures.ts. Keep in sync; DS-only changes are marked DS-ADAPT.
2
+ import { columnSizingFeature, rowSelectionFeature, tableFeatures } from "@tanstack/react-table";
3
+
4
+ export const dataTableFeatures = tableFeatures({
5
+ rowSelectionFeature,
6
+ columnSizingFeature,
7
+ });
@@ -11,13 +11,13 @@ const translations = {
11
11
  "table.filters.result.count.filtered.one": "1 record",
12
12
  "table.filters.result.count.filtered.none": "0 records",
13
13
  // Filter translations
14
- "table.filters.toggle.aria": "Toggle filters panel",
14
+ "table.filters.toggle.aria": "Toggle filters",
15
15
  "table.filters.clear.filters": "Clear filters",
16
16
  "table.filters.chip.date.range.label": "{startDate} - {endDate}",
17
17
  "table.filters.date.range.week": "This week",
18
18
  "table.filters.date.range.month": "This month",
19
19
  "table.filters.date.range.quarter": "This quarter",
20
- "table.filters.date.range.custom": "Custom",
20
+ "table.filters.date.range.custom": "Custom range",
21
21
  "table.filters.date.range.select": "Select a date",
22
22
  "table.filters.applied.on": "Applied On",
23
23
  "table.filters.city": "City",
@@ -44,7 +44,7 @@ const translations = {
44
44
  "table.filters.show.all": "Show all",
45
45
  "table.filters.placeholder.all": "All",
46
46
  "table.filters.placeholder.select.more": "Select more",
47
- "table.search.placeholder": "Search...",
47
+ "table.search.placeholder": "Search",
48
48
  // FilterSystem translations
49
49
  "table.filters.system.validation.max.exceeded": "Maximum {maxFilters} filters allowed, but {filterCount} provided",
50
50
  "table.filters.system.validation.duplicate.ids": "Duplicate filter IDs found: {duplicateIds}",
@@ -86,7 +86,7 @@ const translations = {
86
86
  "table.pagination.showing": "Showing {start}-{end} of {total}",
87
87
  "table.pagination.page": "Page {current} of {total}",
88
88
  "table.rows.per.page": "Rows per page",
89
- "table.row.count": "Showing {start}-{end} of {total}",
89
+ "table.row.count": "{start}-{end} of {total}",
90
90
  // Error translations
91
91
  "table.error.title": "Unable to load table",
92
92
  "table.error.default": "Something went wrong while loading data.",
@@ -95,5 +95,17 @@ const translations = {
95
95
  "table.selected.rows": "{count} rows selected",
96
96
  "table.selected.row": "1 row selected",
97
97
  "table.clear.selection": "Clear selection",
98
+ // Aligned with micro-ui-ts (source of truth for the table). Production strings win over older DS copies above.
99
+ "table.next.page.aria": "Next page",
100
+ "table.previous.page.aria": "Previous page",
101
+ "table.toggle.density": "Toggle density",
102
+ "table.toggle.fullscreen": "Toggle fullscreen",
103
+ "table.overlay.empty.state.title": "No results found",
104
+ "table.overlay.empty.state.description": "Try adjusting your search or filters.",
105
+ "table.overlay.empty.state.button": "Clear filters",
106
+ "table.overlay.error.state.title": "Unable to load data",
107
+ "table.overlay.error.state.description": "Something went wrong while loading the data.",
108
+ "table.overlay.error.state.button": "Try again",
109
+ "table.row.selected.count": "{count, plural, one {# row selected} other {# rows selected}}",
98
110
  };
99
111
  export { translations };
@@ -14,13 +14,13 @@ const translations = {
14
14
  "table.filters.result.count.filtered.none": "0 records",
15
15
 
16
16
  // Filter translations
17
- "table.filters.toggle.aria": "Toggle filters panel",
17
+ "table.filters.toggle.aria": "Toggle filters",
18
18
  "table.filters.clear.filters": "Clear filters",
19
19
  "table.filters.chip.date.range.label": "{startDate} - {endDate}",
20
20
  "table.filters.date.range.week": "This week",
21
21
  "table.filters.date.range.month": "This month",
22
22
  "table.filters.date.range.quarter": "This quarter",
23
- "table.filters.date.range.custom": "Custom",
23
+ "table.filters.date.range.custom": "Custom range",
24
24
  "table.filters.date.range.select": "Select a date",
25
25
  "table.filters.applied.on": "Applied On",
26
26
  "table.filters.city": "City",
@@ -47,7 +47,7 @@ const translations = {
47
47
  "table.filters.show.all": "Show all",
48
48
  "table.filters.placeholder.all": "All",
49
49
  "table.filters.placeholder.select.more": "Select more",
50
- "table.search.placeholder": "Search...",
50
+ "table.search.placeholder": "Search",
51
51
 
52
52
  // FilterSystem translations
53
53
  "table.filters.system.validation.max.exceeded": "Maximum {maxFilters} filters allowed, but {filterCount} provided",
@@ -97,7 +97,7 @@ const translations = {
97
97
  "table.pagination.showing": "Showing {start}-{end} of {total}",
98
98
  "table.pagination.page": "Page {current} of {total}",
99
99
  "table.rows.per.page": "Rows per page",
100
- "table.row.count": "Showing {start}-{end} of {total}",
100
+ "table.row.count": "{start}-{end} of {total}",
101
101
 
102
102
  // Error translations
103
103
  "table.error.title": "Unable to load table",
@@ -108,6 +108,18 @@ const translations = {
108
108
  "table.selected.rows": "{count} rows selected",
109
109
  "table.selected.row": "1 row selected",
110
110
  "table.clear.selection": "Clear selection",
111
+ // Aligned with micro-ui-ts (source of truth for the table). Production strings win over older DS copies above.
112
+ "table.next.page.aria": "Next page",
113
+ "table.previous.page.aria": "Previous page",
114
+ "table.toggle.density": "Toggle density",
115
+ "table.toggle.fullscreen": "Toggle fullscreen",
116
+ "table.overlay.empty.state.title": "No results found",
117
+ "table.overlay.empty.state.description": "Try adjusting your search or filters.",
118
+ "table.overlay.empty.state.button": "Clear filters",
119
+ "table.overlay.error.state.title": "Unable to load data",
120
+ "table.overlay.error.state.description": "Something went wrong while loading the data.",
121
+ "table.overlay.error.state.button": "Try again",
122
+ "table.row.selected.count": "{count, plural, one {# row selected} other {# rows selected}}",
111
123
  } as const;
112
124
 
113
125
  export type TranslationKey = keyof typeof translations;
@@ -9,6 +9,11 @@ export const translate = (key, params) => {
9
9
  return translation;
10
10
  }
11
11
  let result = translation;
12
+ // Minimal ICU plural support: "{count, plural, one {# row} other {# rows}}" (matches micro-ui-ts strings).
13
+ result = result.replace(/\{(\w+), plural, one \{([^}]*)\} other \{([^}]*)\}\}/g, (_match, name, one, other) => {
14
+ const n = Number(params[name]);
15
+ return (n === 1 ? one : other).replace(/#/g, String(n));
16
+ });
12
17
  for (const [paramKey, value] of Object.entries(params)) {
13
18
  result = result.replace(`{${paramKey}}`, String(value));
14
19
  }
@@ -1,6 +1,6 @@
1
1
  import { translations, TranslationKey } from './en';
2
2
 
3
- export const translate = (key: TranslationKey, params?: Record<string, string | number>): string => {
3
+ export const translate = (key: TranslationKey, params?: Record<string, string | number | undefined>): string => {
4
4
  const translation = translations[key];
5
5
 
6
6
  if (!translation) {
@@ -13,6 +13,16 @@ export const translate = (key: TranslationKey, params?: Record<string, string |
13
13
  }
14
14
 
15
15
  let result: string = translation;
16
+
17
+ // Minimal ICU plural support: "{count, plural, one {# row} other {# rows}}" (matches micro-ui-ts strings).
18
+ result = result.replace(
19
+ /\{(\w+), plural, one \{([^}]*)\} other \{([^}]*)\}\}/g,
20
+ (_match, name: string, one: string, other: string) => {
21
+ const n = Number(params[name]);
22
+ return (n === 1 ? one : other).replace(/#/g, String(n));
23
+ }
24
+ );
25
+
16
26
  for (const [paramKey, value] of Object.entries(params)) {
17
27
  result = result.replace(`{${paramKey}}`, String(value));
18
28
  }
@@ -0,0 +1,5 @@
1
+ export const DENSITY_CYCLE = {
2
+ md: "xs",
3
+ xl: "md",
4
+ xs: "xl",
5
+ };
@@ -0,0 +1,17 @@
1
+ // Source of truth: micro-ui-ts/src/components/Table/types.ts. Keep in sync; DS-only changes are marked DS-ADAPT.
2
+ export type DensityState = "xs" | "sm" | "md" | "lg" | "xl";
3
+
4
+ export type TogglableDensityState = Exclude<DensityState, "lg" | "sm">;
5
+
6
+ export const DENSITY_CYCLE: Record<TogglableDensityState, TogglableDensityState> = {
7
+ md: "xs",
8
+ xl: "md",
9
+ xs: "xl",
10
+ };
11
+
12
+ export interface PaginationState {
13
+ pageIndex: number;
14
+ pageSize: number;
15
+ }
16
+
17
+ export type RowSelectionState = Record<string, true>;
@@ -0,0 +1,3 @@
1
+ // Source of truth: micro-ui-ts/src/components/Table/utils/parseCSSVarId.ts. Keep in sync; DS-only changes are marked DS-ADAPT.
2
+ const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9_-]/g, "_");
3
+ export default parseCSSVarId;
@@ -0,0 +1,4 @@
1
+ // Source of truth: micro-ui-ts/src/components/Table/utils/parseCSSVarId.ts. Keep in sync; DS-only changes are marked DS-ADAPT.
2
+ const parseCSSVarId = (id: string): string => id.replace(/[^a-zA-Z0-9_-]/g, "_");
3
+
4
+ export default parseCSSVarId;