@txstate-mws/svelte-components 1.3.6 → 1.3.7

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 CHANGED
@@ -1,16 +1,17 @@
1
1
  import type { SettableSubject } from '@txstate-mws/svelte-store';
2
- export declare type GlueAlignOpts = 'auto' | 'bottomleft' | 'bottomright' | 'topleft' | 'topright';
2
+ export type GlueAlignOpts = 'auto' | 'bottomleft' | 'bottomright' | 'topleft' | 'topright';
3
3
  export interface GlueArgs<T extends GlueAlignStore = GlueAlignStore> {
4
4
  target: HTMLElement;
5
5
  align?: GlueAlignOpts;
6
6
  cover?: boolean;
7
+ adjustparentheight?: boolean;
7
8
  store?: SettableSubject<T>;
8
9
  }
9
10
  export interface GlueAlignStore {
10
11
  valign: 'bottom' | 'top';
11
12
  halign: 'left' | 'right';
12
13
  }
13
- export declare function glue(el: HTMLElement, { target, align, cover, store }: GlueArgs): {
14
+ export declare function glue(el: HTMLElement, { target, align, cover, adjustparentheight, store }: GlueArgs): {
14
15
  update({ target: utarget, align: ualign, cover: ucover, store: ustore }: GlueArgs): void;
15
- destroy: () => void;
16
+ destroy(): void;
16
17
  };
package/actions/glue.js CHANGED
@@ -1,12 +1,14 @@
1
1
  import { sharedOffsetParent, targetOffset, watchForPositionChangeInContainer } from '../util/index.js';
2
2
  let setBodyRelative = false;
3
- export function glue(el, { target, align = 'auto', cover = false, store }) {
3
+ export function glue(el, { target, align = 'auto', cover = false, adjustparentheight = false, store }) {
4
4
  if (!setBodyRelative) {
5
5
  setBodyRelative = true;
6
6
  document.body.style.position = 'relative';
7
7
  }
8
8
  let halign;
9
9
  let valign;
10
+ const parent = el.offsetParent;
11
+ const formerMinHeight = parent.style.minHeight;
10
12
  let sharedOffset = sharedOffsetParent(el, target);
11
13
  function reposition(offset) {
12
14
  if (!target || !sharedOffset || !(el.offsetParent instanceof HTMLElement))
@@ -19,6 +21,18 @@ export function glue(el, { target, align = 'auto', cover = false, store }) {
19
21
  const topbottom = window.innerHeight - rect.bottom > rect.top ? 'bottom' : 'top';
20
22
  autoalign = topbottom + leftright;
21
23
  }
24
+ function adjustParentHeight() {
25
+ if (!adjustparentheight)
26
+ return;
27
+ if (parent.style.overflowY === 'auto')
28
+ return;
29
+ const minHeight = el.offsetTop + el.offsetHeight;
30
+ if (minHeight > parent.clientHeight) {
31
+ requestAnimationFrame(() => {
32
+ parent.style.minHeight = String(minHeight) + 'px';
33
+ });
34
+ }
35
+ }
22
36
  const targetHeight = target.offsetHeight;
23
37
  if (autoalign === 'bottomleft') {
24
38
  requestAnimationFrame(() => {
@@ -26,6 +40,7 @@ export function glue(el, { target, align = 'auto', cover = false, store }) {
26
40
  el.style.left = `${offset.left - parentoffset.left}px`;
27
41
  el.style.bottom = '';
28
42
  el.style.right = '';
43
+ adjustParentHeight();
29
44
  });
30
45
  valign = 'bottom';
31
46
  halign = 'left';
@@ -36,6 +51,7 @@ export function glue(el, { target, align = 'auto', cover = false, store }) {
36
51
  el.style.left = '';
37
52
  el.style.bottom = '';
38
53
  el.style.right = `${offset.right - parentoffset.right}px`;
54
+ adjustParentHeight();
39
55
  });
40
56
  valign = 'bottom';
41
57
  halign = 'right';
@@ -46,6 +62,7 @@ export function glue(el, { target, align = 'auto', cover = false, store }) {
46
62
  el.style.left = `${offset.left - parentoffset.left}px`;
47
63
  el.style.bottom = `${offset.bottom + (cover ? 0 : targetHeight) - parentoffset.bottom}px`;
48
64
  el.style.right = '';
65
+ adjustParentHeight();
49
66
  });
50
67
  valign = 'top';
51
68
  halign = 'left';
@@ -56,13 +73,14 @@ export function glue(el, { target, align = 'auto', cover = false, store }) {
56
73
  el.style.left = '';
57
74
  el.style.bottom = `${offset.bottom + (cover ? 0 : targetHeight) - parentoffset.bottom}px`;
58
75
  el.style.right = `${offset.right - parentoffset.right}px`;
76
+ adjustParentHeight();
59
77
  });
60
78
  valign = 'top';
61
79
  halign = 'right';
62
80
  }
63
81
  store?.update(v => ({ ...v, valign, halign }));
64
82
  }
65
- const { destroy, update } = watchForPositionChangeInContainer(target, sharedOffset, reposition);
83
+ const { destroy: watchDestroy, update } = watchForPositionChangeInContainer(target, sharedOffset, reposition);
66
84
  return {
67
85
  update({ target: utarget, align: ualign = 'auto', cover: ucover = false, store: ustore }) {
68
86
  align = ualign;
@@ -77,6 +95,13 @@ export function glue(el, { target, align = 'auto', cover = false, store }) {
77
95
  update(target, sharedOffset, reposition);
78
96
  }
79
97
  },
80
- destroy
98
+ destroy() {
99
+ watchDestroy();
100
+ if (adjustparentheight) {
101
+ if (formerMinHeight)
102
+ parent.style.minHeight = formerMinHeight;
103
+ parent.style.removeProperty('min-height');
104
+ }
105
+ }
81
106
  };
82
107
  }
