@tensor_1/react 2.40.2 → 2.42.0

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.
Files changed (41) hide show
  1. package/dist/components/Button.d.ts +19 -1
  2. package/dist/components/Button.js +13 -8
  3. package/dist/components/DescriptionList.d.ts +11 -0
  4. package/dist/components/DiscardPrompt.d.ts +54 -0
  5. package/dist/components/DiscardPrompt.js +245 -0
  6. package/dist/components/Drawer.d.ts +19 -3
  7. package/dist/components/Drawer.js +60 -21
  8. package/dist/components/EditorialHome.d.ts +1 -1
  9. package/dist/components/Field.d.ts +7 -1
  10. package/dist/components/Field.js +5 -4
  11. package/dist/components/Input.d.ts +5 -0
  12. package/dist/components/Input.js +2 -1
  13. package/dist/components/Kbd.d.ts +20 -1
  14. package/dist/components/Kbd.js +30 -7
  15. package/dist/components/Menu.d.ts +11 -4
  16. package/dist/components/Menu.js +17 -3
  17. package/dist/components/MetricInput.d.ts +8 -1
  18. package/dist/components/MetricInput.js +11 -3
  19. package/dist/components/Modal.d.ts +15 -1
  20. package/dist/components/Modal.js +58 -13
  21. package/dist/components/SearchBar.d.ts +67 -0
  22. package/dist/components/SearchBar.js +117 -0
  23. package/dist/components/Select.js +5 -4
  24. package/dist/components/ShortcutHint.d.ts +29 -0
  25. package/dist/components/ShortcutHint.js +149 -0
  26. package/dist/components/Table.d.ts +7 -1
  27. package/dist/components/Table.js +2 -0
  28. package/dist/components/Tooltip.d.ts +10 -1
  29. package/dist/components/Tooltip.js +15 -4
  30. package/dist/emoji.cjs +108 -31
  31. package/dist/hooks/useAnchoredPosition.d.ts +13 -1
  32. package/dist/hooks/useAnchoredPosition.js +19 -11
  33. package/dist/hooks/useDialog.d.ts +6 -1
  34. package/dist/hooks/useDialog.js +10 -1
  35. package/dist/index.cjs +3186 -2521
  36. package/dist/index.d.cts +228 -40
  37. package/dist/index.d.ts +3 -1
  38. package/dist/index.js +6 -1
  39. package/dist/labels-context.d.ts +8 -0
  40. package/dist/rich-text.cjs +17 -10
  41. package/package.json +1 -1
@@ -1373,11 +1373,16 @@ function translationOf(el) {
1373
1373
  if (!t || t === "none" || typeof DOMMatrixReadOnly === "undefined") return { x: 0, y: 0 };
1374
1374
  try {
1375
1375
  const m = new DOMMatrixReadOnly(t);
1376
- return { x: m.m41, y: m.m42 };
1376
+ const z = zoomOf(el);
1377
+ return { x: m.m41 * z, y: m.m42 * z };
1377
1378
  } catch {
1378
1379
  return { x: 0, y: 0 };
1379
1380
  }
1380
1381
  }
1382
+ function zoomOf(el) {
1383
+ const z = el.currentCSSZoom;
1384
+ return typeof z === "number" && Number.isFinite(z) && z > 0 ? z : 1;
1385
+ }
1381
1386
  var signed = (n) => `${n < 0 ? "-" : "+"} ${Math.round(Math.abs(n) * 100) / 100}px`;
1382
1387
  var prepared = /* @__PURE__ */ new WeakSet();
