@usableapp/cardds 0.7.175 → 0.7.177

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.
@@ -37,9 +37,29 @@ export interface CalendarProps extends Omit<ComponentProps<'div'>, 'title' | 'on
37
37
  weekdays?: string[];
38
38
  /** replace the default prev/next icon buttons */
39
39
  nav?: ReactNode;
40
+ /** the year shown beside `title` ("2024", "2567"): the app gives the number, in its own calendar. Given, the head is two words, month and year */
41
+ year?: ReactNode;
42
+ /** the 12 month names in order. Given (with `onMonthChange`), a tap on `title` swaps the day grid for a panel of 12 chips; a tap on one returns to the days */
43
+ months?: ReactNode[];
44
+ /** the month shown, 0–11 (January = 0): which month chip is picked in the panel. The app owns it, as `title` */
45
+ month?: number;
46
+ /** a month chip was tapped: its index 0–11. The app turns the month (it owns `title`, `days`, `start`) */
47
+ onMonthChange?: (month: number) => void;
48
+ /** the years the panel lists, in order (the app says the range): `value` is what `onYearChange` hands back, `label` the words ("2567"). Given (with `onYearChange`), a tap on `year` swaps the day grid for a panel of chips that scrolls */
49
+ years?: {
50
+ value: number;
51
+ label: ReactNode;
52
+ }[];
53
+ /** the `value` of the year shown: which year chip is picked in the panel. The app owns it, as `year` */
54
+ yearValue?: number;
55
+ /** a year chip was tapped: its `value`. The app turns the year (it owns `year`, `title`, `days`, `start`) */
56
+ onYearChange?: (year: number) => void;
40
57
  }
41
58
  /** Calendar — a month grid of 44px round cells: one accent day, optional marks; prev/next in the head. It shows ONE month and knows no dates:
42
59
  * the app owns which month (`title`, `days`, `start` + `onPrev` / `onNext`) and which day (`selected` + `onSelect`, or `defaultSelected`).
43
60
  * A run of days instead of one (the asker says from when to when, Lh 2026-10-21): `span` + `onSpanChange`, or `defaultSpan` — a drag across
44
- * the days covers them, or a tap on the first day and a tap on the last; the whole run is one highlight, as a finger drags over words. On a sheet, never in a Card: the sheet is the paper the member fills in (Lh 2026-10-18). */
45
- export declare function Calendar({ title, days, start, selected, defaultSelected, onSelect, span, defaultSpan, onSpanChange, onPrev, onNext, prevLabel, nextLabel, marks, marks2, disabled, weekdays, nav, className, ...rest }: CalendarProps): import("react").JSX.Element;
61
+ * the days covers them, or a tap on the first day and a tap on the last; the whole run is one highlight, as a finger drags over words. On a sheet, never in a Card: the sheet is the paper the member fills in (Lh 2026-10-18).
62
+ * A far month or year (a birthday, Lh 2026-11-08): give `year` and `months` + `onMonthChange` and / or `years` + `onYearChange` — the head's month and year become
63
+ * two buttons; a tap on one swaps the day grid for a panel of chips (the 12 months, or the years in a list that scrolls), a tap on a chip returns to the days.
64
+ * While a panel is open the prev / next buttons are gone. The app still owns the month and year shown and any numbers (a Buddhist year is the app's label); with none of these props the head is as before. */
65
+ export declare function Calendar({ title, days, start, selected, defaultSelected, onSelect, span, defaultSpan, onSpanChange, onPrev, onNext, prevLabel, nextLabel, marks, marks2, disabled, weekdays, nav, year, months, month, onMonthChange, years, yearValue, onYearChange, className, ...rest }: CalendarProps): import("react").JSX.Element;
@@ -1,15 +1,31 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useLayoutEffect, useRef, useState } from 'react';
2
3
  import { useControlled } from '../state.js';
3
4
  import { cx } from '../cx.js';
4
5
  import { Btn } from '../actions/Btn.js';
6
+ import { Chip, ChipGrid } from '../actions/Chip.js';
5
7
  import { word } from '../words.js';
6
8
  import { calendarDay } from './calendarDay.js';
7
9
  import { useSpan } from './span.js';
