@usableapp/cardds 0.7.113 → 0.7.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/bin/cardds.mjs +19 -1
- package/css/actions.css +33 -1
- package/css/base.css +2 -0
- package/css/layover.css +1 -9
- package/css/parts.css +2 -0
- package/css/sheet.css +36 -0
- package/css/stamp.css +21 -2
- package/css/tokens.css +2 -1
- package/dist/actions/BtnGroup.d.ts +47 -6
- package/dist/actions/BtnGroup.js +55 -5
- package/dist/actions/BtnRow.d.ts +6 -2
- package/dist/actions/BtnRow.js +5 -3
- package/dist/actions/Chip.d.ts +4 -2
- package/dist/actions/Chip.js +3 -3
- package/dist/actions/joined.d.ts +2 -0
- package/dist/actions/joined.js +4 -0
- package/dist/cardds.css +97 -13
- package/dist/catalog.json +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/media/MapPick.d.ts +14 -2
- package/dist/media/MapPick.js +41 -2
- package/dist/parts/Foot.d.ts +4 -1
- package/dist/parts/Foot.js +3 -2
- package/dist/parts/Words.d.ts +2 -2
- package/dist/post/PostDesk.js +38 -4
- package/dist/sheets/Modal.d.ts +1 -5
- package/dist/sheets/Modal.js +2 -7
- package/dist/stamp/Stamp.d.ts +4 -2
- package/dist/stamp/Stamp.js +3 -3
- package/docs/reference.md +53 -3
- package/lib/guide.mjs +9 -8
- package/lint/rules.mjs +1 -1
- package/package.json +1 -1
- package/dist/actions/IconBtnGroup.d.ts +0 -35
- package/dist/actions/IconBtnGroup.js +0 -49
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,6 @@ export * from './sheets/SheetSteps.js';
|
|
|
35
35
|
export * from './sheets/Modal.js';
|
|
36
36
|
export * from './actions/Btn.js';
|
|
37
37
|
export * from './actions/IconBtn.js';
|
|
38
|
-
export * from './actions/IconBtnGroup.js';
|
|
39
38
|
export * from './actions/Chip.js';
|
|
40
39
|
export * from './actions/Dot.js';
|
|
41
40
|
export * from './actions/Dropdown.js';
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,6 @@ export * from './sheets/SheetSteps.js';
|
|
|
39
39
|
export * from './sheets/Modal.js';
|
|
40
40
|
export * from './actions/Btn.js';
|
|
41
41
|
export * from './actions/IconBtn.js';
|
|
42
|
-
export * from './actions/IconBtnGroup.js';
|
|
43
42
|
export * from './actions/Chip.js';
|
|
44
43
|
export * from './actions/Dot.js';
|
|
45
44
|
export * from './actions/Dropdown.js';
|
package/dist/media/MapPick.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ChangeEventHandler, type ComponentProps, type ReactNode } from 'react';
|
|
2
2
|
import { type IconName } from '../type/Icon.js';
|
|
3
3
|
export interface MapPickProps extends Omit<ComponentProps<'label'>, 'onChange'> {
|
|
4
4
|
/** the place's short name, under its mark (a library, a village hall): the radio's accessible name */
|
|
@@ -21,6 +21,15 @@ export interface MapPickProps extends Omit<ComponentProps<'label'>, 'onChange'>
|
|
|
21
21
|
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
22
22
|
/** this place cannot be picked now */
|
|
23
23
|
disabled?: boolean;
|
|
24
|
+
/** THE NAME IN A TOOLTIP: only the mark stands on the map; pressing it opens the name in a bubble over it, and a press anywhere
|
|
25
|
+
* else (another place too) or Escape closes it — so close places never lay their names over each other. Without it the name is always under the mark */
|
|
26
|
+
tip?: boolean;
|
|
27
|
+
/** with `tip`, CONTROLLED: the name's bubble is open. The app owns it — pair it with `onOpenChange` */
|
|
28
|
+
open?: boolean;
|
|
29
|
+
/** with `tip`, UNCONTROLLED: the bubble is open on arrival */
|
|
30
|
+
defaultOpen?: boolean;
|
|
31
|
+
/** with `tip`: the member opened (the mark pressed) or closed (the mark pressed again, a press elsewhere, Escape) the bubble */
|
|
32
|
+
onOpenChange?: (open: boolean) => void;
|
|
24
33
|
}
|
|
25
34
|
/**
|
|
26
35
|
* MapPick — a place on a map the member taps to choose it: a small round mark with its short name under it, standing on
|
|
@@ -28,5 +37,8 @@ export interface MapPickProps extends Omit<ComponentProps<'label'>, 'onChange'>
|
|
|
28
37
|
* full `--tap` square round the point, and the name takes a tap too. The marks of one choice share a `name` and are one
|
|
29
38
|
* radio group (arrow keys move between them); the picked one fills with accent. It knows nothing of the map or the sheet:
|
|
30
39
|
* it goes in a `MapArea` after the engine's mount, and the app owns which place is picked. On a sheet, never in a Card: the sheet is the paper the member fills in (Lh 2026-10-18).
|
|
40
|
+
* Variation `tip`: places close together — only the mark shows, its name opens in a bubble over it when it is pressed (the place is
|
|
41
|
+
* picked too) and closes on a press elsewhere or Escape. One bubble at a time with no place knowing another: pressing a second
|
|
42
|
+
* place is a press outside the first, which closes itself. Open/closed is controlled like an input (`open` + `onOpenChange`, or `defaultOpen`).
|
|
31
43
|
*/
|
|
32
|
-
export declare function MapPick({ children, icon, top, left, name, value, checked, defaultChecked, onChange, disabled, className, style, ...rest }: MapPickProps): import("react").JSX.Element;
|
|
44
|
+
export declare function MapPick({ children, icon, top, left, name, value, checked, defaultChecked, onChange, disabled, tip, open, defaultOpen, onOpenChange, className, style, ...rest }: MapPickProps): import("react").JSX.Element;
|
package/dist/media/MapPick.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
2
3
|
import { cx } from '../cx.js';
|
|
4
|
+
import { useControlled, useLatest } from '../state.js';
|
|
3
5
|
import { Icon } from '../type/Icon.js';
|
|
4
6
|
/**
|
|
5
7
|
* MapPick — a place on a map the member taps to choose it: a small round mark with its short name under it, standing on
|
|
@@ -7,7 +9,44 @@ import { Icon } from '../type/Icon.js';
|
|
|
7
9
|
* full `--tap` square round the point, and the name takes a tap too. The marks of one choice share a `name` and are one
|
|
8
10
|
* radio group (arrow keys move between them); the picked one fills with accent. It knows nothing of the map or the sheet:
|
|
9
11
|
* it goes in a `MapArea` after the engine's mount, and the app owns which place is picked. On a sheet, never in a Card: the sheet is the paper the member fills in (Lh 2026-10-18).
|
|
12
|
+
* Variation `tip`: places close together — only the mark shows, its name opens in a bubble over it when it is pressed (the place is
|
|
13
|
+
* picked too) and closes on a press elsewhere or Escape. One bubble at a time with no place knowing another: pressing a second
|
|
14
|
+
* place is a press outside the first, which closes itself. Open/closed is controlled like an input (`open` + `onOpenChange`, or `defaultOpen`).
|
|
10
15
|
*/
|
|
11
|
-
export function MapPick({ children, icon, top, left, name, value, checked, defaultChecked, onChange, disabled, className, style, ...rest }) {
|
|
12
|
-
|
|
16
|
+
export function MapPick({ children, icon, top, left, name, value, checked, defaultChecked, onChange, disabled, tip, open, defaultOpen = false, onOpenChange, className, style, ...rest }) {
|
|
17
|
+
const [shown, request] = useControlled(open, defaultOpen, onOpenChange);
|
|
18
|
+
const ref = useRef(null);
|
|
19
|
+
const ask = useLatest(request);
|
|
20
|
+
const isOpen = !!tip && shown;
|
|
21
|
+
// the bubble stays inside the map's box: under the mark when there is no room over it, slid in from a side edge
|
|
22
|
+
const [fit, setFit] = useState({ below: false, dx: 0 });
|
|
23
|
+
useLayoutEffect(() => {
|
|
24
|
+
if (!isOpen) {
|
|
25
|
+
setFit((f) => (f.below || f.dx ? { below: false, dx: 0 } : f));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const label = ref.current, bubble = label?.querySelector('.map-pick__name'), map = label?.closest('.map');
|
|
29
|
+
if (!bubble || !map)
|
|
30
|
+
return;
|
|
31
|
+
const b = bubble.getBoundingClientRect(), m = map.getBoundingClientRect();
|
|
32
|
+
const dx = b.left < m.left ? m.left - b.left : b.right > m.right ? m.right - b.right : 0;
|
|
33
|
+
setFit({ below: b.top < m.top, dx });
|
|
34
|
+
}, [isOpen]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!isOpen)
|
|
37
|
+
return;
|
|
38
|
+
// a press or the focus (an arrow key moving the pick) going elsewhere closes it
|
|
39
|
+
const away = (e) => { if (!ref.current?.contains(e.target))
|
|
40
|
+
ask.current(false); };
|
|
41
|
+
const key = (e) => { if (e.key === 'Escape')
|
|
42
|
+
ask.current(false); };
|
|
43
|
+
document.addEventListener('pointerdown', away, true);
|
|
44
|
+
document.addEventListener('focusin', away);
|
|
45
|
+
document.addEventListener('keydown', key);
|
|
46
|
+
return () => { document.removeEventListener('pointerdown', away, true); document.removeEventListener('focusin', away); document.removeEventListener('keydown', key); };
|
|
47
|
+
}, [isOpen, ask]);
|
|
48
|
+
// a press on the label reaches the input as one click (so does an arrow key moving the pick): it opens the bubble, or closes the open one
|
|
49
|
+
const press = () => { if (tip)
|
|
50
|
+
request(!shown); };
|
|
51
|
+
return (_jsxs("label", { ref: ref, className: cx('map-pick', tip && 'map-pick--tip', isOpen && 'is-open', isOpen && fit.below && 'is-below', className), style: { top, left, ...(fit.dx ? { '--_tip-dx': `${fit.dx}px` } : null), ...style }, ...rest, children: [_jsx("input", { type: "radio", name: name, value: value, checked: checked, defaultChecked: defaultChecked, onChange: onChange, onClick: press, disabled: disabled }), _jsx("span", { className: "map-pick__mark", children: icon && _jsx(Icon, { name: icon, size: "xs" }) }), _jsx("span", { className: "map-pick__name", children: children })] }));
|
|
13
52
|
}
|
package/dist/parts/Foot.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export interface FootProps extends ComponentProps<'div'> {
|
|
|
7
7
|
* stand as ONE group in the middle of the foot, a fixed gap apart (wider than the Btns' — `--foot-gap` sets it). The Btn foot is
|
|
8
8
|
* unchanged: this is the other foot, for a few big round answers */
|
|
9
9
|
round?: boolean;
|
|
10
|
+
/** with `round`: a dotted link between each two buttons and a closer gap (was `BtnTrio`). Knobs `--btn-trio-gap`, `--btn-trio-dots-w`,
|
|
11
|
+
* `--btn-trio-dots-h` */
|
|
12
|
+
joined?: boolean;
|
|
10
13
|
}
|
|
11
14
|
/** Foot — the last row of a card, a sheet or a stack sheet: what the member can do next, its buttons on one line. One takes the width, up to
|
|
12
15
|
* four share it evenly. Btns only in the row; a small link goes in `link`, under it. A `Btn form` keeps its own size here: as wide as its words,
|
|
@@ -14,4 +17,4 @@ export interface FootProps extends ComponentProps<'div'> {
|
|
|
14
17
|
* `primary` with a word, the others with icons): one centred group, a fixed gap between them. In a `Sheet` it stands on the box's bottom edge
|
|
15
18
|
* at every state. A `Card` finds its `Foot` by type (a turning card draws it on both faces), so a consumer's own component that wraps a `Foot`
|
|
16
19
|
* is not found. */
|
|
17
|
-
export declare function Foot({ link, round, className, children, ...rest }: FootProps): import("react").JSX.Element;
|
|
20
|
+
export declare function Foot({ link, round, joined, className, children, ...rest }: FootProps): import("react").JSX.Element;
|
package/dist/parts/Foot.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cx } from '../cx.js';
|
|
3
|
+
import { joinDots } from '../actions/joined.js';
|
|
3
4
|
/** Foot — the last row of a card, a sheet or a stack sheet: what the member can do next, its buttons on one line. One takes the width, up to
|
|
4
5
|
* four share it evenly. Btns only in the row; a small link goes in `link`, under it. A `Btn form` keeps its own size here: as wide as its words,
|
|
5
6
|
* centred — for a foot whose one button should not fill the card. With `round` it is the foot of a few round `IconBtn`s (`size="xl"`, one
|
|
6
7
|
* `primary` with a word, the others with icons): one centred group, a fixed gap between them. In a `Sheet` it stands on the box's bottom edge
|
|
7
8
|
* at every state. A `Card` finds its `Foot` by type (a turning card draws it on both faces), so a consumer's own component that wraps a `Foot`
|
|
8
9
|
* is not found. */
|
|
9
|
-
export function Foot({ link, round, className, children, ...rest }) {
|
|
10
|
-
return (_jsxs("div", { className: cx('foot', link != null && 'foot--link', round && 'foot--round', className), ...rest, children: [children, link != null && _jsx("div", { className: "foot__link", children: link })] }));
|
|
10
|
+
export function Foot({ link, round, joined, className, children, ...rest }) {
|
|
11
|
+
return (_jsxs("div", { className: cx('foot', link != null && 'foot--link', round && 'foot--round', joined && 'foot--joined', className), ...rest, children: [joined ? joinDots(children) : children, link != null && _jsx("div", { className: "foot__link", children: link })] }));
|
|
11
12
|
}
|
package/dist/parts/Words.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
2
|
export interface WordsProps extends Omit<ComponentProps<'span'>, 'title'> {
|
|
3
|
-
/** the title line */
|
|
3
|
+
/** the title line; on an option row, the answer to the sheet's question in the member's words, never "Choose…" (docs/reference.md "Option rows") */
|
|
4
4
|
title?: ReactNode;
|
|
5
|
-
/** the caption under it (may hold a Dot) */
|
|
5
|
+
/** the caption under it (may hold a Dot); on an option row, only the difference that decides, one line, on every option of the list or on none */
|
|
6
6
|
meta?: ReactNode;
|
|
7
7
|
/** the title as a heading element in that type level; without it the title is a span in title type. In a `Head` the title is always a heading: `h2` unless this says otherwise (`h1` for the one-feature page) */
|
|
8
8
|
level?: 'h1' | 'h2' | 'display';
|
package/dist/post/PostDesk.js
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useLayoutEffect, useRef } from 'react';
|
|
3
3
|
import { cx } from '../cx.js';
|
|
4
|
-
import { reducedMotion, swipeOf, useControlled, useLatest } from '../state.js';
|
|
4
|
+
import { reducedMotion, swipeOf, useControlled, useLatest, watchSize } from '../state.js';
|
|
5
5
|
import { holdRoomWhile } from '../room.js';
|
|
6
6
|
import { word } from '../words.js';
|
|
7
7
|
import { StampPlace } from '../stamp/Stamp.js';
|
|
8
8
|
const STRIKE = 700; // ms the struck card is seen before it asks to leave
|
|
9
9
|
const SWIPE = 48; // px a sideways drag must travel to move the paper
|
|
10
|
+
/* how far down the paper the line being written ends: a copy of the paper's column, off the page, holding only the words BEFORE the cursor */
|
|
11
|
+
function cursorFoot(ta) {
|
|
12
|
+
const cs = getComputedStyle(ta), copy = document.createElement('div');
|
|
13
|
+
Object.assign(copy.style, { position: 'absolute', visibility: 'hidden', top: '0', left: '-9999px', boxSizing: 'border-box', whiteSpace: 'pre-wrap', overflowWrap: 'break-word',
|
|
14
|
+
width: `${ta.clientWidth}px`, padding: cs.padding, font: cs.font, lineHeight: cs.lineHeight, letterSpacing: cs.letterSpacing });
|
|
15
|
+
copy.textContent = `${ta.value.slice(0, ta.selectionEnd)}\u200b`;
|
|
16
|
+
document.body.append(copy);
|
|
17
|
+
const foot = copy.offsetHeight - parseFloat(cs.paddingBottom);
|
|
18
|
+
copy.remove();
|
|
19
|
+
return foot;
|
|
20
|
+
}
|
|
21
|
+
/* the box the page scrolls in: the nearest one round the paper that scrolls */
|
|
22
|
+
function scrollerOf(el) {
|
|
23
|
+
let box = el.parentElement;
|
|
24
|
+
while (box && !/auto|scroll/.test(getComputedStyle(box).overflowY))
|
|
25
|
+
box = box.parentElement;
|
|
26
|
+
return box;
|
|
27
|
+
}
|
|
10
28
|
/* ruled lines the half holds, and how many the words leave free (the box is collapsed for a moment to read the words' own height) */
|
|
11
29
|
function linesOf(ta) {
|
|
12
30
|
const line = parseFloat(getComputedStyle(ta).lineHeight);
|
|
@@ -50,10 +68,26 @@ export function PostDesk({ half, defaultHalf = 'message', onHalfChange, message,
|
|
|
50
68
|
};
|
|
51
69
|
const full = useLatest(onFull);
|
|
52
70
|
const room = useRef(null);
|
|
53
|
-
|
|
71
|
+
/* the line being written stays in sight: with a keyboard up the page is shorter than the paper and its foot lies under the
|
|
72
|
+
bottom layer, where the browser still counts a cursor as seen. The page is scrolled, the paper never moves or shrinks. */
|
|
73
|
+
const reveal = () => {
|
|
74
|
+
const ta = paper.current, box = ta && scrollerOf(ta);
|
|
75
|
+
if (!ta || !box || document.activeElement !== ta)
|
|
76
|
+
return;
|
|
77
|
+
const line = parseFloat(getComputedStyle(ta).lineHeight), b = box.getBoundingClientRect();
|
|
78
|
+
const foot = b.bottom - parseFloat(getComputedStyle(box).paddingBottom); // the page keeps the bottom layer's height as its own padding
|
|
79
|
+
const at = ta.getBoundingClientRect().top + cursorFoot(ta);
|
|
80
|
+
if (at + line / 2 > foot)
|
|
81
|
+
box.scrollTop += at + line / 2 - foot;
|
|
82
|
+
else if (at - line * 2 < b.top)
|
|
83
|
+
box.scrollTop -= b.top - (at - line * 2);
|
|
84
|
+
};
|
|
85
|
+
useLayoutEffect(() => { measure(); room.current?.sync(); reveal(); }, [text]);
|
|
54
86
|
useEffect(() => {
|
|
55
87
|
const ta = paper.current;
|
|
56
|
-
|
|
88
|
+
const stop = watchSize([scrollerOf(ta)], reveal); // the keyboard came up: the page got shorter
|
|
89
|
+
const held = holdRoomWhile(room, [ta], measure, ta.parentElement, () => paper.current, () => ta.scrollHeight > ta.clientHeight + 1, (refused) => refused && full.current?.());
|
|
90
|
+
return () => { stop(); held(); };
|
|
57
91
|
}, []);
|
|
58
92
|
useEffect(() => {
|
|
59
93
|
if (at !== 'struck')
|
|
@@ -68,7 +102,7 @@ export function PostDesk({ half, defaultHalf = 'message', onHalfChange, message,
|
|
|
68
102
|
if (writing && dx)
|
|
69
103
|
askSide(dx < 0 ? 'address' : 'message');
|
|
70
104
|
};
|
|
71
|
-
return (_jsxs("div", { className: cx('post-desk', `post-desk--${side}`, `post-desk--${at}`, className), ...rest, children: [_jsxs("div", { className: "post-desk__window", onPointerDown: (e) => { from.current = { x: e.clientX, y: e.clientY }; }, onPointerUp: drop, children: [_jsxs("div", { className: "post-desk__card post-paper", children: [_jsx("section", { className: "post-desk__half post-desk__half--message", "aria-label": word('message'), inert: !writing || side !== 'message', children: _jsx("textarea", { ref: paper, className: "post-desk__write", "aria-label": word('message'), placeholder: placeholder, value: text, onChange: (e) => askText(e.currentTarget.value) }) }), _jsxs("section", { className: "post-desk__half post-desk__half--address", "aria-label": word('address'), inert: !writing || side !== 'address', children: [_jsx("div", { className: "post-desk__corner", children: _jsxs("div", { className: "post-corner", children: [!writing && postmark, _jsx("button", { className: "post-corner__stamp post-desk__slot", type: "button", "aria-pressed": chosen != null, "aria-label": word(chosen ? 'stampOff' : 'stampOn'), onClick: () => askStamp(chosen ? null : stamps[0]?.id ?? null), children: chosen ? chosen.stamp : _jsx(StampPlace, { "aria-hidden": "true", children: word('stampOn') }) })] }) }), _jsx("div", { className: "post-desk__lines", children: address })] })] }), writing && _jsx("button", { className: `post-desk__reach post-desk__reach--${side === 'message' ? 'address' : 'message'}`, type: "button", "aria-label": word(side === 'message' ? 'toAddress' : 'toMessage'), onClick: () => askSide(side === 'message' ? 'address' : 'message') }), at === 'sent' && _jsx("div", { className: "post-desk__gone", children: sent })] }), _jsx("p", { className: "post-desk__note", "aria-live": "polite", children: note }), writing && side === 'address' && stamps.length > 0 && (_jsx("div", { className: "post-desk__stamps", role: "group", "aria-label": word('stamps'), children: stamps.map((s) => (_jsx("button", { className: "post-desk__pick", type: "button", "aria-pressed": s.id === stuck, "aria-label": s.label, onClick: () => askStamp(s.id), children: s.stamp }, s.id))) }))] }));
|
|
105
|
+
return (_jsxs("div", { className: cx('post-desk', `post-desk--${side}`, `post-desk--${at}`, className), ...rest, children: [_jsxs("div", { className: "post-desk__window", onPointerDown: (e) => { from.current = { x: e.clientX, y: e.clientY }; }, onPointerUp: drop, children: [_jsxs("div", { className: "post-desk__card post-paper", children: [_jsx("section", { className: "post-desk__half post-desk__half--message", "aria-label": word('message'), inert: !writing || side !== 'message', children: _jsx("textarea", { ref: paper, className: "post-desk__write", "aria-label": word('message'), placeholder: placeholder, value: text, onChange: (e) => askText(e.currentTarget.value), onFocus: reveal, onSelect: reveal }) }), _jsxs("section", { className: "post-desk__half post-desk__half--address", "aria-label": word('address'), inert: !writing || side !== 'address', children: [_jsx("div", { className: "post-desk__corner", children: _jsxs("div", { className: "post-corner", children: [!writing && postmark, _jsx("button", { className: "post-corner__stamp post-desk__slot", type: "button", "aria-pressed": chosen != null, "aria-label": word(chosen ? 'stampOff' : 'stampOn'), onClick: () => askStamp(chosen ? null : stamps[0]?.id ?? null), children: chosen ? chosen.stamp : _jsx(StampPlace, { "aria-hidden": "true", children: word('stampOn') }) })] }) }), _jsx("div", { className: "post-desk__lines", children: address })] })] }), writing && _jsx("button", { className: `post-desk__reach post-desk__reach--${side === 'message' ? 'address' : 'message'}`, type: "button", "aria-label": word(side === 'message' ? 'toAddress' : 'toMessage'), onClick: () => askSide(side === 'message' ? 'address' : 'message') }), at === 'sent' && _jsx("div", { className: "post-desk__gone", children: sent })] }), _jsx("p", { className: "post-desk__note", "aria-live": "polite", children: note }), writing && side === 'address' && stamps.length > 0 && (_jsx("div", { className: "post-desk__stamps", role: "group", "aria-label": word('stamps'), children: stamps.map((s) => (_jsx("button", { className: "post-desk__pick", type: "button", "aria-pressed": s.id === stuck, "aria-label": s.label, onClick: () => askStamp(s.id), children: s.stamp }, s.id))) }))] }));
|
|
72
106
|
}
|
|
73
107
|
/** PostDeskLine — one address line of a PostDesk (`address`): a small word and a bare input on a rule. The value is the app's, like any input's. */
|
|
74
108
|
export function PostDeskLine({ label, type = 'text', autoComplete = 'off', className, ...rest }) {
|
package/dist/sheets/Modal.d.ts
CHANGED
|
@@ -29,11 +29,7 @@ export interface ModalAskProps extends Omit<ComponentProps<'div'>, 'title'> {
|
|
|
29
29
|
/** a LIGHT ModalAsk: the card's paper and dark words instead of the dark end (Lh 2026-09-29) — same layout, same trio; the one solid button turns dark */
|
|
30
30
|
light?: boolean;
|
|
31
31
|
}
|
|
32
|
-
/** ModalAsk — the dark end of a `Modal` (`light` = paper and dark words): the question, its fine print, and the answers: a `
|
|
32
|
+
/** ModalAsk — the dark end of a `Modal` (`light` = paper and dark words): the question, its fine print, and the answers: a `BtnRow round joined` of round icon buttons, or a `BtnRow` of word `Btn`s (it fills the card, each button's words on one line; a `Btn quiet` there is edged in the ask's own ink) — plain buttons
|
|
33
33
|
* with the app's `onClick`; the ModalAsk does nothing with them. A `Modal` holding ONLY a ModalAsk (no `Body`) is the CONFIRM: a question with nothing
|
|
34
34
|
* to show above it — the ModalAsk is the whole card and comes in with it in one beat. */
|
|
35
35
|
export declare function ModalAsk({ title, caption, light, className, children, ...rest }: ModalAskProps): import("react").JSX.Element;
|
|
36
|
-
export interface BtnTrioProps extends ComponentProps<'div'> {
|
|
37
|
-
}
|
|
38
|
-
/** BtnTrio — three round buttons with dotted connectors between them (× · ? · ✓); the middle one inverted. */
|
|
39
|
-
export declare function BtnTrio({ className, children, ...rest }: BtnTrioProps): import("react").JSX.Element;
|
package/dist/sheets/Modal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
3
|
import { focusWhenActive, useLatest } from '../state.js';
|
|
4
4
|
import { cx } from '../cx.js';
|
|
5
5
|
/**
|
|
@@ -57,14 +57,9 @@ export function Modal({ open = true, onClosed, onDismiss, className, ...rest })
|
|
|
57
57
|
}, [has, open]);
|
|
58
58
|
return _jsx("article", { ref: ref, className: cx('card modal', className), ...rest });
|
|
59
59
|
}
|
|
60
|
-
/** ModalAsk — the dark end of a `Modal` (`light` = paper and dark words): the question, its fine print, and the answers: a `
|
|
60
|
+
/** ModalAsk — the dark end of a `Modal` (`light` = paper and dark words): the question, its fine print, and the answers: a `BtnRow round joined` of round icon buttons, or a `BtnRow` of word `Btn`s (it fills the card, each button's words on one line; a `Btn quiet` there is edged in the ask's own ink) — plain buttons
|
|
61
61
|
* with the app's `onClick`; the ModalAsk does nothing with them. A `Modal` holding ONLY a ModalAsk (no `Body`) is the CONFIRM: a question with nothing
|
|
62
62
|
* to show above it — the ModalAsk is the whole card and comes in with it in one beat. */
|
|
63
63
|
export function ModalAsk({ title, caption, light, className, children, ...rest }) {
|
|
64
64
|
return (_jsxs("div", { className: cx('modal__drawer', light && 'modal__drawer--light', className), ...rest, children: [_jsx("h2", { className: "t-h2", tabIndex: -1, children: title }), caption != null && _jsx("p", { className: "t-caption", children: caption }), children] }));
|
|
65
65
|
}
|
|
66
|
-
/** BtnTrio — three round buttons with dotted connectors between them (× · ? · ✓); the middle one inverted. */
|
|
67
|
-
export function BtnTrio({ className, children, ...rest }) {
|
|
68
|
-
const items = Children.toArray(children);
|
|
69
|
-
return (_jsx("div", { className: cx('btn-trio', className), ...rest, children: items.map((child, i) => (_jsxs(Fragment, { children: [i > 0 && _jsx("span", { className: "btn-trio__dots" }), child] }, i))) }));
|
|
70
|
-
}
|
package/dist/stamp/Stamp.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface StampProps extends Omit<ComponentProps<'span'>, 'onClick'> {
|
|
|
11
11
|
words?: ReactNode;
|
|
12
12
|
/** the pictures alone: `name` and `words` are not drawn. For a stamp stuck on something (a postcard's corner); in a `StampOn` every stamp is bare already. The words are for the album */
|
|
13
13
|
bare?: boolean;
|
|
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
|
+
xs?: boolean;
|
|
14
16
|
/** turned a little on its middle — the one stamp a start screen hands over */
|
|
15
17
|
tilt?: 'left' | 'right';
|
|
16
18
|
/** the whole stamp is a button: it renders a `<button>` */
|
|
@@ -23,13 +25,13 @@ export interface StampProps extends Omit<ComponentProps<'span'>, 'onClick'> {
|
|
|
23
25
|
/**
|
|
24
26
|
* Stamp — a perforated paper stamp, 4:5: the pictures fill the inner frame on a tone, the words sit on the picture's foot.
|
|
25
27
|
* Every stamp is ONE size wherever it stands (`--stamp-size`, two taps wide: 96 × 120) — what holds it only places it; a holder narrower than that shows it whole, smaller.
|
|
26
|
-
* The one small stamp is a stamp stuck on something (`StampOn`). Every inner length follows the stamp's width.
|
|
28
|
+
* The one small stamp is a stamp stuck on something (`StampOn`); `xs` is the inline one, beside a status line's words. Every inner length follows the stamp's width.
|
|
27
29
|
* The outer box holds the size and the shadow; the paper inside is the one whose edge is punched (a mask would cut the shadow too).
|
|
28
30
|
* With `arrive` the stamp that stands in its place (the head of a card, `end={<Stamp arrive …/>}`) is struck onto it when the member sends, and `onArrived` tells
|
|
29
31
|
* 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);
|
|
30
32
|
* 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.
|
|
31
33
|
*/
|
|
32
|
-
export declare function Stamp({ pictures, tone, name, words, bare, tilt, onClick, arrive, onArrived, className, onAnimationEnd, ...rest }: StampProps): import("react").JSX.Element;
|
|
34
|
+
export declare function Stamp({ pictures, tone, name, words, bare, xs, tilt, onClick, arrive, onArrived, className, onAnimationEnd, ...rest }: StampProps): import("react").JSX.Element;
|
|
33
35
|
export interface StampPlaceProps extends Omit<ComponentProps<'span'>, 'onClick'> {
|
|
34
36
|
/** a gap nobody is asked to fill: a paler edge (an album's free places) */
|
|
35
37
|
faint?: boolean;
|
package/dist/stamp/Stamp.js
CHANGED
|
@@ -5,17 +5,17 @@ import { useStrike } from './useStrike.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Stamp — a perforated paper stamp, 4:5: the pictures fill the inner frame on a tone, the words sit on the picture's foot.
|
|
7
7
|
* Every stamp is ONE size wherever it stands (`--stamp-size`, two taps wide: 96 × 120) — what holds it only places it; a holder narrower than that shows it whole, smaller.
|
|
8
|
-
* The one small stamp is a stamp stuck on something (`StampOn`). Every inner length follows the stamp's width.
|
|
8
|
+
* The one small stamp is a stamp stuck on something (`StampOn`); `xs` is the inline one, beside a status line's words. Every inner length follows the stamp's width.
|
|
9
9
|
* The outer box holds the size and the shadow; the paper inside is the one whose edge is punched (a mask would cut the shadow too).
|
|
10
10
|
* With `arrive` the stamp that stands in its place (the head of a card, `end={<Stamp arrive …/>}`) is struck onto it when the member sends, and `onArrived` tells
|
|
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, tilt, onClick, arrive, onArrived, className, onAnimationEnd, ...rest }) {
|
|
14
|
+
export function Stamp({ pictures, tone = 'custard', name, words, bare, xs, 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', 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', 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 })] }))] }) }) }));
|
|
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/docs/reference.md
CHANGED
|
@@ -219,6 +219,28 @@ is one piece, the question and its answers. The templates take data and draw the
|
|
|
219
219
|
A screen written on the retired names (`CardHead`, `SheetHead`, `SheetBody`, `ModalBody`, `CardFoot`, `RowLead`, `RowBody`, `RowEnd`,
|
|
220
220
|
`CardThumb`, `CardBody`, `CardEnd`, `Card heading caption end level foot footLink footRound`) moves with `npx cardds codemod-parts <files>`.
|
|
221
221
|
|
|
222
|
+
### Option rows: the title and its meta
|
|
223
|
+
|
|
224
|
+
An option row on a sheet is a `Row` whose `Words` hold a `title` and maybe a `meta`, with a `Check` (or a radio) at its
|
|
225
|
+
end. Its words follow four rules (Lh 2026-10-24):
|
|
226
|
+
|
|
227
|
+
1. **The title is the answer, not a description.** Each title reads as a direct answer to the sheet's question, in the
|
|
228
|
+
member's own words. It never starts with "Choose…" / "เลือก…" and never repeats the question. The options differ in
|
|
229
|
+
their first words, so an eye tells them apart at a glance.
|
|
230
|
+
2. **A meta only when the title alone leaves the member unable to decide.** It says the difference that decides: what
|
|
231
|
+
happens, who sees it, how many hours, when. One line.
|
|
232
|
+
3. **No meta when** the title is self-evident (a day, a time, yes / no, a size), when the meta would only say the title
|
|
233
|
+
again in other words, or when it would be a promotion ("recommended!") or an instruction.
|
|
234
|
+
4. **All or none.** In one list every option has a meta, or none does. When only one option needs explaining, rewrite
|
|
235
|
+
that title instead of giving it the only meta.
|
|
236
|
+
|
|
237
|
+
```tsx
|
|
238
|
+
<Rows> {/* "Who sees your ask?" */}
|
|
239
|
+
<Row as="label"><Words title="Everyone nearby" meta="Shown on the map to members within 5 km" /><Check label="Everyone nearby" /></Row>
|
|
240
|
+
<Row as="label"><Words title="Only people I know" meta="Sent to the members you have traded with" /><Check label="Only people I know" /></Row>
|
|
241
|
+
</Rows>
|
|
242
|
+
```
|
|
243
|
+
|
|
222
244
|
## Sheet stack markup
|
|
223
245
|
|
|
224
246
|
The sheet stack (`.sheet-stack`, `stack.css` — the menu, see *Anatomy*) is the
|
|
@@ -550,11 +572,17 @@ between at 40% down the screen (see *Anatomy*, "Where the centre is"):
|
|
|
550
572
|
- **Foot** (`.foot`): the card's action buttons on one line. One
|
|
551
573
|
button takes the width; up to four share it in even parts; from three
|
|
552
574
|
on they drop their side padding so the labels keep the room. A panel of
|
|
553
|
-
up to four icon buttons (`
|
|
575
|
+
up to four icon buttons (`BtnGroup`, its `frame` look) takes the foot the same way; with
|
|
554
576
|
`form` it is as wide as its buttons (one tap each) and stands in the middle,
|
|
555
577
|
as `Btn form` does — in a foot, a `Page`, a `Centre` or a `CtaPack` — and
|
|
556
578
|
with `form labelled` its `label` is SHOWN as words at its left, the two
|
|
557
579
|
centred as one line (Lh 2026-10-10).
|
|
580
|
+
- A pick of a few WORDS (`BtnGroupItem`s) has two looks of its own. `look="strip"`: muted words on no
|
|
581
|
+
paper, the picked one filled — a tab strip, a day picker under a number. `look="choice"`: the words
|
|
582
|
+
JOINED in one frame like the icon frame — the button's paper and edge, a full tap tall, the words sharing
|
|
583
|
+
its width with a rule between them — the picked one the solid brand fill with the ink its ground declares (`--on-accent`, as a primary button) — a pick in a form or a sheet (เช้า · บ่าย ·
|
|
584
|
+
ทั้งวัน), where a strip did not read as pressable (Lh 2026-10-24). Both with `select`; knobs
|
|
585
|
+
`--btngroup-choice-bg|ink|border|rule|radius|on-bg|on-ink`.
|
|
558
586
|
- In React the head is the card's first child, a `<Head>` (`<Head><Words title meta /><Chip>…</Chip></Head>`),
|
|
559
587
|
and the foot its last, a `<Foot>` (`<Foot link={<Link sm>…</Link>}><Btn primary>…</Btn></Foot>`, `round` for a few
|
|
560
588
|
big round buttons), the content between them. The card finds its `Head` and its `Foot` by their type, so a
|
|
@@ -623,6 +651,21 @@ between at 40% down the screen (see *Anatomy*, "Where the centre is"):
|
|
|
623
651
|
`SheetStage over dim` (gallery `Home/AskSheet`). A bar's control is not a
|
|
624
652
|
form on the ground: a `Slider` in an `ActionBarTier`, a `Dropdown` in a
|
|
625
653
|
`FilterRow` or a `TopBar`'s actions, a `Toggle` in an `AppBar`.
|
|
654
|
+
- **Places to pick on a map: `MapPick` in a `MapArea`.** A small mark on its
|
|
655
|
+
point, one radio of a choice (the app owns which is picked); its short name
|
|
656
|
+
stands under the mark. When places stand close and their names would lie
|
|
657
|
+
over each other, give each `tip`: only the mark shows, pressing it picks the
|
|
658
|
+
place and opens its name in a bubble over the mark (under it when the map's
|
|
659
|
+
top edge leaves no room, slid in at a side edge); a press anywhere else,
|
|
660
|
+
another place too, or Escape closes it. One bubble at a time with no place
|
|
661
|
+
knowing another — pressing a second place is a press outside the first.
|
|
662
|
+
Open/closed is controlled like an input: `open` + `onOpenChange`, or
|
|
663
|
+
`defaultOpen`; to drive it, the app keeps the open place's value and gives
|
|
664
|
+
`open={shown === value}` and `onOpenChange={(o) => setShown(o ? value : null)}`
|
|
665
|
+
(gallery `MapPick/Tooltip`, `MapPick/Controlled`). Not a popover: the bubble
|
|
666
|
+
stays in the map's box, so it needs no anchor positioning (iOS 16.4).
|
|
667
|
+
Knobs `--map-pick-tip-bg`, `--map-pick-tip-ink`; a picked place's bubble
|
|
668
|
+
takes `--map-pick-on-bg` / `--map-pick-on-ink`.
|
|
626
669
|
- **Two sheet systems, one material.** *Sheet single* (`.sheet`, `sheet.css`)
|
|
627
670
|
is ONE sheet the member acts in, whatever it holds: a short entry in front
|
|
628
671
|
of a step's card, a place on a map, a payment on a dim page — in a `.step`
|
|
@@ -729,10 +772,17 @@ it up. cardds draws the paper; the pictures, their words and which stamp a membe
|
|
|
729
772
|
taps: 96 × 120) in a `Centre`, a sheet, a page, a `StampBook` and a card's head. What holds a stamp only places it. A
|
|
730
773
|
holder narrower than a stamp shrinks it, and the stamp is still shown whole. Set `--stamp-size` on `:root` for every
|
|
731
774
|
stamp, or on an element for the stamps inside it. There is one other size, the small one: a stamp in a `StampOn` and a
|
|
732
|
-
stamp in an `AvatarStack` are `--stamp-sm-size` wide (one tap: 48 × 60), on any surface and in any row.
|
|
775
|
+
stamp in an `AvatarStack` are `--stamp-sm-size` wide (one tap: 48 × 60), on any surface and in any row. And the inline
|
|
776
|
+
one: `Stamp xs` stands beside a status line's words (a card's `Foot`: the stamp, "X took it", a round button), one
|
|
777
|
+
`Chip xs` tall, `--stamp-xs-size` (18.7 × 23.4, on `--fs-base`); always bare, no shadow, its teeth fewer and larger.
|
|
778
|
+
Several lap in an `AvatarStack` with `more` ("+8"), the count then at the chip's scale. The stamps in
|
|
733
779
|
a `PostDesk`'s tray are the standard size. One exception, by the owner's decision: the stamp at a postcard's corner is
|
|
734
780
|
the postcard's own size, 72 × 90 (`--post-corner-stamp-w`), in neither. `words` is not drawn on a stamp 96 wide or
|
|
735
781
|
narrower, so at the standard size only `name` shows, and it is larger.
|
|
782
|
+
- **A stamp on a card lies flat** (Lh 2026-10-24): no shadow, at every size — the head's (`end`), a `FeedCard`'s lead, a
|
|
783
|
+
`Foot` row's, `xs`. One rule by where it stands (`stamp.css`), nothing to pass. A stamp off a card keeps its shadow: the
|
|
784
|
+
album (`StampBook`, also in a card or a sheet), the tray, a `PostDesk`, a start screen's stamp, a postcard's corner, a
|
|
785
|
+
stamp stuck on a note. A sheet is not "on a card" here: what a sheet holds keeps its shadow.
|
|
736
786
|
- **`StampPlace`** — an empty place the size of a stamp, its edge a ring of round dots: a word inside, `onClick` for "make
|
|
737
787
|
yours", `faint` for a gap nobody is asked to fill. The edge is a drawn stroke, so the dots are yours: `--stamp-place-dot`
|
|
738
788
|
is how wide each is (default `--rule-w`), `--stamp-place-gap` the distance from one dot's centre to the next
|
|
@@ -933,7 +983,7 @@ question and hunts for its answer. Rules 11–13 serve that:
|
|
|
933
983
|
only what is not read — dots, a lone number, an icon, a mark. Empty room is
|
|
934
984
|
not filled with more content; a new edge is made instead (line the buttons
|
|
935
985
|
up with the avatar). One exception: a small control with its own words
|
|
936
|
-
(`
|
|
986
|
+
(`BtnGroup form labelled`) is one centred line — the words name the
|
|
937
987
|
control, they are not content to be read.
|
|
938
988
|
12. **Show, don't explain.** Where a known picture carries it — an avatar for a
|
|
939
989
|
person, an icon, a `Ring`/`Track`/`NumberBand`, a `Chip` for a category — use it
|
package/lib/guide.mjs
CHANGED
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
// `npx cardds guide` (bin/cardds.mjs) prints it, the MCP server (lib/mcp.mjs) hands it over as its `instructions` at start.
|
|
3
3
|
// Short on purpose: an MCP client may truncate server instructions, so the trigger and the order come first. A component's own rules are
|
|
4
4
|
// not here — they are in its JSDoc (get_component) and in lint/rules.mjs (check).
|
|
5
|
-
export const GUIDE = `cardds — BEFORE drawing any phone-width / mobile screen in a project with @usableapp/cardds, or that Lh asks to build "with cardds": load these tools (ToolSearch "cardds" if
|
|
6
|
-
ORDER: find → scaffold or get → write → check. First question: has cardds drawn this screen already? find BOTH ways: by the axes (represents · shape · interact) and by the English noun
|
|
5
|
+
export const GUIDE = `cardds — BEFORE drawing any phone-width / mobile screen in a project with @usableapp/cardds, or that Lh asks to build "with cardds": load these tools (ToolSearch "cardds" if deferred) and call find_components. Even when the request only says prototype, poc, mock-up, sketch, "show me a design", หน้า, หน้าจอ, ขึ้นหน้า, ขอดู prototype — a screen, card, bottom sheet, sheet stack, form step, sticky note / post-it, chat of notes, stamp, postcard, home. Never hand-write HTML, CSS or emoji for what it has.
|
|
6
|
+
ORDER: find → scaffold or get → write → check. First question: has cardds drawn this screen already? find BOTH ways: by the axes (represents · shape · interact) and by the task's English noun ("sticky", "stamp", "chat").
|
|
7
7
|
TOOLS: find_components · scaffold_screen · get_component · list_components · check_source. No MCP: npx cardds find|scaffold|get|list|check (all take --json).
|
|
8
8
|
What no checker sees:
|
|
9
|
-
1. cardds is a framework you take from outside. Never edit, commit to or release cardds from a consumer project, never node_modules. What cannot be set from outside is a framework gap: STOP
|
|
10
|
-
2. Adjust from outside only, widest first: theme.css bases → knobs (--<component>-<what>) → props/slots.
|
|
11
|
-
3. Every component is controlled like an input (state/open/value + its on…, or default…) and none knows another: the app owns
|
|
9
|
+
1. cardds is a framework you take from outside. Never edit, commit to or release cardds from a consumer project, never node_modules. What cannot be set from outside is a framework gap: STOP, tell the user what you needed.
|
|
10
|
+
2. Adjust from outside only, widest first: theme.css bases → knobs (--<component>-<what>) → props/slots. Theme values are the user's call, never yours. cardGrounds() names a card the member cannot see on that theme; inkGrounds() a word or glyph they cannot read (docs/reference.md).
|
|
11
|
+
3. Every component is controlled like an input (state/open/value + its on…, or default…) and none knows another: the app owns state and wires them.
|
|
12
12
|
4. Import components, never copy their markup or classes: a component is the look AND the behaviour.
|
|
13
|
-
5. Mobile only, big targets
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
5. Mobile only, big targets, never adapted to desktop.
|
|
14
|
+
6. Option row: title = the answer; meta = only the deciding difference, all or none (docs/reference.md).
|
|
15
|
+
An HTML prototype (scaffold --html) is a still picture, never a screen; when it warns, run the tsx. check is tsx only.
|
|
16
|
+
A component's own rules: get_component; check enforces them.
|
|
16
17
|
`;
|
package/lint/rules.mjs
CHANGED
|
@@ -187,7 +187,7 @@ export function checkSource(source, file, { classes = carddsClasses() } = {}) {
|
|
|
187
187
|
const tag = tagAt(text, m.index);
|
|
188
188
|
for (const prop of props) {
|
|
189
189
|
const hit = tag.match(new RegExp(`\\s${prop}\\s*=\\s*(?:"[^"]*"|'[^']*'|\\{\\s*(?:"[^"]*"|'[^']*'|\`[^\`$]*\`)\\s*\\})`));
|
|
190
|
-
if (hit) add('control-name-repeat', 'warn', m.index + hit.index + 1, `${prop}="…" on <${name}>:
|
|
190
|
+
if (hit) add('control-name-repeat', 'warn', m.index + hit.index + 1, `${prop}="…" on <${name}>: set lang on <html> (lang="th") and drop this prop; another language is setWords(lang, {…}) once at app start, not a string on each component. cardds names this control itself, in the page's language (<html lang>) — keep the prop only if the words differ from cardds's.`);
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usableapp/cardds",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.115",
|
|
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.",
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { type ComponentProps } from 'react';
|
|
2
|
-
type Picked = string | null | string[];
|
|
3
|
-
export interface IconBtnGroupProps extends Omit<ComponentProps<'div'>, 'onChange' | 'defaultValue'> {
|
|
4
|
-
/** the group's accessible name (what these commands act on) */
|
|
5
|
-
label?: string;
|
|
6
|
-
/** buttons that STAY ON when pressed (Lh 2026-09-29): `one` — one on at a time, pressing another moves it (value: the on
|
|
7
|
-
* button's `value`, or null) · `many` — each on or off by itself (value: the on ones' values). None = plain commands. */
|
|
8
|
-
select?: 'one' | 'many';
|
|
9
|
-
/** which are on — each child IconBtn names itself with its own `value` */
|
|
10
|
-
value?: Picked;
|
|
11
|
-
/** UNCONTROLLED: which are on at first, in the same shape as `value`; the group then keeps its own. Pair of `value` */
|
|
12
|
-
defaultValue?: Picked;
|
|
13
|
-
/** asks the app: `one` → the pressed value · `many` → the new list */
|
|
14
|
-
onChange?: (value: Picked) => void;
|
|
15
|
-
/** the buttons one OVER the other, the panel one button wide — at a `Row`'s end, where a panel across would take the words' room */
|
|
16
|
-
vertical?: boolean;
|
|
17
|
-
/** the panel as wide as its buttons (each one tap wide, or as wide as its word), in the middle of its column the way a `Btn form` is —
|
|
18
|
-
* in a `Page`, a `Centre`, a `CtaPack`, and in a card's or a sheet's foot, where it keeps that width instead of filling the row.
|
|
19
|
-
* Without it the panel is the width of what it stands in. Not with `vertical`: that is already one button wide, at a row's end —
|
|
20
|
-
* `form` wins and warns */
|
|
21
|
-
form?: boolean;
|
|
22
|
-
/** with `form`: SHOW the `label` as words at the panel's left, on one line, the two centred together — plain ink in the label's type,
|
|
23
|
-
* outside the frame, and the words are the group's name (`aria-labelledby`). Where the line is too narrow (a big text size on a small
|
|
24
|
-
* phone) the words wrap ABOVE the panel and both stay centred */
|
|
25
|
-
labelled?: boolean;
|
|
26
|
-
}
|
|
27
|
-
/** IconBtnGroup — a panel of up to FOUR icon-only buttons in ONE frame, sharing its width, a rule between them in the frame's
|
|
28
|
-
* colour (Lh 2026-09-29). Each is an `IconBtn` (its `label` is its spoken name); a WORD may stand beside the icon as its child
|
|
29
|
-
* (`<IconBtn label="ชาย"><Icon name="man" />ชาย</IconBtn>`) — two named sides of a `Panes`. Plain: each does its own thing on its onClick.
|
|
30
|
-
* With `select`, a pressed button stays filled (aria-pressed): `one` or `many`. At home in a card's or a sheet's foot;
|
|
31
|
-
* `vertical` at a row's end; `form` as a small control of its own in the middle of a `Page` or a `Centre`
|
|
32
|
-
* (`<IconBtnGroup form labelled label="เปลี่ยนสีพื้น">` = the words, then the narrow panel, both centred). With `labelled` the root
|
|
33
|
-
* is the line holding the words and the panel — `className`, `style` and `ref` go there, the knobs too. */
|
|
34
|
-
export declare function IconBtnGroup({ label, labelled, form, select, value, defaultValue, onChange, vertical, className, children, ...rest }: IconBtnGroupProps): import("react").JSX.Element;
|
|
35
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Children, cloneElement, isValidElement, useId } from 'react';
|
|
3
|
-
import { cx } from '../cx.js';
|
|
4
|
-
import { useControlled, warnOnce } from '../state.js';
|
|
5
|
-
/** IconBtnGroup — a panel of up to FOUR icon-only buttons in ONE frame, sharing its width, a rule between them in the frame's
|
|
6
|
-
* colour (Lh 2026-09-29). Each is an `IconBtn` (its `label` is its spoken name); a WORD may stand beside the icon as its child
|
|
7
|
-
* (`<IconBtn label="ชาย"><Icon name="man" />ชาย</IconBtn>`) — two named sides of a `Panes`. Plain: each does its own thing on its onClick.
|
|
8
|
-
* With `select`, a pressed button stays filled (aria-pressed): `one` or `many`. At home in a card's or a sheet's foot;
|
|
9
|
-
* `vertical` at a row's end; `form` as a small control of its own in the middle of a `Page` or a `Centre`
|
|
10
|
-
* (`<IconBtnGroup form labelled label="เปลี่ยนสีพื้น">` = the words, then the narrow panel, both centred). With `labelled` the root
|
|
11
|
-
* is the line holding the words and the panel — `className`, `style` and `ref` go there, the knobs too. */
|
|
12
|
-
export function IconBtnGroup({ label, labelled, form, select, value, defaultValue, onChange, vertical, className, children, ...rest }) {
|
|
13
|
-
const words = useId();
|
|
14
|
-
if (Children.count(children) > 4)
|
|
15
|
-
warnOnce('icon-btn-group', 'cardds IconBtnGroup: more than 4 buttons — keep 4, put the rest in a Menu behind one of them');
|
|
16
|
-
if (form && vertical)
|
|
17
|
-
warnOnce('icon-btn-group-form-vertical', 'cardds IconBtnGroup: `form` and `vertical` together — `vertical` is already one button wide at a row\'s end, `form` is the panel in the middle of its column; `form` is kept, `vertical` ignored');
|
|
18
|
-
if (labelled && !form)
|
|
19
|
-
warnOnce('icon-btn-group-labelled', 'cardds IconBtnGroup: `labelled` is for `form` (the words and the narrow panel as one centred line) — without `form` the label stays the spoken name only');
|
|
20
|
-
if (labelled && form && !label)
|
|
21
|
-
warnOnce('icon-btn-group-labelled-words', 'cardds IconBtnGroup: `labelled` shows the `label` — it has none, so no words are drawn');
|
|
22
|
-
const line = !!(form && labelled && label);
|
|
23
|
-
const [shown, request] = useControlled(value, defaultValue ?? (select === 'many' ? [] : null), onChange);
|
|
24
|
-
const on = (v) => (Array.isArray(shown) ? shown.includes(v) : shown === v);
|
|
25
|
-
const items = !select ? children : Children.map(children, (c) => {
|
|
26
|
-
if (!isValidElement(c))
|
|
27
|
-
return c;
|
|
28
|
-
const el = c;
|
|
29
|
-
const v = el.props.value;
|
|
30
|
-
if (v == null)
|
|
31
|
-
return c;
|
|
32
|
-
return cloneElement(el, {
|
|
33
|
-
'aria-pressed': on(v),
|
|
34
|
-
onClick: (e) => {
|
|
35
|
-
el.props.onClick?.(e);
|
|
36
|
-
if (select === 'one')
|
|
37
|
-
request(v);
|
|
38
|
-
else {
|
|
39
|
-
const list = Array.isArray(shown) ? shown : [];
|
|
40
|
-
request(on(v) ? list.filter((x) => x !== v) : [...list, v]);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
const panel = (_jsx("div", { role: "group", "aria-label": line ? undefined : label, "aria-labelledby": line ? words : undefined, className: cx('icon-btn-group', form && 'icon-btn-group--form', vertical && !form && 'icon-btn-group--vertical', !line && className), ...(line ? {} : rest), children: items }));
|
|
46
|
-
if (!line)
|
|
47
|
-
return panel;
|
|
48
|
-
return _jsxs("div", { className: cx('icon-btn-line', className), ...rest, children: [_jsx("span", { id: words, className: "icon-btn-line__words", children: label }), panel] });
|
|
49
|
-
}
|