@txstate-mws/svelte-components 1.2.10 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/glue.d.ts +1 -1
- package/actions/index.d.ts +1 -0
- package/actions/index.js +1 -0
- package/actions/passactions.d.ts +10 -0
- package/actions/passactions.js +36 -0
- package/components/Card.svelte +3 -2
- package/components/Card.svelte.d.ts +2 -0
- package/components/CardLayout.svelte +3 -2
- package/components/CardLayout.svelte.d.ts +2 -0
- package/components/PopupMenu.svelte +5 -4
- package/components/PopupMenu.svelte.d.ts +1 -0
- package/package.json +7 -6
package/actions/glue.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export interface GlueAlignStore {
|
|
|
11
11
|
halign: 'left' | 'right';
|
|
12
12
|
}
|
|
13
13
|
export declare function glue(el: HTMLElement, { target, align, cover, store }: GlueArgs): {
|
|
14
|
-
update({ target
|
|
14
|
+
update({ target, align, cover, store }: GlueArgs): void;
|
|
15
15
|
destroy: () => void;
|
|
16
16
|
};
|
package/actions/index.d.ts
CHANGED
package/actions/index.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface SvelteActionReturnType<P> {
|
|
2
|
+
update?: (newParams: P) => void;
|
|
3
|
+
destroy?: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare type SvelteHTMLActionType<P = any> = (node: HTMLElement, params?: P) => SvelteActionReturnType<P> | undefined;
|
|
6
|
+
export declare type HTMLActionEntry<P extends any = any> = SvelteHTMLActionType<P> | [SvelteHTMLActionType<P>, P];
|
|
7
|
+
export declare type SvelteSVGActionType<P = any> = (node: SVGElement, params?: P) => SvelteActionReturnType<P> | undefined;
|
|
8
|
+
export declare type SVGActionEntry<P extends any = any> = SvelteSVGActionType<P> | [SvelteSVGActionType<P>, P];
|
|
9
|
+
export declare function passActions(node: HTMLElement, actions: HTMLActionEntry[]): SvelteActionReturnType<HTMLActionEntry[]>;
|
|
10
|
+
export declare function passActions(node: SVGElement, actions: SVGActionEntry[]): SvelteActionReturnType<SVGActionEntry[]>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { toArray } from 'txstate-utils';
|
|
2
|
+
export function passActions(node, actions) {
|
|
3
|
+
let actionReturns = new Map();
|
|
4
|
+
for (const actionEntry of actions ?? []) {
|
|
5
|
+
const [action, params] = toArray(actionEntry);
|
|
6
|
+
actionReturns.set(action, action(node, params));
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
update(actions) {
|
|
10
|
+
const newActionReturns = new Map();
|
|
11
|
+
// accept new actions and update actions we already had
|
|
12
|
+
for (const actionEntry of actions ?? []) {
|
|
13
|
+
const [action, params] = toArray(actionEntry);
|
|
14
|
+
if (actionReturns.has(action)) {
|
|
15
|
+
const existing = actionReturns.get(action);
|
|
16
|
+
newActionReturns.set(action, existing);
|
|
17
|
+
existing?.update?.(params);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
newActionReturns.set(action, action(node, params));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// destroy any actions that were removed
|
|
24
|
+
for (const [action, actionReturn] of actionReturns.entries()) {
|
|
25
|
+
if (!newActionReturns.has(action))
|
|
26
|
+
actionReturn?.destroy?.();
|
|
27
|
+
}
|
|
28
|
+
actionReturns = newActionReturns;
|
|
29
|
+
},
|
|
30
|
+
destroy() {
|
|
31
|
+
for (const actionReturn of actionReturns.values()) {
|
|
32
|
+
actionReturn?.destroy?.();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
package/components/Card.svelte
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
<script>export let className = '';
|
|
2
2
|
import { getContext } from 'svelte';
|
|
3
|
-
import { resize } from '../actions';
|
|
3
|
+
import { resize, passActions } from '../actions';
|
|
4
4
|
import { CARDLAYOUT } from '../types';
|
|
5
|
+
export let use = [];
|
|
5
6
|
const block = { element: undefined };
|
|
6
7
|
const { registerBlock, gutter, recalculate } = getContext(CARDLAYOUT);
|
|
7
8
|
const { width, order, linebreak } = registerBlock(block);
|
|
8
9
|
</script>
|
|
9
10
|
|
|
10
|
-
<li class="cardlayout-card {className}" bind:this={block.element} use:resize on:resize={recalculate} style="margin-bottom: {$gutter}px; width: {$width}; order: {$order};">
|
|
11
|
+
<li class="cardlayout-card {className}" bind:this={block.element} use:passActions={use} use:resize on:resize={recalculate} style="margin-bottom: {$gutter}px; width: {$width}; order: {$order};">
|
|
11
12
|
<slot></slot>
|
|
12
13
|
</li>
|
|
13
14
|
{#if $linebreak}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<script>import { onDestroy, tick, setContext, onMount } from 'svelte';
|
|
2
2
|
import { writable } from 'svelte/store';
|
|
3
|
-
import { resize } from '../actions';
|
|
3
|
+
import { resize, passActions } from '../actions';
|
|
4
4
|
import { CARDLAYOUT } from '../types';
|
|
5
5
|
export let maxwidth = 500;
|
|
6
6
|
export let preserveorder = false;
|
|
7
7
|
export let gutter = 10;
|
|
8
8
|
export let className = '';
|
|
9
|
+
export let use = [];
|
|
9
10
|
const ssr = typeof navigator === 'undefined' || navigator.userAgent.includes('jsdom');
|
|
10
11
|
const blocks = [];
|
|
11
12
|
const gutterstore = writable(gutter);
|
|
@@ -177,7 +178,7 @@ function onResize(e) {
|
|
|
177
178
|
onMount(() => triggerrecalc(layoutelement.clientWidth));
|
|
178
179
|
</script>
|
|
179
180
|
|
|
180
|
-
<ul class="cardlayout {className}" class:ssr style:height={ssr ? undefined : `${fullheight + gutter}px`} bind:this={layoutelement} use:resize on:resize={onResize}>
|
|
181
|
+
<ul class="cardlayout {className}" class:ssr style:height={ssr ? undefined : `${fullheight + gutter}px`} bind:this={layoutelement} use:resize on:resize={onResize} use:passActions={use}>
|
|
181
182
|
<slot></slot>
|
|
182
183
|
</ul>
|
|
183
184
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { type HTMLActionEntry } from '../actions';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
maxwidth?: number;
|
|
5
6
|
preserveorder?: boolean;
|
|
6
7
|
gutter?: number;
|
|
7
8
|
className?: string;
|
|
9
|
+
use?: HTMLActionEntry[];
|
|
8
10
|
};
|
|
9
11
|
events: {
|
|
10
12
|
[evt: string]: CustomEvent<any>;
|
|
@@ -22,9 +22,9 @@ export let usePortal = undefined;
|
|
|
22
22
|
export let emptyText = undefined;
|
|
23
23
|
export let value = undefined;
|
|
24
24
|
export let hilited = undefined;
|
|
25
|
+
export let menuid = randomid();
|
|
25
26
|
let menuelement;
|
|
26
27
|
const itemelements = [];
|
|
27
|
-
const menuid = randomid();
|
|
28
28
|
let firstactive = 0;
|
|
29
29
|
let lastactive = items.length - 1;
|
|
30
30
|
function hiddenItem(item) {
|
|
@@ -207,15 +207,16 @@ $: hasSelected = showSelected && items.some(itm => itm.value === value);
|
|
|
207
207
|
on:click={onclick(item)}
|
|
208
208
|
role="option"
|
|
209
209
|
tabindex=-1
|
|
210
|
+
aria-selected={value === item.value}
|
|
210
211
|
aria-disabled={item.disabled}
|
|
211
212
|
><slot {item} label={item.label || item.value} hilited={i === hilited} selected={value === item.value}>{item.label || item.value}</slot></li>
|
|
212
213
|
{/if}
|
|
213
214
|
{/each}
|
|
214
215
|
{#if items.length === 0}
|
|
215
|
-
<li role="option" class={`${menuItemClass} disabled`} aria-live="assertive">
|
|
216
|
+
<li role="option" class={`${menuItemClass} disabled`} aria-live="assertive" aria-selected={false}>
|
|
216
217
|
<slot name="noresults">
|
|
217
218
|
{#if !emptyText}
|
|
218
|
-
<span aria-hidden="true">{'¯\\_(ツ)_/¯'}</span><ScreenReaderOnly>{emptyText || '
|
|
219
|
+
<span aria-hidden="true">{'¯\\_(ツ)_/¯'}</span><ScreenReaderOnly>{emptyText || 'no results found'}</ScreenReaderOnly>
|
|
219
220
|
{:else}
|
|
220
221
|
{emptyText}
|
|
221
222
|
{/if}
|
|
@@ -229,7 +230,7 @@ $: hasSelected = showSelected && items.some(itm => itm.value === value);
|
|
|
229
230
|
<style>
|
|
230
231
|
div {
|
|
231
232
|
position: absolute !important;
|
|
232
|
-
z-index: var(--popup-z, calc(var(--modal-z) + 1));
|
|
233
|
+
z-index: var(--popup-z, calc(var(--modal-z, 3000) + 1));
|
|
233
234
|
}
|
|
234
235
|
ul {
|
|
235
236
|
list-style: none;
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@txstate-mws/svelte-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Svelte components that are generically useful.",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@txstate-mws/svelte-store": "^1.0.3",
|
|
7
|
-
"tabbable": "^
|
|
8
|
-
"txstate-utils": "^1.6
|
|
7
|
+
"tabbable": "^6.0.0",
|
|
8
|
+
"txstate-utils": "^1.7.6"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@playwright/test": "^1.18.1",
|
|
12
12
|
"@sveltejs/adapter-auto": "next",
|
|
13
13
|
"@sveltejs/kit": "next",
|
|
14
|
-
"@sveltejs/package": "next",
|
|
14
|
+
"@sveltejs/package": "1.0.0-next.3",
|
|
15
15
|
"@types/tabbable": "^3.1.2",
|
|
16
|
-
"eslint-config-standard-with-typescript": "^
|
|
17
|
-
"eslint-plugin-svelte3": "^
|
|
16
|
+
"eslint-config-standard-with-typescript": "^23.0.0",
|
|
17
|
+
"eslint-plugin-svelte3": "^4.0.0",
|
|
18
18
|
"svelte": "^3.44.0",
|
|
19
19
|
"svelte-check": "^2.2.6",
|
|
20
20
|
"svelte-preprocess": "^4.9.4",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"./actions/glue": "./actions/glue.js",
|
|
37
37
|
"./actions": "./actions/index.js",
|
|
38
38
|
"./actions/offset": "./actions/offset.js",
|
|
39
|
+
"./actions/passactions": "./actions/passactions.js",
|
|
39
40
|
"./actions/portal": "./actions/portal.js",
|
|
40
41
|
"./actions/resize": "./actions/resize.js",
|
|
41
42
|
"./actions/sticky": "./actions/sticky.js",
|