diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md
index ed8d98b0..45bce5e2 100644
--- a/COMPONENT_INDEX.md
+++ b/COMPONENT_INDEX.md
@@ -171,6 +171,7 @@
- [`TooltipDefinition`](#tooltipdefinition)
- [`TooltipFooter`](#tooltipfooter)
- [`TooltipIcon`](#tooltipicon)
+- [`TreeView`](#treeview)
- [`Truncate`](#truncate)
- [`UnorderedList`](#unorderedlist)
@@ -4649,6 +4650,47 @@ None.
| mouseleave | forwarded | -- |
| focus | forwarded | -- |
+## `TreeView`
+
+### Types
+
+```ts
+export type TreeNodeId = string | number;
+
+export interface TreeNode {
+ id: TreeNodeId;
+ text: string;
+ disabled?: boolean;
+}
+```
+
+### Props
+
+| Prop name | Kind | Reactive | Type | Default value | Description |
+| :---------- | :--------------- | :------- | :------------------------------------------------ | ---------------------- | --------------------------------------------------------------- |
+| selectedIds | let
| Yes | TreeNodeIds
| []
| Set the node ids to be selected |
+| activeId | let
| Yes | TreeNodeId
| ""
| Set the current active node id
Only one node can be active |
+| children | let
| No | TreeNode & { children?: TreeNode[] }
| []
| Provide an array of children nodes to render |
+| multiselect | let
| No | boolean
| false
| Set to `true` to allow multiple selected nodes |
+| size | let
| No | "default" | "compact"
| "default"
| Specify the TreeView size |
+| labelText | let
| No | string
| ""
| Specify the label text |
+| hideLabel | let
| No | boolean
| false
| Set to `true` to visually hide the label text |
+
+### Slots
+
+| Slot name | Default | Props | Fallback |
+| :-------- | :------ | :---- | :----------------------- |
+| labelText | No | -- | {labelText}
|
+
+### Events
+
+| Event name | Type | Detail |
+| :--------- | :--------- | :------------------------------------------------------------ |
+| select | dispatched | TreeNode & { expanded: boolean; leaf: boolean; }
|
+| toggle | dispatched | TreeNode & { expanded: boolean; leaf: boolean; }
|
+| focus | dispatched | TreeNode & { expanded: boolean; leaf: boolean; }
|
+| keydown | forwarded | -- |
+
## `Truncate`
### Props
diff --git a/css/all.scss b/css/all.scss
index 6679fa7a..ecbbd37f 100644
--- a/css/all.scss
+++ b/css/all.scss
@@ -76,5 +76,8 @@ $css--plex: true;
@import "carbon-components/scss/globals/scss/_css--body";
@import "carbon-components/scss/globals/grid/grid";
+// Import experimental TreeView styles not included in global styles
+@import "carbon-components/src/components/treeview/treeview";
+
// Import all component styles
@import "carbon-components/scss/globals/scss/styles";
diff --git a/css/g10.scss b/css/g10.scss
index e97cdb84..e77b2144 100644
--- a/css/g10.scss
+++ b/css/g10.scss
@@ -27,6 +27,9 @@ $carbon--theme: $carbon--theme--g10;
@import "carbon-components/scss/globals/scss/_css--body";
@import "carbon-components/scss/globals/grid/grid";
+// Import experimental TreeView styles not included in global styles
+@import "carbon-components/src/components/treeview/treeview";
+
// Import all component styles
@import "carbon-components/scss/globals/scss/styles";
diff --git a/css/g100.scss b/css/g100.scss
index 6828061d..b30327a8 100644
--- a/css/g100.scss
+++ b/css/g100.scss
@@ -27,5 +27,8 @@ $carbon--theme: $carbon--theme--g100;
@import "carbon-components/scss/globals/scss/_css--body";
@import "carbon-components/scss/globals/grid/grid";
+// Import experimental TreeView styles not included in global styles
+@import "carbon-components/src/components/treeview/treeview";
+
// Import all component styles
@import "carbon-components/scss/globals/scss/styles";
\ No newline at end of file
diff --git a/css/g80.scss b/css/g80.scss
index 9f5475c9..c0df672a 100644
--- a/css/g80.scss
+++ b/css/g80.scss
@@ -27,6 +27,9 @@ $carbon--theme: $carbon--theme--g80;
@import "carbon-components/scss/globals/scss/_css--body";
@import "carbon-components/scss/globals/grid/grid";
+// Import experimental TreeView styles not included in global styles
+@import "carbon-components/src/components/treeview/treeview";
+
// Import all component styles
@import "carbon-components/scss/globals/scss/styles";
diff --git a/css/g90.scss b/css/g90.scss
index abf54fa0..d219f985 100644
--- a/css/g90.scss
+++ b/css/g90.scss
@@ -27,5 +27,8 @@ $carbon--theme: $carbon--theme--g90;
@import "carbon-components/scss/globals/scss/_css--body";
@import "carbon-components/scss/globals/grid/grid";
+// Import experimental TreeView styles not included in global styles
+@import "carbon-components/src/components/treeview/treeview";
+
// Import all component styles
@import "carbon-components/scss/globals/scss/styles";
\ No newline at end of file
diff --git a/css/white.scss b/css/white.scss
index 9b4bd827..409b423f 100644
--- a/css/white.scss
+++ b/css/white.scss
@@ -27,5 +27,8 @@ $carbon--theme: $carbon--theme--white;
@import "carbon-components/scss/globals/scss/_css--body";
@import "carbon-components/scss/globals/grid/grid";
+// Import experimental TreeView styles not included in global styles
+@import "carbon-components/src/components/treeview/treeview";
+
// Import all component styles
@import "carbon-components/scss/globals/scss/styles";
\ No newline at end of file
diff --git a/docs/src/App.svelte b/docs/src/App.svelte
index 50709afa..95e62f70 100644
--- a/docs/src/App.svelte
+++ b/docs/src/App.svelte
@@ -84,6 +84,8 @@
@import "carbon-components/scss/globals/scss/_css--body";
@import "carbon-components/scss/globals/grid/grid";
+ @import "carbon-components/src/components/treeview/treeview";
+
// Import all component styles
@import "carbon-components/scss/globals/scss/styles";
diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json
index 675d727a..9b9d82a6 100644
--- a/docs/src/COMPONENT_API.json
+++ b/docs/src/COMPONENT_API.json
@@ -11834,6 +11834,121 @@
"typedefs": [],
"rest_props": { "type": "Element", "name": "button" }
},
+ {
+ "moduleName": "TreeView",
+ "filePath": "src/TreeView/TreeView.svelte",
+ "props": [
+ {
+ "name": "children",
+ "kind": "let",
+ "description": "Provide an array of children nodes to render",
+ "type": "TreeNode & { children?: TreeNode[] }",
+ "value": "[]",
+ "isFunction": false,
+ "constant": false,
+ "reactive": false
+ },
+ {
+ "name": "activeId",
+ "kind": "let",
+ "description": "Set the current active node id\nOnly one node can be active",
+ "type": "TreeNodeId",
+ "value": "\"\"",
+ "isFunction": false,
+ "constant": false,
+ "reactive": true
+ },
+ {
+ "name": "multiselect",
+ "kind": "let",
+ "description": "Set to `true` to allow multiple selected nodes",
+ "type": "boolean",
+ "value": "false",
+ "isFunction": false,
+ "constant": false,
+ "reactive": false
+ },
+ {
+ "name": "selectedIds",
+ "kind": "let",
+ "description": "Set the node ids to be selected",
+ "type": "TreeNodeIds",
+ "value": "[]",
+ "isFunction": false,
+ "constant": false,
+ "reactive": true
+ },
+ {
+ "name": "size",
+ "kind": "let",
+ "description": "Specify the TreeView size",
+ "type": "\"default\" | \"compact\"",
+ "value": "\"default\"",
+ "isFunction": false,
+ "constant": false,
+ "reactive": false
+ },
+ {
+ "name": "labelText",
+ "kind": "let",
+ "description": "Specify the label text",
+ "type": "string",
+ "value": "\"\"",
+ "isFunction": false,
+ "constant": false,
+ "reactive": false
+ },
+ {
+ "name": "hideLabel",
+ "kind": "let",
+ "description": "Set to `true` to visually hide the label text",
+ "type": "boolean",
+ "value": "false",
+ "isFunction": false,
+ "constant": false,
+ "reactive": false
+ }
+ ],
+ "slots": [
+ {
+ "name": "labelText",
+ "default": false,
+ "fallback": "{labelText}",
+ "slot_props": "{}"
+ }
+ ],
+ "events": [
+ {
+ "type": "dispatched",
+ "name": "select",
+ "detail": "TreeNode & { expanded: boolean; leaf: boolean; }"
+ },
+ {
+ "type": "dispatched",
+ "name": "toggle",
+ "detail": "TreeNode & { expanded: boolean; leaf: boolean; }"
+ },
+ {
+ "type": "dispatched",
+ "name": "focus",
+ "detail": "TreeNode & { expanded: boolean; leaf: boolean; }"
+ },
+ { "type": "forwarded", "name": "keydown", "element": "ul" }
+ ],
+ "typedefs": [
+ {
+ "type": "string | number",
+ "name": "TreeNodeId",
+ "ts": "type TreeNodeId = string | number"
+ },
+ {
+ "type": "{ id: TreeNodeId; text: string; disabled?: boolean; }",
+ "name": "TreeNode",
+ "ts": "interface TreeNode { id: TreeNodeId; text: string; disabled?: boolean; }"
+ }
+ ],
+ "rest_props": { "type": "Element", "name": "ul" }
+ },
{
"moduleName": "Truncate",
"filePath": "src/Truncate/Truncate.svelte",
diff --git a/docs/src/pages/_layout.svelte b/docs/src/pages/_layout.svelte
index 1fa85bb0..ddb35bb1 100644
--- a/docs/src/pages/_layout.svelte
+++ b/docs/src/pages/_layout.svelte
@@ -20,7 +20,7 @@
import Footer from "../components/Footer.svelte";
const deprecated = ["ToggleSmall", "Icon"];
- const new_components = ["ProgressBar", "RecursiveList"];
+ const new_components = ["ProgressBar", "RecursiveList", "TreeView"]];
let isOpen = false;
let isSideNavOpen = true;
diff --git a/docs/src/pages/components/TreeView.svx b/docs/src/pages/components/TreeView.svx
new file mode 100644
index 00000000..14b06a87
--- /dev/null
+++ b/docs/src/pages/components/TreeView.svx
@@ -0,0 +1,18 @@
+
+
+Note: every node MUST have an id.
+
+### Default
+
+