@juspay/svelte-ui-components 4.54.1 → 4.54.2

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.
@@ -18,6 +18,7 @@
18
18
  import { truncateToWidth } from '../_chart/labels';
19
19
  import {
20
20
  DEFAULT_CHART_CORNER_RADIUS,
21
+ CHART_LABEL_PLATE_PADDING,
21
22
  DEFAULT_CHART_MAX_HEIGHT,
22
23
  type TooltipAnchor
23
24
  } from '../_chart/types';
@@ -369,8 +370,10 @@
369
370
  measureText(truncateColumnLabel(label), colLabelFont).width,
370
371
  fontMetrics?.columnWidths[columnIndex] ?? 0
371
372
  );
372
- const canvasLeft = -(marginX + firstColumnLabelGutter) + 2;
373
- const canvasRight = plotWidth + lastColumnLabelGutter + marginX - 2;
373
+ // Inset by the plate padding: a header clamped any closer paints its plate
374
+ // outside the SVG, where it is clipped.
375
+ const canvasLeft = -(marginX + firstColumnLabelGutter) + CHART_LABEL_PLATE_PADDING;
376
+ const canvasRight = plotWidth + lastColumnLabelGutter + marginX - CHART_LABEL_PLATE_PADDING;
374
377
  const min = canvasLeft + textWidth / 2;
375
378
  const max = canvasRight - textWidth / 2;
376
379
  // Text wider than the whole canvas keeps its centre; the colWidth-based
@@ -1,10 +1,11 @@
1
1
  <script lang="ts">
2
2
  import { onMount, type Snippet } from 'svelte';
3
+ import { CHART_LABEL_PLATE_PADDING } from './types';
3
4
 
4
5
  let { children }: { children: Snippet } = $props();
5
6
  let group: SVGGElement | null = $state(null);
6
7
  let bounds: { x: number; y: number; width: number; height: number } | null = $state(null);
7
- const PADDING = 3;
8
+ const PADDING = CHART_LABEL_PLATE_PADDING;
8
9
 
9
10
  onMount(() => {
10
11
  const text = group?.querySelector('text');
@@ -18,6 +18,12 @@ export declare const DEFAULT_CHART_CORNER_RADIUS = 4;
18
18
  * an explicit `maxHeight` to override it.
19
19
  */
20
20
  export declare const DEFAULT_CHART_MAX_HEIGHT = 420;
21
+ /**
22
+ * Padding (px) a label plate draws around its text's bounding box. A label that
23
+ * is clamped to a canvas edge must stay at least this far inside it, otherwise
24
+ * its plate paints outside the SVG and is clipped there.
25
+ */
26
+ export declare const CHART_LABEL_PLATE_PADDING = 3;
21
27
  export type Margin = {
22
28
  top: number;
23
29
  right: number;
@@ -17,3 +17,9 @@ export const DEFAULT_CHART_CORNER_RADIUS = 4;
17
17
  * an explicit `maxHeight` to override it.
18
18
  */
19
19
  export const DEFAULT_CHART_MAX_HEIGHT = 420;
20
+ /**
21
+ * Padding (px) a label plate draws around its text's bounding box. A label that
22
+ * is clamped to a canvas edge must stay at least this far inside it, otherwise
23
+ * its plate paints outside the SVG and is clipped there.
24
+ */
25
+ export const CHART_LABEL_PLATE_PADDING = 3;
package/dist/utils.js CHANGED
@@ -386,8 +386,14 @@ function scrollLocksFor(container) {
386
386
  locks = new WeakMap();
387
387
  Object.defineProperty(owner, scrollLocksKey, { value: locks });
388
388
  }
389
- // The same real owner can be adopted into another document while held.
390
- Object.defineProperty(activeOwner, activeScrollLocksKey, { value: locks, configurable: true });
389
+ // The same real owner can be adopted into another document while held. A sealed or
390
+ // non-extensible owner cannot carry the pointer, so it keeps only the document registry.
391
+ try {
392
+ Object.defineProperty(activeOwner, activeScrollLocksKey, { value: locks, configurable: true });
393
+ }
394
+ catch {
395
+ // Locking still works; adoption of such an owner while held is not tracked.
396
+ }
391
397
  return locks;
392
398
  }
393
399
  const bodyScrollReleases = [];
@@ -415,9 +421,15 @@ export function acquireScrollLock(container = typeof document === 'undefined' ?
415
421
  ]);
416
422
  }
417
423
  }
418
- lock = { count: 0, overflow };
424
+ lock = {
425
+ count: 0,
426
+ overflow,
427
+ originalCssText: container.style.cssText,
428
+ lockedCssText: ''
429
+ };
419
430
  scrollLocks.set(container, lock);
420
431
  container.style.setProperty('overflow', 'hidden', 'important');
432
+ lock.lockedCssText = container.style.cssText;
421
433
  }
422
434
  lock.count += 1;
423
435
  const heldLock = lock;