8
10
  /** Calendar — a month grid of 44px round cells: one accent day, optional marks; prev/next in the head. It shows ONE month and knows no dates:
9
11
  * the app owns which month (`title`, `days`, `start` + `onPrev` / `onNext`) and which day (`selected` + `onSelect`, or `defaultSelected`).
10
12
  * A run of days instead of one (the asker says from when to when, Lh 2026-10-21): `span` + `onSpanChange`, or `defaultSpan` — a drag across
11
- * the days covers them, or a tap on the first day and a tap on the last; the whole run is one highlight, as a finger drags over words. On a sheet, never in a Card: the sheet is the paper the member fills in (Lh 2026-10-18). */
12
- export function Calendar({ title, days = 30, start = 1, selected, defaultSelected, onSelect, span, defaultSpan, onSpanChange, onPrev, onNext, prevLabel = word('previous'), nextLabel = word('next'), marks = [], marks2 = [], disabled = [], weekdays = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], nav, className, ...rest }) {
13
+ * the days covers them, or a tap on the first day and a tap on the last; the whole run is one highlight, as a finger drags over words. On a sheet, never in a Card: the sheet is the paper the member fills in (Lh 2026-10-18).
14
+ * A far month or year (a birthday, Lh 2026-11-08): give `year` and `months` + `onMonthChange` and / or `years` + `onYearChange` — the head's month and year become
15
+ * two buttons; a tap on one swaps the day grid for a panel of chips (the 12 months, or the years in a list that scrolls), a tap on a chip returns to the days.
16
+ * While a panel is open the prev / next buttons are gone. The app still owns the month and year shown and any numbers (a Buddhist year is the app's label); with none of these props the head is as before. */
17
+ export function Calendar({ title, days = 30, start = 1, selected, defaultSelected, onSelect, span, defaultSpan, onSpanChange, onPrev, onNext, prevLabel = word('previous'), nextLabel = word('next'), marks = [], marks2 = [], disabled = [], weekdays = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], nav, year, months, month, onMonthChange, years, yearValue, onYearChange, className, ...rest }) {
18
+ const [view, setView] = useState('days');
19
+ const panel = useRef(null);
20
+ const pickMonth = !!months && !!onMonthChange;
21
+ const pickYear = !!years && !!onYearChange;
22
+ const open = view === 'months' && pickMonth ? 'months' : view === 'years' && pickYear ? 'years' : 'days';
23
+ // a panel opens with the picked chip in the middle of its sight
24
+ useLayoutEffect(() => {
25
+ const box = panel.current, on = box?.querySelector('[aria-pressed="true"]');
26
+ if (box && on)
27
+ box.scrollTop = on.offsetTop - (box.clientHeight - on.offsetHeight) / 2;
28
+ }, [open]);
13
29
  const [day, pick] = useControlled(selected, defaultSelected, onSelect);
14
30
  const spanning = span !== undefined || defaultSpan !== undefined || onSpanChange !== undefined;
15
31
  // the hook counts cells from 0; the app counts days from 1
@@ -18,7 +34,13 @@ export function Calendar({ title, days = 30, start = 1, selected, defaultSelecte
18
34
  onSpanChange: onSpanChange && ((s) => onSpanChange([s[0] + 1, s[1] + 1])),
19
35
  blocked: (i) => i < 0 || i >= days || disabled.includes(i + 1),
20
36
  });
21
- return (_jsxs("div", { className: cx('calendar', spanning && 'calendar--span', className), ...rest, children: [_jsxs("div", { className: "calendar__head", children: [_jsx("span", { className: "t-title", children: title }), nav ?? (_jsxs("span", { className: "icon-row", children: [_jsx(Btn, { shape: "round", size: "sm", icon: "chevron-left", label: prevLabel, onClick: onPrev }), _jsx(Btn, { shape: "round", size: "sm", icon: "chevron-right", label: nextLabel, onClick: onNext })] }))] }), _jsxs("div", { className: "calendar__grid", ...(spanning ? run.box : {}), children: [weekdays.map((d) => _jsx("span", { className: "calendar__wd", children: d }, d)), Array.from({ length: days }, (_, i) => i + 1).map((d) => (calendarDay({
37
+ return (_jsxs("div", { className: cx('calendar', spanning && 'calendar--span', className), ...rest, children: [_jsxs("div", { className: "calendar__head", children: [pickMonth || pickYear || year != null ? (_jsxs("span", { className: "calendar__picks t-title", children: [pickMonth
38
+ ? _jsx("button", { type: "button", className: "calendar__pick", "aria-expanded": open === 'months', onClick: () => setView(open === 'months' ? 'days' : 'months'), children: title })
39
+ : _jsx("span", { children: title }), pickYear
40
+ ? _jsx("button", { type: "button", className: "calendar__pick", "aria-expanded": open === 'years', onClick: () => setView(open === 'years' ? 'days' : 'years'), children: year })
41
+ : year != null && _jsx("span", { children: year })] })) : _jsx("span", { className: "t-title", children: title }), open === 'days' && (nav ?? (_jsxs("span", { className: "icon-row", children: [_jsx(Btn, { shape: "round", size: "sm", icon: "chevron-left", label: prevLabel, onClick: onPrev }), _jsx(Btn, { shape: "round", size: "sm", icon: "chevron-right", label: nextLabel, onClick: onNext })] })))] }), open !== 'days' && (_jsx("div", { ref: panel, className: "calendar__panel", children: _jsx(ChipGrid, { children: open === 'months'
42
+ ? months.map((m, i) => (_jsx(Chip, { as: "button", on: i === month, "aria-pressed": i === month, onClick: () => { onMonthChange(i); setView('days'); }, children: m }, i)))
43
+ : years.map((y) => (_jsx(Chip, { as: "button", on: y.value === yearValue, "aria-pressed": y.value === yearValue, onClick: () => { onYearChange(y.value); setView('days'); }, children: y.label }, y.value))) }) })), open === 'days' && _jsxs("div", { className: "calendar__grid", ...(spanning ? run.box : {}), children: [weekdays.map((d) => _jsx("span", { className: "calendar__wd", children: d }, d)), Array.from({ length: days }, (_, i) => i + 1).map((d) => (calendarDay({
22
44
  key: d, num: d, mark: marks.includes(d), mark2: marks2.includes(d), selected: !spanning && d === day, disabled: disabled.includes(d),
23
45
  style: d === 1 ? { '--start': start } : undefined,
24
46
  onPick: () => (spanning ? run.tap(d - 1) : pick(d)),
@@ -6,3 +6,11 @@ export interface NoteRowProps extends ComponentProps<'div'> {
6
6
  }
7
7
  /** NoteRow — icon + caption: transit hints, fine print. */
8
8
  export declare function NoteRow({ icon, className, children, ...rest }: NoteRowProps): import("react").JSX.Element;
9
+ export interface NoteRowsProps extends ComponentProps<'div'> {
10
+ }
11
+ /** NoteRows — two or more `NoteRow`s as ONE group in a card (a place, a person): the lines stand `--note-rows-gap` apart (default `--sp-1`, the lines of one thing), not the card's gap (which parts one thing from the next). */
12
+ export declare function NoteRows({ className, ...rest }: NoteRowsProps): import("react").JSX.Element;
13
+ export interface WasProps extends ComponentProps<'del'> {
14
+ }
15
+ /** Was — the value that was REPLACED (the old place, the old day, the helper who withdrew), struck through in the line's own words, in the muted ink of its ground, after the new value: `<NoteRow>Village hall <Was>Old pavilion</Was></NoteRow>`. A screen reader hears it as "was" (in the page's language) before the old value. In a `NoteRow`, a `Text` or a `Words` meta. */
16
+ export declare function Was({ className, children, ...rest }: WasProps): import("react").JSX.Element;
@@ -1,7 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cx } from '../cx.js';
3
3
  import { Icon } from '../type/Icon.js';
4
+ import { word } from '../words.js';
4
5
  /** NoteRow — icon + caption: transit hints, fine print. */
5
6
  export function NoteRow({ icon = 'clock', className, children, ...rest }) {
6
- return (_jsxs("div", { className: cx('note-row', className), ...rest, children: [_jsx(Icon, { name: icon, size: "sm" }), " ", children] }));
7
+ return (_jsxs("div", { className: cx('note-row', className), ...rest, children: [_jsx(Icon, { name: icon, size: "sm" }), _jsx("span", { children: children })] }));
8
+ }
9
+ /** NoteRows — two or more `NoteRow`s as ONE group in a card (a place, a person): the lines stand `--note-rows-gap` apart (default `--sp-1`, the lines of one thing), not the card's gap (which parts one thing from the next). */
10
+ export function NoteRows({ className, ...rest }) {
11
+ return _jsx("div", { className: cx('note-rows', className), ...rest });
12
+ }
13
+ /** Was — the value that was REPLACED (the old place, the old day, the helper who withdrew), struck through in the line's own words, in the muted ink of its ground, after the new value: `<NoteRow>Village hall <Was>Old pavilion</Was></NoteRow>`. A screen reader hears it as "was" (in the page's language) before the old value. In a `NoteRow`, a `Text` or a `Words` meta. */
14
+ export function Was({ className, children, ...rest }) {
15
+ return _jsxs("del", { className: cx('was-value', className), ...rest, children: [_jsxs("span", { className: "t-sr", children: [word('was'), " "] }), children] });
7
16
  }
@@ -1,7 +1,7 @@
1
1
  import { type ComponentProps, type ReactNode } from 'react';
2
2
  /** the closed set of heads. The variant lays its slots out; the order they are written in decides nothing:
3
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
4
+ * its meta beside it, the `end` at the top right · `date` a `JourneyBadge stretch` (`lead`) with a `ChipRow` (`chips`, or two: `chips` over `chipsBelow`) beside it, the title
5
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
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
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 */
@@ -23,8 +23,10 @@ export interface HeadProps extends Omit<ComponentProps<'div'>, 'title' | 'onClos
23
23
  lead?: ReactNode;
24
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
25
  tag?: ReactNode;
26
- /** `date` only: a `ChipRow` beside the date, as tall as it */
26
+ /** `date` only: a `ChipRow` beside the date, as tall as it. With `chipsBelow` it is the UPPER of two rows (a warning chip) */
27
27
  chips?: ReactNode;
28
+ /** `date` only: the LOWER `ChipRow` of two beside the date (the day and the time): it stands at the foot of the date's height, whether or not `chips` (the upper row) has any chip, and the date is as tall as the two rows and the gap between them (`--head-col-gap`). The title and the meta then stand under the date, a group gap (`--head-group-gap`, default `--sp-5`) away, and a `--head-words-gap` (`--sp-1`) apart */
29
+ chipsBelow?: ReactNode;
28
30
  /** 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
31
  * 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
32
  * in `stack` the sheet's tabs or an icon. Not in `sheet`: there the buttons are `actions` */
@@ -59,4 +61,4 @@ export interface HeadProps extends Omit<ComponentProps<'div'>, 'title' | 'onClos
59
61
  * 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
62
  * own component that wraps a `Head` is not found.
61
63
  */
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;
64
+ export declare function Head({ variant, title, meta, over, level, tag, lead, chips, chipsBelow, end, actions, onClose, closeLabel, back, backLabel, top, long, className, children, ...rest }: HeadProps): import("react").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Children, Fragment, cloneElement, isValidElement, useContext } from 'react';
3
3
  import { cx } from '../cx.js';
4
4
  import { warnOnce } from '../state.js';
@@ -36,7 +36,7 @@ function slotted(variant, given, words, close) {
36
36
  switch (variant) {
37
37
  case 'status': return [given.tag, words, ...pieces(end)];
38
38
  case 'lead': return [lead, words, ...pieces(end)];
39
- case 'date': return [lead, given.chips, words, ...pieces(end)];
39
+ case 'date': return [lead, given.chipsBelow ? _jsxs("div", { className: "head__chips", children: [_jsx("div", { className: "head__chips-top", children: given.chips }), given.chipsBelow] }, "chips") : given.chips, words, ...pieces(end)];
40
40
  case 'centre': return [lead, words, end];
41
41
  case 'sheet': {
42
42
  const acts = pieces(given.actions);
@@ -65,12 +65,12 @@ function slotted(variant, given, words, close) {
65
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
66
  * own component that wraps a `Head` is not found.
67
67
  */
68
- export function Head({ variant = 'plain', title, meta, over, level, tag, lead, chips, end, actions, onClose, closeLabel, back, backLabel, top, long, className, children, ...rest }) {
68
+ export function Head({ variant = 'plain', title, meta, over, level, tag, lead, chips, chipsBelow, end, actions, onClose, closeLabel, back, backLabel, top, long, className, children, ...rest }) {
69
69
  const tab = useContext(StackHeadCtx);
70
70
  const sheetClose = useContext(HeadCloseCtx);
71
71
  if (children != null)
72
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 };
73
+ const given = { tag, lead, chips, chipsBelow, over, end, actions, onClose, closeLabel, back, backLabel };
74
74
  // the title's words: its keyboard way in on a stack sheet and its run when long are the Words' (HeadCtx)
75
75
  if (variant === 'status' && title != null)
76
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.');
@@ -9,7 +9,8 @@ export interface AppBarProps extends Omit<ComponentProps<'header'>, 'title'> {
9
9
  /** the second line under the title */
10
10
  sub?: ReactNode;
11
11
  /** the trailing control(s) — a round Btn with a chevron-down to switch context; on the home bar a labelled
12
- * switch chip (ChipPick sign, --tap tall here) and the wallet Btn, side by side (Lh 2026-09-13) */
12
+ * switch chip (ChipPick sign, --tap tall here) and the wallet Btn, side by side (Lh 2026-09-13). Up to TWO controls (two in a fragment):
13
+ * they stand together at the right edge, `--appbar-action-gap` apart (default `--sp-2`), and the title keeps the rest of the line, its words cut with "…" */
13
14
  action?: ReactNode;
14
15
  /** makes the mark + the words ONE button (the member's own name → their menu): its props — `popoverTarget` to open a `Menu`
15
16
  * (the app places the Menu), or an `onClick`. Needs an accessible name when the words don't say what it opens: `aria-label`. */
@@ -7,5 +7,5 @@ import { cx } from '../cx.js';
7
7
  */
8
8
  export function AppBar({ lead, icon, title, sub, action, brandButton, className, children, ...rest }) {
9
9
  const who = (_jsxs(_Fragment, { children: [icon, _jsxs("span", { className: "appbar__text", children: [_jsx("span", { className: "appbar__title", children: title }), sub != null && _jsx("span", { className: "appbar__sub", children: sub })] })] }));
10
- return (_jsxs("header", { className: cx('appbar', className), ...rest, children: [_jsxs("div", { className: "appbar__brand", children: [lead != null && _jsx("span", { className: "appbar__lead", children: lead }), brandButton ? (_jsx("button", { type: "button", ...brandButton, className: cx('appbar__who', brandButton.className), children: who })) : who, action] }), children] }));
10
+ return (_jsxs("header", { className: cx('appbar', className), ...rest, children: [_jsxs("div", { className: "appbar__brand", children: [lead != null && _jsx("span", { className: "appbar__lead", children: lead }), brandButton ? (_jsx("button", { type: "button", ...brandButton, className: cx('appbar__who', brandButton.className), children: who })) : who, action ? _jsx("span", { className: "appbar__action", children: action }) : null] }), children] }));
11
11
  }
@@ -16,11 +16,10 @@ export interface ModalProps extends ComponentProps<'article'> {
16
16
  * A COMPONENT, not a wiring: it does not know its buttons. They are plain round `Btn`s / `Btn`s with the app's `onClick` — the app
17
17
  * records the answer and sets `open={false}`; the modal's one behaviour is how it leaves. `onDismiss` asks to leave unanswered (a tap on
18
18
  * the scrim, Esc). When it has arrived, cardds puts the cursor in the field marked `data-autofocus`, else the first field, else the question — write no focus code.
19
- * MOUNT IT ONLY WHEN IT IS TO SHOW. First mounted with `open={false}` it is drawn in place, then leaves, and calls `onClosed` after about 700ms
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
- * effect's first run sets `shown` to false, its cleanup drops the wait, and the second run returns early.
19
+ * Mounted with `open={false}` it draws nothing and never calls `onClosed` (it was never shown, so it has nothing to finish leaving) — the same
20
+ * in production and under React StrictMode. It appears when `open` turns `true`; from then on every close plays the leave and calls `onClosed` once.
22
21
  */
23
- export declare function Modal({ open, onClosed, onDismiss, className, children, ...rest }: ModalProps): import("react").JSX.Element;
22
+ export declare function Modal({ open, onClosed, onDismiss, className, children, ...rest }: ModalProps): import("react").JSX.Element | null;
24
23
  export interface ModalAskProps extends Omit<ComponentProps<'div'>, 'title'> {
25
24
  /** the question */
26
25
  title: ReactNode;
@@ -10,14 +10,16 @@ import { HeadCloseCtx } from '../parts/headCtx.js';
10
10
  * A COMPONENT, not a wiring: it does not know its buttons. They are plain round `Btn`s / `Btn`s with the app's `onClick` — the app
11
11
  * records the answer and sets `open={false}`; the modal's one behaviour is how it leaves. `onDismiss` asks to leave unanswered (a tap on
12
12
  * the scrim, Esc). When it has arrived, cardds puts the cursor in the field marked `data-autofocus`, else the first field, else the question — write no focus code.
13
- * MOUNT IT ONLY WHEN IT IS TO SHOW. First mounted with `open={false}` it is drawn in place, then leaves, and calls `onClosed` after about 700ms
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
15
- * effect's first run sets `shown` to false, its cleanup drops the wait, and the second run returns early.
13
+ * Mounted with `open={false}` it draws nothing and never calls `onClosed` (it was never shown, so it has nothing to finish leaving) — the same
14
+ * in production and under React StrictMode. It appears when `open` turns `true`; from then on every close plays the leave and calls `onClosed` once.
16
15
  */
17
16
  export function Modal({ open = true, onClosed, onDismiss, className, children, ...rest }) {
18
17
  const ref = useRef(null);
19
18
  const closed = useLatest(onClosed);
20
19
  const shown = useRef(true); // the animations stand played forwards
20
+ const seen = useRef(open); // has it ever been on the screen: a Modal mounted closed draws nothing
21
+ if (open)
22
+ seen.current = true;
21
23
  useEffect(() => {
22
24
  const el = ref.current;
23
25
  if (!el || open === shown.current)
@@ -56,6 +58,8 @@ export function Modal({ open = true, onClosed, onDismiss, className, children, .
56
58
  document.addEventListener('keydown', key);
57
59
  return () => { stage.removeEventListener('click', tap); document.removeEventListener('keydown', key); };
58
60
  }, [has, open]);
61
+ if (!seen.current)
62
+ return null;
59
63
  // 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
64
  return _jsx("article", { ref: ref, className: cx('card modal', className), ...rest, children: _jsx(HeadCloseCtx.Provider, { value: null, children: children }) });
61
65
  }
package/dist/words.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type WordKey = 'resize' | 'back' | 'next' | 'previous' | 'skip' | 'digit' | 'progress' | 'image' | 'mood' | 'photos' | 'voiceNote' | 'play' | 'pause' | 'to' | 'turnToBack' | 'turnToPicture' | 'turnToFront' | 'message' | 'address' | 'toMessage' | 'toAddress' | 'stampOn' | 'stampOff' | 'stamps' | 'unread' | 'remove' | 'cancel' | 'toLatest' | 'close';
1
+ export type WordKey = 'resize' | 'back' | 'next' | 'previous' | 'skip' | 'digit' | 'progress' | 'image' | 'mood' | 'photos' | 'voiceNote' | 'play' | 'pause' | 'to' | 'turnToBack' | 'turnToPicture' | 'turnToFront' | 'message' | 'address' | 'toMessage' | 'toAddress' | 'stampOn' | 'stampOff' | 'stamps' | 'unread' | 'remove' | 'cancel' | 'toLatest' | 'close' | 'was';
2
2
  type Words = Record<WordKey, string>;
3
3
  /** add or retune the words for a language (`'lo'`, or `'th'` to change one) — once, at app start. Missing words fall back to English. */
4
4
  export declare function setWords(lang: string, words: Partial<Words>): void;
package/dist/words.js CHANGED
@@ -1,8 +1,8 @@
1
1
  const sets = {
2
2
  en: { resize: 'Resize', back: 'Back', next: 'Next', previous: 'Previous', skip: 'Skip', digit: 'Digit', progress: 'Progress', image: 'Image', mood: 'Mood', photos: 'Photos', voiceNote: 'Voice note',
3
- play: 'Play', pause: 'Pause', to: 'To', turnToBack: 'See the back', turnToPicture: 'See the picture', turnToFront: 'See the front', message: 'Message', address: 'Address', toMessage: 'Back to the message', toAddress: 'On to the address', stampOn: 'Stick a stamp', stampOff: 'Take the stamp off', stamps: 'Choose a stamp', unread: 'Unread', remove: 'Remove', cancel: 'Cancel', toLatest: 'Latest messages', close: 'Close' },
3
+ play: 'Play', pause: 'Pause', to: 'To', turnToBack: 'See the back', turnToPicture: 'See the picture', turnToFront: 'See the front', message: 'Message', address: 'Address', toMessage: 'Back to the message', toAddress: 'On to the address', stampOn: 'Stick a stamp', stampOff: 'Take the stamp off', stamps: 'Choose a stamp', unread: 'Unread', remove: 'Remove', cancel: 'Cancel', toLatest: 'Latest messages', close: 'Close', was: 'was' },
4
4
  th: { resize: 'ปรับความสูง', back: 'กลับ', next: 'ถัดไป', previous: 'ก่อนหน้า', skip: 'ข้าม', digit: 'หลักที่', progress: 'ความคืบหน้า', image: 'รูปภาพ', mood: 'อารมณ์', photos: 'รูปภาพ', voiceNote: 'ข้อความเสียง',
5
- play: 'ฟังเสียง', pause: 'หยุดเสียง', to: 'ถึง', turnToBack: 'พลิกดูด้านหลัง', turnToPicture: 'พลิกดูรูป', turnToFront: 'พลิกดูด้านหน้า', message: 'ข้อความ', address: 'จ่าหน้า', toMessage: 'เลื่อนกลับไปข้อความ', toAddress: 'เลื่อนไปจ่าหน้า', stampOn: 'ติดแสตมป์', stampOff: 'แกะแสตมป์ออก', stamps: 'เลือกแสตมป์', unread: 'ยังไม่ได้อ่าน', remove: 'เอาออก', cancel: 'ยกเลิก', toLatest: 'ไปข้อความล่าสุด', close: 'ปิด' },
5
+ play: 'ฟังเสียง', pause: 'หยุดเสียง', to: 'ถึง', turnToBack: 'พลิกดูด้านหลัง', turnToPicture: 'พลิกดูรูป', turnToFront: 'พลิกดูด้านหน้า', message: 'ข้อความ', address: 'จ่าหน้า', toMessage: 'เลื่อนกลับไปข้อความ', toAddress: 'เลื่อนไปจ่าหน้า', stampOn: 'ติดแสตมป์', stampOff: 'แกะแสตมป์ออก', stamps: 'เลือกแสตมป์', unread: 'ยังไม่ได้อ่าน', remove: 'เอาออก', cancel: 'ยกเลิก', toLatest: 'ไปข้อความล่าสุด', close: 'ปิด', was: 'เดิม' },
6
6
  };
7
7
  /** add or retune the words for a language (`'lo'`, or `'th'` to change one) — once, at app start. Missing words fall back to English. */
8
8
  export function setWords(lang, words) {
package/docs/reference.md CHANGED
@@ -262,6 +262,11 @@ later and stands clear of it. `Card` forwards `ref` to its root for anything els
262
262
  - **`TileGrid cols={2}`** — always two across at every phone width: four picks stand 2×2. A `wide` tile still takes a row.
263
263
  - **`TileGrid cols={4}`** — four small square tiles across: the icon over a short label, a sheet's row of actions.
264
264
 
265
+ ### Notes in a card, and a replaced value
266
+
267
+ (cardds#218) `NoteRows` holds two or more `NoteRow`s as ONE group — the lines stand `--note-rows-gap` apart (default `--sp-1`), not the card's gap (which parts one thing from the next); a single `NoteRow` is unchanged. `Was` is the value that was replaced (the old place, the old day, the helper who withdrew): struck through, in the muted ink of its ground (knob `--was-ink`), after the new value — `<NoteRow icon="map-pin">Coffee shop <Was>Village hall</Was></NoteRow>`; it stands in a `NoteRow`, a `Text` or a `Words` meta, and a screen reader hears "was" (the page's language, `word('was')`) before the old value. Stories `NoteRow · Group`, `NoteRow · WasInWords`.
268
+ In a `NoteRow` the words are one flowing line, so the old value follows the new one in the same sentence; in a `Row`'s `Words` meta (a flex line) it stands a small gap beside it. `--note-rows-gap` is the gap BETWEEN lines (`--note-row-gap` is the icon's, inside one line).
269
+
265
270
  ## Sheet stack markup
266
271
 
267
272
  The sheet stack (`.sheet-stack`, `stack.css` — the menu, see *Anatomy*) is the
@@ -509,6 +514,7 @@ whose markup has rules, because the sheet's box is the step itself:
509
514
  The wireframe has them too. A theme may retune a shade, never a meaning. Each is dark enough for words and edges;
510
515
  `--signal-*-soft` is its light ground (the signal washed 14% into the surface). Never the colour alone: an icon or
511
516
  words say it too. Read by: `Field`/`Pin`/`FormNote` error, `Dot tone` / `Chip dot="ok|warn|error|info"`, `Snackbar` (ok).
517
+ - **`Chip tone`** (cardds#216): a solid fill in a signal's colour for a status that must be read at once — `error` red (what was agreed changed, or the request ended) · `warn` yellow (an answer is needed) · `ok` green (good news) · `info` blue (for your information). The fill is the palette's own shade for the chip's paper (`--signal-<tone>-onlight`; `-ondark` where a project makes its controls' paper dark, `--action-dark`), its words the ink of the other side, 4.5:1 on it in every palette cardds ships (a chip is a surface of its own, so it reads the same on any card and on a sticky note). Works with `sm` and `xs`; not with `on`, `soft`, `muted` or `dot` (`tone` is kept, a warning says so). Pick the colour by the meaning, never by taste: red only for a change or an end, yellow only where the member must answer. Knobs `--chip-tone-bg`, `--chip-tone-ink` retune every tone at once. Story `Chip · Tones`.
512
518
  - **Good news is a `Snackbar`, a warning or a question is a `Modal`** (Lh 2026-10-02): a `Snackbar` is a quick line over the
513
519
  screen — something went well, said in passing. A child of the `Screen`; it slides in from the top (or `bottom`, above the
514
520
  bottom layer), stays `duration` (4 s), slides out, never takes the cursor, never stops the member. `open` +
@@ -519,10 +525,8 @@ whose markup has rules, because the sheet's box is the step itself:
519
525
  component has none). A tap anywhere stops it: `onCancel`. A child of the `Screen`. `open` + `onOpenChange(open, reason)`
520
526
  (`done` | `cancel`) or `defaultOpen`; unmount it in `onClosed`. The number is `--fs-giant` and grows with the text scale;
521
527
  bigger through `--count-in-size`. A screen reader hears each number (`aria-live`). Not `Countdown`, which is a small link that waits.
522
- - **Mount a `Modal` only when it is to show.** A `Modal` first mounted with `open={false}` is drawn in place, then leaves,
523
- and calls `onClosed` after about 700ms. Known fault, not fixed: under React StrictMode (any dev build) `onClosed` is
524
- never called for a `Modal` mounted that way. Keep the app's own `mounted` flag: set it when the question is asked,
525
- clear it in `onClosed`.
528
+ - **A `Modal` mounted with `open={false}` draws nothing and never calls `onClosed`** (it was never shown), the same in production and
529
+ under React StrictMode. It appears when `open` turns `true`; each close after that plays the leave and calls `onClosed` once.
526
530
  - **cardds names its own controls, in the page's language** (Lh 2026-09-29): a handle, a back button, a Pin's cells… read
527
531
  their name from `src/words.ts` by `<html lang>` (en, th ship; `setWords(lang, {…})` adds one). An app passes no label that
528
532
  only repeats these words; a prop still wins.
@@ -631,13 +635,14 @@ between at 40% down the screen (see *Anatomy*, "Where the centre is"):
631
635
  |---|---|---|
632
636
  | `plain` (default) | `over` · `end` | the title over its meta; the `end` at the far right: a `Chip`, an `End`, a `Link`, a round `Btn size="sm"`, a `Btn size="sm"`, a `Stamp` (beside both lines) |
633
637
  | `lead` | `lead` · `over` · `end` | a person or a thing at the left (`Lead`, `Avatar`, `AvatarStack` with a `Stamp bare` in it), the title over its meta as one block beside it, the `end` (one or two, a fragment) at the top right — a FeedCard's head |
634
- | `date` | `lead` · `chips` · `over` · `end` | a date (`JourneyBadge stretch`) with a `ChipRow` beside it, as tall as each other; the title (who asks over it, `over`) under both at the full width; the `end`, if any, on a row of its own under them |
638
+ | `date` | `lead` · `chips` · `chipsBelow` · `over` · `end` | a date (`JourneyBadge stretch`) with a `ChipRow` beside it, as tall as each other; the title (who asks over it, `over`) under both at the full width; the `end`, if any, on a row of its own under them. TWO rows: `chips` (upper, e.g. a warning) over `chipsBelow` (lower, the day and time) — the lower stays at the foot of the date's height when the upper has no chip, the date is as tall as both rows and the gap between them (`--head-col-gap`, `--sp-3`); see below |
635
639
  | `status` | `tag` · `end` (+ `meta`) | a `Chip` (`tag`) at the left and a badge or tile (`end`) at the far right on the first row, the status words under both in the caption look (muted, the font's real weight): the `meta`, a plain line of text, NEVER a heading (this head has no `title`: a status is read in the card's content, the card's own heading is elsewhere) |
636
640
  | `centre` | `lead` · `end` | a stage sheet's head: a round `Btn` · the centred title over its meta · a round `Btn` |
637
641
  | `sheet` | `lead` · `actions` · `onClose` · `closeLabel` | a sheet's or a modal's head: the title over its meta (after a `lead`), up to two round `Btn`s (`actions`, drawn at the close's size) and the CLOSE at the far right — drawn, named in the page's language and wired by cardds |
638
642
  | `stack` | `back` · `backLabel` · `end` | a stack sheet's head on one line: the back (`back="start"` chevron left, `"end"` chevron down after the icons; hidden until the sheet is open), the title (the keyboard's way in), its tabs or icons (`end`) |
639
643
 
640
644
  `<Head title="Sunday market" meta="Saturday · 07:00" end={<Chip>3 new</Chip>} />` ·
645
+ `<Head variant="date" lead={<JourneyBadge stretch …/>} chips={<ChipRow>…a warning…</ChipRow>} chipsBelow={<ChipRow>…day, time…</ChipRow>} title meta />` — two chip rows (story `Head · WithDateTwoRows`): with `chipsBelow` the gaps are two sizes, `--head-group-gap` (the date and its chips → the title, default `--sp-5`) and `--head-words-gap` (the title → its meta, default `--sp-1`), so the date group and the words group read apart; with one chip row (no `chipsBelow`) both stay `--head-lead-gap` (`--sp-3`) as before and the two knobs do nothing. Set either knob on the head to move it (`--head-chips-gap` the gap between the two chip rows). An `end` in a two-row head stands under the words at `--head-words-gap` too: keep a two-row head to the date, the chips and the words.
641
646
  `<Head variant="lead" lead={<AvatarStack><Stamp bare …/></AvatarStack>} title meta end={<End caption="5 min" />} />` ·
642
647
  `<Head variant="sheet" title="Ask for help" onClose={close} actions={<Btn shape="round" icon="share" label="Share" />} />`.
643
648
  THE CLOSE only asks: `onClose` is the app's (it sets the sheet `away`, the modal `open={false}`); a `Head variant="sheet"` given
@@ -870,6 +875,19 @@ between at 40% down the screen (see *Anatomy*, "Where the centre is"):
870
875
  strings, so keys sort as their days do (ISO `2026-06-05`). Given `ranges`,
871
876
  `span` and `selected` are not read
872
877
  (gallery `CalendarWeeks/Ranges`).
878
+ - **Calendar picks a far month or year from its head** (a birthday, Lh 2026-11-08).
879
+ Give `year` (the app's number: a Buddhist year is its label, never the
880
+ component's maths) and `months` + `month` + `onMonthChange`, and / or
881
+ `years` + `yearValue` + `onYearChange`: the head's month and year become two
882
+ buttons. A tap on the month swaps the day grid for 12 chips; a tap on the
883
+ year swaps it for a list of year chips that scrolls (the app says the range;
884
+ the panel opens with the shown year in the middle). A tap on a chip hands
885
+ back its index or value and returns to the days; a second tap on the head's
886
+ word closes the panel unchanged. While a panel is open the prev / next
887
+ buttons are gone. The calendar still knows no dates: the app owns month,
888
+ year, `days` and `start` (a leap February is its `days`) and clears the day
889
+ when it turns month or year. Without these props the head and markup are
890
+ as before (gallery `Calendar/Birthday`).
873
891
  - **Two sheet systems, one material.** *Sheet single* (`.sheet`, `sheet.css`)
874
892
  is ONE sheet the member acts in, whatever it holds: a short entry in front
875
893
  of a step's card, a place on a map, a payment on a dim page — in a `.step`
@@ -1003,6 +1021,7 @@ it up. cardds draws the paper; the pictures, their words and which stamp a membe
1003
1021
  stamp in an `AvatarStack` are `--stamp-sm-size` wide (one tap: 48 × 60), on any surface and in any row. And the inline
1004
1022
  one: `Stamp xs` stands beside a status line's words (a card's `Foot`: the stamp, "X took it", a round button), one
1005
1023
  `Chip xs` tall, `--stamp-xs-size` (18.7 × 23.4, on `--fs-base`); always bare, flat but for the contact shadow, its teeth fewer and larger.
1024
+ `AppBar action` takes one or TWO controls (two in a fragment, e.g. a worded `Btn size="sm"` with an `Icon xs` and a round `Btn size="sm"`): they stand together at the right edge, `--appbar-action-gap` apart (knob; default `--sp-2`), the title keeps the rest of the line and is cut with "…", the buttons never wrap. A third is not a cardds pattern. Story `AppBar · Pair`.
1006
1025
  `AppBar lead` (2026-10-29) is the bar's leading slot: left-most, before the mark and the words, a button of its own (a primary `Btn`) outside the `brandButton`; the bar keeps its height. Story `AppBar · Lead`.
1007
1026
  A `Stamp` as an `AppBar`'s `icon` is the bar's inner height tall (`--header-h` less the bar's block padding: 35 × 44), so it reads
1008
1027
  bigger than the title and its second line and the fixed bar never grows; bare and flat whatever it is handed. Knob `--appbar-stamp-size`.
@@ -1531,6 +1550,7 @@ outgrow it (a second line, a very large text) make a pill taller. `sm` also take
1531
1550
  (knobs `--btn-sm-pad-x`, `--btn-sm-font-size`) — a worded move at a card head's end
1532
1551
  (`<Head title meta end={<Btn size="sm" tone="primary">Keep</Btn>} />`, story `Btn · Small`). Every size in every tone, both
1533
1552
  shapes side by side: story `Btn · Ladder`.
1553
+ A round `Btn` takes `count` (unread alerts): a `Badge` on its top-right corner, half out of the circle; 0 or none draws nothing, over 99 reads "99+", and the spoken name is `label` plus the count ("Alerts 3"). A pill takes no `count`. Story `Btn · RoundCount`.
1534
1554
 
1535
1555
  **Something sent out from a button** (`Btn sending`, `Btn shape="round" sending`, Lh 2026-10-28): for `--motion-send` (0.7 s) the
1536
1556
  button's icon swells and tips forward and two rings spread from its edge (knob `--btn-sending-ink`, default the accent).
@@ -4,7 +4,7 @@
4
4
  export const HEAD_SLOTS = {
5
5
  plain: ['over', 'end'],
6
6
  lead: ['lead', 'over', 'end'],
7
- date: ['lead', 'chips', 'over', 'end'],
7
+ date: ['lead', 'chips', 'chipsBelow', 'over', 'end'],
8
8
  status: ['tag', 'end'],
9
9
  centre: ['lead', 'end'],
10
10
  sheet: ['lead', 'actions', 'onClose', 'closeLabel'],
package/lint/rules.mjs CHANGED
@@ -333,7 +333,7 @@ export function checkSource(source, file, { classes = carddsClasses() } = {}) {
333
333
  if (!variant) continue; // a variant the code picks at runtime: the component warns
334
334
  const takes = HEAD_SLOTS[variant];
335
335
  if (!takes) { add('head-slot', 'error', m.index, `<Head variant="${variant}">: no such head — the variants are ${Object.keys(HEAD_SLOTS).join(' · ')}.`); continue; }
336
- for (const s of own.matchAll(/\s(tag|lead|chips|over|end|actions|onClose|closeLabel|back|backLabel)\s*=/g)) {
336
+ for (const s of own.matchAll(/\s(tag|lead|chips|chipsBelow|over|end|actions|onClose|closeLabel|back|backLabel)\s*=/g)) {
337
337
  if (!takes.includes(s[1])) add('head-slot', 'error', m.index + s.index + 1, `${s[1]} on <Head variant="${variant}">: that head takes no ${s[1]} (it is left out). The slots beside title · meta · level: ${headSlotsText()}.`);
338
338
  }
339
339
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usableapp/cardds",
3
- "version": "0.7.175",
3
+ "version": "0.7.177",
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).",
@@ -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
  "release": "node scripts/publish.mjs",
15
15
  "release:check": "node scripts/publish.mjs --check",
16
+ "release:prepare": "node scripts/prepare-release.mjs",
16
17
  "prepack": "npm run build",
17
18
  "knobs": "node scripts/knobs.mjs"
18
19
  },