@txstate-mws/svelte-components 1.6.1 → 1.6.3

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.
@@ -4,16 +4,16 @@ export function glue(el, { target, align = 'auto', cover = false, gap = 0, adjus
4
4
  let halign;
5
5
  let valign;
6
6
  const parent = el.offsetParent;
7
- const formerMinHeight = parent.style.minHeight;
7
+ const formerMinHeight = parent?.style.minHeight;
8
8
  if (target)
9
9
  el.style.position = 'fixed';
10
10
  function adjustParentHeight() {
11
11
  if (!adjustparentheight)
12
12
  return;
13
- if (parent.style.overflowY === 'auto')
13
+ if (parent?.style.overflowY === 'auto')
14
14
  return;
15
15
  const minHeight = el.offsetTop + el.offsetHeight;
16
- if (minHeight > parent.clientHeight) {
16
+ if (minHeight > (parent?.clientHeight ?? 0)) {
17
17
  requestAnimationFrame(() => {
18
18
  parent.style.minHeight = String(minHeight) + 'px';
19
19
  });
@@ -21,8 +21,14 @@ export function glue(el, { target, align = 'auto', cover = false, gap = 0, adjus
21
21
  }
22
22
  let lastrect;
23
23
  function reposition() {
24
+ const fixedParent = fixedContainingBlock(el);
25
+ let fixedRect = { left: 0, top: 0, right: 0, bottom: 0 };
26
+ if (fixedParent) {
27
+ const tmpRect = fixedParent.getBoundingClientRect();
28
+ fixedRect = { left: tmpRect.left, right: window.innerWidth - tmpRect.right, top: tmpRect.top, bottom: window.innerHeight - tmpRect.bottom };
29
+ }
24
30
  const tmpRect = target.getBoundingClientRect();
25
- const rect = { left: tmpRect.left, right: window.innerWidth - tmpRect.right, top: tmpRect.top, bottom: window.innerHeight - tmpRect.bottom, width: tmpRect.width, height: tmpRect.height };
31
+ const rect = { left: tmpRect.left - fixedRect.left, right: window.innerWidth - tmpRect.right - fixedRect.right, top: tmpRect.top - fixedRect.top, bottom: window.innerHeight - tmpRect.bottom - fixedRect.bottom, width: tmpRect.width, height: tmpRect.height };
26
32
  if (equal(rect, lastrect))
27
33
  return;
28
34
  let autoalign = align;
@@ -109,3 +115,26 @@ export function glue(el, { target, align = 'auto', cover = false, gap = 0, adjus
109
115
  }
110
116
  };
111
117
  }
118
+ const isHTMLElement = (e) => !!e && 'offsetParent' in e;
119
+ function isFixedContainer(el) {
120
+ const css = getComputedStyle(el);
121
+ if (css.getPropertyValue('transform') !== 'none' || css.getPropertyValue('perspective') !== 'none')
122
+ return true; // A transform or perspective value other than none
123
+ if (['transform', 'perspective', 'filter'].includes(css.getPropertyValue('will-change')))
124
+ return true; // A will-change value of transform, filter, or perspective
125
+ if (css.getPropertyValue('filter') !== 'none')
126
+ return true; // A filter value other than none
127
+ if (['layout', 'paint', 'strict', 'content'].includes(css.getPropertyValue('contain')))
128
+ return true; // A contain value of layout, paint, strict or content (e.g. contain: paint;)
129
+ if (css.getPropertyValue('container-type') !== 'normal')
130
+ return true; // A container-type value other than normal
131
+ if (css.getPropertyValue('backdrop-filter') !== 'none')
132
+ return true; // A backdrop-filter other than none (e.g. backdrop-filter: blur(10px);)
133
+ return false;
134
+ }
135
+ function fixedContainingBlock(el) {
136
+ let parent = el.parentElement;
137
+ while (isHTMLElement(parent) && !isFixedContainer(parent))
138
+ parent = parent.parentElement;
139
+ return parent;
140
+ }
@@ -81,7 +81,7 @@ function addSelection(e) {
81
81
  const opt = { ...e.detail, label: e.detail.label || e.detail.value };
82
82
  selected = maxSelections === 1 ? [opt] : [...selected, opt];
83
83
  popupvalue = undefined;
84
- announcement = `${maxSelections === 1 ? 'selected' : 'added'} ${opt.value}`;
84
+ announcement = `${maxSelections === 1 ? 'selected' : 'added'} ${opt.label}`;
85
85
  dispatch('change', selected);
86
86
  }
87
87
  function removeSelection(opt, idx, nextfocus = 1) {
@@ -91,7 +91,7 @@ function removeSelection(opt, idx, nextfocus = 1) {
91
91
  selected = selected.filter(s => s.value !== opt.value);
92
92
  if (document.activeElement !== inputelement)
93
93
  inputelement.focus();
94
- announcement = `removed ${opt.value}`;
94
+ announcement = `removed ${opt.label ?? opt.value}`;
95
95
  dispatch('change', selected);
96
96
  }
97
97
  function inputkeydown(e) {
@@ -281,7 +281,7 @@ $: hasSelected = showSelected && !hideSelectedIndicator && items.some(itm => 'va
281
281
  <div use:portal={usePortal === true ? undefined : (usePortal || null)}
282
282
  use:glue={{ target: buttonelement, align, cover, gap, adjustparentheight, store: computedalign }}
283
283
  class={menuContainerClass}>
284
- <ul bind:this={menuelement} id={menuid} role={usemenurole ? 'menu' : 'listbox'} style={width ? `width: ${width}` : ''}
284
+ <ul bind:this={menuelement} id={menuid} role={usemenurole ? 'menu' : 'listbox'} tabindex="-1" style={width ? `width: ${width}` : ''}
285
285
  class={menuClass} class:hasSelected class:defaultmenu={!menuClass && !menuContainerClass}
286
286
  on:keydown={onkeydown}>
287
287
  {#each items as item, i ('value' in item ? item.value : `popupmenu_divider_${i}`)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@txstate-mws/svelte-components",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "Svelte components that are generically useful.",
5
5
  "scripts": {
6
6
  "prepublishOnly": "svelte-package",
@@ -34,7 +34,7 @@
34
34
  "typescript": "^5.0.4"
35
35
  },
36
36
  "peerDependencies": {
37
- "svelte": "^3.53.1 || ^4.0.0"
37
+ "svelte": "^3.53.1 || ^4.0.0 || ^5.0.0"
38
38
  },
39
39
  "type": "module",
40
40
  "main": "./dist/index.js",