@geoffcox/sterling-svelte 0.0.24 → 0.0.25
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/Dropdown.svelte +17 -39
- package/List.svelte +0 -1
- package/Popover.svelte +135 -0
- package/Popover.svelte.d.ts +51 -0
- package/Progress.svelte +13 -2
- package/Progress.svelte.d.ts +1 -0
- package/Radio.svelte +39 -22
- package/Select.svelte +20 -63
- package/Switch.svelte +7 -3
- package/TextArea.svelte +10 -8
- package/TextArea.svelte.d.ts +1 -1
- package/actions/clickOutside.d.ts +12 -1
- package/actions/clickOutside.js +13 -2
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/package.json +2 -1
package/Dropdown.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import Popup from "./Popover.svelte";
|
|
3
3
|
import { clickOutside } from "./actions/clickOutside";
|
|
4
4
|
import { idGenerator } from "./idGenerator";
|
|
5
5
|
const popupId = idGenerator.nextId("Dropdown-popup");
|
|
@@ -8,11 +8,7 @@ export let disabled = false;
|
|
|
8
8
|
export let open = false;
|
|
9
9
|
export let stayOpenOnClickAway = false;
|
|
10
10
|
let dropdownRef;
|
|
11
|
-
let
|
|
12
|
-
let popupPosition = {
|
|
13
|
-
x: void 0,
|
|
14
|
-
y: void 0
|
|
15
|
-
};
|
|
11
|
+
let popupContentRef;
|
|
16
12
|
const dispatch = createEventDispatcher();
|
|
17
13
|
const raiseOpen = (open2) => {
|
|
18
14
|
dispatch("open", { open: open2 });
|
|
@@ -29,29 +25,11 @@ export const blur = () => {
|
|
|
29
25
|
export const focus = (options) => {
|
|
30
26
|
dropdownRef?.focus(options);
|
|
31
27
|
};
|
|
32
|
-
let mounted = false;
|
|
33
|
-
onMount(() => {
|
|
34
|
-
mounted = true;
|
|
35
|
-
const cleanup = autoUpdate(dropdownRef, popupRef, async () => {
|
|
36
|
-
const { x, y } = await computePosition(dropdownRef, popupRef, {
|
|
37
|
-
placement: "bottom-end",
|
|
38
|
-
middleware: [offset({ mainAxis: 2 }), flip(), shift({ padding: 0 })]
|
|
39
|
-
});
|
|
40
|
-
if (open) {
|
|
41
|
-
popupPosition = { x, y };
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return cleanup;
|
|
45
|
-
});
|
|
46
28
|
const onClick = (event) => {
|
|
47
|
-
if (!disabled
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
open = !open;
|
|
52
|
-
event.preventDefault();
|
|
53
|
-
event.stopPropagation();
|
|
54
|
-
}
|
|
29
|
+
if (!disabled) {
|
|
30
|
+
open = !open;
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
event.stopPropagation();
|
|
55
33
|
}
|
|
56
34
|
};
|
|
57
35
|
const onKeydown = (event) => {
|
|
@@ -81,7 +59,7 @@ const onClickOutside = (event) => {
|
|
|
81
59
|
class:disabled
|
|
82
60
|
role="combobox"
|
|
83
61
|
tabindex="0"
|
|
84
|
-
use:clickOutside
|
|
62
|
+
use:clickOutside={{ ignoreOthers: [popupContentRef] }}
|
|
85
63
|
on:blur
|
|
86
64
|
on:click
|
|
87
65
|
on:click={onClick}
|
|
@@ -120,15 +98,11 @@ const onClickOutside = (event) => {
|
|
|
120
98
|
</div>
|
|
121
99
|
</slot>
|
|
122
100
|
|
|
123
|
-
<
|
|
124
|
-
bind:this={
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
style="left:{popupPosition.x}px; top:{popupPosition.y}px"
|
|
129
|
-
>
|
|
130
|
-
<slot {composed} {disabled} {open} />
|
|
131
|
-
</div>
|
|
101
|
+
<Popup reference={dropdownRef} open={!disabled && open}>
|
|
102
|
+
<div class="popup-content" bind:this={popupContentRef}>
|
|
103
|
+
<slot {composed} {disabled} {open} />
|
|
104
|
+
</div>
|
|
105
|
+
</Popup>
|
|
132
106
|
</div>
|
|
133
107
|
|
|
134
108
|
<style>
|
|
@@ -266,6 +240,10 @@ const onClickOutside = (event) => {
|
|
|
266
240
|
grid-template-rows: 1fr;
|
|
267
241
|
}
|
|
268
242
|
|
|
243
|
+
.popup-content {
|
|
244
|
+
padding: 0.25em;
|
|
245
|
+
}
|
|
246
|
+
|
|
269
247
|
@media (prefers-reduced-motion) {
|
|
270
248
|
.sterling-dropdown,
|
|
271
249
|
.sterling-dropdown::after {
|
package/List.svelte
CHANGED
package/Popover.svelte
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<script>import { onMount } from "svelte";
|
|
2
|
+
import { autoUpdate, computePosition, flip, offset, shift } from "@floating-ui/dom";
|
|
3
|
+
import { portal } from "./actions/portal";
|
|
4
|
+
export let placement = "bottom-start";
|
|
5
|
+
export let open = false;
|
|
6
|
+
export let reference;
|
|
7
|
+
export let portalHost = void 0;
|
|
8
|
+
let popupRef;
|
|
9
|
+
let popupPosition = { x: 0, y: 0 };
|
|
10
|
+
const hostId = "SterlingPopoverPortal";
|
|
11
|
+
const ensurePortalHost = () => {
|
|
12
|
+
if (portalHost) {
|
|
13
|
+
return portalHost;
|
|
14
|
+
}
|
|
15
|
+
let host = document.querySelector(`#${hostId}`);
|
|
16
|
+
if (!host) {
|
|
17
|
+
host = document.createElement("div");
|
|
18
|
+
host.id = hostId;
|
|
19
|
+
host.style.overflow = "visible";
|
|
20
|
+
document.body.append(host);
|
|
21
|
+
}
|
|
22
|
+
portalHost = host;
|
|
23
|
+
};
|
|
24
|
+
let bodyHeight = 0;
|
|
25
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
26
|
+
bodyHeight = entries[0].target.clientHeight;
|
|
27
|
+
});
|
|
28
|
+
const middleware = [
|
|
29
|
+
offset({ mainAxis: -2 }),
|
|
30
|
+
flip(),
|
|
31
|
+
shift({ padding: 0, mainAxis: true, crossAxis: true })
|
|
32
|
+
];
|
|
33
|
+
const computePopupPosition = async () => {
|
|
34
|
+
if (reference && popupRef) {
|
|
35
|
+
popupPosition = await computePosition(reference, popupRef, {
|
|
36
|
+
placement,
|
|
37
|
+
middleware
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
popupPosition = { x: 0, y: 0 };
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
let cleanupAutoUpdate = () => {
|
|
44
|
+
};
|
|
45
|
+
const autoUpdateMenuPosition = () => {
|
|
46
|
+
cleanupAutoUpdate();
|
|
47
|
+
if (reference && popupRef) {
|
|
48
|
+
cleanupAutoUpdate = autoUpdate(reference, popupRef, computePopupPosition);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
$:
|
|
52
|
+
popupRef, reference, autoUpdateMenuPosition();
|
|
53
|
+
$:
|
|
54
|
+
open, bodyHeight, placement, computePopupPosition();
|
|
55
|
+
onMount(() => {
|
|
56
|
+
ensurePortalHost();
|
|
57
|
+
resizeObserver.observe(document.body);
|
|
58
|
+
return () => {
|
|
59
|
+
resizeObserver.unobserve(document.body);
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<div use:portal={{ target: portalHost ?? document.body }} class="sterling-popover-portal">
|
|
65
|
+
<div
|
|
66
|
+
bind:this={popupRef}
|
|
67
|
+
class="sterling-popover"
|
|
68
|
+
class:open
|
|
69
|
+
on:blur
|
|
70
|
+
on:click
|
|
71
|
+
on:copy
|
|
72
|
+
on:cut
|
|
73
|
+
on:dblclick
|
|
74
|
+
on:dragend
|
|
75
|
+
on:dragenter
|
|
76
|
+
on:dragleave
|
|
77
|
+
on:dragover
|
|
78
|
+
on:dragstart
|
|
79
|
+
on:drop
|
|
80
|
+
on:focus
|
|
81
|
+
on:focusin
|
|
82
|
+
on:focusout
|
|
83
|
+
on:keydown
|
|
84
|
+
on:keypress
|
|
85
|
+
on:keyup
|
|
86
|
+
on:mousedown
|
|
87
|
+
on:mouseenter
|
|
88
|
+
on:mouseleave
|
|
89
|
+
on:mousemove
|
|
90
|
+
on:mouseover
|
|
91
|
+
on:mouseout
|
|
92
|
+
on:mouseup
|
|
93
|
+
on:scroll
|
|
94
|
+
on:wheel
|
|
95
|
+
on:paste
|
|
96
|
+
{...$$restProps}
|
|
97
|
+
style="left:{popupPosition.x}px; top:{popupPosition.y}px"
|
|
98
|
+
>
|
|
99
|
+
<slot />
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
<style>
|
|
104
|
+
.sterling-popover-portal {
|
|
105
|
+
position: relative;
|
|
106
|
+
overflow: visible;
|
|
107
|
+
background: rgba(255, 0, 0, 0.1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.sterling-popover {
|
|
111
|
+
background-color: var(--stsv-Common__background-color);
|
|
112
|
+
border-color: var(--stsv-Common__border-color);
|
|
113
|
+
border-radius: var(--stsv-Common__border-radius);
|
|
114
|
+
border-style: var(--stsv-Common__border-style);
|
|
115
|
+
border-width: var(--stsv-Common__border-width);
|
|
116
|
+
box-shadow: rgba(0, 0, 0, 0.4) 2px 2px 4px -1px;
|
|
117
|
+
box-sizing: border-box;
|
|
118
|
+
display: none;
|
|
119
|
+
grid-template-columns: 1fr;
|
|
120
|
+
grid-template-rows: 1fr;
|
|
121
|
+
height: fit-content;
|
|
122
|
+
left: 0;
|
|
123
|
+
max-height: calc(50vh);
|
|
124
|
+
overflow: auto;
|
|
125
|
+
overscroll-behavior: contain;
|
|
126
|
+
position: absolute;
|
|
127
|
+
top: 0;
|
|
128
|
+
width: max-content;
|
|
129
|
+
z-index: 1;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.sterling-popover.open {
|
|
133
|
+
display: grid;
|
|
134
|
+
}
|
|
135
|
+
</style>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Placement } from '@floating-ui/dom';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
placement?: Placement | undefined;
|
|
7
|
+
open?: boolean | undefined;
|
|
8
|
+
reference: HTMLElement;
|
|
9
|
+
portalHost?: HTMLElement | undefined;
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
blur: FocusEvent;
|
|
13
|
+
click: MouseEvent;
|
|
14
|
+
copy: ClipboardEvent;
|
|
15
|
+
cut: ClipboardEvent;
|
|
16
|
+
dblclick: MouseEvent;
|
|
17
|
+
dragend: DragEvent;
|
|
18
|
+
dragenter: DragEvent;
|
|
19
|
+
dragleave: DragEvent;
|
|
20
|
+
dragover: DragEvent;
|
|
21
|
+
dragstart: DragEvent;
|
|
22
|
+
drop: DragEvent;
|
|
23
|
+
focus: FocusEvent;
|
|
24
|
+
focusin: FocusEvent;
|
|
25
|
+
focusout: FocusEvent;
|
|
26
|
+
keydown: KeyboardEvent;
|
|
27
|
+
keypress: KeyboardEvent;
|
|
28
|
+
keyup: KeyboardEvent;
|
|
29
|
+
mousedown: MouseEvent;
|
|
30
|
+
mouseenter: MouseEvent;
|
|
31
|
+
mouseleave: MouseEvent;
|
|
32
|
+
mousemove: MouseEvent;
|
|
33
|
+
mouseover: MouseEvent;
|
|
34
|
+
mouseout: MouseEvent;
|
|
35
|
+
mouseup: MouseEvent;
|
|
36
|
+
scroll: Event;
|
|
37
|
+
wheel: WheelEvent;
|
|
38
|
+
paste: ClipboardEvent;
|
|
39
|
+
} & {
|
|
40
|
+
[evt: string]: CustomEvent<any>;
|
|
41
|
+
};
|
|
42
|
+
slots: {
|
|
43
|
+
default: {};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export type PopoverProps = typeof __propDef.props;
|
|
47
|
+
export type PopoverEvents = typeof __propDef.events;
|
|
48
|
+
export type PopoverSlots = typeof __propDef.slots;
|
|
49
|
+
export default class Popover extends SvelteComponentTyped<PopoverProps, PopoverEvents, PopoverSlots> {
|
|
50
|
+
}
|
|
51
|
+
export {};
|
package/Progress.svelte
CHANGED
|
@@ -3,6 +3,7 @@ export let max = 100;
|
|
|
3
3
|
export let percent = 0;
|
|
4
4
|
export let vertical = false;
|
|
5
5
|
export let colorful = "none";
|
|
6
|
+
export let disabled = false;
|
|
6
7
|
let clientHeight;
|
|
7
8
|
let clientWidth;
|
|
8
9
|
$:
|
|
@@ -33,6 +34,7 @@ $:
|
|
|
33
34
|
|
|
34
35
|
<div
|
|
35
36
|
class="sterling-progress"
|
|
37
|
+
class:disabled
|
|
36
38
|
class:vertical
|
|
37
39
|
role="progressbar"
|
|
38
40
|
on:blur
|
|
@@ -103,7 +105,6 @@ $:
|
|
|
103
105
|
justify-content: flex-start;
|
|
104
106
|
width: 100%;
|
|
105
107
|
height: 100%;
|
|
106
|
-
min-width: 100px;
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
.indicator {
|
|
@@ -127,7 +128,6 @@ $:
|
|
|
127
128
|
flex-direction: column;
|
|
128
129
|
justify-content: flex-end;
|
|
129
130
|
min-width: unset;
|
|
130
|
-
min-height: 100px;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
.sterling-progress.vertical .indicator {
|
|
@@ -155,6 +155,17 @@ $:
|
|
|
155
155
|
background-color: var(--stsv-Error__border-color);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
/* ----- Disabled ----- */
|
|
159
|
+
|
|
160
|
+
.sterling-progress.disabled {
|
|
161
|
+
background: var(--stsv-Common__background-color--disabled);
|
|
162
|
+
border-color: var(--stsv-Common__border-color--disabled);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.sterling-progress.disabled .indicator {
|
|
166
|
+
background-color: var(--stsv-Display__color--disabled);
|
|
167
|
+
}
|
|
168
|
+
|
|
158
169
|
@media (prefers-reduced-motion) {
|
|
159
170
|
.sterling-progress,
|
|
160
171
|
.indicator {
|
package/Progress.svelte.d.ts
CHANGED
package/Radio.svelte
CHANGED
|
@@ -1,42 +1,58 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { idGenerator } from "./idGenerator";
|
|
1
|
+
<script>import { idGenerator } from "./idGenerator";
|
|
3
2
|
import Label from "./Label.svelte";
|
|
4
3
|
export let checked = false;
|
|
5
4
|
export let disabled = false;
|
|
6
5
|
export let group = void 0;
|
|
7
6
|
export let id = void 0;
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
if (checked && $$restProps.value !== group) {
|
|
8
|
+
group = $$restProps.value;
|
|
9
|
+
} else if (!checked && $$restProps.value === group) {
|
|
10
|
+
checked = true;
|
|
11
|
+
}
|
|
12
|
+
let inputRef;
|
|
13
|
+
let previousChecked = checked;
|
|
14
|
+
let previousGroup = group;
|
|
15
|
+
const reconcile = () => {
|
|
16
|
+
if (checked !== previousChecked) {
|
|
17
|
+
if (checked && $$restProps.value) {
|
|
18
|
+
group = $$restProps.value;
|
|
19
|
+
previousGroup = $$restProps.value;
|
|
20
|
+
}
|
|
21
|
+
previousChecked = checked;
|
|
22
|
+
} else if (group !== previousGroup) {
|
|
23
|
+
if ($$restProps.value) {
|
|
24
|
+
checked = $$restProps.value === group;
|
|
25
|
+
previousChecked = checked;
|
|
26
|
+
}
|
|
27
|
+
previousGroup = group;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
$:
|
|
31
|
+
checked, group, $$restProps.value, reconcile();
|
|
10
32
|
$: {
|
|
11
|
-
if (
|
|
12
|
-
|
|
33
|
+
if (inputRef && checked && !inputRef.checked) {
|
|
34
|
+
inputRef.click();
|
|
13
35
|
}
|
|
14
36
|
}
|
|
15
37
|
$: {
|
|
16
|
-
if (
|
|
17
|
-
|
|
38
|
+
if ($$slots.default && id === void 0) {
|
|
39
|
+
id = idGenerator.nextId("Radio");
|
|
18
40
|
}
|
|
19
41
|
}
|
|
20
|
-
const onChange = (e) => {
|
|
21
|
-
if (e.currentTarget.checked) {
|
|
22
|
-
group = $$restProps.value;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
42
|
export const blur = () => {
|
|
26
|
-
|
|
43
|
+
inputRef?.blur();
|
|
27
44
|
};
|
|
28
45
|
export const click = () => {
|
|
29
|
-
|
|
46
|
+
inputRef?.click();
|
|
30
47
|
};
|
|
31
48
|
export const focus = (options) => {
|
|
32
|
-
|
|
49
|
+
inputRef?.focus(options);
|
|
33
50
|
};
|
|
34
|
-
|
|
35
|
-
if (checked) {
|
|
51
|
+
const onChange = (e) => {
|
|
52
|
+
if (e.currentTarget.checked) {
|
|
36
53
|
group = $$restProps.value;
|
|
37
54
|
}
|
|
38
|
-
|
|
39
|
-
});
|
|
55
|
+
};
|
|
40
56
|
</script>
|
|
41
57
|
|
|
42
58
|
<!--
|
|
@@ -46,9 +62,10 @@ onMount(() => {
|
|
|
46
62
|
<div class="sterling-radio" class:disabled>
|
|
47
63
|
<div class="container">
|
|
48
64
|
<input
|
|
49
|
-
bind:this={
|
|
50
|
-
checked
|
|
65
|
+
bind:this={inputRef}
|
|
66
|
+
{checked}
|
|
51
67
|
{disabled}
|
|
68
|
+
{group}
|
|
52
69
|
{id}
|
|
53
70
|
type="radio"
|
|
54
71
|
on:blur
|
package/Select.svelte
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { createEventDispatcher, onMount, tick } from "svelte";
|
|
1
|
+
<script>import { createEventDispatcher, tick } from "svelte";
|
|
3
2
|
import { clickOutside } from "./actions/clickOutside";
|
|
4
3
|
import { idGenerator } from "./idGenerator";
|
|
5
4
|
import List from "./List.svelte";
|
|
5
|
+
import Popup from "./Popover.svelte";
|
|
6
6
|
const popupId = idGenerator.nextId("Select-popup");
|
|
7
7
|
export let composed = false;
|
|
8
8
|
export let disabled = false;
|
|
@@ -11,12 +11,7 @@ export let selectedValue = void 0;
|
|
|
11
11
|
let prevOpen = false;
|
|
12
12
|
let pendingSelectedValue = selectedValue;
|
|
13
13
|
let selectRef;
|
|
14
|
-
let popupRef;
|
|
15
14
|
let listRef;
|
|
16
|
-
let popupPosition = {
|
|
17
|
-
x: void 0,
|
|
18
|
-
y: void 0
|
|
19
|
-
};
|
|
20
15
|
const dispatch = createEventDispatcher();
|
|
21
16
|
const raiseSelect = (value) => {
|
|
22
17
|
dispatch("select", { value });
|
|
@@ -39,8 +34,10 @@ $: {
|
|
|
39
34
|
if (open && !prevOpen) {
|
|
40
35
|
prevOpen = true;
|
|
41
36
|
tick().then(() => {
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
listRef?.focus();
|
|
39
|
+
listRef?.scrollToSelectedItem();
|
|
40
|
+
}, 10);
|
|
44
41
|
});
|
|
45
42
|
} else if (prevOpen) {
|
|
46
43
|
prevOpen = false;
|
|
@@ -61,20 +58,6 @@ export const scrollToSelectedItem = () => {
|
|
|
61
58
|
listRef?.scrollToSelectedItem();
|
|
62
59
|
}
|
|
63
60
|
};
|
|
64
|
-
let mounted = false;
|
|
65
|
-
onMount(() => {
|
|
66
|
-
mounted = true;
|
|
67
|
-
const cleanup = autoUpdate(selectRef, popupRef, async () => {
|
|
68
|
-
const { x, y } = await computePosition(selectRef, popupRef, {
|
|
69
|
-
placement: "bottom-end",
|
|
70
|
-
middleware: [offset({ mainAxis: 2 }), flip(), shift({ padding: 0 })]
|
|
71
|
-
});
|
|
72
|
-
if (open) {
|
|
73
|
-
popupPosition = { x, y };
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
return cleanup;
|
|
77
|
-
});
|
|
78
61
|
const onSelectClick = (event) => {
|
|
79
62
|
if (!disabled) {
|
|
80
63
|
open = !open;
|
|
@@ -216,27 +199,20 @@ const onListSelect = (event) => {
|
|
|
216
199
|
<div class="chevron" />
|
|
217
200
|
</slot>
|
|
218
201
|
</div>
|
|
219
|
-
<
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
on:select={onListSelect}
|
|
234
|
-
tabIndex={open ? 0 : -1}
|
|
235
|
-
>
|
|
236
|
-
<slot />
|
|
237
|
-
</List>
|
|
238
|
-
</div>
|
|
239
|
-
</div>
|
|
202
|
+
<Popup reference={selectRef} bind:open id={popupId}>
|
|
203
|
+
<List
|
|
204
|
+
bind:this={listRef}
|
|
205
|
+
composed
|
|
206
|
+
{disabled}
|
|
207
|
+
selectedValue={pendingSelectedValue}
|
|
208
|
+
on:click={onListClick}
|
|
209
|
+
on:keydown={onListKeydown}
|
|
210
|
+
on:select={onListSelect}
|
|
211
|
+
tabIndex={open ? 0 : -1}
|
|
212
|
+
>
|
|
213
|
+
<slot />
|
|
214
|
+
</List>
|
|
215
|
+
</Popup>
|
|
240
216
|
</div>
|
|
241
217
|
|
|
242
218
|
<style>
|
|
@@ -350,25 +326,6 @@ const onListSelect = (event) => {
|
|
|
350
326
|
transform-origin: 50% 50%;
|
|
351
327
|
}
|
|
352
328
|
|
|
353
|
-
.popup {
|
|
354
|
-
background-color: var(--stsv-Common__background-color);
|
|
355
|
-
box-sizing: border-box;
|
|
356
|
-
display: none;
|
|
357
|
-
overflow: visible;
|
|
358
|
-
outline: none;
|
|
359
|
-
position: absolute;
|
|
360
|
-
box-shadow: rgba(0, 0, 0, 0.4) 2px 2px 4px -1px;
|
|
361
|
-
width: fit-content;
|
|
362
|
-
height: fit-content;
|
|
363
|
-
z-index: 1;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
.popup.open {
|
|
367
|
-
display: grid;
|
|
368
|
-
grid-template-columns: 1fr;
|
|
369
|
-
grid-template-rows: 1fr;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
329
|
.popup-content {
|
|
373
330
|
max-height: 15em;
|
|
374
331
|
}
|
package/Switch.svelte
CHANGED
|
@@ -117,17 +117,21 @@ export const focus = (options) => {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
.sterling-switch:not(.vertical) {
|
|
120
|
+
align-content: center;
|
|
120
121
|
align-items: center;
|
|
121
122
|
column-gap: 0.5em;
|
|
122
|
-
grid-template-columns: auto
|
|
123
|
+
grid-template-columns: auto auto auto;
|
|
123
124
|
grid-template-rows: auto;
|
|
124
|
-
justify-
|
|
125
|
+
justify-content: flex-start;
|
|
126
|
+
justify-items: flex-start;
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
.sterling-switch.vertical {
|
|
128
|
-
align-
|
|
130
|
+
align-content: flex-start;
|
|
131
|
+
align-items: flex-start;
|
|
129
132
|
grid-template-columns: auto;
|
|
130
133
|
grid-template-rows: auto auto auto;
|
|
134
|
+
justify-content: center;
|
|
131
135
|
justify-items: center;
|
|
132
136
|
row-gap: 0.5em;
|
|
133
137
|
}
|
package/TextArea.svelte
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export let autoHeight = false;
|
|
3
3
|
export let disabled = false;
|
|
4
4
|
export let resize = "none";
|
|
5
|
-
export let value;
|
|
5
|
+
export let value = "";
|
|
6
6
|
let textAreaRef;
|
|
7
7
|
const autoSetHeight = () => {
|
|
8
8
|
if (autoHeight && textAreaRef) {
|
|
@@ -42,7 +42,7 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
|
42
42
|
};
|
|
43
43
|
</script>
|
|
44
44
|
|
|
45
|
-
<div class="sterling-text-
|
|
45
|
+
<div class="sterling-text-area" class:disabled>
|
|
46
46
|
<textarea
|
|
47
47
|
bind:this={textAreaRef}
|
|
48
48
|
bind:value
|
|
@@ -88,8 +88,10 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
|
88
88
|
</div>
|
|
89
89
|
|
|
90
90
|
<style>
|
|
91
|
-
.sterling-text-
|
|
91
|
+
.sterling-text-area {
|
|
92
92
|
position: relative;
|
|
93
|
+
height: 100%;
|
|
94
|
+
width: 100%;
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
textarea {
|
|
@@ -130,12 +132,12 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
|
130
132
|
outline-width: var(--stsv-Common__outline-width);
|
|
131
133
|
}
|
|
132
134
|
|
|
133
|
-
.sterling-text-
|
|
135
|
+
.sterling-text-area:disabled {
|
|
134
136
|
cursor: not-allowed;
|
|
135
137
|
outline: none;
|
|
136
138
|
}
|
|
137
139
|
|
|
138
|
-
.sterling-text-
|
|
140
|
+
.sterling-text-area::after {
|
|
139
141
|
background: var(--stsv-Disabled__background);
|
|
140
142
|
bottom: 0;
|
|
141
143
|
content: '';
|
|
@@ -148,7 +150,7 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
|
148
150
|
transition: opacity 250ms;
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
.sterling-text-
|
|
153
|
+
.sterling-text-area.disabled::after {
|
|
152
154
|
opacity: 1;
|
|
153
155
|
}
|
|
154
156
|
|
|
@@ -159,8 +161,8 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
|
159
161
|
|
|
160
162
|
@media (prefers-reduced-motion) {
|
|
161
163
|
textarea,
|
|
162
|
-
.sterling-text-
|
|
163
|
-
.sterling-text-
|
|
164
|
+
.sterling-text-area,
|
|
165
|
+
.sterling-text-area::after {
|
|
164
166
|
transition: none;
|
|
165
167
|
}
|
|
166
168
|
}
|
package/TextArea.svelte.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare const __propDef: {
|
|
|
5
5
|
autoHeight?: boolean | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
resize?: "none" | "horizontal" | "vertical" | "both" | undefined;
|
|
8
|
-
value
|
|
8
|
+
value?: string | undefined;
|
|
9
9
|
blur?: (() => void) | undefined;
|
|
10
10
|
click?: (() => void) | undefined;
|
|
11
11
|
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
type Params = {
|
|
2
|
+
/** Other elements should not raise the event if clicked. */
|
|
3
|
+
ignoreOthers?: HTMLElement[];
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Raises the click_outside event when the user clicks outside the node.
|
|
7
|
+
* @param node The node to check and receive the event.
|
|
8
|
+
* @param params Additional parameters
|
|
9
|
+
*/
|
|
10
|
+
export declare const clickOutside: (node: HTMLElement, params?: Params) => {
|
|
11
|
+
update(params: Params): void;
|
|
2
12
|
destroy(): void;
|
|
3
13
|
};
|
|
14
|
+
export {};
|
package/actions/clickOutside.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Raises the click_outside event when the user clicks outside the node.
|
|
3
|
+
* @param node The node to check and receive the event.
|
|
4
|
+
* @param params Additional parameters
|
|
5
|
+
*/
|
|
6
|
+
export const clickOutside = (node, params) => {
|
|
7
|
+
let ignoreOthers = params?.ignoreOthers;
|
|
2
8
|
const handleClick = (event) => {
|
|
3
9
|
const targetNode = event?.target;
|
|
4
|
-
if (targetNode &&
|
|
10
|
+
if (targetNode &&
|
|
11
|
+
!node.contains(targetNode) &&
|
|
12
|
+
(!ignoreOthers || ignoreOthers.every((x) => !x.contains(targetNode)))) {
|
|
5
13
|
node.dispatchEvent(new CustomEvent('click_outside', {
|
|
6
14
|
detail: { mouseEvent: event }
|
|
7
15
|
}));
|
|
@@ -9,6 +17,9 @@ export const clickOutside = (node) => {
|
|
|
9
17
|
};
|
|
10
18
|
document.addEventListener('click', handleClick, true);
|
|
11
19
|
return {
|
|
20
|
+
update(params) {
|
|
21
|
+
ignoreOthers = params.ignoreOthers;
|
|
22
|
+
},
|
|
12
23
|
destroy() {
|
|
13
24
|
document.removeEventListener('click', handleClick, true);
|
|
14
25
|
}
|
package/index.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ import MenuButton from './MenuButton.svelte';
|
|
|
51
51
|
import MenuItem from './MenuItem.svelte';
|
|
52
52
|
import MenuItemDisplay from './MenuItemDisplay.svelte';
|
|
53
53
|
import MenuSeparator from './MenuSeparator.svelte';
|
|
54
|
+
import Popover from './Popover.svelte';
|
|
54
55
|
import Progress from './Progress.svelte';
|
|
55
56
|
import Radio from './Radio.svelte';
|
|
56
57
|
import Select from './Select.svelte';
|
|
@@ -64,4 +65,4 @@ import Tree from './Tree.svelte';
|
|
|
64
65
|
import TreeChevron from './TreeChevron.svelte';
|
|
65
66
|
import TreeItem from './TreeItem.svelte';
|
|
66
67
|
import TreeItemDisplay from './TreeItemDisplay.svelte';
|
|
67
|
-
export { Button, Checkbox, Dialog, Dropdown, Field, Input, Label, Link, List, ListItem, Menu, MenuBar, MenuButton, MenuItem, MenuItemDisplay, MenuSeparator, Progress, Radio, Select, Slider, Switch, Tab, TabList, TextArea, Tooltip, Tree, TreeChevron, TreeItem, TreeItemDisplay };
|
|
68
|
+
export { Button, Checkbox, Dialog, Dropdown, Field, Input, Label, Link, List, ListItem, Menu, MenuBar, MenuButton, MenuItem, MenuItemDisplay, MenuSeparator, Popover, Progress, Radio, Select, Slider, Switch, Tab, TabList, TextArea, Tooltip, Tree, TreeChevron, TreeItem, TreeItemDisplay };
|
package/index.js
CHANGED
|
@@ -43,6 +43,7 @@ import MenuButton from './MenuButton.svelte';
|
|
|
43
43
|
import MenuItem from './MenuItem.svelte';
|
|
44
44
|
import MenuItemDisplay from './MenuItemDisplay.svelte';
|
|
45
45
|
import MenuSeparator from './MenuSeparator.svelte';
|
|
46
|
+
import Popover from './Popover.svelte';
|
|
46
47
|
import Progress from './Progress.svelte';
|
|
47
48
|
import Radio from './Radio.svelte';
|
|
48
49
|
import Select from './Select.svelte';
|
|
@@ -56,4 +57,4 @@ import Tree from './Tree.svelte';
|
|
|
56
57
|
import TreeChevron from './TreeChevron.svelte';
|
|
57
58
|
import TreeItem from './TreeItem.svelte';
|
|
58
59
|
import TreeItemDisplay from './TreeItemDisplay.svelte';
|
|
59
|
-
export { Button, Checkbox, Dialog, Dropdown, Field, Input, Label, Link, List, ListItem, Menu, MenuBar, MenuButton, MenuItem, MenuItemDisplay, MenuSeparator, Progress, Radio, Select, Slider, Switch, Tab, TabList, TextArea, Tooltip, Tree, TreeChevron, TreeItem, TreeItemDisplay };
|
|
60
|
+
export { Button, Checkbox, Dialog, Dropdown, Field, Input, Label, Link, List, ListItem, Menu, MenuBar, MenuButton, MenuItem, MenuItemDisplay, MenuSeparator, Popover, Progress, Radio, Select, Slider, Switch, Tab, TabList, TextArea, Tooltip, Tree, TreeChevron, TreeItem, TreeItemDisplay };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geoffcox/sterling-svelte",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"author": "Geoff Cox",
|
|
5
5
|
"description": "A modern, accessible, and lightweight component library for Svelte.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
"./MenuItem.utils": "./MenuItem.utils.js",
|
|
79
79
|
"./MenuItemDisplay.svelte": "./MenuItemDisplay.svelte",
|
|
80
80
|
"./MenuSeparator.svelte": "./MenuSeparator.svelte",
|
|
81
|
+
"./Popover.svelte": "./Popover.svelte",
|
|
81
82
|
"./Progress.constants": "./Progress.constants.js",
|
|
82
83
|
"./Progress.svelte": "./Progress.svelte",
|
|
83
84
|
"./Progress.types": "./Progress.types.js",
|