@txstate-mws/svelte-components 1.4.4 → 1.4.6
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 +27 -16
- package/dist/actions/elementqueries.js +2 -2
- package/dist/actions/passactions.d.ts +2 -2
- package/dist/actions/resize.d.ts +1 -1
- package/dist/actions/resize.js +4 -2
- package/dist/components/FocusLock.svelte +3 -3
- package/dist/components/FocusLock.svelte.d.ts +3 -3
- package/dist/components/Modal.svelte +4 -4
- package/dist/components/Modal.svelte.d.ts +3 -3
- package/dist/components/MultiSelect.svelte +3 -3
- package/dist/components/MultiSelect.svelte.d.ts +1 -0
- package/dist/components/PopupMenu.svelte +15 -11
- package/dist/components/PopupMenu.svelte.d.ts +10 -10
- package/dist/components/ScreenReaderOnly.svelte +14 -0
- package/dist/components/ScreenReaderOnly.svelte.d.ts +14 -0
- package/dist/types/CardLayout.d.ts +16 -0
- package/dist/types/CollapsingTable.d.ts +3 -0
- package/dist/types/PopupMenu.d.ts +3 -0
- package/dist/util/util.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
# svelte-components
|
|
2
|
-
A set of generically useful components for svelte.
|
|
3
|
-
|
|
4
|
-
## Components
|
|
5
|
-
|
|
6
|
-
- [
|
|
7
|
-
- [
|
|
8
|
-
- [
|
|
9
|
-
- [
|
|
10
|
-
- [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- [
|
|
14
|
-
- [
|
|
15
|
-
- [
|
|
16
|
-
- [
|
|
17
|
-
|
|
2
|
+
A set of generically useful components and related `use:` actions for svelte.
|
|
3
|
+
|
|
4
|
+
## `<Components>`
|
|
5
|
+
*Italicized entries* point to source only (no .md file).
|
|
6
|
+
- *[Card](./src/lib/components/Card.svelte)*
|
|
7
|
+
- *[CardLayout](./src/lib/components/CardLayout.svelte)*
|
|
8
|
+
- [CollapsingTable](./docs/CollapsingTable.md)
|
|
9
|
+
- [ConditionalWrapper](./docs/ConditionalWrapper.md)
|
|
10
|
+
- [FocusLock](./docs/Modal.md#FocusLock)
|
|
11
|
+
- *[Loading](./src/lib/components/Loading.svelte)*
|
|
12
|
+
- *[Lottie](./src/lib/components/Lottie.svelte)*
|
|
13
|
+
- [Modal](./docs/Modal.md#Modal)
|
|
14
|
+
- *[MultiSelect](./src/lib/components/MultiSelect.svelte)*
|
|
15
|
+
- [PopupMenu](./docs/PopupMenu.md)
|
|
16
|
+
- [ScreenReaderOnly](./docs/ScreenReaderOnly.md)
|
|
17
|
+
|
|
18
|
+
## `use:` Actions
|
|
19
|
+
*Italicized entries* point to source only (no .md file).
|
|
20
|
+
- [buttonify](./docs/actions.md#buttonify)
|
|
21
|
+
- *[elementqueries](./src/lib/actions/elementqueries.ts)*
|
|
22
|
+
- [glue](./docs/actions.md#glue)
|
|
23
|
+
- [offset](./docs/actions.md#offset)
|
|
24
|
+
- *[passActions](./src/lib/actions/passactions.ts)*
|
|
25
|
+
- [portal](./docs/actions.md#portal)
|
|
26
|
+
- [resize](./docs/actions.md#resize)
|
|
27
|
+
- *[sticky](./src/lib/actions/sticky.ts)*
|
|
28
|
+
- *[stickyfixed](./src/lib/actions/stickyfixed.ts)*
|
|
18
29
|
|
|
19
30
|
## Developing
|
|
20
31
|
|
|
@@ -65,7 +65,7 @@ class ElementQueries {
|
|
|
65
65
|
const m = document.location.hash.match(/^#([a-z][\w:.-]*)$/i);
|
|
66
66
|
if (m) {
|
|
67
67
|
const id = m[1];
|
|
68
|
-
requestAnimationFrame(() => document.getElementById(id) || document.querySelector(`[name="${id}"]`).scrollIntoView(true));
|
|
68
|
+
requestAnimationFrame(() => { document.getElementById(id) || document.querySelector(`[name="${id}"]`).scrollIntoView(true); });
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
fullresync() {
|
|
@@ -75,7 +75,7 @@ class ElementQueries {
|
|
|
75
75
|
#activate() {
|
|
76
76
|
this.fullresync();
|
|
77
77
|
window.addEventListener('resize', this.#boundRefresh);
|
|
78
|
-
this.#mutationobserver = new MutationObserver(() => this.fullresync());
|
|
78
|
+
this.#mutationobserver = new MutationObserver(() => { this.fullresync(); });
|
|
79
79
|
this.#mutationobserver.observe(document.body, {
|
|
80
80
|
subtree: true,
|
|
81
81
|
childList: true,
|
|
@@ -3,8 +3,8 @@ export interface SvelteActionReturnType<P> {
|
|
|
3
3
|
destroy?: () => void;
|
|
4
4
|
}
|
|
5
5
|
export type SvelteHTMLActionType<P = any> = (node: HTMLElement, params?: P) => SvelteActionReturnType<P> | undefined;
|
|
6
|
-
export type HTMLActionEntry<P
|
|
6
|
+
export type HTMLActionEntry<P = any> = SvelteHTMLActionType<P> | [SvelteHTMLActionType<P>, P];
|
|
7
7
|
export type SvelteSVGActionType<P = any> = (node: SVGElement, params?: P) => SvelteActionReturnType<P> | undefined;
|
|
8
|
-
export type SVGActionEntry<P
|
|
8
|
+
export type SVGActionEntry<P = any> = SvelteSVGActionType<P> | [SvelteSVGActionType<P>, P];
|
|
9
9
|
export declare function passActions(node: HTMLElement, actions: HTMLActionEntry[]): SvelteActionReturnType<HTMLActionEntry[]>;
|
|
10
10
|
export declare function passActions(node: SVGElement, actions: SVGActionEntry[]): SvelteActionReturnType<SVGActionEntry[]>;
|
package/dist/actions/resize.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ interface ResizeConfig {
|
|
|
13
13
|
export declare class ResizeStore extends Store<ElementSize> {
|
|
14
14
|
constructor(initialState?: ElementSize);
|
|
15
15
|
}
|
|
16
|
-
export declare function resize(el: HTMLElement, config?: ResizeConfig):
|
|
16
|
+
export declare function resize(el: HTMLElement, config?: ResizeConfig): {
|
|
17
17
|
update(newConfig?: ResizeConfig): void;
|
|
18
18
|
destroy(): void;
|
|
19
19
|
};
|
package/dist/actions/resize.js
CHANGED
|
@@ -31,8 +31,10 @@ export function resize(el, config) {
|
|
|
31
31
|
el.dispatchEvent(new CustomEvent('resize', { detail: current }));
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
if (typeof ResizeObserver === 'undefined')
|
|
35
|
-
|
|
34
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
35
|
+
watch();
|
|
36
|
+
return;
|
|
37
|
+
} // support SSR
|
|
36
38
|
let observer = new ResizeObserver(config?.debounce ? debounced(watch, config.debounce) : watch);
|
|
37
39
|
observer.observe(el);
|
|
38
40
|
watch();
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
const waitAtick = typeof requestAnimationFrame !== 'undefined' ? resolve => requestAnimationFrame(resolve) : resolve => resolve(0);
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
|
-
<script>export let
|
|
6
|
-
export let initialfocus = undefined;
|
|
5
|
+
<script>export let escapable = true;
|
|
7
6
|
export let hidefocus = true;
|
|
8
7
|
export let hidefocuslabel = 'focus is above modal dialog, start tabbing';
|
|
9
|
-
export let
|
|
8
|
+
export let initialfocus = undefined;
|
|
9
|
+
export let returnfocusto = undefined;
|
|
10
10
|
/**
|
|
11
11
|
* If you expect any popup menus to be added to the body, we need to know that they
|
|
12
12
|
* are considered to be part of the focus lock, or else the modal will be dismissed
|
|
@@ -5,11 +5,11 @@ export declare const FocusLockStack: {
|
|
|
5
5
|
}[];
|
|
6
6
|
declare const __propDef: {
|
|
7
7
|
props: {
|
|
8
|
-
|
|
9
|
-
initialfocus?: string | undefined;
|
|
8
|
+
escapable?: boolean;
|
|
10
9
|
hidefocus?: boolean;
|
|
11
10
|
hidefocuslabel?: string;
|
|
12
|
-
|
|
11
|
+
initialfocus?: string | undefined;
|
|
12
|
+
returnfocusto?: HTMLElement | null | undefined;
|
|
13
13
|
/**
|
|
14
14
|
* If you expect any popup menus to be added to the body, we need to know that they
|
|
15
15
|
* are considered to be part of the focus lock, or else the modal will be dismissed
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script>export let
|
|
1
|
+
<script>export let opaque = false;
|
|
2
|
+
export let containerClass = '';
|
|
3
|
+
export let escapable = true;
|
|
2
4
|
export let hidefocus = true;
|
|
3
5
|
export let hidefocuslabel = undefined;
|
|
4
|
-
export let returnfocusto = undefined;
|
|
5
6
|
export let initialfocus = undefined;
|
|
6
|
-
export let
|
|
7
|
-
export let opaque = false;
|
|
7
|
+
export let returnfocusto = undefined;
|
|
8
8
|
export let usePortal = undefined;
|
|
9
9
|
/**
|
|
10
10
|
* If you expect any popup menus to be added to the body, we need to know that they
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
|
+
opaque?: boolean;
|
|
5
|
+
containerClass?: string;
|
|
4
6
|
escapable?: boolean;
|
|
5
7
|
hidefocus?: boolean;
|
|
6
8
|
hidefocuslabel?: string | undefined;
|
|
7
|
-
returnfocusto?: HTMLElement | undefined;
|
|
8
9
|
initialfocus?: string | undefined;
|
|
9
|
-
|
|
10
|
-
opaque?: boolean;
|
|
10
|
+
returnfocusto?: HTMLElement | undefined;
|
|
11
11
|
usePortal?: HTMLElement | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* If you expect any popup menus to be added to the body, we need to know that they
|
|
@@ -16,6 +16,7 @@ export let selected = [];
|
|
|
16
16
|
export let placeholder = '';
|
|
17
17
|
export let emptyText = undefined;
|
|
18
18
|
export let usePortal = undefined;
|
|
19
|
+
export let descid = undefined;
|
|
19
20
|
export let PopupMenu = DefaultPopupMenu;
|
|
20
21
|
let menushown;
|
|
21
22
|
let loading = false;
|
|
@@ -24,7 +25,6 @@ let hilitedpill;
|
|
|
24
25
|
let inputvalue = '';
|
|
25
26
|
let popupvalue = undefined;
|
|
26
27
|
let inputelement;
|
|
27
|
-
const descriptionid = randomid();
|
|
28
28
|
const dispatch = createEventDispatcher();
|
|
29
29
|
const optionsCache = new Cache(async (ipt) => {
|
|
30
30
|
return await getOptions(ipt);
|
|
@@ -132,10 +132,10 @@ $: reactToHilite(hilitedpill, id);
|
|
|
132
132
|
bind:this={inputelement} bind:value={inputvalue} on:blur
|
|
133
133
|
on:focus={inputfocus} on:keydown={inputkeydown}
|
|
134
134
|
autocomplete="off" autocorrect="off" spellcheck="false" aria-autocomplete="list"
|
|
135
|
-
aria-describedby=
|
|
135
|
+
aria-describedby={descid}>
|
|
136
136
|
</li>
|
|
137
137
|
</ul>
|
|
138
|
-
<ScreenReaderOnly
|
|
138
|
+
<ScreenReaderOnly arialive="assertive">
|
|
139
139
|
<span>{selected.length ? selected.length + ' selected' : 'none selected'}, select {maxSelections ? 'up to ' + maxSelections : 'multiple'}, up down to choose, left right to hilite existing choices</span>
|
|
140
140
|
{#if menushown}<span>{availablemessage}, touch users explore to find autocomplete menu</span>{/if}
|
|
141
141
|
</ScreenReaderOnly>
|
|
@@ -5,26 +5,26 @@ import { glue, portal } from '../actions';
|
|
|
5
5
|
import ScreenReaderOnly from './ScreenReaderOnly.svelte';
|
|
6
6
|
import { modifierKey } from '../util';
|
|
7
7
|
const dispatch = createEventDispatcher();
|
|
8
|
-
export let menushown = false;
|
|
9
|
-
export let menuContainerClass = '';
|
|
10
|
-
export let menuClass = '';
|
|
11
|
-
export let menuItemClass = '';
|
|
12
|
-
export let menuItemHilitedClass = '';
|
|
13
|
-
export let menuItemSelectedClass = '';
|
|
14
|
-
export let items = [];
|
|
15
8
|
export let buttonelement;
|
|
9
|
+
export let items = [];
|
|
10
|
+
export let menushown = false;
|
|
11
|
+
export let value = undefined;
|
|
16
12
|
export let align = 'auto';
|
|
17
13
|
export let cover = false;
|
|
18
14
|
export let showSelected = true;
|
|
19
15
|
export let width = undefined;
|
|
20
16
|
export let computedalign = new Store({ valign: 'bottom', halign: 'left' });
|
|
21
17
|
export let adjustparentheight = false;
|
|
22
|
-
export let loading = false;
|
|
23
18
|
export let usePortal = undefined;
|
|
24
|
-
export let
|
|
25
|
-
export let value = undefined;
|
|
19
|
+
export let loading = false;
|
|
26
20
|
export let hilited = undefined;
|
|
27
21
|
export let menuid = randomid();
|
|
22
|
+
export let emptyText = undefined;
|
|
23
|
+
export let menuContainerClass = '';
|
|
24
|
+
export let menuClass = '';
|
|
25
|
+
export let menuItemClass = '';
|
|
26
|
+
export let menuItemHilitedClass = '';
|
|
27
|
+
export let menuItemSelectedClass = '';
|
|
28
28
|
let menuelement;
|
|
29
29
|
const itemelements = [];
|
|
30
30
|
let firstactive = 0;
|
|
@@ -47,13 +47,17 @@ async function reactToMenuShown(_) {
|
|
|
47
47
|
await tick();
|
|
48
48
|
if (!menushown) {
|
|
49
49
|
buttonelement.removeAttribute('aria-controls');
|
|
50
|
+
buttonelement.removeAttribute('aria-owns');
|
|
50
51
|
buttonelement.setAttribute('aria-expanded', 'false');
|
|
51
52
|
if (hilited)
|
|
52
53
|
buttonelement.removeAttribute('aria-activedescendant');
|
|
53
54
|
hilited = undefined;
|
|
54
55
|
}
|
|
55
56
|
else {
|
|
56
|
-
buttonelement
|
|
57
|
+
if (buttonelement instanceof HTMLInputElement)
|
|
58
|
+
buttonelement.setAttribute('aria-owns', menuid);
|
|
59
|
+
else
|
|
60
|
+
buttonelement.setAttribute('aria-controls', menuid);
|
|
57
61
|
buttonelement.setAttribute('aria-expanded', 'true');
|
|
58
62
|
if (buttonelement !== document.activeElement)
|
|
59
63
|
buttonelement.focus();
|
|
@@ -4,26 +4,26 @@ import type { GlueAlignOpts, GlueAlignStore } from '../actions';
|
|
|
4
4
|
import type { PopupMenuItem } from '../types';
|
|
5
5
|
declare const __propDef: {
|
|
6
6
|
props: {
|
|
7
|
-
menushown?: boolean;
|
|
8
|
-
menuContainerClass?: string;
|
|
9
|
-
menuClass?: string;
|
|
10
|
-
menuItemClass?: string;
|
|
11
|
-
menuItemHilitedClass?: string;
|
|
12
|
-
menuItemSelectedClass?: string;
|
|
13
|
-
items?: PopupMenuItem[];
|
|
14
7
|
buttonelement: HTMLElement;
|
|
8
|
+
items?: PopupMenuItem[];
|
|
9
|
+
menushown?: boolean;
|
|
10
|
+
value?: string | undefined;
|
|
15
11
|
align?: GlueAlignOpts;
|
|
16
12
|
cover?: boolean;
|
|
17
13
|
showSelected?: boolean;
|
|
18
14
|
width?: string | undefined;
|
|
19
15
|
computedalign?: Store<GlueAlignStore>;
|
|
20
16
|
adjustparentheight?: boolean;
|
|
21
|
-
loading?: boolean;
|
|
22
17
|
usePortal?: HTMLElement | true | undefined;
|
|
23
|
-
|
|
24
|
-
value?: string | undefined;
|
|
18
|
+
loading?: boolean;
|
|
25
19
|
hilited?: number | undefined;
|
|
26
20
|
menuid?: string;
|
|
21
|
+
emptyText?: string | undefined;
|
|
22
|
+
menuContainerClass?: string;
|
|
23
|
+
menuClass?: string;
|
|
24
|
+
menuItemClass?: string;
|
|
25
|
+
menuItemHilitedClass?: string;
|
|
26
|
+
menuItemSelectedClass?: string;
|
|
27
27
|
};
|
|
28
28
|
events: {
|
|
29
29
|
change: CustomEvent<any>;
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
This component is for adding text that can be read by screen readers while remaining invisible to regular users.
|
|
3
|
+
```svelte
|
|
4
|
+
<ScreenReaderOnly {id} {arialive} {ariaatomic}>
|
|
5
|
+
{`Some descriptive text to be read about the component by screen readers.`}
|
|
6
|
+
</ScreenReaderOnly>
|
|
7
|
+
```
|
|
8
|
+
#### Properties
|
|
9
|
+
```ts
|
|
10
|
+
id?: string|undefined = undefined // Any ID you'd like to bind to the underlying <span>.
|
|
11
|
+
arialive?: 'off'|'assertive'|'polite'|undefined = undefined
|
|
12
|
+
ariaatomic?: boolean|'false'|'true'|undefined = undefined
|
|
13
|
+
```
|
|
14
|
+
-->
|
|
1
15
|
<script>export let id = undefined;
|
|
2
16
|
export let arialive = undefined;
|
|
3
17
|
export let ariaatomic = undefined;
|
|
@@ -15,6 +15,20 @@ declare const __propDef: {
|
|
|
15
15
|
export type ScreenReaderOnlyProps = typeof __propDef.props;
|
|
16
16
|
export type ScreenReaderOnlyEvents = typeof __propDef.events;
|
|
17
17
|
export type ScreenReaderOnlySlots = typeof __propDef.slots;
|
|
18
|
+
/**
|
|
19
|
+
* This component is for adding text that can be read by screen readers while remaining invisible to regular users.
|
|
20
|
+
* ```svelte
|
|
21
|
+
* <ScreenReaderOnly {id} {arialive} {ariaatomic}>
|
|
22
|
+
* {`Some descriptive text to be read about the component by screen readers.`}
|
|
23
|
+
* </ScreenReaderOnly>
|
|
24
|
+
* ```
|
|
25
|
+
* #### Properties
|
|
26
|
+
* ```ts
|
|
27
|
+
* id?: string|undefined = undefined // Any ID you'd like to bind to the underlying <span>.
|
|
28
|
+
* arialive?: 'off'|'assertive'|'polite'|undefined = undefined
|
|
29
|
+
* ariaatomic?: boolean|'false'|'true'|undefined = undefined
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
18
32
|
export default class ScreenReaderOnly extends SvelteComponentTyped<ScreenReaderOnlyProps, ScreenReaderOnlyEvents, ScreenReaderOnlySlots> {
|
|
19
33
|
}
|
|
20
34
|
export {};
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { SettableSubject } from '@txstate-mws/svelte-store';
|
|
2
2
|
export declare const CARDLAYOUT: {};
|
|
3
|
+
/**
|
|
4
|
+
```ts
|
|
5
|
+
{ element: HTMLElement
|
|
6
|
+
order?: SettableSubject<number>
|
|
7
|
+
linebreak?: SettableSubject<boolean>
|
|
8
|
+
width?: SettableSubject<string>
|
|
9
|
+
height?: number
|
|
10
|
+
}
|
|
11
|
+
``` */
|
|
3
12
|
export interface Block {
|
|
4
13
|
element: HTMLElement;
|
|
5
14
|
order?: SettableSubject<number>;
|
|
@@ -7,6 +16,13 @@ export interface Block {
|
|
|
7
16
|
width?: SettableSubject<string>;
|
|
8
17
|
height?: number;
|
|
9
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
```ts
|
|
21
|
+
{ registerBlock: (block: Block) => Block
|
|
22
|
+
recalculate: () => void
|
|
23
|
+
gutter: SettableSubject<number>
|
|
24
|
+
}
|
|
25
|
+
``` */
|
|
10
26
|
export interface CardLayoutContext {
|
|
11
27
|
registerBlock: (block: Block) => Block;
|
|
12
28
|
recalculate: () => void;
|
package/dist/util/util.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function classes(...classNames: (string | undefined)[]): string;
|
|
2
|
-
export declare function debounced(fn:
|
|
2
|
+
export declare function debounced(fn: (..._: any[]) => any, timeout: number): (...args: any[]) => void;
|
|
3
3
|
export declare function modifierKey(e: any): any;
|
|
4
4
|
export declare function selectionIsLeft(ele: HTMLInputElement | HTMLTextAreaElement): boolean;
|