@kubex/zinc 2.0.1 → 2.0.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.
@@ -1,10 +1,10 @@
1
1
  import {classMap} from "lit/directives/class-map.js";
2
2
  import {type CSSResultGroup, html, type PropertyValues, unsafeCSS} from 'lit';
3
3
  import {ifDefined} from "lit/directives/if-defined.js";
4
+ import {type IndicatorEdges, slideTabIndicator, squishTabIndicator} from "../../internal/tab-indicator";
4
5
  import {MutationController} from '@lit-labs/observers/mutation-controller.js';
5
6
  import {property} from 'lit/decorators.js';
6
7
  import {ResizeController} from '@lit-labs/observers/resize-controller.js';
7
- import {type IndicatorEdges, slideTabIndicator, squishTabIndicator} from "../../internal/tab-indicator";
8
8
  import {Store} from "../../internal/storage";
9
9
  import ZincElement from '../../internal/zinc-element';
10
10
  import ZnDropdown from "../dropdown";
@@ -111,6 +111,7 @@ export default class ZnNavbar extends ZincElement {
111
111
  private _indicator: HTMLElement | null = null;
112
112
  private _indicatorFrame: number | null = null;
113
113
  private _indicatorTab: HTMLElement | null = null;
114
+ private _indicatorStripWidth = 0;
114
115
  private _indicatorTarget: IndicatorEdges | null = null;
115
116
  private _expandable: HTMLElement | null = null;
116
117
  private readonly _lightDomClones = new WeakMap<HTMLElement, HTMLElement>();
@@ -242,18 +243,23 @@ export default class ZnNavbar extends ZincElement {
242
243
 
243
244
  // The indicator scrolls with the tabs, so it is placed in the strip's content coordinates
244
245
  const box = container.getBoundingClientRect();
245
- const originLeft = box.left - container.scrollLeft;
246
- const target = {left: tab.left - originLeft, right: tab.right - originLeft};
246
+ // An ancestor mid scale-in (e.g. a modal opening) shrinks every rect, and its end fires no resize to re-measure
247
+ const scaleX = box.width / container.offsetWidth || 1;
248
+ const scaleY = box.height / container.offsetHeight || 1;
249
+ const toStrip = (x: number) => (x - box.left) / scaleX + container.scrollLeft;
250
+ const target = {left: toStrip(tab.left), right: toStrip(tab.right)};
247
251
  const previous = this._indicatorTarget;
248
252
  const tabChanged = active !== this._indicatorTab;
249
253
  const ready = indicator.classList.contains('navbar__indicator--ready');
250
254
  this._indicatorTab = active ?? null;
251
- if (tabChanged && active) {
252
- this._revealTab(active, ready);
255
+ const stripResized = container.clientWidth !== this._indicatorStripWidth;
256
+ this._indicatorStripWidth = container.clientWidth;
257
+ if (active && (tabChanged || stripResized)) {
258
+ this._revealTab(active, ready && tabChanged);
253
259
  }
254
260
  // Exposed for ::part(indicator) styles that fill the tab rather than underline it.
255
- setStyle(indicator, '--zn-navbar-indicator-top', `${tab.top - box.top}px`);
256
- setStyle(indicator, '--zn-navbar-indicator-height', `${tab.height}px`);
261
+ setStyle(indicator, '--zn-navbar-indicator-top', `${(tab.top - box.top) / scaleY}px`);
262
+ setStyle(indicator, '--zn-navbar-indicator-height', `${tab.height / scaleY}px`);
257
263
  indicator.classList.toggle('navbar__indicator--shown', true);
258
264
  if (previous && Math.abs(previous.left - target.left) < 0.5 && Math.abs(previous.right - target.right) < 0.5) {
259
265
  return;
@@ -271,7 +277,7 @@ export default class ZnNavbar extends ZincElement {
271
277
  indicator.style.width = `${target.right - target.left}px`;
272
278
  this._indicatorTarget = target;
273
279
  if (slide) {
274
- slideTabIndicator(indicator, {left: drawn.left - originLeft, right: drawn.right - originLeft}, target);
280
+ slideTabIndicator(indicator, {left: toStrip(drawn.left), right: toStrip(drawn.right)}, target);
275
281
  }
276
282
 
277
283
  // The first placement jumps into position; only later moves animate.
@@ -1,7 +1,7 @@
1
- import {ifDefined} from "lit/directives/if-defined.js";
2
1
  import {classMap} from "lit/directives/class-map.js";
3
2
  import {type CSSResultGroup, html, type PropertyValues, unsafeCSS} from 'lit';
4
3
  import {HasSlotController} from "../../internal/slot";
4
+ import {ifDefined} from "lit/directives/if-defined.js";
5
5
  import {property, state} from 'lit/decorators.js';
6
6
  import {registerCosmicBorder} from "../../internal/cosmic-border";
7
7
  import ZincElement from '../../internal/zinc-element';
@@ -1,6 +1,6 @@
1
1
  import '../../../dist/zn.min.js';
2
2
  import {aTimeout, expect, fixture, html} from '@open-wc/testing';
3
- import {centre, drop, dragTo, startDrag} from '../../internal/test-drag';
3
+ import {centre, dragTo, drop, startDrag} from '../../internal/test-drag';
4
4
 
5
5
  describe('<zn-priority-list>', () => {
6
6
  it('should render a component', async () => {
@@ -4,8 +4,8 @@ import {on} from "../../utilities/on";
4
4
  import {Store} from "../../internal/storage";
5
5
  import ZincElement from '../../internal/zinc-element';
6
6
 
7
- import styles from './split-pane.scss';
8
7
  import { PropertyValues } from "@lit/reactive-element";
8
+ import styles from './split-pane.scss';
9
9
 
10
10
  type NavigationItem = {
11
11
  caption: string;
@@ -14,11 +14,11 @@ import {HasSlotController} from "../../internal/slot";
14
14
  import {ifDefined} from "lit/directives/if-defined.js";
15
15
  import {md5} from "../../utilities/md5";
16
16
  import {MutationController} from '@lit-labs/observers/mutation-controller.js';
17
+ import {onHoverIntent} from '../../internal/hover-intent';
18
+ import {pointerInitiated} from '../../internal/input-modality';
17
19
  import {property} from 'lit/decorators.js';
18
20
  import {Store} from "../../internal/storage";
19
21
  import ZincElement from '../../internal/zinc-element';
20
- import {onHoverIntent} from '../../internal/hover-intent';
21
- import {pointerInitiated} from '../../internal/input-modality';
22
22
 
23
23
  // Tabs load in such a way that the global sheet has to be re-applied inside the shadow root.
24
24
  import bootStyles from '../../../scss/boot.scss';