|
1 | 1 | <script>
|
2 | 2 | import { TreeView, toHierarchy } from "carbon-components-svelte";
|
3 |
| - import WatsonMachineLearning from "carbon-icons-svelte/lib/WatsonMachineLearning.svelte"; |
4 | 3 | import Analytics from "carbon-icons-svelte/lib/Analytics.svelte";
|
5 |
| - import Blockchain from "carbon-icons-svelte/lib/Blockchain.svelte"; |
6 |
| - import DataBase from "carbon-icons-svelte/lib/DataBase.svelte"; |
7 |
| - import SignalStrength from "carbon-icons-svelte/lib/SignalStrength.svelte"; |
8 | 4 |
|
9 |
| - let activeId = ""; |
10 |
| - let selectedIds = []; |
11 | 5 | let nodesFlat = [
|
12 |
| - { id: 0, text: "AI / Machine learning", icon: WatsonMachineLearning }, |
13 |
| - { id: 1, text: "Analytics", icon: Analytics }, |
14 |
| - { id: 2, text: "IBM Analytics Engine", pid: 1, icon: Analytics }, |
15 |
| - { id: 3, text: "Apache Spark", pid: 2, icon: Analytics }, |
16 |
| - { id: 4, text: "Hadoop", icon: Analytics, pid: 2 }, |
17 |
| - { id: 5, text: "IBM Cloud SQL Query", icon: Analytics, pid: 1 }, |
18 |
| - { id: 6, text: "IBM Db2 Warehouse on Cloud", icon: Analytics, pid: 1 }, |
19 |
| - { id: 7, text: "Blockchain", icon: Blockchain }, |
20 |
| - { id: 8, text: "IBM Blockchain Platform", icon: Blockchain, pid: 7 }, |
21 |
| - { id: 9, text: "Databases", icon: DataBase }, |
22 |
| - { |
23 |
| - id: 10, |
24 |
| - text: "IBM Cloud Databases for Elasticsearch", |
25 |
| - icon: DataBase, |
26 |
| - pid: 9, |
27 |
| - }, |
28 |
| - { |
29 |
| - id: 11, |
30 |
| - text: "IBM Cloud Databases for Enterprise DB", |
31 |
| - icon: DataBase, |
32 |
| - pid: 9, |
33 |
| - }, |
34 |
| - { id: 12, text: "IBM Cloud Databases for MongoDB", icon: DataBase, pid: 9 }, |
35 |
| - { |
36 |
| - id: 13, |
37 |
| - text: "IBM Cloud Databases for PostgreSQL", |
38 |
| - icon: DataBase, |
39 |
| - pid: 9, |
40 |
| - }, |
41 |
| - { id: 14, text: "Integration", icon: SignalStrength, disabled: true }, |
42 |
| - { |
43 |
| - id: 15, |
44 |
| - text: "IBM API Connect", |
45 |
| - icon: SignalStrength, |
46 |
| - disabled: true, |
47 |
| - pid: 14, |
48 |
| - }, |
| 6 | + { id: 0, text: "AI / Machine learning", icon: Analytics }, |
| 7 | + { id: 1, text: "Analytics" }, |
| 8 | + { id: 2, text: "IBM Analytics Engine", pid: 1 }, |
| 9 | + { id: 3, text: "Apache Spark", pid: 2 }, |
| 10 | + { id: 4, text: "Hadoop", pid: 2 }, |
| 11 | + { id: 5, text: "IBM Cloud SQL Query", pid: 1 }, |
| 12 | + { id: 6, text: "IBM Db2 Warehouse on Cloud", pid: 1 }, |
| 13 | + { id: 7, text: "Blockchain" }, |
| 14 | + { id: 8, text: "IBM Blockchain Platform", pid: 7 }, |
| 15 | + { id: 9, text: "Databases" }, |
| 16 | + { id: 10, text: "IBM Cloud Databases for Elasticsearch", pid: 9 }, |
| 17 | + { id: 11, text: "IBM Cloud Databases for Enterprise DB", pid: 9 }, |
| 18 | + { id: 12, text: "IBM Cloud Databases for MongoDB", pid: 9 }, |
| 19 | + { id: 13, text: "IBM Cloud Databases for PostgreSQL", pid: 9 }, |
| 20 | + { id: 14, text: "Integration", disabled: true }, |
| 21 | + { id: 15, text: "IBM API Connect", disabled: true, pid: 14 }, |
49 | 22 | ];
|
50 | 23 | </script>
|
51 | 24 |
|
52 | 25 | <TreeView
|
53 | 26 | labelText="Cloud Products"
|
54 |
| - nodes={toHierarchy(nodesFlat)} |
55 |
| - bind:activeId |
56 |
| - bind:selectedIds |
57 |
| - on:select={({ detail }) => console.log("select", detail)} |
58 |
| - on:toggle={({ detail }) => console.log("toggle", detail)} |
59 |
| - on:focus={({ detail }) => console.log("focus", detail)} |
| 27 | + nodes={toHierarchy(nodesFlat, (node) => node.pid)} |
60 | 28 | />
|
61 |
| - |
62 |
| -<div>Active node id: {activeId}</div> |
63 |
| -<div>Selected ids: {JSON.stringify(selectedIds)}</div> |
64 |
| - |
65 |
| -<style> |
66 |
| - div { |
67 |
| - margin-top: var(--cds-spacing-05); |
68 |
| - } |
69 |
| -</style> |
0 commit comments