@skeletonlabs/skeleton 1.11.0-dev.fa91c649 → 1.12.0
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/TreeView/TreeView.svelte +2 -71
- package/dist/components/TreeView/TreeView.svelte.d.ts +0 -19
- package/dist/components/TreeView/TreeViewItem.svelte +10 -198
- package/dist/components/TreeView/TreeViewItem.svelte.d.ts +2 -90
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -1
- package/package.json +1 -1
- package/dist/components/TreeView/TreeViewDataDrivenItem.svelte +0 -70
- package/dist/components/TreeView/TreeViewDataDrivenItem.svelte.d.ts +0 -25
- package/dist/components/TreeView/types.d.ts +0 -18
- package/dist/components/TreeView/types.js +0 -1
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
<script>import { setContext } from "svelte";
|
|
2
|
-
import TreeViewDataDrivenItem from "./TreeViewDataDrivenItem.svelte";
|
|
3
|
-
export let selection = false;
|
|
4
|
-
export let multiple = false;
|
|
5
|
-
export let nodes = [];
|
|
6
2
|
export let width = "w-full";
|
|
7
3
|
export let spacing = "space-y-1";
|
|
8
|
-
export let open = false;
|
|
9
|
-
export let disabled = false;
|
|
10
4
|
export let padding = "py-4 px-4";
|
|
11
5
|
export let indent = "ml-4";
|
|
12
6
|
export let hover = "hover:variant-soft";
|
|
@@ -18,56 +12,6 @@ export let regionSummary = "";
|
|
|
18
12
|
export let regionSymbol = "";
|
|
19
13
|
export let regionChildren = "";
|
|
20
14
|
export let labelledby = "";
|
|
21
|
-
export function expandAll() {
|
|
22
|
-
const detailsElements = [...tree.querySelectorAll("details.tree-item")];
|
|
23
|
-
detailsElements.forEach((details) => {
|
|
24
|
-
if (!details.open) {
|
|
25
|
-
const summary = details.querySelector("summary.tree-item-summary");
|
|
26
|
-
if (summary)
|
|
27
|
-
summary.click();
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
export function collapseAll() {
|
|
32
|
-
const detailsElements = [...tree.querySelectorAll("details.tree-item")];
|
|
33
|
-
detailsElements.forEach((details) => {
|
|
34
|
-
if (details.open) {
|
|
35
|
-
const summary = details.querySelector("summary.tree-item-summary");
|
|
36
|
-
if (summary)
|
|
37
|
-
summary.click();
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
export function selectAll() {
|
|
42
|
-
const detailsElements = [...tree.querySelectorAll("details.tree-item")];
|
|
43
|
-
detailsElements.forEach((details) => {
|
|
44
|
-
const input = details.querySelector('input[type="checkbox"].tree-item-checkbox');
|
|
45
|
-
if (!input)
|
|
46
|
-
return;
|
|
47
|
-
if (!input.checked) {
|
|
48
|
-
setTimeout(() => {
|
|
49
|
-
input.click();
|
|
50
|
-
}, 5);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
export function deselectAll() {
|
|
55
|
-
const detailsElements = [...tree.querySelectorAll("details.tree-item")];
|
|
56
|
-
detailsElements.forEach((details) => {
|
|
57
|
-
const input = details.querySelector('input[type="checkbox"].tree-item-checkbox');
|
|
58
|
-
if (!input)
|
|
59
|
-
return;
|
|
60
|
-
if (input.checked) {
|
|
61
|
-
setTimeout(() => {
|
|
62
|
-
input.click();
|
|
63
|
-
}, 5);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
setContext("open", open);
|
|
68
|
-
setContext("selection", selection);
|
|
69
|
-
setContext("multiple", multiple);
|
|
70
|
-
setContext("disabled", disabled);
|
|
71
15
|
setContext("padding", padding);
|
|
72
16
|
setContext("indent", indent);
|
|
73
17
|
setContext("hover", hover);
|
|
@@ -80,21 +24,8 @@ setContext("regionSymbol", regionSymbol);
|
|
|
80
24
|
setContext("regionChildren", regionChildren);
|
|
81
25
|
$:
|
|
82
26
|
classesBase = `${width} ${spacing} ${$$props.class ?? ""}`;
|
|
83
|
-
let tree;
|
|
84
27
|
</script>
|
|
85
28
|
|
|
86
|
-
<div
|
|
87
|
-
|
|
88
|
-
class="tree {classesBase}"
|
|
89
|
-
data-testid="tree"
|
|
90
|
-
role="tree"
|
|
91
|
-
aria-multiselectable={multiple}
|
|
92
|
-
aria-label={labelledby}
|
|
93
|
-
aria-disabled={disabled}
|
|
94
|
-
>
|
|
95
|
-
{#if nodes && nodes.length > 0}
|
|
96
|
-
<TreeViewDataDrivenItem bind:nodes />
|
|
97
|
-
{:else}
|
|
98
|
-
<slot />
|
|
99
|
-
{/if}
|
|
29
|
+
<div class="tree {classesBase}" data-testid="tree" role="tree" aria-multiselectable="true" aria-label={labelledby}>
|
|
30
|
+
<slot />
|
|
100
31
|
</div>
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { TreeViewNode } from '../../index.js';
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
5
4
|
[x: string]: any;
|
|
6
|
-
/** Enable tree-view selection.*/
|
|
7
|
-
selection?: boolean | undefined;
|
|
8
|
-
/** Enable selection of multiple items.*/
|
|
9
|
-
multiple?: boolean | undefined;
|
|
10
|
-
/** Provide data-driven nodes.*/
|
|
11
|
-
nodes?: TreeViewNode[] | undefined;
|
|
12
5
|
/** Provide classes to set the tree width.*/
|
|
13
6
|
width?: string | undefined;
|
|
14
7
|
/** Provide classes to set the vertical spacing between items.*/
|
|
15
8
|
spacing?: string | undefined;
|
|
16
|
-
/** Set open by default on load.*/
|
|
17
|
-
open?: boolean | undefined;
|
|
18
|
-
/** Set the tree disabled state*/
|
|
19
|
-
disabled?: boolean | undefined;
|
|
20
9
|
/** Provide classes to set the tree item padding styles.*/
|
|
21
10
|
padding?: string | undefined;
|
|
22
11
|
/** Provide classes to set the tree children indentation*/
|
|
@@ -38,10 +27,6 @@ declare const __propDef: {
|
|
|
38
27
|
regionChildren?: string | undefined;
|
|
39
28
|
/** Provide the ARIA labelledby value.*/
|
|
40
29
|
labelledby?: string | undefined;
|
|
41
|
-
expandAll?: (() => void) | undefined;
|
|
42
|
-
collapseAll?: (() => void) | undefined;
|
|
43
|
-
selectAll?: (() => void) | undefined;
|
|
44
|
-
deselectAll?: (() => void) | undefined;
|
|
45
30
|
};
|
|
46
31
|
events: {
|
|
47
32
|
[evt: string]: CustomEvent<any>;
|
|
@@ -54,9 +39,5 @@ export type TreeViewProps = typeof __propDef.props;
|
|
|
54
39
|
export type TreeViewEvents = typeof __propDef.events;
|
|
55
40
|
export type TreeViewSlots = typeof __propDef.slots;
|
|
56
41
|
export default class TreeView extends SvelteComponentTyped<TreeViewProps, TreeViewEvents, TreeViewSlots> {
|
|
57
|
-
get expandAll(): () => void;
|
|
58
|
-
get collapseAll(): () => void;
|
|
59
|
-
get selectAll(): () => void;
|
|
60
|
-
get deselectAll(): () => void;
|
|
61
42
|
}
|
|
62
43
|
export {};
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
<!-- To access props and events using reference -->
|
|
2
|
-
<svelte:options accessors />
|
|
3
|
-
|
|
4
1
|
<script>import { getContext, createEventDispatcher } from "svelte";
|
|
5
|
-
export let
|
|
6
|
-
export let name = void 0;
|
|
7
|
-
export let value = void 0;
|
|
8
|
-
export let children = [];
|
|
2
|
+
export let open = false;
|
|
9
3
|
export let spacing = "space-x-4";
|
|
10
|
-
export let open = getContext("open");
|
|
11
|
-
export let selection = getContext("selection");
|
|
12
|
-
export let multiple = getContext("multiple");
|
|
13
|
-
export let disabled = getContext("disabled");
|
|
14
|
-
export let indeterminate = false;
|
|
15
4
|
export let padding = getContext("padding");
|
|
16
5
|
export let indent = getContext("indent");
|
|
17
6
|
export let hover = getContext("hover");
|
|
@@ -19,187 +8,22 @@ export let rounded = getContext("rounded");
|
|
|
19
8
|
export let caretOpen = getContext("caretOpen");
|
|
20
9
|
export let caretClosed = getContext("caretClosed");
|
|
21
10
|
export let hyphenOpacity = getContext("hyphenOpacity");
|
|
22
|
-
export let regionSummary =
|
|
11
|
+
export let regionSummary = "";
|
|
23
12
|
export let regionSymbol = getContext("regionSymbol");
|
|
24
13
|
export let regionChildren = getContext("regionChildren");
|
|
25
|
-
export let hideLead = false;
|
|
26
|
-
export let hideChildren = false;
|
|
27
|
-
let checked = false;
|
|
28
|
-
let treeItem;
|
|
29
|
-
let childrenDiv;
|
|
30
|
-
function onSummaryClick(event) {
|
|
31
|
-
if (disabled)
|
|
32
|
-
event.preventDefault();
|
|
33
|
-
}
|
|
34
|
-
$:
|
|
35
|
-
if (multiple)
|
|
36
|
-
updateCheckbox(group);
|
|
37
|
-
$:
|
|
38
|
-
if (multiple)
|
|
39
|
-
updateGroup(checked);
|
|
40
|
-
function updateCheckbox(group2) {
|
|
41
|
-
if (!Array.isArray(group2))
|
|
42
|
-
return;
|
|
43
|
-
checked = group2.indexOf(value) >= 0;
|
|
44
|
-
}
|
|
45
|
-
function updateGroup(checked2) {
|
|
46
|
-
if (!Array.isArray(group))
|
|
47
|
-
return;
|
|
48
|
-
const index = group.indexOf(value);
|
|
49
|
-
if (checked2) {
|
|
50
|
-
if (index < 0) {
|
|
51
|
-
group = [...group, value];
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
if (index >= 0) {
|
|
55
|
-
group.splice(index, 1);
|
|
56
|
-
group = group;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function onChildValueChange(event, child) {
|
|
61
|
-
if (multiple) {
|
|
62
|
-
if (!Array.isArray(group))
|
|
63
|
-
return;
|
|
64
|
-
const childrenValues = children.map((c) => c.value);
|
|
65
|
-
const index = group.indexOf(value);
|
|
66
|
-
if (childrenValues.every((c) => Array.isArray(child.group) && child.group.includes(c))) {
|
|
67
|
-
if (index < 0) {
|
|
68
|
-
indeterminate = false;
|
|
69
|
-
group = [...group, value];
|
|
70
|
-
}
|
|
71
|
-
} else {
|
|
72
|
-
if (index >= 0) {
|
|
73
|
-
group.splice(index, 1);
|
|
74
|
-
group = group;
|
|
75
|
-
}
|
|
76
|
-
indeterminate = childrenValues.some((c) => Array.isArray(child.group) && child.group.includes(c));
|
|
77
|
-
}
|
|
78
|
-
} else {
|
|
79
|
-
if (event.currentTarget.checked && group !== value) {
|
|
80
|
-
group = value;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function onGroupValueChange(_group) {
|
|
85
|
-
if (!children || children.length === 0 || indeterminate)
|
|
86
|
-
return;
|
|
87
|
-
if (multiple) {
|
|
88
|
-
if (!Array.isArray(_group))
|
|
89
|
-
return;
|
|
90
|
-
const index = _group.indexOf(value);
|
|
91
|
-
const checkChild = (child) => {
|
|
92
|
-
if (!child || !Array.isArray(child.group))
|
|
93
|
-
return;
|
|
94
|
-
if (child.group.indexOf(child.value) < 0) {
|
|
95
|
-
child.group.push(child.value);
|
|
96
|
-
child.group = child.group;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const uncheckChild = (child) => {
|
|
100
|
-
if (!child || !Array.isArray(child.group))
|
|
101
|
-
return;
|
|
102
|
-
const childIndex = child.group.indexOf(child.value);
|
|
103
|
-
if (childIndex >= 0) {
|
|
104
|
-
child.group.splice(childIndex, 1);
|
|
105
|
-
child.group = child.group;
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
children.forEach(index >= 0 ? checkChild : uncheckChild);
|
|
109
|
-
} else {
|
|
110
|
-
if (_group !== value) {
|
|
111
|
-
children.forEach((child) => {
|
|
112
|
-
child.group = [];
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
$:
|
|
118
|
-
onGroupValueChange(group);
|
|
119
14
|
const dispatch = createEventDispatcher();
|
|
120
15
|
$:
|
|
121
16
|
dispatch("toggle", { open });
|
|
122
|
-
$:
|
|
123
|
-
children.forEach((child) => {
|
|
124
|
-
if (child)
|
|
125
|
-
child.$on("change", (event) => onChildValueChange(event, child));
|
|
126
|
-
});
|
|
127
|
-
function onKeyDown(event) {
|
|
128
|
-
function getRootTree() {
|
|
129
|
-
let currentElement = treeItem;
|
|
130
|
-
while (currentElement !== null) {
|
|
131
|
-
if (currentElement.classList.contains("tree"))
|
|
132
|
-
return currentElement;
|
|
133
|
-
currentElement = currentElement.parentElement;
|
|
134
|
-
}
|
|
135
|
-
return void 0;
|
|
136
|
-
}
|
|
137
|
-
let rootTree = void 0;
|
|
138
|
-
let lastVisibleElement = null;
|
|
139
|
-
switch (event.code) {
|
|
140
|
-
case "ArrowRight":
|
|
141
|
-
if (!open)
|
|
142
|
-
open = true;
|
|
143
|
-
else if ($$slots.children && !hideChildren) {
|
|
144
|
-
const child = childrenDiv.querySelector("details>summary");
|
|
145
|
-
if (child)
|
|
146
|
-
child.focus();
|
|
147
|
-
}
|
|
148
|
-
break;
|
|
149
|
-
case "ArrowLeft":
|
|
150
|
-
if (open)
|
|
151
|
-
open = false;
|
|
152
|
-
else {
|
|
153
|
-
const parent = treeItem.parentElement?.parentElement;
|
|
154
|
-
if (parent && parent.tagName === "DETAILS")
|
|
155
|
-
parent.querySelector("summary").focus();
|
|
156
|
-
}
|
|
157
|
-
break;
|
|
158
|
-
case "Home":
|
|
159
|
-
event.preventDefault();
|
|
160
|
-
rootTree = getRootTree();
|
|
161
|
-
if (rootTree)
|
|
162
|
-
rootTree?.querySelector("summary")?.focus();
|
|
163
|
-
break;
|
|
164
|
-
case "End":
|
|
165
|
-
event.preventDefault();
|
|
166
|
-
rootTree = getRootTree();
|
|
167
|
-
if (rootTree) {
|
|
168
|
-
const detailsElements = rootTree?.querySelectorAll("details");
|
|
169
|
-
if (!detailsElements)
|
|
170
|
-
return;
|
|
171
|
-
for (let i = detailsElements.length - 1; i >= 0; i--) {
|
|
172
|
-
const details = detailsElements[i];
|
|
173
|
-
if (details.parentElement?.classList?.contains("tree") || details.parentElement?.parentElement?.getAttribute("open") !== null) {
|
|
174
|
-
lastVisibleElement = details;
|
|
175
|
-
break;
|
|
176
|
-
} else if (details.parentElement?.parentElement?.tagName !== "details") {
|
|
177
|
-
lastVisibleElement = details.parentElement.parentElement;
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (lastVisibleElement) {
|
|
182
|
-
const summary = lastVisibleElement.querySelector("summary");
|
|
183
|
-
if (summary)
|
|
184
|
-
summary.focus();
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
17
|
const cBase = "";
|
|
191
|
-
const cSummary = "list-none
|
|
18
|
+
const cSummary = "list-none flex items-center cursor-pointer";
|
|
192
19
|
const cSymbol = "fill-current w-3 text-center transition-transform duration-[200ms]";
|
|
193
20
|
const cChildren = "";
|
|
194
|
-
const cDisabled = "opacity-50 !cursor-not-allowed";
|
|
195
|
-
$:
|
|
196
|
-
classesCaretState = open && $$slots.children && !hideChildren ? caretOpen : caretClosed;
|
|
197
21
|
$:
|
|
198
|
-
|
|
22
|
+
classesCaretState = open ? caretOpen : caretClosed;
|
|
199
23
|
$:
|
|
200
24
|
classesBase = `${cBase} ${$$props.class ?? ""}`;
|
|
201
25
|
$:
|
|
202
|
-
classesSummary = `${cSummary} ${
|
|
26
|
+
classesSummary = `${cSummary} ${spacing} ${rounded} ${padding} ${hover} ${regionSummary}`;
|
|
203
27
|
$:
|
|
204
28
|
classesSymbol = `${cSymbol} ${classesCaret} ${regionSymbol}`;
|
|
205
29
|
$:
|
|
@@ -210,21 +34,19 @@ $:
|
|
|
210
34
|
classesChildren = `${cChildren} ${indent} ${regionChildren}`;
|
|
211
35
|
</script>
|
|
212
36
|
|
|
213
|
-
<details bind:
|
|
37
|
+
<details bind:open class="tree-item {classesBase}" data-testid="tree-item">
|
|
214
38
|
<summary
|
|
215
39
|
class="tree-item-summary {classesSummary}"
|
|
216
40
|
role="treeitem"
|
|
217
|
-
aria-selected=
|
|
41
|
+
aria-selected="false"
|
|
218
42
|
aria-expanded={$$slots.children ? open : undefined}
|
|
219
|
-
on:click={onSummaryClick}
|
|
220
43
|
on:click
|
|
221
|
-
on:keydown={onKeyDown}
|
|
222
44
|
on:keydown
|
|
223
45
|
on:keyup
|
|
224
46
|
>
|
|
225
47
|
<!-- Symbol -->
|
|
226
48
|
<div class="tree-summary-symbol {classesSymbol}">
|
|
227
|
-
{#if $$slots.children
|
|
49
|
+
{#if $$slots.children}
|
|
228
50
|
<!-- SVG Caret -->
|
|
229
51
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
|
|
230
52
|
<path
|
|
@@ -237,18 +59,8 @@ $:
|
|
|
237
59
|
</svg>
|
|
238
60
|
{/if}
|
|
239
61
|
</div>
|
|
240
|
-
|
|
241
|
-
<!-- Selection -->
|
|
242
|
-
{#if selection && name && group !== undefined}
|
|
243
|
-
{#if multiple}
|
|
244
|
-
<input class="checkbox tree-item-checkbox" type="checkbox" {name} {value} bind:checked bind:indeterminate on:click on:change />
|
|
245
|
-
{:else}
|
|
246
|
-
<input class="radio tree-item-radio" type="radio" bind:group {name} {value} on:click on:change />
|
|
247
|
-
{/if}
|
|
248
|
-
{/if}
|
|
249
|
-
|
|
250
62
|
<!-- Slot: Lead -->
|
|
251
|
-
{#if $$slots.lead
|
|
63
|
+
{#if $$slots.lead}
|
|
252
64
|
<div class="tree-item-lead">
|
|
253
65
|
<slot name="lead" />
|
|
254
66
|
</div>
|
|
@@ -258,7 +70,7 @@ $:
|
|
|
258
70
|
<slot />
|
|
259
71
|
</div>
|
|
260
72
|
</summary>
|
|
261
|
-
<div
|
|
73
|
+
<div class="tree-item-children {classesChildren}" role="group">
|
|
262
74
|
<slot name="children" />
|
|
263
75
|
</div>
|
|
264
76
|
</details>
|
|
@@ -1,28 +1,11 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { TreeViewItem } from '../../index.js';
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
5
4
|
[x: string]: any;
|
|
6
|
-
/** Set the radio group binding value.*/
|
|
7
|
-
group?: unknown;
|
|
8
|
-
/** Set a unique name value for the input.*/
|
|
9
|
-
name?: string | undefined;
|
|
10
|
-
/** Set the input's value.*/
|
|
11
|
-
value?: unknown;
|
|
12
|
-
/** Provide children references to support relational checking.*/
|
|
13
|
-
children?: TreeViewItem[] | undefined;
|
|
14
|
-
/** Provide classes to set the horizontal spacing.*/
|
|
15
|
-
spacing?: string | undefined;
|
|
16
5
|
/** Set open by default on load.*/
|
|
17
6
|
open?: boolean | undefined;
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
/** Enable selection of multiple items.*/
|
|
21
|
-
multiple?: boolean | undefined;
|
|
22
|
-
/** Set the tree item disabled state*/
|
|
23
|
-
disabled?: boolean | undefined;
|
|
24
|
-
/** Set the check state to indeterminate(-).*/
|
|
25
|
-
indeterminate?: boolean | undefined;
|
|
7
|
+
/** Provide classes to set the horizontal spacing.*/
|
|
8
|
+
spacing?: string | undefined;
|
|
26
9
|
/** Provide classes to set the tree item padding styles.*/
|
|
27
10
|
padding?: string | undefined;
|
|
28
11
|
/** Provide classes to set the tree children indentation*/
|
|
@@ -42,16 +25,11 @@ declare const __propDef: {
|
|
|
42
25
|
regionSymbol?: string | undefined;
|
|
43
26
|
/** Provide arbitrary classes to the children region.*/
|
|
44
27
|
regionChildren?: string | undefined;
|
|
45
|
-
/** Don't use this prop, workaround until svelte implements conditional slots*/
|
|
46
|
-
hideLead?: boolean | undefined;
|
|
47
|
-
/** Don't use this prop, workaround until svelte implements conditional slots*/
|
|
48
|
-
hideChildren?: boolean | undefined;
|
|
49
28
|
};
|
|
50
29
|
events: {
|
|
51
30
|
click: MouseEvent;
|
|
52
31
|
keydown: KeyboardEvent;
|
|
53
32
|
keyup: KeyboardEvent;
|
|
54
|
-
change: Event;
|
|
55
33
|
toggle: CustomEvent<any>;
|
|
56
34
|
} & {
|
|
57
35
|
[evt: string]: CustomEvent<any>;
|
|
@@ -66,71 +44,5 @@ export type TreeViewItemProps = typeof __propDef.props;
|
|
|
66
44
|
export type TreeViewItemEvents = typeof __propDef.events;
|
|
67
45
|
export type TreeViewItemSlots = typeof __propDef.slots;
|
|
68
46
|
export default class TreeViewItem extends SvelteComponentTyped<TreeViewItemProps, TreeViewItemEvents, TreeViewItemSlots> {
|
|
69
|
-
get group(): unknown;
|
|
70
|
-
/**accessor*/
|
|
71
|
-
set group(_: unknown);
|
|
72
|
-
get name(): string | undefined;
|
|
73
|
-
/**accessor*/
|
|
74
|
-
set name(_: string | undefined);
|
|
75
|
-
get value(): unknown;
|
|
76
|
-
/**accessor*/
|
|
77
|
-
set value(_: unknown);
|
|
78
|
-
get children(): TreeViewItem[] | undefined;
|
|
79
|
-
/**accessor*/
|
|
80
|
-
set children(_: TreeViewItem[] | undefined);
|
|
81
|
-
get spacing(): string | undefined;
|
|
82
|
-
/**accessor*/
|
|
83
|
-
set spacing(_: string | undefined);
|
|
84
|
-
get open(): boolean | undefined;
|
|
85
|
-
/**accessor*/
|
|
86
|
-
set open(_: boolean | undefined);
|
|
87
|
-
get selection(): boolean | undefined;
|
|
88
|
-
/**accessor*/
|
|
89
|
-
set selection(_: boolean | undefined);
|
|
90
|
-
get multiple(): boolean | undefined;
|
|
91
|
-
/**accessor*/
|
|
92
|
-
set multiple(_: boolean | undefined);
|
|
93
|
-
get disabled(): boolean | undefined;
|
|
94
|
-
/**accessor*/
|
|
95
|
-
set disabled(_: boolean | undefined);
|
|
96
|
-
get indeterminate(): boolean | undefined;
|
|
97
|
-
/**accessor*/
|
|
98
|
-
set indeterminate(_: boolean | undefined);
|
|
99
|
-
get padding(): string | undefined;
|
|
100
|
-
/**accessor*/
|
|
101
|
-
set padding(_: string | undefined);
|
|
102
|
-
get indent(): string | undefined;
|
|
103
|
-
/**accessor*/
|
|
104
|
-
set indent(_: string | undefined);
|
|
105
|
-
get hover(): string | undefined;
|
|
106
|
-
/**accessor*/
|
|
107
|
-
set hover(_: string | undefined);
|
|
108
|
-
get rounded(): string | undefined;
|
|
109
|
-
/**accessor*/
|
|
110
|
-
set rounded(_: string | undefined);
|
|
111
|
-
get caretOpen(): string | undefined;
|
|
112
|
-
/**accessor*/
|
|
113
|
-
set caretOpen(_: string | undefined);
|
|
114
|
-
get caretClosed(): string | undefined;
|
|
115
|
-
/**accessor*/
|
|
116
|
-
set caretClosed(_: string | undefined);
|
|
117
|
-
get hyphenOpacity(): string | undefined;
|
|
118
|
-
/**accessor*/
|
|
119
|
-
set hyphenOpacity(_: string | undefined);
|
|
120
|
-
get regionSummary(): string | undefined;
|
|
121
|
-
/**accessor*/
|
|
122
|
-
set regionSummary(_: string | undefined);
|
|
123
|
-
get regionSymbol(): string | undefined;
|
|
124
|
-
/**accessor*/
|
|
125
|
-
set regionSymbol(_: string | undefined);
|
|
126
|
-
get regionChildren(): string | undefined;
|
|
127
|
-
/**accessor*/
|
|
128
|
-
set regionChildren(_: string | undefined);
|
|
129
|
-
get hideLead(): boolean | undefined;
|
|
130
|
-
/**accessor*/
|
|
131
|
-
set hideLead(_: boolean | undefined);
|
|
132
|
-
get hideChildren(): boolean | undefined;
|
|
133
|
-
/**accessor*/
|
|
134
|
-
set hideChildren(_: boolean | undefined);
|
|
135
47
|
}
|
|
136
48
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export type { ToastSettings } from './utilities/Toast/types.js';
|
|
|
6
6
|
export type { TableSource } from './components/Table/types.js';
|
|
7
7
|
export type { PaginationSettings } from './components/Paginator/types.js';
|
|
8
8
|
export type { PopupSettings } from './utilities/Popup/types.js';
|
|
9
|
-
export type { TreeViewNode } from './components/TreeView/types.js';
|
|
10
9
|
export type CssClasses = string;
|
|
11
10
|
export type SvelteEvent<E extends Event = Event, T extends EventTarget = Element> = E & {
|
|
12
11
|
currentTarget: EventTarget & T;
|
|
@@ -56,7 +55,6 @@ export { default as TabAnchor } from './components/Tab/TabAnchor.svelte';
|
|
|
56
55
|
export { default as TableOfContents } from './components/TableOfContents/TableOfContents.svelte';
|
|
57
56
|
export { default as TreeView } from './components/TreeView/TreeView.svelte';
|
|
58
57
|
export { default as TreeViewItem } from './components/TreeView/TreeViewItem.svelte';
|
|
59
|
-
export { default as TreeViewDataDrivenItem } from './components/TreeView/TreeViewDataDrivenItem.svelte';
|
|
60
58
|
export { default as CodeBlock } from './utilities/CodeBlock/CodeBlock.svelte';
|
|
61
59
|
export { default as Modal } from './utilities/Modal/Modal.svelte';
|
|
62
60
|
export { default as Drawer } from './utilities/Drawer/Drawer.svelte';
|
package/dist/index.js
CHANGED
|
@@ -61,7 +61,6 @@ export { default as TabAnchor } from './components/Tab/TabAnchor.svelte';
|
|
|
61
61
|
export { default as TableOfContents } from './components/TableOfContents/TableOfContents.svelte';
|
|
62
62
|
export { default as TreeView } from './components/TreeView/TreeView.svelte';
|
|
63
63
|
export { default as TreeViewItem } from './components/TreeView/TreeViewItem.svelte';
|
|
64
|
-
export { default as TreeViewDataDrivenItem } from './components/TreeView/TreeViewDataDrivenItem.svelte';
|
|
65
64
|
// Utility Components
|
|
66
65
|
export { default as CodeBlock } from './utilities/CodeBlock/CodeBlock.svelte';
|
|
67
66
|
export { default as Modal } from './utilities/Modal/Modal.svelte';
|
package/package.json
CHANGED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
<script>import { createEventDispatcher, getContext, onMount } from "svelte";
|
|
2
|
-
import TreeViewDataDrivenItem from "./TreeViewDataDrivenItem.svelte";
|
|
3
|
-
import TreeViewItem from "./TreeViewItem.svelte";
|
|
4
|
-
const dispatch = createEventDispatcher();
|
|
5
|
-
export let nodes = [];
|
|
6
|
-
export let selection = getContext("selection");
|
|
7
|
-
export let multiple = getContext("multiple");
|
|
8
|
-
let group;
|
|
9
|
-
let name = "";
|
|
10
|
-
onMount(() => {
|
|
11
|
-
name = String(Math.random());
|
|
12
|
-
if (selection) {
|
|
13
|
-
group = multiple ? [] : "";
|
|
14
|
-
nodes.forEach((node) => {
|
|
15
|
-
if (!node.checked)
|
|
16
|
-
return;
|
|
17
|
-
if (multiple) {
|
|
18
|
-
if (!Array.isArray(group))
|
|
19
|
-
return;
|
|
20
|
-
group.push(node.value);
|
|
21
|
-
} else {
|
|
22
|
-
group = node.value;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
function onCheckChange() {
|
|
28
|
-
nodes.forEach((node) => {
|
|
29
|
-
if (multiple) {
|
|
30
|
-
if (!Array.isArray(group))
|
|
31
|
-
return;
|
|
32
|
-
node.checked = group.includes(node.value);
|
|
33
|
-
} else {
|
|
34
|
-
node.checked = group === node.value;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
nodes = nodes;
|
|
38
|
-
dispatch("change");
|
|
39
|
-
}
|
|
40
|
-
export let parents = [];
|
|
41
|
-
let children = [];
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
{#if nodes && nodes.length > 0}
|
|
45
|
-
{#each nodes as node, i}
|
|
46
|
-
<TreeViewItem
|
|
47
|
-
bind:this={parents[i]}
|
|
48
|
-
bind:open={node.open}
|
|
49
|
-
hideLead={!node.lead}
|
|
50
|
-
hideChildren={!node.children || node.children.length === 0}
|
|
51
|
-
bind:disabled={node.disabled}
|
|
52
|
-
bind:group
|
|
53
|
-
bind:name
|
|
54
|
-
bind:indeterminate={node.indeterminate}
|
|
55
|
-
bind:value={node.value}
|
|
56
|
-
bind:children={children[i]}
|
|
57
|
-
on:change={onCheckChange}
|
|
58
|
-
on:click
|
|
59
|
-
on:toggle
|
|
60
|
-
>
|
|
61
|
-
{@html node.content}
|
|
62
|
-
<svelte:fragment slot="lead">
|
|
63
|
-
{@html node.lead}
|
|
64
|
-
</svelte:fragment>
|
|
65
|
-
<svelte:fragment slot="children">
|
|
66
|
-
<TreeViewDataDrivenItem nodes={node.children} on:change={onCheckChange} bind:parents={children[i]} />
|
|
67
|
-
</svelte:fragment>
|
|
68
|
-
</TreeViewItem>
|
|
69
|
-
{/each}
|
|
70
|
-
{/if}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import TreeViewItem from './TreeViewItem.svelte';
|
|
3
|
-
import type { TreeViewNode } from './types.js';
|
|
4
|
-
declare const __propDef: {
|
|
5
|
-
props: {
|
|
6
|
-
/** Provide data-driven nodes. */ nodes?: TreeViewNode[] | undefined;
|
|
7
|
-
/** Enable tree-view selection */ selection?: boolean | undefined;
|
|
8
|
-
/** Enable selection of multiple items. */ multiple?: boolean | undefined;
|
|
9
|
-
parents?: TreeViewItem[] | undefined;
|
|
10
|
-
};
|
|
11
|
-
events: {
|
|
12
|
-
click: MouseEvent;
|
|
13
|
-
toggle: CustomEvent<any>;
|
|
14
|
-
change: CustomEvent<any>;
|
|
15
|
-
} & {
|
|
16
|
-
[evt: string]: CustomEvent<any>;
|
|
17
|
-
};
|
|
18
|
-
slots: {};
|
|
19
|
-
};
|
|
20
|
-
export type TreeViewDataDrivenItemProps = typeof __propDef.props;
|
|
21
|
-
export type TreeViewDataDrivenItemEvents = typeof __propDef.events;
|
|
22
|
-
export type TreeViewDataDrivenItemSlots = typeof __propDef.slots;
|
|
23
|
-
export default class TreeViewDataDrivenItem extends SvelteComponentTyped<TreeViewDataDrivenItemProps, TreeViewDataDrivenItemEvents, TreeViewDataDrivenItemSlots> {
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface TreeViewNode {
|
|
2
|
-
/** Main content. accepts HTML. */
|
|
3
|
-
content: string;
|
|
4
|
-
/** Lead content. accepts HTML. */
|
|
5
|
-
lead?: string;
|
|
6
|
-
/** Set open by default on load. */
|
|
7
|
-
open?: boolean;
|
|
8
|
-
/** Set the tree disabled state. */
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
/** children nodes. */
|
|
11
|
-
children?: TreeViewNode[];
|
|
12
|
-
/** Set the input's value. */
|
|
13
|
-
value?: unknown;
|
|
14
|
-
/** input checked */
|
|
15
|
-
checked?: boolean;
|
|
16
|
-
/** input is set to indeterminate, only availabe in multiple selection mode. */
|
|
17
|
-
indeterminate?: boolean;
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|