@geoffcox/sterling-svelte 1.0.1 → 1.0.3
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/Callout.svelte +8 -6
- package/Dropdown.svelte +8 -4
- package/Dropdown.svelte.d.ts +5 -0
- package/Input.svelte +1 -1
- package/MenuButton.svelte +4 -2
- package/MenuButton.svelte.d.ts +2 -3
- package/MenuItem.svelte +3 -1
- package/MenuItem.svelte.d.ts +1 -0
- package/Popover.svelte +8 -7
- package/Select.svelte +7 -3
- package/Select.svelte.d.ts +8 -0
- package/css/Input.base.css +2 -2
- package/package.json +1 -1
package/Callout.svelte
CHANGED
|
@@ -26,6 +26,8 @@ let popupRef;
|
|
|
26
26
|
let arrowRef;
|
|
27
27
|
let popupPosition = { x: 0, y: 0 };
|
|
28
28
|
$: floatingUIPlacement = placement;
|
|
29
|
+
let bodyHeight = 0;
|
|
30
|
+
let resizeObserver = undefined;
|
|
29
31
|
// ----- Portal Host ----- //
|
|
30
32
|
const ensurePortalHost = () => {
|
|
31
33
|
if (document) {
|
|
@@ -43,11 +45,6 @@ const ensurePortalHost = () => {
|
|
|
43
45
|
}
|
|
44
46
|
};
|
|
45
47
|
// ----- Body Height Change ----- //
|
|
46
|
-
let bodyHeight = 0;
|
|
47
|
-
// create an Observer instance
|
|
48
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
|
49
|
-
bodyHeight = entries[0].target.clientHeight;
|
|
50
|
-
});
|
|
51
48
|
// ----- Position ----- //
|
|
52
49
|
$: middleware = [
|
|
53
50
|
offset({ mainAxis: mainAxisOffset, crossAxis: crossAxisOffset }),
|
|
@@ -124,10 +121,15 @@ $: fadeMotion = !$prefersReducedMotion ? fade : fadeNoOp;
|
|
|
124
121
|
// ----- EventHandlers ----- //
|
|
125
122
|
onMount(() => {
|
|
126
123
|
ensurePortalHost();
|
|
124
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
125
|
+
bodyHeight = entries[0].target.clientHeight;
|
|
126
|
+
});
|
|
127
127
|
// start observing a DOM node
|
|
128
128
|
resizeObserver.observe(document.body);
|
|
129
129
|
return () => {
|
|
130
|
-
resizeObserver
|
|
130
|
+
resizeObserver?.unobserve(document.body);
|
|
131
|
+
resizeObserver?.disconnect();
|
|
132
|
+
resizeObserver = undefined;
|
|
131
133
|
};
|
|
132
134
|
});
|
|
133
135
|
const onKeydown = (event) => {
|
package/Dropdown.svelte
CHANGED
|
@@ -113,12 +113,16 @@ $: slideMotion = !$prefersReducedMotion ? slide : slideNoOp;
|
|
|
113
113
|
on:click_outside={onClickOutside}
|
|
114
114
|
{...$$restProps}
|
|
115
115
|
>
|
|
116
|
-
|
|
117
|
-
<
|
|
118
|
-
|
|
116
|
+
{#if $$slots.value}
|
|
117
|
+
<div class="value">
|
|
118
|
+
<slot name="value" {disabled} {open} {variant} />
|
|
119
|
+
</div>
|
|
120
|
+
{/if}
|
|
119
121
|
<slot name="button" {disabled} {open} {variant}>
|
|
120
122
|
<div class="button">
|
|
121
|
-
<
|
|
123
|
+
<slot name="icon" {disabled} {open} {variant}>
|
|
124
|
+
<div class="chevron" />
|
|
125
|
+
</slot>
|
|
122
126
|
</div>
|
|
123
127
|
</slot>
|
|
124
128
|
|
package/Dropdown.svelte.d.ts
CHANGED
package/Input.svelte
CHANGED
|
@@ -40,7 +40,7 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
|
40
40
|
</script>
|
|
41
41
|
|
|
42
42
|
{#if $$slots.default}
|
|
43
|
-
<label class={`sterling-input-label ${variant}`} for={id}>
|
|
43
|
+
<label class={`sterling-input-label ${variant}`} class:disabled for={id}>
|
|
44
44
|
<slot {disabled} {value} {variant} />
|
|
45
45
|
</label>
|
|
46
46
|
{/if}
|
package/MenuButton.svelte
CHANGED
|
@@ -13,6 +13,8 @@ export let open = false;
|
|
|
13
13
|
export let value;
|
|
14
14
|
/** Additional class names to apply. */
|
|
15
15
|
export let variant = '';
|
|
16
|
+
/** Additional class names to apply to the Menu*/
|
|
17
|
+
export let menuVariant = '';
|
|
16
18
|
// ----- State ----- //
|
|
17
19
|
const instanceId = idGenerator.nextId('MenuButton');
|
|
18
20
|
let buttonRef;
|
|
@@ -144,8 +146,8 @@ setContext(MENU_ITEM_CONTEXT_KEY, {
|
|
|
144
146
|
<slot {open} {value} {variant} />
|
|
145
147
|
</div>
|
|
146
148
|
<Popover {reference} {open}>
|
|
147
|
-
<Menu bind:this={menuRef} id={menuId} {reference} {open}>
|
|
148
|
-
<slot name="items"
|
|
149
|
+
<Menu bind:this={menuRef} id={menuId} {reference} {open} variant={menuVariant}>
|
|
150
|
+
<slot name="items" />
|
|
149
151
|
</Menu>
|
|
150
152
|
</Popover>
|
|
151
153
|
</Button>
|
package/MenuButton.svelte.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare const __propDef: {
|
|
|
5
5
|
open?: boolean | undefined;
|
|
6
6
|
value: string;
|
|
7
7
|
variant?: string | undefined;
|
|
8
|
+
menuVariant?: string | undefined;
|
|
8
9
|
click?: (() => void) | undefined;
|
|
9
10
|
blur?: (() => void) | undefined;
|
|
10
11
|
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
@@ -53,9 +54,7 @@ declare const __propDef: {
|
|
|
53
54
|
value: string;
|
|
54
55
|
variant: string;
|
|
55
56
|
};
|
|
56
|
-
items: {
|
|
57
|
-
variant: string;
|
|
58
|
-
};
|
|
57
|
+
items: {};
|
|
59
58
|
};
|
|
60
59
|
};
|
|
61
60
|
export type MenuButtonProps = typeof __propDef.props;
|
package/MenuItem.svelte
CHANGED
|
@@ -24,6 +24,8 @@ export let text = undefined;
|
|
|
24
24
|
export let value;
|
|
25
25
|
/** Additional class names to apply. */
|
|
26
26
|
export let variant = '';
|
|
27
|
+
/** Additional class names to apply to the sub Menu*/
|
|
28
|
+
export let menuVariant = '';
|
|
27
29
|
// ----- Get Context ----- //
|
|
28
30
|
const { isMenuBarItem, openValues = writable([]), rootValue = value, depth = 0, closeContainingMenu = undefined, onOpen = undefined, onClose = undefined, onSelect = undefined } = getContext(MENU_ITEM_CONTEXT_KEY) || {};
|
|
29
31
|
const { openPreviousMenuBarItem = undefined, openNextMenuBarItem = undefined } = getContext(MENU_BAR_CONTEXT_KEY) || {};
|
|
@@ -376,7 +378,7 @@ setContext(MENU_ITEM_CONTEXT_KEY, {
|
|
|
376
378
|
placement={isMenuBarItem ? 'bottom-start' : 'right-start'}
|
|
377
379
|
{open}
|
|
378
380
|
>
|
|
379
|
-
<Menu bind:this={menuRef} id={menuId}>
|
|
381
|
+
<Menu bind:this={menuRef} id={menuId} variant={menuVariant}>
|
|
380
382
|
<slot {depth} {disabled} />
|
|
381
383
|
</Menu>
|
|
382
384
|
</Popover>
|
package/MenuItem.svelte.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare const __propDef: {
|
|
|
8
8
|
text?: string | undefined;
|
|
9
9
|
value: string;
|
|
10
10
|
variant?: string | undefined;
|
|
11
|
+
menuVariant?: string | undefined;
|
|
11
12
|
blur?: (() => void) | undefined;
|
|
12
13
|
click?: (() => void) | undefined;
|
|
13
14
|
focus?: ((options?: FocusOptions) => void) | undefined;
|
package/Popover.svelte
CHANGED
|
@@ -23,6 +23,8 @@ export let variant = '';
|
|
|
23
23
|
let popupRef;
|
|
24
24
|
let popupPosition = { x: 0, y: 0 };
|
|
25
25
|
$: floatingUIPlacement = placement;
|
|
26
|
+
let bodyHeight = 0;
|
|
27
|
+
let resizeObserver = undefined;
|
|
26
28
|
// ----- Portal Host ----- //
|
|
27
29
|
const ensurePortalHost = () => {
|
|
28
30
|
if (document) {
|
|
@@ -39,12 +41,6 @@ const ensurePortalHost = () => {
|
|
|
39
41
|
portalHost = host;
|
|
40
42
|
}
|
|
41
43
|
};
|
|
42
|
-
// ----- Body Height Change ----- //
|
|
43
|
-
let bodyHeight = 0;
|
|
44
|
-
// create an Observer instance
|
|
45
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
|
46
|
-
bodyHeight = entries[0].target.clientHeight;
|
|
47
|
-
});
|
|
48
44
|
// ----- Position ----- //
|
|
49
45
|
$: middleware = [offset({ mainAxis: mainAxisOffset, crossAxis: crossAxisOffset }), flip()];
|
|
50
46
|
const computePopoverPosition = async () => {
|
|
@@ -71,10 +67,15 @@ $: open, bodyHeight, middleware, floatingUIPlacement, computePopoverPosition();
|
|
|
71
67
|
// ----- EventHandlers ----- //
|
|
72
68
|
onMount(() => {
|
|
73
69
|
ensurePortalHost();
|
|
70
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
71
|
+
bodyHeight = entries[0].target.clientHeight;
|
|
72
|
+
});
|
|
74
73
|
// start observing a DOM node
|
|
75
74
|
resizeObserver.observe(document.body);
|
|
76
75
|
return () => {
|
|
77
|
-
resizeObserver
|
|
76
|
+
resizeObserver?.unobserve(document.body);
|
|
77
|
+
resizeObserver?.disconnect();
|
|
78
|
+
resizeObserver = undefined;
|
|
78
79
|
};
|
|
79
80
|
});
|
|
80
81
|
const onKeydown = (event) => {
|
package/Select.svelte
CHANGED
|
@@ -12,6 +12,8 @@ export let open = false;
|
|
|
12
12
|
export let selectedValue = undefined;
|
|
13
13
|
/** Additional class names to apply. */
|
|
14
14
|
export let variant = '';
|
|
15
|
+
/** Additional class names to apply to the List*/
|
|
16
|
+
export let listVariant = '';
|
|
15
17
|
// ----- State ----- //
|
|
16
18
|
// Tracks the previous open state
|
|
17
19
|
let prevOpen = false;
|
|
@@ -209,7 +211,9 @@ const onListSelect = (event) => {
|
|
|
209
211
|
</div>
|
|
210
212
|
<div class="button">
|
|
211
213
|
<slot name="button" {disabled} {open} {selectedValue} {variant}>
|
|
212
|
-
<
|
|
214
|
+
<slot name="icon" {disabled} {open} {selectedValue} {variant}>
|
|
215
|
+
<div class="chevron" />
|
|
216
|
+
</slot>
|
|
213
217
|
</slot>
|
|
214
218
|
</div>
|
|
215
219
|
<Popover reference={selectRef} bind:open id={popupId} conditionalRender={false}>
|
|
@@ -222,9 +226,9 @@ const onListSelect = (event) => {
|
|
|
222
226
|
on:keydown={onListKeydown}
|
|
223
227
|
on:select={onListSelect}
|
|
224
228
|
tabIndex={open ? 0 : -1}
|
|
225
|
-
variant={`composed ${
|
|
229
|
+
variant={`composed ${listVariant}`}
|
|
226
230
|
>
|
|
227
|
-
<slot {variant} />
|
|
231
|
+
<slot {variant} {listVariant} />
|
|
228
232
|
</List>
|
|
229
233
|
</div>
|
|
230
234
|
</Popover>
|
package/Select.svelte.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare const __propDef: {
|
|
|
6
6
|
open?: boolean | undefined;
|
|
7
7
|
selectedValue?: string | undefined;
|
|
8
8
|
variant?: string | undefined;
|
|
9
|
+
listVariant?: string | undefined;
|
|
9
10
|
blur?: (() => void) | undefined;
|
|
10
11
|
click?: (() => void) | undefined;
|
|
11
12
|
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
@@ -56,8 +57,15 @@ declare const __propDef: {
|
|
|
56
57
|
selectedValue: string | undefined;
|
|
57
58
|
variant: string;
|
|
58
59
|
};
|
|
60
|
+
icon: {
|
|
61
|
+
disabled: boolean;
|
|
62
|
+
open: boolean;
|
|
63
|
+
selectedValue: string | undefined;
|
|
64
|
+
variant: string;
|
|
65
|
+
};
|
|
59
66
|
default: {
|
|
60
67
|
variant: string;
|
|
68
|
+
listVariant: string;
|
|
61
69
|
};
|
|
62
70
|
};
|
|
63
71
|
};
|
package/css/Input.base.css
CHANGED
|
@@ -84,7 +84,7 @@ input::placeholder {
|
|
|
84
84
|
|
|
85
85
|
/* ----- label ----- */
|
|
86
86
|
|
|
87
|
-
label {
|
|
87
|
+
.sterling-input-label {
|
|
88
88
|
color: var(--stsv-common__color);
|
|
89
89
|
transition: color 250ms;
|
|
90
90
|
font: inherit;
|
|
@@ -94,7 +94,7 @@ label {
|
|
|
94
94
|
|
|
95
95
|
@media (prefers-reduced-motion) {
|
|
96
96
|
.sterling-input::after,
|
|
97
|
-
input {
|
|
97
|
+
.sterling-input-label {
|
|
98
98
|
transition: none;
|
|
99
99
|
}
|
|
100
100
|
}
|