@usableapp/cardds 0.7.157 → 0.7.159

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/css/actions.css +37 -4
  3. package/css/base.css +14 -3
  4. package/css/card.css +5 -0
  5. package/css/forms.css +38 -1
  6. package/css/lists.css +4 -0
  7. package/css/parts.css +5 -1
  8. package/css/sheet.css +5 -2
  9. package/css/stamp.css +21 -17
  10. package/css/tokens.css +1 -0
  11. package/dist/actions/Btn.d.ts +12 -3
  12. package/dist/actions/Btn.js +6 -3
  13. package/dist/actions/BtnGroup.d.ts +3 -2
  14. package/dist/actions/BtnGroup.js +3 -3
  15. package/dist/actions/BtnRow.d.ts +6 -2
  16. package/dist/actions/BtnRow.js +3 -3
  17. package/dist/actions/IconBtn.d.ts +8 -2
  18. package/dist/actions/IconBtn.js +4 -2
  19. package/dist/actions/LinkBlock.d.ts +9 -0
  20. package/dist/actions/LinkBlock.js +8 -0
  21. package/dist/actions/useSendOut.d.ts +4 -0
  22. package/dist/actions/useSendOut.js +15 -0
  23. package/dist/cardds.css +130 -28
  24. package/dist/cards/Card.d.ts +8 -1
  25. package/dist/cards/CardParts.d.ts +8 -0
  26. package/dist/cards/CardParts.js +5 -0
  27. package/dist/catalog.json +1 -1
  28. package/dist/forms/Field.d.ts +13 -1
  29. package/dist/forms/Field.js +55 -6
  30. package/dist/forms/MessageBar.d.ts +9 -2
  31. package/dist/forms/MessageBar.js +6 -4
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.js +1 -0
  34. package/dist/lists/Bubble.d.ts +859 -4
  35. package/dist/lists/Bubble.js +18 -4
  36. package/dist/lists/Row.d.ts +4 -0
  37. package/dist/media/MapArea.d.ts +7 -1
  38. package/dist/media/MapArea.js +5 -3
  39. package/dist/parts/Foot.d.ts +8 -2
  40. package/dist/parts/Foot.js +4 -3
  41. package/dist/scaffold/Page.d.ts +3 -1
  42. package/dist/scaffold/Page.js +3 -1
  43. package/dist/sheets/SheetSteps.js +3 -3
  44. package/dist/stamp/Stamp.d.ts +3 -1
  45. package/dist/stamp/Stamp.js +4 -2
  46. package/dist/state.d.ts +2 -2
  47. package/dist/state.js +4 -4
  48. package/dist/type/Text.d.ts +5 -1
  49. package/dist/type/Text.js +3 -2
  50. package/dist/type/icons.d.ts +1 -1
  51. package/dist/type/icons.js +2 -2
  52. package/docs/reference.md +52 -8
  53. package/icons.svg +1 -0
  54. package/package.json +1 -1
@@ -33,6 +33,18 @@ export interface FieldProps extends Omit<ComponentProps<'input'>, 'className' |
33
33
  className?: string;
34
34
  /** inline style for the label wrapper, not the input */
35
35
  style?: React.CSSProperties;
36
+ /** FOLDED into a button (Lh 2026-10-28): the words of the button the field stands as until it is wanted — its `icon` leads them
37
+ * (`<Field fold="ค้นหาสถานที่" icon="search" action={…} />`). A tap on the button OPENS the field out of it, the cursor in it, the
38
+ * keyboard up; Escape, or leaving it EMPTY, asks to fold it back. In a `CtaPack` the button stands at the line's end and the open
39
+ * field takes the whole line over what stands beside it. Rows of offers under it (`Rows`) are the app's, as with any field. One line
40
+ * only: with `rows` it is ignored */
41
+ fold?: ReactNode;
42
+ /** with `fold`: the field is out (true) or folded into its button (false). Pair of `onOpenChange` */
43
+ open?: boolean;
44
+ /** with `fold`, UNCONTROLLED: out at first; the field then keeps its own */
45
+ defaultOpen?: boolean;
46
+ /** with `fold`: asks the app — true on the button's tap, false on Escape or on leaving the field empty */
47
+ onOpenChange?: (open: boolean) => void;
36
48
  }
