@txstate-mws/svelte-components 0.0.66 → 1.0.2
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 +12 -0
- package/dist/actions/{a11y.js → buttonify.js} +1 -1
- package/dist/actions/buttonify.js.map +1 -0
- package/dist/actions/glue.js +1 -3
- package/dist/actions/glue.js.map +1 -1
- package/dist/actions/index.js +1 -1
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/portal.js +3 -7
- package/dist/actions/portal.js.map +1 -1
- package/dist/actions/stickyfixed.js +5 -5
- package/dist/components/CollapsingTable.svelte +3 -3
- package/dist/components/ConditionalWrapper.svelte +1 -1
- package/dist/components/FocusLock.svelte +13 -11
- package/dist/components/Modal.svelte +19 -11
- package/dist/components/PopupMenu.svelte +19 -18
- package/dist/components/ScreenReaderOnly.svelte +4 -5
- package/dist/lib/activestore.js +123 -0
- package/dist/lib/activestore.js.map +1 -0
- package/dist/lib/convertedstore.js +41 -0
- package/dist/lib/convertedstore.js.map +1 -0
- package/dist/lib/derivedstore.js +37 -25
- package/dist/lib/derivedstore.js.map +1 -1
- package/dist/lib/index.js +3 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/safestore.js +2 -2
- package/dist/lib/safestore.js.map +1 -1
- package/dist/lib/store.js +27 -0
- package/dist/lib/store.js.map +1 -0
- package/dist/lib/substore.js +10 -9
- package/dist/lib/substore.js.map +1 -1
- package/dist/ts/actions/{a11y.d.ts → buttonify.d.ts} +0 -0
- package/dist/ts/actions/glue.d.ts +1 -1
- package/dist/ts/actions/index.d.ts +1 -1
- package/dist/ts/actions/stickyfixed.d.ts +5 -5
- package/dist/ts/components/CollapsingTable.svelte +3 -3
- package/dist/ts/components/ConditionalWrapper.svelte +1 -1
- package/dist/ts/components/FocusLock.svelte +13 -10
- package/dist/ts/components/Modal.svelte +20 -11
- package/dist/ts/components/PopupMenu.svelte +18 -17
- package/dist/ts/components/ScreenReaderOnly.svelte +5 -5
- package/dist/ts/lib/activestore.d.ts +60 -0
- package/dist/ts/lib/convertedstore.d.ts +16 -0
- package/dist/ts/lib/derivedstore.d.ts +15 -8
- package/dist/ts/lib/index.d.ts +3 -1
- package/dist/ts/lib/safestore.d.ts +2 -2
- package/dist/ts/lib/store.d.ts +16 -0
- package/dist/ts/lib/substore.d.ts +7 -6
- package/dist/ts/tests/Modal/ModalTest.svelte +2 -2
- package/dist/ts/tests/PopupMenu/PopupMenuSimple.svelte +8 -2
- package/docs/CollapsingTable.md +11 -12
- package/docs/ConditionalWrapper.md +35 -0
- package/docs/Modal.md +63 -0
- package/docs/PopupMenu.md +31 -0
- package/docs/ScreenReaderOnly.md +10 -0
- package/docs/actions.md +76 -2
- package/docs/stores.md +203 -0
- package/package.json +17 -9
- package/dist/actions/a11y.js.map +0 -1
- package/dist/lib/deepstore.js +0 -80
- package/dist/lib/deepstore.js.map +0 -1
- package/dist/ts/lib/deepstore.d.ts +0 -42
package/README.md
CHANGED
|
@@ -3,3 +3,15 @@ A set of generically useful components for svelte.
|
|
|
3
3
|
|
|
4
4
|
# Components
|
|
5
5
|
[CollapsingTable](/docs/CollapsingTable.md)
|
|
6
|
+
[ConditionalWrapper](/docs/ConditionalWrapper.md)
|
|
7
|
+
[FocusLock](/docs/Modal.md#FocusLock)
|
|
8
|
+
[Modal](/docs/Modal.md#Modal)
|
|
9
|
+
[PopupMenu](/docs/PopupMenu.md)
|
|
10
|
+
[ScreenReaderOnly](/docs/ScreenReaderOnly.md)
|
|
11
|
+
|
|
12
|
+
# Actions
|
|
13
|
+
[use:buttonify](/docs/actions.md#use:buttonify)
|
|
14
|
+
[use:glue](/docs/actions.md#use:glue)
|
|
15
|
+
[use:offset](/docs/actions.md#use:offset)
|
|
16
|
+
[use:portal](/docs/actions.md#use:portal)
|
|
17
|
+
[use:resize](/docs/actions.md#use:resize)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buttonify.js","sourceRoot":"","sources":["../../src/actions/buttonify.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,SAAgB,SAAS,CAAE,IAAiB;IAC1C,SAAS,OAAO,CAAE,CAAgB;QAChC,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE;YACrB,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE;gBACxD,CAAC,CAAC,cAAc,EAAE,CAAA;gBAClB,CAAC,CAAC,eAAe,EAAE,CAAA;gBACnB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;aAC7C;SACF;IACH,CAAC;IAED,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IACzC,IAAI,IAAI,CAAC,QAAQ,GAAG,CAAC;QAAE,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAA;IACxC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACnC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAA;IAE7B,OAAO;QACL,OAAO;YACL,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QAC9C,CAAC;KACF,CAAA;AACH,CAAC;AArBD,8BAqBC"}
|
package/dist/actions/glue.js
CHANGED
package/dist/actions/glue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glue.js","sourceRoot":"","sources":["../../src/actions/glue.ts"],"names":[],"mappings":";;;AAAA,gCAAqJ;AAgBrJ,IAAI,eAAe,GAAG,KAAK,CAAA;AAC3B,SAAgB,IAAI,CAAE,EAAe,EAAE,EAAE,MAAM,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE,KAAK,EAAY;IAC/F,IAAI,CAAC,eAAe,EAAE;QACpB,eAAe,GAAG,IAAI,C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OAAO,CAAC,CAAA;gBAC9C,MAAM,GAAG,OAAO,CAAA;gBAChB,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,CAAC,CAAA;aACzC;QACH,CAAC;QACD,OAAO;KACR,CAAA;AACH,CAAC;AA7ED,oBA6EC"}
|
package/dist/actions/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./
|
|
13
|
+
__exportStar(require("./buttonify"), exports);
|
|
14
14
|
__exportStar(require("./glue"), exports);
|
|
15
15
|
__exportStar(require("./offset"), exports);
|
|
16
16
|
__exportStar(require("./portal"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA2B;AAC3B,yCAAsB;AACtB,2CAAwB;AACxB,2CAAwB;AACxB,2CAAwB;AACxB,2CAAwB;AACxB,gDAA6B"}
|
package/dist/actions/portal.js
CHANGED
|
@@ -3,15 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.portal = void 0;
|
|
4
4
|
function portal(el, target = document.body) {
|
|
5
5
|
function update(target = document.body) {
|
|
6
|
-
|
|
7
|
-
return;
|
|
8
|
-
target.appendChild(el);
|
|
9
|
-
el.hidden = false;
|
|
6
|
+
target === null || target === void 0 ? void 0 : target.appendChild(el);
|
|
10
7
|
}
|
|
11
8
|
function destroy() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
9
|
+
var _a;
|
|
10
|
+
(_a = el.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(el);
|
|
15
11
|
}
|
|
16
12
|
update(target);
|
|
17
13
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal.js","sourceRoot":"","sources":["../../src/actions/portal.ts"],"names":[],"mappings":";;;AAAA,SAAgB,MAAM,CAAE,EAAe,EAAE,SAA2B,QAAQ,CAAC,IAAI;IAC/E,SAAS,MAAM,CAAE,SAA2B,QAAQ,CAAC,IAAI;QACvD,
|
|
1
|
+
{"version":3,"file":"portal.js","sourceRoot":"","sources":["../../src/actions/portal.ts"],"names":[],"mappings":";;;AAAA,SAAgB,MAAM,CAAE,EAAe,EAAE,SAA2B,QAAQ,CAAC,IAAI;IAC/E,SAAS,MAAM,CAAE,SAA2B,QAAQ,CAAC,IAAI;QACvD,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,CAAC,EAAE,CAAC,CAAA;IACzB,CAAC;IACD,SAAS,OAAO;;QACd,MAAA,EAAE,CAAC,aAAa,0CAAE,WAAW,CAAC,EAAE,CAAC,CAAA;IACnC,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,CAAA;IACd,OAAO;QACL,MAAM;QACN,OAAO;KACR,CAAA;AACH,CAAC;AAZD,wBAYC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.stickyfixed = void 0;
|
|
4
4
|
const lib_1 = require("../lib");
|
|
5
5
|
/**
|
|
6
|
-
* An implementation of stickyness based on `
|
|
6
|
+
* An implementation of stickyness based on `positon: fixed`. Only use when
|
|
7
7
|
* `position: sticky` won't work for you. If `position: sticky` does work for you, use it,
|
|
8
8
|
* it performs better.
|
|
9
9
|
*
|
|
@@ -13,10 +13,10 @@ const lib_1 = require("../lib");
|
|
|
13
13
|
* 3) it always stays within the boundaries of the closest parent element that has a `position`
|
|
14
14
|
* * use:sticky accepts a `target` element as a parameter, defining the bounding container
|
|
15
15
|
*
|
|
16
|
-
* Note that this implementation
|
|
17
|
-
* work like cloning the element you place it on, placing the cloned element next
|
|
18
|
-
* setting widths to match between them, watching for mutations to keep them
|
|
19
|
-
* this work may get foiled if you have a complex html/css/js situation.
|
|
16
|
+
* Note that this implementation gets great animation performance at the cost of extra complexity.
|
|
17
|
+
* It does a lot of work like cloning the element you place it on, placing the cloned element next
|
|
18
|
+
* to yours in the DOM, setting widths to match between them, watching for mutations to keep them
|
|
19
|
+
* in sync, etc. Some of this work may get foiled if you have a complex html/css/js situation.
|
|
20
20
|
*
|
|
21
21
|
* You may also want to try use:sticky. It is based on setting `transform: translateY()` as appropriate,
|
|
22
22
|
* and is less fragile than this. However, it cannot do its work before the scroll on mobile, only after,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>var _a;
|
|
2
|
-
import {
|
|
2
|
+
import { Store, classes } from '../lib';
|
|
3
3
|
import { derived } from 'svelte/store';
|
|
4
4
|
import DefaultPopupMenu from './PopupMenu.svelte';
|
|
5
5
|
import ScreenReaderOnly from './ScreenReaderOnly.svelte';
|
|
@@ -41,7 +41,7 @@ function reactToColumns(columns) {
|
|
|
41
41
|
}
|
|
42
42
|
$: sortedcolumns = reactToColumns(columns);
|
|
43
43
|
$: itemkeys = items.map(item => { var _a, _b; return (_b = (_a = item.id) !== null && _a !== void 0 ? _a : item._id) !== null && _b !== void 0 ? _b : identifyingkeys.map(k => item[k]).join('.'); });
|
|
44
|
-
const state = new
|
|
44
|
+
const state = new Store({
|
|
45
45
|
keepcolumns: [],
|
|
46
46
|
hiddencolumns: [],
|
|
47
47
|
dropdowncolumn: undefined
|
|
@@ -113,7 +113,7 @@ $: menubuttonelement = headers[$state.keepcolumns.length - 1];
|
|
|
113
113
|
</table>
|
|
114
114
|
</div>
|
|
115
115
|
{#if $menuitems.length > 0}
|
|
116
|
-
<svelte:component this={PopupMenu} {menuContainerClass} {menuClass} {menuItemClass} {menuItemHilitedClass} items={$menuitems} buttonelement={menubuttonelement}
|
|
116
|
+
<svelte:component this={PopupMenu} {menuContainerClass} {menuClass} {menuItemClass} {menuItemHilitedClass} items={$menuitems} buttonelement={menubuttonelement} on:change={e => selected = e.detail}></svelte:component>
|
|
117
117
|
{/if}
|
|
118
118
|
|
|
119
119
|
<style>
|
|
@@ -10,15 +10,17 @@ 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();
|
|
16
17
|
let lockelement;
|
|
17
18
|
let abovelockelement;
|
|
18
19
|
let active = true;
|
|
20
|
+
let listenforescape = false;
|
|
19
21
|
if (initialfocus)
|
|
20
22
|
hidefocus = false;
|
|
21
|
-
onMount(() => {
|
|
23
|
+
onMount(async () => {
|
|
22
24
|
const prevFocusLock = FocusLockStack.slice(-1)[0];
|
|
23
25
|
if (prevFocusLock)
|
|
24
26
|
prevFocusLock.pause();
|
|
@@ -29,6 +31,7 @@ onMount(() => {
|
|
|
29
31
|
if (typeof returnfocusto === 'undefined') {
|
|
30
32
|
returnfocusto = document.querySelector(':focus');
|
|
31
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
|
|
32
35
|
if (initialfocus) {
|
|
33
36
|
const focusEl = lockelement.querySelector(initialfocus);
|
|
34
37
|
if (focusEl instanceof HTMLElement)
|
|
@@ -37,20 +40,13 @@ onMount(() => {
|
|
|
37
40
|
else {
|
|
38
41
|
setInitialFocus();
|
|
39
42
|
}
|
|
43
|
+
setTimeout(() => listenforescape = true, 0);
|
|
40
44
|
});
|
|
41
45
|
onDestroy(async () => {
|
|
42
46
|
const wasactive = active;
|
|
43
|
-
let focuswasinside;
|
|
44
|
-
try {
|
|
45
|
-
focuswasinside = lockelement.matches(':focus-within');
|
|
46
|
-
}
|
|
47
|
-
catch (e) {
|
|
48
|
-
// browser doesn't support :focus-within
|
|
49
|
-
focuswasinside = true;
|
|
50
|
-
}
|
|
51
47
|
active = false;
|
|
52
48
|
await tick();
|
|
53
|
-
if (returnfocusto && wasactive
|
|
49
|
+
if (returnfocusto && wasactive) {
|
|
54
50
|
returnfocusto.focus();
|
|
55
51
|
}
|
|
56
52
|
FocusLockStack.pop();
|
|
@@ -84,8 +80,14 @@ const focusin = (e) => {
|
|
|
84
80
|
setInitialFocus();
|
|
85
81
|
}
|
|
86
82
|
};
|
|
83
|
+
const windowclick = (_) => {
|
|
84
|
+
if (listenforescape && active) {
|
|
85
|
+
returnfocusto = undefined;
|
|
86
|
+
dispatch('escape');
|
|
87
|
+
}
|
|
88
|
+
};
|
|
87
89
|
</script>
|
|
88
|
-
|
|
90
|
+
<svelte:window on:click={windowclick} />
|
|
89
91
|
<div class={className} role="alertdialog" aria-modal="true" on:click|stopPropagation on:keydown|stopPropagation={keydown} on:focusin={focusin}>
|
|
90
92
|
<div bind:this={abovelockelement} tabindex="0"></div>
|
|
91
93
|
<div bind:this={lockelement} on:keydown={keydown}>
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
<script>export let
|
|
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
|
+
export let containerClass = '';
|
|
7
|
+
export let opaque = false;
|
|
6
8
|
import FocusLock from './FocusLock.svelte';
|
|
7
9
|
import { createEventDispatcher, onMount } from 'svelte';
|
|
8
10
|
import { portal } from '../actions';
|
|
9
11
|
const dispatch = createEventDispatcher();
|
|
10
12
|
const endmodal = () => {
|
|
11
|
-
dispatch('
|
|
13
|
+
dispatch('escape');
|
|
12
14
|
};
|
|
13
15
|
onMount(() => {
|
|
16
|
+
document.body.style.marginRight = (window.innerWidth - document.body.clientWidth) + 'px';
|
|
14
17
|
document.body.style.overflow = 'hidden';
|
|
15
18
|
return () => {
|
|
16
19
|
document.body.style.overflow = '';
|
|
20
|
+
document.body.style.marginRight = '';
|
|
17
21
|
};
|
|
18
22
|
});
|
|
19
23
|
</script>
|
|
20
24
|
|
|
21
|
-
<div use:portal class="modal-backdrop" on:click={() =>
|
|
22
|
-
<FocusLock class="modal-container" escapable
|
|
25
|
+
<div use:portal class="modal-backdrop" class:opaque on:click|stopPropagation|preventDefault={() => escapable && endmodal()}>
|
|
26
|
+
<FocusLock class="modal-container {containerClass}" {escapable} on:escape {hidefocus} {hidefocuslabel} {returnfocusto} {initialfocus}>
|
|
23
27
|
<slot></slot>
|
|
24
28
|
</FocusLock>
|
|
25
29
|
</div>
|
|
@@ -29,16 +33,20 @@ onMount(() => {
|
|
|
29
33
|
position: fixed;
|
|
30
34
|
top: 0;
|
|
31
35
|
left: 0;
|
|
32
|
-
width:
|
|
33
|
-
height:
|
|
36
|
+
width: 100vw;
|
|
37
|
+
height: 100vh;
|
|
34
38
|
background-color: var(--modal-bg, rgba(0, 0, 0, 0.7));
|
|
35
|
-
overflow: auto;
|
|
36
39
|
z-index: 100;
|
|
40
|
+
display: flex;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
align-items: center
|
|
43
|
+
}
|
|
44
|
+
.modal-backdrop.opaque {
|
|
45
|
+
background-color: var(--modal-bg-opaque, #4c4c4c);
|
|
37
46
|
}
|
|
38
47
|
.modal-backdrop :global(.modal-container) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
transform: translate(-50%, -50%);
|
|
48
|
+
max-width: 100vw;
|
|
49
|
+
max-height: 100vh;
|
|
50
|
+
overflow: auto;
|
|
43
51
|
}
|
|
44
52
|
</style>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>import { glue, portal } from '../actions';
|
|
2
2
|
import { createEventDispatcher, onDestroy, tick } from 'svelte';
|
|
3
3
|
import { randomid } from 'txstate-utils';
|
|
4
|
-
import {
|
|
4
|
+
import { Store } from '../lib';
|
|
5
5
|
import ScreenReaderOnly from './ScreenReaderOnly.svelte';
|
|
6
6
|
const dispatch = createEventDispatcher();
|
|
7
7
|
export let menushown = false;
|
|
@@ -16,18 +16,18 @@ export let align = 'auto';
|
|
|
16
16
|
export let cover = false;
|
|
17
17
|
export let showSelected = true;
|
|
18
18
|
export let width = undefined;
|
|
19
|
-
export let computedalign = new
|
|
19
|
+
export let computedalign = new Store({ valign: 'bottom', halign: 'left' });
|
|
20
20
|
export let usePortal = undefined;
|
|
21
21
|
export let emptyText = undefined;
|
|
22
|
-
export let
|
|
23
|
-
|
|
22
|
+
export let value = undefined;
|
|
23
|
+
let hilited = undefined;
|
|
24
24
|
let menuelement;
|
|
25
25
|
let itemelements = [];
|
|
26
26
|
const menuid = randomid();
|
|
27
27
|
let firstactive = 0;
|
|
28
28
|
let lastactive = items.length - 1;
|
|
29
29
|
function hiddenItem(item) {
|
|
30
|
-
return !!item && !showSelected && item.value ===
|
|
30
|
+
return !!item && !showSelected && item.value === value;
|
|
31
31
|
}
|
|
32
32
|
async function reactToItems(..._) {
|
|
33
33
|
var _a;
|
|
@@ -36,7 +36,7 @@ async function reactToItems(..._) {
|
|
|
36
36
|
if (hilited && ((_a = items[hilited]) === null || _a === void 0 ? void 0 : _a.disabled))
|
|
37
37
|
hilited = firstactive;
|
|
38
38
|
}
|
|
39
|
-
$: reactToItems(items,
|
|
39
|
+
$: reactToItems(items, value);
|
|
40
40
|
async function reactToMenuShown(_) {
|
|
41
41
|
if (!buttonelement) {
|
|
42
42
|
hilited = undefined;
|
|
@@ -66,7 +66,7 @@ function move(idx) {
|
|
|
66
66
|
buttonelement.setAttribute('aria-activedescendant', `${menuid}-${hilited}`);
|
|
67
67
|
}
|
|
68
68
|
function onkeydown(e) {
|
|
69
|
-
var _a, _b;
|
|
69
|
+
var _a, _b, _c, _d;
|
|
70
70
|
if (e.key === 'ArrowDown') {
|
|
71
71
|
e.preventDefault();
|
|
72
72
|
if (menushown) {
|
|
@@ -98,8 +98,8 @@ function onkeydown(e) {
|
|
|
98
98
|
if (menushown) {
|
|
99
99
|
menushown = false;
|
|
100
100
|
if (typeof hilited !== 'undefined') {
|
|
101
|
-
|
|
102
|
-
dispatch('change', items[hilited]
|
|
101
|
+
value = (_c = items[hilited]) === null || _c === void 0 ? void 0 : _c.value;
|
|
102
|
+
dispatch('change', items[hilited]);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
else {
|
|
@@ -114,8 +114,8 @@ function onkeydown(e) {
|
|
|
114
114
|
if (typeof hilited !== 'undefined') {
|
|
115
115
|
e.preventDefault();
|
|
116
116
|
menushown = false;
|
|
117
|
-
|
|
118
|
-
dispatch('change', items[hilited]
|
|
117
|
+
value = (_d = items[hilited]) === null || _d === void 0 ? void 0 : _d.value;
|
|
118
|
+
dispatch('change', items[hilited]);
|
|
119
119
|
}
|
|
120
120
|
else {
|
|
121
121
|
if (buttonelement.tagName !== 'INPUT') {
|
|
@@ -152,6 +152,7 @@ function cleanup(element) {
|
|
|
152
152
|
element.removeEventListener('click', onbuttonclick);
|
|
153
153
|
element.removeEventListener('keydown', onkeydown);
|
|
154
154
|
element.removeEventListener('blur', onblur);
|
|
155
|
+
element.removeAttribute('aria-disabled');
|
|
155
156
|
element.removeAttribute('aria-haspopup');
|
|
156
157
|
element.removeAttribute('aria-expanded');
|
|
157
158
|
element.removeAttribute('aria-controls');
|
|
@@ -178,29 +179,29 @@ const onclick = (item) => (e) => {
|
|
|
178
179
|
if (item.disabled)
|
|
179
180
|
return;
|
|
180
181
|
menushown = false;
|
|
181
|
-
|
|
182
|
-
dispatch('change', item
|
|
182
|
+
value = item.value;
|
|
183
|
+
dispatch('change', item);
|
|
183
184
|
};
|
|
184
|
-
$: hasSelected = showSelected &&
|
|
185
|
+
$: hasSelected = showSelected && items.some(itm => itm.value === value);
|
|
185
186
|
</script>
|
|
186
187
|
|
|
187
188
|
{#if menushown}
|
|
188
189
|
<div use:portal={usePortal === true ? document.body : (usePortal || null)} use:glue={{ target: buttonelement, align, cover, store: computedalign }} class={menuContainerClass}>
|
|
189
190
|
<ul bind:this={menuelement} id={menuid} role='listbox' style={width ? `width: ${width}` : ''} class={menuClass} class:hasSelected class:defaultmenu={!menuClass && !menuContainerClass} on:keydown={onkeydown}>
|
|
190
191
|
{#each items as item, i (item.value)}
|
|
191
|
-
{#if showSelected ||
|
|
192
|
+
{#if showSelected || item.value !== value}
|
|
192
193
|
<li
|
|
193
194
|
id={`${menuid}-${i}`}
|
|
194
195
|
bind:this={itemelements[i]}
|
|
195
|
-
class={`${menuItemClass} ${i === hilited ? menuItemHilitedClass || '' : ''} ${
|
|
196
|
+
class={`${menuItemClass} ${i === hilited ? menuItemHilitedClass || '' : ''} ${value === item.value ? menuItemSelectedClass || '' : ''}`}
|
|
196
197
|
class:disabled={!!item.disabled}
|
|
197
198
|
class:hilited={!menuItemHilitedClass && i === hilited}
|
|
198
|
-
class:selected={showSelected && !menuItemSelectedClass &&
|
|
199
|
+
class:selected={showSelected && !menuItemSelectedClass && value === item.value}
|
|
199
200
|
on:click={onclick(item)}
|
|
200
201
|
role="option"
|
|
201
202
|
tabindex=-1
|
|
202
203
|
aria-disabled={item.disabled}
|
|
203
|
-
><slot {item} label={item.label || item.value} hilited={i === hilited} selected={
|
|
204
|
+
><slot {item} label={item.label || item.value} hilited={i === hilited} selected={value === item.value}>{item.label || item.value}</slot></li>
|
|
204
205
|
{/if}
|
|
205
206
|
{/each}
|
|
206
207
|
{#if items.length === 0}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export let ariaatomic = ''
|
|
1
|
+
<script>export let id = undefined;
|
|
2
|
+
export let arialive = undefined;
|
|
3
|
+
export let ariaatomic = undefined;
|
|
5
4
|
</script>
|
|
6
5
|
|
|
7
6
|
<style>
|
|
@@ -23,4 +22,4 @@
|
|
|
23
22
|
}
|
|
24
23
|
</style>
|
|
25
24
|
|
|
26
|
-
<span
|
|
25
|
+
<span {id} class="sr-only" aria-live={arialive} aria-atomic={ariaatomic}><slot/></span>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActiveStore = exports.isSettable = exports.isWritable = exports.isUsable = void 0;
|
|
4
|
+
function isUsable(value) {
|
|
5
|
+
return !!value && typeof value.subscribe === 'function';
|
|
6
|
+
}
|
|
7
|
+
exports.isUsable = isUsable;
|
|
8
|
+
function isWritable(value) {
|
|
9
|
+
return isUsable(value) && typeof value.update === 'function';
|
|
10
|
+
}
|
|
11
|
+
exports.isWritable = isWritable;
|
|
12
|
+
function isSettable(value) {
|
|
13
|
+
return isWritable(value) && typeof value.set === 'function';
|
|
14
|
+
}
|
|
15
|
+
exports.isSettable = isSettable;
|
|
16
|
+
/**
|
|
17
|
+
* An alternative to svelte's "writable" that does not check equality before notifying
|
|
18
|
+
* subscribers. A writable will notify subscribers after a shallow equality check, which
|
|
19
|
+
* does not work with mutated states:
|
|
20
|
+
* store.update(v => { v.someprop = 'newvalue'; return v })
|
|
21
|
+
*
|
|
22
|
+
* With a writable, this line would NOT notify subscribers because the state will be compared
|
|
23
|
+
* against itself and always found to be equal.
|
|
24
|
+
*
|
|
25
|
+
* An alternative to this store type is SafeStore, which will do a deep equality check but
|
|
26
|
+
* clone data so that it is safe against mutations. It costs more CPU cycles but results in
|
|
27
|
+
* fewer notifications to subscribers which could be an overall win.
|
|
28
|
+
*/
|
|
29
|
+
class ActiveStore {
|
|
30
|
+
constructor(value) {
|
|
31
|
+
this.cleanups = [];
|
|
32
|
+
this.sourceInits = [];
|
|
33
|
+
this.subscribers = new Map();
|
|
34
|
+
this.value = this.clone(value);
|
|
35
|
+
}
|
|
36
|
+
// this is here to support SafeStore: the regular store makes this a null-op, but
|
|
37
|
+
// SafeStore overrides the implementation to a deep clone operation
|
|
38
|
+
clone(value) {
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
// always returns false so that subscribers are notified on every `set` or `update`.
|
|
42
|
+
// Subclasses can override this for shallow or deep equality checks.
|
|
43
|
+
equal(a, b) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
set(value) {
|
|
47
|
+
if (!this.equal(value, this.value)) {
|
|
48
|
+
this.value = this.clone(value);
|
|
49
|
+
for (const [id, run] of this.subscribers) {
|
|
50
|
+
run(value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
update(updater) {
|
|
55
|
+
// we have to send the user's updater function a cloned value, because they might mutate it
|
|
56
|
+
this.set(updater(this.clone(this.value)));
|
|
57
|
+
}
|
|
58
|
+
subscribe(run) {
|
|
59
|
+
// if we previously had no listeners, then we will have unsubscribed from our sources
|
|
60
|
+
// and we need to re-subscribe so our new listener will get updates
|
|
61
|
+
if (this.subscribers.size === 0)
|
|
62
|
+
this.subscribeToSources();
|
|
63
|
+
// generate a random id for this subscriber, it makes unsubscription O(1) instead of O(n)
|
|
64
|
+
let id;
|
|
65
|
+
do {
|
|
66
|
+
id = Math.random().toString(32);
|
|
67
|
+
} while (this.subscribers.has(id));
|
|
68
|
+
// register our new subscriber to receive updates
|
|
69
|
+
this.subscribers.set(id, run);
|
|
70
|
+
// immediately send the current value to our new subscriber
|
|
71
|
+
run(this.value);
|
|
72
|
+
// return an unsubscribe function
|
|
73
|
+
return () => {
|
|
74
|
+
this.subscribers.delete(id);
|
|
75
|
+
// if we have no listeners, stop listening to our sources for updates
|
|
76
|
+
// this makes it possible for us to be properly garbage collected
|
|
77
|
+
if (this.subscribers.size === 0)
|
|
78
|
+
this.unsubscribeFromSources();
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Provided as a last ditch avenue to clean up memory after rogue subscribers forget
|
|
83
|
+
* to unsubscribe themselves. For example, in an SSR environment one could clear out
|
|
84
|
+
* global stores anytime a request finishes and no other requests are being processed.
|
|
85
|
+
*/
|
|
86
|
+
clearSubscribers() {
|
|
87
|
+
this.subscribers.clear();
|
|
88
|
+
this.unsubscribeFromSources();
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Stores that subscribe to external events should set it up with a start/stop mentality
|
|
92
|
+
* so that the external events can be unsubscribed when the store itself has no listeners
|
|
93
|
+
* to notify. This helps ensure unused stores can be garbage collected.
|
|
94
|
+
*
|
|
95
|
+
* To do this, pass registerSource a function that initializes the subscription to the external
|
|
96
|
+
* event, and returns a function that can unsubscribe from the external event. This parent
|
|
97
|
+
* class will take care of running those functions at appropriate times.
|
|
98
|
+
*/
|
|
99
|
+
registerSource(fn) {
|
|
100
|
+
if (this.subscribers.size)
|
|
101
|
+
this.cleanups.push(fn());
|
|
102
|
+
this.sourceInits.push(fn);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Provided in case a child class has a need to change out the external resources
|
|
106
|
+
*/
|
|
107
|
+
unregisterSources() {
|
|
108
|
+
this.unsubscribeFromSources();
|
|
109
|
+
this.sourceInits = [];
|
|
110
|
+
}
|
|
111
|
+
subscribeToSources() {
|
|
112
|
+
for (const fn of this.sourceInits) {
|
|
113
|
+
this.cleanups.push(fn());
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
unsubscribeFromSources() {
|
|
117
|
+
for (const fn of this.cleanups)
|
|
118
|
+
fn();
|
|
119
|
+
this.cleanups = [];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.ActiveStore = ActiveStore;
|
|
123
|
+
//# sourceMappingURL=activestore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activestore.js","sourceRoot":"","sources":["../../src/lib/activestore.ts"],"names":[],"mappings":";;;AAcA,SAAgB,QAAQ,CAAM,KAAmC;IAC/D,OAAO,CAAC,CAAC,KAAK,IAAI,OAAQ,KAAa,CAAC,SAAS,KA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ACvB,CAAC;IAEO,kBAAkB;QACxB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE;YACjC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;SACzB;IACH,CAAC;IAEO,sBAAsB;QAC5B,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,QAAQ;YAAE,EAAE,EAAE,CAAA;QACpC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;IACpB,CAAC;CACF;AAxGD,kCAwGC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertStore = exports.ConvertedStore = void 0;
|
|
4
|
+
const store_1 = require("./store");
|
|
5
|
+
const activestore_1 = require("./activestore");
|
|
6
|
+
/**
|
|
7
|
+
* A store that allows you to pass in a traditional svelte store in the constructor.
|
|
8
|
+
*
|
|
9
|
+
* Updates to the original store will be sent to subscribers of this store, but only after a deep equality check.
|
|
10
|
+
*
|
|
11
|
+
* Updates to this store will also be sent to the original store after a deep equality check.
|
|
12
|
+
*/
|
|
13
|
+
class ConvertedStore extends store_1.Store {
|
|
14
|
+
constructor(value) {
|
|
15
|
+
super({});
|
|
16
|
+
this.pause = false;
|
|
17
|
+
this.valueStore = value;
|
|
18
|
+
this.registerSource(() => this.valueStore.subscribe(v => this.set(v)));
|
|
19
|
+
}
|
|
20
|
+
set(value) {
|
|
21
|
+
if (this.pause)
|
|
22
|
+
return;
|
|
23
|
+
if (!this.equal(value, this.value)) {
|
|
24
|
+
this.value = this.clone(value);
|
|
25
|
+
for (const [id, run] of this.subscribers) {
|
|
26
|
+
run(value);
|
|
27
|
+
}
|
|
28
|
+
if ((0, activestore_1.isSettable)(this.valueStore)) {
|
|
29
|
+
this.pause = true;
|
|
30
|
+
this.valueStore.set(value);
|
|
31
|
+
this.pause = false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.ConvertedStore = ConvertedStore;
|
|
37
|
+
function convertStore(store) {
|
|
38
|
+
return new ConvertedStore(store);
|
|
39
|
+
}
|
|
40
|
+
exports.convertStore = convertStore;
|
|
41
|
+
//# sourceMappingURL=convertedstore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertedstore.js","sourceRoot":"","sources":["../../src/lib/convertedstore.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAC/B,+CAAyD;AAEzD;;;;;;GAMG;AACH,MAAa,cAAkB,SAAQ,aAAQ;IAI7C,YAAa,KAAuB;QAClC,KAAK,CAAC,EAAS,CAAC,CAAA;QAHV,UAAK,GAAG,KAAK,CAAA;QAInB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;QACvB,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACxE,CAAC;IAED,GAAG,CAAE,KAAQ;QACX,IAAI,IAAI,CAAC,KAAK;YAAE,OAAM;QACtB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE;YAClC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YAC9B,KAAK,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE;gBACxC,GAAG,CAAC,KAAK,CAAC,CAAA;aACX;YACD,IAAI,IAAA,wBAAU,EAAC,IAAI,CAAC,UAAU,CAAC,EAAE;gBAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;gBACjB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;gBAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;aACnB;SACF;IACH,CAAC;CACF;AAxBD,wCAwBC;AAED,SAAgB,YAAY,CAAM,KAAuB;IACvD,OAAO,IAAI,cAAc,CAAC,KAAK,CAAC,CAAA;AAClC,CAAC;AAFD,oCAEC"}
|