@skeletonlabs/skeleton 1.9.0 → 1.10.0-dev.9d07e49d
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/AppRail/AppRail.svelte +14 -3
- package/dist/components/AppRail/AppRail.svelte.d.ts +5 -3
- package/dist/components/AppRail/AppRailAnchor.svelte +4 -3
- package/dist/components/AppRail/AppRailAnchor.svelte.d.ts +1 -0
- package/dist/components/AppRail/AppRailTile.svelte +5 -3
- package/dist/components/AppRail/AppRailTile.svelte.d.ts +2 -0
- package/dist/components/Autocomplete/Autocomplete.svelte +10 -15
- package/dist/components/ListBox/ListBox.svelte +6 -0
- package/dist/components/ListBox/ListBox.svelte.d.ts +6 -0
- package/dist/components/ListBox/ListBoxItem.svelte +15 -3
- package/dist/components/ListBox/ListBoxItem.svelte.d.ts +3 -0
- package/dist/components/Paginator/Paginator.svelte +8 -2
- package/dist/components/Ratings/Ratings.svelte +25 -15
- package/dist/components/TreeView/TreeView.svelte +31 -0
- package/dist/components/TreeView/TreeView.svelte.d.ts +43 -0
- package/dist/components/TreeView/TreeViewItem.svelte +76 -0
- package/dist/components/TreeView/TreeViewItem.svelte.d.ts +48 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/styles/elements/logo-clouds.css +1 -1
- package/dist/tailwind/generated/intellisense-classes.cjs +1 -1
- package/dist/tailwind/generated/intellisense-classes.d.cts +5 -1
- package/dist/utilities/Modal/Modal.svelte +5 -5
- package/dist/utilities/Popup/popup.js +4 -1
- package/package.json +1 -1
|
@@ -10,21 +10,32 @@ export let regionTrail = "";
|
|
|
10
10
|
export let hover = "bg-primary-hover-token";
|
|
11
11
|
export let active = "bg-primary-active-token";
|
|
12
12
|
export let spacing = "space-y-1";
|
|
13
|
+
export let aspectRatio = "aspect-square";
|
|
13
14
|
setContext("active", active);
|
|
14
15
|
setContext("hover", hover);
|
|
15
16
|
setContext("spacing", spacing);
|
|
17
|
+
setContext("aspectRatio", aspectRatio);
|
|
16
18
|
const cBase = "grid grid-rows-[auto_1fr_auto] overflow-y-auto";
|
|
19
|
+
const cRegionLead = "box-border";
|
|
20
|
+
const cRegionDefault = "box-border";
|
|
21
|
+
const cRegionTrail = "box-border";
|
|
17
22
|
$:
|
|
18
23
|
classesBase = `${cBase} ${background} ${border} ${width} ${height} ${gap} ${$$props.class || ""}`;
|
|
24
|
+
$:
|
|
25
|
+
classesRegionLead = `${cRegionLead} ${regionLead}`;
|
|
26
|
+
$:
|
|
27
|
+
classesRegionDefault = `${cRegionDefault} ${regionDefault}`;
|
|
28
|
+
$:
|
|
29
|
+
classesRegionTrail = `${cRegionTrail} ${regionTrail}`;
|
|
19
30
|
</script>
|
|
20
31
|
|
|
21
32
|
<!-- @component A vertical navigation rail component. -->
|
|
22
33
|
|
|
23
34
|
<div class="app-rail {classesBase}" data-testid="app-rail">
|
|
24
35
|
<!-- Slot: lead -->
|
|
25
|
-
<div class="app-bar-lead {
|
|
36
|
+
<div class="app-bar-lead {classesRegionLead}"><slot name="lead" /></div>
|
|
26
37
|
<!-- Slot: Default -->
|
|
27
|
-
<div class="app-bar-default {
|
|
38
|
+
<div class="app-bar-default {classesRegionDefault}"><slot /></div>
|
|
28
39
|
<!-- Slot: lead -->
|
|
29
|
-
<div class="app-bar-trail {
|
|
40
|
+
<div class="app-bar-trail {classesRegionTrail}"><slot name="trail" /></div>
|
|
30
41
|
</div>
|
|
@@ -18,12 +18,14 @@ declare const __propDef: {
|
|
|
18
18
|
regionDefault?: string | undefined;
|
|
19
19
|
/** Rail: Provide arbitrary classes to the trail region.*/
|
|
20
20
|
regionTrail?: string | undefined;
|
|
21
|
-
/**
|
|
21
|
+
/** Provide classes to set the tile/anchor hover background color.*/
|
|
22
22
|
hover?: string | undefined;
|
|
23
|
-
/**
|
|
23
|
+
/** Provide classes to set the tile/anchor active tile background.*/
|
|
24
24
|
active?: string | undefined;
|
|
25
|
-
/**
|
|
25
|
+
/** Provide classes to set the tile/anchor vertical spacing.*/
|
|
26
26
|
spacing?: string | undefined;
|
|
27
|
+
/** Provide classes to set the tile/anchor aspect ratio.*/
|
|
28
|
+
aspectRatio?: string | undefined;
|
|
27
29
|
};
|
|
28
30
|
events: {
|
|
29
31
|
[evt: string]: CustomEvent<any>;
|
|
@@ -5,15 +5,16 @@ export let regionLabel = "";
|
|
|
5
5
|
export let hover = getContext("hover");
|
|
6
6
|
export let active = getContext("active");
|
|
7
7
|
export let spacing = getContext("spacing");
|
|
8
|
+
export let aspectRatio = getContext("aspectRatio");
|
|
8
9
|
const cBase = "unstyled";
|
|
9
|
-
const cWrapper = "w-full
|
|
10
|
+
const cWrapper = "w-full flex flex-col justify-center items-stretch text-center space-y-1";
|
|
10
11
|
const cLabel = "font-bold text-xs";
|
|
11
12
|
$:
|
|
12
13
|
classActive = selected ? active : "";
|
|
13
14
|
$:
|
|
14
|
-
classesBase = `${cBase}
|
|
15
|
+
classesBase = `${cBase} ${$$props.class || ""}`;
|
|
15
16
|
$:
|
|
16
|
-
classesWrapper = `${cWrapper} ${hover} ${spacing} ${classActive}`;
|
|
17
|
+
classesWrapper = `${cWrapper} ${aspectRatio} ${hover} ${spacing} ${classActive}`;
|
|
17
18
|
$:
|
|
18
19
|
classesLead = `${regionLead}`;
|
|
19
20
|
$:
|
|
@@ -8,17 +8,19 @@ export let regionLabel = "";
|
|
|
8
8
|
export let hover = getContext("hover");
|
|
9
9
|
export let active = getContext("active");
|
|
10
10
|
export let spacing = getContext("spacing");
|
|
11
|
+
export let width = getContext("width");
|
|
12
|
+
export let aspectRatio = getContext("aspectRatio");
|
|
11
13
|
const cBase = "cursor-pointer";
|
|
12
|
-
const cWrapper = "
|
|
14
|
+
const cWrapper = "flex flex-col justify-center items-stretch";
|
|
13
15
|
const cInterface = "text-center";
|
|
14
16
|
const cLabel = "font-bold text-xs";
|
|
15
17
|
let elemInput;
|
|
16
18
|
$:
|
|
17
19
|
classActive = group === value ? active : "";
|
|
18
20
|
$:
|
|
19
|
-
classesBase = `${cBase}
|
|
21
|
+
classesBase = `${cBase} ${$$props.class || ""}`;
|
|
20
22
|
$:
|
|
21
|
-
classesWrapper = `${cWrapper} ${hover} ${classActive}`;
|
|
23
|
+
classesWrapper = `${cWrapper} ${aspectRatio} ${width} ${hover} ${classActive}`;
|
|
22
24
|
$:
|
|
23
25
|
classesInterface = `${cInterface} ${spacing}`;
|
|
24
26
|
$:
|
|
@@ -17,20 +17,18 @@ export let duration = 200;
|
|
|
17
17
|
const deprecated = [whitelist, blacklist, duration];
|
|
18
18
|
$:
|
|
19
19
|
listedOptions = options;
|
|
20
|
-
function
|
|
20
|
+
function filterByAllowDeny() {
|
|
21
|
+
let _options = [...options];
|
|
21
22
|
if (allowlist.length) {
|
|
22
|
-
|
|
23
|
-
} else {
|
|
24
|
-
listedOptions = [...options];
|
|
23
|
+
_options = _options.filter((option) => allowlist.includes(option.value));
|
|
25
24
|
}
|
|
26
|
-
}
|
|
27
|
-
function filterByDenied() {
|
|
28
25
|
if (denylist.length) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
_options = _options.filter((option) => !denylist.includes(option.value));
|
|
27
|
+
}
|
|
28
|
+
if (!allowlist.length && !denylist.length) {
|
|
29
|
+
_options = options;
|
|
33
30
|
}
|
|
31
|
+
listedOptions = _options;
|
|
34
32
|
}
|
|
35
33
|
function filterOptions() {
|
|
36
34
|
let _options = [...listedOptions];
|
|
@@ -46,11 +44,8 @@ function onSelection(option) {
|
|
|
46
44
|
dispatch("selection", option);
|
|
47
45
|
}
|
|
48
46
|
$:
|
|
49
|
-
if (allowlist)
|
|
50
|
-
|
|
51
|
-
$:
|
|
52
|
-
if (denylist)
|
|
53
|
-
filterByDenied();
|
|
47
|
+
if (allowlist.length || denylist.length)
|
|
48
|
+
filterByAllowDeny();
|
|
54
49
|
$:
|
|
55
50
|
optionsFiltered = input ? filterOptions() : listedOptions;
|
|
56
51
|
$:
|
|
@@ -5,12 +5,18 @@ export let rounded = "rounded-token";
|
|
|
5
5
|
export let active = "variant-filled";
|
|
6
6
|
export let hover = "hover:variant-soft";
|
|
7
7
|
export let padding = "px-4 py-2";
|
|
8
|
+
export let regionLead = "";
|
|
9
|
+
export let regionDefault = "";
|
|
10
|
+
export let regionTrail = "";
|
|
8
11
|
export let labelledby = "";
|
|
9
12
|
setContext("multiple", multiple);
|
|
10
13
|
setContext("rounded", rounded);
|
|
11
14
|
setContext("active", active);
|
|
12
15
|
setContext("hover", hover);
|
|
13
16
|
setContext("padding", padding);
|
|
17
|
+
setContext("regionLead", regionLead);
|
|
18
|
+
setContext("regionDefault", regionDefault);
|
|
19
|
+
setContext("regionTrail", regionTrail);
|
|
14
20
|
const cBase = "";
|
|
15
21
|
$:
|
|
16
22
|
classesBase = `${cBase} ${spacing} ${rounded} ${$$props.class ?? ""}`;
|
|
@@ -14,6 +14,12 @@ declare const __propDef: {
|
|
|
14
14
|
hover?: string | undefined;
|
|
15
15
|
/** Provide classes to set the listbox item padding styles.*/
|
|
16
16
|
padding?: string | undefined;
|
|
17
|
+
/** Provide arbitrary classes to style the lead region.*/
|
|
18
|
+
regionLead?: string | undefined;
|
|
19
|
+
/** Provide arbitrary classes to the default region.*/
|
|
20
|
+
regionDefault?: string | undefined;
|
|
21
|
+
/** Provide arbitrary classes to the trail region.*/
|
|
22
|
+
regionTrail?: string | undefined;
|
|
17
23
|
/** Provide the ARIA labelledby value.*/
|
|
18
24
|
labelledby?: string | undefined;
|
|
19
25
|
};
|
|
@@ -7,6 +7,9 @@ export let rounded = getContext("rounded");
|
|
|
7
7
|
export let active = getContext("active");
|
|
8
8
|
export let hover = getContext("hover");
|
|
9
9
|
export let padding = getContext("padding");
|
|
10
|
+
export let regionLead = getContext("regionLead");
|
|
11
|
+
export let regionDefault = getContext("regionDefault");
|
|
12
|
+
export let regionTrail = getContext("regionTrail");
|
|
10
13
|
const cBase = "cursor-pointer -outline-offset-[3px]";
|
|
11
14
|
const cLabel = "flex items-center space-x-4";
|
|
12
15
|
let checked;
|
|
@@ -57,6 +60,9 @@ function onKeyDown(event) {
|
|
|
57
60
|
elemInput.click();
|
|
58
61
|
}
|
|
59
62
|
}
|
|
63
|
+
const cRegionLead = "";
|
|
64
|
+
const cRegionDefault = "flex-1";
|
|
65
|
+
const cRegionTrail = "";
|
|
60
66
|
$:
|
|
61
67
|
selected = multiple ? group.some((groupVal) => areDeeplyEqual(value, groupVal)) : areDeeplyEqual(group, value);
|
|
62
68
|
$:
|
|
@@ -65,6 +71,12 @@ $:
|
|
|
65
71
|
classesBase = `${cBase} ${rounded} ${padding} ${classesActive} ${$$props.class ?? ""}`;
|
|
66
72
|
$:
|
|
67
73
|
classesLabel = `${cLabel}`;
|
|
74
|
+
$:
|
|
75
|
+
classesRegionLead = `${cRegionLead} ${regionLead}`;
|
|
76
|
+
$:
|
|
77
|
+
classesRegionDefault = `${cRegionDefault} ${regionDefault}`;
|
|
78
|
+
$:
|
|
79
|
+
classesRegionTrail = `${cRegionTrail} ${regionTrail}`;
|
|
68
80
|
</script>
|
|
69
81
|
|
|
70
82
|
<label>
|
|
@@ -91,11 +103,11 @@ $:
|
|
|
91
103
|
<!-- <slot /> -->
|
|
92
104
|
<div class="listbox-label {classesLabel}">
|
|
93
105
|
<!-- Slot: Lead -->
|
|
94
|
-
{#if $$slots.lead}<div class="listbox-label-lead"><slot name="lead" /></div>{/if}
|
|
106
|
+
{#if $$slots.lead}<div class="listbox-label-lead {classesRegionLead}"><slot name="lead" /></div>{/if}
|
|
95
107
|
<!-- Slot: Default -->
|
|
96
|
-
<div class="listbox-label-content
|
|
108
|
+
<div class="listbox-label-content {classesRegionDefault}"><slot /></div>
|
|
97
109
|
<!-- Slot: Trail -->
|
|
98
|
-
{#if $$slots.trail}<div class="listbox-label-trail"><slot name="trail" /></div>{/if}
|
|
110
|
+
{#if $$slots.trail}<div class="listbox-label-trail {classesRegionTrail}"><slot name="trail" /></div>{/if}
|
|
99
111
|
</div>
|
|
100
112
|
</div>
|
|
101
113
|
</label>
|
|
@@ -13,6 +13,9 @@ declare const __propDef: {
|
|
|
13
13
|
active?: string | undefined;
|
|
14
14
|
hover?: string | undefined;
|
|
15
15
|
padding?: string | undefined;
|
|
16
|
+
regionLead?: string | undefined;
|
|
17
|
+
regionDefault?: string | undefined;
|
|
18
|
+
regionTrail?: string | undefined;
|
|
16
19
|
};
|
|
17
20
|
events: {
|
|
18
21
|
keydown: KeyboardEvent;
|
|
@@ -25,12 +25,12 @@ export let labelNext = "Next page";
|
|
|
25
25
|
export let labelLast = "Last page";
|
|
26
26
|
const cBase = "flex flex-col md:flex-row items-center space-y-4 md:space-y-0 md:space-x-4";
|
|
27
27
|
const cLabel = "w-full md:w-auto";
|
|
28
|
-
let lastPage = Math.ceil(settings.size / settings.limit - 1);
|
|
28
|
+
let lastPage = Math.max(0, Math.ceil(settings.size / settings.limit - 1));
|
|
29
29
|
let controlPages = getNumerals();
|
|
30
30
|
function onChangeLength() {
|
|
31
31
|
settings.offset = 0;
|
|
32
32
|
dispatch("amount", settings.limit);
|
|
33
|
-
lastPage = Math.ceil(settings.size / settings.limit - 1);
|
|
33
|
+
lastPage = Math.max(0, Math.ceil(settings.size / settings.limit - 1));
|
|
34
34
|
controlPages = getNumerals();
|
|
35
35
|
}
|
|
36
36
|
function gotoPage(page) {
|
|
@@ -72,12 +72,18 @@ function getNumerals() {
|
|
|
72
72
|
pages.push(lastPage);
|
|
73
73
|
return pages;
|
|
74
74
|
}
|
|
75
|
+
function updateSize(size) {
|
|
76
|
+
lastPage = Math.max(0, Math.ceil(size / settings.limit - 1));
|
|
77
|
+
controlPages = getNumerals();
|
|
78
|
+
}
|
|
75
79
|
$:
|
|
76
80
|
classesButtonActive = (page) => {
|
|
77
81
|
return page === settings.offset ? `${active} pointer-events-none` : "";
|
|
78
82
|
};
|
|
79
83
|
$:
|
|
80
84
|
maxNumerals, onChangeLength();
|
|
85
|
+
$:
|
|
86
|
+
updateSize(settings.size);
|
|
81
87
|
$:
|
|
82
88
|
classesBase = `${cBase} ${justify} ${$$props.class ?? ""}`;
|
|
83
89
|
$:
|
|
@@ -13,11 +13,13 @@ function iconClick(index) {
|
|
|
13
13
|
index: index + 1
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
+
function isFull(value2, index) {
|
|
17
|
+
return Math.floor(value2) >= index + 1;
|
|
18
|
+
}
|
|
19
|
+
function isHalf(value2, index) {
|
|
20
|
+
return value2 === index + 0.5;
|
|
21
|
+
}
|
|
16
22
|
const cBase = "w-full flex";
|
|
17
|
-
$:
|
|
18
|
-
elemInteractive = interactive ? "button" : "span";
|
|
19
|
-
$:
|
|
20
|
-
attrInteractive = interactive ? { type: "button" } : {};
|
|
21
23
|
$:
|
|
22
24
|
classesBase = `${cBase} ${text} ${fill} ${justify} ${spacing} ${$$props.class ?? ""}`;
|
|
23
25
|
</script>
|
|
@@ -25,18 +27,26 @@ $:
|
|
|
25
27
|
<div class="ratings {classesBase}" data-testid="rating-bar">
|
|
26
28
|
<!-- eslint-disable-next-line @typescript-eslint/no-unused-vars -->
|
|
27
29
|
{#each Array(max) as _, i}
|
|
28
|
-
{#if
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
{#if interactive}
|
|
31
|
+
<button class="rating-icon {regionIcon}" type="button" on:click={() => iconClick(i)}>
|
|
32
|
+
{#if isFull(value, i)}
|
|
33
|
+
<slot name="full" />
|
|
34
|
+
{:else if isHalf(value, i)}
|
|
35
|
+
<slot name="half" />
|
|
36
|
+
{:else}
|
|
37
|
+
<slot name="empty" />
|
|
38
|
+
{/if}
|
|
39
|
+
</button>
|
|
36
40
|
{:else}
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
<span class="rating-icon {regionIcon}">
|
|
42
|
+
{#if isFull(value, i)}
|
|
43
|
+
<slot name="full" />
|
|
44
|
+
{:else if isHalf(value, i)}
|
|
45
|
+
<slot name="half" />
|
|
46
|
+
{:else}
|
|
47
|
+
<slot name="empty" />
|
|
48
|
+
{/if}
|
|
49
|
+
</span>
|
|
40
50
|
{/if}
|
|
41
51
|
{/each}
|
|
42
52
|
</div>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script>import { setContext } from "svelte";
|
|
2
|
+
export let width = "w-full";
|
|
3
|
+
export let spacing = "space-y-1";
|
|
4
|
+
export let padding = "py-4 px-4";
|
|
5
|
+
export let indent = "ml-4";
|
|
6
|
+
export let hover = "hover:variant-soft";
|
|
7
|
+
export let rounded = "rounded-container-token";
|
|
8
|
+
export let caretOpen = "rotate-180";
|
|
9
|
+
export let caretClosed = "";
|
|
10
|
+
export let hyphenOpacity = "opacity-10";
|
|
11
|
+
export let regionSummary = "";
|
|
12
|
+
export let regionSymbol = "";
|
|
13
|
+
export let regionChildren = "";
|
|
14
|
+
export let labelledby = "";
|
|
15
|
+
setContext("padding", padding);
|
|
16
|
+
setContext("indent", indent);
|
|
17
|
+
setContext("hover", hover);
|
|
18
|
+
setContext("rounded", rounded);
|
|
19
|
+
setContext("caretOpen", caretOpen);
|
|
20
|
+
setContext("caretClosed", caretClosed);
|
|
21
|
+
setContext("hyphenOpacity", hyphenOpacity);
|
|
22
|
+
setContext("regionSummary", regionSummary);
|
|
23
|
+
setContext("regionSymbol", regionSymbol);
|
|
24
|
+
setContext("regionChildren", regionChildren);
|
|
25
|
+
$:
|
|
26
|
+
classesBase = `${width} ${spacing} ${$$props.class ?? ""}`;
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<div class="tree {classesBase}" data-testid="tree" role="tree" aria-multiselectable="true" aria-label={labelledby}>
|
|
30
|
+
<slot />
|
|
31
|
+
</div>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
/** Provide classes to set the tree width.*/
|
|
6
|
+
width?: string | undefined;
|
|
7
|
+
/** Provide classes to set the vertical spacing between items.*/
|
|
8
|
+
spacing?: string | undefined;
|
|
9
|
+
/** Provide classes to set the tree item padding styles.*/
|
|
10
|
+
padding?: string | undefined;
|
|
11
|
+
/** Provide classes to set the tree children indentation*/
|
|
12
|
+
indent?: string | undefined;
|
|
13
|
+
/** Provide classes to set the tree item hover styles.*/
|
|
14
|
+
hover?: string | undefined;
|
|
15
|
+
/** Provide classes to set the tree item rounded styles.*/
|
|
16
|
+
rounded?: string | undefined;
|
|
17
|
+
/** Set the rotation of the item caret in the open state.*/
|
|
18
|
+
caretOpen?: string | undefined;
|
|
19
|
+
/** Set the rotation of the item caret in the closed state.*/
|
|
20
|
+
caretClosed?: string | undefined;
|
|
21
|
+
hyphenOpacity?: string | undefined;
|
|
22
|
+
/** Provide arbitrary classes to the tree item summary region.*/
|
|
23
|
+
regionSummary?: string | undefined;
|
|
24
|
+
/** Provide arbitrary classes to the symbol icon region.*/
|
|
25
|
+
regionSymbol?: string | undefined;
|
|
26
|
+
/** Provide arbitrary classes to the children region.*/
|
|
27
|
+
regionChildren?: string | undefined;
|
|
28
|
+
/** Provide the ARIA labelledby value.*/
|
|
29
|
+
labelledby?: string | undefined;
|
|
30
|
+
};
|
|
31
|
+
events: {
|
|
32
|
+
[evt: string]: CustomEvent<any>;
|
|
33
|
+
};
|
|
34
|
+
slots: {
|
|
35
|
+
default: {};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type TreeViewProps = typeof __propDef.props;
|
|
39
|
+
export type TreeViewEvents = typeof __propDef.events;
|
|
40
|
+
export type TreeViewSlots = typeof __propDef.slots;
|
|
41
|
+
export default class TreeView extends SvelteComponentTyped<TreeViewProps, TreeViewEvents, TreeViewSlots> {
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script>import { getContext, createEventDispatcher } from "svelte";
|
|
2
|
+
export let open = false;
|
|
3
|
+
export let spacing = "space-x-4";
|
|
4
|
+
export let padding = getContext("padding");
|
|
5
|
+
export let indent = getContext("indent");
|
|
6
|
+
export let hover = getContext("hover");
|
|
7
|
+
export let rounded = getContext("rounded");
|
|
8
|
+
export let caretOpen = getContext("caretOpen");
|
|
9
|
+
export let caretClosed = getContext("caretClosed");
|
|
10
|
+
export let hyphenOpacity = getContext("hyphenOpacity");
|
|
11
|
+
export let regionSummary = "";
|
|
12
|
+
export let regionSymbol = getContext("regionSymbol");
|
|
13
|
+
export let regionChildren = getContext("regionChildren");
|
|
14
|
+
const dispatch = createEventDispatcher();
|
|
15
|
+
$:
|
|
16
|
+
dispatch("toggle", { open });
|
|
17
|
+
const cBase = "";
|
|
18
|
+
const cSummary = "list-none flex items-center cursor-pointer";
|
|
19
|
+
const cSymbol = "fill-current w-3 text-center transition-transform duration-[200ms]";
|
|
20
|
+
const cChildren = "";
|
|
21
|
+
$:
|
|
22
|
+
classesCaretState = open ? caretOpen : caretClosed;
|
|
23
|
+
$:
|
|
24
|
+
classesBase = `${cBase} ${$$props.class ?? ""}`;
|
|
25
|
+
$:
|
|
26
|
+
classesSummary = `${cSummary} ${spacing} ${rounded} ${padding} ${hover} ${regionSummary}`;
|
|
27
|
+
$:
|
|
28
|
+
classesSymbol = `${cSymbol} ${classesCaret} ${regionSymbol}`;
|
|
29
|
+
$:
|
|
30
|
+
classesCaret = `${classesCaretState}`;
|
|
31
|
+
$:
|
|
32
|
+
classesHyphen = `${hyphenOpacity}`;
|
|
33
|
+
$:
|
|
34
|
+
classesChildren = `${cChildren} ${indent} ${regionChildren}`;
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<details bind:open class="tree-item {classesBase}" data-testid="tree-item">
|
|
38
|
+
<summary
|
|
39
|
+
class="tree-item-summary {classesSummary}"
|
|
40
|
+
role="treeitem"
|
|
41
|
+
aria-selected="false"
|
|
42
|
+
aria-expanded={$$slots.children ? open : undefined}
|
|
43
|
+
on:click
|
|
44
|
+
on:keydown
|
|
45
|
+
on:keyup
|
|
46
|
+
>
|
|
47
|
+
<!-- Symbol -->
|
|
48
|
+
<div class="tree-summary-symbol {classesSymbol}">
|
|
49
|
+
{#if $$slots.children}
|
|
50
|
+
<!-- SVG Caret -->
|
|
51
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
|
|
52
|
+
<path
|
|
53
|
+
d="M201.4 374.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 306.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z"
|
|
54
|
+
/>
|
|
55
|
+
</svg>
|
|
56
|
+
{:else}
|
|
57
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class="w-3 {classesHyphen}">
|
|
58
|
+
<path d="M432 256c0 17.7-14.3 32-32 32L48 288c-17.7 0-32-14.3-32-32s14.3-32 32-32l352 0c17.7 0 32 14.3 32 32z" />
|
|
59
|
+
</svg>
|
|
60
|
+
{/if}
|
|
61
|
+
</div>
|
|
62
|
+
<!-- Slot: Lead -->
|
|
63
|
+
{#if $$slots.lead}
|
|
64
|
+
<div class="tree-item-lead">
|
|
65
|
+
<slot name="lead" />
|
|
66
|
+
</div>
|
|
67
|
+
{/if}
|
|
68
|
+
<!-- Slot: Content -->
|
|
69
|
+
<div class="tree-item-content">
|
|
70
|
+
<slot />
|
|
71
|
+
</div>
|
|
72
|
+
</summary>
|
|
73
|
+
<div class="tree-item-children {classesChildren}" role="group">
|
|
74
|
+
<slot name="children" />
|
|
75
|
+
</div>
|
|
76
|
+
</details>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
/** Set open by default on load.*/
|
|
6
|
+
open?: boolean | undefined;
|
|
7
|
+
/** Provide classes to set the horizontal spacing.*/
|
|
8
|
+
spacing?: string | undefined;
|
|
9
|
+
/** Provide classes to set the tree item padding styles.*/
|
|
10
|
+
padding?: string | undefined;
|
|
11
|
+
/** Provide classes to set the tree children indentation*/
|
|
12
|
+
indent?: string | undefined;
|
|
13
|
+
/** Provide classes to set the tree item hover styles.*/
|
|
14
|
+
hover?: string | undefined;
|
|
15
|
+
/** Provide classes to set the tree item rounded styles.*/
|
|
16
|
+
rounded?: string | undefined;
|
|
17
|
+
/** Set the rotation of the item caret in the open state.*/
|
|
18
|
+
caretOpen?: string | undefined;
|
|
19
|
+
/** Set the rotation of the item caret in the closed state.*/
|
|
20
|
+
caretClosed?: string | undefined;
|
|
21
|
+
hyphenOpacity?: string | undefined;
|
|
22
|
+
/** Provide arbitrary classes to the tree item summary region.*/
|
|
23
|
+
regionSummary?: string | undefined;
|
|
24
|
+
/** Provide arbitrary classes to the symbol icon region.*/
|
|
25
|
+
regionSymbol?: string | undefined;
|
|
26
|
+
/** Provide arbitrary classes to the children region.*/
|
|
27
|
+
regionChildren?: string | undefined;
|
|
28
|
+
};
|
|
29
|
+
events: {
|
|
30
|
+
click: MouseEvent;
|
|
31
|
+
keydown: KeyboardEvent;
|
|
32
|
+
keyup: KeyboardEvent;
|
|
33
|
+
toggle: CustomEvent<any>;
|
|
34
|
+
} & {
|
|
35
|
+
[evt: string]: CustomEvent<any>;
|
|
36
|
+
};
|
|
37
|
+
slots: {
|
|
38
|
+
lead: {};
|
|
39
|
+
default: {};
|
|
40
|
+
children: {};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export type TreeViewItemProps = typeof __propDef.props;
|
|
44
|
+
export type TreeViewItemEvents = typeof __propDef.events;
|
|
45
|
+
export type TreeViewItemSlots = typeof __propDef.slots;
|
|
46
|
+
export default class TreeViewItem extends SvelteComponentTyped<TreeViewItemProps, TreeViewItemEvents, TreeViewItemSlots> {
|
|
47
|
+
}
|
|
48
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -53,6 +53,8 @@ export { default as TabGroup } from './components/Tab/TabGroup.svelte';
|
|
|
53
53
|
export { default as Tab } from './components/Tab/Tab.svelte';
|
|
54
54
|
export { default as TabAnchor } from './components/Tab/TabAnchor.svelte';
|
|
55
55
|
export { default as TableOfContents } from './components/TableOfContents/TableOfContents.svelte';
|
|
56
|
+
export { default as TreeView } from './components/TreeView/TreeView.svelte';
|
|
57
|
+
export { default as TreeViewItem } from './components/TreeView/TreeViewItem.svelte';
|
|
56
58
|
export { default as CodeBlock } from './utilities/CodeBlock/CodeBlock.svelte';
|
|
57
59
|
export { default as Modal } from './utilities/Modal/Modal.svelte';
|
|
58
60
|
export { default as Drawer } from './utilities/Drawer/Drawer.svelte';
|
package/dist/index.js
CHANGED
|
@@ -59,6 +59,8 @@ export { default as TabGroup } from './components/Tab/TabGroup.svelte';
|
|
|
59
59
|
export { default as Tab } from './components/Tab/Tab.svelte';
|
|
60
60
|
export { default as TabAnchor } from './components/Tab/TabAnchor.svelte';
|
|
61
61
|
export { default as TableOfContents } from './components/TableOfContents/TableOfContents.svelte';
|
|
62
|
+
export { default as TreeView } from './components/TreeView/TreeView.svelte';
|
|
63
|
+
export { default as TreeViewItem } from './components/TreeView/TreeViewItem.svelte';
|
|
62
64
|
// Utility Components
|
|
63
65
|
export { default as CodeBlock } from './utilities/CodeBlock/CodeBlock.svelte';
|
|
64
66
|
export { default as Modal } from './utilities/Modal/Modal.svelte';
|