react-resizable-panels 4.0.3 → 4.0.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.
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as W } from "react/jsx-runtime";
3
- import { useId as $e, useLayoutEffect as Ne, useEffect as _e, useRef as T, useCallback as xe, createContext as He, useImperativeHandle as ze, useState as G, useMemo as be, useSyncExternalStore as Fe, useContext as We } from "react";
3
+ import { useId as $e, useLayoutEffect as Ne, useEffect as _e, useRef as T, useCallback as xe, createContext as Fe, useImperativeHandle as ze, useState as G, useMemo as be, useSyncExternalStore as He, useContext as We } from "react";
4
4
  function z(e, t = "Assertion error") {
5
5
  if (!e)
6
6
  throw Error(t);
@@ -303,7 +303,7 @@ function Je({
303
303
  }
304
304
  return o > 0 && r > 0 ? "move" : o > 0 ? "ew-resize" : "ns-resize";
305
305
  }
306
- let ie = null, k;
306
+ let ie, k;
307
307
  function le() {
308
308
  k === void 0 && (k = new CSSStyleSheet(), document.adoptedStyleSheets = [k]);
309
309
  const { cursorFlags: e, interactionState: t } = O();
@@ -312,16 +312,16 @@ function le() {
312
312
  case "hover": {
313
313
  const n = Je({
314
314
  cursorFlags: e,
315
- groups: t.hitRegions.map((o) => o.group),
315
+ groups: t.hitRegions.map((r) => r.group),
316
316
  state: t.state
317
- });
318
- if (ie === n)
317
+ }), o = `*{cursor: ${n} !important; ${t.state === "active" ? "touch-action: none;" : ""} }`;
318
+ if (ie === o)
319
319
  return;
320
- ie = n, n ? k.cssRules.length === 0 ? k.insertRule(`*{cursor: ${n} !important;}`) : k.replaceSync(`*{cursor: ${n} !important;}`) : k.cssRules.length === 1 && k.deleteRule(0);
320
+ ie = o, n ? k.cssRules.length === 0 ? k.insertRule(o) : k.replaceSync(o) : k.cssRules.length === 1 && k.deleteRule(0);
321
321
  break;
322
322
  }
323
323
  case "inactive": {
324
- ie = null, k.cssRules.length === 1 && k.deleteRule(0);
324
+ ie = void 0, k.cssRules.length === 1 && k.deleteRule(0);
325
325
  break;
326
326
  }
327
327
  }