@@ -2,9 +2,9 @@ export interface SvelteActionReturnType<P> {
2
2
  update?: (newParams: P) => void;
3
3
  destroy?: () => void;
4
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];
5
+ export type SvelteHTMLActionType<P = any> = (node: HTMLElement, params?: P) => SvelteActionReturnType<P> | undefined;
6
+ export type HTMLActionEntry<P extends any = any> = SvelteHTMLActionType<P> | [SvelteHTMLActionType<P>, P];
7
+ export type SvelteSVGActionType<P = any> = (node: SVGElement, params?: P) => SvelteActionReturnType<P> | undefined;
8
+ export type SVGActionEntry<P extends any = 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[]>;
@@ -12,9 +12,9 @@ declare const __propDef: {
12
12
  default: {};
13
13
  };
14
14
  };
15
- export declare type CardProps = typeof __propDef.props;
16
- export declare type CardEvents = typeof __propDef.events;
17
- export declare type CardSlots = typeof __propDef.slots;
15
+ export type CardProps = typeof __propDef.props;
16
+ export type CardEvents = typeof __propDef.events;
17
+ export type CardSlots = typeof __propDef.slots;
18
18
  export default class Card extends SvelteComponentTyped<CardProps, CardEvents, CardSlots> {
19
19
  }
20
20
  export {};
@@ -15,9 +15,9 @@ declare const __propDef: {
15
15
  default: {};
16
16
  };
17
17
  };
18
- export declare type CardLayoutProps = typeof __propDef.props;
19
- export declare type CardLayoutEvents = typeof __propDef.events;
20
- export declare type CardLayoutSlots = typeof __propDef.slots;
18
+ export type CardLayoutProps = typeof __propDef.props;
19
+ export type CardLayoutEvents = typeof __propDef.events;
20
+ export type CardLayoutSlots = typeof __propDef.slots;
21
21
  export default class CardLayout extends SvelteComponentTyped<CardLayoutProps, CardLayoutEvents, CardLayoutSlots> {
22
22
  }
23
23
  export {};
@@ -51,9 +51,9 @@ declare const __propDef: {
51
51
  };
52
52
  };
53
53
  };
54
- export declare type CollapsingTableProps = typeof __propDef.props;
55
- export declare type CollapsingTableEvents = typeof __propDef.events;
56
- export declare type CollapsingTableSlots = typeof __propDef.slots;
54
+ export type CollapsingTableProps = typeof __propDef.props;
55
+ export type CollapsingTableEvents = typeof __propDef.events;
56
+ export type CollapsingTableSlots = typeof __propDef.slots;
57
57
  export default class CollapsingTable extends SvelteComponentTyped<CollapsingTableProps, CollapsingTableEvents, CollapsingTableSlots> {
58
58
  }
59
59
  export {};
@@ -15,9 +15,9 @@ declare const __propDef: {
15
15
  default: {};
16
16
  };
17
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;
18
+ export type ConditionalWrapperProps = typeof __propDef.props;
19
+ export type ConditionalWrapperEvents = typeof __propDef.events;
20
+ export type ConditionalWrapperSlots = typeof __propDef.slots;
21
21
  export default class ConditionalWrapper extends SvelteComponentTyped<ConditionalWrapperProps, ConditionalWrapperEvents, ConditionalWrapperSlots> {
22
22
  }
23
23
  export {};
@@ -19,9 +19,9 @@ declare const __propDef: {
19
19
  default: {};
20
20
  };
21
21
  };
