@txstate-mws/svelte-components 1.0.0 → 1.0.4
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/README.md +33 -14
- package/{dist/ts/actions → actions}/buttonify.d.ts +0 -0
- package/{dist/actions → actions}/buttonify.js +1 -6
- package/{dist/ts/actions → actions}/glue.d.ts +1 -1
- package/{dist/actions → actions}/glue.js +8 -13
- package/actions/index.d.ts +7 -0
- package/actions/index.js +7 -0
- package/actions/offset.d.ts +15 -0
- package/actions/offset.js +35 -0
- package/{dist/ts/actions → actions}/portal.d.ts +0 -0
- package/actions/portal.js +13 -0
- package/{dist/ts/actions → actions}/resize.d.ts +6 -2
- package/actions/resize.js +45 -0
- package/{dist/ts/actions → actions}/sticky.d.ts +2 -2
- package/{dist/actions → actions}/sticky.js +10 -18
- package/{dist/ts/actions → actions}/stickyfixed.d.ts +2 -2
- package/{dist/actions → actions}/stickyfixed.js +14 -23
- package/{dist/components → components}/CollapsingTable.svelte +12 -13
- package/components/CollapsingTable.svelte.d.ts +59 -0
- package/{dist/ts/components → components}/ConditionalWrapper.svelte +6 -7
- package/components/ConditionalWrapper.svelte.d.ts +23 -0
- package/{dist/components → components}/FocusLock.svelte +15 -11
- package/components/FocusLock.svelte.d.ts +26 -0
- package/{dist/components → components}/Modal.svelte +5 -4
- package/components/Modal.svelte.d.ts +27 -0
- package/{dist/components → components}/PopupMenu.svelte +13 -16
- package/components/PopupMenu.svelte.d.ts +44 -0
- package/{dist/components → components}/ScreenReaderOnly.svelte +1 -1
- package/components/ScreenReaderOnly.svelte.d.ts +20 -0
- package/{dist/ts/components → components}/index.d.ts +0 -0
- package/components/index.js +6 -0
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/package.json +47 -75
- package/{dist/ts/types → types}/CollapsingTable.d.ts +0 -0
- package/{dist/ts/tests/Actions/Actions.stories.d.ts → types/CollapsingTable.js} +0 -0
- package/{dist/ts/types → types}/PopupMenu.d.ts +0 -0
- package/{dist/ts/tests/CollapsingTable/CollapsingTable.stories.d.ts → types/PopupMenu.js} +0 -0
- package/types/index.d.ts +2 -0
- package/types/index.js +2 -0
- package/{dist/ts/lib → util}/bodyoffset.d.ts +2 -1
- package/{dist/lib → util}/bodyoffset.js +10 -14
- package/util/index.d.ts +3 -0
- package/util/index.js +3 -0
- package/{dist/ts/lib → util}/repositioned.d.ts +1 -2
- package/{dist/lib → util}/repositioned.js +13 -24
- package/{dist/ts/lib → util}/util.d.ts +0 -0
- package/util/util.js +10 -0
- package/LICENSE +0 -21
- package/dist/actions/buttonify.js.map +0 -1
- package/dist/actions/glue.js.map +0 -1
- package/dist/actions/index.js +0 -20
- package/dist/actions/index.js.map +0 -1
- package/dist/actions/offset.js +0 -35
- package/dist/actions/offset.js.map +0 -1
- package/dist/actions/portal.js +0 -19
- package/dist/actions/portal.js.map +0 -1
- package/dist/actions/resize.js +0 -48
- package/dist/actions/resize.js.map +0 -1
- package/dist/actions/sticky.js.map +0 -1
- package/dist/actions/stickyfixed.js.map +0 -1
- package/dist/components/ConditionalWrapper.svelte +0 -38
- package/dist/components/index.js +0 -19
- package/dist/components/index.js.map +0 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +0 -1
- package/dist/lib/activestore.js +0 -123
- package/dist/lib/activestore.js.map +0 -1
- package/dist/lib/bodyoffset.js.map +0 -1
- package/dist/lib/convertedstore.js +0 -41
- package/dist/lib/convertedstore.js.map +0 -1
- package/dist/lib/derivedstore.js +0 -65
- package/dist/lib/derivedstore.js.map +0 -1
- package/dist/lib/index.js +0 -22
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/repositioned.js.map +0 -1
- package/dist/lib/safestore.js +0 -16
- package/dist/lib/safestore.js.map +0 -1
- package/dist/lib/store.js +0 -27
- package/dist/lib/store.js.map +0 -1
- package/dist/lib/substore.js +0 -47
- package/dist/lib/substore.js.map +0 -1
- package/dist/lib/util.js +0 -16
- package/dist/lib/util.js.map +0 -1
- package/dist/ts/actions/index.d.ts +0 -7
- package/dist/ts/actions/offset.d.ts +0 -15
- package/dist/ts/components/CollapsingTable.svelte +0 -147
- package/dist/ts/components/FocusLock.svelte +0 -99
- package/dist/ts/components/Modal.svelte +0 -54
- package/dist/ts/components/PopupMenu.svelte +0 -279
- package/dist/ts/components/ScreenReaderOnly.svelte +0 -26
- package/dist/ts/index.d.ts +0 -4
- package/dist/ts/lib/activestore.d.ts +0 -60
- package/dist/ts/lib/convertedstore.d.ts +0 -16
- package/dist/ts/lib/derivedstore.d.ts +0 -23
- package/dist/ts/lib/index.d.ts +0 -9
- package/dist/ts/lib/safestore.d.ts +0 -4
- package/dist/ts/lib/store.d.ts +0 -16
- package/dist/ts/lib/substore.d.ts +0 -24
- package/dist/ts/tests/Actions/Offset.svelte +0 -34
- package/dist/ts/tests/Actions/Resize.svelte +0 -31
- package/dist/ts/tests/Actions/Sticky.svelte +0 -65
- package/dist/ts/tests/CollapsingTable/CollapsingTable.test.d.ts +0 -1
- package/dist/ts/tests/CollapsingTable/CollapsingTableTest.svelte +0 -36
- package/dist/ts/tests/Modal/Modal.stories.d.ts +0 -1
- package/dist/ts/tests/Modal/Modal.test.d.ts +0 -1
- package/dist/ts/tests/Modal/ModalTest.svelte +0 -58
- package/dist/ts/tests/PopupMenu/PopupMenu.stories.d.ts +0 -1
- package/dist/ts/tests/PopupMenu/PopupMenu.test.d.ts +0 -1
- package/dist/ts/tests/PopupMenu/PopupMenuBody.svelte +0 -34
- package/dist/ts/tests/PopupMenu/PopupMenuButtonIsParent.svelte +0 -36
- package/dist/ts/tests/PopupMenu/PopupMenuComplex.svelte +0 -34
- package/dist/ts/tests/PopupMenu/PopupMenuSimple.svelte +0 -36
- package/dist/ts/tests/stores/deepstore.test.d.ts +0 -1
- package/dist/ts/types/index.d.ts +0 -2
- package/dist/types/CollapsingTable.js +0 -3
- package/dist/types/CollapsingTable.js.map +0 -1
- package/dist/types/PopupMenu.js +0 -3
- package/dist/types/PopupMenu.js.map +0 -1
- package/dist/types/index.js +0 -15
- package/dist/types/index.js.map +0 -1
- package/docs/CollapsingTable.md +0 -79
- package/docs/ConditionalWrapper.md +0 -35
- package/docs/Modal.md +0 -63
- package/docs/PopupMenu.md +0 -31
- package/docs/ScreenReaderOnly.md +0 -10
- package/docs/actions.md +0 -84
- package/docs/stores.md +0 -203
- package/esm/index.js +0 -1
- package/esm/package.json +0 -3
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
condition: boolean | undefined;
|
|
6
|
+
component?: Function | undefined;
|
|
7
|
+
a?: boolean;
|
|
8
|
+
span?: boolean;
|
|
9
|
+
element?: HTMLElement | undefined;
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {
|
|
15
|
+
default: {};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare type ConditionalWrapperProps = typeof __propDef.props;
|
|
19
|
+
export declare type ConditionalWrapperEvents = typeof __propDef.events;
|
|
20
|
+
export declare type ConditionalWrapperSlots = typeof __propDef.slots;
|
|
21
|
+
export default class ConditionalWrapper extends SvelteComponentTyped<ConditionalWrapperProps, ConditionalWrapperEvents, ConditionalWrapperSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
<script context="module">const FocusLockStack = [];
|
|
1
|
+
<script context="module" >const FocusLockStack = [];
|
|
2
2
|
</script>
|
|
3
3
|
|
|
4
|
-
<script>export let returnfocusto = undefined;
|
|
4
|
+
<script >export let returnfocusto = undefined;
|
|
5
5
|
export let initialfocus = undefined;
|
|
6
6
|
export let hidefocus = true;
|
|
7
|
-
export let hidefocuslabel =
|
|
7
|
+
export let hidefocuslabel = 'focus is above modal dialog, start tabbing';
|
|
8
8
|
export let escapable = true;
|
|
9
9
|
let className = '';
|
|
10
10
|
export { className as class };
|
|
11
11
|
import { onMount, onDestroy, createEventDispatcher, tick } from 'svelte';
|
|
12
12
|
import { tabbable } from 'tabbable';
|
|
13
|
+
import { sleep } from 'txstate-utils';
|
|
13
14
|
import { buttonify } from '../actions';
|
|
14
15
|
import ScreenReaderOnly from './ScreenReaderOnly.svelte';
|
|
15
16
|
const dispatch = createEventDispatcher();
|
|
@@ -19,7 +20,7 @@ let active = true;
|
|
|
19
20
|
let listenforescape = false;
|
|
20
21
|
if (initialfocus)
|
|
21
22
|
hidefocus = false;
|
|
22
|
-
onMount(() => {
|
|
23
|
+
onMount(async () => {
|
|
23
24
|
const prevFocusLock = FocusLockStack.slice(-1)[0];
|
|
24
25
|
if (prevFocusLock)
|
|
25
26
|
prevFocusLock.pause();
|
|
@@ -30,6 +31,9 @@ onMount(() => {
|
|
|
30
31
|
if (typeof returnfocusto === 'undefined') {
|
|
31
32
|
returnfocusto = document.querySelector(':focus');
|
|
32
33
|
}
|
|
34
|
+
await sleep(1); // sapper resets focus on page load, so we'll wait a millisecond in case our modal is on screen at load
|
|
35
|
+
if (!lockelement)
|
|
36
|
+
return; // in case we already unmounted
|
|
33
37
|
if (initialfocus) {
|
|
34
38
|
const focusEl = lockelement.querySelector(initialfocus);
|
|
35
39
|
if (focusEl instanceof HTMLElement)
|
|
@@ -38,7 +42,7 @@ onMount(() => {
|
|
|
38
42
|
else {
|
|
39
43
|
setInitialFocus();
|
|
40
44
|
}
|
|
41
|
-
setTimeout(() => listenforescape = true, 0);
|
|
45
|
+
setTimeout(() => { listenforescape = true; }, 0);
|
|
42
46
|
});
|
|
43
47
|
onDestroy(async () => {
|
|
44
48
|
const wasactive = active;
|
|
@@ -53,32 +57,32 @@ onDestroy(async () => {
|
|
|
53
57
|
prevFocusLock.unpause();
|
|
54
58
|
});
|
|
55
59
|
const setInitialFocus = () => {
|
|
56
|
-
const firstfocus = tabbable(lockelement)[0];
|
|
60
|
+
const firstfocus = lockelement ? tabbable(lockelement)[0] : undefined;
|
|
57
61
|
if (firstfocus && firstfocus.focus) {
|
|
58
62
|
firstfocus.focus();
|
|
59
63
|
}
|
|
60
64
|
};
|
|
61
65
|
const setLastFocus = () => {
|
|
62
|
-
const lastfocus = tabbable(lockelement).slice(-1)[0];
|
|
66
|
+
const lastfocus = lockelement ? tabbable(lockelement).slice(-1)[0] : undefined;
|
|
63
67
|
if (lastfocus && lastfocus.focus) {
|
|
64
68
|
lastfocus.focus();
|
|
65
69
|
}
|
|
66
70
|
};
|
|
67
71
|
const keydown = (e) => {
|
|
68
|
-
if (active && e.key ===
|
|
72
|
+
if (active && e.key === 'Escape' && escapable) {
|
|
69
73
|
e.preventDefault();
|
|
70
74
|
dispatch('escape');
|
|
71
75
|
}
|
|
72
76
|
};
|
|
73
77
|
const focusin = (e) => {
|
|
74
|
-
if (active && e.target instanceof HTMLElement && !
|
|
78
|
+
if (active && e.target instanceof HTMLElement && !lockelement?.contains(e.target)) {
|
|
75
79
|
if (e.target === abovelockelement)
|
|
76
80
|
setLastFocus();
|
|
77
81
|
else
|
|
78
82
|
setInitialFocus();
|
|
79
83
|
}
|
|
80
84
|
};
|
|
81
|
-
const windowclick = (
|
|
85
|
+
const windowclick = (_) => {
|
|
82
86
|
if (listenforescape && active) {
|
|
83
87
|
returnfocusto = undefined;
|
|
84
88
|
dispatch('escape');
|
|
@@ -89,7 +93,7 @@ const windowclick = (e) => {
|
|
|
89
93
|
<div class={className} role="alertdialog" aria-modal="true" on:click|stopPropagation on:keydown|stopPropagation={keydown} on:focusin={focusin}>
|
|
90
94
|
<div bind:this={abovelockelement} tabindex="0"></div>
|
|
91
95
|
<div bind:this={lockelement} on:keydown={keydown}>
|
|
92
|
-
{#if hidefocus}<div class="hiddenfocus" use:buttonify on:blur={() =>{ hidefocus = false }} on:click={() => escapable && dispatch('escape')}><ScreenReaderOnly>{hidefocuslabel}{#if escapable}, click to escape or use escape key at any time{/if}</ScreenReaderOnly></div>{/if}
|
|
96
|
+
{#if hidefocus}<div class="hiddenfocus" use:buttonify on:blur={() => { hidefocus = false }} on:click={() => escapable && dispatch('escape')}><ScreenReaderOnly>{hidefocuslabel}{#if escapable}, click to escape or use escape key at any time{/if}</ScreenReaderOnly></div>{/if}
|
|
93
97
|
<slot></slot>
|
|
94
98
|
</div>
|
|
95
99
|
<div tabindex="0"></div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
returnfocusto?: HTMLElement | null | undefined;
|
|
5
|
+
initialfocus?: string | undefined;
|
|
6
|
+
hidefocus?: boolean;
|
|
7
|
+
hidefocuslabel?: string;
|
|
8
|
+
escapable?: boolean;
|
|
9
|
+
class?: string;
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
click: MouseEvent;
|
|
13
|
+
escape: CustomEvent<any>;
|
|
14
|
+
} & {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
};
|
|
17
|
+
slots: {
|
|
18
|
+
default: {};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare type FocusLockProps = typeof __propDef.props;
|
|
22
|
+
export declare type FocusLockEvents = typeof __propDef.events;
|
|
23
|
+
export declare type FocusLockSlots = typeof __propDef.slots;
|
|
24
|
+
export default class FocusLock extends SvelteComponentTyped<FocusLockProps, FocusLockEvents, FocusLockSlots> {
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
<script>export let escapable = true;
|
|
1
|
+
<script >export let escapable = true;
|
|
2
2
|
export let hidefocus = true;
|
|
3
3
|
export let hidefocuslabel = undefined;
|
|
4
4
|
export let returnfocusto = undefined;
|
|
5
5
|
export let initialfocus = undefined;
|
|
6
6
|
export let containerClass = '';
|
|
7
7
|
export let opaque = false;
|
|
8
|
-
|
|
8
|
+
export let usePortal = undefined;
|
|
9
9
|
import { createEventDispatcher, onMount } from 'svelte';
|
|
10
|
+
import FocusLock from './FocusLock.svelte';
|
|
10
11
|
import { portal } from '../actions';
|
|
11
12
|
const dispatch = createEventDispatcher();
|
|
12
13
|
const endmodal = () => {
|
|
@@ -22,7 +23,7 @@ onMount(() => {
|
|
|
22
23
|
});
|
|
23
24
|
</script>
|
|
24
25
|
|
|
25
|
-
<div use:portal class="modal-backdrop" class:opaque on:click|stopPropagation|preventDefault={() => escapable && endmodal()}>
|
|
26
|
+
<div use:portal={usePortal} class="modal-backdrop" class:opaque on:click|stopPropagation|preventDefault={() => escapable && endmodal()}>
|
|
26
27
|
<FocusLock class="modal-container {containerClass}" {escapable} on:escape {hidefocus} {hidefocuslabel} {returnfocusto} {initialfocus}>
|
|
27
28
|
<slot></slot>
|
|
28
29
|
</FocusLock>
|
|
@@ -36,7 +37,7 @@ onMount(() => {
|
|
|
36
37
|
width: 100vw;
|
|
37
38
|
height: 100vh;
|
|
38
39
|
background-color: var(--modal-bg, rgba(0, 0, 0, 0.7));
|
|
39
|
-
z-index:
|
|
40
|
+
z-index: 2147483000;
|
|
40
41
|
display: flex;
|
|
41
42
|
justify-content: center;
|
|
42
43
|
align-items: center
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
escapable?: boolean;
|
|
5
|
+
hidefocus?: boolean;
|
|
6
|
+
hidefocuslabel?: string | undefined;
|
|
7
|
+
returnfocusto?: HTMLElement | undefined;
|
|
8
|
+
initialfocus?: string | undefined;
|
|
9
|
+
containerClass?: string;
|
|
10
|
+
opaque?: boolean;
|
|
11
|
+
usePortal?: HTMLElement | undefined;
|
|
12
|
+
};
|
|
13
|
+
events: {
|
|
14
|
+
escape: CustomEvent<any>;
|
|
15
|
+
} & {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
};
|
|
18
|
+
slots: {
|
|
19
|
+
default: {};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare type ModalProps = typeof __propDef.props;
|
|
23
|
+
export declare type ModalEvents = typeof __propDef.events;
|
|
24
|
+
export declare type ModalSlots = typeof __propDef.slots;
|
|
25
|
+
export default class Modal extends SvelteComponentTyped<ModalProps, ModalEvents, ModalSlots> {
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { createEventDispatcher, onDestroy, tick } from 'svelte';
|
|
1
|
+
<script >import { createEventDispatcher, onDestroy, tick } from 'svelte';
|
|
3
2
|
import { randomid } from 'txstate-utils';
|
|
4
|
-
import { Store } from '
|
|
3
|
+
import { Store } from '@txstate-mws/svelte-store';
|
|
4
|
+
import { glue, portal } from '../actions';
|
|
5
5
|
import ScreenReaderOnly from './ScreenReaderOnly.svelte';
|
|
6
6
|
const dispatch = createEventDispatcher();
|
|
7
7
|
export let menushown = false;
|
|
@@ -22,7 +22,7 @@ export let emptyText = undefined;
|
|
|
22
22
|
export let value = undefined;
|
|
23
23
|
let hilited = undefined;
|
|
24
24
|
let menuelement;
|
|
25
|
-
|
|
25
|
+
const itemelements = [];
|
|
26
26
|
const menuid = randomid();
|
|
27
27
|
let firstactive = 0;
|
|
28
28
|
let lastactive = items.length - 1;
|
|
@@ -30,10 +30,9 @@ function hiddenItem(item) {
|
|
|
30
30
|
return !!item && !showSelected && item.value === value;
|
|
31
31
|
}
|
|
32
32
|
async function reactToItems(..._) {
|
|
33
|
-
var _a;
|
|
34
33
|
firstactive = items.findIndex(itm => !itm.disabled && !hiddenItem(itm));
|
|
35
34
|
lastactive = items.length - [...items].reverse().findIndex(itm => !itm.disabled && !hiddenItem(itm)) - 1;
|
|
36
|
-
if (hilited &&
|
|
35
|
+
if (hilited && items[hilited]?.disabled)
|
|
37
36
|
hilited = firstactive;
|
|
38
37
|
}
|
|
39
38
|
$: reactToItems(items, value);
|
|
@@ -56,22 +55,20 @@ async function reactToMenuShown(_) {
|
|
|
56
55
|
}
|
|
57
56
|
$: reactToMenuShown(menushown);
|
|
58
57
|
function move(idx) {
|
|
59
|
-
var _a;
|
|
60
58
|
if (!menushown)
|
|
61
59
|
return;
|
|
62
|
-
if (
|
|
60
|
+
if (items[idx]?.disabled)
|
|
63
61
|
return;
|
|
64
62
|
hilited = Math.max(firstactive, Math.min(lastactive, idx));
|
|
65
63
|
itemelements[hilited].scrollIntoView({ block: 'center' });
|
|
66
64
|
buttonelement.setAttribute('aria-activedescendant', `${menuid}-${hilited}`);
|
|
67
65
|
}
|
|
68
66
|
function onkeydown(e) {
|
|
69
|
-
var _a, _b, _c, _d;
|
|
70
67
|
if (e.key === 'ArrowDown') {
|
|
71
68
|
e.preventDefault();
|
|
72
69
|
if (menushown) {
|
|
73
|
-
let i = (hilited
|
|
74
|
-
while (
|
|
70
|
+
let i = (hilited ?? firstactive - 1) + 1;
|
|
71
|
+
while (items[i]?.disabled || hiddenItem(items[i]))
|
|
75
72
|
i++;
|
|
76
73
|
move(i);
|
|
77
74
|
}
|
|
@@ -83,8 +80,8 @@ function onkeydown(e) {
|
|
|
83
80
|
else if (e.key === 'ArrowUp') {
|
|
84
81
|
e.preventDefault();
|
|
85
82
|
if (menushown) {
|
|
86
|
-
let i = (hilited
|
|
87
|
-
while (
|
|
83
|
+
let i = (hilited ?? lastactive + 1) - 1;
|
|
84
|
+
while (items[i]?.disabled || hiddenItem(items[i]))
|
|
88
85
|
i--;
|
|
89
86
|
move(i);
|
|
90
87
|
}
|
|
@@ -98,7 +95,7 @@ function onkeydown(e) {
|
|
|
98
95
|
if (menushown) {
|
|
99
96
|
menushown = false;
|
|
100
97
|
if (typeof hilited !== 'undefined') {
|
|
101
|
-
value =
|
|
98
|
+
value = items[hilited]?.value;
|
|
102
99
|
dispatch('change', items[hilited]);
|
|
103
100
|
}
|
|
104
101
|
}
|
|
@@ -114,7 +111,7 @@ function onkeydown(e) {
|
|
|
114
111
|
if (typeof hilited !== 'undefined') {
|
|
115
112
|
e.preventDefault();
|
|
116
113
|
menushown = false;
|
|
117
|
-
value =
|
|
114
|
+
value = items[hilited]?.value;
|
|
118
115
|
dispatch('change', items[hilited]);
|
|
119
116
|
}
|
|
120
117
|
else {
|
|
@@ -144,7 +141,7 @@ function onbuttonclick(e) {
|
|
|
144
141
|
}
|
|
145
142
|
async function onblur(e) {
|
|
146
143
|
// tabindex=-1 on our menu elements means e.relatedTarget will be set
|
|
147
|
-
if (!(e.relatedTarget instanceof HTMLElement &&
|
|
144
|
+
if (!(e.relatedTarget instanceof HTMLElement && menuelement?.contains(e.relatedTarget)))
|
|
148
145
|
menushown = false;
|
|
149
146
|
}
|
|
150
147
|
function cleanup(element) {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { Store } from '@txstate-mws/svelte-store';
|
|
3
|
+
import type { GlueAlignOpts, GlueAlignStore } from '../actions';
|
|
4
|
+
import type { PopupMenuItem } from '../types';
|
|
5
|
+
declare const __propDef: {
|
|
6
|
+
props: {
|
|
7
|
+
menushown?: boolean;
|
|
8
|
+
menuContainerClass?: string;
|
|
9
|
+
menuClass?: string;
|
|
10
|
+
menuItemClass?: string;
|
|
11
|
+
menuItemHilitedClass?: string;
|
|
12
|
+
menuItemSelectedClass?: string;
|
|
13
|
+
items?: PopupMenuItem[];
|
|
14
|
+
buttonelement: HTMLElement;
|
|
15
|
+
align?: GlueAlignOpts;
|
|
16
|
+
cover?: boolean;
|
|
17
|
+
showSelected?: boolean;
|
|
18
|
+
width?: string | undefined;
|
|
19
|
+
computedalign?: Store<GlueAlignStore>;
|
|
20
|
+
usePortal?: HTMLElement | true | undefined;
|
|
21
|
+
emptyText?: string | undefined;
|
|
22
|
+
value?: string | undefined;
|
|
23
|
+
};
|
|
24
|
+
events: {
|
|
25
|
+
change: CustomEvent<any>;
|
|
26
|
+
} & {
|
|
27
|
+
[evt: string]: CustomEvent<any>;
|
|
28
|
+
};
|
|
29
|
+
slots: {
|
|
30
|
+
default: {
|
|
31
|
+
item: PopupMenuItem;
|
|
32
|
+
label: string;
|
|
33
|
+
hilited: boolean;
|
|
34
|
+
selected: boolean;
|
|
35
|
+
};
|
|
36
|
+
noresults: {};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export declare type PopupMenuProps = typeof __propDef.props;
|
|
40
|
+
export declare type PopupMenuEvents = typeof __propDef.events;
|
|
41
|
+
export declare type PopupMenuSlots = typeof __propDef.slots;
|
|
42
|
+
export default class PopupMenu extends SvelteComponentTyped<PopupMenuProps, PopupMenuEvents, PopupMenuSlots> {
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
id?: string | undefined;
|
|
5
|
+
arialive?: 'off' | 'assertive' | 'polite' | undefined;
|
|
6
|
+
ariaatomic?: boolean | 'false' | 'true' | undefined;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {
|
|
12
|
+
default: {};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare type ScreenReaderOnlyProps = typeof __propDef.props;
|
|
16
|
+
export declare type ScreenReaderOnlyEvents = typeof __propDef.events;
|
|
17
|
+
export declare type ScreenReaderOnlySlots = typeof __propDef.slots;
|
|
18
|
+
export default class ScreenReaderOnly extends SvelteComponentTyped<ScreenReaderOnlyProps, ScreenReaderOnlyEvents, ScreenReaderOnlySlots> {
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as CollapsingTable } from './CollapsingTable.svelte';
|
|
2
|
+
export { default as FocusLock } from './FocusLock.svelte';
|
|
3
|
+
export { default as ConditionalWrapper } from './ConditionalWrapper.svelte';
|
|
4
|
+
export { default as Modal } from './Modal.svelte';
|
|
5
|
+
export { default as PopupMenu } from './PopupMenu.svelte';
|
|
6
|
+
export { default as ScreenReaderOnly } from './ScreenReaderOnly.svelte';
|
package/index.d.ts
ADDED
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,85 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@txstate-mws/svelte-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Svelte components that are generically useful.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "esm/index.js",
|
|
7
|
-
"svelte": "esm/index.js",
|
|
8
|
-
"types": "dist/ts/index.d.ts",
|
|
9
|
-
"scripts": {
|
|
10
|
-
"test": "jest src",
|
|
11
|
-
"test:watch": "npm run test -- --watch",
|
|
12
|
-
"svelte-check": "svelte-check --ignore 'dist'",
|
|
13
|
-
"prebuild": "rm -rf ./dist",
|
|
14
|
-
"build": "npm run svelte-check && tsc -m commonjs && node scripts/preprocess.js && rm -rf dist/tests",
|
|
15
|
-
"prepublishOnly": "npm run build"
|
|
16
|
-
},
|
|
17
|
-
"repository": {
|
|
18
|
-
"type": "git",
|
|
19
|
-
"url": "git@github.com:txstate-etc/svelte-components.git"
|
|
20
|
-
},
|
|
21
|
-
"author": "Nick Wing",
|
|
22
|
-
"license": "MIT",
|
|
23
5
|
"dependencies": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"txstate-utils": "^1.4.0"
|
|
6
|
+
"@txstate-mws/svelte-store": "^1.0.3",
|
|
7
|
+
"tabbable": "^5.2.1",
|
|
8
|
+
"txstate-utils": "^1.6.0"
|
|
28
9
|
},
|
|
29
10
|
"devDependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
11
|
+
"@babel/preset-env": "^7.16.11",
|
|
12
|
+
"@sveltejs/adapter-auto": "next",
|
|
13
|
+
"@sveltejs/kit": "next",
|
|
14
|
+
"@testing-library/jest-dom": "^5.16.1",
|
|
32
15
|
"@testing-library/svelte": "^3.0.3",
|
|
33
|
-
"@testing-library/user-event": "^13.
|
|
34
|
-
"@
|
|
35
|
-
"@types/jest": "^27.0.2",
|
|
36
|
-
"@types/node": "^15.3.1",
|
|
37
|
-
"@typescript-eslint/eslint-plugin": "^4.14.1",
|
|
38
|
-
"@typescript-eslint/parser": "^4.14.1",
|
|
39
|
-
"babel-jest": "^27.3.1",
|
|
40
|
-
"eslint": "^7.18.0",
|
|
16
|
+
"@testing-library/user-event": "^13.5.0",
|
|
17
|
+
"@types/tabbable": "^3.1.2",
|
|
41
18
|
"eslint-config-standard-with-typescript": "^21.0.1",
|
|
42
|
-
"eslint-plugin-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"jest": "^27.3
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"svelte-jester": "^2.1.5",
|
|
52
|
-
"svelte-preprocess": "^4.6.5",
|
|
53
|
-
"ts-jest": "^27.0.7",
|
|
54
|
-
"tslib": "^2.1.0",
|
|
55
|
-
"typescript": "^4.1.3"
|
|
19
|
+
"eslint-plugin-svelte3": "^3.2.1",
|
|
20
|
+
"svelte": "^3.44.0",
|
|
21
|
+
"svelte2tsx": "^0.5.1",
|
|
22
|
+
"svelte-check": "^2.2.6",
|
|
23
|
+
"svelte-jester": "^2.3.1",
|
|
24
|
+
"svelte-preprocess": "^4.9.4",
|
|
25
|
+
"ts-jest": "^27.1.3",
|
|
26
|
+
"tslib": "^2.3.1",
|
|
27
|
+
"typescript": "^4.4.3"
|
|
56
28
|
},
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
29
|
+
"type": "module",
|
|
30
|
+
"exports": {
|
|
31
|
+
"./package.json": "./package.json",
|
|
32
|
+
"./actions/buttonify": "./actions/buttonify.js",
|
|
33
|
+
"./actions/glue": "./actions/glue.js",
|
|
34
|
+
"./actions": "./actions/index.js",
|
|
35
|
+
"./actions/offset": "./actions/offset.js",
|
|
36
|
+
"./actions/portal": "./actions/portal.js",
|
|
37
|
+
"./actions/resize": "./actions/resize.js",
|
|
38
|
+
"./actions/sticky": "./actions/sticky.js",
|
|
39
|
+
"./actions/stickyfixed": "./actions/stickyfixed.js",
|
|
40
|
+
"./components/CollapsingTable.svelte": "./components/CollapsingTable.svelte",
|
|
41
|
+
"./components/ConditionalWrapper.svelte": "./components/ConditionalWrapper.svelte",
|
|
42
|
+
"./components/FocusLock.svelte": "./components/FocusLock.svelte",
|
|
43
|
+
"./components/Modal.svelte": "./components/Modal.svelte",
|
|
44
|
+
"./components/PopupMenu.svelte": "./components/PopupMenu.svelte",
|
|
45
|
+
"./components/ScreenReaderOnly.svelte": "./components/ScreenReaderOnly.svelte",
|
|
46
|
+
"./components": "./components/index.js",
|
|
47
|
+
".": "./index.js",
|
|
48
|
+
"./types/CollapsingTable": "./types/CollapsingTable.js",
|
|
49
|
+
"./types/PopupMenu": "./types/PopupMenu.js",
|
|
50
|
+
"./types": "./types/index.js",
|
|
51
|
+
"./util/bodyoffset": "./util/bodyoffset.js",
|
|
52
|
+
"./util": "./util/index.js",
|
|
53
|
+
"./util/repositioned": "./util/repositioned.js",
|
|
54
|
+
"./util/util": "./util/util.js"
|
|
78
55
|
},
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
"dist",
|
|
82
|
-
"esm",
|
|
83
|
-
"docs"
|
|
84
|
-
]
|
|
85
|
-
}
|
|
56
|
+
"svelte": "./index.js"
|
|
57
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/types/index.d.ts
ADDED
package/types/index.js
ADDED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare type ElementOffsets = Partial<ReturnType<typeof bodyOffset>>;
|
|
1
2
|
export declare function bodyOffset(ele: HTMLElement): {
|
|
2
3
|
right: number;
|
|
3
4
|
bottom: number;
|
|
@@ -10,4 +11,4 @@ export declare function targetOffset(ele: HTMLElement, target: HTMLElement): {
|
|
|
10
11
|
top: number;
|
|
11
12
|
left: number;
|
|
12
13
|
};
|
|
13
|
-
export declare function sharedOffsetParent(a: HTMLElement, b: HTMLElement): HTMLElement
|
|
14
|
+
export declare function sharedOffsetParent(a: HTMLElement, b: HTMLElement): HTMLElement;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sharedOffsetParent = exports.targetOffset = exports.bodyOffset = void 0;
|
|
4
|
-
function bodyOffset(ele) {
|
|
1
|
+
export function bodyOffset(ele) {
|
|
5
2
|
return targetOffset(ele, document.body);
|
|
6
3
|
}
|
|
7
|
-
|
|
8
|
-
function targetOffset(ele, target) {
|
|
4
|
+
export function targetOffset(ele, target) {
|
|
9
5
|
const offset = targetOffsetRecursive(ele, target);
|
|
10
|
-
return
|
|
6
|
+
return {
|
|
7
|
+
...offset,
|
|
8
|
+
right: target.offsetWidth - offset.left - ele.offsetWidth,
|
|
9
|
+
bottom: target.offsetHeight - offset.top - ele.offsetHeight
|
|
10
|
+
};
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
function sharedOffsetParent(a, b) {
|
|
12
|
+
export function sharedOffsetParent(a, b) {
|
|
14
13
|
if (!a || !b)
|
|
15
14
|
return undefined;
|
|
16
15
|
if (a.contains(b) && a.firstElementChild.offsetParent === a)
|
|
@@ -22,13 +21,11 @@ function sharedOffsetParent(a, b) {
|
|
|
22
21
|
c = c.offsetParent;
|
|
23
22
|
return c;
|
|
24
23
|
}
|
|
25
|
-
exports.sharedOffsetParent = sharedOffsetParent;
|
|
26
24
|
function targetOffsetRecursive(ele, target, currentOffset) {
|
|
27
|
-
var _a, _b;
|
|
28
25
|
const { x, y } = getTranslate(ele);
|
|
29
26
|
const offset = {
|
|
30
|
-
top: ele.offsetTop + (
|
|
31
|
-
left: ele.offsetLeft + (
|
|
27
|
+
top: ele.offsetTop + (currentOffset?.top ?? 0) + y,
|
|
28
|
+
left: ele.offsetLeft + (currentOffset?.left ?? 0) + x
|
|
32
29
|
};
|
|
33
30
|
if (ele.offsetParent instanceof HTMLElement && target !== ele.offsetParent && target.contains(ele.offsetParent))
|
|
34
31
|
return targetOffsetRecursive(ele.offsetParent, target, offset);
|
|
@@ -73,4 +70,3 @@ function getTranslate(element) {
|
|
|
73
70
|
z: 0
|
|
74
71
|
};
|
|
75
72
|
}
|
|
76
|
-
//# sourceMappingURL=bodyoffset.js.map
|
package/util/index.d.ts
ADDED
package/util/index.js
ADDED