@geoffcox/sterling-svelte 0.0.30 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/clickOutside.d.ts +11 -7
- package/Button.svelte +11 -183
- package/Button.svelte.d.ts +2 -6
- package/Callout.svelte +188 -0
- package/Callout.svelte.d.ts +54 -0
- package/Checkbox.svelte +15 -177
- package/Checkbox.svelte.d.ts +2 -2
- package/ColorPicker.svelte +204 -223
- package/ColorPicker.svelte.d.ts +1 -2
- package/Dialog.svelte +91 -187
- package/Dialog.svelte.d.ts +3 -1
- package/Dropdown.svelte +52 -219
- package/Dropdown.svelte.d.ts +4 -8
- package/HexColorSliders.svelte +77 -145
- package/HexColorSliders.svelte.d.ts +28 -1
- package/HslColorSliders.svelte +99 -179
- package/HslColorSliders.svelte.d.ts +28 -1
- package/Input.svelte +27 -136
- package/Input.svelte.d.ts +2 -3
- package/Label.constants.d.ts +1 -0
- package/Label.constants.js +1 -0
- package/Label.svelte +96 -169
- package/Label.svelte.d.ts +6 -1
- package/Label.types.d.ts +3 -1
- package/Link.svelte +9 -106
- package/Link.svelte.d.ts +0 -1
- package/List.svelte +142 -230
- package/List.svelte.d.ts +2 -3
- package/List.types.d.ts +6 -1
- package/ListItem.svelte +25 -94
- package/ListItem.svelte.d.ts +2 -0
- package/Menu.svelte +48 -64
- package/Menu.svelte.d.ts +4 -1
- package/MenuBar.svelte +84 -86
- package/MenuBar.svelte.d.ts +4 -1
- package/MenuButton.svelte +67 -74
- package/MenuButton.svelte.d.ts +7 -3
- package/MenuItem.svelte +256 -288
- package/MenuItem.svelte.d.ts +2 -2
- package/MenuItemDisplay.svelte +12 -116
- package/MenuItemDisplay.svelte.d.ts +21 -7
- package/MenuSeparator.svelte +6 -45
- package/MenuSeparator.svelte.d.ts +8 -78
- package/Popover.constants.d.ts +2 -0
- package/{floating-ui.constants.js → Popover.constants.js} +10 -9
- package/Popover.svelte +72 -82
- package/Popover.svelte.d.ts +10 -5
- package/Popover.types.d.ts +4 -0
- package/Progress.svelte +28 -126
- package/Progress.svelte.d.ts +4 -3
- package/Radio.svelte +49 -192
- package/Radio.svelte.d.ts +2 -2
- package/RgbColorSliders.svelte +48 -137
- package/RgbColorSliders.svelte.d.ts +5 -5
- package/Select.svelte +124 -251
- package/Select.svelte.d.ts +6 -2
- package/Slider.svelte +90 -259
- package/Slider.svelte.d.ts +1 -2
- package/Switch.svelte +24 -259
- package/Switch.svelte.d.ts +3 -1
- package/Tab.svelte +27 -175
- package/Tab.svelte.d.ts +6 -4
- package/TabList.svelte +146 -171
- package/TabList.svelte.d.ts +3 -2
- package/TabList.types.d.ts +6 -1
- package/TextArea.svelte +32 -129
- package/TextArea.svelte.d.ts +1 -1
- package/Tooltip.svelte +88 -222
- package/Tooltip.svelte.d.ts +21 -13
- package/Tree.constants.d.ts +0 -1
- package/Tree.constants.js +0 -1
- package/Tree.svelte +35 -119
- package/Tree.svelte.d.ts +4 -4
- package/Tree.types.d.ts +1 -3
- package/TreeChevron.svelte +18 -98
- package/TreeChevron.svelte.d.ts +1 -0
- package/TreeItem.constants.d.ts +1 -0
- package/TreeItem.constants.js +1 -0
- package/TreeItem.svelte +251 -211
- package/TreeItem.svelte.d.ts +7 -3
- package/TreeItem.types.d.ts +1 -1
- package/TreeItemDisplay.svelte +20 -104
- package/TreeItemDisplay.svelte.d.ts +2 -2
- package/actions/applyLightDarkMode.d.ts +10 -0
- package/actions/applyLightDarkMode.js +36 -0
- package/actions/forwardEvents.js +3 -3
- package/css/Button.base.css +74 -0
- package/css/Button.colorful.css +17 -0
- package/css/Button.css +7 -0
- package/css/Button.secondary.colorful.css +15 -0
- package/css/Button.secondary.css +11 -0
- package/css/Button.shapes.css +14 -0
- package/css/Button.tool.colorful.css +13 -0
- package/css/Button.tool.css +18 -0
- package/css/Callout.base.css +43 -0
- package/css/Callout.colorful.css +5 -0
- package/css/Callout.css +2 -0
- package/css/Checkbox.base.css +145 -0
- package/css/Checkbox.colorful.css +17 -0
- package/css/Checkbox.css +2 -0
- package/css/ColorPicker.base.css +23 -0
- package/css/ColorPicker.css +1 -0
- package/css/Dialog.base.css +116 -0
- package/css/Dialog.css +1 -0
- package/css/Dropdown.base.css +147 -0
- package/css/Dropdown.colorful.css +23 -0
- package/css/Dropdown.css +2 -0
- package/css/HexColorSliders.base.css +106 -0
- package/css/HexColorSliders.css +1 -0
- package/css/HslColorSliders.base.css +124 -0
- package/css/HslColorSliders.css +1 -0
- package/css/Input.base.css +100 -0
- package/css/Input.colorful.css +22 -0
- package/css/Input.composed.css +8 -0
- package/css/Input.css +3 -0
- package/css/Label.base.css +119 -0
- package/css/Label.boxed.colorful.css +21 -0
- package/css/Label.boxed.css +31 -0
- package/css/Label.colorful.css +3 -0
- package/css/Label.css +4 -0
- package/css/Link.base.css +52 -0
- package/css/Link.colorful.css +15 -0
- package/css/Link.css +6 -0
- package/css/Link.ghost.colorful.css +7 -0
- package/css/Link.ghost.css +11 -0
- package/css/Link.undecorated.colorful.css +6 -0
- package/css/Link.undecorated.css +6 -0
- package/css/List.base.css +98 -0
- package/css/List.css +1 -0
- package/css/ListItem.base.css +59 -0
- package/css/ListItem.css +1 -0
- package/css/Menu.base.css +21 -0
- package/css/Menu.css +1 -0
- package/css/MenuBar.base.css +9 -0
- package/css/MenuBar.css +1 -0
- package/css/MenuButton.base.css +13 -0
- package/css/MenuButton.css +1 -0
- package/css/MenuItem.base.css +48 -0
- package/css/MenuItem.css +1 -0
- package/css/MenuItemDisplay.base.css +104 -0
- package/css/MenuItemDisplay.css +1 -0
- package/css/MenuSeparator.base.css +5 -0
- package/css/MenuSeparator.css +1 -0
- package/css/Popover copy.css +21 -0
- package/css/Popover.css +21 -0
- package/css/Progress.base.css +99 -0
- package/css/Progress.css +1 -0
- package/css/Radio.base.css +135 -0
- package/css/Radio.colorful.css +18 -0
- package/css/Radio.css +2 -0
- package/css/RgbColorSliders.base.css +94 -0
- package/css/RgbColorSliders.css +1 -0
- package/css/Select.base.css +127 -0
- package/css/Select.colorful.css +24 -0
- package/css/Select.composed.css +12 -0
- package/css/Select.css +3 -0
- package/css/Slider.base.css +182 -0
- package/css/Slider.colorful.css +11 -0
- package/css/Slider.composed.css +8 -0
- package/css/Slider.css +3 -0
- package/css/Switch.base.css +193 -0
- package/css/Switch.colorful.css +39 -0
- package/css/Switch.css +2 -0
- package/css/Tab.base.css +135 -0
- package/css/Tab.colorful.css +13 -0
- package/css/Tab.css +2 -0
- package/css/TabList.base.css +34 -0
- package/css/TabList.css +1 -0
- package/css/TextArea.base.css +85 -0
- package/css/TextArea.colorful.css +17 -0
- package/css/TextArea.composed.css +8 -0
- package/css/TextArea.css +3 -0
- package/css/Tooltip.base.css +6 -0
- package/css/Tooltip.css +1 -0
- package/css/Tree.base.css +74 -0
- package/css/Tree.composed.css +8 -0
- package/css/Tree.css +2 -0
- package/css/TreeChevron.base.css +86 -0
- package/css/TreeChevron.css +1 -0
- package/css/TreeItem.base.css +3 -0
- package/css/TreeItem.css +1 -0
- package/css/TreeItemDisplay.base.css +74 -0
- package/css/TreeItemDisplay.colorful.css +9 -0
- package/css/TreeItemDisplay.css +1 -0
- package/css/dark-mode.css +134 -0
- package/css/light-mode.css +134 -0
- package/css/sterling.css +37 -0
- package/index.d.ts +13 -18
- package/index.js +11 -15
- package/mediaQueries/prefersColorSchemeDark.d.ts +2 -0
- package/mediaQueries/prefersColorSchemeDark.js +10 -0
- package/{stores → mediaQueries}/prefersReducedMotion.d.ts +1 -0
- package/{stores → mediaQueries}/usingKeyboard.d.ts +1 -0
- package/package.json +136 -19
- package/Link.constants.d.ts +0 -1
- package/Link.constants.js +0 -1
- package/Link.types.d.ts +0 -4
- package/Tooltip.constants.d.ts +0 -1
- package/Tooltip.constants.js +0 -1
- package/Tooltip.types.d.ts +0 -4
- package/Tooltip.types.js +0 -1
- package/floating-ui.constants.d.ts +0 -1
- package/floating-ui.types.d.ts +0 -4
- package/floating-ui.types.js +0 -1
- package/theme/applyDarkTheme.d.ts +0 -7
- package/theme/applyDarkTheme.js +0 -11
- package/theme/applyLightTheme.d.ts +0 -7
- package/theme/applyLightTheme.js +0 -11
- package/theme/applyTheme.d.ts +0 -7
- package/theme/applyTheme.js +0 -20
- package/theme/colors.d.ts +0 -54
- package/theme/colors.js +0 -82
- package/theme/darkTheme.d.ts +0 -2
- package/theme/darkTheme.js +0 -142
- package/theme/lightTheme.d.ts +0 -2
- package/theme/lightTheme.js +0 -119
- package/theme/toggleDarkTheme.d.ts +0 -18
- package/theme/toggleDarkTheme.js +0 -53
- package/theme/types.d.ts +0 -21
- package/theme/types.js +0 -1
- /package/{Link.types.js → Popover.types.js} +0 -0
- /package/{stores → mediaQueries}/prefersReducedMotion.js +0 -0
- /package/{stores → mediaQueries}/usingKeyboard.js +0 -0
package/Tooltip.svelte
CHANGED
|
@@ -1,240 +1,106 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export let
|
|
7
|
-
export let
|
|
8
|
-
export let hoverDelayMilliseconds = 1e3;
|
|
1
|
+
<script>import { onMount } from 'svelte';
|
|
2
|
+
import Callout from './Callout.svelte';
|
|
3
|
+
// ----- Props ----- //
|
|
4
|
+
// Forwarded to Callout
|
|
5
|
+
export let conditionalRender = true;
|
|
6
|
+
export let crossAxisOffset = 0;
|
|
7
|
+
export let mainAxisOffset = 0;
|
|
9
8
|
export let open = false;
|
|
10
|
-
export let placement =
|
|
11
|
-
export let
|
|
9
|
+
export let placement = 'bottom-start';
|
|
10
|
+
export let portalHost = undefined;
|
|
11
|
+
export let variant = '';
|
|
12
|
+
/** When true, the tooltip is disabled and will not be shown. */
|
|
13
|
+
export let disabled = false;
|
|
14
|
+
/** The duration of mouse hover before showing the tooltip. */
|
|
15
|
+
export let hoverDelayMilliseconds = 1000;
|
|
16
|
+
// ----- State ----- //
|
|
12
17
|
let originRef;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let position = void 0;
|
|
16
|
-
$:
|
|
17
|
-
reference = $$slots.default ? originRef?.previousElementSibling : void 0;
|
|
18
|
-
const computeTooltipPosition = async () => {
|
|
19
|
-
if (reference && tooltipRef && arrowRef) {
|
|
20
|
-
const floatingOffset = Math.sqrt(2 * arrowRef.offsetWidth ** 2) / 2;
|
|
21
|
-
const middleware = [
|
|
22
|
-
offset(floatingOffset),
|
|
23
|
-
flip({ fallbackPlacements: ["top", "bottom", "right", "left"] }),
|
|
24
|
-
arrow({
|
|
25
|
-
element: arrowRef
|
|
26
|
-
})
|
|
27
|
-
];
|
|
28
|
-
position = await computePosition(reference, tooltipRef, {
|
|
29
|
-
placement,
|
|
30
|
-
middleware
|
|
31
|
-
});
|
|
32
|
-
} else {
|
|
33
|
-
position = void 0;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
let cleanupAutoUpdate = () => {
|
|
37
|
-
};
|
|
38
|
-
const autoUpdateTooltipPosition = () => {
|
|
39
|
-
cleanupAutoUpdate();
|
|
40
|
-
cleanupAutoUpdate = () => {
|
|
41
|
-
};
|
|
42
|
-
if (reference && tooltipRef) {
|
|
43
|
-
cleanupAutoUpdate = autoUpdate(reference, tooltipRef, computeTooltipPosition);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
$:
|
|
47
|
-
reference, tooltipRef, autoUpdateTooltipPosition();
|
|
48
|
-
$:
|
|
49
|
-
open, placement, computeTooltipPosition();
|
|
50
|
-
$:
|
|
51
|
-
tipStyle = position ? `left:${position.x}px; top:${position.y}px;` : "";
|
|
52
|
-
const getArrowPlacementStyle = (position2) => {
|
|
53
|
-
if (position2?.placement) {
|
|
54
|
-
switch (position2.placement) {
|
|
55
|
-
case "top":
|
|
56
|
-
case "top-start":
|
|
57
|
-
case "top-end":
|
|
58
|
-
return `bottom: -${arrowRef.offsetWidth}px;transform:translate(0, -50%) rotate(135deg);`;
|
|
59
|
-
case "right":
|
|
60
|
-
case "right-start":
|
|
61
|
-
case "right-end":
|
|
62
|
-
return `left: -${arrowRef.offsetWidth}px;transform:translate(50%, 0) rotate(225deg);`;
|
|
63
|
-
case "bottom":
|
|
64
|
-
case "bottom-start":
|
|
65
|
-
case "bottom-end":
|
|
66
|
-
return `top: -${arrowRef.offsetWidth}px;transform:translate(0, 50%) rotate(-45deg);`;
|
|
67
|
-
case "left":
|
|
68
|
-
case "left-start":
|
|
69
|
-
case "left-end":
|
|
70
|
-
return `right: -${arrowRef.offsetWidth}px;transform:translate(-50%, 0) rotate(45deg);`;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return "";
|
|
74
|
-
};
|
|
75
|
-
const getArrowOffsetStyle = (position2) => {
|
|
76
|
-
const arrow2 = position2?.middlewareData?.arrow;
|
|
77
|
-
if (arrow2) {
|
|
78
|
-
if (arrow2.x !== null && arrow2.x !== void 0) {
|
|
79
|
-
return `left: ${arrow2.x}px;`;
|
|
80
|
-
} else if (arrow2.y !== null && arrow2.y !== void 0) {
|
|
81
|
-
return `top: ${arrow2.y}px;`;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return "";
|
|
85
|
-
};
|
|
86
|
-
$:
|
|
87
|
-
arrowStyle = getArrowPlacementStyle(position) + getArrowOffsetStyle(position);
|
|
18
|
+
$: reference = $$slots.default ? originRef?.previousElementSibling : undefined;
|
|
19
|
+
// ----- Show/Hide ----- //
|
|
88
20
|
const show = () => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
};
|
|
93
|
-
const hide = () => open = false;
|
|
94
|
-
const toggle = () => {
|
|
95
|
-
if (!disabled) {
|
|
96
|
-
open = !open;
|
|
97
|
-
} else {
|
|
98
|
-
open = false;
|
|
99
|
-
}
|
|
21
|
+
if (!disabled) {
|
|
22
|
+
open = true;
|
|
23
|
+
}
|
|
100
24
|
};
|
|
25
|
+
const hide = () => (open = false);
|
|
101
26
|
const delayShow = () => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
27
|
+
hoverDelayMilliseconds === 0
|
|
28
|
+
? show()
|
|
29
|
+
: setTimeout(() => {
|
|
30
|
+
show();
|
|
31
|
+
}, hoverDelayMilliseconds);
|
|
105
32
|
};
|
|
106
33
|
$: {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
34
|
+
if (disabled) {
|
|
35
|
+
hide();
|
|
36
|
+
}
|
|
110
37
|
}
|
|
111
|
-
|
|
112
|
-
};
|
|
38
|
+
// ----- Event Listeners ----- //
|
|
39
|
+
let cleanupAutoShowUpdate = () => { };
|
|
113
40
|
const autoShowUpdate = () => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
case "click":
|
|
122
|
-
element.addEventListener("click", toggle);
|
|
123
|
-
cleanupAutoShowUpdate = () => element.removeEventListener("click", toggle);
|
|
124
|
-
break;
|
|
125
|
-
case "hover":
|
|
126
|
-
element.addEventListener("mouseenter", delayShow);
|
|
127
|
-
element.addEventListener("mouseleave", hide);
|
|
41
|
+
cleanupAutoShowUpdate();
|
|
42
|
+
cleanupAutoShowUpdate = () => { };
|
|
43
|
+
const element = reference;
|
|
44
|
+
open = false;
|
|
45
|
+
if (element) {
|
|
46
|
+
element.addEventListener('mouseenter', delayShow);
|
|
47
|
+
element.addEventListener('mouseleave', hide);
|
|
128
48
|
cleanupAutoShowUpdate = () => {
|
|
129
|
-
|
|
130
|
-
|
|
49
|
+
element.removeEventListener('mouseenter', delayShow);
|
|
50
|
+
element.removeEventListener('mouseleave', hide);
|
|
131
51
|
};
|
|
132
52
|
}
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
$:
|
|
136
|
-
reference, showOn, autoShowUpdate();
|
|
137
|
-
const fadeNoOp = (node, params) => {
|
|
138
|
-
return { delay: 0, duration: 0 };
|
|
139
53
|
};
|
|
140
|
-
$:
|
|
141
|
-
|
|
142
|
-
let mounted = false;
|
|
54
|
+
$: reference, autoShowUpdate();
|
|
55
|
+
// ----- EventHandlers ----- //
|
|
143
56
|
onMount(() => {
|
|
144
|
-
|
|
145
|
-
portalTarget = portalTarget || document.body;
|
|
146
|
-
autoUpdateTooltipPosition();
|
|
147
|
-
computeTooltipPosition();
|
|
148
|
-
autoShowUpdate();
|
|
57
|
+
autoShowUpdate();
|
|
149
58
|
});
|
|
150
59
|
</script>
|
|
151
60
|
|
|
152
|
-
<slot {disabled} {open} />
|
|
61
|
+
<slot {disabled} {hoverDelayMilliseconds} {open} {variant} />
|
|
153
62
|
<div class="sterling-tooltip-origin" bind:this={originRef} />
|
|
154
|
-
|
|
155
|
-
{
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
<div class="arrow" bind:this={arrowRef} style={arrowStyle} />
|
|
199
|
-
<slot name="tip" />
|
|
200
|
-
</div>
|
|
201
|
-
</div>
|
|
202
|
-
{/if}
|
|
203
|
-
|
|
204
|
-
<style>
|
|
205
|
-
.sterling-tooltip-origin {
|
|
206
|
-
display: none;
|
|
207
|
-
width: 0;
|
|
208
|
-
height: 0;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
.sterling-tooltip-portal {
|
|
212
|
-
position: relative;
|
|
213
|
-
overflow: visible;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.sterling-tooltip {
|
|
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);
|
|
223
|
-
position: absolute;
|
|
224
|
-
overflow: visible;
|
|
225
|
-
box-shadow: rgba(0, 0, 0, 0.4) 2px 2px 4px -1px;
|
|
226
|
-
z-index: 4;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.arrow {
|
|
230
|
-
position: absolute;
|
|
231
|
-
width: 10px;
|
|
232
|
-
height: 10px;
|
|
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);
|
|
238
|
-
clip-path: polygon(0% 1%, 100% 1%, 100% 100%, 0% 1%);
|
|
239
|
-
}
|
|
240
|
-
</style>
|
|
63
|
+
<Callout
|
|
64
|
+
{conditionalRender}
|
|
65
|
+
{crossAxisOffset}
|
|
66
|
+
{mainAxisOffset}
|
|
67
|
+
{open}
|
|
68
|
+
{placement}
|
|
69
|
+
{portalHost}
|
|
70
|
+
{reference}
|
|
71
|
+
{variant}
|
|
72
|
+
on:blur
|
|
73
|
+
on:click
|
|
74
|
+
on:dblclick
|
|
75
|
+
on:dragend
|
|
76
|
+
on:dragenter
|
|
77
|
+
on:dragleave
|
|
78
|
+
on:dragover
|
|
79
|
+
on:dragstart
|
|
80
|
+
on:drop
|
|
81
|
+
on:focus
|
|
82
|
+
on:focusin
|
|
83
|
+
on:focusout
|
|
84
|
+
on:keydown
|
|
85
|
+
on:keypress
|
|
86
|
+
on:keyup
|
|
87
|
+
on:mousedown
|
|
88
|
+
on:mouseenter
|
|
89
|
+
on:mouseleave
|
|
90
|
+
on:mousemove
|
|
91
|
+
on:mouseover
|
|
92
|
+
on:mouseout
|
|
93
|
+
on:mouseup
|
|
94
|
+
on:pointercancel
|
|
95
|
+
on:pointerdown
|
|
96
|
+
on:pointerenter
|
|
97
|
+
on:pointerleave
|
|
98
|
+
on:pointermove
|
|
99
|
+
on:pointerover
|
|
100
|
+
on:pointerout
|
|
101
|
+
on:pointerup
|
|
102
|
+
on:wheel
|
|
103
|
+
{...$$restProps}
|
|
104
|
+
>
|
|
105
|
+
<slot name="tip" {placement} {variant} />
|
|
106
|
+
</Callout>
|
package/Tooltip.svelte.d.ts
CHANGED
|
@@ -2,12 +2,15 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
+
conditionalRender?: boolean | undefined;
|
|
6
|
+
crossAxisOffset?: number | undefined;
|
|
7
|
+
mainAxisOffset?: number | undefined;
|
|
8
|
+
open?: boolean | undefined;
|
|
9
|
+
placement?: string | undefined;
|
|
10
|
+
portalHost?: HTMLElement | undefined;
|
|
11
|
+
variant?: string | undefined;
|
|
5
12
|
disabled?: boolean | undefined;
|
|
6
|
-
showOn?: string | undefined;
|
|
7
13
|
hoverDelayMilliseconds?: number | undefined;
|
|
8
|
-
open?: boolean | undefined;
|
|
9
|
-
placement?: import("@floating-ui/core").Placement | undefined;
|
|
10
|
-
portalTarget?: HTMLElement | undefined;
|
|
11
14
|
};
|
|
12
15
|
events: {
|
|
13
16
|
blur: FocusEvent;
|
|
@@ -32,14 +35,14 @@ declare const __propDef: {
|
|
|
32
35
|
mouseover: MouseEvent;
|
|
33
36
|
mouseout: MouseEvent;
|
|
34
37
|
mouseup: MouseEvent;
|
|
35
|
-
pointercancel:
|
|
36
|
-
pointerdown:
|
|
37
|
-
pointerenter:
|
|
38
|
-
pointerleave:
|
|
39
|
-
pointermove:
|
|
40
|
-
pointerover:
|
|
41
|
-
pointerout:
|
|
42
|
-
pointerup:
|
|
38
|
+
pointercancel: CustomEvent<any>;
|
|
39
|
+
pointerdown: CustomEvent<any>;
|
|
40
|
+
pointerenter: CustomEvent<any>;
|
|
41
|
+
pointerleave: CustomEvent<any>;
|
|
42
|
+
pointermove: CustomEvent<any>;
|
|
43
|
+
pointerover: CustomEvent<any>;
|
|
44
|
+
pointerout: CustomEvent<any>;
|
|
45
|
+
pointerup: CustomEvent<any>;
|
|
43
46
|
wheel: WheelEvent;
|
|
44
47
|
} & {
|
|
45
48
|
[evt: string]: CustomEvent<any>;
|
|
@@ -47,9 +50,14 @@ declare const __propDef: {
|
|
|
47
50
|
slots: {
|
|
48
51
|
default: {
|
|
49
52
|
disabled: boolean;
|
|
53
|
+
hoverDelayMilliseconds: number;
|
|
50
54
|
open: boolean;
|
|
55
|
+
variant: string;
|
|
56
|
+
};
|
|
57
|
+
tip: {
|
|
58
|
+
placement: string;
|
|
59
|
+
variant: string;
|
|
51
60
|
};
|
|
52
|
-
tip: {};
|
|
53
61
|
};
|
|
54
62
|
};
|
|
55
63
|
export type TooltipProps = typeof __propDef.props;
|
package/Tree.constants.d.ts
CHANGED
package/Tree.constants.js
CHANGED
package/Tree.svelte
CHANGED
|
@@ -1,68 +1,70 @@
|
|
|
1
|
-
<script>import { createEventDispatcher, setContext } from
|
|
2
|
-
import { writable } from
|
|
3
|
-
import { TREE_CONTEXT_KEY } from
|
|
4
|
-
import { usingKeyboard } from
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script>import { createEventDispatcher, setContext } from 'svelte';
|
|
2
|
+
import { writable } from 'svelte/store';
|
|
3
|
+
import { TREE_CONTEXT_KEY } from './Tree.constants';
|
|
4
|
+
import { usingKeyboard } from './mediaQueries/usingKeyboard';
|
|
5
|
+
// ----- Props ----- //
|
|
6
|
+
/** When true, the tree and its descendants are disabled. */
|
|
7
7
|
export let disabled = false;
|
|
8
|
-
|
|
8
|
+
/** The value of the currently selected item. */
|
|
9
|
+
export let selectedValue = undefined;
|
|
10
|
+
/** The values of items that are expanded. */
|
|
9
11
|
export let expandedValues = [];
|
|
12
|
+
/** Additional class names to apply. */
|
|
13
|
+
export let variant = '';
|
|
14
|
+
// ----- State ----- //
|
|
10
15
|
let treeRef;
|
|
11
|
-
const colorfulStore = writable(colorful);
|
|
12
16
|
const disabledStore = writable(disabled);
|
|
13
17
|
const expandedValuesStore = writable(expandedValues);
|
|
14
18
|
const selectedValueStore = writable(selectedValue);
|
|
19
|
+
// ----- Methods ----- //
|
|
15
20
|
export const blur = () => {
|
|
16
|
-
|
|
21
|
+
treeRef?.blur();
|
|
17
22
|
};
|
|
18
23
|
export const focus = (options) => {
|
|
19
|
-
|
|
24
|
+
treeRef?.focus(options);
|
|
20
25
|
};
|
|
26
|
+
// ----- Events ----- //
|
|
21
27
|
const dispatch = createEventDispatcher();
|
|
22
|
-
const raiseExpandCollapse = (
|
|
23
|
-
|
|
28
|
+
const raiseExpandCollapse = (expandedValues) => {
|
|
29
|
+
dispatch('expandCollapse', { expandedValues });
|
|
24
30
|
};
|
|
25
|
-
const raiseSelect = (
|
|
26
|
-
|
|
31
|
+
const raiseSelect = (selectedValue) => {
|
|
32
|
+
dispatch('select', { selectedValue });
|
|
27
33
|
};
|
|
34
|
+
// ----- Reactions ----- //
|
|
28
35
|
$: {
|
|
29
|
-
|
|
36
|
+
selectedValueStore.set(selectedValue);
|
|
30
37
|
}
|
|
31
38
|
$: {
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
selectedValue = $selectedValueStore;
|
|
40
|
+
raiseSelect($selectedValueStore);
|
|
34
41
|
}
|
|
35
42
|
$: {
|
|
36
|
-
|
|
43
|
+
expandedValuesStore.set(expandedValues);
|
|
37
44
|
}
|
|
38
45
|
$: {
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
expandedValues = $expandedValuesStore;
|
|
47
|
+
raiseExpandCollapse($expandedValuesStore);
|
|
41
48
|
}
|
|
42
49
|
$: {
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
$: {
|
|
46
|
-
disabledStore.set(disabled);
|
|
50
|
+
disabledStore.set(disabled);
|
|
47
51
|
}
|
|
52
|
+
// ----- Set Context ----- //
|
|
48
53
|
setContext(TREE_CONTEXT_KEY, {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
selectedValue: selectedValueStore
|
|
54
|
+
disabled: disabledStore,
|
|
55
|
+
expandedValues: expandedValuesStore,
|
|
56
|
+
selectedValue: selectedValueStore
|
|
53
57
|
});
|
|
54
58
|
</script>
|
|
55
59
|
|
|
56
|
-
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
57
60
|
<div
|
|
58
61
|
bind:this={treeRef}
|
|
59
62
|
aria-disabled={disabled}
|
|
60
|
-
class=
|
|
61
|
-
class:colorful
|
|
62
|
-
class:composed
|
|
63
|
+
class={`sterling-tree ${variant}`}
|
|
63
64
|
class:disabled
|
|
64
65
|
class:using-keyboard={$usingKeyboard}
|
|
65
66
|
role="tree"
|
|
67
|
+
tabindex="0"
|
|
66
68
|
on:blur
|
|
67
69
|
on:click
|
|
68
70
|
on:dblclick
|
|
@@ -97,92 +99,6 @@ setContext(TREE_CONTEXT_KEY, {
|
|
|
97
99
|
{...$$restProps}
|
|
98
100
|
>
|
|
99
101
|
<div class="container">
|
|
100
|
-
<slot {
|
|
102
|
+
<slot {disabled} {expandedValues} {selectedValue} {variant} />
|
|
101
103
|
</div>
|
|
102
104
|
</div>
|
|
103
|
-
|
|
104
|
-
<style>
|
|
105
|
-
.sterling-tree {
|
|
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);
|
|
111
|
-
box-sizing: border-box;
|
|
112
|
-
color: var(--stsv-common__color);
|
|
113
|
-
height: 100%;
|
|
114
|
-
overflow-x: hidden;
|
|
115
|
-
overflow-y: auto;
|
|
116
|
-
margin: 0;
|
|
117
|
-
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.sterling-tree:hover {
|
|
121
|
-
border-color: var(--stsv-input__border-color--hover);
|
|
122
|
-
color: var(--stsv-input__color--hover);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.sterling-tree.using-keyboard:focus-within {
|
|
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);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.sterling-tree.composed,
|
|
135
|
-
.sterling-tree.composed:hover,
|
|
136
|
-
.sterling-tree.composed.using-keyboard:focus-visible,
|
|
137
|
-
.sterling-tree.composed.disabled {
|
|
138
|
-
background: none;
|
|
139
|
-
border: none;
|
|
140
|
-
outline: none;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.sterling-tree.disabled * {
|
|
144
|
-
cursor: not-allowed;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/* ----- container - a layout panel that grows with the items ----- */
|
|
148
|
-
|
|
149
|
-
.container {
|
|
150
|
-
display: flex;
|
|
151
|
-
flex-direction: column;
|
|
152
|
-
flex-wrap: nowrap;
|
|
153
|
-
position: relative;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.container::after {
|
|
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
|
-
);
|
|
165
|
-
bottom: 0;
|
|
166
|
-
content: '';
|
|
167
|
-
left: 0;
|
|
168
|
-
opacity: 0;
|
|
169
|
-
position: absolute;
|
|
170
|
-
pointer-events: none;
|
|
171
|
-
right: 0;
|
|
172
|
-
top: 0;
|
|
173
|
-
transition: opacity 250ms;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
.sterling-tree.disabled .container::after {
|
|
177
|
-
opacity: 1;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/* ----- media queries ----- */
|
|
181
|
-
|
|
182
|
-
@media (prefers-reduced-motion) {
|
|
183
|
-
.sterling-tree,
|
|
184
|
-
.container::after {
|
|
185
|
-
transition: none;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
</style>
|
package/Tree.svelte.d.ts
CHANGED
|
@@ -2,11 +2,10 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
-
colorful?: boolean | undefined;
|
|
6
|
-
composed?: boolean | undefined;
|
|
7
5
|
disabled?: boolean | undefined;
|
|
8
6
|
selectedValue?: string | undefined;
|
|
9
7
|
expandedValues?: string[] | undefined;
|
|
8
|
+
variant?: string | undefined;
|
|
10
9
|
blur?: (() => void) | undefined;
|
|
11
10
|
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
12
11
|
};
|
|
@@ -49,9 +48,10 @@ declare const __propDef: {
|
|
|
49
48
|
};
|
|
50
49
|
slots: {
|
|
51
50
|
default: {
|
|
52
|
-
colorful: boolean;
|
|
53
|
-
composed: boolean;
|
|
54
51
|
disabled: boolean;
|
|
52
|
+
expandedValues: string[];
|
|
53
|
+
selectedValue: string | undefined;
|
|
54
|
+
variant: string;
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
};
|
package/Tree.types.d.ts
CHANGED
|
@@ -3,9 +3,7 @@ import type { Readable, Writable } from 'svelte/store';
|
|
|
3
3
|
* The context for a Tree and its descendants.
|
|
4
4
|
*/
|
|
5
5
|
export type TreeContext = {
|
|
6
|
-
/** When true,
|
|
7
|
-
colorful: Readable<boolean>;
|
|
8
|
-
/** When true, the tree and its descendants are disabled */
|
|
6
|
+
/** When true, the tree and its descendants are disabled. */
|
|
9
7
|
disabled: Readable<boolean>;
|
|
10
8
|
/** The values of items that are expanded. */
|
|
11
9
|
expandedValues: Writable<string[]>;
|