@usableapp/cardds 0.7.152 → 0.7.154

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.
@@ -31,6 +31,8 @@ export interface SheetProps extends Omit<ComponentProps<'article'>, 'onChange'>
31
31
  tone?: 1 | 2 | 3 | 4 | 5;
32
32
  /** the content is the theme's paper (`--action-bg`, the ground of its fields) and the head keeps the sheet's colour. The same prop on a `StackSheet` or a `Card` in a stack. Omit it and the content is the same colour as the head */
33
33
  paper?: boolean;
34
+ /** coming up, the sheet leaves the cursor where it is: it gives it to none of its fields and not to its handle. For a sheet that comes up under a field outside it that has the cursor (a `StickyAnswer` note being written) — the keyboard stays up */
35
+ leaveCursor?: boolean;
34
36
  }
35
37
  /**
36
38
  * Sheet — the SINGLE sheet: one card as a bottom sheet holding what the member ACTS on. Always the full height of its
@@ -52,6 +54,7 @@ export interface SheetProps extends Omit<ComponentProps<'article'>, 'onChange'>
52
54
  * fixed habit of every sheet. A sheet asked up in the same box meanwhile waits for it: "one left, another came", never two sheets
53
55
  * crossing and never one continuous move, whatever the app's wiring (both states set in one render, or the next raised from the
54
56
  * first's `onSettled`) — the app adds no timer.
55
- * The CURSOR is cardds's too: once it has come up it waits in the field marked `data-autofocus`, else the first field, else the heading — write no `autoFocus` or `.focus()` for it.
57
+ * The CURSOR is cardds's too: once it has come up it waits in the field marked `data-autofocus`, else the first field, else the heading — write no `autoFocus` or `.focus()` for it. `leaveCursor`: it
58
+ * moves the cursor nowhere (a field over the sheet is being written in).
56
59
  */
