@usableapp/cardds 0.7.109 → 0.7.111

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.
@@ -23,6 +23,8 @@ export interface StampOnProps extends ComponentProps<'div'> {
23
23
  removeFor?: number;
24
24
  /** the stamp at the stamp's MAIN size, 96 × 120 (`--stamp-size`), to cover what it lies on; the default is the small size, 48 × 60 (`--stamp-sm-size`), which leaves a note's words readable */
25
25
  main?: boolean;
26
+ /** UNDER A CARD'S WORDS: the stamp at the main size, 96 × 120, laid at the top right corner of the card (or of its face), stacked LOWEST inside it so the badge, the chips and the words are all drawn over it and none is hidden. No shadow, no drag (`at` and `onAtChange` are ignored), and a press on it falls through to the card; `turn` and `arrive` work as on any stamp. Put it as a direct child of the `Card` */
27
+ under?: boolean;
26
28
  /** the stamp sticks ITSELF: as it comes onto the screen it is struck onto its place (shown large, pressed down to its size). Nobody
27
29
  * picked it or pressed to stick it — the app shows it when its own move (send) begins. With `onArrived`. A stamp that already stands in a card's head or a centre, where the layout put it, is `Stamp arrive` instead */
28
30
  arrive?: boolean;
@@ -47,4 +49,4 @@ export interface StampOnProps extends ComponentProps<'div'> {
47
49
  * arriving cannot be taken off: no cross, no focus, no Delete until it has landed (it is not stuck yet). `arrive` with `main` strikes
48
50
  * the main size, 96 × 120, onto its place.
49
51
  */
50
- export declare function StampOn({ at, defaultAt, turn, onAtChange, label, onRemove, removeLabel, removeFor, main, arrive, onArrived, className, style, onAnimationEnd, children, ...rest }: StampOnProps): import("react").JSX.Element;
52
+ export declare function StampOn({ at, defaultAt, turn, onAtChange, label, onRemove, removeLabel, removeFor, main, under, arrive, onArrived, className, style, onAnimationEnd, children, ...rest }: StampOnProps): import("react").JSX.Element;
@@ -38,16 +38,16 @@ const write = (el, at) => { el.style.setProperty('--stamp-on-x', String(at.x));
38
38
  * arriving cannot be taken off: no cross, no focus, no Delete until it has landed (it is not stuck yet). `arrive` with `main` strikes
39
39
  * the main size, 96 × 120, onto its place.
40
40
  */
41
- export function StampOn({ at, defaultAt = MIDDLE, turn = 0, onAtChange, label, onRemove, removeLabel, removeFor = 3000, main, arrive, onArrived, className, style, onAnimationEnd, children, ...rest }) {
42
- const under = useContext(UnderNotes);
41
+ export function StampOn({ at, defaultAt = MIDDLE, turn = 0, onAtChange, label, onRemove, removeLabel, removeFor = 3000, main, under, arrive, onArrived, className, style, onAnimationEnd, children, ...rest }) {
42
+ const pile = useContext(UnderNotes);
43
43
  const [shown, request] = useControlled(at, defaultAt, onAtChange);
44
44
  const [held, setHeld] = useState(false);
45
45
  const [cross, setCross] = useState(false);
46
46
  const grip = useRef(null);
47
47
  const timer = useRef(undefined);
48
- const moves = onAtChange != null && !under;
48
+ const moves = onAtChange != null && !pile && !under;
49
49
  const { arrived, struck } = useStrike(arrive, onArrived, onAnimationEnd);
50
- const removes = onRemove != null && !under && !(arrive && !arrived);
50
+ const removes = onRemove != null && !pile && !(arrive && !arrived);
51
51
  const ask = (next) => { if (next.x !== shown.x || next.y !== shown.y)
52
52
  request(next); };
53
53
  const stop = () => clearTimeout(timer.current);
@@ -119,6 +119,6 @@ export function StampOn({ at, defaultAt = MIDDLE, turn = 0, onAtChange, label, o
119
119
  const own = moves || removes ? { tabIndex: 0, role: 'group', 'aria-label': label, onKeyDown: key } : null;
120
120
  const drag = moves ? { onPointerDown: down, onPointerMove: move, onPointerUp: up, onPointerCancel: up } : null;
121
121
  const guard = removes ? { onClick: click } : null;
122
- return (_jsxs("div", { className: cx('stamp-on', moves && 'stamp-on--move', main && 'stamp-on--main', arrive && 'stamp-on--arrive', held && 'is-held', className), style: place, onAnimationEnd: struck, ...rest, ...own, ...drag, ...guard, inert: under || undefined, children: [children, removes && cross && (_jsx("button", { type: "button", className: "stamp-on__remove", "aria-label": removeLabel ?? word('remove'), onPointerDown: (e) => e.stopPropagation(), onClick: (e) => { e.stopPropagation(); stop(); setCross(false); onRemove(); }, onFocus: stop, onBlur: () => { if (!grip.current)
122
+ return (_jsxs("div", { className: cx('stamp-on', moves && 'stamp-on--move', main && 'stamp-on--main', under && 'stamp-on--under', arrive && 'stamp-on--arrive', held && 'is-held', className), style: place, onAnimationEnd: struck, ...rest, ...own, ...drag, ...guard, inert: pile || undefined, children: [children, removes && cross && (_jsx("button", { type: "button", className: "stamp-on__remove", "aria-label": removeLabel ?? word('remove'), onPointerDown: (e) => e.stopPropagation(), onClick: (e) => { e.stopPropagation(); stop(); setCross(false); onRemove(); }, onFocus: stop, onBlur: () => { if (!grip.current)
123
123
  show(); }, children: _jsx("span", { className: "stamp-on__remove-disc", children: _jsx(Icon, { name: "x" }) }) }))] }));
124
124
  }
@@ -19,6 +19,8 @@ export interface TextProps extends React.HTMLAttributes<HTMLElement> {
19
19
  /** the member may select and copy these words (a code, an address, a reference number) — everything else in a Screen is not
20
20
  * selectable, like a native app (Lh 2026-09-25) */
21
21
  selectable?: boolean;
22
+ /** body only: the words show `--text-scroll-lines` lines (knob, default 3) in a plain box with no border, and the rest scrolls inside the box — a long reason in a card. A scroll never turns a turning card */
23
+ scroll?: boolean;
22
24
  /** the element; defaults per level (h2 for display/h1/h2, p for title/body/stat, span for the rest) */
23
25
  as?: 'h1' | 'h2' | 'h3' | 'p' | 'span' | 'strong' | 'div';
24
26
  }
@@ -27,7 +29,7 @@ export interface TextProps extends React.HTMLAttributes<HTMLElement> {
27
29
  * Headings inside a card head are h2 by default; a screen title in a TopBar is h1.
28
30
  * Everything scales from the root font-size, so there are no pixel sizes to pick.
29
31
  */
30
- export declare function Text({ level, xl, mono, muted, caps, grow, sr, selectable, as, className, ...rest }: TextProps): import("react").DetailedReactHTMLElement<{
32
+ export declare function Text({ level, xl, mono, muted, caps, grow, sr, selectable, scroll, as, className, ...rest }: TextProps): import("react").DetailedReactHTMLElement<{
31
33
  /** the element it renders (React 19 passes `ref` as a prop) */
32
34
  ref?: React.Ref<HTMLElement>;
33
35
  defaultChecked?: boolean | undefined;
package/dist/type/Text.js CHANGED
@@ -8,9 +8,9 @@ const DEFAULT_AS = {
8
8
  * Headings inside a card head are h2 by default; a screen title in a TopBar is h1.
9
9
  * Everything scales from the root font-size, so there are no pixel sizes to pick.
10
10
  */
11
- export function Text({ level, xl, mono, muted, caps, grow, sr, selectable, as, className, ...rest }) {
11
+ export function Text({ level, xl, mono, muted, caps, grow, sr, selectable, scroll, as, className, ...rest }) {
12
12
  return createElement(as ?? DEFAULT_AS[level] ?? 'span', {
13
- className: cx(`t-${level}`, level === 'stat' && xl && 't-stat--xl', level === 'stat' && mono && 't-stat--mono', muted && 't-muted', caps && 't-caps', grow && 'grow', sr && 't-sr', selectable && 't-select', className),
13
+ className: cx(`t-${level}`, level === 'stat' && xl && 't-stat--xl', level === 'stat' && mono && 't-stat--mono', muted && 't-muted', caps && 't-caps', grow && 'grow', sr && 't-sr', selectable && 't-select', scroll && level === 'body' && 't-scroll', className),
14
14
  ...rest,
15
15
  });
16
16
  }
package/lib/catalog.mjs CHANGED
@@ -150,7 +150,7 @@ export function find(cat, query, axes = {}) {
150
150
  // every three words of the request in a row, function words kept: a note that says "a or b" or "at a glance" as asked is the piece the request describes
151
151
  const all = words(String(query));
152
152
  const phrases = all.slice(2).map((w, i) => ` ${all[i]} ${all[i + 1]} ${w} `);
153
- const rank = (items, fields, level, said = () => 0, saysIt = () => '') => { // a field is [text, weight, match = hits]; saysIt is the text whose phrases count
153
+ const rank = (items, fields, level, said = () => 0, saysIt = () => '', variant = () => 0) => { // a field is [text, weight, match = hits]; saysIt is the text whose phrases count
154
154
  const scored = items.map((item) => {
155
155
  let matched = 0, score = 0;
156
156
  for (const t of toks) {
@@ -159,9 +159,9 @@ export function find(cat, query, axes = {}) {
159
159
  }
160
160
  const own = ` ${words(saysIt(item)).join(' ')} `;
161
161
  score += 3 * phrases.filter((p) => own.includes(p)).length;
162
- return { item, matched, score, level: active ? level(item) : 0, said: active ? said(item) : 0 };
162
+ return { item, matched, score, level: active ? level(item) : 0, said: active ? said(item) : 0, variant: variant(item) };
163
163
  });
164
- const byWords = (a, b) => b.matched - a.matched || b.score - a.score;
164
+ const byWords = (a, b) => b.matched - a.matched || b.score - a.score || a.variant - b.variant; // equal words: the picture that is another's again with one thing changed goes last
165
165
  const byAxes = (a, b) => b.said - a.said || b.level - a.level; // among equal words: the screen that says the axes itself, then one component over several
166
166
  return { axis: scored.filter((r) => r.level).sort((a, b) => byWords(a, b) || byAxes(a, b)), rest: scored.filter((r) => r.matched && !r.level).sort(byWords) };
167
167
  };
@@ -174,7 +174,7 @@ export function find(cat, query, axes = {}) {
174
174
  return !matchesUnion(parts, asked.want) ? 0 : parts.some((r) => matches(r, asked.want)) ? 2 : 1; // `none` is about the whole screen: one show-only part is not enough
175
175
  };
176
176
  const said = (s) => axisWords.filter((v) => hits(s.description, v)).length;
177
- const [screenAxis, screenRest] = tier(rank(screens, (s) => [[s.id, 5], [s.description, 3], [s.uses.join(' '), 1]], level, said), TOP);
177
+ const [screenAxis, screenRest] = tier(rank(screens, (s) => [[s.id, 5], [s.description, 3], [s.uses.join(' '), 1]], level, said, undefined, (s) => Number(screens.some((o) => o !== s && s.id.startsWith(o.id)))), TOP);
178
178
  // a component is found by its name (the name that IS the word counts as much again as one that contains it: "card" is Card before FeedCard, whatever
179
179
  // their other words say), its description, its role's note (what it is FOR, in the words of a request: "a setting turned on or off"), the values of its role
180
180
  // a word says ("choose" → pick, "number"), what it stands in for, then its prop names
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usableapp/cardds",
3
- "version": "0.7.109",
3
+ "version": "0.7.111",
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.",