@skeletonlabs/skeleton 2.3.0 → 2.4.0-dev.df5caa19
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 +48 -21
- package/dist/components/TreeView/RecursiveTreeViewItem.svelte.d.ts +3 -0
- package/dist/components/TreeView/TreeViewItem.svelte +9 -13
- package/dist/components/TreeView/types.d.ts +9 -4
- package/dist/utilities/Drawer/Drawer.svelte +13 -10
- package/dist/utilities/Drawer/Drawer.svelte.d.ts +10 -8
- package/dist/utilities/Drawer/types.d.ts +2 -2
- 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
|
|
3
|
+
import { createEventDispatcher, getContext, onMount } from "svelte";
|
|
4
4
|
export let nodes = [];
|
|
5
5
|
export let expandedNodes = [];
|
|
6
6
|
export let disabledNodes = [];
|
|
@@ -9,9 +9,9 @@ export let indeterminateNodes = [];
|
|
|
9
9
|
let selection = getContext("selection");
|
|
10
10
|
let multiple = getContext("multiple");
|
|
11
11
|
let relational = getContext("relational");
|
|
12
|
-
let
|
|
13
|
-
let group;
|
|
12
|
+
let group = multiple ? [] : "";
|
|
14
13
|
let name = "";
|
|
14
|
+
const dispatch = createEventDispatcher();
|
|
15
15
|
function toggleNode(node, open) {
|
|
16
16
|
if (!node.children?.length)
|
|
17
17
|
return;
|
|
@@ -51,27 +51,29 @@ function checkNode(node, checked, indeterminate) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
if (selection) {
|
|
55
|
+
if (multiple) {
|
|
56
|
+
nodes.forEach((node) => {
|
|
57
|
+
if (!Array.isArray(group))
|
|
58
|
+
return;
|
|
59
|
+
if (checkedNodes.includes(node.id) && !group.includes(node.id)) {
|
|
60
|
+
group.push(node.id);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
group = group;
|
|
64
|
+
} else {
|
|
65
|
+
nodes.forEach((node) => {
|
|
66
|
+
if (checkedNodes.includes(node.id) && group !== node.id) {
|
|
67
|
+
group = node.id;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
55
72
|
onMount(async () => {
|
|
56
73
|
if (selection) {
|
|
57
74
|
name = String(Math.random());
|
|
58
|
-
if (group === void 0) {
|
|
59
|
-
if (multiple) {
|
|
60
|
-
group = [];
|
|
61
|
-
nodes.forEach((node) => {
|
|
62
|
-
if (checkedNodes.includes(node.id) && Array.isArray(group))
|
|
63
|
-
group.push(node.id);
|
|
64
|
-
});
|
|
65
|
-
group = group;
|
|
66
|
-
} else if (!nodes.some((node) => checkedNodes.includes(node.id))) {
|
|
67
|
-
group = "";
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
75
|
if (!relational)
|
|
71
76
|
treeItems = [];
|
|
72
|
-
checkedNodes = [];
|
|
73
|
-
await tick();
|
|
74
|
-
checkedNodes = [...tempCheckedNodes];
|
|
75
77
|
}
|
|
76
78
|
});
|
|
77
79
|
export let treeItems = [];
|
|
@@ -94,10 +96,27 @@ let children = [];
|
|
|
94
96
|
indeterminate={indeterminateNodes.includes(node.id)}
|
|
95
97
|
on:toggle={(e) => toggleNode(node, e.detail.open)}
|
|
96
98
|
on:groupChange={(e) => checkNode(node, e.detail.checked, e.detail.indeterminate)}
|
|
99
|
+
on:click={() =>
|
|
100
|
+
dispatch('click', {
|
|
101
|
+
id: node.id
|
|
102
|
+
})}
|
|
103
|
+
on:toggle={() => {
|
|
104
|
+
dispatch('toggle', {
|
|
105
|
+
id: node.id
|
|
106
|
+
});
|
|
107
|
+
}}
|
|
97
108
|
>
|
|
98
|
-
{
|
|
109
|
+
{#if typeof node.content === 'string'}
|
|
110
|
+
{@html node.content}
|
|
111
|
+
{:else}
|
|
112
|
+
<svelte:component this={node.content} {...node.contentProps} />
|
|
113
|
+
{/if}
|
|
99
114
|
<svelte:fragment slot="lead">
|
|
100
|
-
{
|
|
115
|
+
{#if typeof node.lead === 'string'}
|
|
116
|
+
{@html node.lead}
|
|
117
|
+
{:else}
|
|
118
|
+
<svelte:component this={node.lead} {...node.leadProps} />
|
|
119
|
+
{/if}
|
|
101
120
|
</svelte:fragment>
|
|
102
121
|
<svelte:fragment slot="children">
|
|
103
122
|
<RecursiveTreeViewItem
|
|
@@ -107,6 +126,14 @@ let children = [];
|
|
|
107
126
|
bind:checkedNodes
|
|
108
127
|
bind:indeterminateNodes
|
|
109
128
|
bind:treeItems={children[i]}
|
|
129
|
+
on:click={(e) =>
|
|
130
|
+
dispatch('click', {
|
|
131
|
+
id: e.detail.id
|
|
132
|
+
})}
|
|
133
|
+
on:toggle={(e) =>
|
|
134
|
+
dispatch('toggle', {
|
|
135
|
+
id: e.detail.id
|
|
136
|
+
})}
|
|
110
137
|
/>
|
|
111
138
|
</svelte:fragment>
|
|
112
139
|
</TreeViewItem>
|
|
@@ -37,23 +37,12 @@ $:
|
|
|
37
37
|
$:
|
|
38
38
|
if (multiple)
|
|
39
39
|
updateGroup(checked, indeterminate);
|
|
40
|
-
$:
|
|
41
|
-
if (!multiple)
|
|
42
|
-
updateRadio(group);
|
|
43
|
-
$:
|
|
44
|
-
if (!multiple)
|
|
45
|
-
updateRadioGroup(checked);
|
|
46
|
-
let initUpdate = true;
|
|
47
40
|
function updateCheckbox(group2, indeterminate2) {
|
|
48
41
|
if (!Array.isArray(group2))
|
|
49
42
|
return;
|
|
50
43
|
checked = group2.indexOf(value) >= 0;
|
|
51
44
|
dispatch("groupChange", { checked, indeterminate: indeterminate2 });
|
|
52
45
|
dispatch("childChange");
|
|
53
|
-
if (initUpdate) {
|
|
54
|
-
onParentChange();
|
|
55
|
-
initUpdate = false;
|
|
56
|
-
}
|
|
57
46
|
}
|
|
58
47
|
function updateGroup(checked2, indeterminate2) {
|
|
59
48
|
if (!Array.isArray(group))
|
|
@@ -63,16 +52,23 @@ function updateGroup(checked2, indeterminate2) {
|
|
|
63
52
|
if (index < 0) {
|
|
64
53
|
group.push(value);
|
|
65
54
|
group = group;
|
|
66
|
-
onParentChange();
|
|
67
55
|
}
|
|
68
56
|
} else {
|
|
69
57
|
if (index >= 0) {
|
|
70
58
|
group.splice(index, 1);
|
|
71
59
|
group = group;
|
|
72
|
-
onParentChange();
|
|
73
60
|
}
|
|
74
61
|
}
|
|
62
|
+
if (!indeterminate2) {
|
|
63
|
+
onParentChange();
|
|
64
|
+
}
|
|
75
65
|
}
|
|
66
|
+
$:
|
|
67
|
+
if (!multiple)
|
|
68
|
+
updateRadio(group);
|
|
69
|
+
$:
|
|
70
|
+
if (!multiple)
|
|
71
|
+
updateRadioGroup(checked);
|
|
76
72
|
function updateRadio(group2) {
|
|
77
73
|
checked = group2 === value;
|
|
78
74
|
dispatch("groupChange", { checked, indeterminate: false });
|
|
@@ -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. */
|
|
@@ -7,20 +7,21 @@ import { getDrawerStore } from "./stores.js";
|
|
|
7
7
|
import { fade, fly } from "svelte/transition";
|
|
8
8
|
import { dynamicTransition } from "../../internal/transitions.js";
|
|
9
9
|
export let position = "left";
|
|
10
|
-
export let bgBackdrop = "bg-surface-backdrop-token";
|
|
11
|
-
export let blur = "";
|
|
12
|
-
export let padding = "";
|
|
13
10
|
export let bgDrawer = "bg-surface-100-800-token";
|
|
14
11
|
export let border = "";
|
|
15
12
|
export let rounded = "";
|
|
16
13
|
export let shadow = "shadow-xl";
|
|
17
14
|
export let width = "";
|
|
18
15
|
export let height = "";
|
|
16
|
+
export let bgBackdrop = "bg-surface-backdrop-token";
|
|
17
|
+
export let blur = "";
|
|
18
|
+
export let padding = "";
|
|
19
19
|
export let zIndex = "z-40";
|
|
20
20
|
export let regionBackdrop = "";
|
|
21
21
|
export let regionDrawer = "";
|
|
22
22
|
export let labelledby = "";
|
|
23
23
|
export let describedby = "";
|
|
24
|
+
export let duration = 200;
|
|
24
25
|
export let transitions = !$prefersReducedMotionStore;
|
|
25
26
|
export let opacityTransition = true;
|
|
26
27
|
const presets = {
|
|
@@ -47,10 +48,11 @@ const propDefaults = {
|
|
|
47
48
|
width,
|
|
48
49
|
height,
|
|
49
50
|
opacityTransition,
|
|
51
|
+
regionBackdrop,
|
|
52
|
+
regionDrawer,
|
|
50
53
|
labelledby,
|
|
51
54
|
describedby,
|
|
52
|
-
|
|
53
|
-
regionDrawer
|
|
55
|
+
duration
|
|
54
56
|
};
|
|
55
57
|
function applyPropSettings(settings) {
|
|
56
58
|
position = settings.position || propDefaults.position;
|
|
@@ -63,11 +65,12 @@ function applyPropSettings(settings) {
|
|
|
63
65
|
shadow = settings.shadow || propDefaults.shadow;
|
|
64
66
|
width = settings.width || propDefaults.width;
|
|
65
67
|
height = settings.height || propDefaults.height;
|
|
66
|
-
opacityTransition = settings.opacityTransition || propDefaults.opacityTransition;
|
|
67
68
|
regionBackdrop = settings.regionBackdrop || propDefaults.regionBackdrop;
|
|
68
69
|
regionDrawer = settings.regionDrawer || propDefaults.regionDrawer;
|
|
69
70
|
labelledby = settings.labelledby || propDefaults.labelledby;
|
|
70
71
|
describedby = settings.describedby || propDefaults.describedby;
|
|
72
|
+
opacityTransition = settings.opacityTransition || propDefaults.opacityTransition;
|
|
73
|
+
duration = settings.duration || propDefaults.duration;
|
|
71
74
|
}
|
|
72
75
|
function applyAnimationSettings() {
|
|
73
76
|
if (!BROWSER)
|
|
@@ -140,12 +143,12 @@ $:
|
|
|
140
143
|
on:keypress
|
|
141
144
|
in:dynamicTransition|local={{
|
|
142
145
|
transition: fade,
|
|
143
|
-
params: { duration
|
|
146
|
+
params: { duration },
|
|
144
147
|
enabled: transitions && opacityTransition
|
|
145
148
|
}}
|
|
146
149
|
out:dynamicTransition|local={{
|
|
147
150
|
transition: fade,
|
|
148
|
-
params: { duration
|
|
151
|
+
params: { duration },
|
|
149
152
|
enabled: transitions && opacityTransition
|
|
150
153
|
}}
|
|
151
154
|
use:focusTrap={true}
|
|
@@ -162,12 +165,12 @@ $:
|
|
|
162
165
|
aria-describedby={describedby}
|
|
163
166
|
in:dynamicTransition|local={{
|
|
164
167
|
transition: fly,
|
|
165
|
-
params: { x: anim.x, y: anim.y, duration
|
|
168
|
+
params: { x: anim.x, y: anim.y, duration, opacity: opacityTransition ? undefined : 1 },
|
|
166
169
|
enabled: transitions
|
|
167
170
|
}}
|
|
168
171
|
out:dynamicTransition|local={{
|
|
169
172
|
transition: fly,
|
|
170
|
-
params: { x: anim.x, y: anim.y, duration
|
|
173
|
+
params: { x: anim.x, y: anim.y, duration, opacity: opacityTransition ? undefined : 1 },
|
|
171
174
|
enabled: transitions
|
|
172
175
|
}}
|
|
173
176
|
>
|
|
@@ -4,12 +4,6 @@ declare const __propDef: {
|
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
/** Set the anchor position.*/
|
|
6
6
|
position?: "left" | "top" | "right" | "bottom" | undefined;
|
|
7
|
-
/** Backdrop - Provide classes to set the backdrop background color*/
|
|
8
|
-
bgBackdrop?: string | undefined;
|
|
9
|
-
/** Backdrop - Provide classes to set the blur style.*/
|
|
10
|
-
blur?: string | undefined;
|
|
11
|
-
/** Backdrop - Provide classes to set padding.*/
|
|
12
|
-
padding?: string | undefined;
|
|
13
7
|
/** Drawer - Provide classes to set the drawer background color.*/
|
|
14
8
|
bgDrawer?: string | undefined;
|
|
15
9
|
/** Drawer - Provide classes to set border color.*/
|
|
@@ -22,7 +16,13 @@ declare const __propDef: {
|
|
|
22
16
|
width?: string | undefined;
|
|
23
17
|
/** Drawer - Provide classes to override the height.*/
|
|
24
18
|
height?: string | undefined;
|
|
25
|
-
/** Provide
|
|
19
|
+
/** Backdrop - Provide classes to set the backdrop background color*/
|
|
20
|
+
bgBackdrop?: string | undefined;
|
|
21
|
+
/** Backdrop - Provide classes to set the blur style.*/
|
|
22
|
+
blur?: string | undefined;
|
|
23
|
+
/** Backdrop - Provide classes to set padding.*/
|
|
24
|
+
padding?: string | undefined;
|
|
25
|
+
/** Backdrop - Provide a class to override the z-index*/
|
|
26
26
|
zIndex?: string | undefined;
|
|
27
27
|
/** Provide arbitrary classes to the backdrop region.*/
|
|
28
28
|
regionBackdrop?: string | undefined;
|
|
@@ -32,9 +32,11 @@ declare const __propDef: {
|
|
|
32
32
|
labelledby?: string | undefined;
|
|
33
33
|
/** Provide an ID of the element describing the drawer.*/
|
|
34
34
|
describedby?: string | undefined;
|
|
35
|
+
/** Set the transition duration in milliseconds.*/
|
|
36
|
+
duration?: number | undefined;
|
|
35
37
|
/** Enable/Disable transitions*/
|
|
36
38
|
transitions?: boolean | undefined;
|
|
37
|
-
/**
|
|
39
|
+
/** Enable/Disable opacity transition of Drawer*/
|
|
38
40
|
opacityTransition?: boolean | undefined;
|
|
39
41
|
};
|
|
40
42
|
events: {
|
|
@@ -9,8 +9,6 @@ export interface DrawerSettings {
|
|
|
9
9
|
* @type {'left' | 'top' | 'right' | 'bottom'}
|
|
10
10
|
*/
|
|
11
11
|
position?: 'left' | 'top' | 'right' | 'bottom';
|
|
12
|
-
/** Define the Svelte transition animation duration.*/
|
|
13
|
-
duration?: number;
|
|
14
12
|
/** Backdrop - Provide classes to set the backdrop background color*/
|
|
15
13
|
bgBackdrop?: string;
|
|
16
14
|
/** Backdrop - Provide classes to set the blur style.*/
|
|
@@ -29,6 +27,8 @@ export interface DrawerSettings {
|
|
|
29
27
|
width?: string;
|
|
30
28
|
/** Drawer - Provide classes to override the height.*/
|
|
31
29
|
height?: string;
|
|
30
|
+
/** Define the Svelte transition animation duration.*/
|
|
31
|
+
duration?: number;
|
|
32
32
|
/** Drawer - Enable/Disable opacity transition */
|
|
33
33
|
opacityTransition?: boolean;
|
|
34
34
|
/** Provide arbitrary classes to the backdrop region. */
|