57
- export declare function Sheet({ state, defaultState, onStateChange, onSettled, half, states, handle, mark, refreshing, tone, paper, className, style, children, onFocus, ...rest }: SheetProps): import("react").JSX.Element;
60
+ export declare function Sheet({ state, defaultState, onStateChange, onSettled, half, states, handle, mark, refreshing, tone, paper, leaveCursor, className, style, children, onFocus, ...rest }: SheetProps): import("react").JSX.Element;
@@ -36,9 +36,10 @@ function markLong(node, long) {
36
36
  * fixed habit of every sheet. A sheet asked up in the same box meanwhile waits for it: "one left, another came", never two sheets
37
37
  * crossing and never one continuous move, whatever the app's wiring (both states set in one render, or the next raised from the
38
38
  * first's `onSettled`) — the app adds no timer.
39
- * The CURSOR is cardds's too: once it has come up it waits in the field marked `data-autofocus`, else the first field, else the heading — write no `autoFocus` or `.focus()` for it.
39
+ * The CURSOR is cardds's too: once it has come up it waits in the field marked `data-autofocus`, else the first field, else the heading — write no `autoFocus` or `.focus()` for it. `leaveCursor`: it
40
+ * moves the cursor nowhere (a field over the sheet is being written in).
40
41
  */
41
- export function Sheet({ state, defaultState = 'half', onStateChange, onSettled, half, states, handle = true, mark = 'line', refreshing, tone, paper, className, style, children, onFocus, ...rest }) {
42
+ export function Sheet({ state, defaultState = 'half', onStateChange, onSettled, half, states, handle = true, mark = 'line', refreshing, tone, paper, leaveCursor, className, style, children, onFocus, ...rest }) {
42
43
  const [current, request] = useControlled(state, defaultState, onStateChange);
43
44
  const ref = useRef(null);
44
45
  const handleRef = useRef(null);
@@ -61,12 +62,12 @@ export function Sheet({ state, defaultState = 'half', onStateChange, onSettled,
61
62
  const rose = live !== 'peek' && live !== 'away' && RANK[live] > RANK[was.current];
62
63
  const from = was.current;
63
64
  was.current = live;
64
- if (!rose)
65
+ if (!rose || leaveCursor)
65
66
  return;
66
67
  const cancel = focusWhenActive(ref.current, { scope: ':scope > .body', fallback: () => (from === 'away' ? handleRef.current : null) });
67
68
  return () => { if (!cancel())
68
69
  was.current = from; }; // cut short (StrictMode's trial run, or a new state mid-slide): the rise still counts from where it began
69
- }, [live]);
70
+ }, [live]); // leaveCursor is read as it is when the sheet rises
70
71
  /* bring a control into the part of the body that shows — between the pinned head and the foot's strip on the cut. The sheet asks
71
72
  for the lowest of its states, from the current one (or `atLeast`) upward, that has room; if none has, its highest. */
72
73
  const reveal = useCallback((target, reason, atLeast) => {
@@ -7,7 +7,7 @@ export interface StickyProps extends Omit<ComponentProps<'div'>, 'onClick'> {
7
7
  tone?: StickyTone;
8
8
  /** the note has been READ: no folded corner. A folded corner (the default) says the note is new — not read yet */
9
9
  flat?: boolean;
10
- /** a die-cut sticker note: a band of white paper all round it (`--sticky-cut-size`), rounded corners, a soft lifted shadow, no fold — so it says nothing of read or unread. Straight like every note (`tilt` still turns it) */
10
+ /** a die-cut sticker note: a band of white paper all round it (`--sticky-cut-size`), rounded corners, a soft lifted shadow. Read or unread as any note: unread, the paper's corner folds inside the band; `flat` = read. Straight like every note (`tilt` still turns it) */
11
11
  cut?: boolean;
12
12
  /** what a folded note says to a screen reader after its words (default: cardds's own word, "Unread" / "ยังไม่ได้อ่าน" by the page's language) */
13
13
  unreadLabel?: string;
@@ -29,7 +29,7 @@ export interface StickyProps extends Omit<ComponentProps<'div'>, 'onClick'> {
29
29
  * Every note is that one square whatever it says, never grown: words it cannot hold are written one size smaller (`--sticky-small-font`, the label size:
30
30
  * six lines instead of four and a half); words that do not fit even then are cut where their room ends. The note measures its own words.
31
31
  * A `StickyField` on it stops at that room: the note refuses the input that would not fit, and the app's `onChange` is not called for it.
32
- * THE FOLD SAYS UNREAD: the bottom-right corner folded over = not read yet; `flat` = read. A folded note says so to a screen reader too (`unreadLabel`).
32
+ * THE FOLD SAYS UNREAD: the bottom-right corner folded over = not read yet; `flat` = read — a `cut` note too, its paper folding inside the white band. A folded note says so to a screen reader too (`unreadLabel`).
33
33
  * The outer box holds the tone and the shadow; the paper inside is the part that is cut (a clip would cut the shadow too).
34
34
  */
35
35
  export declare function Sticky({ tone, flat, cut, unreadLabel, head, date, tilt, foot, corner, stuck, onClick, className, children, ref, ...rest }: StickyProps): import("react").JSX.Element;
@@ -11,7 +11,7 @@ import { fitSticky } from './fit.js';
11
11
  * Every note is that one square whatever it says, never grown: words it cannot hold are written one size smaller (`--sticky-small-font`, the label size:
12
12
  * six lines instead of four and a half); words that do not fit even then are cut where their room ends. The note measures its own words.
13
13
  * A `StickyField` on it stops at that room: the note refuses the input that would not fit, and the app's `onChange` is not called for it.
14
- * THE FOLD SAYS UNREAD: the bottom-right corner folded over = not read yet; `flat` = read. A folded note says so to a screen reader too (`unreadLabel`).
14
+ * THE FOLD SAYS UNREAD: the bottom-right corner folded over = not read yet; `flat` = read — a `cut` note too, its paper folding inside the white band. A folded note says so to a screen reader too (`unreadLabel`).
15
15
  * The outer box holds the tone and the shadow; the paper inside is the part that is cut (a clip would cut the shadow too).
16
16
  */
17
17
  export function Sticky({ tone = 'custard', flat, cut, unreadLabel, head, date, tilt, foot, corner, stuck, onClick, className, children, ref, ...rest }) {
@@ -34,8 +34,8 @@ export function Sticky({ tone = 'custard', flat, cut, unreadLabel, head, date, t
34
34
  return holdRoomWhile(room, [paper.querySelector('.sticky__body')], measure, paper, fieldOf, () => fitSticky(note) === 'over', measure);
35
35
  }, []);
36
36
  const notched = corner != null;
37
- const folded = !flat && !notched && !cut;
37
+ const folded = !flat && !notched;
38
38
  const { tap, Box, boxProps } = pressable(notched ? undefined : onClick, 'div', rest);
39
39
  const Part = tap ? 'span' : 'div';
40
- return (_jsxs(Box, { ref: setRefs(own, ref), className: cx('sticky', `sticky--${tone}`, small && 'sticky--small', (flat || cut) && 'sticky--flat', cut && 'sticky--cut', notched && 'sticky--corner', tilt && `sticky--tilt-${tilt}`, tap && 'sticky--tap', className), ...boxProps, children: [_jsxs(Part, { className: "sticky__paper", children: [(head != null || date != null) && _jsxs(Part, { className: "sticky__head", children: [head, date] }), _jsx(Part, { className: "sticky__body", children: children }), foot != null && _jsx(Part, { className: "sticky__foot", children: foot }), folded && _jsx("span", { className: "sticky__fold", "aria-hidden": "true" }), folded && _jsx("span", { className: "sticky__state t-sr", children: unreadLabel ?? word('unread') })] }), stuck != null && _jsx(Part, { className: "sticky__stuck", children: stuck }), notched && _jsx("div", { className: "sticky__corner", children: corner })] }));
40
+ return (_jsxs(Box, { ref: setRefs(own, ref), className: cx('sticky', `sticky--${tone}`, small && 'sticky--small', flat && 'sticky--flat', cut && 'sticky--cut', notched && 'sticky--corner', tilt && `sticky--tilt-${tilt}`, tap && 'sticky--tap', className), ...boxProps, children: [_jsxs(Part, { className: "sticky__paper", children: [(head != null || date != null) && _jsxs(Part, { className: "sticky__head", children: [head, date] }), _jsx(Part, { className: "sticky__body", children: children }), foot != null && _jsx(Part, { className: "sticky__foot", children: foot }), folded && _jsx("span", { className: "sticky__fold", "aria-hidden": "true" }), folded && _jsx("span", { className: "sticky__state t-sr", children: unreadLabel ?? word('unread') })] }), stuck != null && _jsx(Part, { className: "sticky__stuck", children: stuck }), notched && _jsx("div", { className: "sticky__corner", children: corner })] }));
41
41
  }
@@ -11,13 +11,18 @@ export interface StickyAnswerProps extends ComponentProps<'div'> {
11
11
  tools?: ReactNode;
12
12
  /** what stands under that row — the stamp the writer may stick on the note (a `StampCell on` button), a line of words */
13
13
  tray?: ReactNode;
14
+ /** a `Sheet` standing under the note while it is written on, from under the note to the screen's foot (above the keyboard) — in place of `tools` and `tray`: what it holds (a `StickyPick`, a stamp strip, a `Foot` with the send button) is the app's, and so is its `state` (`writing ? 'full' : 'away'`). Give it `leaveCursor`: the cursor stays in the note's field from the first touch, so the keyboard stays up */
15
+ sheet?: ReactNode;
14
16
  }
15
17
  /**
16
- * StickyAnswer — the note you answer on, and its two places. The child is the note itself: a `Sticky flat` holding a `StickyField` (give it
18
+ * StickyAnswer — the note you answer on, and its two places. The child is the note itself: a `Sticky cut flat` (or a plain `Sticky flat`) holding a `StickyField` (give it
17
19
  * a `placeholder`: the pale word). AT REST it waits at the screen's foot, near the right, three quarters of it in sight. A touch on it puts
18
20
  * the cursor in the field, and the holder ASKS to write: the note goes to the top of the screen, the screen behind is washed pale and takes
19
21
  * no touch, and `tools` and `tray` wake under it (inert until then). The note keeps the one size in both places. A child of the `Screen`,
20
22
  * a layer over it. Controlled like an input: `writing` + `onWritingChange(writing, reason)`, or `defaultWriting`; the words, the paper and
21
23
  * what is stuck on the note are the app's, on the parts it passes in. When writing ends the cursor leaves the note, so the keyboard goes down.
24
+ * THE MAKE-A-NOTE FORM: `sheet` instead of `tools`/`tray` — a `Sheet` under the note, from its bottom edge to the screen's foot, holding what the
25
+ * app picks for the note. While the cursor is in the note, a press on a control under it (a swatch, a stamp, a button — not a field) leaves the
26
+ * cursor in the note, so the keyboard stays up: the writer goes on typing after every pick.
22
27
  */
23
- export declare function StickyAnswer({ writing, defaultWriting, onWritingChange, tools, tray, className, children, onKeyDown, ...rest }: StickyAnswerProps): import("react").JSX.Element;
28
+ export declare function StickyAnswer({ writing, defaultWriting, onWritingChange, tools, tray, sheet, className, children, onKeyDown, ...rest }: StickyAnswerProps): import("react").JSX.Element;
@@ -2,15 +2,20 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useRef } from 'react';
3
3
  import { cx } from '../cx.js';
4
4
  import { useControlled } from '../state.js';
5
+ /* what takes the cursor for typing in it — a press on anything else under the note leaves the cursor in the note */
6
+ const TYPED = 'textarea, select, [contenteditable="true"], input:not([type=checkbox], [type=radio], [type=button], [type=submit], [type=reset], [type=hidden])';
5
7
  /**
6
- * StickyAnswer — the note you answer on, and its two places. The child is the note itself: a `Sticky flat` holding a `StickyField` (give it
8
+ * StickyAnswer — the note you answer on, and its two places. The child is the note itself: a `Sticky cut flat` (or a plain `Sticky flat`) holding a `StickyField` (give it
7
9
  * a `placeholder`: the pale word). AT REST it waits at the screen's foot, near the right, three quarters of it in sight. A touch on it puts
8
10
  * the cursor in the field, and the holder ASKS to write: the note goes to the top of the screen, the screen behind is washed pale and takes
9
11
  * no touch, and `tools` and `tray` wake under it (inert until then). The note keeps the one size in both places. A child of the `Screen`,
10
12
  * a layer over it. Controlled like an input: `writing` + `onWritingChange(writing, reason)`, or `defaultWriting`; the words, the paper and
11
13
  * what is stuck on the note are the app's, on the parts it passes in. When writing ends the cursor leaves the note, so the keyboard goes down.
14
+ * THE MAKE-A-NOTE FORM: `sheet` instead of `tools`/`tray` — a `Sheet` under the note, from its bottom edge to the screen's foot, holding what the
15
+ * app picks for the note. While the cursor is in the note, a press on a control under it (a swatch, a stamp, a button — not a field) leaves the
16
+ * cursor in the note, so the keyboard stays up: the writer goes on typing after every pick.
12
17
  */
13
- export function StickyAnswer({ writing, defaultWriting = false, onWritingChange, tools, tray, className, children, onKeyDown, ...rest }) {
18
+ export function StickyAnswer({ writing, defaultWriting = false, onWritingChange, tools, tray, sheet, className, children, onKeyDown, ...rest }) {
14
19
  const [shown, request] = useControlled(writing, defaultWriting, onWritingChange);
15
20
  const box = useRef(null);
16
21
  const note = useRef(null);
@@ -31,5 +36,10 @@ export function StickyAnswer({ writing, defaultWriting = false, onWritingChange,
31
36
  if (e.key === 'Escape' && shown)
32
37
  request(false, 'escape');
33
38
  };
34
- return (_jsxs("div", { ref: box, className: cx('sticky-answer', shown && 'sticky-answer--writing', className), onKeyDown: key, ...rest, children: [_jsx("div", { className: "sticky-answer__scrim", onClick: () => request(false, 'outside') }), _jsx("div", { ref: note, className: "sticky-answer__note", onFocus: () => request(true, 'focus'), children: children }), (tools != null || tray != null) && (_jsxs("div", { className: "sticky-answer__under", inert: !shown, children: [tools != null && _jsx("div", { className: "sticky-answer__tools", children: tools }), tray != null && _jsx("div", { className: "sticky-answer__tray", children: tray })] }))] }));
39
+ /* a press under the note keeps the cursor in it (the press still clicks): the keyboard does not drop with every pick */
40
+ const keep = (e) => {
41
+ if (note.current?.contains(document.activeElement) && !e.target.closest(TYPED))
42
+ e.preventDefault();
43
+ };
44
+ return (_jsxs("div", { ref: box, className: cx('sticky-answer', shown && 'sticky-answer--writing', className), onKeyDown: key, ...rest, children: [_jsx("div", { className: "sticky-answer__scrim", onClick: () => request(false, 'outside') }), _jsx("div", { ref: note, className: "sticky-answer__note", onFocus: () => request(true, 'focus'), children: children }), (tools != null || tray != null) && (_jsxs("div", { className: "sticky-answer__under", inert: !shown, onMouseDown: keep, children: [tools != null && _jsx("div", { className: "sticky-answer__tools", children: tools }), tray != null && _jsx("div", { className: "sticky-answer__tray", children: tray })] })), sheet != null && _jsx("div", { className: "sticky-answer__sheet", inert: !shown, onMouseDown: keep, children: sheet })] }));
35
45
  }
package/docs/reference.md CHANGED
@@ -478,6 +478,8 @@ whose markup has rules, because the sheet's box is the step itself:
478
478
  that already has the cursor keeps it. One mechanic for all of them (`focusWhenActive`, src/state.ts); an app writes no focus code.
479
479
  Another field than the first: `<Field data-autofocus … />`. Off: `data-standby="off"` on any box around the part — no field
480
480
  is given the cursor (the heading or the handle still is). The gallery sets it on its stories; its Cursor button (C) turns it on.
481
+ One exception, said by the sheet: `Sheet leaveCursor` moves the cursor nowhere as it comes up — for a sheet that rises under a
482
+ field outside it being written in (the `StickyAnswer` make-a-note form), so the keyboard stays up.
481
483
  - **The signal set — four colours, four meanings, everywhere** (Lh 2026-10-02): `--signal-ok` green (it went right) ·
482
484
  `--signal-warn` yellow (look out) · `--signal-error` red (it went wrong) · `--signal-info` blue (for your information).
483
485
  The wireframe has them too. A theme may retune a shade, never a meaning. Each is dark enough for words and edges;
@@ -815,15 +817,19 @@ A sticky note is a square of paper with a few words on it. The family is in `src
815
817
  inside that element only.
816
818
  - **The fold says unread.** A folded bottom-right corner means the note has not been read. `flat` means it has. A
817
819
  folded note also says so to a screen reader after its words: cardds's own word by the page's language, or
818
- `unreadLabel`.
820
+ `unreadLabel`. The same on a `cut` note (2026-10-27): an app's `flat={!unread}` reads the same on both.
819
821
  - **`Sticky`** — `tone` is one of the nine papers in `STICKY_TONES`. `head`, `date`, `foot` are small rows above and
820
822
  under the words. `onClick` makes the whole note a button. `stuck` holds what is stuck on the paper (`StampOn`).
821
823
  `tilt` turns the one note a start screen hands over. A `Chip sm` in the `foot` is a name label on the paper: it
822
824
  stands at the start, what follows it (a time) at the end, on one line.
823
825
  - **`Sticky cut`** — the die-cut sticker note (Lh 2026-10-27): a band of plain paper all round it (`--sticky-cut-size`,
824
- `--sticky-cut-bg`, default the stamp paper), round corners (`--sticky-radius`), a soft lifted shadow, no fold — a
825
- sticker says nothing of read or unread. Straight like every note: the sample it came from was turned, the turn was
826
- not taken (`tilt` still turns it). The note being written on a "make a note" screen wears it (`StickyScreens/MakeNote`).
826
+ `--sticky-cut-bg`, default the stamp paper), small round corners (`--sticky-radius`, the small card's corner here),
827
+ a soft lifted shadow. Read or unread as every note: unread, its paper's corner folds INSIDE the band, the band showing
828
+ through the cut corner; `flat` = read (the earlier "a sticker says nothing of read or unread" is gone: a chat needs to
829
+ mark unread on cut notes). Straight like every note: the sample it came
830
+ from was turned, the turn was not taken (`tilt` still turns it). The band is inside the note's box: the note grows by
831
+ the band on every side and the paper inside stays `--sticky-size`, so its writing room is a plain note's; nothing
832
+ spills. The note being written on a "make a note" screen wears it, `flat` (`StickyScreens/MakeNote`, `StickyAnswer/MakeNote`).
827
833
  - **`StickyBoard`** — notes stuck on a page. Rows wrap by the width: two on a phone, three from 504 of room, a screen about 540 wide.
828
834
  The notes stand edge to edge and each is turned by one of four angles in turn (`--sticky-board-turn-1` to `-4`), so
829
835
  no two notes that touch lean alike. Later is on top, always: the right note over the left, the lower over the
@@ -842,12 +848,17 @@ A sticky note is a square of paper with a few words on it. The family is in `src
842
848
  note's words start under it and show two lines at most. As the first child of a `StickyThread` (the room, with
843
849
  `as="h2"`: the sub-heading under the screen's h1) it stays at the top while the notes run under it. The app stops
844
850
  rendering it when the subject ends. Knobs: `--sticky-heading-title-font`, `-caption-font`, `-gap`, `-room`.
845
- - **`StickyAnswer`** — the note you answer on. Its child is a `Sticky flat` holding a `StickyField`. At rest it waits
851
+ - **`StickyAnswer`** — the note you answer on. Its child is a `Sticky cut flat` (or a plain `Sticky flat`) holding a `StickyField`. At rest it waits
846
852
  at the screen's foot near the right, three quarters of it in sight (`--sticky-answer-show`). A touch on it puts the
847
853
  cursor in the field and the holder asks to write: `writing` + `onWritingChange(writing, reason)`, or
848
854
  `defaultWriting`. While writing, the note stands at the top, the screen behind is washed pale and takes no touch,
849
855
  and `tools` (the paper chooser, the send button) and `tray` (the writer's stamp) stand under it. A touch outside or
850
856
  Escape asks to stop. The words, the paper and the stamps on the note are the app's. It is a child of the `Screen`.
857
+ The make-a-note form: `sheet` in place of `tools`/`tray` — a `Sheet` standing under the note while it is written on,
858
+ from the note's edge to the screen's foot, above the keyboard. What it holds (a `StickyPick`, a stamp strip, a `Foot`
859
+ with the send button) and its `state` (`writing ? 'full' : 'away'`) are the app's; give it `leaveCursor`. The cursor
860
+ stays in the note's field from the first touch: a press on a control under the note (not a field) leaves it there, so
861
+ the keyboard stays up while the writer picks. Story: `StickyAnswer/MakeNote`.
851
862
  - **`StickyPile`** — one to six notes lying one over another, as the newest notes of a feed do. It is a feed item of
852
863
  its own, with no card frame. The first child is on top, so pass the newest first. Each note under it lies a step
853
864
  right and down (`--sticky-pile-step-x`, 24, and `--sticky-pile-step-y`, 8), turned by the board's four angles by
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usableapp/cardds",
3
- "version": "0.7.152",
3
+ "version": "0.7.154",
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).",