-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1680 from Adslot/tree-picker
[ADS-7903] feat: new tree picker
- Loading branch information
Showing
60 changed files
with
2,145 additions
and
276 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,32 @@ | ||
@import url('../../styles/variable.css'); | ||
|
||
.aui--tree-picker { | ||
& .aui--tree-picker-row + .aui--tree-picker-tree { | ||
border-top: 1px solid $color-border-base; | ||
} | ||
} | ||
|
||
.aui--tree-picker-section { | ||
margin-top: 16px; | ||
margin-bottom: 16px; | ||
} | ||
|
||
.aui--tree-picker-row { | ||
padding: 0 2px; | ||
min-height: 36px; | ||
display: flex; | ||
align-items: center; | ||
position: relative; | ||
gap: 12px; | ||
border-top: 1px solid $color-border-base; | ||
|
||
& .aui--button.aui-icon { | ||
width: 24px; | ||
height: 24px; | ||
min-height: 24px; | ||
} | ||
} | ||
|
||
.aui--tree-picker-row-content { | ||
flex: 1; | ||
} |
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,38 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import cc from 'classnames'; | ||
import { TreePickerProvider } from './TreePickerContext'; | ||
import TreePickerTree from './TreePickerTree'; | ||
import TreePickerHeader from './TreePickerHeader'; | ||
import TreePickerNode from './TreePickerNode'; | ||
import TreePickerNav from './TreePickerNav'; | ||
import TreePickerSearch from './TreePickerSearch'; | ||
|
||
import './TreePicker.css'; | ||
|
||
const TreePicker = ({ children, renderNode, className }) => { | ||
const renderNodeWithKey = React.useCallback( | ||
(node, index) => <React.Fragment key={node.id}>{renderNode(node, index)}</React.Fragment>, | ||
[renderNode] | ||
); | ||
|
||
return ( | ||
<TreePickerProvider renderNode={renderNodeWithKey}> | ||
<div className={cc('tree-picker', className)}>{children}</div> | ||
</TreePickerProvider> | ||
); | ||
}; | ||
|
||
TreePicker.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
renderNode: PropTypes.func.isRequired, | ||
className: PropTypes.string, | ||
}; | ||
|
||
TreePicker.Tree = TreePickerTree; | ||
TreePicker.Header = TreePickerHeader; | ||
TreePicker.Node = TreePickerNode; | ||
TreePicker.Nav = TreePickerNav; | ||
TreePicker.Search = TreePickerSearch; | ||
|
||
export default TreePicker; |
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,34 @@ | ||
import { Meta, ArgTypes, Story, Stories } from '@storybook/blocks'; | ||
import * as TreePickerStories from './TreePicker.stories'; | ||
import * as TreePickerHeaderStories from './TreePickerHeader.stories'; | ||
import * as TreePickerNodeStories from './TreePickerNode.stories'; | ||
import * as TreePickerSearchStories from './TreePickerSearch.stories'; | ||
import * as TreePickerNavStories from './TreePickerNav.stories'; | ||
|
||
<Meta title="Components/TreePicker" /> | ||
|
||
# TreePicker | ||
|
||
`TreePicker` is a complex component with many sub components for composition. It is intended to be used for displaying multiple layers of data, with the capability of adding and expanding a particular node. | ||
|
||
`TreePicker` | ||
|
||
<ArgTypes of={TreePickerStories} /> | ||
|
||
`TreePicker.Node` | ||
|
||
<ArgTypes of={TreePickerNodeStories} /> | ||
|
||
`TreePicker.Search` | ||
|
||
<ArgTypes of={TreePickerSearchStories} /> | ||
|
||
`TreePicker.Header` | ||
|
||
<ArgTypes of={TreePickerSearchStories} /> | ||
|
||
`TreePicker.Nav` | ||
|
||
<ArgTypes of={TreePickerNavStories} /> | ||
|
||
<Story of={TreePickerStories.Basic} /> |
Oops, something went wrong.