mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 04:13:02 +00:00
feat(tree-view): add TreeView
This commit is contained in:
parent
f4a3646cb4
commit
cf6331820c
18 changed files with 648 additions and 1 deletions
67
types/TreeView/TreeView.d.ts
vendored
Normal file
67
types/TreeView/TreeView.d.ts
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
/// <reference types="svelte" />
|
||||
import { SvelteComponentTyped } from "svelte";
|
||||
|
||||
export type TreeNodeId = string | number;
|
||||
|
||||
export interface TreeNode {
|
||||
id: TreeNodeId;
|
||||
text: string;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export interface TreeViewProps
|
||||
extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["ul"]> {
|
||||
/**
|
||||
* Provide an array of children nodes to render
|
||||
* @default []
|
||||
*/
|
||||
children?: TreeNode & { children?: TreeNode[] };
|
||||
|
||||
/**
|
||||
* Set the current active node id
|
||||
* Only one node can be active
|
||||
* @default ""
|
||||
*/
|
||||
activeId?: TreeNodeId;
|
||||
|
||||
/**
|
||||
* Set to `true` to allow multiple selected nodes
|
||||
* @default false
|
||||
*/
|
||||
multiselect?: boolean;
|
||||
|
||||
/**
|
||||
* Set the node ids to be selected
|
||||
* @default []
|
||||
*/
|
||||
selectedIds?: TreeNodeIds;
|
||||
|
||||
/**
|
||||
* Specify the TreeView size
|
||||
* @default "default"
|
||||
*/
|
||||
size?: "default" | "compact";
|
||||
|
||||
/**
|
||||
* Specify the label text
|
||||
* @default ""
|
||||
*/
|
||||
labelText?: string;
|
||||
|
||||
/**
|
||||
* Set to `true` to visually hide the label text
|
||||
* @default false
|
||||
*/
|
||||
hideLabel?: boolean;
|
||||
}
|
||||
|
||||
export default class TreeView extends SvelteComponentTyped<
|
||||
TreeViewProps,
|
||||
{
|
||||
select: CustomEvent<TreeNode & { expanded: boolean; leaf: boolean }>;
|
||||
toggle: CustomEvent<TreeNode & { expanded: boolean; leaf: boolean }>;
|
||||
focus: CustomEvent<TreeNode & { expanded: boolean; leaf: boolean }>;
|
||||
keydown: WindowEventMap["keydown"];
|
||||
},
|
||||
{ labelText: {} }
|
||||
> {}
|
1
types/index.d.ts
vendored
1
types/index.d.ts
vendored
|
@ -144,6 +144,7 @@ export { default as Tooltip } from "./Tooltip/Tooltip";
|
|||
export { default as TooltipFooter } from "./Tooltip/TooltipFooter";
|
||||
export { default as TooltipDefinition } from "./TooltipDefinition/TooltipDefinition";
|
||||
export { default as TooltipIcon } from "./TooltipIcon/TooltipIcon";
|
||||
export { default as TreeView } from "./TreeView/TreeView";
|
||||
export { default as Truncate } from "./Truncate/Truncate";
|
||||
export { default as Header } from "./UIShell/GlobalHeader/Header";
|
||||
export { default as HeaderAction } from "./UIShell/GlobalHeader/HeaderAction";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue