@usableapp/cardds 0.7.77 → 0.7.79

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.d.ts CHANGED
@@ -24,6 +24,7 @@ export * from './cards/Card.js';
24
24
  export * from './cards/CardHead.js';
25
25
  export * from './cards/CardFoot.js';
26
26
  export * from './cards/CardParts.js';
27
+ export * from './cards/CardFeed.js';
27
28
  export * from './cards/Stat.js';
28
29
  export * from './cards/Placeholder.js';
29
30
  export * from './sheets/SheetStack.js';
package/dist/index.js CHANGED
@@ -28,6 +28,7 @@ export * from './cards/Card.js';
28
28
  export * from './cards/CardHead.js';
29
29
  export * from './cards/CardFoot.js';
30
30
  export * from './cards/CardParts.js';
31
+ export * from './cards/CardFeed.js';
31
32
  export * from './cards/Stat.js';
32
33
  export * from './cards/Placeholder.js';
33
34
  export * from './sheets/SheetStack.js';
@@ -21,7 +21,7 @@ export interface SheetStackProps extends ComponentProps<'div'> {
21
21
  closed?: boolean;
22
22
  /** how an OPEN sheet meets the top bar of a closed stack in a `Screen fill`: `under` (default) stops under the bar · `flood` rises over it and fills the WHOLE screen (from the safe-top line down), the bar covered and hidden while a sheet is open. Only for a `closed` tap stack (warns once otherwise). Nothing resizes: the bar is a layer under the sheets */
23
23
  rise?: 'under' | 'flood';
24
- /** what the base shows in a closed stack's headroom, behind the sheets, laid out against the peeks (a picture, a greeting) */
24
+ /** what the base shows in a closed stack's headroom, behind the sheets, laid out against the peeks (a picture, a greeting). A room too short for it keeps the upper thing whole and scrolls: the rest lies under the heads until the member scrolls up to it */
25
25
  base?: ReactNode;
26
26
  }
27
27
  /**
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Children, cloneElement, isValidElement, useEffect, useLayoutEffect, useRef, useState } from 'react';
3
- import { useControlled, warnOnce } from '../state.js';
3
+ import { useControlled, warnOnce, watchSize } from '../state.js';
4
4
  import { cx } from '../cx.js';
5
5
  import { Card } from '../cards/Card.js';
6
6
  import { StackSheet } from './StackSheet.js';
@@ -25,6 +25,19 @@ function measureRests(stack) {
25
25
  };
26
26
  }
27
27
  const SLOP = 8; // px a pointer may travel and still be a tap
28
+ /* the base's room either holds what stands in it or is too short for it (`is-long`). The CSS lays both out the same way, from the
29
+ room's top once there is no room to spare, so the measure does not feed back; the class only says there is something to scroll. */
30
+ function StackBase({ children }) {
31
+ const ref = useRef(null);
32
+ const [long, setLong] = useState(false);
33
+ useLayoutEffect(() => {
34
+ const box = ref.current;
35
+ if (!box)
36
+ return;
37
+ return watchSize([box, ...box.children], () => setLong(box.scrollHeight - box.clientHeight > 1));
38
+ });
39
+ return _jsx("div", { ref: ref, className: cx('sheet-stack__base', long && 'is-long'), children: children });
40
+ }
28
41
  /* one wrapper around a sheet is fine (a host's own box). The props land on the Card or StackSheet inside it, so the card renders them. */
29
42
  function stamp(child, place) {
30
43
  if (SHEET.has(child.type))
@@ -163,5 +176,5 @@ export function SheetStack({ mode = 'tap', open, defaultOpen = null, onOpenChang
163
176
  };
164
177
  return stamp(child, place);
165
178
  }) : items;
166
- return (_jsxs("div", { className: cx('sheet-stack', mode !== 'static' && `sheet-stack--${mode}`, fanned && 'sheet-stack--fanned', closed && 'sheet-stack--closed', flood && 'sheet-stack--flood', className), ...rest, ref: setRef, onClickCapture: clickCapture, onPointerDownCapture: pointerDownCapture, children: [stamped, base != null && _jsx("div", { className: "sheet-stack__base", children: base })] }));
179
+ return (_jsxs("div", { className: cx('sheet-stack', mode !== 'static' && `sheet-stack--${mode}`, fanned && 'sheet-stack--fanned', closed && 'sheet-stack--closed', flood && 'sheet-stack--flood', className), ...rest, ref: setRef, onClickCapture: clickCapture, onPointerDownCapture: pointerDownCapture, children: [stamped, base != null && _jsx(StackBase, { children: base })] }));
167
180
  }
