Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: datetime tooltip to show full value #2286

Merged
merged 9 commits into from
Dec 5, 2024
Merged
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
5 changes: 3 additions & 2 deletions packages/grid/src/mouse-handlers/GridTokenMouseHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import GridUtils, {
} from '../GridUtils';
import { isTokenBoxCellRenderer } from '../TokenBoxCellRenderer';

// Handler also helps with other tooltips
class GridTokenMouseHandler extends GridMouseHandler {
timeoutId?: ReturnType<typeof setTimeout>;

Expand All @@ -21,7 +22,7 @@ class GridTokenMouseHandler extends GridMouseHandler {
private isDown = false;

// Stores the current hovered token box if it exists with translated coordinates
private currentLinkBox?: TokenBox;
protected currentLinkBox?: TokenBox;

private static HOLD_LENGTH = 1000;

Expand Down Expand Up @@ -86,7 +87,7 @@ class GridTokenMouseHandler extends GridMouseHandler {
* @param grid The grid
* @returns False
*/
private setCursor(gridPoint: GridPoint, grid: Grid): EventHandlerResult {
protected setCursor(gridPoint: GridPoint, grid: Grid): EventHandlerResult {
if (this.isHoveringLink(gridPoint, grid)) {
this.cursor = 'pointer';
} else {
Expand Down
61 changes: 27 additions & 34 deletions packages/iris-grid/src/IrisGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@ export interface IrisGridState {
overflowButtonTooltipProps: CSSProperties | null;
expandCellTooltipProps: CSSProperties | null;
expandTooltipDisplayValue: string;
linkHoverTooltipProps: CSSProperties | null;
linkHoverDisplayValue: string;
hoverTooltipProps: CSSProperties | null;
hoverDisplayValue: ReactNode;

gotoRow: string;
gotoRowError: string;
Expand Down Expand Up @@ -874,8 +874,8 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
overflowButtonTooltipProps: null,
expandCellTooltipProps: null,
expandTooltipDisplayValue: 'expand',
linkHoverTooltipProps: null,
linkHoverDisplayValue: '',
hoverTooltipProps: null,
hoverDisplayValue: '',
isGotoShown: false,
gotoRow: '',
gotoRowError: '',
Expand Down Expand Up @@ -3976,37 +3976,31 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
}
);

getLinkHoverTooltip = memoize(
(linkHoverTooltipProps: CSSProperties): ReactNode => {
if (linkHoverTooltipProps == null) {
return null;
}
getHoverTooltip = memoize((hoverTooltipProps: CSSProperties): ReactNode => {
if (hoverTooltipProps == null) {
return null;
}

const { linkHoverDisplayValue } = this.state;
const { hoverDisplayValue } = this.state;

const wrapperStyle: CSSProperties = {
position: 'absolute',
...linkHoverTooltipProps,
pointerEvents: 'none',
};
const wrapperStyle: CSSProperties = {
position: 'absolute',
...hoverTooltipProps,
pointerEvents: 'none',
};

const popperOptions: PopperOptions = {
placement: 'bottom',
};
const popperOptions: PopperOptions = {
placement: 'bottom',
};

return (
<div style={wrapperStyle}>
<Tooltip options={popperOptions} ref={this.handleTooltipRef}>
<div className="link-hover-tooltip">
{linkHoverDisplayValue} - Click once to follow.
<br />
Click and hold to select this cell.
</div>
</Tooltip>
</div>
);
}
);
return (
<div style={wrapperStyle}>
<Tooltip options={popperOptions} ref={this.handleTooltipRef}>
<div className="link-hover-tooltip">{hoverDisplayValue}</div>
</Tooltip>
</div>
);
});

handleGotoRowSelectedRowNumberSubmit(): void {
const { gotoRow: rowNumber } = this.state;
Expand Down Expand Up @@ -4282,7 +4276,7 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
overflowText,
overflowButtonTooltipProps,
expandCellTooltipProps,
linkHoverTooltipProps,
hoverTooltipProps,
isGotoShown,
gotoRow,
gotoRowError,
Expand Down Expand Up @@ -4902,8 +4896,7 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
this.getOverflowButtonTooltip(overflowButtonTooltipProps)}
{expandCellTooltipProps &&
this.getExpandCellTooltip(expandCellTooltipProps)}
{linkHoverTooltipProps &&
this.getLinkHoverTooltip(linkHoverTooltipProps)}
{hoverTooltipProps && this.getHoverTooltip(hoverTooltipProps)}
</Grid>
<GotoRow
ref={this.gotoRowRef}
Expand Down
5 changes: 5 additions & 0 deletions packages/iris-grid/src/IrisGridModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
type GridCell,
GridModel,
type GridRange,
type GridRangeIndex,
type GridThemeType,
type ModelIndex,
type MoveOperation,
Expand Down Expand Up @@ -601,6 +602,10 @@ abstract class IrisGridModel<
): DataBarOptions {
throw new Error('Method not implemented.');
}

tooltipForCell(column: GridRangeIndex, row: GridRangeIndex): string | null {
return null;
}
}

export default IrisGridModel;
21 changes: 20 additions & 1 deletion packages/iris-grid/src/IrisGridTableModelTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
type EditableGridModel,
type EditOperation,
GridRange,
type GridRangeIndex,
GridUtils,
memoizeClear,
type ModelIndex,
Expand All @@ -21,7 +22,12 @@ import {
PromiseUtils,
assertNotNull,
} from '@deephaven/utils';
import { TableUtils, Formatter, FormatterUtils } from '@deephaven/jsapi-utils';
import {
TableUtils,
Formatter,
FormatterUtils,
DateUtils,
} from '@deephaven/jsapi-utils';
import IrisGridModel, { type DisplayColumn } from './IrisGridModel';
import AggregationOperation from './sidebar/aggregations/AggregationOperation';
import IrisGridUtils from './IrisGridUtils';
Expand Down Expand Up @@ -682,6 +688,19 @@ class IrisGridTableModelTemplate<
return null;
}

tooltipForCell(column: GridRangeIndex, row: GridRangeIndex): string | null {
if (column === null || row === null) return null;
if (TableUtils.isDateType(this.columns[column].type)) {
return this.displayString(
this.valueForCell(column, row),
this.columns[column].type,
this.columns[column].name,
{ formatString: DateUtils.FULL_DATE_FORMAT }
);
}
return null;
}

getColumnHeaderGroup(
modelIndex: ModelIndex,
depth: number
Expand Down
144 changes: 0 additions & 144 deletions packages/iris-grid/src/mousehandlers/IrisGridTokenMouseHandler.ts

This file was deleted.

Loading
Loading