22
- export declare type FocusLockProps = typeof __propDef.props;
23
- export declare type FocusLockEvents = typeof __propDef.events;
24
- export declare type FocusLockSlots = typeof __propDef.slots;
22
+ export type FocusLockProps = typeof __propDef.props;
23
+ export type FocusLockEvents = typeof __propDef.events;
24
+ export type FocusLockSlots = typeof __propDef.slots;
25
25
  export default class FocusLock extends SvelteComponentTyped<FocusLockProps, FocusLockEvents, FocusLockSlots> {
26
26
  }
27
27
  export {};
@@ -11,9 +11,9 @@ declare const __propDef: {
11
11
  default: {};
12
12
  };
13
13
  };
14
- export declare type LoadingProps = typeof __propDef.props;
15
- export declare type LoadingEvents = typeof __propDef.events;
16
- export declare type LoadingSlots = typeof __propDef.slots;
14
+ export type LoadingProps = typeof __propDef.props;
15
+ export type LoadingEvents = typeof __propDef.events;
16
+ export type LoadingSlots = typeof __propDef.slots;
17
17
  export default class Loading extends SvelteComponentTyped<LoadingProps, LoadingEvents, LoadingSlots> {
18
18
  }
19
19
  export {};
@@ -19,9 +19,9 @@ declare const __propDef: {
19
19
  default: {};
20
20
  };
21
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;
22
+ export type ModalProps = typeof __propDef.props;
23
+ export type ModalEvents = typeof __propDef.events;
24
+ export type ModalSlots = typeof __propDef.slots;
25
25
  export default class Modal extends SvelteComponentTyped<ModalProps, ModalEvents, ModalSlots> {
26
26
  }
27
27
  export {};
@@ -14,6 +14,7 @@ export let menuItemHilitedClass = undefined;
14
14
  export let selected = [];
15
15
  export let placeholder = '';
16
16
  export let emptyText = undefined;
17
+ export let usePortal = undefined;
17
18
  export let PopupMenu = DefaultPopupMenu;
18
19
  let menushown;
19
20
  let loading = false;
@@ -117,7 +118,7 @@ $: reactToHilite(hilitedpill, id);
117
118
  on:click|preventDefault|stopPropagation={() => !disabled && removeSelection(option, i, 1)} on:mousedown={e => disabled && e.preventDefault()}
118
119
  aria-selected="true">
119
120
  {option.label || option.value}
120
- <ScreenReaderOnly>, click to remove</ScreenReaderOnly>
121
+ <ScreenReaderOnly>, click to deselect</ScreenReaderOnly>
121
122
  </li>
122
123
  {/each}
123
124
  <li class="input">
@@ -134,7 +135,7 @@ $: reactToHilite(hilitedpill, id);
134
135
  </ScreenReaderOnly>
135
136
  <slot></slot>
136
137
  </fieldset>
137
- <svelte:component this={PopupMenu} bind:menushown bind:hilited={popuphilited} bind:value={popupvalue} align='bottomleft' {loading} {emptyText} {menuContainerClass} {menuClass} {menuItemClass} {menuItemHilitedClass} items={options} buttonelement={inputelement} on:change={addSelection}></svelte:component>
138
+ <svelte:component this={PopupMenu} bind:menushown bind:hilited={popuphilited} bind:value={popupvalue} align='bottomleft' {usePortal} {loading} {emptyText} {menuContainerClass} {menuClass} {menuItemClass} {menuItemHilitedClass} items={options} buttonelement={inputelement} on:change={addSelection}></svelte:component>
138
139
 
139
140
  <style>
140
141
  fieldset {
@@ -17,6 +17,7 @@ declare const __propDef: {
17
17
  }[];
18
18
  placeholder?: string;
19
19
  emptyText?: string | undefined;
20
+ usePortal?: HTMLElement | true | undefined;
20
21
  PopupMenu?: typeof DefaultPopupMenu;
21
22
  };
22
23
  events: {
@@ -29,9 +30,9 @@ declare const __propDef: {
29
30
  default: {};
30
31
  };
31
32
  };
32
- export declare type MultiSelectProps = typeof __propDef.props;
33
- export declare type MultiSelectEvents = typeof __propDef.events;
34
- export declare type MultiSelectSlots = typeof __propDef.slots;
33
+ export type MultiSelectProps = typeof __propDef.props;
34
+ export type MultiSelectEvents = typeof __propDef.events;
35
+ export type MultiSelectSlots = typeof __propDef.slots;
35
36
  export default class MultiSelect extends SvelteComponentTyped<MultiSelectProps, MultiSelectEvents, MultiSelectSlots> {
36
37
  }
37
38
  export {};
@@ -18,6 +18,7 @@ export let cover = false;
18
18
  export let showSelected = true;
