-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
272 additions
and
24 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
packages/devextreme/js/__internal/grids/new/card_view/header_panel/drop_down_button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* eslint-disable @typescript-eslint/no-non-null-assertion */ | ||
import { Component, createRef } from 'inferno'; | ||
|
||
import type { Column } from '../../grid_core/columns_controller/types'; | ||
import { Button } from '../../grid_core/inferno_wrappers/button'; | ||
import { Popup } from '../../grid_core/inferno_wrappers/popup'; | ||
import { Sortable } from '../../grid_core/inferno_wrappers/sortable'; | ||
import { Item } from './item'; | ||
|
||
const CLASSES = { | ||
popup: 'dx-cardview-headerpanel-popup', | ||
}; | ||
|
||
export interface DropDownButtonProps { | ||
columns: Column[]; | ||
|
||
onReorder?: (fromIndex: number, toIndex: number) => void; | ||
|
||
onAdd?: (fromIndex: number, toIndex: number) => void; | ||
|
||
onRemove?: (name: string) => void; | ||
} | ||
|
||
interface DropDownButtonState { | ||
opened: boolean; | ||
} | ||
|
||
export class DropDownButton extends Component<DropDownButtonProps, DropDownButtonState> { | ||
private readonly buttonRef = createRef<HTMLDivElement>(); | ||
|
||
private readonly popupPosition = { | ||
my: 'top right', | ||
at: 'bottom right', | ||
collision: 'fit flip', | ||
offset: { v: 3 }, | ||
of: this.buttonRef, | ||
}; | ||
|
||
state = { | ||
opened: false, | ||
}; | ||
|
||
private readonly popupOptionChanged = ({ name, value }): void => { | ||
if (name === 'visible') { | ||
this.setState({ opened: value }); | ||
} | ||
}; | ||
|
||
public render(): JSX.Element { | ||
return (<> | ||
<Button | ||
elementRef={this.buttonRef} | ||
icon="overflow" | ||
onClick={(): void => { this.setState(({ opened }) => ({ opened: !opened })); } | ||
} | ||
/> | ||
<Popup | ||
visible={this.state.opened} | ||
// @ts-expect-error | ||
onOptionChanged={this.popupOptionChanged} | ||
deferRendering={false} | ||
height={'auto'} | ||
width={'auto'} | ||
hideOnParentScroll={true} | ||
shading={false} | ||
dragEnabled={false} | ||
showTitle={false} | ||
fullScreen={false} | ||
// @ts-expect-error | ||
position={this.popupPosition} | ||
wrapperAttr={{ | ||
class: CLASSES.popup, | ||
}} | ||
> | ||
<Sortable | ||
itemOrientation='horizontal' | ||
dropFeedbackMode='indicate' | ||
onReorder={(e): void => this.props.onReorder?.(e.fromIndex, e.toIndex)} | ||
onAdd={(e): void => this.props.onAdd?.(e.fromIndex, e.toIndex)} | ||
group='cardview' | ||
> | ||
{this.props.columns.map((column) => ( | ||
<Item | ||
column={column} | ||
onRemove={ | ||
(): void => this.props.onRemove?.(column.name) | ||
} | ||
/> | ||
))} | ||
</Sortable> | ||
</Popup> | ||
</>); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/devextreme/js/__internal/grids/new/grid_core/inferno_wrappers/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* eslint-disable @typescript-eslint/explicit-function-return-type */ | ||
/* eslint-disable @typescript-eslint/no-non-null-assertion */ | ||
import type { dxElementWrapper } from '@js/core/renderer'; | ||
import type { RefObject } from 'inferno'; | ||
|
||
export function wrapRef(ref: RefObject<HTMLElement>): dxElementWrapper { | ||
return { | ||
// @ts-expect-error | ||
dxRenderer: true, | ||
get 0() { | ||
return ref.current!; | ||
}, | ||
get() { | ||
return ref.current!; | ||
}, | ||
length: 1, | ||
}; | ||
} |
Oops, something went wrong.