@usableapp/cardds 0.7.121 → 0.7.123

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -105,6 +105,7 @@ export * from './media/Tile.js';
105
105
  export * from './media/Mosaic.js';
106
106
  export * from './layover/Banner.js';
107
107
  export * from './layover/Callout.js';
108
+ export * from './layover/CountIn.js';
108
109
  export * from './layover/Snackbar.js';
109
110
  export * from './journey/Route.js';
110
111
  export * from './journey/JourneyBadge.js';
package/dist/index.js CHANGED
@@ -108,6 +108,7 @@ export * from './media/Tile.js';
108
108
  export * from './media/Mosaic.js';
109
109
  export * from './layover/Banner.js';
110
110
  export * from './layover/Callout.js';
111
+ export * from './layover/CountIn.js';
111
112
  export * from './layover/Snackbar.js';
112
113
  export * from './journey/Route.js';
113
114
  export * from './journey/JourneyBadge.js';
@@ -0,0 +1,27 @@
1
+ import { type ComponentProps } from 'react';
2
+ export type CountInReason = 'done' | 'cancel';
3
+ export interface CountInProps extends Omit<ComponentProps<'div'>, 'onClick' | 'children'> {
4
+ /** CONTROLLED: counting over the screen — with `onOpenChange`; or `defaultOpen` */
5
+ open?: boolean;
6
+ /** UNCONTROLLED: starts counting (default true — mounting it is starting the count) */
7
+ defaultOpen?: boolean;
8
+ /** it asks to leave: the count reached its end (`done`) or the member tapped to stop it (`cancel`) */
9
+ onOpenChange?: (open: boolean, reason: CountInReason) => void;
10
+ /** the number it starts from, counting down one a second to 1 (default 5) */
11
+ from?: number;
12
+ /** the count ran out: the app starts what it was counting in to (its own sound, its own buzz) */
13
+ onDone?: () => void;
14
+ /** the member tapped anywhere: the count stops, nothing starts */
15
+ onCancel?: () => void;
16
+ /** it has faded out: the app unmounts it now */
17
+ onClosed?: () => void;
18
+ /** the tap-anywhere control's name for a screen reader (default: cardds's own "Cancel", in the page's language) */
19
+ cancelLabel?: string;
20
+ }
21
+ /**
22
+ * CountIn — a count laid over the whole screen, one BIG number a second (5 4 3 2 1), then it tells the app it is done. Ready, set, go: before
23
+ * something starts that the member must be ready for. A tap anywhere stops it. A child of the `Screen`, over everything, on the scrim.
24
+ * Controlled like an input: `open` + `onOpenChange(open, reason)`, or `defaultOpen`; `onDone` / `onCancel` say which way it ended.
25
+ * The count itself is all it shows: a sound or a buzz at the end is the app's.
26
+ */
27
+ export declare function CountIn({ open, defaultOpen, onOpenChange, from, onDone, onCancel, onClosed, cancelLabel, className, ...rest }: CountInProps): import("react").JSX.Element;
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { cx } from '../cx.js';
4
+ import { word } from '../words.js';
5
+ import { reducedMotion, useControlled, useLatest } from '../state.js';
6
+ /**
7
+ * CountIn — a count laid over the whole screen, one BIG number a second (5 4 3 2 1), then it tells the app it is done. Ready, set, go: before
8
+ * something starts that the member must be ready for. A tap anywhere stops it. A child of the `Screen`, over everything, on the scrim.
9
+ * Controlled like an input: `open` + `onOpenChange(open, reason)`, or `defaultOpen`; `onDone` / `onCancel` say which way it ended.
10
+ * The count itself is all it shows: a sound or a buzz at the end is the app's.
11
+ */
12
+ export function CountIn({ open, defaultOpen = true, onOpenChange, from = 5, onDone, onCancel, onClosed, cancelLabel, className, ...rest }) {
13
+ const [shown, request] = useControlled(open, defaultOpen, onOpenChange);
14
+ const [entered, setEntered] = useState(false); // its first frame is out of sight, so one mounted open fades in
15
+ const [n, setN] = useState(from);
16
+ const done = useLatest(onDone);
17
+ const closed = useLatest(onClosed);
18
+ const up = shown && entered;
19
+ useEffect(() => { const f = requestAnimationFrame(() => setEntered(true)); return () => cancelAnimationFrame(f); }, []);
20
+ useEffect(() => { if (shown)
21
+ setN(from); }, [shown, from]); // each opening counts from the top
22
+ useEffect(() => {
23
+ if (!up)
24
+ return;
25
+ const t = setTimeout(() => {
26
+ if (n > 1)
27
+ setN(n - 1);
28
+ else {
29
+ request(false, 'done');
30
+ done.current?.();
31
+ }
32
+ }, 1000);
33
+ return () => clearTimeout(t);
34
+ }, [up, n, request]);
35
+ useEffect(() => {
36
+ if (shown || !entered)
37
+ return;
38
+ const ms = reducedMotion() ? 0 : quickMs();
39
+ const t = setTimeout(() => closed.current?.(), ms);
40
+ return () => clearTimeout(t);
41
+ }, [shown, entered]);
42
+ const cancel = () => { if (!up)
43
+ return; request(false, 'cancel'); onCancel?.(); };
44
+ return (_jsxs("div", { className: cx('count-in', up && 'count-in--open', className), inert: !up, ...rest, children: [_jsx("button", { type: "button", className: "count-in__cancel", "aria-label": cancelLabel ?? word('cancel'), onClick: cancel }), _jsx("span", { className: "count-in__number", "aria-live": "assertive", "aria-atomic": "true", children: _jsx("span", { className: "count-in__digit", children: n }, n) })] }));
45
+ }
46
+ const quickMs = () => (parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--motion-quick')) || 0.2) * 1000;
@@ -13,6 +13,8 @@ export interface StampProps extends Omit<ComponentProps<'span'>, 'onClick'> {
13
13
  bare?: boolean;
14
14
  /** the inline size: a stamp beside a status line's words (a card's `Foot`: the stamp, "X took it", a round button), one `Chip xs` tall (`--stamp-xs-size`). Always bare and flat (no shadow). Several, lapped with a "+8": `AvatarStack more` */
15
15
  xs?: boolean;
16
+ /** kept back: the stamp keeps its box and draws nothing, hidden from screen readers too — until the app is ready to show it; when this turns false it appears in the same box, so nothing beside it moves */
17
+ held?: boolean;
16
18
  /** in a `Head`: the words keep no room for the stamp — they run the head's whole width and lie OVER it, the stamp in its place and size at the right under them (a long title that would wrap in the column beside it). Never hides a word */
17
19
  under?: boolean;
18
20
  /** turned a little on its middle — the one stamp a start screen hands over */
@@ -33,7 +35,7 @@ export interface StampProps extends Omit<ComponentProps<'span'>, 'onClick'> {
33
35
  * the app it has landed, so it sends. The strike scales it down from twice its size, so it never moves the layout (it may cover its neighbours for a moment);
34
36
  * a `tilt` is kept, the stamp ends at its turn. Afterwards the same stamp stands in the same place with no strike: drop `arrive` or keep it, nothing is struck twice.
35
37
  */
36
- export declare function Stamp({ pictures, tone, name, words, bare, xs, under, tilt, onClick, arrive, onArrived, className, onAnimationEnd, ...rest }: StampProps): import("react").JSX.Element;
38
+ export declare function Stamp({ pictures, tone, name, words, bare, xs, held, under, tilt, onClick, arrive, onArrived, className, onAnimationEnd, ...rest }: StampProps): import("react").JSX.Element;
37
39
  export interface StampPlaceProps extends Omit<ComponentProps<'span'>, 'onClick'> {
38
40
  /** a gap nobody is asked to fill: a paler edge (an album's free places) */
39
41
  faint?: boolean;
@@ -11,11 +11,11 @@ import { useStrike } from './useStrike.js';
11
11
  * the app it has landed, so it sends. The strike scales it down from twice its size, so it never moves the layout (it may cover its neighbours for a moment);
12
12
  * a `tilt` is kept, the stamp ends at its turn. Afterwards the same stamp stands in the same place with no strike: drop `arrive` or keep it, nothing is struck twice.
13
13
  */
14
- export function Stamp({ pictures, tone = 'custard', name, words, bare, xs, under, tilt, onClick, arrive, onArrived, className, onAnimationEnd, ...rest }) {
14
+ export function Stamp({ pictures, tone = 'custard', name, words, bare, xs, held, under, tilt, onClick, arrive, onArrived, className, onAnimationEnd, ...rest }) {
15
15
  const shown = pictures.slice(0, 4);
16
16
  const { struck } = useStrike(arrive, onArrived, onAnimationEnd);
17
17
  const { tap, Box, boxProps } = pressable(onClick, 'span', rest);
18
- return (_jsx(Box, { className: cx('stamp', `stamp--${shown.length}`, bare && 'stamp--bare', xs && 'stamp--xs', under && 'stamp--under', tilt && `stamp--tilt-${tilt}`, tap && 'stamp--tap', arrive && 'stamp--arrive', className), onAnimationEnd: struck, ...boxProps, children: _jsx("span", { className: "stamp__paper", children: _jsxs("span", { className: cx('stamp__pic', `sticky--${tone}`), children: [shown.map((picture, i) => _jsx("span", { className: "stamp__art", "aria-hidden": "true", children: picture }, i)), (name != null || words != null) && (_jsxs("span", { className: "stamp__cap", children: [words != null && _jsx("span", { className: "stamp__words", children: words }), name != null && _jsx("span", { className: "stamp__name", children: name })] }))] }) }) }));
18
+ return (_jsx(Box, { className: cx('stamp', `stamp--${shown.length}`, bare && 'stamp--bare', xs && 'stamp--xs', held && 'stamp--held', under && 'stamp--under', tilt && `stamp--tilt-${tilt}`, tap && 'stamp--tap', arrive && 'stamp--arrive', className), onAnimationEnd: struck, "aria-hidden": held || undefined, ...boxProps, children: _jsx("span", { className: "stamp__paper", children: _jsxs("span", { className: cx('stamp__pic', `sticky--${tone}`), children: [shown.map((picture, i) => _jsx("span", { className: "stamp__art", "aria-hidden": "true", children: picture }, i)), (name != null || words != null) && (_jsxs("span", { className: "stamp__cap", children: [words != null && _jsx("span", { className: "stamp__words", children: words }), name != null && _jsx("span", { className: "stamp__name", children: name })] }))] }) }) }));
19
19
  }
20
20
  /**
21
21
  * StampPlace — an empty place for a stamp: a 4:5 frame of round dots the size a Stamp is (`--stamp-size`), a word or an Icon inside.
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';
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';
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' },
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' },
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: 'เอาออก' },
5
+ play: 'ฟังเสียง', pause: 'หยุดเสียง', to: 'ถึง', turnToBack: 'พลิกดูด้านหลัง', turnToPicture: 'พลิกดูรูป', turnToFront: 'พลิกดูด้านหน้า', message: 'ข้อความ', address: 'จ่าหน้า', toMessage: 'เลื่อนกลับไปข้อความ', toAddress: 'เลื่อนไปจ่าหน้า', stampOn: 'ติดแสตมป์', stampOff: 'แกะแสตมป์ออก', stamps: 'เลือกแสตมป์', unread: 'ยังไม่ได้อ่าน', remove: 'เอาออก', cancel: 'ยกเลิก' },
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
@@ -451,6 +451,11 @@ whose markup has rules, because the sheet's box is the step itself:
451
451
  bottom layer), stays `duration` (4 s), slides out, never takes the cursor, never stops the member. `open` +
452
452
  `onOpenChange(open, reason)` or `defaultOpen`; unmount it in `onClosed`. One at a time: the queue and the notification
453
453
  list are the app's — the app shows its newest notification in it, `onTap` opens that notification.
454
+ - **A count before a start is a `CountIn`** (2026-10-25): one BIG number a second over the whole screen (`from`, default 5:
455
+ 5 4 3 2 1), on the scrim, then `onDone` — the app starts what it counted in to and plays its own sound or buzz (the
456
+ component has none). A tap anywhere stops it: `onCancel`. A child of the `Screen`. `open` + `onOpenChange(open, reason)`
457
+ (`done` | `cancel`) or `defaultOpen`; unmount it in `onClosed`. The number is `--fs-giant` and grows with the text scale;
458
+ bigger through `--count-in-size`. A screen reader hears each number (`aria-live`). Not `Countdown`, which is a small link that waits.
454
459
  - **Mount a `Modal` only when it is to show.** A `Modal` first mounted with `open={false}` is drawn in place, then leaves,
455
460
  and calls `onClosed` after about 700ms. Known fault, not fixed: under React StrictMode (any dev build) `onClosed` is
456
461
  never called for a `Modal` mounted that way. Keep the app's own `mounted` flag: set it when the question is asked,
@@ -807,7 +812,8 @@ it up. cardds draws the paper; the pictures, their words and which stamp a membe
807
812
  stamp in an `AvatarStack` are `--stamp-sm-size` wide (one tap: 48 × 60), on any surface and in any row. And the inline
808
813
  one: `Stamp xs` stands beside a status line's words (a card's `Foot`: the stamp, "X took it", a round button), one
809
814
  `Chip xs` tall, `--stamp-xs-size` (18.7 × 23.4, on `--fs-base`); always bare, no shadow, its teeth fewer and larger.
810
- Several lap in an `AvatarStack` with `more` ("+8"), the count then at the chip's scale. The stamps in
815
+ Several lap in an `AvatarStack` with `more` ("+8"), the count then at the chip's scale. A stamp the app is not ready to show yet is `held`: it keeps its box, draws nothing,
816
+ is hidden from screen readers, and appears in the same box when `held` turns false, so nothing beside it moves (any size). The stamps in
811
817
  a `PostDesk`'s tray are the standard size. One exception, by the owner's decision: the stamp at a postcard's corner is
812
818
  the postcard's own size, 72 × 90 (`--post-corner-stamp-w`), in neither. `words` is not drawn on a stamp 96 wide or
813
819
  narrower, so at the standard size only `name` shows, and it is larger.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usableapp/cardds",
3
- "version": "0.7.121",
3
+ "version": "0.7.123",
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.",