@skeletonlabs/skeleton 2.2.0 → 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/actions/FocusTrap/focusTrap.js +1 -1
- package/dist/components/Accordion/AccordionItem.svelte +1 -1
- package/dist/components/FileButton/FileButton.svelte +4 -3
- package/dist/components/FileButton/FileButton.svelte.d.ts +2 -0
- package/dist/components/FileDropzone/FileDropzone.svelte +5 -0
- package/dist/components/FileDropzone/FileDropzone.svelte.d.ts +5 -0
- package/dist/components/InputChip/InputChip.svelte +10 -7
- package/dist/components/InputChip/InputChip.svelte.d.ts +6 -0
- package/dist/components/ProgressRadial/ProgressRadial.svelte +5 -3
- package/dist/components/ProgressRadial/ProgressRadial.svelte.d.ts +2 -0
- package/dist/components/Table/Table.svelte +1 -1
- package/dist/components/TreeView/RecursiveTreeView.svelte +75 -0
- package/dist/components/TreeView/RecursiveTreeView.svelte.d.ts +67 -0
- package/dist/components/TreeView/RecursiveTreeViewItem.svelte +140 -0
- package/dist/components/TreeView/RecursiveTreeViewItem.svelte.d.ts +38 -0
- package/dist/components/TreeView/TreeView.svelte +1 -7
- package/dist/components/TreeView/TreeView.svelte.d.ts +0 -9
- package/dist/components/TreeView/TreeViewItem.svelte +51 -14
- package/dist/components/TreeView/TreeViewItem.svelte.d.ts +5 -1
- package/dist/components/TreeView/types.d.ts +11 -12
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- 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/dist/utilities/LightSwitch/LightSwitch.svelte +2 -1
- package/dist/utilities/LightSwitch/LightSwitch.svelte.d.ts +2 -0
- package/package.json +1 -1
- package/dist/components/TreeView/TreeViewDataDrivenItem.svelte +0 -90
- package/dist/components/TreeView/TreeViewDataDrivenItem.svelte.d.ts +0 -27
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Action: Focus Trap
|
|
2
2
|
export function focusTrap(node, enabled) {
|
|
3
|
-
const elemWhitelist = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])';
|
|
3
|
+
const elemWhitelist = 'a[href]:not([tabindex="-1"]), button:not([tabindex="-1"]), input:not([tabindex="-1"]), textarea:not([tabindex="-1"]), select:not([tabindex="-1"]), details:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])';
|
|
4
4
|
let elemFirst;
|
|
5
5
|
let elemLast;
|
|
6
6
|
// When the first element is selected, shift+tab pressed, jump to the last selectable item.
|
|
@@ -5,7 +5,7 @@ const dispatch = createEventDispatcher();
|
|
|
5
5
|
export let open = false;
|
|
6
6
|
export let id = String(Math.random());
|
|
7
7
|
const cBase = "";
|
|
8
|
-
const cControl = "text-
|
|
8
|
+
const cControl = "text-start w-full flex items-center space-x-4";
|
|
9
9
|
const cControlCaret = "fill-current w-3 transition-transform duration-[200ms]";
|
|
10
10
|
const cPanel = "";
|
|
11
11
|
export let autocollapse = getContext("autocollapse");
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<script>export let files = void 0;
|
|
2
|
+
export let fileInput = void 0;
|
|
2
3
|
export let name;
|
|
3
4
|
export let width = "";
|
|
4
5
|
export let button = "btn variant-filled";
|
|
5
|
-
let elemFileInput;
|
|
6
6
|
function onButtonClick() {
|
|
7
|
-
|
|
7
|
+
if (fileInput)
|
|
8
|
+
fileInput.click();
|
|
8
9
|
}
|
|
9
10
|
function prunedRestProps() {
|
|
10
11
|
delete $$restProps.class;
|
|
@@ -19,7 +20,7 @@ $:
|
|
|
19
20
|
<div class="file-button {classesBase}" data-testid="file-button">
|
|
20
21
|
<!-- NOTE: Don't use `hidden` as it prevents `required` from operating -->
|
|
21
22
|
<div class="w-0 h-0 overflow-hidden">
|
|
22
|
-
<input type="file" bind:this={
|
|
23
|
+
<input type="file" bind:this={fileInput} bind:files {name} {...prunedRestProps()} on:change />
|
|
23
24
|
</div>
|
|
24
25
|
<!-- Button -->
|
|
25
26
|
<button
|
|
@@ -4,6 +4,8 @@ declare const __propDef: {
|
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
/** Bind FileList to the file input.*/
|
|
6
6
|
files?: FileList | undefined;
|
|
7
|
+
/** File input reference.*/
|
|
8
|
+
fileInput?: HTMLInputElement | undefined;
|
|
7
9
|
/** Required. Set a unique name for the file input.*/
|
|
8
10
|
name: string;
|
|
9
11
|
/** Provide classes to set the width.*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script>export let files = void 0;
|
|
2
|
+
export let fileInput = void 0;
|
|
2
3
|
export let name;
|
|
3
4
|
export let border = "border-2 border-dashed";
|
|
4
5
|
export let padding = "p-4 py-8";
|
|
@@ -28,6 +29,7 @@ function prunedRestProps() {
|
|
|
28
29
|
<!-- NOTE: keep `bind:files` here, unlike FileButton -->
|
|
29
30
|
<input
|
|
30
31
|
bind:files
|
|
32
|
+
bind:this={fileInput}
|
|
31
33
|
type="file"
|
|
32
34
|
{name}
|
|
33
35
|
class="dropzone-input {classesInput}"
|
|
@@ -41,6 +43,9 @@ function prunedRestProps() {
|
|
|
41
43
|
on:keydown
|
|
42
44
|
on:keyup
|
|
43
45
|
on:keypress
|
|
46
|
+
on:focus
|
|
47
|
+
on:focusin
|
|
48
|
+
on:focusout
|
|
44
49
|
/>
|
|
45
50
|
<!-- Interface -->
|
|
46
51
|
<div class="dropzone-interface {classesInterface} {regionInterface}">
|
|
@@ -4,6 +4,8 @@ declare const __propDef: {
|
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
/** Bind FileList to the file input.*/
|
|
6
6
|
files?: FileList | undefined;
|
|
7
|
+
/** File input reference.*/
|
|
8
|
+
fileInput?: HTMLInputElement | undefined;
|
|
7
9
|
/** Required. Set a unique name for the file input.*/
|
|
8
10
|
name: string;
|
|
9
11
|
/** Provide classes to set the border styles.*/
|
|
@@ -33,6 +35,9 @@ declare const __propDef: {
|
|
|
33
35
|
keydown: KeyboardEvent;
|
|
34
36
|
keyup: KeyboardEvent;
|
|
35
37
|
keypress: KeyboardEvent;
|
|
38
|
+
focus: FocusEvent;
|
|
39
|
+
focusin: FocusEvent;
|
|
40
|
+
focusout: FocusEvent;
|
|
36
41
|
} & {
|
|
37
42
|
[evt: string]: CustomEvent<any>;
|
|
38
43
|
};
|
|
@@ -25,6 +25,9 @@ export let chips = "variant-filled";
|
|
|
25
25
|
export let invalid = "input-error";
|
|
26
26
|
export let padding = "p-2";
|
|
27
27
|
export let rounded = "rounded-container-token";
|
|
28
|
+
export let regionChipWrapper = "";
|
|
29
|
+
export let regionChipList = "";
|
|
30
|
+
export let regionInput = "";
|
|
28
31
|
export let transitions = !$prefersReducedMotionStore;
|
|
29
32
|
export let listTransitionIn = fly;
|
|
30
33
|
export let listTransitionInParams = { duration: 150, opacity: 0, y: -20 };
|
|
@@ -35,7 +38,7 @@ export let chipTransitionInParams = { duration: 150, opacity: 0 };
|
|
|
35
38
|
export let chipTransitionOut = scale;
|
|
36
39
|
export let chipTransitionOutParams = { duration: 150, opacity: 0 };
|
|
37
40
|
const cBase = "textarea cursor-pointer";
|
|
38
|
-
const
|
|
41
|
+
const cChipWrapper = "space-y-4";
|
|
39
42
|
const cChipList = "flex flex-wrap gap-2";
|
|
40
43
|
const cInputField = "unstyled bg-transparent border-0 !ring-0 p-0 w-full";
|
|
41
44
|
let inputValid = true;
|
|
@@ -105,11 +108,11 @@ $:
|
|
|
105
108
|
$:
|
|
106
109
|
classesBase = `${cBase} ${padding} ${rounded} ${$$props.class ?? ""} ${classesInvalid}`;
|
|
107
110
|
$:
|
|
108
|
-
|
|
111
|
+
classesChipWrapper = `${cChipWrapper} ${regionChipWrapper}`;
|
|
109
112
|
$:
|
|
110
|
-
classesChipList = `${cChipList}`;
|
|
113
|
+
classesChipList = `${cChipList} ${regionChipList}`;
|
|
111
114
|
$:
|
|
112
|
-
|
|
115
|
+
classesInput = `${cInputField} ${regionInput}`;
|
|
113
116
|
$:
|
|
114
117
|
chipValues = value?.map((val, i) => {
|
|
115
118
|
if (chipValues[i]?.val === val)
|
|
@@ -126,15 +129,15 @@ $:
|
|
|
126
129
|
{#each value as option}<option value={option}>{option}</option>{/each}
|
|
127
130
|
</select>
|
|
128
131
|
</div>
|
|
129
|
-
<!--
|
|
130
|
-
<div class="input-chip-
|
|
132
|
+
<!-- Chip Wrapper -->
|
|
133
|
+
<div class="input-chip-wrapper {classesChipWrapper}">
|
|
131
134
|
<!-- Input Field -->
|
|
132
135
|
<form on:submit={addChip}>
|
|
133
136
|
<input
|
|
134
137
|
type="text"
|
|
135
138
|
bind:value={input}
|
|
136
139
|
placeholder={$$restProps.placeholder ?? 'Enter values...'}
|
|
137
|
-
class="input-chip-field {
|
|
140
|
+
class="input-chip-field {classesInput}"
|
|
138
141
|
on:input={onInputHandler}
|
|
139
142
|
on:input
|
|
140
143
|
on:focus
|
|
@@ -38,6 +38,12 @@ declare class __sveltets_Render<ListTransitionIn extends Transition = FlyTransit
|
|
|
38
38
|
padding?: string | undefined;
|
|
39
39
|
/** Provide classes to set border radius styles.*/
|
|
40
40
|
rounded?: string | undefined;
|
|
41
|
+
/** Provide arbitrary classes to style the chip wrapper region.*/
|
|
42
|
+
regionChipWrapper?: string | undefined;
|
|
43
|
+
/** Provide arbitrary classes to style the chip list region.*/
|
|
44
|
+
regionChipList?: string | undefined;
|
|
45
|
+
/** Provide arbitrary classes to style the input field region.*/
|
|
46
|
+
regionInput?: string | undefined;
|
|
41
47
|
/** Enable/Disable transitions*/
|
|
42
48
|
transitions?: boolean | undefined;
|
|
43
49
|
/** Provide the transition used in list on entry.*/
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
export let value = void 0;
|
|
4
4
|
export let stroke = 40;
|
|
5
5
|
export let font = 56;
|
|
6
|
+
export let strokeLinecap = "butt";
|
|
6
7
|
export let width = "w-36";
|
|
7
8
|
export let meter = "stroke-surface-900 dark:stroke-surface-50";
|
|
8
9
|
export let track = "stroke-surface-500/30";
|
|
@@ -12,7 +13,7 @@ const cBase = "progress-radial relative overflow-hidden";
|
|
|
12
13
|
const cBaseTrack = "fill-transparent";
|
|
13
14
|
const cBaseMeter = "fill-transparent transition-[stroke-dashoffset] duration-200 -rotate-90 origin-[50%_50%]";
|
|
14
15
|
const baseSize = 512;
|
|
15
|
-
const radius = baseSize / 2;
|
|
16
|
+
const radius = baseSize / 2 - stroke / 2;
|
|
16
17
|
let circumference = radius;
|
|
17
18
|
let dashoffset;
|
|
18
19
|
function setProgress(percent) {
|
|
@@ -40,18 +41,19 @@ $:
|
|
|
40
41
|
<!-- Draw SVG -->
|
|
41
42
|
<svg viewBox="0 0 {baseSize} {baseSize}" class="rounded-full" class:animate-spin={value === undefined}>
|
|
42
43
|
<!-- Track -->
|
|
43
|
-
<circle class="progress-radial-track {cBaseTrack} {track}" stroke-width={stroke} r={
|
|
44
|
+
<circle class="progress-radial-track {cBaseTrack} {track}" stroke-width={stroke} r={radius} cx="50%" cy="50%" />
|
|
44
45
|
|
|
45
46
|
<!-- Meter -->
|
|
46
47
|
<circle
|
|
47
48
|
class="progress-radial-meter {cBaseMeter} {meter}"
|
|
48
49
|
stroke-width={stroke}
|
|
49
|
-
r={
|
|
50
|
+
r={radius}
|
|
50
51
|
cx="50%"
|
|
51
52
|
cy="50%"
|
|
52
53
|
style:stroke-dasharray="{circumference}
|
|
53
54
|
{circumference}"
|
|
54
55
|
style:stroke-dashoffset={dashoffset}
|
|
56
|
+
stroke-linecap={strokeLinecap}
|
|
55
57
|
/>
|
|
56
58
|
|
|
57
59
|
<!-- Center Text -->
|
|
@@ -8,6 +8,8 @@ declare const __propDef: {
|
|
|
8
8
|
stroke?: number | undefined;
|
|
9
9
|
/** Sets the base font size. Scales responsively.*/
|
|
10
10
|
font?: number | undefined;
|
|
11
|
+
/** Sets the stoke-linecap value*/
|
|
12
|
+
strokeLinecap?: "butt" | "round" | "square" | undefined;
|
|
11
13
|
/** Provide classes to set the width.*/
|
|
12
14
|
width?: string | undefined;
|
|
13
15
|
/** Provide classes to set meter color.*/
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<script>import { createEventDispatcher, setContext } from "svelte";
|
|
2
|
+
import RecursiveTreeViewItem from "./RecursiveTreeViewItem.svelte";
|
|
3
|
+
export let selection = false;
|
|
4
|
+
export let multiple = false;
|
|
5
|
+
export let relational = false;
|
|
6
|
+
export let nodes = [];
|
|
7
|
+
export let expandedNodes = [];
|
|
8
|
+
export let disabledNodes = [];
|
|
9
|
+
export let checkedNodes = [];
|
|
10
|
+
export let indeterminateNodes = [];
|
|
11
|
+
export let width = "w-full";
|
|
12
|
+
export let spacing = "space-y-1";
|
|
13
|
+
export let open = false;
|
|
14
|
+
export let disabled = false;
|
|
15
|
+
export let padding = "py-4 px-4";
|
|
16
|
+
export let indent = "ml-4";
|
|
17
|
+
export let hover = "hover:variant-soft";
|
|
18
|
+
export let rounded = "rounded-container-token";
|
|
19
|
+
export let caretOpen = "rotate-180";
|
|
20
|
+
export let caretClosed = "";
|
|
21
|
+
export let hyphenOpacity = "opacity-10";
|
|
22
|
+
export let regionSummary = "";
|
|
23
|
+
export let regionSymbol = "";
|
|
24
|
+
export let regionChildren = "";
|
|
25
|
+
export let labelledby = "";
|
|
26
|
+
setContext("open", open);
|
|
27
|
+
setContext("selection", selection);
|
|
28
|
+
setContext("multiple", multiple);
|
|
29
|
+
setContext("relational", relational);
|
|
30
|
+
setContext("disabled", disabled);
|
|
31
|
+
setContext("padding", padding);
|
|
32
|
+
setContext("indent", indent);
|
|
33
|
+
setContext("hover", hover);
|
|
34
|
+
setContext("rounded", rounded);
|
|
35
|
+
setContext("caretOpen", caretOpen);
|
|
36
|
+
setContext("caretClosed", caretClosed);
|
|
37
|
+
setContext("hyphenOpacity", hyphenOpacity);
|
|
38
|
+
setContext("regionSummary", regionSummary);
|
|
39
|
+
setContext("regionSymbol", regionSymbol);
|
|
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
|
+
}
|
|
52
|
+
$:
|
|
53
|
+
classesBase = `${width} ${spacing} ${$$props.class ?? ""}`;
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<div
|
|
57
|
+
class="tree {classesBase}"
|
|
58
|
+
data-testid="tree"
|
|
59
|
+
role="tree"
|
|
60
|
+
aria-multiselectable={multiple}
|
|
61
|
+
aria-label={labelledby}
|
|
62
|
+
aria-disabled={disabled}
|
|
63
|
+
>
|
|
64
|
+
{#if nodes && nodes.length > 0}
|
|
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
|
+
/>
|
|
74
|
+
{/if}
|
|
75
|
+
</div>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { TreeViewNode } from '../../index.js';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
/** Enable tree-view selection.*/
|
|
7
|
+
selection?: boolean | undefined;
|
|
8
|
+
/** Enable selection of multiple items.*/
|
|
9
|
+
multiple?: boolean | undefined;
|
|
10
|
+
/** Enable relational checking.*/
|
|
11
|
+
relational?: boolean | undefined;
|
|
12
|
+
/** Provide data-driven nodes.*/
|
|
13
|
+
nodes?: TreeViewNode[] | undefined;
|
|
14
|
+
/** provides id's of expanded nodes*/
|
|
15
|
+
expandedNodes?: string[] | undefined;
|
|
16
|
+
/** provides id's of disabled nodes*/
|
|
17
|
+
disabledNodes?: string[] | undefined;
|
|
18
|
+
/** provides id's of checked nodes*/
|
|
19
|
+
checkedNodes?: string[] | undefined;
|
|
20
|
+
/** provides id's of indeterminate nodes*/
|
|
21
|
+
indeterminateNodes?: string[] | undefined;
|
|
22
|
+
/** Provide classes to set the tree width.*/
|
|
23
|
+
width?: string | undefined;
|
|
24
|
+
/** Provide classes to set the vertical spacing between items.*/
|
|
25
|
+
spacing?: string | undefined;
|
|
26
|
+
/** Set open by default on load.*/
|
|
27
|
+
open?: boolean | undefined;
|
|
28
|
+
/** Set the tree disabled state*/
|
|
29
|
+
disabled?: boolean | undefined;
|
|
30
|
+
/** Provide classes to set the tree item padding styles.*/
|
|
31
|
+
padding?: string | undefined;
|
|
32
|
+
/** Provide classes to set the tree children indentation*/
|
|
33
|
+
indent?: string | undefined;
|
|
34
|
+
/** Provide classes to set the tree item hover styles.*/
|
|
35
|
+
hover?: string | undefined;
|
|
36
|
+
/** Provide classes to set the tree item rounded styles.*/
|
|
37
|
+
rounded?: string | undefined;
|
|
38
|
+
/** Set the rotation of the item caret in the open state.*/
|
|
39
|
+
caretOpen?: string | undefined;
|
|
40
|
+
/** Set the rotation of the item caret in the closed state.*/
|
|
41
|
+
caretClosed?: string | undefined;
|
|
42
|
+
hyphenOpacity?: string | undefined;
|
|
43
|
+
/** Provide arbitrary classes to the tree item summary region.*/
|
|
44
|
+
regionSummary?: string | undefined;
|
|
45
|
+
/** Provide arbitrary classes to the symbol icon region.*/
|
|
46
|
+
regionSymbol?: string | undefined;
|
|
47
|
+
/** Provide arbitrary classes to the children region.*/
|
|
48
|
+
regionChildren?: string | undefined;
|
|
49
|
+
/** Provide the ARIA labelledby value.*/
|
|
50
|
+
labelledby?: string | undefined;
|
|
51
|
+
};
|
|
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
|
+
} & {
|
|
58
|
+
[evt: string]: CustomEvent<any>;
|
|
59
|
+
};
|
|
60
|
+
slots: {};
|
|
61
|
+
};
|
|
62
|
+
export type RecursiveTreeViewProps = typeof __propDef.props;
|
|
63
|
+
export type RecursiveTreeViewEvents = typeof __propDef.events;
|
|
64
|
+
export type RecursiveTreeViewSlots = typeof __propDef.slots;
|
|
65
|
+
export default class RecursiveTreeView extends SvelteComponentTyped<RecursiveTreeViewProps, RecursiveTreeViewEvents, RecursiveTreeViewSlots> {
|
|
66
|
+
}
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
<script>import TreeViewItem from "./TreeViewItem.svelte";
|
|
2
|
+
import RecursiveTreeViewItem from "./RecursiveTreeViewItem.svelte";
|
|
3
|
+
import { createEventDispatcher, getContext, onMount, tick } from "svelte";
|
|
4
|
+
export let nodes = [];
|
|
5
|
+
export let expandedNodes = [];
|
|
6
|
+
export let disabledNodes = [];
|
|
7
|
+
export let checkedNodes = [];
|
|
8
|
+
export let indeterminateNodes = [];
|
|
9
|
+
let selection = getContext("selection");
|
|
10
|
+
let multiple = getContext("multiple");
|
|
11
|
+
let relational = getContext("relational");
|
|
12
|
+
let tempCheckedNodes = [];
|
|
13
|
+
let group;
|
|
14
|
+
let name = "";
|
|
15
|
+
const dispatch = createEventDispatcher();
|
|
16
|
+
function toggleNode(node, open) {
|
|
17
|
+
if (!node.children?.length)
|
|
18
|
+
return;
|
|
19
|
+
if (open) {
|
|
20
|
+
if (!expandedNodes.includes(node.id)) {
|
|
21
|
+
expandedNodes.push(node.id);
|
|
22
|
+
expandedNodes = expandedNodes;
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
if (expandedNodes.includes(node.id)) {
|
|
26
|
+
expandedNodes.splice(expandedNodes.indexOf(node.id), 1);
|
|
27
|
+
expandedNodes = expandedNodes;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function checkNode(node, checked, indeterminate) {
|
|
32
|
+
if (checked) {
|
|
33
|
+
if (!checkedNodes.includes(node.id)) {
|
|
34
|
+
checkedNodes.push(node.id);
|
|
35
|
+
checkedNodes = checkedNodes;
|
|
36
|
+
}
|
|
37
|
+
if (!indeterminate && indeterminateNodes.includes(node.id)) {
|
|
38
|
+
indeterminateNodes.splice(indeterminateNodes.indexOf(node.id), 1);
|
|
39
|
+
indeterminateNodes = indeterminateNodes;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
if (checkedNodes.includes(node.id)) {
|
|
43
|
+
checkedNodes.splice(checkedNodes.indexOf(node.id), 1);
|
|
44
|
+
checkedNodes = checkedNodes;
|
|
45
|
+
}
|
|
46
|
+
if (indeterminate && !indeterminateNodes.includes(node.id)) {
|
|
47
|
+
indeterminateNodes.push(node.id);
|
|
48
|
+
indeterminateNodes = indeterminateNodes;
|
|
49
|
+
} else if (!indeterminate && indeterminateNodes.includes(node.id)) {
|
|
50
|
+
indeterminateNodes.splice(indeterminateNodes.indexOf(node.id), 1);
|
|
51
|
+
indeterminateNodes = indeterminateNodes;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
tempCheckedNodes = [...checkedNodes];
|
|
56
|
+
onMount(async () => {
|
|
57
|
+
if (selection) {
|
|
58
|
+
name = String(Math.random());
|
|
59
|
+
if (group === void 0) {
|
|
60
|
+
if (multiple) {
|
|
61
|
+
group = [];
|
|
62
|
+
nodes.forEach((node) => {
|
|
63
|
+
if (checkedNodes.includes(node.id) && Array.isArray(group))
|
|
64
|
+
group.push(node.id);
|
|
65
|
+
});
|
|
66
|
+
group = group;
|
|
67
|
+
} else if (!nodes.some((node) => checkedNodes.includes(node.id))) {
|
|
68
|
+
group = "";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (!relational)
|
|
72
|
+
treeItems = [];
|
|
73
|
+
checkedNodes = [];
|
|
74
|
+
await tick();
|
|
75
|
+
checkedNodes = [...tempCheckedNodes];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
export let treeItems = [];
|
|
79
|
+
let children = [];
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
{#if nodes && nodes.length > 0}
|
|
83
|
+
{#each nodes as node, i}
|
|
84
|
+
<TreeViewItem
|
|
85
|
+
bind:this={treeItems[i]}
|
|
86
|
+
bind:children={children[i]}
|
|
87
|
+
bind:group
|
|
88
|
+
bind:name
|
|
89
|
+
bind:value={node.id}
|
|
90
|
+
hideLead={!node.lead}
|
|
91
|
+
hideChildren={!node.children || node.children.length === 0}
|
|
92
|
+
open={expandedNodes.includes(node.id)}
|
|
93
|
+
disabled={disabledNodes.includes(node.id)}
|
|
94
|
+
checked={checkedNodes.includes(node.id)}
|
|
95
|
+
indeterminate={indeterminateNodes.includes(node.id)}
|
|
96
|
+
on:toggle={(e) => toggleNode(node, e.detail.open)}
|
|
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
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
{#if typeof node.content === 'string'}
|
|
109
|
+
{@html node.content}
|
|
110
|
+
{:else}
|
|
111
|
+
<svelte:component this={node.content} {...node.contentProps} />
|
|
112
|
+
{/if}
|
|
113
|
+
<svelte:fragment slot="lead">
|
|
114
|
+
{#if typeof node.lead === 'string'}
|
|
115
|
+
{@html node.lead}
|
|
116
|
+
{:else}
|
|
117
|
+
<svelte:component this={node.lead} {...node.leadProps} />
|
|
118
|
+
{/if}
|
|
119
|
+
</svelte:fragment>
|
|
120
|
+
<svelte:fragment slot="children">
|
|
121
|
+
<RecursiveTreeViewItem
|
|
122
|
+
nodes={node.children}
|
|
123
|
+
bind:expandedNodes
|
|
124
|
+
bind:disabledNodes
|
|
125
|
+
bind:checkedNodes
|
|
126
|
+
bind:indeterminateNodes
|
|
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
|
+
})}
|
|
136
|
+
/>
|
|
137
|
+
</svelte:fragment>
|
|
138
|
+
</TreeViewItem>
|
|
139
|
+
{/each}
|
|
140
|
+
{/if}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* provides id's of expanded nodes
|
|
9
|
+
* @type {string[]}
|
|
10
|
+
*/ expandedNodes?: string[] | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* provides id's of disabled nodes
|
|
13
|
+
* @type {string[]}
|
|
14
|
+
*/ disabledNodes?: string[] | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* provides id's of checked nodes
|
|
17
|
+
* @type {string[]}
|
|
18
|
+
*/ checkedNodes?: string[] | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* provides id's of indeterminate nodes
|
|
21
|
+
* @type {string[]}
|
|
22
|
+
*/ indeterminateNodes?: string[] | undefined;
|
|
23
|
+
treeItems?: TreeViewItem[] | undefined;
|
|
24
|
+
};
|
|
25
|
+
events: {
|
|
26
|
+
click: CustomEvent<any>;
|
|
27
|
+
toggle: CustomEvent<any>;
|
|
28
|
+
} & {
|
|
29
|
+
[evt: string]: CustomEvent<any>;
|
|
30
|
+
};
|
|
31
|
+
slots: {};
|
|
32
|
+
};
|
|
33
|
+
export type RecursiveTreeViewItemProps = typeof __propDef.props;
|
|
34
|
+
export type RecursiveTreeViewItemEvents = typeof __propDef.events;
|
|
35
|
+
export type RecursiveTreeViewItemSlots = typeof __propDef.slots;
|
|
36
|
+
export default class RecursiveTreeViewItem extends SvelteComponentTyped<RecursiveTreeViewItemProps, RecursiveTreeViewItemEvents, RecursiveTreeViewItemSlots> {
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
<script>import { setContext } from "svelte";
|
|
2
|
-
import TreeViewDataDrivenItem from "./TreeViewDataDrivenItem.svelte";
|
|
3
2
|
export let selection = false;
|
|
4
3
|
export let multiple = false;
|
|
5
|
-
export let nodes = [];
|
|
6
4
|
export let width = "w-full";
|
|
7
5
|
export let spacing = "space-y-1";
|
|
8
6
|
export let open = false;
|
|
@@ -66,9 +64,5 @@ let tree;
|
|
|
66
64
|
aria-label={labelledby}
|
|
67
65
|
aria-disabled={disabled}
|
|
68
66
|
>
|
|
69
|
-
|
|
70
|
-
<TreeViewDataDrivenItem bind:nodes on:change on:click on:toggle on:keydown on:keyup />
|
|
71
|
-
{:else}
|
|
72
|
-
<slot />
|
|
73
|
-
{/if}
|
|
67
|
+
<slot />
|
|
74
68
|
</div>
|
|
@@ -1,5 +1,4 @@
|
|
|
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;
|
|
@@ -7,8 +6,6 @@ declare const __propDef: {
|
|
|
7
6
|
selection?: boolean | undefined;
|
|
8
7
|
/** Enable selection of multiple items.*/
|
|
9
8
|
multiple?: boolean | undefined;
|
|
10
|
-
/** Provide data-driven nodes.*/
|
|
11
|
-
nodes?: TreeViewNode[] | undefined;
|
|
12
9
|
/** Provide classes to set the tree width.*/
|
|
13
10
|
width?: string | undefined;
|
|
14
11
|
/** Provide classes to set the vertical spacing between items.*/
|
|
@@ -42,12 +39,6 @@ declare const __propDef: {
|
|
|
42
39
|
collapseAll?: (() => void) | undefined;
|
|
43
40
|
};
|
|
44
41
|
events: {
|
|
45
|
-
change: Event;
|
|
46
|
-
click: MouseEvent;
|
|
47
|
-
toggle: CustomEvent<any>;
|
|
48
|
-
keydown: KeyboardEvent;
|
|
49
|
-
keyup: KeyboardEvent;
|
|
50
|
-
} & {
|
|
51
42
|
[evt: string]: CustomEvent<any>;
|
|
52
43
|
};
|
|
53
44
|
slots: {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<!-- To access props and events using reference -->
|
|
2
2
|
<svelte:options accessors />
|
|
3
3
|
|
|
4
|
-
<script>import { getContext, createEventDispatcher } from "svelte";
|
|
4
|
+
<script>import { getContext, createEventDispatcher, onMount } from "svelte";
|
|
5
5
|
export let group = void 0;
|
|
6
6
|
export let name = void 0;
|
|
7
7
|
export let value = void 0;
|
|
8
|
+
export let checked = false;
|
|
8
9
|
export let children = [];
|
|
9
10
|
export let spacing = "space-x-4";
|
|
10
11
|
export let open = getContext("open");
|
|
@@ -24,7 +25,6 @@ export let regionSymbol = getContext("regionSymbol");
|
|
|
24
25
|
export let regionChildren = getContext("regionChildren");
|
|
25
26
|
export let hideLead = false;
|
|
26
27
|
export let hideChildren = false;
|
|
27
|
-
let checked = false;
|
|
28
28
|
let treeItem;
|
|
29
29
|
let childrenDiv;
|
|
30
30
|
function onSummaryClick(event) {
|
|
@@ -33,16 +33,29 @@ function onSummaryClick(event) {
|
|
|
33
33
|
}
|
|
34
34
|
$:
|
|
35
35
|
if (multiple)
|
|
36
|
-
updateCheckbox(group);
|
|
36
|
+
updateCheckbox(group, indeterminate);
|
|
37
37
|
$:
|
|
38
38
|
if (multiple)
|
|
39
|
-
updateGroup(checked);
|
|
40
|
-
|
|
39
|
+
updateGroup(checked, indeterminate);
|
|
40
|
+
$:
|
|
41
|
+
if (!multiple)
|
|
42
|
+
updateRadio(group);
|
|
43
|
+
$:
|
|
44
|
+
if (!multiple)
|
|
45
|
+
updateRadioGroup(checked);
|
|
46
|
+
let initUpdate = true;
|
|
47
|
+
function updateCheckbox(group2, indeterminate2) {
|
|
41
48
|
if (!Array.isArray(group2))
|
|
42
49
|
return;
|
|
43
50
|
checked = group2.indexOf(value) >= 0;
|
|
51
|
+
dispatch("groupChange", { checked, indeterminate: indeterminate2 });
|
|
52
|
+
dispatch("childChange");
|
|
53
|
+
if (initUpdate) {
|
|
54
|
+
onParentChange();
|
|
55
|
+
initUpdate = false;
|
|
56
|
+
}
|
|
44
57
|
}
|
|
45
|
-
function updateGroup(checked2) {
|
|
58
|
+
function updateGroup(checked2, indeterminate2) {
|
|
46
59
|
if (!Array.isArray(group))
|
|
47
60
|
return;
|
|
48
61
|
const index = group.indexOf(value);
|
|
@@ -50,14 +63,28 @@ function updateGroup(checked2) {
|
|
|
50
63
|
if (index < 0) {
|
|
51
64
|
group.push(value);
|
|
52
65
|
group = group;
|
|
66
|
+
onParentChange();
|
|
53
67
|
}
|
|
54
68
|
} else {
|
|
55
69
|
if (index >= 0) {
|
|
56
70
|
group.splice(index, 1);
|
|
57
71
|
group = group;
|
|
72
|
+
onParentChange();
|
|
58
73
|
}
|
|
59
74
|
}
|
|
60
75
|
}
|
|
76
|
+
function updateRadio(group2) {
|
|
77
|
+
checked = group2 === value;
|
|
78
|
+
dispatch("groupChange", { checked, indeterminate: false });
|
|
79
|
+
if (group2)
|
|
80
|
+
dispatch("childChange");
|
|
81
|
+
}
|
|
82
|
+
function updateRadioGroup(checked2) {
|
|
83
|
+
if (checked2 && group !== value)
|
|
84
|
+
group = value;
|
|
85
|
+
else if (!checked2 && group === value)
|
|
86
|
+
group = "";
|
|
87
|
+
}
|
|
61
88
|
function onChildValueChange() {
|
|
62
89
|
if (multiple) {
|
|
63
90
|
if (!Array.isArray(group))
|
|
@@ -67,6 +94,10 @@ function onChildValueChange() {
|
|
|
67
94
|
const index = group.indexOf(value);
|
|
68
95
|
if (children.some((c) => c.indeterminate)) {
|
|
69
96
|
indeterminate = true;
|
|
97
|
+
if (index >= 0) {
|
|
98
|
+
group.splice(index, 1);
|
|
99
|
+
group = group;
|
|
100
|
+
}
|
|
70
101
|
} else if (childrenValues.every((c) => Array.isArray(childrenGroup) && childrenGroup.includes(c))) {
|
|
71
102
|
indeterminate = false;
|
|
72
103
|
if (index < 0) {
|
|
@@ -75,6 +106,10 @@ function onChildValueChange() {
|
|
|
75
106
|
}
|
|
76
107
|
} else if (childrenValues.some((c) => Array.isArray(childrenGroup) && childrenGroup.includes(c))) {
|
|
77
108
|
indeterminate = true;
|
|
109
|
+
if (index >= 0) {
|
|
110
|
+
group.splice(index, 1);
|
|
111
|
+
group = group;
|
|
112
|
+
}
|
|
78
113
|
} else {
|
|
79
114
|
indeterminate = false;
|
|
80
115
|
if (index >= 0) {
|
|
@@ -83,11 +118,13 @@ function onChildValueChange() {
|
|
|
83
118
|
}
|
|
84
119
|
}
|
|
85
120
|
} else {
|
|
86
|
-
if (group !== value) {
|
|
121
|
+
if (group !== value && children.some((c) => c.checked)) {
|
|
87
122
|
group = value;
|
|
123
|
+
} else if (group === value && !children.some((c) => c.checked)) {
|
|
124
|
+
group = "";
|
|
88
125
|
}
|
|
89
126
|
}
|
|
90
|
-
dispatch("
|
|
127
|
+
dispatch("childChange");
|
|
91
128
|
}
|
|
92
129
|
export function onParentChange() {
|
|
93
130
|
if (!multiple || !children || children.length === 0)
|
|
@@ -115,16 +152,18 @@ export function onParentChange() {
|
|
|
115
152
|
}
|
|
116
153
|
};
|
|
117
154
|
children.forEach((child) => {
|
|
155
|
+
if (!child)
|
|
156
|
+
return;
|
|
118
157
|
index >= 0 ? checkChild(child) : uncheckChild(child);
|
|
119
158
|
child.onParentChange();
|
|
120
159
|
});
|
|
121
160
|
}
|
|
122
161
|
$:
|
|
123
|
-
if (!multiple && group) {
|
|
162
|
+
if (!multiple && group !== void 0) {
|
|
124
163
|
if (group !== value) {
|
|
125
164
|
children.forEach((child) => {
|
|
126
165
|
if (child)
|
|
127
|
-
child.group =
|
|
166
|
+
child.group = "";
|
|
128
167
|
});
|
|
129
168
|
}
|
|
130
169
|
}
|
|
@@ -134,7 +173,7 @@ $:
|
|
|
134
173
|
$:
|
|
135
174
|
children.forEach((child) => {
|
|
136
175
|
if (child)
|
|
137
|
-
child.$on("
|
|
176
|
+
child.$on("childChange", onChildValueChange);
|
|
138
177
|
});
|
|
139
178
|
function onKeyDown(event) {
|
|
140
179
|
function getRootTree() {
|
|
@@ -260,12 +299,10 @@ $:
|
|
|
260
299
|
{value}
|
|
261
300
|
bind:checked
|
|
262
301
|
bind:indeterminate
|
|
263
|
-
on:click
|
|
264
|
-
on:change
|
|
265
302
|
on:change={onParentChange}
|
|
266
303
|
/>
|
|
267
304
|
{:else}
|
|
268
|
-
<input class="radio tree-item-radio" type="radio" bind:group {name} {value}
|
|
305
|
+
<input class="radio tree-item-radio" type="radio" bind:group {name} {value} />
|
|
269
306
|
{/if}
|
|
270
307
|
{/if}
|
|
271
308
|
|
|
@@ -9,6 +9,8 @@ declare const __propDef: {
|
|
|
9
9
|
name?: string | undefined;
|
|
10
10
|
/** Set the input's value.*/
|
|
11
11
|
value?: unknown;
|
|
12
|
+
/** Set the input's check state*/
|
|
13
|
+
checked?: boolean | undefined;
|
|
12
14
|
/** Provide children references to support relational checking.*/
|
|
13
15
|
children?: TreeViewItem[] | undefined;
|
|
14
16
|
/** Provide classes to set the horizontal spacing.*/
|
|
@@ -52,7 +54,6 @@ declare const __propDef: {
|
|
|
52
54
|
click: MouseEvent;
|
|
53
55
|
keydown: KeyboardEvent;
|
|
54
56
|
keyup: KeyboardEvent;
|
|
55
|
-
change: Event;
|
|
56
57
|
toggle: CustomEvent<any>;
|
|
57
58
|
} & {
|
|
58
59
|
[evt: string]: CustomEvent<any>;
|
|
@@ -77,6 +78,9 @@ export default class TreeViewItem extends SvelteComponentTyped<TreeViewItemProps
|
|
|
77
78
|
get value(): unknown;
|
|
78
79
|
/**accessor*/
|
|
79
80
|
set value(_: unknown);
|
|
81
|
+
get checked(): boolean | undefined;
|
|
82
|
+
/**accessor*/
|
|
83
|
+
set checked(_: boolean | undefined);
|
|
80
84
|
get children(): TreeViewItem[] | undefined;
|
|
81
85
|
/**accessor*/
|
|
82
86
|
set children(_: TreeViewItem[] | undefined);
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
+
import type { ComponentType } from 'svelte';
|
|
1
2
|
export interface TreeViewNode {
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
|
|
3
|
+
/** Nodes Unique ID */
|
|
4
|
+
id: string;
|
|
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;
|
|
10
13
|
/** children nodes. */
|
|
11
14
|
children?: TreeViewNode[];
|
|
12
15
|
/** Set the input's value. */
|
|
13
16
|
value?: unknown;
|
|
14
|
-
/** input checked */
|
|
15
|
-
checked?: boolean;
|
|
16
|
-
/** input is set to indeterminate, only availabe in multiple selection mode. */
|
|
17
|
-
indeterminate?: boolean;
|
|
18
17
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -56,7 +56,8 @@ export { default as Tab } from './components/Tab/Tab.svelte';
|
|
|
56
56
|
export { default as TabAnchor } from './components/Tab/TabAnchor.svelte';
|
|
57
57
|
export { default as TreeView } from './components/TreeView/TreeView.svelte';
|
|
58
58
|
export { default as TreeViewItem } from './components/TreeView/TreeViewItem.svelte';
|
|
59
|
-
export { default as
|
|
59
|
+
export { default as RecursiveTreeView } from './components/TreeView/RecursiveTreeView.svelte';
|
|
60
|
+
export { default as RecursiveTreeViewItem } from './components/TreeView/RecursiveTreeViewItem.svelte';
|
|
60
61
|
export { default as CodeBlock } from './utilities/CodeBlock/CodeBlock.svelte';
|
|
61
62
|
export { default as Modal } from './utilities/Modal/Modal.svelte';
|
|
62
63
|
export { default as Drawer } from './utilities/Drawer/Drawer.svelte';
|
package/dist/index.js
CHANGED
|
@@ -58,7 +58,8 @@ export { default as Tab } from './components/Tab/Tab.svelte';
|
|
|
58
58
|
export { default as TabAnchor } from './components/Tab/TabAnchor.svelte';
|
|
59
59
|
export { default as TreeView } from './components/TreeView/TreeView.svelte';
|
|
60
60
|
export { default as TreeViewItem } from './components/TreeView/TreeViewItem.svelte';
|
|
61
|
-
export { default as
|
|
61
|
+
export { default as RecursiveTreeView } from './components/TreeView/RecursiveTreeView.svelte';
|
|
62
|
+
export { default as RecursiveTreeViewItem } from './components/TreeView/RecursiveTreeViewItem.svelte';
|
|
62
63
|
// Utility Components
|
|
63
64
|
export { default as CodeBlock } from './utilities/CodeBlock/CodeBlock.svelte';
|
|
64
65
|
export { default as Modal } from './utilities/Modal/Modal.svelte';
|
|
@@ -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. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script>import { onMount } from "svelte";
|
|
2
2
|
import { modeCurrent, setModeUserPrefers, setModeCurrent, setInitialClassState, getModeOsPrefers } from "./lightswitch.js";
|
|
3
|
+
export let title = "Toggle light or dark mode.";
|
|
3
4
|
export let bgLight = "bg-surface-50";
|
|
4
5
|
export let bgDark = "bg-surface-900";
|
|
5
6
|
export let fillLight = "fill-surface-50";
|
|
@@ -64,7 +65,7 @@ $:
|
|
|
64
65
|
role="switch"
|
|
65
66
|
aria-label="Light Switch"
|
|
66
67
|
aria-checked={$modeCurrent}
|
|
67
|
-
title
|
|
68
|
+
{title}
|
|
68
69
|
tabindex="0"
|
|
69
70
|
>
|
|
70
71
|
<!-- Thumb -->
|
|
@@ -2,6 +2,8 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
+
/** Customize the `title` attribute for the component.*/
|
|
6
|
+
title?: string | undefined;
|
|
5
7
|
/** Provide classes to set the light background color.*/
|
|
6
8
|
bgLight?: string | undefined;
|
|
7
9
|
/** Provide classes to set the dark background color.*/
|
package/package.json
CHANGED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
<script>import { getContext, onMount } from "svelte";
|
|
2
|
-
import TreeViewDataDrivenItem from "./TreeViewDataDrivenItem.svelte";
|
|
3
|
-
import TreeViewItem from "./TreeViewItem.svelte";
|
|
4
|
-
export let nodes = [];
|
|
5
|
-
export let selection = getContext("selection");
|
|
6
|
-
export let multiple = getContext("multiple");
|
|
7
|
-
let group;
|
|
8
|
-
let name = "";
|
|
9
|
-
onMount(() => {
|
|
10
|
-
name = String(Math.random());
|
|
11
|
-
if (selection) {
|
|
12
|
-
group = multiple ? [] : "";
|
|
13
|
-
if (multiple) {
|
|
14
|
-
nodes.forEach((node) => {
|
|
15
|
-
if (!Array.isArray(group))
|
|
16
|
-
return;
|
|
17
|
-
if (node.children && node.children.length > 0) {
|
|
18
|
-
if (node.children.some((c) => c.indeterminate)) {
|
|
19
|
-
node.indeterminate = true;
|
|
20
|
-
} else if (node.children.every((c) => c.checked)) {
|
|
21
|
-
node.indeterminate = false;
|
|
22
|
-
group.push(node.value);
|
|
23
|
-
group = group;
|
|
24
|
-
} else if (node.children.some((c) => c.checked)) {
|
|
25
|
-
node.indeterminate = true;
|
|
26
|
-
} else {
|
|
27
|
-
node.indeterminate = false;
|
|
28
|
-
node.checked = false;
|
|
29
|
-
}
|
|
30
|
-
} else if (node.checked) {
|
|
31
|
-
group.push(node.value);
|
|
32
|
-
group = group;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
} else {
|
|
36
|
-
nodes.forEach((node) => {
|
|
37
|
-
if (!node.checked)
|
|
38
|
-
return;
|
|
39
|
-
group = node.value;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
function onGroupChange() {
|
|
45
|
-
if (multiple) {
|
|
46
|
-
nodes.forEach((node) => {
|
|
47
|
-
if (!Array.isArray(group))
|
|
48
|
-
return;
|
|
49
|
-
node.checked = group.includes(node.value);
|
|
50
|
-
});
|
|
51
|
-
} else {
|
|
52
|
-
nodes.forEach((node) => {
|
|
53
|
-
node.checked = node.value === group;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
export let treeItems = [];
|
|
58
|
-
let children = [];
|
|
59
|
-
</script>
|
|
60
|
-
|
|
61
|
-
{#if nodes && nodes.length > 0}
|
|
62
|
-
{#each nodes as node, i}
|
|
63
|
-
<TreeViewItem
|
|
64
|
-
bind:this={treeItems[i]}
|
|
65
|
-
bind:open={node.open}
|
|
66
|
-
hideLead={!node.lead}
|
|
67
|
-
hideChildren={!node.children || node.children.length === 0}
|
|
68
|
-
bind:disabled={node.disabled}
|
|
69
|
-
bind:group
|
|
70
|
-
bind:name
|
|
71
|
-
bind:indeterminate={node.indeterminate}
|
|
72
|
-
bind:value={node.value}
|
|
73
|
-
bind:children={children[i]}
|
|
74
|
-
on:change={onGroupChange}
|
|
75
|
-
on:change
|
|
76
|
-
on:click
|
|
77
|
-
on:toggle
|
|
78
|
-
on:keydown
|
|
79
|
-
on:keyup
|
|
80
|
-
>
|
|
81
|
-
{@html node.content}
|
|
82
|
-
<svelte:fragment slot="lead">
|
|
83
|
-
{@html node.lead}
|
|
84
|
-
</svelte:fragment>
|
|
85
|
-
<svelte:fragment slot="children">
|
|
86
|
-
<TreeViewDataDrivenItem bind:nodes={node.children} bind:treeItems={children[i]} />
|
|
87
|
-
</svelte:fragment>
|
|
88
|
-
</TreeViewItem>
|
|
89
|
-
{/each}
|
|
90
|
-
{/if}
|
|
@@ -1,27 +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
|
-
treeItems?: TreeViewItem[] | undefined;
|
|
10
|
-
};
|
|
11
|
-
events: {
|
|
12
|
-
change: Event;
|
|
13
|
-
click: MouseEvent;
|
|
14
|
-
toggle: CustomEvent<any>;
|
|
15
|
-
keydown: KeyboardEvent;
|
|
16
|
-
keyup: KeyboardEvent;
|
|
17
|
-
} & {
|
|
18
|
-
[evt: string]: CustomEvent<any>;
|
|
19
|
-
};
|
|
20
|
-
slots: {};
|
|
21
|
-
};
|
|
22
|
-
export type TreeViewDataDrivenItemProps = typeof __propDef.props;
|
|
23
|
-
export type TreeViewDataDrivenItemEvents = typeof __propDef.events;
|
|
24
|
-
export type TreeViewDataDrivenItemSlots = typeof __propDef.slots;
|
|
25
|
-
export default class TreeViewDataDrivenItem extends SvelteComponentTyped<TreeViewDataDrivenItemProps, TreeViewDataDrivenItemEvents, TreeViewDataDrivenItemSlots> {
|
|
26
|
-
}
|
|
27
|
-
export {};
|