@@ -429,11 +441,18 @@ export function acquireScrollLock(container = typeof document === 'undefined' ?
429
441
  released = true;
430
442
  heldLock.count -= 1;
431
443
  if (heldLock.count === 0) {
432
- container.style.removeProperty('overflow');
433
- container.style.removeProperty('overflow-x');
434
- container.style.removeProperty('overflow-y');
435
- for (const [name, value, priority] of heldLock.overflow) {
436
- container.style.setProperty(name, value, priority);
444
+ if (container.style.cssText === heldLock.lockedCssText) {
445
+ // Nothing else wrote to the inline style while held: put it back verbatim, which keeps the
446
+ // declaration order that removing and re-adding the overflow longhands would change.
447
+ container.style.cssText = heldLock.originalCssText;
448
+ }
449
+ else {
450
+ container.style.removeProperty('overflow');
451
+ container.style.removeProperty('overflow-x');
452
+ container.style.removeProperty('overflow-y');
453
+ for (const [name, value, priority] of heldLock.overflow) {
454
+ container.style.setProperty(name, value, priority);
455
+ }
437
456
  }
438
457
  scrollLocks.delete(container);
439
458
  Reflect.deleteProperty(container, activeScrollLocksKey);
package/dist-wc/index.js CHANGED
@@ -7078,10 +7078,14 @@ function scrollLocksFor(e) {
7078
7078
  let t = e;
7079
7079
  if (t[activeScrollLocksKey]) return t[activeScrollLocksKey];
7080
7080
  let n = e.ownerDocument, i = n[scrollLocksKey];
7081
- return i || (i = /* @__PURE__ */ new WeakMap(), Object.defineProperty(n, scrollLocksKey, { value: i })), Object.defineProperty(t, activeScrollLocksKey, {
7082
- value: i,
7083
- configurable: !0
7084
- }), i;
7081
+ i || (i = /* @__PURE__ */ new WeakMap(), Object.defineProperty(n, scrollLocksKey, { value: i }));
7082
+ try {
7083
+ Object.defineProperty(t, activeScrollLocksKey, {
7084
+ value: i,
7085
+ configurable: !0
7086
+ });
7087
+ } catch {}
7088
+ return i;
7085
7089
  }
7086
7090
  var bodyScrollReleases = [];
7087
7091
  function acquireScrollLock(e = typeof document > "u" ? null : document.body) {
@@ -7099,15 +7103,20 @@ function acquireScrollLock(e = typeof document > "u" ? null : document.body) {
7099
7103
  }
7100
7104
  n = {
7101
7105
  count: 0,
7102
- overflow: i
7103
- }, t.set(e, n), e.style.setProperty("overflow", "hidden", "important");
7106
+ overflow: i,
7107
+ originalCssText: e.style.cssText,
7108
+ lockedCssText: ""
7109
+ }, t.set(e, n), e.style.setProperty("overflow", "hidden", "important"), n.lockedCssText = e.style.cssText;
7104
7110
  }
7105
7111
  n.count += 1;
7106
7112
  let i = n, a = !1;
7107
7113
  return () => {
7108
7114
  if (!a && (a = !0, --i.count, i.count === 0)) {
7109
- e.style.removeProperty("overflow"), e.style.removeProperty("overflow-x"), e.style.removeProperty("overflow-y");
7110
- for (let [t, n, a] of i.overflow) e.style.setProperty(t, n, a);
7115
+ if (e.style.cssText === i.lockedCssText) e.style.cssText = i.originalCssText;
7116
+ else {
7117
+ e.style.removeProperty("overflow"), e.style.removeProperty("overflow-x"), e.style.removeProperty("overflow-y");
7118
+ for (let [t, n, a] of i.overflow) e.style.setProperty(t, n, a);
7119
+ }
7111
7120
  t.delete(e), Reflect.deleteProperty(e, activeScrollLocksKey);
7112
7121
  }
7113
7122
  };
@@ -39075,7 +39084,7 @@ function SankeyChart(e, t) {
39075
39084
  }
39076
39085
  return e;
39077
39086
  }), Gt = /* @__PURE__ */ user_derived(() => get(Bt).nodes.length > 0 ? Math.max(...get(Bt).nodes.map((e) => e.column)) + 1 : 0), qt = /* @__PURE__ */ user_derived(() => get(Gt) <= 1 ? get(Rt) : (get(Rt) - a()) / (get(Gt) - 1)), Zt = (e) => truncateToWidth(e, Math.max(0, get(qt) - 6), get(Mt)), Qt = (e, t) => {
39078
- let n = e * get(qt) + a() / 2, i = Math.max(measureText(Zt(t), get(Mt)).width, get(kt)?.columnWidths[e] ?? 0), o = -(ut() + get(Lt)) + 2, s = get(Rt) + get(It) + ut() - 2, c = o + i / 2, l = s - i / 2;
39087
+ let n = e * get(qt) + a() / 2, i = Math.max(measureText(Zt(t), get(Mt)).width, get(kt)?.columnWidths[e] ?? 0), o = -(ut() + get(Lt)) + 3, s = get(Rt) + get(It) + ut() - 3, c = o + i / 2, l = s - i / 2;
39079
39088
  return l < c ? n : Math.min(Math.max(n, c), l);
39080
39089
  }, $t = (e) => e === 0 && ct() === "left" || e === get(Gt) - 1 && e !== 0 && lt() === "left", en = (e, t) => truncateToWidth(e, t === 0 && ct() === "left" ? Math.max(0, get(Lt) + ut() - 10 - at()) : t === get(Gt) - 1 && lt() === "right" ? Math.max(0, get(It) + ut() - 10 - at()) : Math.max(0, get(qt) - a() - 20 - at()), get(jt)), tn = /* @__PURE__ */ user_derived(() => {
39081
39090
  let e = new SvelteMap();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "4.54.1",
3
+ "version": "4.54.2",
4
4
  "description": "A themeable Svelte 5 UI component library with CSS custom property driven styling",
5
5
  "keywords": [
6
6
  "svelte",