Merge branch 'master' into patch-1

This commit is contained in:
Daniel Miedzik 2021-10-14 10:41:14 +02:00
commit a2494ad128
20 changed files with 506 additions and 14 deletions

View file

@ -708,6 +708,17 @@
"moduleName": "Checkbox",
"filePath": "src/Checkbox/Checkbox.svelte",
"props": [
{
"name": "value",
"kind": "let",
"description": "Specify the value of the checkbox",
"type": "string",
"value": "\"\"",
"isFunction": false,
"isFunctionDeclaration": false,
"constant": false,
"reactive": false
},
{
"name": "checked",
"kind": "let",
@ -13152,6 +13163,50 @@
"isFunctionDeclaration": false,
"constant": false,
"reactive": false
},
{
"name": "expandAll",
"kind": "function",
"description": "Programmatically expand all nodes",
"type": "() => void",
"value": "() => { expandedIds = [...nodeIds]; }",
"isFunction": true,
"isFunctionDeclaration": true,
"constant": false,
"reactive": false
},
{
"name": "collapseAll",
"kind": "function",
"description": "Programmatically collapse all nodes",
"type": "() => void",
"value": "() => { expandedIds = []; }",
"isFunction": true,
"isFunctionDeclaration": true,
"constant": false,
"reactive": false
},
{
"name": "expandNodes",
"kind": "function",
"description": "Programmatically expand a subset of nodes.\nExpands all nodes if no argument is provided",
"type": "(filterId?: (node: TreeNode) => boolean) => void",
"value": "() => { expandedIds = nodes .filter((node) => !filterNode(node)) .map((node) => node.id); }",
"isFunction": true,
"isFunctionDeclaration": true,
"constant": false,
"reactive": false
},
{
"name": "collapseNodes",
"kind": "function",
"description": "Programmatically collapse a subset of nodes.\nCollapses all nodes if no argument is provided",
"type": "(filterId?: (node: TreeNode) => boolean) => void",
"value": "() => { expandedIds = nodes .filter((node) => !filterNode(node)) .map((node) => node.id); }",
"isFunction": true,
"isFunctionDeclaration": true,
"constant": false,
"reactive": false
}
],
"slots": [

View file

@ -1,3 +1,7 @@
---
source: TextInput/PasswordInput.svelte
---
<script>
import { PasswordInput } from "carbon-components-svelte";
import Preview from "../../components/Preview.svelte";

View file

@ -1,5 +1,6 @@
---
components: ["TileGroup", "RadioTile"]
source: Tile/RadioTile.svelte
---
<script>

View file

@ -1,5 +1,6 @@
---
components: ["SelectableTile"]
source: Tile/SelectableTile.svelte
---
<script>

View file

@ -45,4 +45,34 @@ Expanded nodes can be set using `expandedIds`.
Initial multiple selected nodes can be set using `selectedIds`.
<FileSource src="/framed/TreeView/TreeViewMultiselect" />
<FileSource src="/framed/TreeView/TreeViewMultiselect" />
### Expand all nodes
To programmatically expand all nodes, access the component instance using the [bind:this](https://svelte.dev/docs#bind_element) directive and invoke the `TreeView.expandAll()` method to expand all nodes.
<FileSource src="/framed/TreeView/TreeViewExpandAll" />
### Collapse all nodes
Similarly, invoke `TreeView.collapseAll()` to collapse all nodes.
<FileSource src="/framed/TreeView/TreeViewCollapseAll" />
### Expand a subset of nodes
Use the `TreeView.expandNodes` method to expand only a subset of nodes.
The method accepts an argument that takes a node and returns a boolean.
If no argument is provided, all nodes will be expanded.
<FileSource src="/framed/TreeView/TreeViewExpandNodes" />
### Collapse a subset of nodes
Use the `TreeView.collapseNodes` method to collapse a subset of nodes.
If no argument is provided, all nodes will be collapsed.
<FileSource src="/framed/TreeView/TreeViewCollapseNodes" />

View file

@ -0,0 +1,63 @@
<script>
import { TreeView, Button } from "carbon-components-svelte";
let treeview = null;
let expandedIds = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
let children = [
{ id: 0, text: "AI / Machine learning" },
{
id: 1,
text: "Analytics",
children: [
{
id: 2,
text: "IBM Analytics Engine",
children: [
{ id: 3, text: "Apache Spark" },
{ id: 4, text: "Hadoop" },
],
},
{ id: 5, text: "IBM Cloud SQL Query" },
{ id: 6, text: "IBM Db2 Warehouse on Cloud" },
],
},
{
id: 7,
text: "Blockchain",
children: [{ id: 8, text: "IBM Blockchain Platform" }],
},
{
id: 9,
text: "Databases",
children: [
{ id: 10, text: "IBM Cloud Databases for Elasticsearch" },
{ id: 11, text: "IBM Cloud Databases for Enterprise DB" },
{ id: 12, text: "IBM Cloud Databases for MongoDB" },
{ id: 13, text: "IBM Cloud Databases for PostgreSQL" },
],
},
{
id: 14,
text: "Integration",
disabled: true,
children: [{ id: 15, text: "IBM API Connect", disabled: true }],
},
];
</script>
<div>
<Button on:click="{treeview?.collapseAll}">Collapse all</Button>
</div>
<TreeView
bind:this="{treeview}"
bind:expandedIds
labelText="Cloud Products"
children="{children}"
/>
<style>
div {
margin-bottom: var(--cds-spacing-05);
}
</style>

View file

@ -0,0 +1,71 @@
<script>
import { TreeView, Button } from "carbon-components-svelte";
let treeview = null;
let expandedIds = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 14];
let children = [
{ id: 0, text: "AI / Machine learning" },
{
id: 1,
text: "Analytics",
disabled: true,
children: [
{
id: 2,
text: "IBM Analytics Engine",
disabled: true,
children: [
{ id: 3, text: "Apache Spark", disabled: true },
{ id: 4, text: "Hadoop", disabled: true },
],
},
{ id: 5, text: "IBM Cloud SQL Query", disabled: true },
{ id: 6, text: "IBM Db2 Warehouse on Cloud", disabled: true },
],
},
{
id: 7,
text: "Blockchain",
children: [{ id: 8, text: "IBM Blockchain Platform" }],
},
{
id: 9,
text: "Databases",
children: [
{ id: 10, text: "IBM Cloud Databases for Elasticsearch" },
{ id: 11, text: "IBM Cloud Databases for Enterprise DB" },
{ id: 12, text: "IBM Cloud Databases for MongoDB" },
{ id: 13, text: "IBM Cloud Databases for PostgreSQL" },
],
},
{
id: 14,
text: "Integration",
disabled: true,
children: [{ id: 15, text: "IBM API Connect", disabled: true }],
},
];
</script>
<div>
<Button
on:click="{() => {
treeview?.collapseNodes((node) => node.disabled);
}}"
>
Collapse disabled nodes
</Button>
</div>
<TreeView
bind:this="{treeview}"
bind:expandedIds
labelText="Cloud Products"
children="{children}"
/>
<style>
div {
margin-bottom: var(--cds-spacing-05);
}
</style>

