@skeletonlabs/skeleton 2.3.0-dev.041af337 → 2.3.0-dev.2e060a2e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Table/Table.svelte +1 -1
- package/dist/components/TreeView/RecursiveTreeView.svelte +21 -2
- package/dist/components/TreeView/RecursiveTreeView.svelte.d.ts +5 -0
- package/dist/components/TreeView/RecursiveTreeViewItem.svelte +29 -3
- package/dist/components/TreeView/RecursiveTreeViewItem.svelte.d.ts +3 -0
- package/dist/components/TreeView/types.d.ts +9 -4
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>import { setContext } from "svelte";
|
|
1
|
+
<script>import { createEventDispatcher, setContext } from "svelte";
|
|
2
2
|
import RecursiveTreeViewItem from "./RecursiveTreeViewItem.svelte";
|
|
3
3
|
export let selection = false;
|
|
4
4
|
export let multiple = false;
|
|
@@ -38,6 +38,17 @@ setContext("hyphenOpacity", hyphenOpacity);
|
|
|
38
38
|
setContext("regionSummary", regionSummary);
|
|
39
39
|
setContext("regionSymbol", regionSymbol);
|
|
40
40
|
setContext("regionChildren", regionChildren);
|
|
41
|
+
const dispatch = createEventDispatcher();
|
|
42
|
+
function onClick(event) {
|
|
43
|
+
dispatch("click", {
|
|
44
|
+
id: event.detail.id
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function onToggle(event) {
|
|
48
|
+
dispatch("toggle", {
|
|
49
|
+
id: event.detail.id
|
|
50
|
+
});
|
|
51
|
+
}
|
|
41
52
|
$:
|
|
42
53
|
classesBase = `${width} ${spacing} ${$$props.class ?? ""}`;
|
|
43
54
|
</script>
|
|
@@ -51,6 +62,14 @@ $:
|
|
|
51
62
|
aria-disabled={disabled}
|
|
52
63
|
>
|
|
53
64
|
{#if nodes && nodes.length > 0}
|
|
54
|
-
<RecursiveTreeViewItem
|
|
65
|
+
<RecursiveTreeViewItem
|
|
66
|
+
{nodes}
|
|
67
|
+
bind:expandedNodes
|
|
68
|
+
bind:disabledNodes
|
|
69
|
+
bind:checkedNodes
|
|
70
|
+
bind:indeterminateNodes
|
|
71
|
+
on:click={onClick}
|
|
72
|
+
on:toggle={onToggle}
|
|
73
|
+
/>
|
|
55
74
|
{/if}
|
|
56
75
|
</div>
|
|
@@ -50,6 +50,11 @@ declare const __propDef: {
|
|
|
50
50
|
labelledby?: string | undefined;
|
|
51
51
|
};
|
|
52
52
|
events: {
|
|
53
|
+
/** {{id:string}} click - Fires on tree item click*/
|
|
54
|
+
click: CustomEvent<any>;
|
|
55
|
+
/** {{id:string}} toggle - Fires on tree item toggle*/
|
|
56
|
+
toggle: CustomEvent<any>;
|
|
57
|
+
} & {
|
|
53
58
|
[evt: string]: CustomEvent<any>;
|
|
54
59
|
};
|
|
55
60
|
slots: {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import TreeViewItem from "./TreeViewItem.svelte";
|
|
2
2
|
import RecursiveTreeViewItem from "./RecursiveTreeViewItem.svelte";
|
|
3
|
-
import { getContext, onMount, tick } from "svelte";
|
|
3
|
+
import { createEventDispatcher, getContext, onMount, tick } from "svelte";
|
|
4
4
|
export let nodes = [];
|
|
5
5
|
export let expandedNodes = [];
|
|
6
6
|
export let disabledNodes = [];
|
|
@@ -12,6 +12,7 @@ let relational = getContext("relational");
|
|
|
12
12
|
let tempCheckedNodes = [];
|
|
13
13
|
let group;
|
|
14
14
|
let name = "";
|
|
15
|
+
const dispatch = createEventDispatcher();
|
|
15
16
|
function toggleNode(node, open) {
|
|
16
17
|
if (!node.children?.length)
|
|
17
18
|
return;
|
|
@@ -94,10 +95,27 @@ let children = [];
|
|
|
94
95
|
indeterminate={indeterminateNodes.includes(node.id)}
|
|
95
96
|
on:toggle={(e) => toggleNode(node, e.detail.open)}
|
|
96
97
|
on:groupChange={(e) => checkNode(node, e.detail.checked, e.detail.indeterminate)}
|
|
98
|
+
on:click={() =>
|
|
99
|
+
dispatch('click', {
|
|
100
|
+
id: node.id
|
|
101
|
+
})}
|
|
102
|
+
on:toggle={() => {
|
|
103
|
+
dispatch('toggle', {
|
|
104
|
+
id: node.id
|
|
105
|
+
});
|
|
106
|
+
}}
|
|
97
107
|
>
|
|
98
|
-
{
|
|
108
|
+
{#if typeof node.content === 'string'}
|
|
109
|
+
{@html node.content}
|
|
110
|
+
{:else}
|
|
111
|
+
<svelte:component this={node.content} {...node.contentProps} />
|
|
112
|
+
{/if}
|
|
99
113
|
<svelte:fragment slot="lead">
|
|
100
|
-
{
|
|
114
|
+
{#if typeof node.lead === 'string'}
|
|
115
|
+
{@html node.lead}
|
|
116
|
+
{:else}
|
|
117
|
+
<svelte:component this={node.lead} {...node.leadProps} />
|
|
118
|
+
{/if}
|
|
101
119
|
</svelte:fragment>
|
|
102
120
|
<svelte:fragment slot="children">
|
|
103
121
|
<RecursiveTreeViewItem
|
|
@@ -107,6 +125,14 @@ let children = [];
|
|
|
107
125
|
bind:checkedNodes
|
|
108
126
|
bind:indeterminateNodes
|
|
109
127
|
bind:treeItems={children[i]}
|
|
128
|
+
on:click={(e) =>
|
|
129
|
+
dispatch('click', {
|
|
130
|
+
id: e.detail.id
|
|
131
|
+
})}
|
|
132
|
+
on:toggle={(e) =>
|
|
133
|
+
dispatch('toggle', {
|
|
134
|
+
id: e.detail.id
|
|
135
|
+
})}
|
|
110
136
|
/>
|
|
111
137
|
</svelte:fragment>
|
|
112
138
|
</TreeViewItem>
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import type { ComponentType } from 'svelte';
|
|
1
2
|
export interface TreeViewNode {
|
|
2
3
|
/** Nodes Unique ID */
|
|
3
4
|
id: string;
|
|
4
|
-
/** Main content. accepts HTML. */
|
|
5
|
-
content: string;
|
|
6
|
-
/**
|
|
7
|
-
|
|
5
|
+
/** Main content. accepts HTML or svelte component. */
|
|
6
|
+
content: string | ComponentType;
|
|
7
|
+
/** Main content props. only used when the Content is a svelte component. */
|
|
8
|
+
contentProps?: object;
|
|
9
|
+
/** Lead content. accepts HTML or svelte component. */
|
|
10
|
+
lead?: string | ComponentType;
|
|
11
|
+
/** lead props. only used when the Lead is a svelte component. */
|
|
12
|
+
leadProps?: object;
|
|
8
13
|
/** children nodes. */
|
|
9
14
|
children?: TreeViewNode[];
|
|
10
15
|
/** Set the input's value. */
|