@juspay/svelte-ui-components 4.55.2 → 4.55.4
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/dist/Resizable/Resizable.svelte +51 -15
- package/dist/_interaction/focus.js +8 -3
- package/dist-wc/index.js +51 -28
- package/package.json +1 -1
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
let active: {
|
|
36
36
|
edge: ResizeEdge;
|
|
37
37
|
pointerId: number;
|
|
38
|
+
handle: HTMLElement;
|
|
38
39
|
startX: number;
|
|
39
40
|
startY: number;
|
|
40
41
|
startW: number;
|
|
@@ -82,33 +83,40 @@
|
|
|
82
83
|
event: PointerEvent & { currentTarget: HTMLElement },
|
|
83
84
|
edge: ResizeEdge
|
|
84
85
|
): void {
|
|
85
|
-
if (disabled) {
|
|
86
|
+
if (disabled || active !== null) {
|
|
86
87
|
return;
|
|
87
88
|
}
|
|
88
89
|
event.preventDefault();
|
|
89
90
|
const startW = clampWidth(measuredWidth());
|
|
90
91
|
const startH = clampHeight(measuredHeight());
|
|
91
92
|
const direction = DIRS[edge];
|
|
92
|
-
if (direction.x !== 0) {
|
|
93
|
-
width = startW;
|
|
94
|
-
}
|
|
95
|
-
if (direction.y !== 0) {
|
|
96
|
-
height = startH;
|
|
97
|
-
}
|
|
98
93
|
active = {
|
|
99
94
|
edge,
|
|
100
95
|
pointerId: event.pointerId,
|
|
96
|
+
handle: event.currentTarget,
|
|
101
97
|
startX: event.clientX,
|
|
102
98
|
startY: event.clientY,
|
|
103
99
|
startW,
|
|
104
100
|
startH
|
|
105
101
|
};
|
|
106
|
-
|
|
102
|
+
try {
|
|
103
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
104
|
+
} catch {
|
|
105
|
+
// A pointer that already ended cannot own a resize session.
|
|
106
|
+
active = null;
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (direction.x !== 0) {
|
|
110
|
+
width = startW;
|
|
111
|
+
}
|
|
112
|
+
if (direction.y !== 0) {
|
|
113
|
+
height = startH;
|
|
114
|
+
}
|
|
107
115
|
onresizestart?.({ width: startW, height: startH });
|
|
108
116
|
}
|
|
109
117
|
|
|
110
118
|
function moveResize(event: PointerEvent): void {
|
|
111
|
-
if (active === null) {
|
|
119
|
+
if (active === null || event.pointerId !== active.pointerId) {
|
|
112
120
|
return;
|
|
113
121
|
}
|
|
114
122
|
const dir = DIRS[active.edge];
|
|
@@ -121,15 +129,40 @@
|
|
|
121
129
|
onresize?.({ width: measuredWidth(), height: measuredHeight() });
|
|
122
130
|
}
|
|
123
131
|
|
|
124
|
-
function
|
|
125
|
-
|
|
132
|
+
function finishResize(notify: boolean): void {
|
|
133
|
+
const session = active;
|
|
134
|
+
if (session === null) {
|
|
126
135
|
return;
|
|
127
136
|
}
|
|
128
|
-
|
|
129
|
-
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
130
|
-
}
|
|
137
|
+
// Clear ownership before release, which can synchronously dispatch capture loss.
|
|
131
138
|
active = null;
|
|
132
|
-
|
|
139
|
+
try {
|
|
140
|
+
if (session.handle.hasPointerCapture(session.pointerId)) {
|
|
141
|
+
session.handle.releasePointerCapture(session.pointerId);
|
|
142
|
+
}
|
|
143
|
+
} catch {
|
|
144
|
+
// Capture may already have been removed by the browser or a detached handle.
|
|
145
|
+
}
|
|
146
|
+
if (notify) {
|
|
147
|
+
onresizeend?.({ width: measuredWidth(), height: measuredHeight() });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function endResize(event: PointerEvent): void {
|
|
152
|
+
if (active === null || event.pointerId !== active.pointerId) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
finishResize(!disabled && handles.includes(active.edge));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function trackResizeHandle(handle: HTMLElement): { destroy: () => void } {
|
|
159
|
+
return {
|
|
160
|
+
destroy: () => {
|
|
161
|
+
if (active?.handle === handle) {
|
|
162
|
+
finishResize(false);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
133
166
|
}
|
|
134
167
|
|
|
135
168
|
function keyResize(event: KeyboardEvent, edge: ResizeEdge): void {
|
|
@@ -198,6 +231,7 @@
|
|
|
198
231
|
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
199
232
|
<div
|
|
200
233
|
class="handle"
|
|
234
|
+
use:trackResizeHandle
|
|
201
235
|
data-edge={edge}
|
|
202
236
|
role="separator"
|
|
203
237
|
tabindex="0"
|
|
@@ -209,6 +243,8 @@
|
|
|
209
243
|
onpointerdown={(event) => startResize(event, edge)}
|
|
210
244
|
onpointermove={moveResize}
|
|
211
245
|
onpointerup={endResize}
|
|
246
|
+
onpointercancel={endResize}
|
|
247
|
+
onlostpointercapture={endResize}
|
|
212
248
|
onkeydown={(event) => keyResize(event, edge)}
|
|
213
249
|
></div>
|
|
214
250
|
{/each}
|
|
@@ -31,8 +31,9 @@ const FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), textarea:not([disab
|
|
|
31
31
|
/**
|
|
32
32
|
* True when `el` can actually take focus. `FOCUSABLE_SELECTOR` alone matches
|
|
33
33
|
* candidates that pass its tag/attribute shape but still cannot receive
|
|
34
|
-
* focus in a real browser:
|
|
35
|
-
* `inert` subtree, or explicitly marked
|
|
34
|
+
* focus in a real browser: an input with type="hidden", hidden via the
|
|
35
|
+
* `hidden` attribute, inside an `inert` subtree, or explicitly marked
|
|
36
|
+
* `aria-disabled="true"`. Without this,
|
|
36
37
|
* Tab wrapping can land focus on one of these -- worse than no trap at all,
|
|
37
38
|
* since focus then effectively vanishes instead of just not being managed.
|
|
38
39
|
*
|
|
@@ -46,7 +47,7 @@ const FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), textarea:not([disab
|
|
|
46
47
|
* jsdom, which the test suite runs under, never computes layout, so a
|
|
47
48
|
* layout-based check would either be a permanent no-op there or -- worse --
|
|
48
49
|
* report every element as non-focusable and empty out every boundary under
|
|
49
|
-
* test. The
|
|
50
|
+
* test. The checks below are all attribute/tree-shape reads, which
|
|
50
51
|
* jsdom does support, so behavior under test matches behavior in a browser.
|
|
51
52
|
*/
|
|
52
53
|
function canReceiveFocus(el) {
|
|
@@ -55,6 +56,10 @@ function canReceiveFocus(el) {
|
|
|
55
56
|
typeof el.closest !== 'function') {
|
|
56
57
|
return true;
|
|
57
58
|
}
|
|
59
|
+
if (el.tagName?.toLowerCase() === 'input' &&
|
|
60
|
+
el.getAttribute('type')?.toLowerCase() === 'hidden') {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
58
63
|
if (el.hasAttribute('hidden')) {
|
|
59
64
|
return false;
|
|
60
65
|
}
|
package/dist-wc/index.js
CHANGED
|
@@ -7135,7 +7135,7 @@ function unlockBodyScroll() {
|
|
|
7135
7135
|
//#region src/lib/_interaction/focus.ts
|
|
7136
7136
|
var FOCUSABLE_SELECTOR = "a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
|
|
7137
7137
|
function canReceiveFocus(e) {
|
|
7138
|
-
return typeof e.hasAttribute != "function" || typeof e.getAttribute != "function" || typeof e.closest != "function" ? !0 : e.hasAttribute("hidden") || e.getAttribute("aria-disabled") === "true" ? !1 : e.closest("[inert]") === null;
|
|
7138
|
+
return typeof e.hasAttribute != "function" || typeof e.getAttribute != "function" || typeof e.closest != "function" ? !0 : e.tagName?.toLowerCase() === "input" && e.getAttribute("type")?.toLowerCase() === "hidden" || e.hasAttribute("hidden") || e.getAttribute("aria-disabled") === "true" ? !1 : e.closest("[inert]") === null;
|
|
7139
7139
|
}
|
|
7140
7140
|
function collectFocusableCandidates(e) {
|
|
7141
7141
|
let t = e.querySelectorAll(FOCUSABLE_SELECTOR), n = [];
|
|
@@ -11240,23 +11240,31 @@ function Resizable(e, t) {
|
|
|
11240
11240
|
return t === "x" ? "vertical" : t === "y" ? "horizontal" : null;
|
|
11241
11241
|
}
|
|
11242
11242
|
function ct(e, t) {
|
|
11243
|
-
if (f()) return;
|
|
11243
|
+
if (f() || get(re) !== null) return;
|
|
11244
11244
|
e.preventDefault();
|
|
11245
11245
|
let a = Me(Ue()), o = Re(it()), s = ne[t];
|
|
11246
|
-
|
|
11246
|
+
set(re, {
|
|
11247
11247
|
edge: t,
|
|
11248
11248
|
pointerId: e.pointerId,
|
|
11249
|
+
handle: e.currentTarget,
|
|
11249
11250
|
startX: e.clientX,
|
|
11250
11251
|
startY: e.clientY,
|
|
11251
11252
|
startW: a,
|
|
11252
11253
|
startH: o
|
|
11253
|
-
}, !0)
|
|
11254
|
+
}, !0);
|
|
11255
|
+
try {
|
|
11256
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
11257
|
+
} catch {
|
|
11258
|
+
set(re, null);
|
|
11259
|
+
return;
|
|
11260
|
+
}
|
|
11261
|
+
s.x !== 0 && n(a), s.y !== 0 && i(o), C()?.({
|
|
11254
11262
|
width: a,
|
|
11255
11263
|
height: o
|
|
11256
11264
|
});
|
|
11257
11265
|
}
|
|
11258
11266
|
function lt(e) {
|
|
11259
|
-
if (get(re) === null) return;
|
|
11267
|
+
if (get(re) === null || e.pointerId !== get(re).pointerId) return;
|
|
11260
11268
|
let t = ne[get(re).edge];
|
|
11261
11269
|
t.x !== 0 && n(Me(get(re).startW + t.x * (e.clientX - get(re).startX))), t.y !== 0 && i(Re(get(re).startH + t.y * (e.clientY - get(re).startY))), S()?.({
|
|
11262
11270
|
width: Ue(),
|
|
@@ -11264,12 +11272,27 @@ function Resizable(e, t) {
|
|
|
11264
11272
|
});
|
|
11265
11273
|
}
|
|
11266
11274
|
function ut(e) {
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11275
|
+
let t = get(re);
|
|
11276
|
+
if (t !== null) {
|
|
11277
|
+
set(re, null);
|
|
11278
|
+
try {
|
|
11279
|
+
t.handle.hasPointerCapture(t.pointerId) && t.handle.releasePointerCapture(t.pointerId);
|
|
11280
|
+
} catch {}
|
|
11281
|
+
e && k()?.({
|
|
11282
|
+
width: Ue(),
|
|
11283
|
+
height: it()
|
|
11284
|
+
});
|
|
11285
|
+
}
|
|
11286
|
+
}
|
|
11287
|
+
function dt(e) {
|
|
11288
|
+
get(re) === null || e.pointerId !== get(re).pointerId || ut(!f() && l().includes(get(re).edge));
|
|
11289
|
+
}
|
|
11290
|
+
function ft(e) {
|
|
11291
|
+
return { destroy: () => {
|
|
11292
|
+
get(re)?.handle === e && ut(!1);
|
|
11293
|
+
} };
|
|
11271
11294
|
}
|
|
11272
|
-
function
|
|
11295
|
+
function pt(e, t) {
|
|
11273
11296
|
if (f()) return;
|
|
11274
11297
|
let a = ne[t], o = Ue(), s = it(), c = !1;
|
|
11275
11298
|
a.x !== 0 && (e.key === "ArrowRight" || e.key === "ArrowLeft") && (o = Me(o + a.x * (e.key === "ArrowRight" ? u() : -u())), c = !0), a.y !== 0 && (e.key === "ArrowDown" || e.key === "ArrowUp") && (s = Re(s + a.y * (e.key === "ArrowDown" ? u() : -u())), c = !0), c && (e.preventDefault(), a.x !== 0 && (e.key === "ArrowRight" || e.key === "ArrowLeft") && n(o), a.y !== 0 && (e.key === "ArrowDown" || e.key === "ArrowUp") && i(s), S()?.({
|
|
@@ -11277,17 +11300,17 @@ function Resizable(e, t) {
|
|
|
11277
11300
|
height: s
|
|
11278
11301
|
}));
|
|
11279
11302
|
}
|
|
11280
|
-
function
|
|
11303
|
+
function mt(e) {
|
|
11281
11304
|
return at(e) === "y" ? typeof i() == "number" ? i() : null : typeof n() == "number" ? n() : null;
|
|
11282
11305
|
}
|
|
11283
|
-
function
|
|
11306
|
+
function ht(e) {
|
|
11284
11307
|
return at(e) === "y" ? s() : a();
|
|
11285
11308
|
}
|
|
11286
|
-
function
|
|
11309
|
+
function gt(e) {
|
|
11287
11310
|
let t = at(e) === "y" ? c() : o();
|
|
11288
11311
|
return Number.isFinite(t) ? t : null;
|
|
11289
11312
|
}
|
|
11290
|
-
var
|
|
11313
|
+
var _t = {
|
|
11291
11314
|
get width() {
|
|
11292
11315
|
return n();
|
|
11293
11316
|
},
|
|
@@ -11384,30 +11407,30 @@ function Resizable(e, t) {
|
|
|
11384
11407
|
set classes(e) {
|
|
11385
11408
|
te(e), flushSync();
|
|
11386
11409
|
}
|
|
11387
|
-
},
|
|
11388
|
-
let
|
|
11389
|
-
var
|
|
11410
|
+
}, vt = root_1$82();
|
|
11411
|
+
let yt, bt;
|
|
11412
|
+
var xt = child(vt), St = (e) => {
|
|
11390
11413
|
var t = comment();
|
|
11391
11414
|
snippet(first_child(t), h), append(e, t);
|
|
11392
11415
|
};
|
|
11393
|
-
return if_block(
|
|
11394
|
-
typeof h() == "function" && e(
|
|
11395
|
-
}), each(sibling(
|
|
11416
|
+
return if_block(xt, (e) => {
|
|
11417
|
+
typeof h() == "function" && e(St);
|
|
11418
|
+
}), each(sibling(xt, 2), 16, () => get(be), (e) => e, (e, t) => {
|
|
11396
11419
|
var n = root$89();
|
|
11397
|
-
template_effect((e, i, a, o) => {
|
|
11420
|
+
action(n, (e) => ft?.(e)), template_effect((e, i, a, o) => {
|
|
11398
11421
|
set_attribute(n, "data-edge", t), set_attribute(n, "aria-label", p()), set_attribute(n, "aria-orientation", e), set_attribute(n, "aria-valuenow", i), set_attribute(n, "aria-valuemin", a), set_attribute(n, "aria-valuemax", o);
|
|
11399
11422
|
}, [
|
|
11400
11423
|
() => ot(t),
|
|
11401
|
-
() =>
|
|
11402
|
-
() =>
|
|
11403
|
-
() =>
|
|
11404
|
-
]), delegated("pointerdown", n, (e) => ct(e, t)), delegated("pointermove", n, lt), delegated("pointerup", n,
|
|
11405
|
-
}), reset(
|
|
11406
|
-
|
|
11424
|
+
() => mt(t),
|
|
11425
|
+
() => ht(t),
|
|
11426
|
+
() => gt(t)
|
|
11427
|
+
]), delegated("pointerdown", n, (e) => ct(e, t)), delegated("pointermove", n, lt), delegated("pointerup", n, dt), event("pointercancel", n, dt), event("lostpointercapture", n, dt), delegated("keydown", n, (e) => pt(e, t)), append(e, n);
|
|
11428
|
+
}), reset(vt), bind_this(vt, (e) => set(G, e), () => get(G)), template_effect(() => {
|
|
11429
|
+
yt = set_class(vt, 1, `resizable ${te() ?? "" ?? ""}`, "svelte-1su0g5i", yt, { resizing: get(re) !== null }), set_attribute(vt, "data-pw", typeof R() == "string" ? R() : null), set_attribute(vt, "testid", typeof R() == "string" ? R() : null), bt = set_style(vt, "", bt, {
|
|
11407
11430
|
width: typeof n() == "number" ? `${n()}px` : null,
|
|
11408
11431
|
height: typeof i() == "number" ? `${i()}px` : null
|
|
11409
11432
|
});
|
|
11410
|
-
}), append(e,
|
|
11433
|
+
}), append(e, vt), pop(_t);
|
|
11411
11434
|
}
|
|
11412
11435
|
delegate([
|
|
11413
11436
|
"pointerdown",
|