@wallarm-org/design-system 1.28.2-rc-fix-table-window-scroll-root.1 → 1.29.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/FilterDropdown/FilterDropdown.d.ts +58 -0
- package/dist/components/FilterDropdown/FilterDropdown.js +168 -0
- package/dist/components/FilterDropdown/FilterDropdownAllOption.d.ts +14 -0
- package/dist/components/FilterDropdown/FilterDropdownAllOption.js +25 -0
- package/dist/components/FilterDropdown/FilterDropdownClear.d.ts +12 -0
- package/dist/components/FilterDropdown/FilterDropdownClear.js +33 -0
- package/dist/components/FilterDropdown/FilterDropdownContent.d.ts +13 -0
- package/dist/components/FilterDropdown/FilterDropdownContent.js +57 -0
- package/dist/components/FilterDropdown/FilterDropdownContext.d.ts +60 -0
- package/dist/components/FilterDropdown/FilterDropdownContext.js +21 -0
- package/dist/components/FilterDropdown/FilterDropdownEmpty.d.ts +9 -0
- package/dist/components/FilterDropdown/FilterDropdownEmpty.js +21 -0
- package/dist/components/FilterDropdown/FilterDropdownFooter.d.ts +9 -0
- package/dist/components/FilterDropdown/FilterDropdownFooter.js +19 -0
- package/dist/components/FilterDropdown/FilterDropdownFooterClear.d.ts +9 -0
- package/dist/components/FilterDropdown/FilterDropdownFooterClear.js +40 -0
- package/dist/components/FilterDropdown/FilterDropdownGroup.d.ts +5 -0
- package/dist/components/FilterDropdown/FilterDropdownGroup.js +8 -0
- package/dist/components/FilterDropdown/FilterDropdownGroupLabel.d.ts +4 -0
- package/dist/components/FilterDropdown/FilterDropdownGroupLabel.js +8 -0
- package/dist/components/FilterDropdown/FilterDropdownOption.d.ts +15 -0
- package/dist/components/FilterDropdown/FilterDropdownOption.js +32 -0
- package/dist/components/FilterDropdown/FilterDropdownSearch.d.ts +12 -0
- package/dist/components/FilterDropdown/FilterDropdownSearch.js +38 -0
- package/dist/components/FilterDropdown/FilterDropdownSelected.d.ts +16 -0
- package/dist/components/FilterDropdown/FilterDropdownSelected.js +38 -0
- package/dist/components/FilterDropdown/FilterDropdownTrigger.d.ts +16 -0
- package/dist/components/FilterDropdown/FilterDropdownTrigger.js +139 -0
- package/dist/components/FilterDropdown/classes.d.ts +16 -0
- package/dist/components/FilterDropdown/classes.js +43 -0
- package/dist/components/FilterDropdown/index.d.ts +15 -0
- package/dist/components/FilterDropdown/index.js +15 -0
- package/dist/components/FilterDropdown/lib/index.d.ts +1 -0
- package/dist/components/FilterDropdown/lib/index.js +1 -0
- package/dist/components/FilterDropdown/lib/values.d.ts +59 -0
- package/dist/components/FilterDropdown/lib/values.js +58 -0
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/components/Select/SelectContent.d.ts +2 -1
- package/dist/components/Select/SelectContent.js +3 -2
- package/dist/components/Select/SelectEmptyState.d.ts +1 -0
- package/dist/components/Select/SelectEmptyState.js +2 -1
- package/dist/components/Select/SelectFooter.d.ts +7 -2
- package/dist/components/Select/SelectFooter.js +6 -3
- package/dist/components/Select/SelectGroup.d.ts +8 -2
- package/dist/components/Select/SelectGroup.js +3 -2
- package/dist/components/Select/SelectGroupLabel.d.ts +5 -2
- package/dist/components/Select/SelectGroupLabel.js +2 -2
- package/dist/components/Select/SelectOption.js +1 -1
- package/dist/components/Select/SelectOptionHint.d.ts +11 -0
- package/dist/components/Select/SelectOptionHint.js +15 -0
- package/dist/components/Select/SelectPositioner.d.ts +13 -3
- package/dist/components/Select/SelectPositioner.js +2 -1
- package/dist/components/Select/SelectSearchInput.d.ts +5 -2
- package/dist/components/Select/SelectSearchInput.js +11 -1
- package/dist/components/Select/classes.d.ts +3 -0
- package/dist/components/Select/classes.js +13 -0
- package/dist/components/Select/index.d.ts +4 -2
- package/dist/components/Select/index.js +2 -0
- package/dist/components/Table/TableBody/TableBodyVirtualizedCore.js +1 -1
- package/dist/components/Table/TableBody/TableBodyVirtualizedWindow.js +9 -25
- package/dist/components/Table/TableInner/TableInnerWindow.js +0 -1
- package/dist/components/Table/hooks/infiniteScroll/useInfiniteScroll.d.ts +1 -1
- package/dist/components/Table/hooks/infiniteScroll/usePrependScrollAnchor.d.ts +0 -1
- package/dist/components/Table/hooks/infiniteScroll/usePrependScrollAnchor.js +10 -12
- package/dist/components/Table/hooks/infiniteScroll/useScrollEdge.d.ts +1 -4
- package/dist/components/Table/hooks/infiniteScroll/useScrollEdge.js +17 -4
- package/dist/components/Table/lib/index.d.ts +0 -1
- package/dist/components/Table/lib/index.js +0 -1
- package/dist/components/Table/types.d.ts +1 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/metadata/components.json +6160 -983
- package/package.json +1 -1
- package/dist/components/Table/lib/scrollRoot.d.ts +0 -18
- package/dist/components/Table/lib/scrollRoot.js +0 -22
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
1
|
+
import type { FC, Ref } from 'react';
|
|
2
2
|
import { Select as ArkUiSelect } from '@ark-ui/react/select';
|
|
3
|
-
type
|
|
3
|
+
import { type TestableProps } from '../../utils/testId';
|
|
4
|
+
type SelectGroupLabelProps = ArkUiSelect.ItemGroupLabelProps & TestableProps & {
|
|
5
|
+
ref?: Ref<HTMLDivElement>;
|
|
6
|
+
};
|
|
4
7
|
export declare const SelectGroupLabel: FC<SelectGroupLabelProps>;
|
|
5
8
|
export {};
|
|
@@ -3,8 +3,8 @@ import { Select } from "@ark-ui/react/select";
|
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
4
|
import { useTestId } from "../../utils/testId.js";
|
|
5
5
|
import { dropdownMenuLabelVariants } from "../DropdownMenu/index.js";
|
|
6
|
-
const SelectGroupLabel = (props)=>{
|
|
7
|
-
const testId = useTestId('group-label');
|
|
6
|
+
const SelectGroupLabel = ({ 'data-testid': testIdProp, ...props })=>{
|
|
7
|
+
const testId = useTestId('group-label', testIdProp);
|
|
8
8
|
return /*#__PURE__*/ jsx(Select.ItemGroupLabel, {
|
|
9
9
|
...props,
|
|
10
10
|
"data-testid": testId,
|
|
@@ -12,7 +12,7 @@ const SelectOption = ({ variant = 'default', 'data-testid': testIdProp, ...props
|
|
|
12
12
|
className: cn(dropdownMenuItemVariants({
|
|
13
13
|
variant,
|
|
14
14
|
inset: false
|
|
15
|
-
}), 'flex-wrap relative gap-y-0 gap-x-8 pr-32', 'data-[state=checked]:bg-states-primary-active', 'data-highlighted:bg-states-primary-hover')
|
|
15
|
+
}), 'flex-wrap relative gap-y-0 gap-x-8 pr-32', 'has-[>[data-slot=select-option-hint]]:flex-nowrap', 'data-[state=checked]:bg-states-primary-active', 'data-highlighted:bg-states-primary-hover')
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
18
|
SelectOption.displayName = 'SelectOption';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../utils/testId';
|
|
3
|
+
export interface SelectOptionHintProps extends HTMLAttributes<HTMLSpanElement>, TestableProps {
|
|
4
|
+
ref?: Ref<HTMLSpanElement>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Secondary text at the right end of an option, such as a count. It sits before the indicator
|
|
8
|
+
* rather than under it: the option stops wrapping while a hint is present, so the label wraps
|
|
9
|
+
* inside its own box and the hint keeps its place on the first line.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SelectOptionHint: FC<SelectOptionHintProps>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { useTestId } from "../../utils/testId.js";
|
|
4
|
+
const SelectOptionHint = ({ ref, className, 'data-testid': testIdProp, ...props })=>{
|
|
5
|
+
const testId = useTestId('option-hint', testIdProp);
|
|
6
|
+
return /*#__PURE__*/ jsx("span", {
|
|
7
|
+
...props,
|
|
8
|
+
ref: ref,
|
|
9
|
+
"data-slot": "select-option-hint",
|
|
10
|
+
"data-testid": testId,
|
|
11
|
+
className: cn('ml-auto shrink-0 self-start font-sans text-sm text-text-secondary tabular-nums', className)
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
SelectOptionHint.displayName = 'SelectOptionHint';
|
|
15
|
+
export { SelectOptionHint };
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
1
|
+
import type { FC, Ref } from 'react';
|
|
2
2
|
import { Select as ArkUiSelect } from '@ark-ui/react/select';
|
|
3
|
-
|
|
3
|
+
export interface SelectPositionerProps extends ArkUiSelect.PositionerProps {
|
|
4
|
+
/**
|
|
5
|
+
* Props for the content element (the `listbox` panel inside the positioner) — for a ref, an
|
|
6
|
+
* inline measurement such as a locked width, or `data-*` attributes. `className` on the
|
|
7
|
+
* positioner itself already lands on the content, and overrides its default sizes
|
|
8
|
+
* (`min-w-240 max-w-320 max-h-(--available-height)`) through tailwind-merge.
|
|
9
|
+
*/
|
|
10
|
+
contentProps?: Omit<ArkUiSelect.ContentProps, 'className' | 'children' | 'asChild'> & {
|
|
11
|
+
ref?: Ref<HTMLDivElement>;
|
|
12
|
+
[dataAttribute: `data-${string}`]: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
4
15
|
export declare const SelectPositioner: FC<SelectPositionerProps>;
|
|
5
|
-
export {};
|
|
@@ -3,11 +3,12 @@ import { Portal } from "@ark-ui/react/portal";
|
|
|
3
3
|
import { Select } from "@ark-ui/react/select";
|
|
4
4
|
import { cn } from "../../utils/cn.js";
|
|
5
5
|
import { dropdownMenuClassNames } from "../DropdownMenu/index.js";
|
|
6
|
-
const SelectPositioner = ({ className, children, ...props })=>/*#__PURE__*/ jsx(Portal, {
|
|
6
|
+
const SelectPositioner = ({ className, children, contentProps, ...props })=>/*#__PURE__*/ jsx(Portal, {
|
|
7
7
|
children: /*#__PURE__*/ jsx(Select.Positioner, {
|
|
8
8
|
...props,
|
|
9
9
|
className: "outline-none",
|
|
10
10
|
children: /*#__PURE__*/ jsx(Select.Content, {
|
|
11
|
+
...contentProps,
|
|
11
12
|
className: cn(dropdownMenuClassNames, 'flex flex-col', 'h-full', 'min-w-240', 'max-w-320', 'max-h-(--available-height)', 'p-0', 'origin-[--transform-origin]', className),
|
|
12
13
|
children: children
|
|
13
14
|
})
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type { FC,
|
|
1
|
+
import type { FC, InputHTMLAttributes, Ref } from 'react';
|
|
2
2
|
import { type TestableProps } from '../../utils/testId';
|
|
3
|
-
export interface SelectSearchInputProps extends Omit<
|
|
3
|
+
export interface SelectSearchInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'children' | 'onChange' | 'color' | 'size' | 'type' | 'value'>, TestableProps {
|
|
4
4
|
value: string;
|
|
5
5
|
onChange: (value: string) => void;
|
|
6
|
+
/** Called when the built-in clear button empties the field, before `onChange('')`. */
|
|
7
|
+
onClear?: () => void;
|
|
8
|
+
ref?: Ref<HTMLInputElement>;
|
|
6
9
|
}
|
|
7
10
|
export declare const SelectSearchInput: FC<SelectSearchInputProps>;
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useTestId } from "../../utils/testId.js";
|
|
3
3
|
import { SearchInput } from "../SearchInput/index.js";
|
|
4
|
-
const
|
|
4
|
+
const INPUT_OWNED_KEYS = new Set([
|
|
5
|
+
' ',
|
|
6
|
+
'Home',
|
|
7
|
+
'End'
|
|
8
|
+
]);
|
|
9
|
+
const SelectSearchInput = ({ value, onChange, onKeyDown, 'data-testid': testIdProp, ...rest })=>{
|
|
5
10
|
const testId = useTestId('search-input', testIdProp);
|
|
11
|
+
const handleKeyDown = (event)=>{
|
|
12
|
+
onKeyDown?.(event);
|
|
13
|
+
if (INPUT_OWNED_KEYS.has(event.key)) event.stopPropagation();
|
|
14
|
+
};
|
|
6
15
|
return /*#__PURE__*/ jsx(SearchInput, {
|
|
7
16
|
...rest,
|
|
8
17
|
value: value,
|
|
9
18
|
onChange: onChange,
|
|
19
|
+
onKeyDown: handleKeyDown,
|
|
10
20
|
"data-testid": testId
|
|
11
21
|
});
|
|
12
22
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
const selectFooterVariants = cva('shrink-0 border-t', {
|
|
3
|
+
variants: {
|
|
4
|
+
variant: {
|
|
5
|
+
default: 'bg-component-outline-button-bg py-8 px-16 border-border-primary',
|
|
6
|
+
actions: 'flex items-center justify-end gap-8 p-8 border-border-primary-light'
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
defaultVariants: {
|
|
10
|
+
variant: 'default'
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export { selectFooterVariants };
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
export { createListCollection } from '@ark-ui/react/collection';
|
|
2
|
+
export { selectFooterVariants } from './classes';
|
|
2
3
|
export { Select } from './Select';
|
|
3
4
|
export { SelectButton } from './SelectButton';
|
|
4
5
|
export { SelectButtonTag, SelectButtonTagValue } from './SelectButtonTag';
|
|
5
6
|
export { SelectClearTrigger } from './SelectClearTrigger';
|
|
6
7
|
export { SelectContent } from './SelectContent';
|
|
7
8
|
export { SelectEmptyState, type SelectEmptyStateProps } from './SelectEmptyState';
|
|
8
|
-
export { SelectFooter } from './SelectFooter';
|
|
9
|
+
export { SelectFooter, type SelectFooterProps } from './SelectFooter';
|
|
9
10
|
export { SelectGroup } from './SelectGroup';
|
|
10
11
|
export { SelectGroupLabel } from './SelectGroupLabel';
|
|
11
12
|
export { SelectHeader } from './SelectHeader';
|
|
12
13
|
export { SelectInput } from './SelectInput';
|
|
13
14
|
export { SelectOption } from './SelectOption';
|
|
14
15
|
export { SelectOptionDescription } from './SelectOptionDescription';
|
|
16
|
+
export { SelectOptionHint, type SelectOptionHintProps } from './SelectOptionHint';
|
|
15
17
|
export { SelectOptionIndicator } from './SelectOptionIndicator';
|
|
16
18
|
export { SelectOptionText } from './SelectOptionText';
|
|
17
|
-
export { SelectPositioner } from './SelectPositioner';
|
|
19
|
+
export { SelectPositioner, type SelectPositionerProps } from './SelectPositioner';
|
|
18
20
|
export { SelectSearchInput, type SelectSearchInputProps } from './SelectSearchInput';
|
|
19
21
|
export { SelectSeparator, type SelectSeparatorProps } from './SelectSeparator';
|
|
20
22
|
export type { SelectDataItem } from './types';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { createListCollection } from "@ark-ui/react/collection";
|
|
2
|
+
export { selectFooterVariants } from "./classes.js";
|
|
2
3
|
export { Select } from "./Select.js";
|
|
3
4
|
export { SelectButton } from "./SelectButton.js";
|
|
4
5
|
export { SelectButtonTag, SelectButtonTagValue } from "./SelectButtonTag/index.js";
|
|
@@ -12,6 +13,7 @@ export { SelectHeader } from "./SelectHeader.js";
|
|
|
12
13
|
export { SelectInput } from "./SelectInput/index.js";
|
|
13
14
|
export { SelectOption } from "./SelectOption.js";
|
|
14
15
|
export { SelectOptionDescription } from "./SelectOptionDescription.js";
|
|
16
|
+
export { SelectOptionHint } from "./SelectOptionHint.js";
|
|
15
17
|
export { SelectOptionIndicator } from "./SelectOptionIndicator.js";
|
|
16
18
|
export { SelectOptionText } from "./SelectOptionText.js";
|
|
17
19
|
export { SelectPositioner } from "./SelectPositioner.js";
|
|
@@ -47,7 +47,7 @@ const TableBodyVirtualizedCore = ({ tbodyRef, virtualizer })=>{
|
|
|
47
47
|
virtualRows.length > 0 && /*#__PURE__*/ jsx(Tr, {
|
|
48
48
|
children: /*#__PURE__*/ jsx(Td, {
|
|
49
49
|
style: {
|
|
50
|
-
height: `${totalSize
|
|
50
|
+
height: `${totalSize - (virtualRows[virtualRows.length - 1]?.end ?? 0)}px`,
|
|
51
51
|
padding: 0,
|
|
52
52
|
border: 'none'
|
|
53
53
|
},
|
|
@@ -1,37 +1,20 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect
|
|
3
|
-
import {
|
|
4
|
-
import { TABLE_VIRTUALIZATION_OVERSCAN,
|
|
2
|
+
import { useCallback, useEffect } from "react";
|
|
3
|
+
import { useWindowVirtualizer } from "@tanstack/react-virtual";
|
|
4
|
+
import { TABLE_VIRTUALIZATION_OVERSCAN, getRowKey } from "../lib/index.js";
|
|
5
5
|
import { useTableContext } from "../TableContext/index.js";
|
|
6
|
+
import { getDocumentOffsetTop } from "./lib/getDocumentOffsetTop.js";
|
|
6
7
|
import { measureRowElement } from "./lib/measureRowElement.js";
|
|
7
8
|
import { TableBodyVirtualizedCore } from "./TableBodyVirtualizedCore.js";
|
|
8
9
|
import { useResetVirtualizerOnDataChange } from "./useResetVirtualizerOnDataChange.js";
|
|
9
10
|
import { useSmoothScrollOnSort } from "./useSmoothScrollOnSort.js";
|
|
10
|
-
const isWindowRoot = (instance)=>instance.scrollElement === window;
|
|
11
|
-
const observeRootRect = (instance, cb)=>isWindowRoot(instance) ? observeWindowRect(instance, cb) : observeElementRect(instance, cb);
|
|
12
|
-
const observeRootOffset = (instance, cb)=>isWindowRoot(instance) ? observeWindowOffset(instance, cb) : observeElementOffset(instance, cb);
|
|
13
11
|
const TableBodyVirtualizedWindow = ()=>{
|
|
14
|
-
const { table, estimateRowHeight, overscan, tbodyRef, virtualizerRef
|
|
15
|
-
const
|
|
16
|
-
const getScrollElement = useCallback(()=>{
|
|
17
|
-
const anchor = tbodyRef.current ?? containerRef.current;
|
|
18
|
-
if (!scrollRootRef.current && anchor) scrollRootRef.current = getScrollRoot(anchor);
|
|
19
|
-
return scrollRootRef.current;
|
|
20
|
-
}, [
|
|
21
|
-
tbodyRef,
|
|
22
|
-
containerRef
|
|
23
|
-
]);
|
|
24
|
-
const scrollRoot = getScrollElement();
|
|
25
|
-
const virtualizer = useVirtualizer({
|
|
12
|
+
const { table, estimateRowHeight, overscan, tbodyRef, virtualizerRef } = useTableContext();
|
|
13
|
+
const virtualizer = useWindowVirtualizer({
|
|
26
14
|
count: table.getRowModel().rows.length,
|
|
27
|
-
getScrollElement: getScrollElement,
|
|
28
|
-
observeElementRect: observeRootRect,
|
|
29
|
-
observeElementOffset: observeRootOffset,
|
|
30
|
-
scrollToFn: elementScroll,
|
|
31
|
-
initialOffset: ()=>getScrollMetrics(getScrollElement() ?? window).scrollTop,
|
|
32
15
|
estimateSize: estimateRowHeight ?? (()=>40),
|
|
33
16
|
overscan: overscan ?? TABLE_VIRTUALIZATION_OVERSCAN,
|
|
34
|
-
scrollMargin: tbodyRef.current
|
|
17
|
+
scrollMargin: tbodyRef.current ? getDocumentOffsetTop(tbodyRef.current) : 0,
|
|
35
18
|
getItemKey: useCallback((index)=>getRowKey(table.getRowModel().rows, index), [
|
|
36
19
|
table
|
|
37
20
|
]),
|
|
@@ -44,7 +27,8 @@ const TableBodyVirtualizedWindow = ()=>{
|
|
|
44
27
|
virtualizerRef
|
|
45
28
|
]);
|
|
46
29
|
useResetVirtualizerOnDataChange(table, virtualizer);
|
|
47
|
-
|
|
30
|
+
const getScrollTarget = useCallback(()=>window, []);
|
|
31
|
+
useSmoothScrollOnSort(table, getScrollTarget);
|
|
48
32
|
return /*#__PURE__*/ jsx(TableBodyVirtualizedCore, {
|
|
49
33
|
tbodyRef: tbodyRef,
|
|
50
34
|
virtualizer: virtualizer
|
|
@@ -4,7 +4,7 @@ import { type DSTableFeatures } from '../../lib';
|
|
|
4
4
|
import type { TableVirtualizerInstance } from '../../TableContext/types';
|
|
5
5
|
interface UseInfiniteScrollOptions<T extends RowData> {
|
|
6
6
|
mode: 'container' | 'window';
|
|
7
|
-
/**
|
|
7
|
+
/** Scroll element ref — required for `container` mode */
|
|
8
8
|
scrollRef?: RefObject<HTMLElement | null>;
|
|
9
9
|
table: Table<DSTableFeatures, T>;
|
|
10
10
|
virtualizerRef: RefObject<TableVirtualizerInstance | null>;
|
|
@@ -2,7 +2,6 @@ import { type RefObject } from 'react';
|
|
|
2
2
|
import type { TableVirtualizerInstance } from '../../TableContext/types';
|
|
3
3
|
interface UsePrependScrollAnchorOptions {
|
|
4
4
|
mode: 'container' | 'window';
|
|
5
|
-
/** `container`: the scroll element. `window`: an element to resolve the scroll root from. */
|
|
6
5
|
scrollRef?: RefObject<HTMLElement | null>;
|
|
7
6
|
rows: {
|
|
8
7
|
id: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useLayoutEffect, useRef } from "react";
|
|
2
|
-
import { detectDataChange
|
|
2
|
+
import { detectDataChange } from "../../lib/index.js";
|
|
3
3
|
const usePrependScrollAnchor = ({ mode, scrollRef, rows, virtualizerRef, tbodyRef, isLoadingPrevious })=>{
|
|
4
4
|
const prevFirstRowIdRef = useRef(void 0);
|
|
5
5
|
const prevLastRowIdRef = useRef(void 0);
|
|
@@ -12,15 +12,7 @@ const usePrependScrollAnchor = ({ mode, scrollRef, rows, virtualizerRef, tbodyRe
|
|
|
12
12
|
});
|
|
13
13
|
const seededRef = useRef(false);
|
|
14
14
|
useLayoutEffect(()=>{
|
|
15
|
-
const
|
|
16
|
-
const getScrollHeight = ()=>{
|
|
17
|
-
const root = getRoot();
|
|
18
|
-
return root ? getScrollMetrics(root).scrollHeight : 0;
|
|
19
|
-
};
|
|
20
|
-
const scrollBy = (delta)=>{
|
|
21
|
-
const root = getRoot();
|
|
22
|
-
if (root) scrollRootBy(root, delta);
|
|
23
|
-
};
|
|
15
|
+
const getScrollHeight = ()=>'window' === mode ? document.documentElement.scrollHeight : scrollRef?.current?.scrollHeight ?? 0;
|
|
24
16
|
const getStartLoaderHeight = ()=>{
|
|
25
17
|
const loaderRows = tbodyRef?.current?.querySelectorAll('tr[data-loading-position="start"]');
|
|
26
18
|
const count = loaderRows?.length ?? 0;
|
|
@@ -62,10 +54,16 @@ const usePrependScrollAnchor = ({ mode, scrollRef, rows, virtualizerRef, tbodyRe
|
|
|
62
54
|
const rowDelta = newStart - prevFirstRowStartRef.current;
|
|
63
55
|
const loaderDelta = getStartLoaderHeight() - prevLoaderHeight;
|
|
64
56
|
const delta = rowDelta + loaderDelta;
|
|
65
|
-
if (0 !== delta)
|
|
57
|
+
if (0 !== delta) {
|
|
58
|
+
if ('window' === mode) window.scrollBy(0, delta);
|
|
59
|
+
else if (scrollRef?.current) scrollRef.current.scrollTop += delta;
|
|
60
|
+
}
|
|
66
61
|
} else if (null !== prevScrollHeightRef.current) {
|
|
67
62
|
const delta = getScrollHeight() - prevScrollHeightRef.current;
|
|
68
|
-
if (delta > 0)
|
|
63
|
+
if (delta > 0) {
|
|
64
|
+
if ('window' === mode) window.scrollBy(0, delta);
|
|
65
|
+
else if (scrollRef?.current) scrollRef.current.scrollTop += delta;
|
|
66
|
+
}
|
|
69
67
|
}
|
|
70
68
|
}
|
|
71
69
|
prevFirstRowIdRef.current = rows[0]?.id;
|
|
@@ -4,10 +4,7 @@ type ScrollEdge = 'start' | 'end';
|
|
|
4
4
|
interface UseScrollEdgeOptions {
|
|
5
5
|
edge: ScrollEdge;
|
|
6
6
|
mode: ScrollMode;
|
|
7
|
-
/**
|
|
8
|
-
* `container`: the scroll element. `window`: any element inside the table —
|
|
9
|
-
* the scroll root is resolved from it (see `getScrollRoot`).
|
|
10
|
-
*/
|
|
7
|
+
/** Scroll element ref — required for `container` mode */
|
|
11
8
|
scrollRef?: RefObject<HTMLElement | null>;
|
|
12
9
|
onReached?: () => void;
|
|
13
10
|
threshold: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
|
-
import { SCROLL_EDGE_COOLDOWN_MS
|
|
2
|
+
import { SCROLL_EDGE_COOLDOWN_MS } from "../../lib/index.js";
|
|
3
3
|
const useScrollEdge = ({ edge, mode, scrollRef, onReached, threshold, enabled = true })=>{
|
|
4
4
|
const firedRef = useRef(false);
|
|
5
5
|
const lastFiredAtRef = useRef(0);
|
|
@@ -12,12 +12,23 @@ const useScrollEdge = ({ edge, mode, scrollRef, onReached, threshold, enabled =
|
|
|
12
12
|
enabledRef.current = enabled;
|
|
13
13
|
});
|
|
14
14
|
useEffect(()=>{
|
|
15
|
-
const target = 'window' === mode ? getScrollRoot(scrollRef?.current ?? null) : scrollRef?.current;
|
|
16
|
-
if (!target) return;
|
|
17
15
|
const check = ()=>{
|
|
18
16
|
const callback = onReachedRef.current;
|
|
19
17
|
if (!callback || !enabledRef.current) return;
|
|
20
|
-
|
|
18
|
+
let scrollTop;
|
|
19
|
+
let clientHeight;
|
|
20
|
+
let scrollHeight;
|
|
21
|
+
if ('window' === mode) {
|
|
22
|
+
scrollTop = window.scrollY;
|
|
23
|
+
clientHeight = window.innerHeight;
|
|
24
|
+
scrollHeight = document.documentElement.scrollHeight;
|
|
25
|
+
} else {
|
|
26
|
+
const el = scrollRef?.current;
|
|
27
|
+
if (!el) return;
|
|
28
|
+
scrollTop = el.scrollTop;
|
|
29
|
+
clientHeight = el.clientHeight;
|
|
30
|
+
scrollHeight = el.scrollHeight;
|
|
31
|
+
}
|
|
21
32
|
const distance = 'start' === edge ? scrollTop : scrollHeight - scrollTop - clientHeight;
|
|
22
33
|
if (distance <= threshold) {
|
|
23
34
|
const now = Date.now();
|
|
@@ -28,6 +39,8 @@ const useScrollEdge = ({ edge, mode, scrollRef, onReached, threshold, enabled =
|
|
|
28
39
|
}
|
|
29
40
|
} else firedRef.current = false;
|
|
30
41
|
};
|
|
42
|
+
const target = 'window' === mode ? window : scrollRef?.current;
|
|
43
|
+
if (!target) return;
|
|
31
44
|
target.addEventListener('scroll', check, {
|
|
32
45
|
passive: true
|
|
33
46
|
});
|
|
@@ -11,7 +11,6 @@ export { getDndStyles } from './getDndStyles';
|
|
|
11
11
|
export { getPinningStyles } from './getPinningStyles';
|
|
12
12
|
export { getRowKey } from './getRowKey';
|
|
13
13
|
export { isLastPinnedLeft } from './isLastPinnedLeft';
|
|
14
|
-
export { getOffsetTopInScrollRoot, getScrollMetrics, getScrollRoot, isWindowScrollRoot, type ScrollRoot, scrollRootBy, } from './scrollRoot';
|
|
15
14
|
export { useColumnDnd } from './useColumnDnd';
|
|
16
15
|
export { useContainerWidth } from './useContainerWidth';
|
|
17
16
|
export { useRowDnd } from './useRowDnd';
|
|
@@ -11,7 +11,6 @@ export { getDndStyles } from "./getDndStyles.js";
|
|
|
11
11
|
export { getPinningStyles } from "./getPinningStyles.js";
|
|
12
12
|
export { getRowKey } from "./getRowKey.js";
|
|
13
13
|
export { isLastPinnedLeft } from "./isLastPinnedLeft.js";
|
|
14
|
-
export { getOffsetTopInScrollRoot, getScrollMetrics, getScrollRoot, isWindowScrollRoot, scrollRootBy } from "./scrollRoot.js";
|
|
15
14
|
export { useColumnDnd } from "./useColumnDnd.js";
|
|
16
15
|
export { useContainerWidth } from "./useContainerWidth.js";
|
|
17
16
|
export { useRowDnd } from "./useRowDnd.js";
|
|
@@ -245,10 +245,7 @@ export interface TableProps<T> extends TestableProps {
|
|
|
245
245
|
* the close edge here.
|
|
246
246
|
*/
|
|
247
247
|
onSettingsOpenChange?: (open: boolean) => void;
|
|
248
|
-
/**
|
|
249
|
-
* Enable row virtualization. `'container'` virtualizes within the table's own scroll container;
|
|
250
|
-
* `'window'` follows the page scroll — the nearest scrollable ancestor, or the browser window.
|
|
251
|
-
*/
|
|
248
|
+
/** Enable row virtualization. `'container'` virtualizes within the scroll container; `'window'` virtualizes against the browser window. */
|
|
252
249
|
virtualized?: TableVirtualized;
|
|
253
250
|
/**
|
|
254
251
|
* Whether columns stretch proportionally to fill the container width.
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export { EmptyState, EmptyStateActions, EmptyStateDescription, EmptyStateIllustr
|
|
|
36
36
|
export { FeedbackPulse, type FeedbackPulseCloseReason, type FeedbackPulseProps, } from './components/FeedbackPulse';
|
|
37
37
|
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, } from './components/Field';
|
|
38
38
|
export { FileUpload, FileUploadDropzone, type FileUploadDropzoneProps, FileUploadError, type FileUploadErrorCode, type FileUploadErrorProps, FileUploadItem, FileUploadItemAction, type FileUploadItemActionProps, FileUploadItemDeleteTrigger, type FileUploadItemDeleteTriggerProps, type FileUploadItemFile, FileUploadItemGroup, type FileUploadItemGroupProps, type FileUploadItemProps, FileUploadItemReplaceTrigger, type FileUploadItemReplaceTriggerProps, type FileUploadProps, type FileUploadRejection, FileUploadTrigger, type FileUploadTriggerProps, fileUploadDropzoneVariants, fileUploadItemVariants, fileUploadVariants, } from './components/FileUpload';
|
|
39
|
+
export { FilterDropdown, FilterDropdownAllOption, type FilterDropdownAllOptionProps, FilterDropdownClear, type FilterDropdownClearProps, FilterDropdownContent, type FilterDropdownContentProps, FilterDropdownEmpty, type FilterDropdownEmptyProps, FilterDropdownFooter, FilterDropdownFooterClear, type FilterDropdownFooterClearProps, type FilterDropdownFooterProps, FilterDropdownGroup, FilterDropdownGroupLabel, type FilterDropdownGroupLabelProps, type FilterDropdownGroupProps, type FilterDropdownOpenChangeDetails, FilterDropdownOption, type FilterDropdownOptionProps, type FilterDropdownProps, FilterDropdownSearch, type FilterDropdownSearchProps, FilterDropdownSelected, type FilterDropdownSelectedProps, FilterDropdownTrigger, type FilterDropdownTriggerProps, type FilterDropdownValueChangeDetails, filterDropdownControlVariants, filterDropdownTriggerVariants, type UseFilterDropdownResult, useFilterDropdown, } from './components/FilterDropdown';
|
|
39
40
|
export { type Condition, type ExprNode, type FieldMetadata, type FieldType, FilterInput, FilterInputChip, type FilterInputChipData, type FilterInputChipProps, type FilterInputChipVariant, FilterInputFieldMenu, type FilterInputFieldMenuProps, FilterInputOperatorMenu, type FilterInputOperatorMenuProps, type FilterInputProps, type FilterOperator, type Group, } from './components/FilterInput';
|
|
40
41
|
export { Flex, type FlexProps } from './components/Flex';
|
|
41
42
|
export { FormatDateTime, type FormatDateTimeProps } from './components/FormatDateTime';
|
|
@@ -73,7 +74,7 @@ export { SearchInput, type SearchInputProps } from './components/SearchInput';
|
|
|
73
74
|
export { SearchModal, SearchModalBody, type SearchModalBodyProps, SearchModalContent, type SearchModalContentProps, SearchModalEmpty, type SearchModalEmptyProps, SearchModalFooter, type SearchModalFooterProps, SearchModalGroup, SearchModalGroupLabel, type SearchModalGroupLabelProps, type SearchModalGroupProps, SearchModalInput, type SearchModalInputProps, SearchModalItem, type SearchModalItemProps, type SearchModalProps, SearchModalTrigger, type SearchModalTriggerProps, useSearchModalContext, } from './components/SearchModal';
|
|
74
75
|
export { SegmentedControl, SegmentedControlButton, type SegmentedControlButtonProps, SegmentedControlItem, type SegmentedControlItemProps, type SegmentedControlProps, SegmentedControlSeparator, type SegmentedControlSeparatorProps, } from './components/SegmentedControl';
|
|
75
76
|
export { SegmentedTabs, SegmentedTabsButton, SegmentedTabsContent, SegmentedTabsList, SegmentedTabsSeparator, SegmentedTabsTrigger, SegmentedTabsTriggerButton, } from './components/SegmentedTabs';
|
|
76
|
-
export { createListCollection, Select, SelectButton, SelectClearTrigger, SelectContent, type SelectDataItem, SelectEmptyState, type SelectEmptyStateProps, SelectFooter, SelectGroup, SelectGroupLabel, SelectHeader, SelectInput, SelectOption, SelectOptionDescription, SelectOptionIndicator, SelectOptionText, SelectPositioner, SelectSearchInput, SelectSeparator, type UseSelectSearchOptions, type UseSelectSearchResult, useSelectSearch, } from './components/Select';
|
|
77
|
+
export { createListCollection, Select, SelectButton, SelectClearTrigger, SelectContent, type SelectDataItem, SelectEmptyState, type SelectEmptyStateProps, SelectFooter, type SelectFooterProps, SelectGroup, SelectGroupLabel, SelectHeader, SelectInput, SelectOption, SelectOptionDescription, SelectOptionHint, type SelectOptionHintProps, SelectOptionIndicator, SelectOptionText, SelectPositioner, type SelectPositionerProps, SelectSearchInput, SelectSeparator, selectFooterVariants, type UseSelectSearchOptions, type UseSelectSearchResult, useSelectSearch, } from './components/Select';
|
|
77
78
|
export { Selection, SelectionAll, type SelectionAllProps, SelectionBulkBar, type SelectionBulkBarPlacement, type SelectionBulkBarProps, type SelectionContextValue, SelectionItem, type SelectionItemProps, type SelectionProps, useSelectionContext, } from './components/Selection';
|
|
78
79
|
export { Separator, type SeparatorProps } from './components/Separator';
|
|
79
80
|
export { SettingsHeader, SettingsHeaderActions, type SettingsHeaderActionsProps, SettingsHeaderBreadcrumbs, type SettingsHeaderBreadcrumbsProps, SettingsHeaderDescription, type SettingsHeaderDescriptionProps, SettingsHeaderFilters, type SettingsHeaderFiltersProps, SettingsHeaderHeading, type SettingsHeaderHeadingProps, type SettingsHeaderProps, SettingsHeaderTitle, type SettingsHeaderTitleProps, } from './components/SettingsHeader';
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export { EmptyState, EmptyStateActions, EmptyStateDescription, EmptyStateIllustr
|
|
|
25
25
|
export { FeedbackPulse } from "./components/FeedbackPulse/index.js";
|
|
26
26
|
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle } from "./components/Field/index.js";
|
|
27
27
|
export { FileUpload, FileUploadDropzone, FileUploadError, FileUploadItem, FileUploadItemAction, FileUploadItemDeleteTrigger, FileUploadItemGroup, FileUploadItemReplaceTrigger, FileUploadTrigger, fileUploadDropzoneVariants, fileUploadItemVariants, fileUploadVariants } from "./components/FileUpload/index.js";
|
|
28
|
+
export { FilterDropdown, FilterDropdownAllOption, FilterDropdownClear, FilterDropdownContent, FilterDropdownEmpty, FilterDropdownFooter, FilterDropdownFooterClear, FilterDropdownGroup, FilterDropdownGroupLabel, FilterDropdownOption, FilterDropdownSearch, FilterDropdownSelected, FilterDropdownTrigger, filterDropdownControlVariants, filterDropdownTriggerVariants, useFilterDropdown } from "./components/FilterDropdown/index.js";
|
|
28
29
|
export { FilterInput, FilterInputChip, FilterInputFieldMenu, FilterInputOperatorMenu } from "./components/FilterInput/index.js";
|
|
29
30
|
export { Flex } from "./components/Flex/index.js";
|
|
30
31
|
export { FormatDateTime } from "./components/FormatDateTime/index.js";
|
|
@@ -62,7 +63,7 @@ export { SearchInput } from "./components/SearchInput/index.js";
|
|
|
62
63
|
export { SearchModal, SearchModalBody, SearchModalContent, SearchModalEmpty, SearchModalFooter, SearchModalGroup, SearchModalGroupLabel, SearchModalInput, SearchModalItem, SearchModalTrigger, useSearchModalContext } from "./components/SearchModal/index.js";
|
|
63
64
|
export { SegmentedControl, SegmentedControlButton, SegmentedControlItem, SegmentedControlSeparator } from "./components/SegmentedControl/index.js";
|
|
64
65
|
export { SegmentedTabs, SegmentedTabsButton, SegmentedTabsContent, SegmentedTabsList, SegmentedTabsSeparator, SegmentedTabsTrigger, SegmentedTabsTriggerButton } from "./components/SegmentedTabs/index.js";
|
|
65
|
-
export { Select, SelectButton, SelectClearTrigger, SelectContent, SelectEmptyState, SelectFooter, SelectGroup, SelectGroupLabel, SelectHeader, SelectInput, SelectOption, SelectOptionDescription, SelectOptionIndicator, SelectOptionText, SelectPositioner, SelectSearchInput, SelectSeparator, createListCollection, useSelectSearch } from "./components/Select/index.js";
|
|
66
|
+
export { Select, SelectButton, SelectClearTrigger, SelectContent, SelectEmptyState, SelectFooter, SelectGroup, SelectGroupLabel, SelectHeader, SelectInput, SelectOption, SelectOptionDescription, SelectOptionHint, SelectOptionIndicator, SelectOptionText, SelectPositioner, SelectSearchInput, SelectSeparator, createListCollection, selectFooterVariants, useSelectSearch } from "./components/Select/index.js";
|
|
66
67
|
export { Selection, SelectionAll, SelectionBulkBar, SelectionItem, useSelectionContext } from "./components/Selection/index.js";
|
|
67
68
|
export { Separator } from "./components/Separator/index.js";
|
|
68
69
|
export { SettingsHeader, SettingsHeaderActions, SettingsHeaderBreadcrumbs, SettingsHeaderDescription, SettingsHeaderFilters, SettingsHeaderHeading, SettingsHeaderTitle } from "./components/SettingsHeader/index.js";
|