@geoffcox/sterling-svelte 0.0.26 → 0.0.28
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/Button.svelte +81 -25
- package/Button.svelte.d.ts +3 -0
- package/Checkbox.svelte +56 -26
- package/Checkbox.svelte.d.ts +2 -0
- package/ColorPicker.constants.d.ts +1 -0
- package/ColorPicker.constants.js +1 -0
- package/ColorPicker.svelte +257 -0
- package/ColorPicker.svelte.d.ts +49 -0
- package/ColorPicker.types.d.ts +4 -0
- package/Dialog.svelte +10 -10
- package/Dropdown.svelte +97 -58
- package/Dropdown.svelte.d.ts +4 -0
- package/HexColorSliders.svelte +171 -0
- package/HexColorSliders.svelte.d.ts +22 -0
- package/HslColorSliders.svelte +208 -0
- package/HslColorSliders.svelte.d.ts +22 -0
- package/Input.svelte +59 -25
- package/Input.svelte.d.ts +3 -2
- package/Label.constants.d.ts +1 -0
- package/Label.constants.js +1 -0
- package/Label.svelte +212 -14
- package/Label.svelte.d.ts +24 -4
- package/Label.types.d.ts +4 -0
- package/Label.types.js +1 -0
- package/Link.svelte +62 -16
- package/Link.svelte.d.ts +1 -0
- package/List.svelte +29 -16
- package/List.svelte.d.ts +1 -0
- package/List.types.d.ts +4 -3
- package/ListItem.svelte +30 -10
- package/ListItem.svelte.d.ts +1 -1
- package/Menu.svelte +7 -7
- package/MenuBar.svelte +1 -1
- package/MenuButton.svelte +3 -9
- package/MenuButton.svelte.d.ts +2 -4
- package/MenuItem.svelte +34 -12
- package/MenuItem.svelte.d.ts +2 -1
- package/MenuItemDisplay.svelte +8 -1
- package/MenuSeparator.svelte +3 -3
- package/Popover.svelte +66 -51
- package/Popover.svelte.d.ts +4 -2
- package/Progress.constants.d.ts +1 -1
- package/Progress.constants.js +1 -1
- package/Progress.svelte +34 -28
- package/Progress.svelte.d.ts +1 -1
- package/Progress.types.d.ts +3 -3
- package/Radio.svelte +54 -23
- package/Radio.svelte.d.ts +2 -0
- package/RgbColorSliders.svelte +182 -0
- package/RgbColorSliders.svelte.d.ts +22 -0
- package/Select.svelte +32 -25
- package/Select.svelte.d.ts +1 -1
- package/Slider.svelte +111 -123
- package/Slider.svelte.d.ts +1 -0
- package/Switch.svelte +112 -41
- package/Switch.svelte.d.ts +3 -2
- package/Tab.svelte +53 -29
- package/Tab.svelte.d.ts +7 -4
- package/TabList.svelte +21 -11
- package/TabList.svelte.d.ts +1 -0
- package/TabList.types.d.ts +1 -0
- package/TextArea.svelte +48 -22
- package/TextArea.svelte.d.ts +4 -3
- package/Tooltip.svelte +59 -16
- package/Tooltip.svelte.d.ts +34 -2
- package/Tree.svelte +35 -21
- package/Tree.svelte.d.ts +2 -0
- package/Tree.types.d.ts +6 -8
- package/TreeChevron.svelte +1 -1
- package/TreeItem.svelte +40 -9
- package/TreeItem.svelte.d.ts +2 -0
- package/TreeItem.types.d.ts +4 -4
- package/TreeItemDisplay.svelte +28 -9
- package/TreeItemDisplay.svelte.d.ts +3 -1
- package/actions/clickOutside.js +1 -1
- package/actions/trapKeyboardFocus.d.ts +3 -0
- package/actions/trapKeyboardFocus.js +52 -0
- package/floating-ui.types.d.ts +2 -0
- package/index.d.ts +14 -10
- package/index.js +11 -7
- package/package.json +12 -4
- package/theme/applyTheme.js +3 -2
- package/theme/colors.d.ts +1 -0
- package/theme/colors.js +28 -13
- package/theme/darkTheme.js +129 -87
- package/theme/lightTheme.js +109 -90
- package/Field.constants.d.ts +0 -1
- package/Field.constants.js +0 -1
- package/Field.svelte +0 -265
- package/Field.svelte.d.ts +0 -75
- package/Field.types.d.ts +0 -4
- /package/{Field.types.js → ColorPicker.types.js} +0 -0
package/TextArea.svelte.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
-
autoHeight?: boolean | undefined;
|
|
6
5
|
disabled?: boolean | undefined;
|
|
7
|
-
resize?: "none" | "horizontal" | "vertical" | "both" | undefined;
|
|
8
6
|
value?: string | undefined;
|
|
7
|
+
autoHeight?: boolean | undefined;
|
|
8
|
+
colorful?: boolean | undefined;
|
|
9
|
+
resize?: "none" | "vertical" | "horizontal" | "both" | undefined;
|
|
9
10
|
blur?: (() => void) | undefined;
|
|
10
11
|
click?: (() => void) | undefined;
|
|
11
12
|
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
@@ -60,7 +61,7 @@ export default class TextArea extends SvelteComponentTyped<TextAreaProps, TextAr
|
|
|
60
61
|
get click(): () => void;
|
|
61
62
|
get focus(): (options?: FocusOptions | undefined) => void;
|
|
62
63
|
get select(): () => void;
|
|
63
|
-
get setSelectionRange(): (start: number | null, end: number | null, direction?: "
|
|
64
|
+
get setSelectionRange(): (start: number | null, end: number | null, direction?: "forward" | "backward" | "none" | undefined) => void;
|
|
64
65
|
get setRangeText(): (replacement: string, start?: number | undefined, end?: number | undefined, selectionMode?: SelectionMode | undefined) => void;
|
|
65
66
|
}
|
|
66
67
|
export {};
|
package/Tooltip.svelte
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { arrow, autoUpdate, computePosition, flip, offset } from "@floating-ui/dom";
|
|
1
|
+
<script>import { arrow, autoUpdate, computePosition, flip, offset } from "@floating-ui/dom";
|
|
3
2
|
import { onMount } from "svelte";
|
|
4
3
|
import { fade } from "svelte/transition";
|
|
4
|
+
import { portal } from "./actions/portal";
|
|
5
|
+
import { prefersReducedMotion } from "./stores/prefersReducedMotion";
|
|
5
6
|
export let disabled = false;
|
|
6
|
-
export let showOn =
|
|
7
|
+
export let showOn = "hover";
|
|
7
8
|
export let hoverDelayMilliseconds = 1e3;
|
|
8
9
|
export let open = false;
|
|
9
10
|
export let placement = "top";
|
|
@@ -114,6 +115,7 @@ const autoShowUpdate = () => {
|
|
|
114
115
|
cleanupAutoShowUpdate = () => {
|
|
115
116
|
};
|
|
116
117
|
const element = reference;
|
|
118
|
+
open = false;
|
|
117
119
|
if (element) {
|
|
118
120
|
switch (showOn) {
|
|
119
121
|
case "click":
|
|
@@ -132,6 +134,11 @@ const autoShowUpdate = () => {
|
|
|
132
134
|
};
|
|
133
135
|
$:
|
|
134
136
|
reference, showOn, autoShowUpdate();
|
|
137
|
+
const fadeNoOp = (node, params) => {
|
|
138
|
+
return { delay: 0, duration: 0 };
|
|
139
|
+
};
|
|
140
|
+
$:
|
|
141
|
+
fadeMotion = !$prefersReducedMotion ? fade : fadeNoOp;
|
|
135
142
|
let mounted = false;
|
|
136
143
|
onMount(() => {
|
|
137
144
|
mounted = true;
|
|
@@ -149,9 +156,45 @@ onMount(() => {
|
|
|
149
156
|
<div
|
|
150
157
|
class="sterling-tooltip-portal"
|
|
151
158
|
use:portal={{ target: document.body }}
|
|
152
|
-
transition:
|
|
159
|
+
transition:fadeMotion={{ duration: 250 }}
|
|
153
160
|
>
|
|
154
|
-
<div
|
|
161
|
+
<div
|
|
162
|
+
bind:this={tooltipRef}
|
|
163
|
+
class="sterling-tooltip"
|
|
164
|
+
style={tipStyle}
|
|
165
|
+
on:blur
|
|
166
|
+
on:click
|
|
167
|
+
on:dblclick
|
|
168
|
+
on:dragend
|
|
169
|
+
on:dragenter
|
|
170
|
+
on:dragleave
|
|
171
|
+
on:dragover
|
|
172
|
+
on:dragstart
|
|
173
|
+
on:drop
|
|
174
|
+
on:focus
|
|
175
|
+
on:focusin
|
|
176
|
+
on:focusout
|
|
177
|
+
on:keydown
|
|
178
|
+
on:keypress
|
|
179
|
+
on:keyup
|
|
180
|
+
on:mousedown
|
|
181
|
+
on:mouseenter
|
|
182
|
+
on:mouseleave
|
|
183
|
+
on:mousemove
|
|
184
|
+
on:mouseover
|
|
185
|
+
on:mouseout
|
|
186
|
+
on:mouseup
|
|
187
|
+
on:pointercancel
|
|
188
|
+
on:pointerdown
|
|
189
|
+
on:pointerenter
|
|
190
|
+
on:pointerleave
|
|
191
|
+
on:pointermove
|
|
192
|
+
on:pointerover
|
|
193
|
+
on:pointerout
|
|
194
|
+
on:pointerup
|
|
195
|
+
on:wheel|passive
|
|
196
|
+
{...$$restProps}
|
|
197
|
+
>
|
|
155
198
|
<div class="arrow" bind:this={arrowRef} style={arrowStyle} />
|
|
156
199
|
<slot name="tip" />
|
|
157
200
|
</div>
|
|
@@ -171,12 +214,12 @@ onMount(() => {
|
|
|
171
214
|
}
|
|
172
215
|
|
|
173
216
|
.sterling-tooltip {
|
|
174
|
-
background-color: var(--stsv-
|
|
175
|
-
border-color: var(--stsv-
|
|
176
|
-
border-radius: var(--stsv-
|
|
177
|
-
border-style: var(--stsv-
|
|
178
|
-
border-width: var(--stsv-
|
|
179
|
-
color: var(--stsv-
|
|
217
|
+
background-color: var(--stsv-common__background-color);
|
|
218
|
+
border-color: var(--stsv-common__border-color);
|
|
219
|
+
border-radius: var(--stsv-common__border-radius);
|
|
220
|
+
border-style: var(--stsv-common__border-style);
|
|
221
|
+
border-width: var(--stsv-common__border-width);
|
|
222
|
+
color: var(--stsv-common__color);
|
|
180
223
|
position: absolute;
|
|
181
224
|
overflow: visible;
|
|
182
225
|
box-shadow: rgba(0, 0, 0, 0.4) 2px 2px 4px -1px;
|
|
@@ -187,11 +230,11 @@ onMount(() => {
|
|
|
187
230
|
position: absolute;
|
|
188
231
|
width: 10px;
|
|
189
232
|
height: 10px;
|
|
190
|
-
background-color: var(--stsv-
|
|
191
|
-
border-color: var(--stsv-
|
|
192
|
-
border-radius: var(--stsv-
|
|
193
|
-
border-style: var(--stsv-
|
|
194
|
-
border-width: var(--stsv-
|
|
233
|
+
background-color: var(--stsv-common__background-color);
|
|
234
|
+
border-color: var(--stsv-common__border-color);
|
|
235
|
+
border-radius: var(--stsv-common__border-radius);
|
|
236
|
+
border-style: var(--stsv-common__border-style);
|
|
237
|
+
border-width: var(--stsv-common__border-width);
|
|
195
238
|
clip-path: polygon(0% 1%, 100% 1%, 100% 100%, 0% 1%);
|
|
196
239
|
}
|
|
197
240
|
</style>
|
package/Tooltip.svelte.d.ts
CHANGED
|
@@ -1,15 +1,47 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { TooltipShowOn } from './Tooltip.types';
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
5
|
disabled?: boolean | undefined;
|
|
6
|
-
showOn?:
|
|
6
|
+
showOn?: string | undefined;
|
|
7
7
|
hoverDelayMilliseconds?: number | undefined;
|
|
8
8
|
open?: boolean | undefined;
|
|
9
9
|
placement?: import("@floating-ui/core").Placement | undefined;
|
|
10
10
|
portalTarget?: HTMLElement | undefined;
|
|
11
11
|
};
|
|
12
12
|
events: {
|
|
13
|
+
blur: FocusEvent;
|
|
14
|
+
click: MouseEvent;
|
|
15
|
+
dblclick: MouseEvent;
|
|
16
|
+
dragend: DragEvent;
|
|
17
|
+
dragenter: DragEvent;
|
|
18
|
+
dragleave: DragEvent;
|
|
19
|
+
dragover: DragEvent;
|
|
20
|
+
dragstart: DragEvent;
|
|
21
|
+
drop: DragEvent;
|
|
22
|
+
focus: FocusEvent;
|
|
23
|
+
focusin: FocusEvent;
|
|
24
|
+
focusout: FocusEvent;
|
|
25
|
+
keydown: KeyboardEvent;
|
|
26
|
+
keypress: KeyboardEvent;
|
|
27
|
+
keyup: KeyboardEvent;
|
|
28
|
+
mousedown: MouseEvent;
|
|
29
|
+
mouseenter: MouseEvent;
|
|
30
|
+
mouseleave: MouseEvent;
|
|
31
|
+
mousemove: MouseEvent;
|
|
32
|
+
mouseover: MouseEvent;
|
|
33
|
+
mouseout: MouseEvent;
|
|
34
|
+
mouseup: MouseEvent;
|
|
35
|
+
pointercancel: PointerEvent;
|
|
36
|
+
pointerdown: PointerEvent;
|
|
37
|
+
pointerenter: PointerEvent;
|
|
38
|
+
pointerleave: PointerEvent;
|
|
39
|
+
pointermove: PointerEvent;
|
|
40
|
+
pointerover: PointerEvent;
|
|
41
|
+
pointerout: PointerEvent;
|
|
42
|
+
pointerup: PointerEvent;
|
|
43
|
+
wheel: WheelEvent;
|
|
44
|
+
} & {
|
|
13
45
|
[evt: string]: CustomEvent<any>;
|
|
14
46
|
};
|
|
15
47
|
slots: {
|
package/Tree.svelte
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
import { writable } from "svelte/store";
|
|
3
3
|
import { TREE_CONTEXT_KEY } from "./Tree.constants";
|
|
4
4
|
import { usingKeyboard } from "./stores/usingKeyboard";
|
|
5
|
+
export let colorful = false;
|
|
5
6
|
export let composed = false;
|
|
6
7
|
export let disabled = false;
|
|
7
8
|
export let selectedValue = void 0;
|
|
8
9
|
export let expandedValues = [];
|
|
9
10
|
let treeRef;
|
|
10
|
-
const
|
|
11
|
-
const expandedValuesStore = writable(expandedValues);
|
|
11
|
+
const colorfulStore = writable(colorful);
|
|
12
12
|
const disabledStore = writable(disabled);
|
|
13
|
+
const expandedValuesStore = writable(expandedValues);
|
|
14
|
+
const selectedValueStore = writable(selectedValue);
|
|
13
15
|
export const blur = () => {
|
|
14
16
|
treeRef?.blur();
|
|
15
17
|
};
|
|
@@ -37,13 +39,17 @@ $: {
|
|
|
37
39
|
expandedValues = $expandedValuesStore;
|
|
38
40
|
raiseExpandCollapse($expandedValuesStore);
|
|
39
41
|
}
|
|
42
|
+
$: {
|
|
43
|
+
colorfulStore.set(colorful);
|
|
44
|
+
}
|
|
40
45
|
$: {
|
|
41
46
|
disabledStore.set(disabled);
|
|
42
47
|
}
|
|
43
48
|
setContext(TREE_CONTEXT_KEY, {
|
|
49
|
+
colorful: colorfulStore,
|
|
50
|
+
disabled: disabledStore,
|
|
44
51
|
expandedValues: expandedValuesStore,
|
|
45
|
-
selectedValue: selectedValueStore
|
|
46
|
-
disabled: disabledStore
|
|
52
|
+
selectedValue: selectedValueStore
|
|
47
53
|
});
|
|
48
54
|
</script>
|
|
49
55
|
|
|
@@ -52,6 +58,7 @@ setContext(TREE_CONTEXT_KEY, {
|
|
|
52
58
|
bind:this={treeRef}
|
|
53
59
|
aria-disabled={disabled}
|
|
54
60
|
class="sterling-tree"
|
|
61
|
+
class:colorful
|
|
55
62
|
class:composed
|
|
56
63
|
class:disabled
|
|
57
64
|
class:using-keyboard={$usingKeyboard}
|
|
@@ -86,23 +93,23 @@ setContext(TREE_CONTEXT_KEY, {
|
|
|
86
93
|
on:pointerover
|
|
87
94
|
on:pointerout
|
|
88
95
|
on:pointerup
|
|
89
|
-
on:wheel
|
|
96
|
+
on:wheel|passive
|
|
90
97
|
{...$$restProps}
|
|
91
98
|
>
|
|
92
99
|
<div class="container">
|
|
93
|
-
<slot {composed} {disabled} />
|
|
100
|
+
<slot {colorful} {composed} {disabled} />
|
|
94
101
|
</div>
|
|
95
102
|
</div>
|
|
96
103
|
|
|
97
104
|
<style>
|
|
98
105
|
.sterling-tree {
|
|
99
|
-
background-color: var(--stsv-
|
|
100
|
-
border-color: var(--stsv-
|
|
101
|
-
border-radius: var(--stsv-
|
|
102
|
-
border-style: var(--stsv-
|
|
103
|
-
border-width: var(--stsv-
|
|
106
|
+
background-color: var(--stsv-common__background-color);
|
|
107
|
+
border-color: var(--stsv-common__border-color);
|
|
108
|
+
border-radius: var(--stsv-common__border-radius);
|
|
109
|
+
border-style: var(--stsv-common__border-style);
|
|
110
|
+
border-width: var(--stsv-common__border-width);
|
|
104
111
|
box-sizing: border-box;
|
|
105
|
-
color: var(--stsv-
|
|
112
|
+
color: var(--stsv-common__color);
|
|
106
113
|
height: 100%;
|
|
107
114
|
overflow-x: hidden;
|
|
108
115
|
overflow-y: auto;
|
|
@@ -111,17 +118,17 @@ setContext(TREE_CONTEXT_KEY, {
|
|
|
111
118
|
}
|
|
112
119
|
|
|
113
120
|
.sterling-tree:hover {
|
|
114
|
-
border-color: var(--stsv-
|
|
115
|
-
color: var(--stsv-
|
|
121
|
+
border-color: var(--stsv-input__border-color--hover);
|
|
122
|
+
color: var(--stsv-input__color--hover);
|
|
116
123
|
}
|
|
117
124
|
|
|
118
125
|
.sterling-tree.using-keyboard:focus-within {
|
|
119
|
-
border-color: var(--stsv-
|
|
120
|
-
color: var(--stsv-
|
|
121
|
-
outline-color: var(--stsv-
|
|
122
|
-
outline-offset: var(--stsv-
|
|
123
|
-
outline-style: var(--stsv-
|
|
124
|
-
outline-width: var(--stsv-
|
|
126
|
+
border-color: var(--stsv-button__border-color--focus);
|
|
127
|
+
color: var(--stsv-input__color--focus);
|
|
128
|
+
outline-color: var(--stsv-common__outline-color);
|
|
129
|
+
outline-offset: var(--stsv-common__outline-offset);
|
|
130
|
+
outline-style: var(--stsv-common__outline-style);
|
|
131
|
+
outline-width: var(--stsv-common__outline-width);
|
|
125
132
|
}
|
|
126
133
|
|
|
127
134
|
.sterling-tree.composed,
|
|
@@ -147,7 +154,14 @@ setContext(TREE_CONTEXT_KEY, {
|
|
|
147
154
|
}
|
|
148
155
|
|
|
149
156
|
.container::after {
|
|
150
|
-
background:
|
|
157
|
+
background: repeating-linear-gradient(
|
|
158
|
+
var(--stsv-common--disabled__stripe-angle),
|
|
159
|
+
var(--stsv-common--disabled__stripe-color),
|
|
160
|
+
var(--stsv-common--disabled__stripe-color) var(--stsv-common--disabled__stripe-width),
|
|
161
|
+
var(--stsv-common--disabled__stripe-color--alt) var(--stsv-common--disabled__stripe-width),
|
|
162
|
+
var(--stsv-common--disabled__stripe-color--alt)
|
|
163
|
+
calc(2 * var(--stsv-common--disabled__stripe-width))
|
|
164
|
+
);
|
|
151
165
|
bottom: 0;
|
|
152
166
|
content: '';
|
|
153
167
|
left: 0;
|
package/Tree.svelte.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
+
colorful?: boolean | undefined;
|
|
5
6
|
composed?: boolean | undefined;
|
|
6
7
|
disabled?: boolean | undefined;
|
|
7
8
|
selectedValue?: string | undefined;
|
|
@@ -48,6 +49,7 @@ declare const __propDef: {
|
|
|
48
49
|
};
|
|
49
50
|
slots: {
|
|
50
51
|
default: {
|
|
52
|
+
colorful: boolean;
|
|
51
53
|
composed: boolean;
|
|
52
54
|
disabled: boolean;
|
|
53
55
|
};
|
package/Tree.types.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import type { Readable, Writable } from 'svelte/store';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The context for a Tree and its descendants.
|
|
4
4
|
*/
|
|
5
5
|
export type TreeContext = {
|
|
6
|
-
/**
|
|
6
|
+
/** When true, applies colorful theme styles. */
|
|
7
|
+
colorful: Readable<boolean>;
|
|
8
|
+
/** When true, the tree and its descendants are disabled */
|
|
7
9
|
disabled: Readable<boolean>;
|
|
8
|
-
/**
|
|
9
|
-
* The values of the expanded tree tree items.
|
|
10
|
-
*/
|
|
10
|
+
/** The values of items that are expanded. */
|
|
11
11
|
expandedValues: Writable<string[]>;
|
|
12
|
-
/**
|
|
13
|
-
* The value of the selected tree item.
|
|
14
|
-
*/
|
|
12
|
+
/** The value of the currently selected item. */
|
|
15
13
|
selectedValue: Writable<string | undefined>;
|
|
16
14
|
};
|
package/TreeChevron.svelte
CHANGED
package/TreeItem.svelte
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { slide } from "svelte/transition";
|
|
3
3
|
import { TREE_CONTEXT_KEY, TREE_ITEM_CONTEXT_KEY } from "./Tree.constants";
|
|
4
4
|
import TreeItemDisplay from "./TreeItemDisplay.svelte";
|
|
5
|
-
import { writable } from "svelte/store";
|
|
5
|
+
import { readable, writable } from "svelte/store";
|
|
6
6
|
import { prefersReducedMotion } from "./stores/prefersReducedMotion";
|
|
7
7
|
export let disabled = false;
|
|
8
|
+
export let text = void 0;
|
|
8
9
|
export let value;
|
|
9
10
|
const slidNoOp = (node, params) => {
|
|
10
11
|
return { delay: 0, duration: 0 };
|
|
@@ -12,11 +13,17 @@ const slidNoOp = (node, params) => {
|
|
|
12
13
|
$:
|
|
13
14
|
slideMotion = !$prefersReducedMotion ? slide : slidNoOp;
|
|
14
15
|
const {
|
|
16
|
+
colorful,
|
|
17
|
+
disabled: treeDisabled,
|
|
15
18
|
expandedValues,
|
|
16
|
-
selectedValue
|
|
17
|
-
disabled: treeDisabled
|
|
19
|
+
selectedValue
|
|
18
20
|
} = getContext(TREE_CONTEXT_KEY);
|
|
19
|
-
const { depth = 0 } = getContext(TREE_ITEM_CONTEXT_KEY) || {
|
|
21
|
+
const { depth = 0 } = getContext(TREE_ITEM_CONTEXT_KEY) || {
|
|
22
|
+
colorful: readable(false),
|
|
23
|
+
disabled: readable(false),
|
|
24
|
+
expandedValues: readable([]),
|
|
25
|
+
selectedValue: readable(void 0)
|
|
26
|
+
};
|
|
20
27
|
let treeItemRef;
|
|
21
28
|
$:
|
|
22
29
|
hasChildren = $$slots.default;
|
|
@@ -244,6 +251,7 @@ A item in a Tree displaying the item and children.
|
|
|
244
251
|
aria-expanded={expanded}
|
|
245
252
|
bind:this={treeItemRef}
|
|
246
253
|
class="sterling-tree-item"
|
|
254
|
+
class:colorful={$colorful}
|
|
247
255
|
class:disabled={_disabled}
|
|
248
256
|
data-value={value}
|
|
249
257
|
role="treeitem"
|
|
@@ -277,7 +285,7 @@ A item in a Tree displaying the item and children.
|
|
|
277
285
|
on:pointerover
|
|
278
286
|
on:pointerout
|
|
279
287
|
on:pointerup
|
|
280
|
-
on:wheel
|
|
288
|
+
on:wheel|passive
|
|
281
289
|
{...$$restProps}
|
|
282
290
|
>
|
|
283
291
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
@@ -289,10 +297,33 @@ A item in a Tree displaying the item and children.
|
|
|
289
297
|
on:keydown={onKeydown}
|
|
290
298
|
>
|
|
291
299
|
<slot name="item" {depth} disabled={_disabled} {expanded} {hasChildren} {selected} {value}>
|
|
292
|
-
<TreeItemDisplay
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
300
|
+
<TreeItemDisplay
|
|
301
|
+
colorful={$colorful}
|
|
302
|
+
{depth}
|
|
303
|
+
disabled={_disabled}
|
|
304
|
+
{expanded}
|
|
305
|
+
{hasChildren}
|
|
306
|
+
{selected}
|
|
307
|
+
{value}
|
|
308
|
+
>
|
|
309
|
+
<svelte:fragment
|
|
310
|
+
let:colorful
|
|
311
|
+
let:depth
|
|
312
|
+
let:disabled
|
|
313
|
+
let:expanded
|
|
314
|
+
let:hasChildren
|
|
315
|
+
let:selected
|
|
316
|
+
let:value
|
|
317
|
+
>
|
|
318
|
+
<slot
|
|
319
|
+
name="label"
|
|
320
|
+
{colorful}
|
|
321
|
+
{depth}
|
|
322
|
+
{disabled}
|
|
323
|
+
{expanded}
|
|
324
|
+
{hasChildren}
|
|
325
|
+
{selected}
|
|
326
|
+
{value}>{text || value}</slot
|
|
296
327
|
>
|
|
297
328
|
</svelte:fragment>
|
|
298
329
|
</TreeItemDisplay>
|
package/TreeItem.svelte.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ declare const __propDef: {
|
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
disabled?: boolean | undefined;
|
|
6
|
+
text?: string | undefined;
|
|
6
7
|
value: string;
|
|
7
8
|
collapse?: (() => boolean) | undefined;
|
|
8
9
|
expand?: (() => boolean) | undefined;
|
|
@@ -60,6 +61,7 @@ declare const __propDef: {
|
|
|
60
61
|
value: string;
|
|
61
62
|
};
|
|
62
63
|
label: {
|
|
64
|
+
colorful: import("svelte/store").Readable<boolean>;
|
|
63
65
|
depth: number;
|
|
64
66
|
disabled: boolean;
|
|
65
67
|
expanded: boolean;
|
package/TreeItem.types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Readable } from 'svelte/store';
|
|
2
2
|
/**
|
|
3
|
-
* The context for a tree item.
|
|
3
|
+
* The context for a tree item and its descendants.
|
|
4
4
|
*/
|
|
5
5
|
export type TreeItemContext = {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* The depth of this tree item within the tree hierarchy.
|
|
8
|
+
* Starts at zero.
|
|
9
9
|
*/
|
|
10
10
|
depth: number;
|
|
11
|
-
/**
|
|
11
|
+
/** When true, the three item is disabled. */
|
|
12
12
|
disabled: Readable<boolean>;
|
|
13
13
|
};
|
package/TreeItemDisplay.svelte
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
import { TREE_CONTEXT_KEY } from "./Tree.constants";
|
|
3
3
|
import TreeChevron from "./TreeChevron.svelte";
|
|
4
4
|
import { readable } from "svelte/store";
|
|
5
|
+
export let colorful = false;
|
|
5
6
|
export let depth = 0;
|
|
6
7
|
export let disabled = false;
|
|
7
8
|
export let expanded = false;
|
|
8
9
|
export let hasChildren = false;
|
|
9
|
-
export let value;
|
|
10
10
|
export let selected = false;
|
|
11
|
+
export let value;
|
|
11
12
|
const { disabled: treeDisabled } = getContext(TREE_CONTEXT_KEY) || {
|
|
12
13
|
disabled: readable(false)
|
|
13
14
|
};
|
|
@@ -26,6 +27,7 @@ export const focus = (options) => {
|
|
|
26
27
|
<div
|
|
27
28
|
bind:this={divRef}
|
|
28
29
|
class="sterling-tree-item-display"
|
|
30
|
+
class:colorful
|
|
29
31
|
class:disabled={disabled && !$treeDisabled}
|
|
30
32
|
class:item-disabled={disabled}
|
|
31
33
|
class:expanded
|
|
@@ -61,11 +63,11 @@ export const focus = (options) => {
|
|
|
61
63
|
on:pointerover
|
|
62
64
|
on:pointerout
|
|
63
65
|
on:pointerup
|
|
64
|
-
on:wheel
|
|
66
|
+
on:wheel|passive
|
|
65
67
|
{...$$restProps}
|
|
66
68
|
>
|
|
67
69
|
<TreeChevron {expanded} {hasChildren} />
|
|
68
|
-
<slot {depth} {disabled} {expanded} {hasChildren} {selected} {value} />
|
|
70
|
+
<slot {colorful} {depth} {disabled} {expanded} {hasChildren} {selected} {value} />
|
|
69
71
|
</div>
|
|
70
72
|
|
|
71
73
|
<style>
|
|
@@ -74,7 +76,7 @@ export const focus = (options) => {
|
|
|
74
76
|
align-items: center;
|
|
75
77
|
background-color: transparent;
|
|
76
78
|
box-sizing: border-box;
|
|
77
|
-
color: var(--stsv-
|
|
79
|
+
color: var(--stsv-input__color);
|
|
78
80
|
display: grid;
|
|
79
81
|
grid-template-columns: auto 1fr;
|
|
80
82
|
column-gap: 0.25em;
|
|
@@ -89,13 +91,23 @@ export const focus = (options) => {
|
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
.sterling-tree-item-display:not(.item-disabled):not(.selected):hover {
|
|
92
|
-
background-color: var(--stsv-
|
|
93
|
-
color: var(--stsv-
|
|
94
|
+
background-color: var(--stsv-button__background-color--hover);
|
|
95
|
+
color: var(--stsv-button__color--hover);
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
.sterling-tree-item-display.selected {
|
|
97
|
-
background-color: var(--stsv-
|
|
98
|
-
color: var(--stsv-
|
|
99
|
+
background-color: var(--stsv-button__background-color--active);
|
|
100
|
+
color: var(--stsv-button__color--active);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.sterling-tree-item-display.colorful:not(.item-disabled):not(.selected):hover {
|
|
104
|
+
background-color: var(--stsv-button--colorful__background-color--hover);
|
|
105
|
+
color: var(--stsv-button--colorful__color--hover);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.sterling-tree-item-display.colorful.selected {
|
|
109
|
+
background-color: var(--stsv-button--colorful__background-color--active);
|
|
110
|
+
color: var(--stsv-button--colorful__color--active);
|
|
99
111
|
}
|
|
100
112
|
|
|
101
113
|
.sterling-tree-item-display.disabled {
|
|
@@ -104,7 +116,14 @@ export const focus = (options) => {
|
|
|
104
116
|
}
|
|
105
117
|
|
|
106
118
|
.sterling-tree-item-display::after {
|
|
107
|
-
background:
|
|
119
|
+
background: repeating-linear-gradient(
|
|
120
|
+
var(--stsv-common--disabled__stripe-angle),
|
|
121
|
+
var(--stsv-common--disabled__stripe-color),
|
|
122
|
+
var(--stsv-common--disabled__stripe-color) var(--stsv-common--disabled__stripe-width),
|
|
123
|
+
var(--stsv-common--disabled__stripe-color--alt) var(--stsv-common--disabled__stripe-width),
|
|
124
|
+
var(--stsv-common--disabled__stripe-color--alt)
|
|
125
|
+
calc(2 * var(--stsv-common--disabled__stripe-width))
|
|
126
|
+
);
|
|
108
127
|
bottom: 0;
|
|
109
128
|
content: '';
|
|
110
129
|
left: 0;
|
|
@@ -2,12 +2,13 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
+
colorful?: boolean | undefined;
|
|
5
6
|
depth?: number | undefined;
|
|
6
7
|
disabled?: boolean | undefined;
|
|
7
8
|
expanded?: boolean | undefined;
|
|
8
9
|
hasChildren?: boolean | undefined;
|
|
9
|
-
value: string;
|
|
10
10
|
selected?: boolean | undefined;
|
|
11
|
+
value: string;
|
|
11
12
|
click?: (() => void) | undefined;
|
|
12
13
|
blur?: (() => void) | undefined;
|
|
13
14
|
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
@@ -49,6 +50,7 @@ declare const __propDef: {
|
|
|
49
50
|
};
|
|
50
51
|
slots: {
|
|
51
52
|
default: {
|
|
53
|
+
colorful: boolean;
|
|
52
54
|
depth: number;
|
|
53
55
|
disabled: boolean;
|
|
54
56
|
expanded: boolean;
|
package/actions/clickOutside.js
CHANGED
|
@@ -9,7 +9,7 @@ export const clickOutside = (node, params) => {
|
|
|
9
9
|
const targetNode = event?.target;
|
|
10
10
|
if (targetNode &&
|
|
11
11
|
!node.contains(targetNode) &&
|
|
12
|
-
(!ignoreOthers || ignoreOthers.every((x) => !x.contains(targetNode)))) {
|
|
12
|
+
(!ignoreOthers || ignoreOthers.filter(Boolean).every((x) => !x.contains(targetNode)))) {
|
|
13
13
|
node.dispatchEvent(new CustomEvent('click_outside', {
|
|
14
14
|
detail: { mouseEvent: event }
|
|
15
15
|
}));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const getFirstFocusable = (node) => {
|
|
2
|
+
// we can't select [tabIndex] as many elements don't have tabIndex as a declared property
|
|
3
|
+
// but do default to tabIndex >= 0.
|
|
4
|
+
const nodes = node.querySelectorAll('*');
|
|
5
|
+
const elements = Array.from(nodes)
|
|
6
|
+
.map((n) => n)
|
|
7
|
+
.filter((n) => n.tabIndex !== undefined && n.tabIndex >= 0);
|
|
8
|
+
return elements.length > 0 ? elements[0] : null;
|
|
9
|
+
};
|
|
10
|
+
const getLastFocusable = (node) => {
|
|
11
|
+
// we can't select [tabIndex] as many elements don't have tabIndex as a declared property
|
|
12
|
+
// but do default to tabIndex >= 0.
|
|
13
|
+
const nodes = node.querySelectorAll('*');
|
|
14
|
+
const elements = Array.from(nodes)
|
|
15
|
+
.map((n) => n)
|
|
16
|
+
.filter((n) => n.tabIndex !== undefined && n.tabIndex >= 0);
|
|
17
|
+
return elements.length > 0 ? elements[elements.length - 1] : null;
|
|
18
|
+
};
|
|
19
|
+
export const trapKeyboardFocus = (node) => {
|
|
20
|
+
const onKeydown = (e) => {
|
|
21
|
+
let handledFocus = false;
|
|
22
|
+
if (e.key === 'Tab') {
|
|
23
|
+
if (e.shiftKey) {
|
|
24
|
+
const firstFocusable = getFirstFocusable(node);
|
|
25
|
+
if (document.activeElement === firstFocusable) {
|
|
26
|
+
const lastFocusable = getLastFocusable(node);
|
|
27
|
+
lastFocusable?.focus();
|
|
28
|
+
handledFocus = true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const lastFocusable = getLastFocusable(node);
|
|
33
|
+
if (document.activeElement === lastFocusable) {
|
|
34
|
+
const firstFocusable = getFirstFocusable(node);
|
|
35
|
+
firstFocusable?.focus();
|
|
36
|
+
handledFocus = true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (handledFocus) {
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
node.addEventListener('keydown', onKeydown);
|
|
47
|
+
return {
|
|
48
|
+
destroy: () => {
|
|
49
|
+
node.removeEventListener('keydown', onKeydown);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
package/floating-ui.types.d.ts
CHANGED