Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ declare namespace NSScrollArea {
type Component = NSBox.Component;
}

type Component = Intergalactic.Component<'div', Props, Ctx> & {
interface Instance {
get isScrollVisible(): boolean;
}

type Component = Intergalactic.Component<'div', Props, Ctx, [], Instance> & {
Slider: Slider.Component;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ScrollBarRoot extends Component<
{ container: React.RefObject<HTMLElement | null> },
NSScrollArea.Bar.State,
NSScrollArea.Bar.DefaultProps
> {
> implements NSScrollArea.Bar.Instance {
static displayName = 'Bar';

static style = style;
Expand Down Expand Up @@ -70,6 +70,10 @@ class ScrollBarRoot extends Component<
visibleScroll: false,
};

public get isScrollVisible(): boolean {
return this.state.visibleScroll;
}

get $container(): Element | null {
return this.asProps.container.current;
}
Expand Down
4 changes: 4 additions & 0 deletions semcore/data-table/src/components/Body/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ class BodyRoot<Data extends DataTableData, UniqKeyType> extends Component<DataTa
rows,
renderCellOverlay,
selectedRows,
hasGroups,
scrollBarInstanceRef,
} = this.asProps;

let rowsToRender = rows;
Expand Down Expand Up @@ -394,7 +396,9 @@ class BodyRoot<Data extends DataTableData, UniqKeyType> extends Component<DataTa
<SSpinContainer
innerOutline
// @ts-ignore
hasGroups={hasGroups}
headerHeight={`${this.getSpinnerTopOffset()}px`}
tableInnerVerticalScroll={scrollBarInstanceRef.current?.isScrollVisible}
tabIndex={-1}
ref={spinnerRef}
role='row'
Expand Down
2 changes: 2 additions & 0 deletions semcore/data-table/src/components/Body/Body.types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { NSScrollArea } from '@semcore/base-components';
import type { Intergalactic } from '@semcore/core';
import type * as React from 'react';

Expand Down Expand Up @@ -96,6 +97,7 @@ export type BodyPropsInner<Data extends DataTableData, UniqKeyType> = DataTableB
variant?: DataTableProps<any, any, any>['variant'];
totalRows?: number;
accordionAnimationRows: RowPropsInner<Data, UniqKeyType>['accordionAnimationRows'];
scrollBarInstanceRef: React.RefObject<NSScrollArea.Bar.Instance>;
};

export type DataTableBodyType = (<
Expand Down
12 changes: 11 additions & 1 deletion semcore/data-table/src/components/Body/style.shadow.css
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ SCellWrapper[fixed] {
}

SSpinContainer {
grid-area: 2 / 1 / 20 / 5;
grid-area: 2 / 1 / 20 / -1;
display: flex;
align-items: center;
justify-content: center;
Expand All @@ -287,6 +287,16 @@ SSpinContainer {
top: 0;
height: min(100vh, calc(var(--global-table-height) - var(--headerHeight)));
min-height: min(100vh, calc(var(--global-table-height) - var(--headerHeight)));
max-width: 100vw;
left: 0;
}

&[tableInnerVerticalScroll][headerHeight] {
top: var(--headerHeight);
}

&[hasGroups] {
grid-area: 3 / 1 / 20 / -1;
}
}

Expand Down
4 changes: 4 additions & 0 deletions semcore/data-table/src/components/DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { NSScrollArea } from '@semcore/base-components';
import { Box, ScrollArea } from '@semcore/base-components';
import { Component, createComponent, lastInteraction, Root, sstyled } from '@semcore/core';
import canUseDOM from '@semcore/core/lib/utils/canUseDOM';
Expand Down Expand Up @@ -116,6 +117,7 @@ class DataTableRoot<
private focusedCell: [RowIndex, ColIndex] = [-1, -1];

private scrollAreaRef = React.createRef<HTMLDivElement>();
private scrollBarInstanceRef = React.createRef<React.RefObject<NSScrollArea.Bar.Instance>>();

private tableContainerRef = React.createRef<HTMLDivElement>();
private tableRef = React.createRef<HTMLDivElement>();
Expand Down Expand Up @@ -420,6 +422,7 @@ class DataTableRoot<
limit,
variant,
totalRows,
scrollBarInstanceRef: this.scrollBarInstanceRef,
};
}

Expand Down Expand Up @@ -1018,6 +1021,7 @@ class DataTableRoot<
topOffset={topOffset}
withHeaderScrollBar={headerProps?.withScrollBar}
withAnimation={this.withAnimation}
scrollBarInstanceRef={this.scrollBarInstanceRef}
/>

{selectedRows !== undefined && !Array.isArray(selectedRows) && (
Expand Down
6 changes: 4 additions & 2 deletions semcore/data-table/src/components/DataTable/ScrollBars.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { NSScrollArea } from '@semcore/base-components';
import { ScrollArea } from '@semcore/base-components';
import { sstyled } from '@semcore/core';
import React from 'react';
Expand All @@ -9,14 +10,15 @@ type Props = {
withHeaderScrollBar?: boolean;
topOffset?: number;
withAnimation: boolean;
scrollBarInstanceRef: React.RefObject<NSScrollArea.Bar.Instance>;
};

const SCROLL_BAR_HEIGHT = 12;

export class ScrollBars extends React.PureComponent<Props> {
render() {
const SScrollAreaBarInHeader = ScrollArea.Bar;
const { loading, topOffset, withHeaderScrollBar, withAnimation } = this.props;
const { loading, topOffset, withHeaderScrollBar, withAnimation, scrollBarInstanceRef } = this.props;

return sstyled(styles)(
<>
Expand All @@ -33,7 +35,7 @@ export class ScrollBars extends React.PureComponent<Props> {
{!loading && (
<>
<ScrollArea.Bar orientation='horizontal' zIndex={20} />
<ScrollArea.Bar orientation='vertical' zIndex={20} />
<ScrollArea.Bar orientation='vertical' zIndex={20} instanceRef={scrollBarInstanceRef} />
</>
)}
</>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ const Demo = (demoProps: AccordionInTableProps) => {
loading={demoProps.loading}
data={data}
aria-label='Accordion inside table'
h='100%'
defaultGridTemplateColumnWidth='1fr'
columns={cols}
renderCell={(props) => {
Expand Down
Loading