@fasl-work/caos-app-shell 0.8.0 → 0.8.1

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/index.js CHANGED
@@ -1264,11 +1264,11 @@ function BarChart({ title, data, axis, orientation = "horizontal", values = true
1264
1264
  const t1 = ticks[ticks.length - 1];
1265
1265
  const tickLabels = formatTicks(ticks, lang, fmt);
1266
1266
  const sx = (v) => x0 + (v - t0) / (t1 - t0 || 1) * (x1 - x0);
1267
- const rowH = fill && box.height > 0 ? Math.max(need, Math.min(need * 2.2, (box.height - axisH - 4) / data.length)) : need;
1267
+ const rowH = fill && box.height > 0 ? Math.max(need, (box.height - axisH - 4) / data.length) : need;
1268
1268
  const top = 4;
1269
1269
  const plotBottom = top + data.length * rowH;
1270
1270
  drawnHeight = fill && box.height > 0 ? Math.max(box.height, plotBottom + axisH) : plotBottom + axisH;
1271
- const barH = Math.min(rowH * 0.62, 28);
1271
+ const barH = Math.min(rowH * 0.5, 40);
1272
1272
  drawing = /* @__PURE__ */ jsxs("svg", { width, height: drawnHeight, role: "img", "aria-label": name, "data-chart": "", "data-chart-kind": "bars", children: [
1273
1273
  /* @__PURE__ */ jsx("title", { children: name }),
1274
1274
  ticks.map((t, i) => /* @__PURE__ */ jsxs("g", { children: [
package/gate/inpage.mjs CHANGED
@@ -17,6 +17,11 @@ export function installLib() {
17
17
  });
18
18
  }
19
19
 
20
+ /** The ancestors of an element up to (not including) `stop`. */
21
+ function* ancestorsUntil(el, stop) {
22
+ for (let a = el.parentElement; a && a !== stop && a !== document.body; a = a.parentElement) yield a;
23
+ }
24
+
20
25
  const visible = (el) => {
21
26
  if (!el || el.nodeType !== 1) return false;
22
27
  const r = el.getBoundingClientRect();
@@ -233,7 +238,9 @@ export function installLib() {
233
238
  y,
234
239
  w: x2 - x,
235
240
  h: y2 - y,
236
- right: r.right,
241
+ // a table or drawing inside a box that SCROLLS sideways (a wide table on a phone, ADR-0071 rule 3) ends where
242
+ // its box ends: a reader scrolls it; one cut by a box that hides its overflow still extends past the page
243
+ right: Math.min(r.right, ...[...ancestorsUntil(el, inst)].filter((a) => ['auto', 'scroll'].includes(getComputedStyle(a).overflowX)).map((a) => a.getBoundingClientRect().right)),
237
244
  stageKey: path(stageEl),
238
245
  stage: clipRect(stageEl.getBoundingClientRect()),
239
246
  viewKey: path(viewEl),
@@ -523,6 +530,25 @@ export function installLib() {
523
530
 
524
531
  // ---- 0.8.0 measures ----------------------------------------------------------------------------------------
525
532
 
533
+ /** The part of the page the ancestors of an element let it show when they CUT their content (overflow hidden or
534
+ * clip). A scroll container does not cut (a reader scrolls it), and neither does the viewport. */
535
+ const cutArea = (el) => {
536
+ const area = { left: -Infinity, top: -Infinity, right: Infinity, bottom: Infinity };
537
+ for (let a = el.parentElement; a && a !== document.body && a !== document.documentElement; a = a.parentElement) {
538
+ const s = getComputedStyle(a);
539
+ const ar = a.getBoundingClientRect();
540
+ if (s.overflowX === 'hidden' || s.overflowX === 'clip') {
541
+ area.left = Math.max(area.left, ar.left);
542
+ area.right = Math.min(area.right, ar.right);
543
+ }
544
+ if (s.overflowY === 'hidden' || s.overflowY === 'clip') {
545
+ area.top = Math.max(area.top, ar.top);
546
+ area.bottom = Math.min(area.bottom, ar.bottom);
547
+ }
548
+ }
549
+ return area;
550
+ };
551
+
526
552
  /** The boxes a text element occupies on screen: one per line (tspan) when it has several. */
527
553
  const textBoxes = (t) => {
528
554
  const spans = [...t.querySelectorAll('tspan')].filter((s) => (s.textContent || '').trim());
@@ -550,7 +576,7 @@ export function installLib() {
550
576
  if (svg.classList.contains('lucide') || !visible(svg)) continue;
551
577
  const sr = svg.getBoundingClientRect();
552
578
  if (sr.width < 48 || sr.height < 24) continue;
553
- const area = visibleArea(svg);
579
+ const area = cutArea(svg);
554
580
  const box = { left: Math.max(sr.left, area.left), top: Math.max(sr.top, area.top), right: Math.min(sr.right, area.right), bottom: Math.min(sr.bottom, area.bottom) };
555
581
  const name = describe(svg.closest('[data-plot]') || svg);
556
582
  const texts = [...svg.querySelectorAll('text')].filter((t) => (t.textContent || '').trim() && visible(t));
@@ -559,7 +585,7 @@ export function installLib() {
559
585
  for (const b of textBoxes(t)) {
560
586
  // a label outside the visible part of the drawing: cut, or drawn where no one sees it
561
587
  if (b.top >= box.bottom || b.bottom <= box.top) {
562
- if (sr.bottom <= area.bottom + 1 && sr.top >= area.top - 1) out.push(`${name}: the label "${(t.textContent || '').trim().slice(0, 40)}" lies outside the drawing`);
588
+ out.push(`${name}: the label "${(t.textContent || '').trim().slice(0, 40)}" lies outside the drawing`);
563
589
  continue;
564
590
  }
565
591
  const cutX = Math.max(0, box.left - b.left) + Math.max(0, b.right - box.right);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fasl-work/caos-app-shell",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Shared web-app shell, workbench primitives, content primitives, design system and measured gate for the CAOS / Faena public apps (ADR-0016, ADR-0017, ADR-0071).",
5
5
  "license": "MIT",
6
6
  "author": "Felipe Santibáñez-Leal",