@@ -13,8 +13,12 @@ export interface HomeSheet {
13
13
  paper?: boolean;
14
14
  /** the sheet's pages as icon tabs in its head (a count shows as a small circle over the icon) — see `StackSheet` */
15
15
  tabs?: StackSheetTab[];
16
- /** the tab shown first (default: the first) */
16
+ /** CONTROLLED: the tab this sheet shows (its id) — with `onTabChange`. The app sets it to bring the sheet up on a named tab; without it the Home keeps the sheet's tab itself */
17
+ tab?: string;
18
+ /** UNCONTROLLED: the tab shown first (default: the first); the Home then keeps its own. Pair of `tab` */
17
19
  defaultTab?: string;
20
+ /** a tab of this sheet was tapped: its id */
21
+ onTabChange?: (tab: string) => void;
18
22
  /** the SHEET BODY — rendered only while the sheet is open (or kept, with `keep`); a function gets the chosen tab */
19
23
  body: ReactNode | ((tab?: string) => ReactNode);
20
24
  /** the SHEET FOOT: the CTA at the sheet's bottom (one row); a function gets the chosen tab */
@@ -50,5 +50,6 @@ export function Home({ top, title, sheets, open: openProp, defaultOpen = null, o
50
50
  }, [leaving]);
51
51
  const [tabs, setTabs] = useState(() => Object.fromEntries(sheets.map((x, i) => [i, x.defaultTab ?? x.tabs?.[0]?.id])));
52
52
  const shows = (i) => i === shown || i === leaving || (keep && seen.has(i));
53
- return (_jsxs(Screen, { fill: true, top: top, ...rest, children: [_jsx(Text, { level: "h1", as: "h1", sr: true, children: title }), _jsx(SheetStack, { closed: true, open: shown, onOpenChange: request, onRefresh: onRefresh, refreshing: refreshing, mark: mark, rise: rise, base: base, children: sheets.map((s, i) => (_jsx(StackSheet, { tone: s.tone ?? TONES[i], paper: s.paper, title: s.title, icon: s.icon, tabs: s.tabs, tab: tabs[i], onTabChange: (t) => setTabs((v) => ({ ...v, [i]: t })), backLabel: backLabel, backAt: backAt, foot: typeof s.foot === 'function' ? s.foot(tabs[i]) : s.foot, children: shows(i) ? (typeof s.body === 'function' ? s.body(tabs[i]) : s.body) : null }, i))) }), children] }));
53
+ const tabOf = (i) => sheets[i].tab ?? tabs[i];
54
+ return (_jsxs(Screen, { fill: true, top: top, ...rest, children: [_jsx(Text, { level: "h1", as: "h1", sr: true, children: title }), _jsx(SheetStack, { closed: true, open: shown, onOpenChange: request, onRefresh: onRefresh, refreshing: refreshing, mark: mark, rise: rise, base: base, children: sheets.map((s, i) => (_jsx(StackSheet, { tone: s.tone ?? TONES[i], paper: s.paper, title: s.title, icon: s.icon, tabs: s.tabs, tab: tabOf(i), onTabChange: (t) => { setTabs((v) => ({ ...v, [i]: t })); s.onTabChange?.(t); }, backLabel: backLabel, backAt: backAt, foot: typeof s.foot === 'function' ? s.foot(tabOf(i)) : s.foot, children: shows(i) ? (typeof s.body === 'function' ? s.body(tabOf(i)) : s.body) : null }, i))) }), children] }));
54
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usableapp/cardds",
3
- "version": "0.7.77",
3
+ "version": "0.7.79",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "description": "card-first mobile design system, React-first: the components in src/ are thin wrappers over the CSS contract (css/*.css stays the only truth); gallery/ shows every story live (npm run dev), tests/ measures the geometry.",
@@ -13,6 +13,7 @@
13
13
  "build": "node scripts/build-icons.mjs && tsc -p tsconfig.json && node scripts/flatten-css.mjs && node scripts/build-catalog.mjs",
14
14
  "test": "playwright test",
15
15
  "validate:inbox": "node scripts/validate-inbox.mjs",
16
+ "ci": "npm run validate:inbox && npm run typecheck && npm run check && playwright test",
16
17
  "prepack": "npm run build",
17
18
  "knobs": "node scripts/knobs.mjs",
18
19
  "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p gallery/tsconfig.json --noEmit",