-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'devel' into CB-5340-unit-tests-for-basic-core-blocks-hooks
- Loading branch information
Showing
216 changed files
with
1,904 additions
and
1,781 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0. | ||
* you may not use this file except in compliance with the License. | ||
*/ | ||
import { observer } from 'mobx-react-lite'; | ||
import { useState } from 'react'; | ||
|
||
import { TableItemGroupContext } from './TableItemGroupContext'; | ||
|
||
export interface TableItemGroupProps extends React.PropsWithChildren { | ||
expanded?: boolean; | ||
} | ||
|
||
export const TableItemGroup = observer<TableItemGroupProps>(function TableItemGroup({ expanded = true, children }) { | ||
const [internalExpanded, setExpanded] = useState(expanded); | ||
|
||
return <TableItemGroupContext.Provider value={{ expanded: internalExpanded, setExpanded }}>{children}</TableItemGroupContext.Provider>; | ||
}); |
29 changes: 29 additions & 0 deletions
29
webapp/packages/core-blocks/src/Table/TableItemGroupContent.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,29 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0. | ||
* you may not use this file except in compliance with the License. | ||
*/ | ||
import { observer } from 'mobx-react-lite'; | ||
import { useContext } from 'react'; | ||
|
||
import { TableItemGroupContext } from './TableItemGroupContext'; | ||
|
||
export interface TableItemGroupContentProps { | ||
children?: React.ReactNode | (() => React.ReactNode); | ||
} | ||
|
||
export const TableItemGroupContent = observer<TableItemGroupContentProps>(function TableItemGroupContent({ children }) { | ||
const context = useContext(TableItemGroupContext); | ||
|
||
if (!context) { | ||
throw new Error('TableItemGroupContent can be used only inside TableItemGroup'); | ||
} | ||
|
||
if (!context.expanded) { | ||
return null; | ||
} | ||
|
||
return <>{typeof children === 'function' ? children() : children}</>; | ||
}); |
14 changes: 14 additions & 0 deletions
14
webapp/packages/core-blocks/src/Table/TableItemGroupContext.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,14 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0. | ||
* you may not use this file except in compliance with the License. | ||
*/ | ||
import { createContext } from 'react'; | ||
|
||
export interface ITableItemGroupContext { | ||
expanded: boolean; | ||
setExpanded: (expanded: boolean) => void; | ||
} | ||
export const TableItemGroupContext = createContext<ITableItemGroupContext | undefined>(undefined); |
Oops, something went wrong.