@usableapp/cardds 0.7.119 → 0.7.121

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.
@@ -27,6 +27,8 @@ export interface StackSheetProps extends Omit<ComponentProps<'article'>, 'title'
27
27
  defaultTab?: string;
28
28
  /** a tab was tapped: its id */
29
29
  onTabChange?: (tab: string) => void;
30
+ /** a row pinned under the SHEET HEAD, outside the body's scroll and pull (a form button over a list): it never scrolls nor moves with a pull to refresh */
31
+ top?: ReactNode;
30
32
  /** the SHEET FOOT: the CTA at the sheet's bottom (one row) */
31
33
  foot?: ReactNode;
32
34
  /** the back button's label (shown once the sheet is open) — cardds names it in the page's language (`<html lang>`); pass it only for different words */
@@ -39,9 +41,9 @@ export interface StackSheetProps extends Omit<ComponentProps<'article'>, 'title'
39
41
  }
40
42
  /**
41
43
  * StackSheet — ONE sheet of a `SheetStack`, in the one sheet shape: SHEET HEAD (back · title · tabs or an icon) pinned at the top ·
42
- * SHEET BODY (the children; scrolls) · SHEET FOOT (`foot`, the CTA) at the bottom. Its tabs are icon buttons. The chosen one is filled
44
+ * `top` (pinned under the head, optional) · SHEET BODY (the children; scrolls) · SHEET FOOT (`foot`, the CTA) at the bottom. Its tabs are icon buttons. The chosen one is filled
43
45
  * only while this sheet is open — a closed home shows every icon plain; the disc fades in with the rise and out with the fold.
44
46
  * A count shows as a small circle over its icon. The body is the app's: render the page of the chosen tab (and nothing while the sheet
45
47
  * is closed — see `Home`). A direct child of `SheetStack`. Once open, cardds puts the cursor in the field marked `data-autofocus`, else the first field, else the heading — write no focus code.
46
48
  */
47
- export declare function StackSheet({ title, tone, paper, icon, tabs, tab: tabProp, defaultTab, onTabChange, foot, backLabel, backAt, stack, className, children, ...rest }: StackSheetProps): import("react").JSX.Element;
49
+ export declare function StackSheet({ title, tone, paper, icon, tabs, tab: tabProp, defaultTab, onTabChange, top, foot, backLabel, backAt, stack, className, children, ...rest }: StackSheetProps): import("react").JSX.Element;
@@ -15,12 +15,12 @@ import { word } from '../words.js';
15
15
  import { runOver } from './sheetMeasure.js';
16
16
  /**
17
17
  * StackSheet — ONE sheet of a `SheetStack`, in the one sheet shape: SHEET HEAD (back · title · tabs or an icon) pinned at the top ·
18
- * SHEET BODY (the children; scrolls) · SHEET FOOT (`foot`, the CTA) at the bottom. Its tabs are icon buttons. The chosen one is filled
18
+ * `top` (pinned under the head, optional) · SHEET BODY (the children; scrolls) · SHEET FOOT (`foot`, the CTA) at the bottom. Its tabs are icon buttons. The chosen one is filled
19
19
  * only while this sheet is open — a closed home shows every icon plain; the disc fades in with the rise and out with the fold.
20
20
  * A count shows as a small circle over its icon. The body is the app's: render the page of the chosen tab (and nothing while the sheet
21
21
  * is closed — see `Home`). A direct child of `SheetStack`. Once open, cardds puts the cursor in the field marked `data-autofocus`, else the first field, else the heading — write no focus code.
22
22
  */
