@ai-matrx/canvas 0.7.1 → 0.7.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.2
4
+
5
+ Measured live on 0.7.1 (phone 375px; a 363px canvas after a reload):
6
+
7
+ - **A tab's name ends before its close.** A background tab's close used to overlay the name's end (a fade), and on touch every tab showed one, so a name ran under it ("Quick Ch" cut at 103px, close at 90px). Now the close's room is reserved while it shows (hover / focus), and on touch (no hover) only the active tab shows a close - background names keep the room.
8
+ - **The tab fit is re-read until layout settles.** A reload measured the strip before fonts and the header's actions had settled, so two tabs that fit showed "Quick ..." plus one under "All tabs". The strip is re-measured on its own resize, when `document.fonts.ready` resolves, two frames after mount, and whenever the tab count changes.
9
+
10
+ ### Consumer action
11
+
12
+ - None.
13
+
3
14
  ## 0.7.1
4
15
 
5
16
  Measured live on 0.7.0 (a 480px strip, six tabs):
package/dist/react.cjs CHANGED
@@ -3199,15 +3199,30 @@ function TabStrip({ tabs, activeItemId }) {
3199
3199
  const canvas = useCanvas();
3200
3200
  const strip = (0, import_react9.useRef)(null);
3201
3201
  const [width, setWidth] = (0, import_react9.useState)(0);
3202
+ const read = (0, import_react9.useRef)(() => {
3203
+ });
3202
3204
  useIsoLayoutEffect4(() => {
3203
3205
  const el = strip.current;
3204
3206
  if (!el) return void 0;
3205
- const read = () => setWidth(Math.floor(el.getBoundingClientRect().width));
3206
- read();
3207
- const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(read);
3207
+ let live = true;
3208
+ const measure = () => {
3209
+ if (live) setWidth(Math.floor(el.getBoundingClientRect().width));
3210
+ };
3211
+ read.current = measure;
3212
+ measure();
3213
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
3208
3214
  observer?.observe(el);
3209
- return () => observer?.disconnect();
3215
+ void document.fonts?.ready?.then(measure);
3216
+ const frame2 = typeof requestAnimationFrame === "undefined" ? 0 : requestAnimationFrame(() => requestAnimationFrame(measure));
3217
+ return () => {
3218
+ live = false;
3219
+ observer?.disconnect();
3220
+ if (frame2 && typeof cancelAnimationFrame !== "undefined") cancelAnimationFrame(frame2);
3221
+ };
3210
3222
  }, []);
3223
+ useIsoLayoutEffect4(() => {
3224
+ read.current();
3225
+ }, [tabs.length]);
3211
3226
  const activeIndex = Math.max(0, tabs.findIndex((tab) => tab.itemId === activeItemId));
3212
3227
  const fit = fitCanvasTabs(tabs.length, activeIndex, width);
3213
3228
  const shown = tabs.slice(fit.start, fit.end);