This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(UIKIT-375,NewDataGrid): Реализована блокировка строки при выполн…
…ении действий (#1100) Co-authored-by: ooops_o_O <[email protected]>
- Loading branch information
1 parent
fc3579a
commit 19cf54f
Showing
35 changed files
with
1,447 additions
and
103 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -88,6 +88,7 @@ mobx | |
monokai | ||
navpanes | ||
nextjs | ||
newactioncell | ||
newdatagrid | ||
newdatagridinfinite | ||
noopener | ||
|
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
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
95 changes: 95 additions & 0 deletions
95
packages/components/src/NewActionCell/MainAction/MainAction.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,95 @@ | ||
import type { ActionCellHandler, MainActionKind } from '../types'; | ||
import { Tooltip, type TooltipProps } from '../../Tooltip'; | ||
import { IconDropdownButton } from '../../IconDropdownButton'; | ||
import { MenuItem } from '../../MenuItem'; | ||
import { IconButton } from '../../IconButton'; | ||
|
||
type MainActionProps<TAction> = { | ||
/** | ||
* Основные действия | ||
*/ | ||
action: MainActionKind<TAction>; | ||
/** | ||
* Обработчик клика на действие | ||
*/ | ||
onActionClick: ActionCellHandler<TAction>; | ||
/** | ||
* Если true, action не доступен | ||
*/ | ||
isDisabled?: boolean; | ||
/** | ||
* Положение тултипа | ||
*/ | ||
tooltipPlacement?: TooltipProps['placement']; | ||
}; | ||
|
||
export const MainAction = <TAction,>({ | ||
action, | ||
onActionClick, | ||
isDisabled, | ||
tooltipPlacement, | ||
}: MainActionProps<TAction>) => { | ||
if ('actions' in action) { | ||
const { disabled, icon, name, disabledReason, actions } = action; | ||
|
||
return ( | ||
<Tooltip | ||
key={name} | ||
title={disabledReason || name} | ||
withoutContainer={!disabled} | ||
placement={tooltipPlacement} | ||
> | ||
<IconDropdownButton | ||
icon={icon} | ||
variant="text" | ||
disabled={isDisabled || disabled} | ||
> | ||
{actions.map( | ||
({ name: nestedActionName, onClick: onClickNested, ...props }) => ( | ||
<MenuItem | ||
{...props} | ||
key={nestedActionName} | ||
onClick={onActionClick(onClickNested)} | ||
> | ||
{nestedActionName} | ||
</MenuItem> | ||
), | ||
)} | ||
</IconDropdownButton> | ||
</Tooltip> | ||
); | ||
} | ||
|
||
const { | ||
onClick, | ||
name, | ||
icon, | ||
disabledReason, | ||
disabled, | ||
loading, | ||
isBlockingOperation, | ||
loadingNote, | ||
...actions | ||
} = action; | ||
|
||
const title = !loading && (disabledReason || name); | ||
|
||
return ( | ||
<Tooltip | ||
key={name} | ||
title={title} | ||
withoutContainer={!disabled} | ||
placement={tooltipPlacement} | ||
> | ||
<IconButton | ||
disabled={isDisabled || disabled} | ||
loading={loading} | ||
{...actions} | ||
variant="text" | ||
onClick={onActionClick(onClick)} | ||
> | ||
{icon} | ||
</IconButton> | ||
</Tooltip> | ||
); | ||
}; |
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 @@ | ||
export * from './MainAction'; |
Oops, something went wrong.