23
- export function StackSheet({ title, tone, paper, icon, tabs, tab: tabProp, defaultTab, onTabChange, foot, backLabel = word('back'), backAt = 'none', stack, className, children, ...rest }) {
23
+ export function StackSheet({ title, tone, paper, icon, tabs, tab: tabProp, defaultTab, onTabChange, top, foot, backLabel = word('back'), backAt = 'none', stack, className, children, ...rest }) {
24
24
  const [tab, pick] = useControlled(tabProp, defaultTab ?? tabs?.[0]?.id, onTabChange);
25
25
  // a title longer than its room does not wrap: it runs sideways, like a song title in a short slot — the room it overflows by
26
26
  // is measured here (the tabs may grow with the text size) and handed to the CSS as --_over / --_run, the Sheet's measurer
@@ -34,5 +34,5 @@ export function StackSheet({ title, tone, paper, icon, tabs, tab: tabProp, defau
34
34
  measure();
35
35
  return watchSize([h, run], measure);
36
36
  }, [title]);
37
- return (_jsxs(Card, { stack: stack, tone: tone, paper: paper, className: cx('stack-sheet', className), ...rest, children: [_jsxs(Head, { ref: headRef, long: long, children: [backAt === 'start' && _jsx(StackBack, { label: backLabel }), _jsx(Words, { title: _jsx("span", { className: "stack-sheet__run", children: title }) }), tabs?.length ? (_jsx("span", { className: "stack-sheet__tabs", role: "tablist", children: tabs.map((t) => (_jsxs(IconBtn, { sm: true, invert: t.id === tab, role: "tab", "aria-selected": t.id === tab, label: t.label, className: "stack-sheet__tab", onClick: () => pick(t.id), children: [_jsx(Icon, { name: t.icon }), t.count ? _jsx(Badge, { className: "stack-sheet__count", children: t.count > 99 ? '99+' : t.count }) : null] }, t.id))) })) : icon, backAt === 'end' && _jsx(StackBack, { end: true, label: backLabel })] }), _jsx(Body, { role: tabs?.length ? 'tabpanel' : undefined, children: children }), foot != null && _jsx(Foot, { children: foot })] }));
37
+ return (_jsxs(Card, { stack: stack, tone: tone, paper: paper, className: cx('stack-sheet', className), ...rest, children: [_jsxs(Head, { ref: headRef, long: long, children: [backAt === 'start' && _jsx(StackBack, { label: backLabel }), _jsx(Words, { title: _jsx("span", { className: "stack-sheet__run", children: title }) }), tabs?.length ? (_jsx("span", { className: "stack-sheet__tabs", role: "tablist", children: tabs.map((t) => (_jsxs(IconBtn, { sm: true, invert: t.id === tab, role: "tab", "aria-selected": t.id === tab, label: t.label, className: "stack-sheet__tab", onClick: () => pick(t.id), children: [_jsx(Icon, { name: t.icon }), t.count ? _jsx(Badge, { className: "stack-sheet__count", children: t.count > 99 ? '99+' : t.count }) : null] }, t.id))) })) : icon, backAt === 'end' && _jsx(StackBack, { end: true, label: backLabel })] }), top != null && _jsx("div", { className: "stack-sheet__top", children: top }), _jsx(Body, { role: tabs?.length ? 'tabpanel' : undefined, children: children }), foot != null && _jsx(Foot, { children: foot })] }));
38
38
  }
@@ -21,6 +21,8 @@ export interface HomeSheet {
21
21
  onTabChange?: (tab: string) => void;
22
22
  /** the SHEET BODY — rendered only while the sheet is open (or kept, with `keep`); a function gets the chosen tab */
23
23
  body: ReactNode | ((tab?: string) => ReactNode);
24
+ /** a row pinned under the SHEET HEAD, outside the body's scroll and pull — see `StackSheet top`; a function gets the chosen tab (return null for no row) */
25
+ top?: ReactNode | ((tab?: string) => ReactNode);
24
26
  /** the SHEET FOOT: the CTA at the sheet's bottom (one row); a function gets the chosen tab */
25
27
  foot?: ReactNode | ((tab?: string) => ReactNode);
26
28
  }
@@ -51,5 +51,5 @@ export function Home({ top, title, sheets, open: openProp, defaultOpen = null, o
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
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
+ 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, top: shows(i) ? (typeof s.top === 'function' ? s.top(tabOf(i)) : s.top) : null, 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] }));
55
55
  }
package/docs/reference.md CHANGED
@@ -282,7 +282,7 @@ the card is the material, the sheet is what it is in the stack.
282
282
  A tap, or a pull up, opens any sheet over it. The open title or its back
283
283
  button, tapped or pulled down, drops it home. A pull down in the open
284
284
  content, already at the top, asks `onRefresh` — omit it and that pull only
285
- scrolls. A tab in the head stays a click. Every sheet wears a grip — four
285
+ scrolls. A `StackSheet`'s `top` is a row pinned under its head (a form button over a list): outside the scroll and the pull, it never moves with them. A tab in the head stays a click. Every sheet wears a grip — four
286
286
  small dots at the middle of its top edge, a mark that it slides, not a
287
287
  control. `mark="line"` on the `SheetStack` (or `Home`) draws one line
288
288
  there instead, as a single `Sheet`'s; while a sheet is `refreshing`, either
@@ -300,6 +300,8 @@ the card is the material, the sheet is what it is in the stack.
300
300
  that tab shows, and a tapped tab asks `onTabChange(tab)`. Something outside
301
301
  the stack (a card in the base) brings a sheet up on a named tab by setting
302
302
  that sheet's `tab` and the Home's `open` together. Story `Home · Feed`.
303
+ A sheet's `top` reaches `StackSheet top`; like `body` and `foot` it may be a
304
+ function of the tab, returning null where that tab has no row.
303
305
  - **Five sheets max.** Slots are declared per `:nth-child` in `stack.css`; a
304
306
  sixth would render at slot 0, on top of the first.
305
307
  - **Every head needs its own `.sheet-stack__back`** if the stack is `--tap`. It stays
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usableapp/cardds",
3
- "version": "0.7.119",
3
+ "version": "0.7.121",
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.",