@usableapp/cardds 0.7.166 → 0.7.167
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 +21 -0
- package/bin/cardds.mjs +4 -3
- package/css/lists.css +8 -1
- package/css/parts.css +7 -4
- package/css/stack.css +1 -1
- package/dist/cardds.css +16 -6
- package/dist/cards/Card.js +2 -1
- package/dist/cards/CardFeed.js +1 -2
- package/dist/catalog.json +1 -1
- package/dist/lists/Bubble.d.ts +29 -5
- package/dist/lists/Bubble.js +70 -9
- package/dist/parts/Head.d.ts +57 -13
- package/dist/parts/Head.js +72 -31
- package/dist/parts/Words.d.ts +2 -2
- package/dist/parts/Words.js +2 -2
- package/dist/parts/endRoom.d.ts +2 -0
- package/dist/parts/endRoom.js +1 -1
- package/dist/parts/headCtx.d.ts +3 -0
- package/dist/parts/headCtx.js +3 -0
- package/dist/sheets/Modal.d.ts +1 -1
- package/dist/sheets/Modal.js +4 -2
- package/dist/sheets/Sheet.d.ts +3 -2
- package/dist/sheets/Sheet.js +4 -1
- package/dist/sheets/StackBack.d.ts +1 -1
- package/dist/sheets/StackBack.js +1 -1
- package/dist/sheets/StackSheet.js +4 -6
- package/dist/sheets/sheetMeasure.js +1 -1
- package/dist/templates/CallSheet.js +2 -3
- package/dist/templates/Walkthrough.js +1 -2
- package/dist/type/icons.d.ts +1 -1
- package/dist/type/icons.js +2 -2
- package/dist/words.d.ts +1 -1
- package/dist/words.js +2 -2
- package/docs/reference.md +51 -28
- package/icons.svg +2 -1
- package/lib/guide.mjs +6 -5
- package/lint/headSlots.d.mts +2 -0
- package/lint/headSlots.mjs +15 -0
- package/lint/rules.mjs +42 -1
- package/package.json +2 -1
- package/scripts/codemod-head.mjs +306 -0
- package/scripts/codemod-parts.mjs +2 -1
package/dist/lists/Bubble.d.ts
CHANGED
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
import { type ComponentProps, type KeyboardEvent, type ReactNode } from 'react';
|
|
2
2
|
export interface ThreadProps extends ComponentProps<'div'> {
|
|
3
|
+
/** where a Bubble's `author` shows: `none` (default — a 1-to-1 chat, the head already names the person), `change` (a group chat:
|
|
4
|
+
* only where the sender changes from the bubble before), `every` (each bubble) */
|
|
5
|
+
authors?: 'none' | 'change' | 'every';
|
|
6
|
+
/** where a Bubble's `day` shows: `change` (default — only where the day changes from the bubble before), `every` (each bubble) */
|
|
7
|
+
days?: 'change' | 'every';
|
|
8
|
+
/** the jump-to-latest button's accessible name (default cardds's own word, "Latest messages"); `false` drops the button */
|
|
9
|
+
jumpLabel?: string | false;
|
|
3
10
|
}
|
|
4
|
-
/**
|
|
5
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Thread — a stack of Bubbles: a chat, a conversation turn by turn. It FOLLOWS ITS END: while the reader is at the last words, it stays
|
|
13
|
+
* at the bottom when its scroller or its words resize (the keyboard comes up, the MessageBar grows, a message is added). Scrolled up
|
|
14
|
+
* away from the end, a round `Btn` (arrow-down, 48px) stands at the bottom corner and slides back to the last words; at the end it is
|
|
15
|
+
* gone. The thread ends with room (`--thread-end-size`) so the last bubble and its `meta` clear the bar under it. `authors` says where a
|
|
16
|
+
* Bubble's `author` shows (default nowhere: the head already names the person).
|
|
17
|
+
*/
|
|
18
|
+
export declare function Thread({ authors, days, jumpLabel, className, children, ref, ...rest }: ThreadProps): import("react").JSX.Element;
|
|
6
19
|
export interface BubbleProps extends Omit<ComponentProps<'div'>, 'onClick'> {
|
|
7
20
|
/** whose: theirs on the left (default), mine on the right */
|
|
8
21
|
side?: 'left' | 'right';
|
|
9
22
|
/** the caption under the message — a time, a tick (an Icon) */
|
|
10
23
|
meta?: ReactNode;
|
|
24
|
+
/** who sent it ("Noi", "You"): shown at the start of the `meta` line where the Thread's `authors` says (default nowhere). Compared by
|
|
25
|
+
* value with the bubble before, so pass a string */
|
|
26
|
+
author?: ReactNode;
|
|
27
|
+
/** show `author` on this bubble (the Thread sets it from `authors`; set it yourself to override one bubble) */
|
|
28
|
+
showAuthor?: boolean;
|
|
29
|
+
/** the day it was sent ("Dec 4", "เมื่อวาน"): shown on the `meta` line before the time only where it changes from the bubble before
|
|
30
|
+
* (the Thread decides; `days="every"` shows it on each). Compared by value, so pass a string; put the time alone in `meta` */
|
|
31
|
+
day?: ReactNode;
|
|
32
|
+
/** show `day` on this bubble (the Thread sets it; set it yourself to override one bubble). Outside a Thread it shows */
|
|
33
|
+
showDay?: boolean;
|
|
11
34
|
/** the message is a LINK: the bubble renders an `<a>` (the chat it belongs to, opened at it) and dims under the finger */
|
|
12
35
|
href?: string;
|
|
13
36
|
/** with `href`: where the link opens (`_blank`) */
|
|
@@ -21,10 +44,11 @@ export interface BubbleProps extends Omit<ComponentProps<'div'>, 'onClick'> {
|
|
|
21
44
|
}
|
|
22
45
|
/**
|
|
23
46
|
* Bubble — a chat message: a rounded block, its corner nearest the sender squared (bottom-left for theirs, bottom-right
|
|
24
|
-
* for mine), no tail. `meta` sits under it on the sender's side
|
|
25
|
-
* under the finger); `highlighted` rings the message the member is
|
|
47
|
+
* for mine), no tail. `meta` sits under it on the sender's side, led by `author` where the Thread's `authors` allows. Stack them in a
|
|
48
|
+
* Thread. `href` makes it a link, `onClick` a pressed one (both dim under the finger); `highlighted` rings the message the member is
|
|
49
|
+
* looking at (the one a reply points at).
|
|
26
50
|
*/
|
|
27
|
-
export declare function Bubble({ side, meta, href, target, rel, onClick, highlighted, className, children, onKeyDown, ...rest }: BubbleProps): import("react").DetailedReactHTMLElement<{
|
|
51
|
+
export declare function Bubble({ side, meta, author, showAuthor, day, showDay, href, target, rel, onClick, highlighted, className, children, onKeyDown, ...rest }: BubbleProps): import("react").DetailedReactHTMLElement<{
|
|
28
52
|
className: string;
|
|
29
53
|
href: string;
|
|
30
54
|
target: string | undefined;
|
package/dist/lists/Bubble.js
CHANGED
|
@@ -1,17 +1,78 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createElement } from 'react';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Children, cloneElement, createElement, isValidElement, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { cx } from '../cx.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { reducedMotion, setRefs, watchSize } from '../state.js';
|
|
5
|
+
import { word } from '../words.js';
|
|
6
|
+
import { Btn } from '../actions/Btn.js';
|
|
7
|
+
/* the scroller a thread reads in: the nearest ancestor that scrolls (a Sheet's Body, a Page) */
|
|
8
|
+
function scrollerOf(el) {
|
|
9
|
+
for (let p = el.parentElement; p; p = p.parentElement)
|
|
10
|
+
if (/(auto|scroll)/.test(getComputedStyle(p).overflowY))
|
|
11
|
+
return p;
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const AT_END = 8; // px of slack: a scroll that stops a hair short of the end is still at the end
|
|
15
|
+
/**
|
|
16
|
+
* Thread — a stack of Bubbles: a chat, a conversation turn by turn. It FOLLOWS ITS END: while the reader is at the last words, it stays
|
|
17
|
+
* at the bottom when its scroller or its words resize (the keyboard comes up, the MessageBar grows, a message is added). Scrolled up
|
|
18
|
+
* away from the end, a round `Btn` (arrow-down, 48px) stands at the bottom corner and slides back to the last words; at the end it is
|
|
19
|
+
* gone. The thread ends with room (`--thread-end-size`) so the last bubble and its `meta` clear the bar under it. `authors` says where a
|
|
20
|
+
* Bubble's `author` shows (default nowhere: the head already names the person).
|
|
21
|
+
*/
|
|
22
|
+
export function Thread({ authors = 'none', days = 'change', jumpLabel, className, children, ref, ...rest }) {
|
|
23
|
+
const own = useRef(null);
|
|
24
|
+
const atEnd = useRef(true);
|
|
25
|
+
const [away, setAway] = useState(false);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const el = own.current, box = el && scrollerOf(el);
|
|
28
|
+
if (!el || !box)
|
|
29
|
+
return;
|
|
30
|
+
const look = () => { atEnd.current = box.scrollHeight - box.scrollTop - box.clientHeight <= AT_END; setAway(!atEnd.current); };
|
|
31
|
+
const follow = () => { if (atEnd.current)
|
|
32
|
+
box.scrollTop = box.scrollHeight;
|
|
33
|
+
else
|
|
34
|
+
look(); };
|
|
35
|
+
box.addEventListener('scroll', look, { passive: true });
|
|
36
|
+
const stop = watchSize([box, el], follow);
|
|
37
|
+
const vv = typeof visualViewport === 'undefined' ? null : visualViewport;
|
|
38
|
+
vv?.addEventListener('resize', follow);
|
|
39
|
+
look();
|
|
40
|
+
return () => { box.removeEventListener('scroll', look); stop(); vv?.removeEventListener('resize', follow); };
|
|
41
|
+
}, []);
|
|
42
|
+
const jump = () => {
|
|
43
|
+
const box = own.current && scrollerOf(own.current);
|
|
44
|
+
box?.scrollTo({ top: box.scrollHeight, behavior: reducedMotion() ? 'auto' : 'smooth' });
|
|
45
|
+
};
|
|
46
|
+
let last, lastDay;
|
|
47
|
+
const marked = Children.map(children, (node) => {
|
|
48
|
+
if (!isValidElement(node))
|
|
49
|
+
return node;
|
|
50
|
+
const { author: who, day, showAuthor, showDay } = node.props;
|
|
51
|
+
const set = {};
|
|
52
|
+
if (who !== undefined) {
|
|
53
|
+
if (showAuthor === undefined)
|
|
54
|
+
set.showAuthor = authors === 'every' || (authors === 'change' && who !== last);
|
|
55
|
+
last = who;
|
|
56
|
+
}
|
|
57
|
+
if (day !== undefined) {
|
|
58
|
+
if (showDay === undefined)
|
|
59
|
+
set.showDay = days === 'every' || day !== lastDay;
|
|
60
|
+
lastDay = day;
|
|
61
|
+
}
|
|
62
|
+
return Object.keys(set).length ? cloneElement(node, set) : node;
|
|
63
|
+
});
|
|
64
|
+
return (_jsxs("div", { ref: setRefs(own, ref), className: cx('thread', className), ...rest, children: [marked, jumpLabel !== false && (_jsx("div", { className: "thread__end", children: away && _jsx(Btn, { shape: "round", icon: "arrow-down", label: jumpLabel ?? word('toLatest'), className: "thread__jump", onClick: jump }) }))] }));
|
|
7
65
|
}
|
|
8
66
|
/**
|
|
9
67
|
* Bubble — a chat message: a rounded block, its corner nearest the sender squared (bottom-left for theirs, bottom-right
|
|
10
|
-
* for mine), no tail. `meta` sits under it on the sender's side
|
|
11
|
-
* under the finger); `highlighted` rings the message the member is
|
|
68
|
+
* for mine), no tail. `meta` sits under it on the sender's side, led by `author` where the Thread's `authors` allows. Stack them in a
|
|
69
|
+
* Thread. `href` makes it a link, `onClick` a pressed one (both dim under the finger); `highlighted` rings the message the member is
|
|
70
|
+
* looking at (the one a reply points at).
|
|
12
71
|
*/
|
|
13
|
-
export function Bubble({ side = 'left', meta, href, target, rel, onClick, highlighted, className, children, onKeyDown, ...rest }) {
|
|
72
|
+
export function Bubble({ side = 'left', meta, author, showAuthor, day, showDay, href, target, rel, onClick, highlighted, className, children, onKeyDown, ...rest }) {
|
|
14
73
|
const press = href == null && onClick != null;
|
|
74
|
+
const named = showAuthor === true && author != null;
|
|
75
|
+
const dated = showDay !== false && day != null;
|
|
15
76
|
const keys = (e) => {
|
|
16
77
|
onKeyDown?.(e);
|
|
17
78
|
if (e.defaultPrevented || (e.key !== 'Enter' && e.key !== ' '))
|
|
@@ -23,5 +84,5 @@ export function Bubble({ side = 'left', meta, href, target, rel, onClick, highli
|
|
|
23
84
|
...rest,
|
|
24
85
|
...(href != null ? { href, target, rel, onClick } : press ? { role: 'button', tabIndex: 0, onClick, onKeyDown: keys } : { onKeyDown }),
|
|
25
86
|
className: cx('bubble', side === 'right' && 'bubble--right', (href != null || press) && 'bubble--press', highlighted && 'bubble--highlighted', className),
|
|
26
|
-
}, _jsx("p", { className: "bubble__body", children: children }), meta != null &&
|
|
87
|
+
}, _jsx("p", { className: "bubble__body", children: children }), (meta != null || named || dated) && (_jsxs("span", { className: "bubble__meta", children: [named && _jsx("span", { className: "bubble__author", children: author }), dated && _jsx("span", { className: "bubble__day", children: day }), meta] })));
|
|
27
88
|
}
|
package/dist/parts/Head.d.ts
CHANGED
|
@@ -1,18 +1,62 @@
|
|
|
1
|
-
import { type ComponentProps } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
/** the closed set of heads. The variant lays its slots out; the order they are written in decides nothing:
|
|
3
|
+
* `plain` the title over its meta, the `end` at the far right · `lead` a `Lead`, an `Avatar` or an `AvatarStack` at the left, the title over
|
|
4
|
+
* its meta beside it, the `end` at the top right · `date` a `JourneyBadge stretch` (`lead`) with a `ChipRow` (`chips`) beside it, the title
|
|
5
|
+
* over its meta under both, the `end` under them · `centre` a stage sheet's head: a round `Btn` (`lead`) · the centred title over
|
|
6
|
+
* its meta · a round `Btn` (`end`) · `sheet` a sheet's head: the title over its meta (after a `lead`), its `actions` and the close at the far
|
|
7
|
+
* right · `status` a `tag` chip and an `end` badge on the first row, the status words (`meta`, a line of text, never a heading) under them · `stack` a stack sheet's head: the `back` button, the title, its tabs or an icon (`end`) on one line */
|
|
8
|
+
export type HeadVariant = NonNullable<HeadProps['variant']>;
|
|
9
|
+
export interface HeadProps extends Omit<ComponentProps<'div'>, 'title' | 'onClose'> {
|
|
10
|
+
/** which head this is, one of a closed set (default `plain`); it lays the slots out (see `HeadVariant`). A slot the variant does not
|
|
11
|
+
* take is left out, with a warning */
|
|
12
|
+
variant?: 'plain' | 'lead' | 'date' | 'centre' | 'sheet' | 'stack' | 'status';
|
|
13
|
+
/** the title, a heading (`h2`, or `level`); in a stack sheet's head the keyboard's way in */
|
|
14
|
+
title?: ReactNode;
|
|
15
|
+
/** the caption under the title */
|
|
16
|
+
meta?: ReactNode;
|
|
17
|
+
/** the caption OVER the title (who asks, over the ask) — `plain`, `lead` and `date` */
|
|
18
|
+
over?: ReactNode;
|
|
19
|
+
/** the title's heading level (default `h2`; `h1` for the one-feature page) */
|
|
20
|
+
level?: 'h1' | 'h2' | 'display';
|
|
21
|
+
/** what leads the head at the left: a `Lead`, an `Avatar` or an `AvatarStack` (a `Stamp bare` in one) in `lead` and `sheet`; the date,
|
|
22
|
+
* a `JourneyBadge stretch`, in `date`; the left round `Btn` in `centre` */
|
|
23
|
+
lead?: ReactNode;
|
|
24
|
+
/** `status` only: the tag at the left of the first row, a `Chip` (what this is a status of); the status words are `meta`, the `end` stands at the far right */
|
|
25
|
+
tag?: ReactNode;
|
|
26
|
+
/** `date` only: a `ChipRow` beside the date, as tall as it */
|
|
27
|
+
chips?: ReactNode;
|
|
28
|
+
/** the one thing beside the title: a `Chip`, an `End`, a `Stamp`, a round `Btn size="sm"` (or two, as a fragment) — never a button that
|
|
29
|
+
* finishes the card (that goes in its `Foot`). In `date` it stands on a row under the date, the chips and the title; in `centre` it is the right round `Btn`;
|
|
30
|
+
* in `stack` the sheet's tabs or an icon. Not in `sheet`: there the buttons are `actions` */
|
|
31
|
+
end?: ReactNode;
|
|
32
|
+
/** `sheet` only: round `Btn`s (an icon each) beside the close, before it — two at most (more are left out); drawn at the close's size */
|
|
33
|
+
actions?: ReactNode;
|
|
34
|
+
/** `sheet` only: the close was pressed. The head only asks: the app takes the sheet away (`state="away"`). Without it the `Sheet` round
|
|
35
|
+
* the head is asked to go `away` (its `onStateChange(…, 'close')`); with neither, no close is drawn */
|
|
36
|
+
onClose?: () => void;
|
|
37
|
+
/** `sheet` only: the close's spoken name — cardds names it in the page's language (`<html lang>`); pass it only for different words */
|
|
38
|
+
closeLabel?: string;
|
|
39
|
+
/** `stack` only: the stack sheet's back button, hidden until the sheet is open. `start` before the title (chevron left) · `end` after the
|
|
40
|
+
* tabs (chevron down: the sheet folds down) · none (default): a tap on the open sheet's title folds it */
|
|
41
|
+
back?: 'start' | 'end';
|
|
42
|
+
/** `stack` only: the back button's spoken name — cardds names it in the page's language; pass it only for different words */
|
|
43
|
+
backLabel?: string;
|
|
44
|
+
/** top-align a genuinely tall multi-line title with its control (`plain`, `sheet`) */
|
|
4
45
|
top?: boolean;
|
|
5
|
-
/**
|
|
6
|
-
centre?: boolean;
|
|
7
|
-
/** the sheet measured this title as wider than its line, so the title runs sideways */
|
|
46
|
+
/** set by the sheet that holds the head, never by the app: the sheet measured the title wider than its line, so the title runs sideways */
|
|
8
47
|
long?: boolean;
|
|
48
|
+
/** a head takes no children: it is written by its variant and slots (`npx cardds codemod-head` rewrites a head written with children) */
|
|
49
|
+
children?: never;
|
|
9
50
|
}
|
|
10
51
|
/**
|
|
11
|
-
* Head — the first row of a card, a sheet or a stack sheet: what this is, and the one thing beside it.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
52
|
+
* Head — the first row of a card, a sheet or a stack sheet: what this is, and the one thing beside it. ONE OF A CLOSED SET of heads
|
|
53
|
+
* (`variant`), each filled through named slots — the variant lays them out, never the order they are written in:
|
|
54
|
+
* `plain` (default) `title` · `meta` · `end` · `lead` a person or a thing at the left · `date` a `JourneyBadge stretch` and its `chips` over
|
|
55
|
+
* the title · `centre` a stage sheet's round button · title · round button · `sheet` the title, up to two `actions` and the close, drawn and
|
|
56
|
+
* wired (`onClose`, else the `Sheet` round it goes `away`) · `stack` a stack sheet's back · title · tabs.
|
|
57
|
+
* `<Head title="Sunday market" meta="Saturday · 07:00" end={<Chip>3 new</Chip>} />` ·
|
|
58
|
+
* `<Head variant="sheet" title="Ask for help" onClose={close} actions={<Btn shape="round" icon="flag" label="Report" />} />`.
|
|
59
|
+
* Never put buttons here that finish the card: they go in the foot. A head takes no children. A `Card` finds its `Head` by type, so a consumer's
|
|
60
|
+
* own component that wraps a `Head` is not found.
|
|
17
61
|
*/
|
|
18
|
-
export declare function Head({
|
|
62
|
+
export declare function Head({ variant, title, meta, over, level, tag, lead, chips, end, actions, onClose, closeLabel, back, backLabel, top, long, className, children, ...rest }: HeadProps): import("react").JSX.Element;
|
package/dist/parts/Head.js
CHANGED
|
@@ -1,40 +1,81 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Children, cloneElement, isValidElement, useContext } from 'react';
|
|
2
|
+
import { Children, Fragment, cloneElement, isValidElement, useContext } from 'react';
|
|
3
3
|
import { cx } from '../cx.js';
|
|
4
|
-
import {
|
|
4
|
+
import { warnOnce } from '../state.js';
|
|
5
|
+
import { word } from '../words.js';
|
|
6
|
+
import { Btn } from '../actions/Btn.js';
|
|
7
|
+
import { StackBack } from '../sheets/StackBack.js';
|
|
5
8
|
import { StackHeadCtx } from '../sheets/stackCard.js';
|
|
6
|
-
import {
|
|
7
|
-
import { withEndRoom } from './endRoom.js';
|
|
9
|
+
import { HeadCloseCtx, HeadCtx } from './headCtx.js';
|
|
10
|
+
import { LEADS, withEndRoom } from './endRoom.js';
|
|
8
11
|
import { Words } from './Words.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
import { HEAD_SLOTS, headSlotsText } from '../../lint/headSlots.mjs';
|
|
13
|
+
/** the slots each variant takes beside `title`, `meta` and `level`: the one table, lint/headSlots.mjs (the lint rule reads it too). A slot a variant does not take is left out */
|
|
14
|
+
const TAKES = HEAD_SLOTS;
|
|
15
|
+
/** a sheet head's buttons beside its close: two at most, so the title keeps its room on a phone */
|
|
16
|
+
const ACTIONS_MAX = 2;
|
|
17
|
+
/** a slot's pieces, a fragment opened: `end={<><End …/><Btn …/></>}` is two ends */
|
|
18
|
+
const pieces = (node) => Children.toArray(node).flatMap((c) => (isValidElement(c) && c.type === Fragment ? pieces(c.props.children) : [c]));
|
|
19
|
+
/** a sheet head's action at the close's size: a round `Btn` is drawn `sm`, as the close is */
|
|
20
|
+
function action(node) {
|
|
21
|
+
if (isValidElement(node) && node.type === Btn && node.props.shape === 'round')
|
|
22
|
+
return cloneElement(node, { size: 'sm' });
|
|
23
|
+
warnOnce('head-actions', 'cardds Head variant="sheet": `actions` are round Btns (an icon each, `shape="round"`) — a worded button, or one that finishes the sheet, goes in its Foot.');
|
|
24
|
+
return node;
|
|
25
|
+
}
|
|
26
|
+
/** the head's children in the variant's order, from its slots */
|
|
27
|
+
function slotted(variant, given, words, close) {
|
|
28
|
+
const takes = TAKES[variant] ?? TAKES.plain;
|
|
29
|
+
for (const k of Object.keys(given)) {
|
|
30
|
+
if (given[k] != null && !takes.includes(k))
|
|
31
|
+
warnOnce(`head-slot-${variant}-${k}`, `cardds Head: variant="${variant}" takes no \`${k}\` — it is left out. The slots of each variant: ${headSlotsText()}.`);
|
|
32
|
+
}
|
|
33
|
+
const lead = given.lead, end = given.end;
|
|
34
|
+
if ((variant === 'lead' || variant === 'sheet') && lead != null && !(isValidElement(lead) && LEADS.includes(lead.type)))
|
|
35
|
+
warnOnce(`head-lead-${variant}`, `cardds Head variant="${variant}": the \`lead\` is a Lead, an Avatar or an AvatarStack (a Stamp bare stands in an AvatarStack) — anything else is not laid out as a lead.`);
|
|
36
|
+
switch (variant) {
|
|
37
|
+
case 'status': return [given.tag, words, ...pieces(end)];
|
|
38
|
+
case 'lead': return [lead, words, ...pieces(end)];
|
|
39
|
+
case 'date': return [lead, given.chips, words, ...pieces(end)];
|
|
40
|
+
case 'centre': return [lead, words, end];
|
|
41
|
+
case 'sheet': {
|
|
42
|
+
const acts = pieces(given.actions);
|
|
43
|
+
if (acts.length > ACTIONS_MAX)
|
|
44
|
+
warnOnce('head-actions-max', `cardds Head variant="sheet": ${ACTIONS_MAX} actions at most beside the close — the rest are left out. More choices go in the sheet's Body, or a Menu.`);
|
|
45
|
+
if (!close)
|
|
46
|
+
warnOnce('head-close', 'cardds Head variant="sheet": no `onClose` and no Sheet round the head — the close would do nothing, so none is drawn. Pass onClose.');
|
|
47
|
+
const label = given.closeLabel ?? word('close');
|
|
48
|
+
return [lead, words, ...acts.slice(0, ACTIONS_MAX).map(action), close && _jsx(Btn, { shape: "round", size: "sm", icon: "x", label: label, onClick: () => close() }, "close")];
|
|
49
|
+
}
|
|
50
|
+
case 'stack': {
|
|
51
|
+
const label = given.backLabel ?? word('back');
|
|
52
|
+
return [given.back === 'start' && _jsx(StackBack, { label: label }, "back"), words, end, given.back === 'end' && _jsx(StackBack, { end: true, label: label }, "back")];
|
|
53
|
+
}
|
|
54
|
+
default: return [words, ...pieces(end)];
|
|
55
|
+
}
|
|
27
56
|
}
|
|
28
57
|
/**
|
|
29
|
-
* Head — the first row of a card, a sheet or a stack sheet: what this is, and the one thing beside it.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
58
|
+
* Head — the first row of a card, a sheet or a stack sheet: what this is, and the one thing beside it. ONE OF A CLOSED SET of heads
|
|
59
|
+
* (`variant`), each filled through named slots — the variant lays them out, never the order they are written in:
|
|
60
|
+
* `plain` (default) `title` · `meta` · `end` · `lead` a person or a thing at the left · `date` a `JourneyBadge stretch` and its `chips` over
|
|
61
|
+
* the title · `centre` a stage sheet's round button · title · round button · `sheet` the title, up to two `actions` and the close, drawn and
|
|
62
|
+
* wired (`onClose`, else the `Sheet` round it goes `away`) · `stack` a stack sheet's back · title · tabs.
|
|
63
|
+
* `<Head title="Sunday market" meta="Saturday · 07:00" end={<Chip>3 new</Chip>} />` ·
|
|
64
|
+
* `<Head variant="sheet" title="Ask for help" onClose={close} actions={<Btn shape="round" icon="flag" label="Report" />} />`.
|
|
65
|
+
* Never put buttons here that finish the card: they go in the foot. A head takes no children. A `Card` finds its `Head` by type, so a consumer's
|
|
66
|
+
* own component that wraps a `Head` is not found.
|
|
35
67
|
*/
|
|
36
|
-
export function Head({
|
|
68
|
+
export function Head({ variant = 'plain', title, meta, over, level, tag, lead, chips, end, actions, onClose, closeLabel, back, backLabel, top, long, className, children, ...rest }) {
|
|
37
69
|
const tab = useContext(StackHeadCtx);
|
|
38
|
-
const
|
|
39
|
-
|
|
70
|
+
const sheetClose = useContext(HeadCloseCtx);
|
|
71
|
+
if (children != null)
|
|
72
|
+
warnOnce('head-children', 'cardds Head: a head takes no children, they are left out — write its variant and slots (title, meta, lead, end…); `npx cardds codemod-head <files>` rewrites them.');
|
|
73
|
+
const given = { tag, lead, chips, over, end, actions, onClose, closeLabel, back, backLabel };
|
|
74
|
+
// the title's words: its keyboard way in on a stack sheet and its run when long are the Words' (HeadCtx)
|
|
75
|
+
if (variant === 'status' && title != null)
|
|
76
|
+
warnOnce('head-status-title', 'cardds Head variant="status": the status words are `meta` (a line of text, never a heading) — `title` is left out.');
|
|
77
|
+
const takesOver = TAKES[variant]?.includes('over') && over != null;
|
|
78
|
+
const words = ((variant !== 'status' && title != null) || meta != null || takesOver) && (_jsx(Words, { title: variant === 'status' ? undefined : title, meta: meta, level: level, over: takesOver ? over : undefined }, "words"));
|
|
79
|
+
const list = Children.toArray(slotted(variant, given, words, onClose ?? sheetClose));
|
|
80
|
+
return (_jsx("div", { className: cx('head', top && 'head--top', variant === 'centre' && 'head--centre', variant === 'status' && 'head--status', className), ...rest, children: _jsx(HeadCtx.Provider, { value: { tab, long: !!long }, children: withEndRoom(list, Words) ?? list }) }));
|
|
40
81
|
}
|
package/dist/parts/Words.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export interface WordsProps extends Omit<ComponentProps<'span'>, 'title'> {
|
|
|
11
11
|
level?: 'h1' | 'h2' | 'display';
|
|
12
12
|
}
|
|
13
13
|
/** Words — the words of a line, filling the room between the lead and the end: a `title` over a `meta` caption, maybe under an `over` caption;
|
|
14
|
-
* its children come under them, or instead of them (a Wave for a voice note).
|
|
15
|
-
*
|
|
14
|
+
* its children come under them, or instead of them (a Wave for a voice note). A `Head` draws its own from its `title` · `meta` · `over` slots
|
|
15
|
+
* (a head takes no children): there is no box round them, the title and the meta stand in the head. After a lead, with ends after it, in a `Head` or a
|
|
16
16
|
* `LinkBlock`'s `Row` (a led line): the title and the meta are ONE flowing block round the ends' room (their unseen copy, at its top right),
|
|
17
17
|
* so both wrap round the ends and run under them at full width; the title's first line has its x-height middle on the ends' centre. */
|
|
18
18
|
export declare function Words({ title, meta, over, level, className, children, ...rest }: WordsProps): import("react").JSX.Element;
|
package/dist/parts/Words.js
CHANGED
|
@@ -4,8 +4,8 @@ import { cx } from '../cx.js';
|
|
|
4
4
|
import { HeadCtx, onTitleKey } from './headCtx.js';
|
|
5
5
|
import { EndRoomCtx } from './endRoom.js';
|
|
6
6
|
/** Words — the words of a line, filling the room between the lead and the end: a `title` over a `meta` caption, maybe under an `over` caption;
|
|
7
|
-
* its children come under them, or instead of them (a Wave for a voice note).
|
|
8
|
-
*
|
|
7
|
+
* its children come under them, or instead of them (a Wave for a voice note). A `Head` draws its own from its `title` · `meta` · `over` slots
|
|
8
|
+
* (a head takes no children): there is no box round them, the title and the meta stand in the head. After a lead, with ends after it, in a `Head` or a
|
|
9
9
|
* `LinkBlock`'s `Row` (a led line): the title and the meta are ONE flowing block round the ends' room (their unseen copy, at its top right),
|
|
10
10
|
* so both wrap round the ends and run under them at full width; the title's first line has its x-height middle on the ends' centre. */
|
|
11
11
|
export function Words({ title, meta, over, level, className, children, ...rest }) {
|
package/dist/parts/endRoom.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type ElementType, type ReactNode } from 'react';
|
|
2
|
+
/** what may lead a line that keeps the room (the CSS's .lead, .avatar, .avatar-stack) */
|
|
3
|
+
export declare const LEADS: unknown[];
|
|
2
4
|
/** the ends a led line's `Words` keeps room for at the top right of its words: unseen copies of them, floated so the title and the meta wrap
|
|
3
5
|
* round them and run under the real ends at full width (parts.css "the ends' room"). `null`: no room */
|
|
4
6
|
export declare const EndRoomCtx: import("react").Context<ReactNode>;
|
package/dist/parts/endRoom.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Children, cloneElement, createContext, createElement, isValidElement }
|
|
|
2
2
|
import { Lead } from './Lead.js';
|
|
3
3
|
import { Avatar, AvatarStack } from '../people/Avatar.js';
|
|
4
4
|
/** what may lead a line that keeps the room (the CSS's .lead, .avatar, .avatar-stack) */
|
|
5
|
-
const LEADS = [Lead, Avatar, AvatarStack];
|
|
5
|
+
export const LEADS = [Lead, Avatar, AvatarStack];
|
|
6
6
|
/** the ends a led line's `Words` keeps room for at the top right of its words: unseen copies of them, floated so the title and the meta wrap
|
|
7
7
|
* round them and run under the real ends at full width (parts.css "the ends' room"). `null`: no room */
|
|
8
8
|
export const EndRoomCtx = createContext(null);
|
package/dist/parts/headCtx.d.ts
CHANGED
|
@@ -4,4 +4,7 @@ export declare const HeadCtx: import("react").Context<{
|
|
|
4
4
|
tab: 0 | -1 | null;
|
|
5
5
|
long: boolean;
|
|
6
6
|
} | null>;
|
|
7
|
+
/** what a `Head variant="sheet"` close asks when the app gave it no `onClose`: the `Sheet` round it, to go `away`. `null` outside a
|
|
8
|
+
* sheet, and inside a `Card` (a card standing in a sheet's body never closes the sheet) */
|
|
9
|
+
export declare const HeadCloseCtx: import("react").Context<(() => void) | null>;
|
|
7
10
|
export declare const onTitleKey: (e: KeyboardEvent<HTMLElement>) => void;
|
package/dist/parts/headCtx.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
/** what a `Words` in a head reads: the stack's tab stop and whether the title runs. `null` outside a head */
|
|
3
3
|
export const HeadCtx = createContext(null);
|
|
4
|
+
/** what a `Head variant="sheet"` close asks when the app gave it no `onClose`: the `Sheet` round it, to go `away`. `null` outside a
|
|
5
|
+
* sheet, and inside a `Card` (a card standing in a sheet's body never closes the sheet) */
|
|
6
|
+
export const HeadCloseCtx = createContext(null);
|
|
4
7
|
export const onTitleKey = (e) => {
|
|
5
8
|
if (e.key !== 'Enter' && e.key !== ' ')
|
|
6
9
|
return;
|
package/dist/sheets/Modal.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface ModalProps extends ComponentProps<'article'> {
|
|
|
20
20
|
* (measured at 375, 2026-10-11). KNOWN FAULT, not fixed: under React StrictMode `onClosed` is never called for a Modal mounted that way — the
|
|
21
21
|
* effect's first run sets `shown` to false, its cleanup drops the wait, and the second run returns early.
|
|
22
22
|
*/
|
|
23
|
-
export declare function Modal({ open, onClosed, onDismiss, className, ...rest }: ModalProps): import("react").JSX.Element;
|
|
23
|
+
export declare function Modal({ open, onClosed, onDismiss, className, children, ...rest }: ModalProps): import("react").JSX.Element;
|
|
24
24
|
export interface ModalAskProps extends Omit<ComponentProps<'div'>, 'title'> {
|
|
25
25
|
/** the question */
|
|
26
26
|
title: ReactNode;
|
package/dist/sheets/Modal.js
CHANGED
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
3
|
import { focusWhenActive, useLatest } from '../state.js';
|
|
4
4
|
import { cx } from '../cx.js';
|
|
5
|
+
import { HeadCloseCtx } from '../parts/headCtx.js';
|
|
5
6
|
/**
|
|
6
7
|
* Modal — the ask: ONE card at the centre of a `SheetStage dim`, two parts — a `Body` (the thing being asked about, light, scrolls
|
|
7
8
|
* when tall) and a `ModalAsk` (the dark end that asks). No border. Two beats on appearing: drops in from above, then the ModalAsk comes
|
|
@@ -13,7 +14,7 @@ import { cx } from '../cx.js';
|
|
|
13
14
|
* (measured at 375, 2026-10-11). KNOWN FAULT, not fixed: under React StrictMode `onClosed` is never called for a Modal mounted that way — the
|
|
14
15
|
* effect's first run sets `shown` to false, its cleanup drops the wait, and the second run returns early.
|
|
15
16
|
*/
|
|
16
|
-
export function Modal({ open = true, onClosed, onDismiss, className, ...rest }) {
|
|
17
|
+
export function Modal({ open = true, onClosed, onDismiss, className, children, ...rest }) {
|
|
17
18
|
const ref = useRef(null);
|
|
18
19
|
const closed = useLatest(onClosed);
|
|
19
20
|
const shown = useRef(true); // the animations stand played forwards
|
|
@@ -55,7 +56,8 @@ export function Modal({ open = true, onClosed, onDismiss, className, ...rest })
|
|
|
55
56
|
document.addEventListener('keydown', key);
|
|
56
57
|
return () => { stage.removeEventListener('click', tap); document.removeEventListener('keydown', key); };
|
|
57
58
|
}, [has, open]);
|
|
58
|
-
|
|
59
|
+
// a head in a modal never closes the Sheet the modal is drawn inside of (context passes through React): no close unless the app gives onClose
|
|
60
|
+
return _jsx("article", { ref: ref, className: cx('card modal', className), ...rest, children: _jsx(HeadCloseCtx.Provider, { value: null, children: children }) });
|
|
59
61
|
}
|
|
60
62
|
/** ModalAsk — the dark end of a `Modal` (`light` = paper and dark words): the question, its fine print, and the answers: a `BtnRow round joined` of round icon buttons, or a `BtnRow` of word `Btn`s (it fills the card, each button's words on one line; a `Btn tone="quiet"` there is edged in the ask's own ink) — plain buttons
|
|
61
63
|
* with the app's `onClick`; the ModalAsk does nothing with them. A `Modal` holding ONLY a ModalAsk (no `Body`) is the CONFIRM: a question with nothing
|
package/dist/sheets/Sheet.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ import type { ComponentProps } from 'react';
|
|
|
3
3
|
import { type Resting } from './sheetMeasure.js';
|
|
4
4
|
/** how far the sheet slid. `away` = not on the screen (slid out, inert) — a state the app sets, never one a drag or a tap lands on */
|
|
5
5
|
export type SheetState = 'peek' | 'half' | '3q' | 'full' | 'away';
|
|
6
|
-
/** what asked for the change: the handle's `tap`, a `drag` released, `focus` in a peeked sheet, the `keyboard` (or anything else) moving the cut
|
|
7
|
-
|
|
6
|
+
/** what asked for the change: the handle's `tap`, a `drag` released, `focus` in a peeked sheet, the `keyboard` (or anything else) moving the cut,
|
|
7
|
+
* the `close` of its `Head variant="sheet"` (one given no `onClose`: it asks for `away`) */
|
|
8
|
+
export type SheetChangeReason = 'tap' | 'drag' | 'focus' | 'keyboard' | 'close';
|
|
8
9
|
export interface SheetProps extends Omit<ComponentProps<'article'>, 'onChange'> {
|
|
9
10
|
/** CONTROLLED: where the sheet is. The app owns it — pair it with `onStateChange`, or the sheet cannot move (like `value` without `onChange`).
|
|
10
11
|
* `peek` (handle + title row) · `half` · `3q` · `full` (its top edge at the top bar) · `away` (not on the screen). A class, never a height. */
|
package/dist/sheets/Sheet.js
CHANGED
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Children, cloneElement, isValidElement, useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { focusWhenActive, useControlled, visibleBottom, watchSize } from '../state.js';
|
|
4
4
|
import { Head } from '../parts/Head.js';
|
|
5
|
+
import { HeadCloseCtx } from '../parts/headCtx.js';
|
|
5
6
|
import { cx } from '../cx.js';
|
|
6
7
|
import { word } from '../words.js';
|
|
7
8
|
import { ORDER, slid, stopsOf, useFootRoom, usePeekStrip, useTitleRun } from './sheetMeasure.js';
|
|
@@ -136,10 +137,12 @@ export function Sheet({ state, defaultState = 'half', onStateChange, onSettled,
|
|
|
136
137
|
body.scrollTop = 0; // the browser's own reveal scrolled it against the peek strip: start over
|
|
137
138
|
reveal(e.target, 'focus', home.current);
|
|
138
139
|
};
|
|
140
|
+
/* a `Head variant="sheet"` given no `onClose` asks the sheet: away, as the app would set it */
|
|
141
|
+
const close = useCallback(() => request('away', 'close'), [request]);
|
|
139
142
|
const tap = () => {
|
|
140
143
|
if (afterDrag())
|
|
141
144
|
return; // the click that follows a drag is not a tap
|
|
142
145
|
request(current === 'peek' ? (allowed().includes(home.current) ? home.current : allowed().find((s) => s !== 'peek') ?? 'half') : 'peek', 'tap');
|
|
143
146
|
};
|
|
144
|
-
return (_jsxs("article", { ref: ref, className: cx('card sheet', tone && tone !== 1 && `card--${tone}`, paper && 'sheet--paper', `sheet--${shown}`, refreshing && 'is-loading', className), "aria-busy": refreshing || undefined, inert: current === 'away' || held || undefined, onFocus: focus, style: half ? { ...style, '--sheet-half': (10 - half) / 10 } : style, ...rest, children: [handle !== false && (_jsx("button", { ref: handleRef, className: cx('sheet__handle', mark === 'dots' && 'sheet__handle--dots'), type: "button", "aria-label": typeof handle === 'string' ? handle : word('resize'), onClick: tap, onPointerDown: down, onPointerMove: move, onPointerUp: up, onPointerCancel: up })), withTopRow(Children.map(children, (node) => markLong(node, titleLong)) ?? [], topRow)] }));
|
|
147
|
+
return (_jsxs("article", { ref: ref, className: cx('card sheet', tone && tone !== 1 && `card--${tone}`, paper && 'sheet--paper', `sheet--${shown}`, refreshing && 'is-loading', className), "aria-busy": refreshing || undefined, inert: current === 'away' || held || undefined, onFocus: focus, style: half ? { ...style, '--sheet-half': (10 - half) / 10 } : style, ...rest, children: [handle !== false && (_jsx("button", { ref: handleRef, className: cx('sheet__handle', mark === 'dots' && 'sheet__handle--dots'), type: "button", "aria-label": typeof handle === 'string' ? handle : word('resize'), onClick: tap, onPointerDown: down, onPointerMove: move, onPointerUp: up, onPointerCancel: up })), _jsx(HeadCloseCtx.Provider, { value: close, children: withTopRow(Children.map(children, (node) => markLong(node, titleLong)) ?? [], topRow) })] }));
|
|
145
148
|
}
|
|
@@ -6,6 +6,6 @@ export interface StackBackProps extends Omit<ComponentProps<'button'>, 'form' |
|
|
|
6
6
|
* default: at its start, chevron left */
|
|
7
7
|
end?: boolean;
|
|
8
8
|
}
|
|
9
|
-
/** StackBack — the back button a tapped stack sheet reveals in its head
|
|
9
|
+
/** StackBack — the back button a tapped stack sheet reveals in its head, drawn by `Head variant="stack" back`. Hidden until the sheet is open.
|
|
10
10
|
* A SMALL disc (Lh 2026-09-23): 32px with a chevron — the head keeps its room for the title and the tabs; the 44px tap target stays. */
|
|
11
11
|
export declare function StackBack({ label, end, className, ...rest }: StackBackProps): import("react").JSX.Element;
|
package/dist/sheets/StackBack.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { cx } from '../cx.js';
|
|
3
3
|
import { Btn } from '../actions/Btn.js';
|
|
4
4
|
import { word } from '../words.js';
|
|
5
|
-
/** StackBack — the back button a tapped stack sheet reveals in its head
|
|
5
|
+
/** StackBack — the back button a tapped stack sheet reveals in its head, drawn by `Head variant="stack" back`. Hidden until the sheet is open.
|
|
6
6
|
* A SMALL disc (Lh 2026-09-23): 32px with a chevron — the head keeps its room for the title and the tabs; the 44px tap target stays. */
|
|
7
7
|
export function StackBack({ label = word('back'), end, className, ...rest }) {
|
|
8
8
|
return _jsx(Btn, { shape: "round", size: "sm", icon: end ? 'chevron-down' : 'chevron-left', label: label, className: cx('sheet-stack__back', end && 'sheet-stack__back--end', className), ...rest });
|
|
@@ -5,10 +5,8 @@ import { cx } from '../cx.js';
|
|
|
5
5
|
import { Card } from '../cards/Card.js';
|
|
6
6
|
import { Btn } from '../actions/Btn.js';
|
|
7
7
|
import { Head } from '../parts/Head.js';
|
|
8
|
-
import { Words } from '../parts/Words.js';
|
|
9
8
|
import { Foot } from '../parts/Foot.js';
|
|
10
9
|
import { Body } from '../parts/Body.js';
|
|
11
|
-
import { StackBack } from './StackBack.js';
|
|
12
10
|
import { Badge } from '../numbers/Badge.js';
|
|
13
11
|
import { word } from '../words.js';
|
|
14
12
|
import { runOver } from './sheetMeasure.js';
|
|
@@ -33,8 +31,8 @@ export function StackSheet({ title, tone, paper, icon, tabs, tab: tabProp, defau
|
|
|
33
31
|
measure();
|
|
34
32
|
return watchSize([h, run], measure);
|
|
35
33
|
}, [title]);
|
|
36
|
-
return (_jsxs(Card, { stack: stack, tone: tone, paper: paper, className: cx('stack-sheet', className), ...rest, children: [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
return (_jsxs(Card, { stack: stack, tone: tone, paper: paper, className: cx('stack-sheet', className), ...rest, children: [_jsx(Head, { ref: headRef, long: long, variant: "stack", back: backAt === 'none' ? undefined : backAt, backLabel: backLabel, title: _jsx("span", { className: "stack-sheet__run", children: title }), end: tabs?.length ? (_jsx("span", { className: "stack-sheet__tabs", role: "tablist", children: tabs.map((t) => {
|
|
35
|
+
const count = t.count ? `${t.countPrefix ?? ''}${t.count > 99 ? '99+' : t.count}` : '';
|
|
36
|
+
return (_jsx(Btn, { shape: "round", size: "sm", icon: t.icon, tone: t.id === tab ? 'primary' : undefined, role: "tab", "aria-selected": t.id === tab, label: count ? `${t.label} ${count}` : t.label, className: "stack-sheet__tab", onClick: () => pick(t.id), children: count ? _jsx(Badge, { className: "stack-sheet__count", children: count }) : null }, t.id));
|
|
37
|
+
}) })) : icon }), 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 })] }));
|
|
40
38
|
}
|
|
@@ -53,7 +53,7 @@ export function runOver(line, words = line) {
|
|
|
53
53
|
/* the Sheet's title: the app's own heading, measured whole (sheet.css runs it with text-indent) */
|
|
54
54
|
export function useTitleRun(ref, onLong) {
|
|
55
55
|
useEffect(() => {
|
|
56
|
-
const el = ref.current, title = el?.querySelector(':scope > .head >
|
|
56
|
+
const el = ref.current, title = el?.querySelector(':scope > .head > .words__title');
|
|
57
57
|
if (!el || !title)
|
|
58
58
|
return;
|
|
59
59
|
let was = false;
|
|
@@ -7,7 +7,6 @@ import { Page, CtaPack } from '../scaffold/Page.js';
|
|
|
7
7
|
import { Sheet } from '../sheets/Sheet.js';
|
|
8
8
|
import { Body } from '../parts/Body.js';
|
|
9
9
|
import { Head } from '../parts/Head.js';
|
|
10
|
-
import { Words } from '../parts/Words.js';
|
|
11
10
|
import { Foot } from '../parts/Foot.js';
|
|
12
11
|
import { Text } from '../type/Text.js';
|
|
13
12
|
import { Btn } from '../actions/Btn.js';
|
|
@@ -30,9 +29,9 @@ export function CallSheet({ media, heading, body, action, sheet, ways, open: ope
|
|
|
30
29
|
if (was !== null)
|
|
31
30
|
setLeaving(was);
|
|
32
31
|
}
|
|
33
|
-
return (_jsxs(Screen, { fill: true, ...rest, children: [_jsxs(Step, { children: [_jsxs(Page, { children: [media, _jsx(Head, {
|
|
32
|
+
return (_jsxs(Screen, { fill: true, ...rest, children: [_jsxs(Step, { children: [_jsxs(Page, { children: [media, _jsx(Head, { title: heading, level: "h1" }), typeof body === 'string' ? _jsx(Text, { level: "body", children: body }) : body, _jsx(CtaPack, { children: list.map((w, i) => w.action == null ? null : (_jsx(Btn, { tone: i === first ? 'primary' : 'quiet', "aria-expanded": on === i, onClick: () => { setAt('full'); set(i); }, children: w.action }, i))) })] }), list.map(({ sheet: sh }, i) => (_jsxs(Sheet, { state: on === i ? at : 'away', onStateChange: (s) => { if (s === 'away')
|
|
34
33
|
set(null);
|
|
35
34
|
else
|
|
36
35
|
setAt(s); }, onSettled: (s) => { if (s === 'away' && leaving === i)
|
|
37
|
-
setLeaving(null); }, states: states, handle: sh.handle ?? handle, children: [_jsx(Head, {
|
|
36
|
+
setLeaving(null); }, states: states, handle: sh.handle ?? handle, children: [_jsx(Head, { title: sh.title }), _jsx(Body, { children: on === i || leaving === i ? (typeof sh.body === 'function' ? sh.body() : sh.body) : null }), (sh.foot != null || sh.footLink != null) && _jsx(Foot, { link: sh.footLink, children: sh.foot })] }, i)))] }), children] }));
|
|
38
37
|
}
|