19
19
  export let width = undefined;
20
20
  export let computedalign = new Store({ valign: 'bottom', halign: 'left' });
21
+ export let adjustparentheight = false;
21
22
  export let loading = false;
22
23
  export let usePortal = undefined;
23
24
  export let emptyText = undefined;
@@ -195,7 +196,7 @@ $: hasSelected = showSelected && items.some(itm => itm.value === value);
195
196
  </script>
196
197
 
197
198
  {#if menushown}
198
- <div use:portal={usePortal === true ? document.body : (usePortal || null)} use:glue={{ target: buttonelement, align, cover, store: computedalign }} class={menuContainerClass}>
199
+ <div use:portal={usePortal === true ? undefined : (usePortal || null)} use:glue={{ target: buttonelement, align, cover, adjustparentheight, store: computedalign }} class={menuContainerClass}>
199
200
  <ul bind:this={menuelement} id={menuid} role='listbox' style={width ? `width: ${width}` : ''} class={menuClass} class:hasSelected class:defaultmenu={!menuClass && !menuContainerClass} on:keydown={onkeydown}>
200
201
  {#each items as item, i (item.value)}
201
202
  {#if showSelected || item.value !== value}
@@ -17,6 +17,7 @@ declare const __propDef: {
17
17
  showSelected?: boolean;
18
18
  width?: string | undefined;
19
19
  computedalign?: Store<GlueAlignStore>;
20
+ adjustparentheight?: boolean;
20
21
  loading?: boolean;
21
22
  usePortal?: HTMLElement | true | undefined;
22
23
  emptyText?: string | undefined;
@@ -39,9 +40,9 @@ declare const __propDef: {
39
40
  noresults: {};
40
41
  };
41
42
  };
42
- export declare type PopupMenuProps = typeof __propDef.props;
43
- export declare type PopupMenuEvents = typeof __propDef.events;
44
- export declare type PopupMenuSlots = typeof __propDef.slots;
43
+ export type PopupMenuProps = typeof __propDef.props;
44
+ export type PopupMenuEvents = typeof __propDef.events;
45
+ export type PopupMenuSlots = typeof __propDef.slots;
45
46
  export default class PopupMenu extends SvelteComponentTyped<PopupMenuProps, PopupMenuEvents, PopupMenuSlots> {
46
47
  }
47
48
  export {};
@@ -12,9 +12,9 @@ declare const __propDef: {
12
12
  default: {};
13
13
  };
14
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;
15
+ export type ScreenReaderOnlyProps = typeof __propDef.props;
16
+ export type ScreenReaderOnlyEvents = typeof __propDef.events;
17
+ export type ScreenReaderOnlySlots = typeof __propDef.slots;
18
18
  export default class ScreenReaderOnly extends SvelteComponentTyped<ScreenReaderOnlyProps, ScreenReaderOnlyEvents, ScreenReaderOnlySlots> {
19
19
  }
20
20
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@txstate-mws/svelte-components",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "description": "Svelte components that are generically useful.",
5
5
  "dependencies": {
6
6
  "@txstate-mws/svelte-store": "^1.0.3",
@@ -9,16 +9,16 @@
9
9
  },
10
10
  "devDependencies": {
11
11
  "@playwright/test": "^1.18.1",
12
- "@sveltejs/adapter-auto": "next",
13
- "@sveltejs/kit": "next",
14
- "@sveltejs/package": "1.0.0-next.3",
12
+ "@sveltejs/adapter-auto": "^1.0.0",
13
+ "@sveltejs/kit": "^1.0.1",
14
+ "@sveltejs/package": "^1.0.1",
15
15
  "@types/tabbable": "^3.1.2",
16
- "eslint-config-standard-with-typescript": "^23.0.0",
16
+ "eslint-config-standard-with-typescript": "^24.0.0",
17
17
  "eslint-plugin-svelte3": "^4.0.0",
18
18
  "svelte": "^3.44.0",
19
- "svelte-check": "^2.2.6",
20
- "svelte-preprocess": "^4.9.4",
21
- "svelte2tsx": "^0.5.2",
19
+ "svelte-check": "^3.0.1",
20
+ "svelte-preprocess": "^5.0.0",
21
+ "svelte2tsx": "^0.6.0",
22
22
  "tslib": "^2.3.1",
23
23
  "typescript": "^4.4.3"
24
24
  },
@@ -1,4 +1,4 @@
1
- export declare type ElementOffsets = Partial<ReturnType<typeof bodyOffset>>;
1
+ export type ElementOffsets = Partial<ReturnType<typeof bodyOffset>>;
2
2
  export declare function bodyOffset(ele: HTMLElement): {
3
3
  right: number;
4
4
  bottom: number;