View file

@ -0,0 +1,61 @@
<script>
import { TreeView, Button } from "carbon-components-svelte";
let treeview = null;
let children = [
{ id: 0, text: "AI / Machine learning" },
{
id: 1,
text: "Analytics",
children: [
{
id: 2,
text: "IBM Analytics Engine",
children: [
{ id: 3, text: "Apache Spark" },
{ id: 4, text: "Hadoop" },
],
},
{ id: 5, text: "IBM Cloud SQL Query" },
{ id: 6, text: "IBM Db2 Warehouse on Cloud" },
],
},
{
id: 7,
text: "Blockchain",
children: [{ id: 8, text: "IBM Blockchain Platform" }],
},
{
id: 9,
text: "Databases",
children: [
{ id: 10, text: "IBM Cloud Databases for Elasticsearch" },
{ id: 11, text: "IBM Cloud Databases for Enterprise DB" },
{ id: 12, text: "IBM Cloud Databases for MongoDB" },
{ id: 13, text: "IBM Cloud Databases for PostgreSQL" },
],
},
{
id: 14,
text: "Integration",
disabled: true,
children: [{ id: 15, text: "IBM API Connect", disabled: true }],
},
];
</script>
<div>
<Button on:click="{treeview?.expandAll}">Expand all</Button>
</div>
<TreeView
bind:this="{treeview}"
labelText="Cloud Products"
children="{children}"
/>
<style>
div {
margin-bottom: var(--cds-spacing-05);
}
</style>

View file

@ -0,0 +1,67 @@
<script>
import { TreeView, Button } from "carbon-components-svelte";
let treeview = null;
let children = [
{ id: 0, text: "AI / Machine learning" },
{
id: 1,
text: "Analytics",
children: [
{
id: 2,
text: "IBM Analytics Engine",
children: [
{ id: 3, text: "Apache Spark" },
{ id: 4, text: "Hadoop" },
],
},
{ id: 5, text: "IBM Cloud SQL Query" },
{ id: 6, text: "IBM Db2 Warehouse on Cloud" },
],
},
{
id: 7,
text: "Blockchain",
children: [{ id: 8, text: "IBM Blockchain Platform" }],
},
{
id: 9,
text: "Databases",
children: [
{ id: 10, text: "IBM Cloud Databases for Elasticsearch" },
{ id: 11, text: "IBM Cloud Databases for Enterprise DB" },
{ id: 12, text: "IBM Cloud Databases for MongoDB" },
{ id: 13, text: "IBM Cloud Databases for PostgreSQL" },
],
},
{
id: 14,
text: "Integration",
disabled: true,
children: [{ id: 15, text: "IBM API Connect", disabled: true }],
},
];
</script>
<div>
<Button
on:click="{() => {
treeview?.expandNodes((node) => /^IBM/.test(node.text));
}}"
>
Expand nodes starting with "IBM"
</Button>
</div>
<TreeView
bind:this="{treeview}"
labelText="Cloud Products"
children="{children}"
/>
<style>
div {
margin-bottom: var(--cds-spacing-05);
}
</style>