37
49
  /** the digits of `v`, written into `mask`; a mark is written only when a digit comes after it */
38
50
  export declare function applyMask(v: string, mask: string): string;
@@ -45,4 +57,4 @@ export declare function applyMask(v: string, mask: string): string;
45
57
  * sheet: `<Field rows={4} />` over `<Field rows={2} />`). A frame says "tap me", so a framed write-in is a Field, never a Composer:
46
58
  * the Composer is the one big write-in on the paper, bare (Lh 2026-10-19, timebank's ask sheet).
47
59
  */
48
- export declare function Field({ icon, action, label, error, format: formatProp, digits: digitsProp, formatError, mask: maskProp, rows, className, style, onBlur, onInput, onChange, ...input }: FieldProps): import("react").JSX.Element;
60
+ export declare function Field({ icon, action, label, error, format: formatProp, digits: digitsProp, formatError, mask: maskProp, rows, fold: foldProp, open, defaultOpen, onOpenChange, className, style, onBlur, onInput, onChange, onKeyDown, ...input }: FieldProps): import("react").JSX.Element;
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useLayoutEffect, useRef, useState } from 'react';
3
- import { warnOnce, watchSize } from '../state.js';
3
+ import { flushSync } from 'react-dom';
4
+ import { useControlled, warnOnce, watchSize } from '../state.js';
4
5
  import { formatOk, useCheck } from './check.js';
5
6
  import { cx } from '../cx.js';
6
7
  import { Icon } from '../type/Icon.js';
@@ -28,8 +29,16 @@ export function applyMask(v, mask) {
28
29
  * sheet: `<Field rows={4} />` over `<Field rows={2} />`). A frame says "tap me", so a framed write-in is a Field, never a Composer:
