@wallarm-org/design-system 1.20.4 → 1.22.0
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.
- package/dist/components/AppShell/story-content/_storySearchModal.js +3 -3
- package/dist/components/CodeSnippet/CodeSnippetCopyButton.d.ts +1 -1
- package/dist/components/CodeSnippet/CodeSnippetCopyButton.js +14 -7
- package/dist/components/CodeSnippet/InlineCodeSnippet.js +7 -25
- package/dist/components/Copyable/Copyable.d.ts +39 -0
- package/dist/components/Copyable/Copyable.js +85 -0
- package/dist/components/Copyable/CopyableContext.d.ts +11 -0
- package/dist/components/Copyable/CopyableContext.js +9 -0
- package/dist/components/Copyable/CopyableIcon.d.ts +9 -0
- package/dist/components/Copyable/CopyableIcon.js +13 -0
- package/dist/components/Copyable/CopyableLabel.d.ts +18 -0
- package/dist/components/Copyable/CopyableLabel.js +24 -0
- package/dist/components/Copyable/index.d.ts +4 -0
- package/dist/components/Copyable/index.js +4 -0
- package/dist/components/SearchInput/SearchInput.d.ts +18 -0
- package/dist/components/SearchInput/SearchInput.js +54 -0
- package/dist/components/SearchInput/index.d.ts +1 -0
- package/dist/components/SearchInput/index.js +1 -0
- package/dist/components/SearchModal/SearchModalInput.js +16 -3
- package/dist/components/SegmentedControl/classes.js +1 -1
- package/dist/components/Select/Select.d.ts +3 -1
- package/dist/components/Select/Select.js +6 -3
- package/dist/components/Select/SelectSearchInput.js +6 -19
- package/dist/components/SettingsHeader/SettingsHeader.d.ts +7 -0
- package/dist/components/SettingsHeader/SettingsHeader.js +16 -0
- package/dist/components/SettingsHeader/SettingsHeaderActions.d.ts +6 -0
- package/dist/components/SettingsHeader/SettingsHeaderActions.js +16 -0
- package/dist/components/SettingsHeader/SettingsHeaderBreadcrumbs.d.ts +6 -0
- package/dist/components/SettingsHeader/SettingsHeaderBreadcrumbs.js +16 -0
- package/dist/components/SettingsHeader/SettingsHeaderDescription.d.ts +5 -0
- package/dist/components/SettingsHeader/SettingsHeaderDescription.js +16 -0
- package/dist/components/SettingsHeader/SettingsHeaderFilters.d.ts +6 -0
- package/dist/components/SettingsHeader/SettingsHeaderFilters.js +16 -0
- package/dist/components/SettingsHeader/SettingsHeaderHeading.d.ts +6 -0
- package/dist/components/SettingsHeader/SettingsHeaderHeading.js +16 -0
- package/dist/components/SettingsHeader/SettingsHeaderTitle.d.ts +5 -0
- package/dist/components/SettingsHeader/SettingsHeaderTitle.js +16 -0
- package/dist/components/SettingsHeader/index.d.ts +7 -0
- package/dist/components/SettingsHeader/index.js +7 -0
- package/dist/components/Table/EditableCell/EditableSelectCell.d.ts +1 -1
- package/dist/components/Table/EditableCell/EditableSelectCell.js +12 -1
- package/dist/components/Table/StickyGroupParent.js +7 -8
- package/dist/components/Table/TableBody/TableBodyCell.d.ts +3 -1
- package/dist/components/Table/TableBody/TableBodyCell.js +6 -2
- package/dist/components/Table/TableBody/TableBodyRowDndContext.d.ts +5 -0
- package/dist/components/Table/TableBody/TableBodyRowDndContext.js +65 -21
- package/dist/components/Table/TableBody/TableRowOverlay.js +2 -1
- package/dist/components/Table/TableColGroup.js +20 -17
- package/dist/components/Table/TableContext/TableProvider.js +3 -1
- package/dist/components/Table/TableContext/types.d.ts +1 -0
- package/dist/components/Table/TableHead.js +13 -8
- package/dist/components/Table/TableLoadingState.js +19 -13
- package/dist/components/Table/TableMasterCellActions.js +2 -5
- package/dist/components/Table/TableRow.js +42 -12
- package/dist/components/Table/TableRowExpanded.js +3 -2
- package/dist/components/Table/classes.d.ts +5 -0
- package/dist/components/Table/classes.js +2 -1
- package/dist/components/Table/hooks/useStickyGroupParent.js +3 -1
- package/dist/components/Table/lib/constants.d.ts +1 -1
- package/dist/components/Table/lib/constants.js +1 -1
- package/dist/components/Table/lib/createDragHandleColumn.js +3 -3
- package/dist/components/Table/lib/useRowDnd.js +3 -13
- package/dist/components/Table/types.d.ts +8 -0
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.js +0 -1
- package/dist/hooks/useCopyToClipboard.d.ts +9 -10
- package/dist/hooks/useCopyToClipboard.js +6 -18
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/metadata/components.json +12502 -9142
- package/package.json +1 -1
- package/dist/components/CopyButton/CopyButton.d.ts +0 -16
- package/dist/components/CopyButton/CopyButton.js +0 -63
- package/dist/components/CopyButton/index.d.ts +0 -1
- package/dist/components/CopyButton/index.js +0 -1
- package/dist/hooks/useCopyTooltip.d.ts +0 -12
- package/dist/hooks/useCopyTooltip.js +0 -63
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { useTestId } from "../../utils/testId.js";
|
|
4
|
+
const SettingsHeaderDescription = ({ ref, children, className, ...props })=>{
|
|
5
|
+
const testId = useTestId("description");
|
|
6
|
+
return /*#__PURE__*/ jsx("p", {
|
|
7
|
+
...props,
|
|
8
|
+
ref: ref,
|
|
9
|
+
"data-testid": testId,
|
|
10
|
+
"data-slot": "settings-header-description",
|
|
11
|
+
className: cn('text-sm text-text-secondary', className),
|
|
12
|
+
children: children
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
SettingsHeaderDescription.displayName = "SettingsHeaderDescription";
|
|
16
|
+
export { SettingsHeaderDescription };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
export interface SettingsHeaderFiltersProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
ref?: Ref<HTMLDivElement>;
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare const SettingsHeaderFilters: FC<SettingsHeaderFiltersProps>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { useTestId } from "../../utils/testId.js";
|
|
4
|
+
const SettingsHeaderFilters = ({ ref, children, className, ...props })=>{
|
|
5
|
+
const testId = useTestId('filters');
|
|
6
|
+
return /*#__PURE__*/ jsx("div", {
|
|
7
|
+
...props,
|
|
8
|
+
ref: ref,
|
|
9
|
+
"data-testid": testId,
|
|
10
|
+
"data-slot": "settings-header-filters",
|
|
11
|
+
className: cn('flex gap-12 items-center', className),
|
|
12
|
+
children: children
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
SettingsHeaderFilters.displayName = 'SettingsHeaderFilters';
|
|
16
|
+
export { SettingsHeaderFilters };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
export interface SettingsHeaderHeadingProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
ref?: Ref<HTMLDivElement>;
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare const SettingsHeaderHeading: FC<SettingsHeaderHeadingProps>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { useTestId } from "../../utils/testId.js";
|
|
4
|
+
const SettingsHeaderHeading = ({ ref, children, className, ...props })=>{
|
|
5
|
+
const testId = useTestId('heading');
|
|
6
|
+
return /*#__PURE__*/ jsx("div", {
|
|
7
|
+
...props,
|
|
8
|
+
ref: ref,
|
|
9
|
+
"data-testid": testId,
|
|
10
|
+
"data-slot": "settings-header-heading",
|
|
11
|
+
className: cn('flex items-start justify-between gap-16 w-full', className),
|
|
12
|
+
children: children
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
SettingsHeaderHeading.displayName = 'SettingsHeaderHeading';
|
|
16
|
+
export { SettingsHeaderHeading };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { useTestId } from "../../utils/testId.js";
|
|
4
|
+
const SettingsHeaderTitle = ({ ref, children, className, ...props })=>{
|
|
5
|
+
const testId = useTestId('title');
|
|
6
|
+
return /*#__PURE__*/ jsx("h1", {
|
|
7
|
+
...props,
|
|
8
|
+
ref: ref,
|
|
9
|
+
"data-testid": testId,
|
|
10
|
+
"data-slot": "settings-header-title",
|
|
11
|
+
className: cn('font-sans-display text-xl font-medium leading-28 text-text-primary truncate', className),
|
|
12
|
+
children: children
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
SettingsHeaderTitle.displayName = 'SettingsHeaderTitle';
|
|
16
|
+
export { SettingsHeaderTitle };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { SettingsHeader, type SettingsHeaderProps } from './SettingsHeader';
|
|
2
|
+
export { SettingsHeaderActions, type SettingsHeaderActionsProps, } from './SettingsHeaderActions';
|
|
3
|
+
export { SettingsHeaderBreadcrumbs, type SettingsHeaderBreadcrumbsProps, } from './SettingsHeaderBreadcrumbs';
|
|
4
|
+
export { SettingsHeaderDescription, type SettingsHeaderDescriptionProps, } from './SettingsHeaderDescription';
|
|
5
|
+
export { SettingsHeaderFilters, type SettingsHeaderFiltersProps, } from './SettingsHeaderFilters';
|
|
6
|
+
export { SettingsHeaderHeading, type SettingsHeaderHeadingProps, } from './SettingsHeaderHeading';
|
|
7
|
+
export { SettingsHeaderTitle, type SettingsHeaderTitleProps, } from './SettingsHeaderTitle';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { SettingsHeader } from "./SettingsHeader.js";
|
|
2
|
+
export { SettingsHeaderActions } from "./SettingsHeaderActions.js";
|
|
3
|
+
export { SettingsHeaderBreadcrumbs } from "./SettingsHeaderBreadcrumbs.js";
|
|
4
|
+
export { SettingsHeaderDescription } from "./SettingsHeaderDescription.js";
|
|
5
|
+
export { SettingsHeaderFilters } from "./SettingsHeaderFilters.js";
|
|
6
|
+
export { SettingsHeaderHeading } from "./SettingsHeaderHeading.js";
|
|
7
|
+
export { SettingsHeaderTitle } from "./SettingsHeaderTitle.js";
|
|
@@ -11,7 +11,7 @@ export interface EditableSelectCellProps extends NativeProps, TestableProps {
|
|
|
11
11
|
items: SelectDataItem[];
|
|
12
12
|
/** Read-mode rendering of the selected value (e.g. a `Badge`). */
|
|
13
13
|
children?: ReactNode;
|
|
14
|
-
/** Shown when nothing is selected. Defaults to `'Select
|
|
14
|
+
/** Shown when nothing is selected. Defaults to `'Select'`. */
|
|
15
15
|
placeholder?: ReactNode;
|
|
16
16
|
ref?: Ref<HTMLDivElement>;
|
|
17
17
|
}
|
|
@@ -6,7 +6,7 @@ import { cn } from "../../../utils/cn.js";
|
|
|
6
6
|
import { useTestId } from "../../../utils/testId.js";
|
|
7
7
|
import { Select as index_js_Select, SelectContent, SelectOption, SelectOptionIndicator, SelectOptionText, SelectPositioner, createListCollection } from "../../Select/index.js";
|
|
8
8
|
import { editableCellIcon, editableCellPlaceholder, editableCellValue, editableCellVariants } from "./classes.js";
|
|
9
|
-
const EditableSelectCell = ({ value, onCommit, items, children, placeholder = 'Select
|
|
9
|
+
const EditableSelectCell = ({ value, onCommit, items, children, placeholder = 'Select', className, ref, 'data-testid': testIdProp, ...rest })=>{
|
|
10
10
|
const testId = useTestId(void 0, testIdProp);
|
|
11
11
|
const collection = useMemo(()=>createListCollection({
|
|
12
12
|
items
|
|
@@ -21,6 +21,13 @@ const EditableSelectCell = ({ value, onCommit, items, children, placeholder = 'S
|
|
|
21
21
|
value
|
|
22
22
|
] : [],
|
|
23
23
|
"data-testid": testId,
|
|
24
|
+
positioning: {
|
|
25
|
+
placement: 'bottom-start',
|
|
26
|
+
sameWidth: true,
|
|
27
|
+
offset: {
|
|
28
|
+
crossAxis: -8
|
|
29
|
+
}
|
|
30
|
+
},
|
|
24
31
|
onValueChange: (details)=>{
|
|
25
32
|
const next = details.value[0];
|
|
26
33
|
if (next && next !== value) onCommit(next);
|
|
@@ -53,6 +60,10 @@ const EditableSelectCell = ({ value, onCommit, items, children, placeholder = 'S
|
|
|
53
60
|
})
|
|
54
61
|
}),
|
|
55
62
|
/*#__PURE__*/ jsx(SelectPositioner, {
|
|
63
|
+
className: "min-w-full max-w-full",
|
|
64
|
+
style: {
|
|
65
|
+
width: 'calc(var(--reference-width) + 16px)'
|
|
66
|
+
},
|
|
56
67
|
children: /*#__PURE__*/ jsx(SelectContent, {
|
|
57
68
|
children: items.map((item)=>/*#__PURE__*/ jsxs(SelectOption, {
|
|
58
69
|
item: item,
|
|
@@ -59,19 +59,18 @@ const StickyGroupParent = ({ tableWidth, headerHeight })=>{
|
|
|
59
59
|
useWindowScroll,
|
|
60
60
|
headerHeight
|
|
61
61
|
]);
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const isSelected = stickyRow.getIsAllSubRowsSelected();
|
|
62
|
+
const cells = stickyRow?.getVisibleCells();
|
|
63
|
+
const systemCells = cells?.filter((c)=>SYSTEM_COLUMN_IDS.has(c.column.id));
|
|
64
|
+
const dataCells = cells?.filter((c)=>!SYSTEM_COLUMN_IDS.has(c.column.id));
|
|
65
|
+
const firstDataCell = dataCells?.[0];
|
|
66
|
+
const isSelected = stickyRow?.getIsAllSubRowsSelected();
|
|
68
67
|
return /*#__PURE__*/ jsx("div", {
|
|
69
|
-
className: "sticky z-
|
|
68
|
+
className: "sticky z-[21] h-0 overflow-visible pointer-events-none",
|
|
70
69
|
style: {
|
|
71
70
|
top: headerHeight
|
|
72
71
|
},
|
|
73
72
|
"aria-hidden": "true",
|
|
74
|
-
children: /*#__PURE__*/ jsx("div", {
|
|
73
|
+
children: stickyRow && /*#__PURE__*/ jsx("div", {
|
|
75
74
|
className: "overflow-hidden",
|
|
76
75
|
style: {
|
|
77
76
|
height: rowRef.current?.offsetHeight ?? 40
|
|
@@ -10,8 +10,10 @@ interface TableBodyCellProps<T extends RowData> {
|
|
|
10
10
|
lastRow?: boolean;
|
|
11
11
|
dragListeners?: ReturnType<typeof useSortable>['listeners'];
|
|
12
12
|
dragAttributes?: ReturnType<typeof useSortable>['attributes'];
|
|
13
|
+
/** Orange line indicator for row drag-and-drop placement */
|
|
14
|
+
dropIndicator?: 'above' | 'below';
|
|
13
15
|
}
|
|
14
|
-
export declare function TableBodyCell<T extends RowData>({ cell, colSpan, className, disablePinnedShadow, lastRow, dragListeners, dragAttributes, }: TableBodyCellProps<T>): import("react").JSX.Element;
|
|
16
|
+
export declare function TableBodyCell<T extends RowData>({ cell, colSpan, className, disablePinnedShadow, lastRow, dragListeners, dragAttributes, dropIndicator, }: TableBodyCellProps<T>): import("react").JSX.Element;
|
|
15
17
|
export declare namespace TableBodyCell {
|
|
16
18
|
var displayName: string;
|
|
17
19
|
}
|
|
@@ -3,12 +3,13 @@ import { flexRender } from "@tanstack/react-table";
|
|
|
3
3
|
import { cn } from "../../../utils/cn.js";
|
|
4
4
|
import { useTestId } from "../../../utils/testId.js";
|
|
5
5
|
import { Tooltip, TooltipContent, TooltipTrigger } from "../../Tooltip/index.js";
|
|
6
|
+
import { DROP_INDICATOR_BASE } from "../classes.js";
|
|
6
7
|
import { useMasterCell } from "../hooks/index.js";
|
|
7
8
|
import { TABLE_EXPAND_COLUMN_ID, getAlignClass, getExpandBorderClass, getPinningStyles, isLastPinnedLeft, useColumnDnd } from "../lib/index.js";
|
|
8
9
|
import { Td } from "../primitives/index.js";
|
|
9
10
|
import { useTableContext } from "../TableContext/index.js";
|
|
10
11
|
import { TableMasterCellActions } from "../TableMasterCellActions.js";
|
|
11
|
-
const TableBodyCell = ({ cell, colSpan, className, disablePinnedShadow, lastRow, dragListeners, dragAttributes })=>{
|
|
12
|
+
const TableBodyCell = ({ cell, colSpan, className, disablePinnedShadow, lastRow, dragListeners, dragAttributes, dropIndicator })=>{
|
|
12
13
|
const { allLeafColumns, masterColumnId } = useTableContext();
|
|
13
14
|
const testId = useTestId('body-cell');
|
|
14
15
|
const column = cell.column;
|
|
@@ -61,7 +62,7 @@ const TableBodyCell = ({ cell, colSpan, className, disablePinnedShadow, lastRow,
|
|
|
61
62
|
};
|
|
62
63
|
return /*#__PURE__*/ jsx(Td, {
|
|
63
64
|
"data-testid": testId,
|
|
64
|
-
className: cn(getAlignClass(meta), getExpandBorderClass(isExpandColumn, cell.row.depth, lastRow), isCut && 'pr-0', (isMasterTrigger || tooltipText) && 'cursor-pointer', dragListeners && 'cursor-grab active:cursor-grabbing', meta?.cellClassName, className),
|
|
65
|
+
className: cn(getAlignClass(meta), getExpandBorderClass(isExpandColumn, cell.row.depth, lastRow), isCut && 'pr-0', (isMasterTrigger || tooltipText) && 'cursor-pointer', dragListeners && 'cursor-grab active:cursor-grabbing', dropIndicator && DROP_INDICATOR_BASE, 'above' === dropIndicator && 'after:top-0', 'below' === dropIndicator && 'after:-bottom-px', meta?.cellClassName, className),
|
|
65
66
|
pinned: 'start' === isPinned,
|
|
66
67
|
lastPinnedLeft: disablePinnedShadow ? false : lastLeft,
|
|
67
68
|
expanded: isExpandedToggle,
|
|
@@ -74,6 +75,9 @@ const TableBodyCell = ({ cell, colSpan, className, disablePinnedShadow, lastRow,
|
|
|
74
75
|
...dndStyle,
|
|
75
76
|
...isCut && {
|
|
76
77
|
overflow: 'hidden'
|
|
78
|
+
},
|
|
79
|
+
...dropIndicator && {
|
|
80
|
+
overflow: 'visible'
|
|
77
81
|
}
|
|
78
82
|
},
|
|
79
83
|
colSpan: colSpan,
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { type FC, type ReactNode } from 'react';
|
|
2
|
+
interface RowDndIndicatorState {
|
|
3
|
+
activeId: string | null;
|
|
4
|
+
overId: string | null;
|
|
5
|
+
}
|
|
6
|
+
export declare const useRowDndIndicator: () => RowDndIndicatorState;
|
|
2
7
|
interface TableBodyRowDndContextProps {
|
|
3
8
|
children: ReactNode;
|
|
4
9
|
}
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useMemo, useState } from "react";
|
|
2
|
+
import { createContext, useCallback, useContext, useMemo, useState } from "react";
|
|
3
3
|
import { DndContext, DragOverlay, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
|
|
4
4
|
import { SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
5
5
|
import { useTableContext } from "../TableContext/index.js";
|
|
6
6
|
import { TableRowOverlay } from "./TableRowOverlay.js";
|
|
7
|
+
const ROW_DND_INDICATOR_DEFAULT = {
|
|
8
|
+
activeId: null,
|
|
9
|
+
overId: null
|
|
10
|
+
};
|
|
11
|
+
const RowDndIndicatorContext = /*#__PURE__*/ createContext(ROW_DND_INDICATOR_DEFAULT);
|
|
12
|
+
const useRowDndIndicator = ()=>useContext(RowDndIndicatorContext);
|
|
13
|
+
const CURSOR_STYLE_ATTR = 'data-table-row-drag';
|
|
14
|
+
function setCursorGrabbing() {
|
|
15
|
+
const style = document.createElement('style');
|
|
16
|
+
style.setAttribute(CURSOR_STYLE_ATTR, '');
|
|
17
|
+
style.textContent = '* { cursor: grabbing !important; }';
|
|
18
|
+
document.head.appendChild(style);
|
|
19
|
+
}
|
|
20
|
+
function resetCursor() {
|
|
21
|
+
document.head.querySelector(`style[${CURSOR_STYLE_ATTR}]`)?.remove();
|
|
22
|
+
}
|
|
7
23
|
const TableBodyRowDndContext = ({ children })=>{
|
|
8
24
|
const { rowDndEnabled, onRowReorder } = useTableContext();
|
|
9
25
|
if (!rowDndEnabled) return children;
|
|
@@ -19,19 +35,37 @@ const TableBodyRowDndContextInner = ({ children, onRowReorder })=>{
|
|
|
19
35
|
rows
|
|
20
36
|
]);
|
|
21
37
|
const [activeRow, setActiveRow] = useState(null);
|
|
38
|
+
const [activeId, setActiveId] = useState(null);
|
|
39
|
+
const [overId, setOverId] = useState(null);
|
|
40
|
+
const indicatorState = useMemo(()=>({
|
|
41
|
+
activeId,
|
|
42
|
+
overId
|
|
43
|
+
}), [
|
|
44
|
+
activeId,
|
|
45
|
+
overId
|
|
46
|
+
]);
|
|
22
47
|
const sensors = useSensors(useSensor(PointerSensor, {
|
|
23
48
|
activationConstraint: {
|
|
24
49
|
distance: 5
|
|
25
50
|
}
|
|
26
51
|
}), useSensor(KeyboardSensor));
|
|
27
52
|
const handleDragStart = useCallback((event)=>{
|
|
28
|
-
const
|
|
53
|
+
const id = String(event.active.id);
|
|
54
|
+
const row = rows.find((r)=>r.id === id);
|
|
29
55
|
setActiveRow(row ?? null);
|
|
56
|
+
setActiveId(id);
|
|
57
|
+
setCursorGrabbing();
|
|
30
58
|
}, [
|
|
31
59
|
rows
|
|
32
60
|
]);
|
|
61
|
+
const handleDragOver = useCallback((event)=>{
|
|
62
|
+
setOverId(event.over ? String(event.over.id) : null);
|
|
63
|
+
}, []);
|
|
33
64
|
const handleDragEnd = useCallback((event)=>{
|
|
34
65
|
setActiveRow(null);
|
|
66
|
+
setActiveId(null);
|
|
67
|
+
setOverId(null);
|
|
68
|
+
resetCursor();
|
|
35
69
|
const { active, over } = event;
|
|
36
70
|
if (!over || active.id === over.id) return;
|
|
37
71
|
onRowReorder?.({
|
|
@@ -43,26 +77,36 @@ const TableBodyRowDndContextInner = ({ children, onRowReorder })=>{
|
|
|
43
77
|
]);
|
|
44
78
|
const handleDragCancel = useCallback(()=>{
|
|
45
79
|
setActiveRow(null);
|
|
80
|
+
setActiveId(null);
|
|
81
|
+
setOverId(null);
|
|
82
|
+
resetCursor();
|
|
46
83
|
}, []);
|
|
47
|
-
return /*#__PURE__*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
84
|
+
return /*#__PURE__*/ jsx(RowDndIndicatorContext.Provider, {
|
|
85
|
+
value: indicatorState,
|
|
86
|
+
children: /*#__PURE__*/ jsxs(DndContext, {
|
|
87
|
+
sensors: sensors,
|
|
88
|
+
collisionDetection: closestCenter,
|
|
89
|
+
onDragStart: handleDragStart,
|
|
90
|
+
onDragOver: handleDragOver,
|
|
91
|
+
onDragEnd: handleDragEnd,
|
|
92
|
+
onDragCancel: handleDragCancel,
|
|
93
|
+
children: [
|
|
94
|
+
/*#__PURE__*/ jsx(SortableContext, {
|
|
95
|
+
items: rowIds,
|
|
96
|
+
strategy: verticalListSortingStrategy,
|
|
97
|
+
children: children
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ jsx(DragOverlay, {
|
|
100
|
+
style: {
|
|
101
|
+
cursor: 'grabbing'
|
|
102
|
+
},
|
|
103
|
+
children: activeRow ? /*#__PURE__*/ jsx(TableRowOverlay, {
|
|
104
|
+
row: activeRow
|
|
105
|
+
}) : null
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
})
|
|
65
109
|
});
|
|
66
110
|
};
|
|
67
111
|
TableBodyRowDndContext.displayName = 'TableBodyRowDndContext';
|
|
68
|
-
export { TableBodyRowDndContext };
|
|
112
|
+
export { TableBodyRowDndContext, useRowDndIndicator };
|
|
@@ -10,7 +10,8 @@ const TableRowOverlayInner = ({ row })=>{
|
|
|
10
10
|
return /*#__PURE__*/ jsx("table", {
|
|
11
11
|
className: "w-full table-fixed border-collapse",
|
|
12
12
|
style: {
|
|
13
|
-
tableLayout: 'fixed'
|
|
13
|
+
tableLayout: 'fixed',
|
|
14
|
+
cursor: 'grabbing'
|
|
14
15
|
},
|
|
15
16
|
children: /*#__PURE__*/ jsx("tbody", {
|
|
16
17
|
children: /*#__PURE__*/ jsx(Tr, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { TABLE_DRAG_HANDLE_COLUMN_ID, TABLE_EXPAND_COLUMN_ID, TABLE_SELECT_COLUMN_ID } from "./lib/index.js";
|
|
3
3
|
import { useTableContext } from "./TableContext/index.js";
|
|
4
4
|
const SYSTEM_COLUMN_IDS = new Set([
|
|
@@ -7,27 +7,30 @@ const SYSTEM_COLUMN_IDS = new Set([
|
|
|
7
7
|
TABLE_DRAG_HANDLE_COLUMN_ID
|
|
8
8
|
]);
|
|
9
9
|
const TableColGroup = ({ tableWidth })=>{
|
|
10
|
-
const { table } = useTableContext();
|
|
10
|
+
const { table, stretch } = useTableContext();
|
|
11
11
|
const columns = table.getVisibleLeafColumns();
|
|
12
12
|
const isFixed = (col)=>SYSTEM_COLUMN_IDS.has(col.id) || !col.getCanResize() && col.columnDef.minSize === col.columnDef.maxSize || col.columnDef.meta?.resizeType === 'cut';
|
|
13
13
|
const fixedWidth = columns.filter(isFixed).reduce((sum, c)=>sum + c.getSize(), 0);
|
|
14
14
|
const totalFlexSize = columns.filter((c)=>!isFixed(c)).reduce((sum, c)=>sum + c.getSize(), 0);
|
|
15
15
|
const availableForFlex = tableWidth - fixedWidth;
|
|
16
|
-
return /*#__PURE__*/
|
|
17
|
-
children:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
return /*#__PURE__*/ jsxs("colgroup", {
|
|
17
|
+
children: [
|
|
18
|
+
columns.map((col)=>{
|
|
19
|
+
if (isFixed(col) || !stretch) return /*#__PURE__*/ jsx("col", {
|
|
20
|
+
style: {
|
|
21
|
+
width: col.getSize()
|
|
22
|
+
}
|
|
23
|
+
}, col.id);
|
|
24
|
+
if (0 === totalFlexSize) return /*#__PURE__*/ jsx("col", {}, col.id);
|
|
25
|
+
const pixelWidth = col.getSize() / totalFlexSize * availableForFlex;
|
|
26
|
+
return /*#__PURE__*/ jsx("col", {
|
|
27
|
+
style: {
|
|
28
|
+
width: pixelWidth
|
|
29
|
+
}
|
|
30
|
+
}, col.id);
|
|
31
|
+
}),
|
|
32
|
+
!stretch && /*#__PURE__*/ jsx("col", {}, "_filler")
|
|
33
|
+
]
|
|
31
34
|
});
|
|
32
35
|
};
|
|
33
36
|
TableColGroup.displayName = 'TableColGroup';
|
|
@@ -15,7 +15,7 @@ const toTanStackPinning = (p, pinnedLeft)=>({
|
|
|
15
15
|
end: p?.right ?? []
|
|
16
16
|
});
|
|
17
17
|
const TableProvider = (props)=>{
|
|
18
|
-
const { data, columns, isLoading = false, isLoadingPrevious = false, skeletonCount = TABLE_SKELETON_ROWS, children, getRowId, sorting: sortingProp, onSortingChange, manualSorting = false, rowSelection: rowSelectionProp, onRowSelectionChange, enableSelectAllRows = true, onSelectAllRows, columnSizing: columnSizingProp, onColumnSizingChange, columnPinning: columnPinningProp, onColumnPinningChange, columnOrder: columnOrderProp, onColumnOrderChange, grouping: groupingProp, onGroupingChange, expanded: expandedProp, onExpandedChange, renderGroupRow, getSubRows, renderExpandedRow, columnVisibility: columnVisibilityProp, onColumnVisibilityChange, defaultColumnVisibility, defaultColumnOrder, columnGroups, virtualized, estimateRowHeight, overscan = TABLE_VIRTUALIZATION_OVERSCAN, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold, initialScrollToRowId, onRowReorder, onMasterCellClick, activeRowId: activeRowIdProp, onSettingsOpenChange } = props;
|
|
18
|
+
const { data, columns, isLoading = false, isLoadingPrevious = false, skeletonCount = TABLE_SKELETON_ROWS, children, getRowId, sorting: sortingProp, onSortingChange, manualSorting = false, rowSelection: rowSelectionProp, onRowSelectionChange, enableSelectAllRows = true, onSelectAllRows, columnSizing: columnSizingProp, onColumnSizingChange, columnPinning: columnPinningProp, onColumnPinningChange, columnOrder: columnOrderProp, onColumnOrderChange, grouping: groupingProp, onGroupingChange, expanded: expandedProp, onExpandedChange, renderGroupRow, getSubRows, renderExpandedRow, columnVisibility: columnVisibilityProp, onColumnVisibilityChange, defaultColumnVisibility, defaultColumnOrder, columnGroups, virtualized, stretch = true, estimateRowHeight, overscan = TABLE_VIRTUALIZATION_OVERSCAN, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold, initialScrollToRowId, onRowReorder, onMasterCellClick, activeRowId: activeRowIdProp, onSettingsOpenChange } = props;
|
|
19
19
|
const masterCellActiveRowId = activeRowIdProp ?? null;
|
|
20
20
|
const sortingEnabled = !!onSortingChange;
|
|
21
21
|
const selectionEnabled = !!onRowSelectionChange;
|
|
@@ -203,6 +203,7 @@ const TableProvider = (props)=>{
|
|
|
203
203
|
visibilityEnabled,
|
|
204
204
|
hasSubRowGrouping: !!getSubRows,
|
|
205
205
|
virtualized,
|
|
206
|
+
stretch,
|
|
206
207
|
renderExpandedRow: renderExpandedRow,
|
|
207
208
|
estimateRowHeight,
|
|
208
209
|
overscan,
|
|
@@ -245,6 +246,7 @@ const TableProvider = (props)=>{
|
|
|
245
246
|
visibilityEnabled,
|
|
246
247
|
getSubRows,
|
|
247
248
|
virtualized,
|
|
249
|
+
stretch,
|
|
248
250
|
renderExpandedRow,
|
|
249
251
|
estimateRowHeight,
|
|
250
252
|
overscan,
|
|
@@ -25,6 +25,7 @@ export interface TableContextValue<T extends RowData> {
|
|
|
25
25
|
visibilityEnabled: boolean;
|
|
26
26
|
hasSubRowGrouping: boolean;
|
|
27
27
|
virtualized: TableVirtualized | undefined;
|
|
28
|
+
stretch: boolean;
|
|
28
29
|
renderExpandedRow?: (row: Row<DSTableFeatures, T>) => ReactNode;
|
|
29
30
|
estimateRowHeight?: (index: number) => number;
|
|
30
31
|
overscan: number;
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../../utils/cn.js";
|
|
3
3
|
import { useTestId } from "../../utils/testId.js";
|
|
4
|
-
import { THead, Tr } from "./primitives/index.js";
|
|
4
|
+
import { THead, Th, Tr } from "./primitives/index.js";
|
|
5
5
|
import { useTableContext } from "./TableContext/index.js";
|
|
6
6
|
import { TableHeadCell } from "./TableHeadCell.js";
|
|
7
7
|
const TableHead = ()=>{
|
|
8
|
-
const { table } = useTableContext();
|
|
8
|
+
const { table, stretch } = useTableContext();
|
|
9
9
|
const testId = useTestId('head');
|
|
10
10
|
const hasTextDescription = table.getAllLeafColumns().some((col)=>col.columnDef.meta?.description?.type === 'text');
|
|
11
11
|
return /*#__PURE__*/ jsx(THead, {
|
|
12
12
|
className: cn('sticky top-0 z-30', hasTextDescription ? 'h-48' : 'h-32'),
|
|
13
13
|
"data-testid": testId,
|
|
14
|
-
children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/
|
|
15
|
-
children:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ jsxs(Tr, {
|
|
15
|
+
children: [
|
|
16
|
+
headerGroup.headers.map((header)=>/*#__PURE__*/ jsx(TableHeadCell, {
|
|
17
|
+
header: header,
|
|
18
|
+
hasTextDescription: hasTextDescription
|
|
19
|
+
}, header.id)),
|
|
20
|
+
!stretch && /*#__PURE__*/ jsx(Th, {
|
|
21
|
+
"aria-hidden": true
|
|
22
|
+
})
|
|
23
|
+
]
|
|
19
24
|
}, headerGroup.id))
|
|
20
25
|
});
|
|
21
26
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../../utils/cn.js";
|
|
3
3
|
import { useTestId } from "../../utils/testId.js";
|
|
4
4
|
import { Skeleton } from "../Skeleton/index.js";
|
|
5
5
|
import { Td, Tr } from "./primitives/index.js";
|
|
6
6
|
import { useTableContext } from "./TableContext/index.js";
|
|
7
7
|
const TableLoadingState = ({ position = 'end', count })=>{
|
|
8
|
-
const { table, skeletonCount } = useTableContext();
|
|
8
|
+
const { table, skeletonCount, stretch } = useTableContext();
|
|
9
9
|
const testId = useTestId('start' === position ? 'loading-start' : 'loading');
|
|
10
10
|
const columns = table.getVisibleLeafColumns();
|
|
11
11
|
const lastRowIdx = (count ?? skeletonCount) - 1;
|
|
@@ -14,19 +14,25 @@ const TableLoadingState = ({ position = 'end', count })=>{
|
|
|
14
14
|
length: count ?? skeletonCount
|
|
15
15
|
}, (_, rowIdx)=>{
|
|
16
16
|
const key = `skeleton-${rowIdx}`;
|
|
17
|
-
return /*#__PURE__*/
|
|
17
|
+
return /*#__PURE__*/ jsxs(Tr, {
|
|
18
18
|
"data-testid": 0 === rowIdx ? testId : void 0,
|
|
19
19
|
"data-loading-position": position,
|
|
20
|
-
children:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
children: [
|
|
21
|
+
columns.map((column)=>/*#__PURE__*/ jsx(Td, {
|
|
22
|
+
className: cn('px-16 py-8 border-b border-r border-border-primary-light', 'end' === position && rowIdx === lastRowIdx && 'border-b-0'),
|
|
23
|
+
style: {
|
|
24
|
+
width: column.getSize()
|
|
25
|
+
},
|
|
26
|
+
children: /*#__PURE__*/ jsx(Skeleton, {
|
|
27
|
+
width: "100%",
|
|
28
|
+
height: "20px"
|
|
29
|
+
})
|
|
30
|
+
}, column.id)),
|
|
31
|
+
!stretch && /*#__PURE__*/ jsx(Td, {
|
|
32
|
+
pinned: false,
|
|
33
|
+
"aria-hidden": true
|
|
34
|
+
})
|
|
35
|
+
]
|
|
30
36
|
}, key);
|
|
31
37
|
})
|
|
32
38
|
});
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../../utils/cn.js";
|
|
3
3
|
const TableMasterCellActions = ({ children })=>/*#__PURE__*/ jsx("div", {
|
|
4
|
-
className: cn('shrink-0
|
|
5
|
-
children:
|
|
6
|
-
className: "overflow-hidden flex items-center gap-2",
|
|
7
|
-
children: children
|
|
8
|
-
})
|
|
4
|
+
className: cn('shrink-0 pl-4 pr-4 flex items-center gap-2', 'opacity-0 pointer-events-none', 'group-hover/row:opacity-100 group-hover/row:pointer-events-auto', 'group-data-[selected]/row:opacity-100 group-data-[selected]/row:pointer-events-auto', 'group-data-[preview-active]/row:opacity-100 group-data-[preview-active]/row:pointer-events-auto'),
|
|
5
|
+
children: children
|
|
9
6
|
});
|
|
10
7
|
TableMasterCellActions.displayName = 'TableMasterCellActions';
|
|
11
8
|
export { TableMasterCellActions };
|