1383
1388
  function useAnchoredPosition(anchor, floatingRef, { open, placement = "bottom-start", offset = 6, padding = 8, shiftMainAxis = true, capHeight = false, onAnchorHidden }) {
@@ -1402,8 +1407,9 @@ function useAnchoredPosition(anchor, floatingRef, { open, placement = "bottom-st
1402
1407
  const s = floating.style;
1403
1408
  if (keepPlace && current.anchor.isConnected) {
1404
1409
  const a = current.anchor.getBoundingClientRect();
1405
- s.top = `${Math.round((current.yEdge === "bottom" ? a.bottom : a.top) + current.dy)}px`;
1406
- s.left = `${Math.round((current.xEdge === "right" ? a.right : a.left) + current.dx)}px`;
1410
+ const z = zoomOf(floating);
1411
+ s.top = `${Math.round(((current.yEdge === "bottom" ? a.bottom : a.top) + current.dy) / z)}px`;
1412
+ s.left = `${Math.round(((current.xEdge === "right" ? a.right : a.left) + current.dx) / z)}px`;
1407
1413
  }
1408
1414
  s.removeProperty("position-anchor");
1409
1415
  }
@@ -1431,6 +1437,7 @@ function useAnchoredPosition(anchor, floatingRef, { open, placement = "bottom-st
1431
1437
  written.current = "";
1432
1438
  }
1433
1439
  const { placement: p, offset: o, padding: pad, shiftMainAxis: keepInView, capHeight: cap } = opts.current;
1440
+ const zoom = floating.getClientRects().length > 0 ? zoomOf(floating) : zoomOf(anchorEl);
1434
1441
  if (cap) {
1435
1442
  if (!heightCap.current) {
1436
1443
  const own = getComputedStyle(floating);
@@ -1444,7 +1451,7 @@ function useAnchoredPosition(anchor, floatingRef, { open, placement = "bottom-st
1444
1451
  };
1445
1452
  if (setOverflow) s.overflowY = "auto";
1446
1453
  }
1447
- const room = `${Math.max(0, window.innerHeight - 2 * pad)}px`;
1454
+ const room = `${Math.max(0, (window.innerHeight - 2 * pad * zoom) / zoom)}px`;
1448
1455
  const max = heightCap.current.ownMaxHeight ? `min(${room}, ${heightCap.current.ownMaxHeight})` : room;
1449
1456
  if (max !== heightCap.current.written) {
1450
1457
  s.maxHeight = max;
@@ -1454,19 +1461,19 @@ function useAnchoredPosition(anchor, floatingRef, { open, placement = "bottom-st
1454
1461
  uncap();
1455
1462
  }
1456
1463
  const a = anchorEl.getBoundingClientRect();
1457
- const size = { width: floating.offsetWidth, height: floating.offsetHeight };
1464
+ const size = { width: floating.offsetWidth * zoom, height: floating.offsetHeight * zoom };
1458
1465
  const pos = computePosition(
1459
1466
  { x: a.x, y: a.y, width: a.width, height: a.height },
1460
1467
  size,
1461
1468
  { width: window.innerWidth, height: window.innerHeight },
1462
- { placement: p, offset: o, padding: pad, shiftMainAxis: keepInView, stickySide: side.current ?? void 0 }
1469
+ { placement: p, offset: o * zoom, padding: pad * zoom, shiftMainAxis: keepInView, stickySide: side.current ?? void 0 }
1463
1470
  );
1464
1471
  const measured = size.width > 0 || size.height > 0;
1465
1472
  if (measured && session.current) side.current = pos.side;
1466
1473
  if (floating.dataset.placement !== pos.placement) floating.dataset.placement = pos.placement;
1467
1474
  const writeFixed = (at) => {
1468
- const left2 = `${Math.round(at.x)}px`;
1469
- const top2 = `${Math.round(at.y)}px`;
1475
+ const left2 = `${Math.round(at.x / zoom)}px`;
1476
+ const top2 = `${Math.round(at.y / zoom)}px`;
1470
1477
  const key2 = `fixed ${left2} ${top2}`;
1471
1478
  if (key2 === written.current) return;
1472
1479
  s.left = left2;
@@ -1493,8 +1500,8 @@ function useAnchoredPosition(anchor, floatingRef, { open, placement = "bottom-st
1493
1500
  current.xEdge = pos.side === "right" ? "right" : "left";
1494
1501
  current.dy = pos.y - (current.yEdge === "bottom" ? a.bottom : a.top);
1495
1502
  current.dx = pos.x - (current.xEdge === "right" ? a.right : a.left);
1496
- const top = `round(anchor(${current.yEdge}) ${signed(current.dy)}, 1px)`;
1497
- const left = `round(anchor(${current.xEdge}) ${signed(current.dx)}, 1px)`;
1503
+ const top = `round(anchor(${current.yEdge}) ${signed(current.dy / zoom)}, 1px)`;
1504
+ const left = `round(anchor(${current.xEdge}) ${signed(current.dx / zoom)}, 1px)`;
1498
1505
  const key = `anchored ${top} ${left}`;
1499
1506
  if (key !== written.current) {
1500
1507
  s.top = top;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tensor_1/react",
3
- "version": "2.40.2",
3
+ "version": "2.42.0",
4
4
  "description": "Thin React wrappers over the UIx v2 CSS component library.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",