29
30
  * the Composer is the one big write-in on the paper, bare (Lh 2026-10-19, timebank's ask sheet).
30
31
  */
31
- export function Field({ icon, action, label, error, format: formatProp, digits: digitsProp, formatError, mask: maskProp, rows, className, style, onBlur, onInput, onChange, ...input }) {
32
+ export function Field({ icon, action, label, error, format: formatProp, digits: digitsProp, formatError, mask: maskProp, rows, fold: foldProp, open, defaultOpen = false, onOpenChange, className, style, onBlur, onInput, onChange, onKeyDown, ...input }) {
32
33
  const lines = rows != null;
34
+ if (lines && foldProp != null)
35
+ warnOnce('field-rows-fold', 'cardds Field: `fold` is for one line — with `rows` it is ignored');
36
+ const fold = lines ? undefined : foldProp;
37
+ const [out, ask] = useControlled(open, defaultOpen, onOpenChange);
38
+ const box = useRef(null);
39
+ const btn = useRef(null);
40
+ const wide = useRef(0); // the button's width with its words, read while they show
41
+ const [tight, setTight] = useState(false); // no room for the words beside the line's other controls: the icon alone
33
42
  if (lines && (formatProp != null || digitsProp != null || maskProp != null))
34
43
  warnOnce('field-rows-one-line', 'cardds Field: `mask`, `format` and `digits` are for one line — with `rows` they are ignored');
35
44
  const [format, digits, mask] = lines ? [undefined, undefined, undefined] : [formatProp, digitsProp, maskProp];
@@ -74,6 +83,28 @@ export function Field({ icon, action, label, error, format: formatProp, digits:
74
83
  document.fonts?.ready.then(fit);
75
84
  return watchSize([el], fit);
76
85
  }, [input.placeholder, lines]);
86
+ /* folded: the open field grows out of the button's own box — its width (`--_fold-w`) and, in a CtaPack, the line it stands on (`--_fold-y`) */
87
+ useLayoutEffect(() => {
88
+ const el = box.current, b = btn.current;
89
+ if (!el || !b)
90
+ return;
91
+ const fit = () => {
92
+ if (!el.classList.contains('field-fold--tight'))
93
+ wide.current = b.offsetWidth;
94
+ setTight(el.clientWidth < wide.current);
95
+ el.style.setProperty('--_fold-w', `${b.offsetWidth}px`);
96
+ el.style.setProperty('--_fold-y', `${el.offsetTop}px`);
97
+ el.style.setProperty('--_fold-h', `${el.offsetHeight}px`);
98
+ };
99
+ fit();
100
+ return watchSize([b, el], fit);
101
+ }, [fold != null, tight]);
102
+ /* the tap opens it INSIDE the finger's own event (flushSync), so the cursor goes in while the phone still lets a keyboard come up */
103
+ const unfold = () => {
104
+ flushSync(() => ask(true));
105
+ ref.current?.focus();
106
+ };
107
+ const refold = () => { ask(false); btn.current?.focus(); };
77
108
  useEffect(() => {
78
109
  if (wrong) {
79
110
  ref.current?.focus();
@@ -81,8 +112,16 @@ export function Field({ icon, action, label, error, format: formatProp, digits:
81
112
  }
82
113
  // eslint-disable-next-line react-hooks/exhaustive-deps -- when the app's error comes or changes
83
114
  }, [error]);
84
- const onBlurField = (e) => { onBlur?.(e); if (!checked)
85
- return; const w = verdict(false); setBad(w != null); say(w); };
115
+ const onBlurField = (e) => {
116
+ onBlur?.(e);
117
+ if (fold != null && out && !e.currentTarget.value && !box.current?.contains(e.relatedTarget))
118
+ ask(false); // left empty: back into its button
119
+ if (!checked)
120
+ return;
121
+ const w = verdict(false);
122
+ setBad(w != null);
123
+ say(w);
124
+ };
86
125
  const onInputField = (e) => { onInput?.(e); if (bad && verdict(false) == null) {
87
126
  setBad(false);
88
127
  say(null);
@@ -102,6 +141,16 @@ export function Field({ icon, action, label, error, format: formatProp, digits:
102
141
  }
103
142
  onChange?.(e);
104
143
  };
105
- const shared = { ref, 'aria-label': label, 'aria-invalid': wrong || undefined, ...input, ...cursor, onBlur: onBlurField, onInput: onInputField, onChange: onChangeField };
106
- return (_jsxs("label", { className: cx('field', lines && 'field--rows', action != null && 'field--action', wrong && 'field--error', className), style: style, children: [icon && _jsx(Icon, { name: icon, size: "sm" }), lines ? _jsx("textarea", { rows: rows, ...shared }) : _jsx("input", { ...shared }), action] }));
144
+ const onKeyDownField = (e) => {
145
+ onKeyDown?.(e);
146
+ if (fold != null && e.key === 'Escape' && !e.defaultPrevented) {
147
+ e.preventDefault();
148
+ refold();
149
+ }
150
+ };
151
+ const shared = { ref, 'aria-label': label, 'aria-invalid': wrong || undefined, ...input, ...cursor, onBlur: onBlurField, onInput: onInputField, onChange: onChangeField, onKeyDown: onKeyDownField };
152
+ const field = (_jsxs("label", { className: cx('field', lines && 'field--rows', action != null && 'field--action', wrong && 'field--error', fold == null && className), style: fold == null ? style : undefined, inert: fold != null && !out ? true : undefined, children: [icon && _jsx(Icon, { name: icon, size: "sm" }), lines ? _jsx("textarea", { rows: rows, ...shared }) : _jsx("input", { ...shared }), action] }));
153
+ if (fold == null)
154
+ return field;
155
+ return (_jsxs("div", { ref: box, className: cx('field-fold', out && 'field-fold--open', tight && 'field-fold--tight', className), style: style, children: [_jsxs("button", { ref: btn, type: "button", className: "btn field-fold__btn", "aria-expanded": out, inert: out || undefined, onClick: unfold, children: [icon && _jsx(Icon, { name: icon, size: "xs" }), _jsx("span", { className: "field-fold__words", children: fold })] }), field] }));
107
156
  }
@@ -20,6 +20,13 @@ export interface MessageBarProps extends Omit<ComponentProps<'textarea'>, 'value
20
20
  people?: MentionPerson[];
21
21
  /** a person was picked from the `@` list — the words already hold their name; who to tell is the app's */
22
22
  onMention?: (person: MentionPerson) => void;
23
+ /** a REPLY-TO QUOTE over the box: the line being answered ("Noi: thank you for…"), cut at one line, a rule at its start. CONTROLLED: shown while
24
+ * the app passes it; the app drops it (after a send, or on `onQuoteClose`). Knobs `--message-bar-quote-ink`, `--message-bar-quote-rule-ink` */
25
+ quote?: ReactNode;
26
+ /** the quote's ✕ was pressed: the member drops the reply-to — the app stops passing `quote`. Without it the quote has no ✕ */
27
+ onQuoteClose?: () => void;
28
+ /** the quote's ✕'s accessible name ("Cancel the reply") — the app's word, cardds has none; needed with `onQuoteClose` */
29
+ quoteCloseLabel?: string;
23
30
  /** classes for the bar, not the textarea */
24
31
  className?: string;
25
32
  /** inline style for the bar, not the textarea */
@@ -35,6 +42,6 @@ export interface MessageBarProps extends Omit<ComponentProps<'textarea'>, 'value
35
42
  * keyboard, and the body stops above it however tall it grows. Controlled like an
36
43
  * input: `value` + `onValueChange`, or `defaultValue`. `people` turns on naming with `@` (a comment that names a neighbour): the
37
44
  * matching names are listed above the box, a pick writes `@name ` and reports it to `onMention`; a written name is marked and a
38
- * backspace takes it whole.
45
+ * backspace takes it whole. `quote` is a reply-to line over the box (the message being answered), with a ✕ (`onQuoteClose`) — the app shows and drops it.
39
46
  */
40
- export declare function MessageBar({ value, defaultValue, onValueChange, onSend, sendLabel, sendIcon, lead, people, onMention, className, style, rows, ref, onKeyDown, onSelect, onScroll, onBlur, ...textarea }: MessageBarProps): import("react").JSX.Element;
47
+ export declare function MessageBar({ value, defaultValue, onValueChange, onSend, sendLabel, sendIcon, lead, people, onMention, quote, onQuoteClose, quoteCloseLabel, className, style, rows, ref, onKeyDown, onSelect, onScroll, onBlur, ...textarea }: MessageBarProps): import("react").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useRef } from 'react';
3
3
  import { cx } from '../cx.js';
4
- import { setRefs, useControlled } from '../state.js';
4
+ import { setRefs, useControlled, warnOnce } from '../state.js';
5
5
  import { useMention } from './mention.js';
6
6
  import { IconBtn } from '../actions/IconBtn.js';
7
7
  /**
@@ -14,21 +14,23 @@ import { IconBtn } from '../actions/IconBtn.js';
14
14
  * keyboard, and the body stops above it however tall it grows. Controlled like an
15
15
  * input: `value` + `onValueChange`, or `defaultValue`. `people` turns on naming with `@` (a comment that names a neighbour): the
16
16
  * matching names are listed above the box, a pick writes `@name ` and reports it to `onMention`; a written name is marked and a
17
- * backspace takes it whole.
17
+ * backspace takes it whole. `quote` is a reply-to line over the box (the message being answered), with a ✕ (`onQuoteClose`) — the app shows and drops it.
18
18
  */
19
- export function MessageBar({ value, defaultValue = '', onValueChange, onSend, sendLabel, sendIcon = 'arrow-up', lead, people, onMention, className, style, rows = 1, ref, onKeyDown, onSelect, onScroll, onBlur, ...textarea }) {
19
+ export function MessageBar({ value, defaultValue = '', onValueChange, onSend, sendLabel, sendIcon = 'arrow-up', lead, people, onMention, quote, onQuoteClose, quoteCloseLabel, className, style, rows = 1, ref, onKeyDown, onSelect, onScroll, onBlur, ...textarea }) {
20
20
  const [shown, request] = useControlled(value, defaultValue, onValueChange);
21
21
  const box = useRef(null);
22
22
  const under = useRef(null);
23
23
  const mention = useMention(box, shown, people, onMention);
24
24
  const empty = !shown.trim();
25
+ if (onQuoteClose && !quoteCloseLabel)
26
+ warnOnce('message-bar-quote-label', 'cardds MessageBar: `onQuoteClose` without `quoteCloseLabel` — the quote\'s ✕ has no name');
25
27
  const send = () => {
26
28
  if (empty)
27
29
  return;
28
30
  onSend?.(shown);
29
31
  request('');
30
32
  };
31
- return (_jsxs("div", { className: cx('message-bar', className), style: style, children: [mention.list, lead, _jsxs("div", { className: "message-bar__box", "data-value": shown, children: [mention.under && _jsx("div", { ref: under, className: "message-bar__input mention-under", "aria-hidden": "true", children: mention.under }), _jsx("textarea", { ref: setRefs(box, ref), className: "message-bar__input", rows: rows, ...textarea, value: shown, onChange: (e) => request(e.currentTarget.value), onKeyDown: (e) => { onKeyDown?.(e); if (!e.defaultPrevented)
33
+ return (_jsxs("div", { className: cx('message-bar', className), style: style, children: [mention.list, quote != null && (_jsxs("div", { className: "message-bar__quote", children: [_jsx("span", { className: "message-bar__quote-words", children: quote }), onQuoteClose && _jsx(IconBtn, { sm: true, icon: "x", label: quoteCloseLabel ?? '', onPointerDown: (e) => e.preventDefault(), onClick: onQuoteClose })] })), lead, _jsxs("div", { className: "message-bar__box", "data-value": shown, children: [mention.under && _jsx("div", { ref: under, className: "message-bar__input mention-under", "aria-hidden": "true", children: mention.under }), _jsx("textarea", { ref: setRefs(box, ref), className: "message-bar__input", rows: rows, ...textarea, value: shown, onChange: (e) => request(e.currentTarget.value), onKeyDown: (e) => { onKeyDown?.(e); if (!e.defaultPrevented)
32
34
  mention.onKeyDown(e); }, onSelect: (e) => { onSelect?.(e); mention.look(); }, onBlur: (e) => { onBlur?.(e); mention.leave(); }, onScroll: (e) => { onScroll?.(e); if (under.current)
33
35
  under.current.scrollTop = e.currentTarget.scrollTop; } })] }), _jsx(IconBtn, { invert: true, icon: sendIcon, label: sendLabel, disabled: empty, onPointerDown: (e) => e.preventDefault(), onClick: send })] }));
34
36
  }
package/dist/index.d.ts CHANGED
@@ -43,6 +43,7 @@ export * from './actions/BtnGroup.js';
43
43
  export * from './actions/Fab.js';
44
44
  export * from './actions/BtnRow.js';
45
45
  export * from './actions/Link.js';
46
+ export * from './actions/LinkBlock.js';
46
47
  export * from './actions/Countdown.js';
47
48
  export * from './forms/Field.js';
48
49
  export * from './forms/FileBtn.js';
package/dist/index.js CHANGED
@@ -47,6 +47,7 @@ export * from './actions/BtnGroup.js';
47
47
  export * from './actions/Fab.js';
48
48
  export * from './actions/BtnRow.js';
49
49
  export * from './actions/Link.js';
50
+ export * from './actions/LinkBlock.js';
50
51
  export * from './actions/Countdown.js';
51
52
  export * from './forms/Field.js';
52
53
  export * from './forms/FileBtn.js';