-
Notifications
You must be signed in to change notification settings - Fork 0
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
12 changed files
with
689 additions
and
646 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { createListCollection } from '@ark-ui/solid/combobox' | ||
export * as Combobox from './styled/combobox' |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export { createListCollection } from '@ark-ui/solid/select' | ||
export * as Select from './styled/select' |
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 |
---|---|---|
@@ -1,65 +1,54 @@ | ||
import { For, Show, splitProps } from 'solid-js' | ||
import { CheckSquareIcon, ChevronRightIcon, FileIcon, FolderIcon } from 'lucide-solid' | ||
import { For, Show } from 'solid-js' | ||
import * as StyledTreeView from './styled/tree-view' | ||
|
||
interface Child { | ||
value: string | ||
name: string | ||
children?: Child[] | ||
} | ||
|
||
export interface TreeViewData { | ||
label: string | ||
children: Child[] | ||
} | ||
|
||
export interface TreeViewProps extends StyledTreeView.RootProps { | ||
data: TreeViewData | ||
} | ||
export const TreeView = (props: TreeViewProps) => { | ||
const [localProps, rootProps] = splitProps(props, ['data']) | ||
|
||
const renderChild = (child: Child) => ( | ||
<Show | ||
when={child.children} | ||
fallback={ | ||
<StyledTreeView.Item value={child.value}> | ||
<StyledTreeView.ItemText>{child.name}</StyledTreeView.ItemText> | ||
</StyledTreeView.Item> | ||
} | ||
> | ||
<StyledTreeView.Branch value={child.value}> | ||
<StyledTreeView.BranchControl> | ||
<StyledTreeView.BranchIndicator> | ||
<ChevronRightIcon /> | ||
</StyledTreeView.BranchIndicator> | ||
<StyledTreeView.BranchText>{child.name}</StyledTreeView.BranchText> | ||
</StyledTreeView.BranchControl> | ||
<StyledTreeView.BranchContent> | ||
<For each={child.children}>{(child) => renderChild(child)}</For> | ||
</StyledTreeView.BranchContent> | ||
</StyledTreeView.Branch> | ||
</Show> | ||
) | ||
|
||
export const TreeView = (props: StyledTreeView.RootProps) => { | ||
return ( | ||
<StyledTreeView.Root aria-label={localProps.data.label} {...rootProps}> | ||
<StyledTreeView.Root {...props}> | ||
<StyledTreeView.Tree> | ||
<For each={localProps.data.children}>{(child) => renderChild(child)}</For> | ||
<For each={props.collection.rootNode.children}> | ||
{(node, index) => <TreeNode node={node} indexPath={[index()]} />} | ||
</For> | ||
</StyledTreeView.Tree> | ||
</StyledTreeView.Root> | ||
) | ||
} | ||
|
||
const ChevronRightIcon = () => ( | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> | ||
<title>Chevron Right Icon</title> | ||
<path | ||
fill="none" | ||
stroke="currentColor" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="2" | ||
d="m9 18l6-6l-6-6" | ||
/> | ||
</svg> | ||
) | ||
const TreeNode = (props: StyledTreeView.NodeProviderProps) => { | ||
const { node, indexPath } = props | ||
return ( | ||
<StyledTreeView.NodeProvider node={node} indexPath={indexPath}> | ||
<Show | ||
when={node.children} | ||
fallback={ | ||
<StyledTreeView.Item> | ||
<StyledTreeView.ItemIndicator> | ||
<CheckSquareIcon /> | ||
</StyledTreeView.ItemIndicator> | ||
<StyledTreeView.ItemText> | ||
<FileIcon /> | ||
{node.name} | ||
</StyledTreeView.ItemText> | ||
</StyledTreeView.Item> | ||
} | ||
> | ||
<StyledTreeView.Branch> | ||
<StyledTreeView.BranchControl> | ||
<StyledTreeView.BranchText> | ||
<FolderIcon /> {node.name} | ||
</StyledTreeView.BranchText> | ||
<StyledTreeView.BranchIndicator> | ||
<ChevronRightIcon /> | ||
</StyledTreeView.BranchIndicator> | ||
</StyledTreeView.BranchControl> | ||
<StyledTreeView.BranchContent> | ||
<StyledTreeView.BranchIndentGuide /> | ||
<For each={node.children}> | ||
{(child, index) => <TreeNode node={child} indexPath={[...indexPath, index()]} />} | ||
</For> | ||
</StyledTreeView.BranchContent> | ||
</StyledTreeView.Branch> | ||
</Show> | ||
</StyledTreeView.NodeProvider> | ||
) | ||
} |
Oops, something went wrong.