@@ -337,7 +337,7 @@ function Qe(e, t) {
337
337
  function j(e, t) {
338
338
  return w(e, t) ? 0 : e > t ? 1 : -1;
339
339
  }
340
- function H({
340
+ function F({
341
341
  panelConstraints: e,
342
342
  size: t
343
343
  }) {
@@ -423,7 +423,7 @@ function B({
423
423
  g != null,
424
424
  `Previous layout not found for panel index ${p}`
425
425
  );
426
- const y = H({
426
+ const y = F({
427
427
  panelConstraints: n[p],
428
428
  size: 100
429
429
  }) - g;
@@ -441,7 +441,7 @@ function B({
441
441
  h != null,
442
442
  `Previous layout not found for panel index ${p}`
443
443
  );
444
- const g = h - v, x = H({
444
+ const g = h - v, x = F({
445
445
  panelConstraints: n[p],
446
446
  size: g
447
447
  });
@@ -460,7 +460,7 @@ function B({
460
460
  p != null,
461
461
  `Previous layout not found for panel index ${d}`
462
462
  );
463
- const v = p + u, h = H({
463
+ const v = p + u, h = F({
464
464
  panelConstraints: n[d],
465
465
  size: v
466
466
  });
@@ -472,7 +472,7 @@ function B({
472
472
  L != null,
473
473
  `Previous layout not found for panel index ${y}`
474
474
  );
475
- const P = L + g, E = H({
475
+ const P = L + g, E = F({
476
476
  panelConstraints: n[y],
477
477
  size: P
478
478
  });
@@ -558,6 +558,8 @@ function he(e) {
558
558
  return;
559
559
  if (e.relatedTarget !== null)
560
560
  return;
561
+ if (e.clientX === 0 && e.clientY === 0)
562
+ return;
561
563
  const { interactionState: t, mountedGroups: n } = O();
562
564
  switch (t.state) {
563
565
  case "active":
@@ -603,7 +605,7 @@ function $({
603
605
  for (let i = 0; i < t.length; i++) {
604
606
  const a = o[i];
605
607
  z(a != null, `No layout data found for index ${i}`);
606
- const l = H({
608
+ const l = F({
607
609
  panelConstraints: t[i],
608
610
  size: a
609
611
  });
@@ -613,7 +615,7 @@ function $({
613
615
  for (let i = 0; i < t.length; i++) {
614
616
  const a = o[i];
615
617
  z(a != null, `No layout data found for index ${i}`);
616
- const l = a + s, f = H({
618
+ const l = a + s, f = F({
617
619
  panelConstraints: t[i],
618
620
  size: l
619
621
  });
@@ -804,12 +806,13 @@ function ge(e) {
804
806
  if (e.defaultPrevented)
805
807
  return;
806
808
  const { mountedGroups: t } = O(), n = Ie(e, t), o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map();
807
- n.forEach((i) => {
808
- o.add(i.group), i.panels.forEach((l) => {
809
- r.add(l);
810
- }), i.separator && s.add(i.separator);
811
- const a = t.get(i.group);
812
- a && c.set(i.group, a.layout);
809
+ let i = !1;
810
+ n.forEach((a) => {
811
+ o.add(a.group), a.panels.forEach((f) => {
812
+ r.add(f);
813
+ }), a.separator && (s.add(a.separator), i || (i = !0, a.separator.element.focus()));
814
+ const l = t.get(a.group);
815
+ l && c.set(a.group, l.layout);
813
816
  }), C({
814
817
  interactionState: {
815
818
  hitRegions: n,
@@ -979,10 +982,10 @@ function ce(e) {
979
982
  const t = $e();
980
983
  return `${e ?? t}`;
981
984
  }
982
- const F = typeof window < "u" ? Ne : _e;
985
+ const H = typeof window < "u" ? Ne : _e;
983
986
  function ue(e) {
984
987
  const t = T(e);
985
- return F(() => {
988
+ return H(() => {
986
989
  t.current = e;
987
990
  }, [e]), xe((n) => t.current?.(n), [t]);
988
991
  }
@@ -1008,13 +1011,13 @@ function Oe(e, t) {
1008
1011
  const n = e.replace(/[^a-zA-Z0-9\-_]/g, ""), o = t.replace(/[^a-zA-Z0-9\-_]/g, "");
1009
1012
  return `--react-resizable-panels--${n}--${o}`;
1010
1013
  }
1011
- const Te = He(null);
1014
+ const Te = Fe(null);
1012
1015
  function rt(e, t) {
1013
1016
  const n = T({
1014
1017
  getLayout: () => ({}),
1015
1018
  setLayout: Ze
1016
1019
  });
1017
- ze(t, () => n.current, []), F(() => {
1020
+ ze(t, () => n.current, []), H(() => {
1018
1021
  Object.assign(
1019
1022
  n.current,
1020
1023
  Me({ groupId: e })
@@ -1056,7 +1059,7 @@ function ht({
1056
1059
  }),
1057
1060
  [d, l]
1058
1061
  );
1059
- F(() => {
1062
+ H(() => {
1060
1063
  if (h !== null && L.length > 0) {
1061
1064
  const b = {
1062
1065
  defaultLayout: n,
@@ -1155,7 +1158,7 @@ function vt({
1155
1158
  groupId: e,
1156
1159
  storage: t
1157
1160
  }) {
1158
- const n = Fe(
1161
+ const n = He(
1159
1162
  lt,
1160
1163
  () => t.getItem(re(e)),
1161
1164
  () => t.getItem(re(e))
@@ -1300,7 +1303,7 @@ function ut(e, t) {
1300
1303
  isCollapsed: () => !1,
1301
1304
  resize: oe
1302
1305
  });
1303
- ze(t, () => o.current, []), F(() => {
1306
+ ze(t, () => o.current, []), H(() => {
1304
1307
  Object.assign(
1305
1308
  o.current,
1306
1309
  ct({ groupId: n, panelId: e })
@@ -1325,7 +1328,7 @@ function St({
1325
1328
  const S = !!c, d = ce(c), [p, v] = G(null), h = fe(v, s), { id: g, registerPanel: x } = de(), y = l !== null, L = ue((E) => {
1326
1329
  l?.(E, c);
1327
1330
  });
1328
- F(() => {
1331
+ H(() => {
1329
1332
  if (p !== null)
1330
1333
  return x({
1331
1334
  element: p,
@@ -1464,7 +1467,7 @@ function bt({
1464
1467
  orientation: p,
1465
1468
  registerSeparator: v
1466
1469
  } = de(), h = p === "horizontal" ? "vertical" : "horizontal";
1467
- return F(() => {
1470
+ return H(() => {
1468
1471
  if (u !== null) {
1469
1472
  const g = {
1470
1473
  element: u,