@usableapp/cardds 0.7.142 → 0.7.144
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 +21 -0
- package/css/card.css +1 -0
- package/css/forms.css +54 -0
- package/css/sticky.css +4 -3
- package/dist/cardds.css +59 -3
- package/dist/catalog.json +1 -1
- package/dist/forms/MessageBar.d.ts +31 -0
- package/dist/forms/MessageBar.js +23 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/scaffold/Screen.d.ts +1 -1
- package/dist/scaffold/Screen.js +1 -1
- package/docs/reference.md +8 -1
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
import type { IconName } from '../type/Icon.js';
|
|
3
|
+
export interface MessageBarProps extends Omit<ComponentProps<'textarea'>, 'value' | 'defaultValue' | 'onChange' | 'className' | 'style' | 'children'> {
|
|
4
|
+
/** CONTROLLED: the words in the box — with `onValueChange`; or `defaultValue` */
|
|
5
|
+
value?: string;
|
|
6
|
+
/** UNCONTROLLED: the words it starts with (default empty) */
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
/** it asks: the member typed — and, after a send, asks for the box to be empty again ('') */
|
|
9
|
+
onValueChange?: (value: string) => void;
|
|
10
|
+
/** the send button was pressed with words in the box: the words, as typed. What sending does is the app's */
|
|
11
|
+
onSend?: (value: string) => void;
|
|
12
|
+
/** the send button's accessible name ("Send", "ส่ง") — the app's word, cardds has none */
|
|
13
|
+
sendLabel: string;
|
|
14
|
+
/** the send button's icon (default `arrow-up`) */
|
|
15
|
+
sendIcon?: IconName;
|
|
16
|
+
/** what stands before the box: an extra action (an `IconBtn` — attach, a photo) */
|
|
17
|
+
lead?: ReactNode;
|
|
18
|
+
/** classes for the bar, not the textarea */
|
|
19
|
+
className?: string;
|
|
20
|
+
/** inline style for the bar, not the textarea */
|
|
21
|
+
style?: React.CSSProperties;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* MessageBar — the box a chat's message is typed in, at the foot of a conversation (a `Thread` of `Bubble`s): lead · the box · send.
|
|
25
|
+
* The box starts one line tall and grows with the words up to five lines (`--message-bar-input-max-h`), then scrolls. The send button
|
|
26
|
+
* (an `IconBtn invert`) is off while the box holds only blanks; pressing it hands the words to `onSend` and asks for an empty box, and
|
|
27
|
+
* the cursor stays in the box, so the keyboard stays up. The Screen's `bottom` (`<Screen fill bottom={<MessageBar…>}>`): a layer over
|
|
28
|
+
* the content's foot that rides above the keyboard (`--kb`), the conversation's last words scroll clear of it. Controlled like an
|
|
29
|
+
* input: `value` + `onValueChange`, or `defaultValue`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function MessageBar({ value, defaultValue, onValueChange, onSend, sendLabel, sendIcon, lead, className, style, rows, ...textarea }: MessageBarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from '../cx.js';
|
|
3
|
+
import { useControlled } from '../state.js';
|
|
4
|
+
import { IconBtn } from '../actions/IconBtn.js';
|
|
5
|
+
/**
|
|
6
|
+
* MessageBar — the box a chat's message is typed in, at the foot of a conversation (a `Thread` of `Bubble`s): lead · the box · send.
|
|
7
|
+
* The box starts one line tall and grows with the words up to five lines (`--message-bar-input-max-h`), then scrolls. The send button
|
|
8
|
+
* (an `IconBtn invert`) is off while the box holds only blanks; pressing it hands the words to `onSend` and asks for an empty box, and
|
|
9
|
+
* the cursor stays in the box, so the keyboard stays up. The Screen's `bottom` (`<Screen fill bottom={<MessageBar…>}>`): a layer over
|
|
10
|
+
* the content's foot that rides above the keyboard (`--kb`), the conversation's last words scroll clear of it. Controlled like an
|
|
11
|
+
* input: `value` + `onValueChange`, or `defaultValue`.
|
|
12
|
+
*/
|
|
13
|
+
export function MessageBar({ value, defaultValue = '', onValueChange, onSend, sendLabel, sendIcon = 'arrow-up', lead, className, style, rows = 1, ...textarea }) {
|
|
14
|
+
const [shown, request] = useControlled(value, defaultValue, onValueChange);
|
|
15
|
+
const empty = !shown.trim();
|
|
16
|
+
const send = () => {
|
|
17
|
+
if (empty)
|
|
18
|
+
return;
|
|
19
|
+
onSend?.(shown);
|
|
20
|
+
request('');
|
|
21
|
+
};
|
|
22
|
+
return (_jsxs("div", { className: cx('message-bar', className), style: style, children: [lead, _jsx("div", { className: "message-bar__box", "data-value": shown, children: _jsx("textarea", { className: "message-bar__input", rows: rows, ...textarea, value: shown, onChange: (e) => request(e.currentTarget.value) }) }), _jsx(IconBtn, { invert: true, icon: sendIcon, label: sendLabel, disabled: empty, onPointerDown: (e) => e.preventDefault(), onClick: send })] }));
|
|
23
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export * from './forms/FileBtn.js';
|
|
|
49
49
|
export * from './forms/AddRow.js';
|
|
50
50
|
export * from './forms/Pin.js';
|
|
51
51
|
export * from './forms/Composer.js';
|
|
52
|
+
export * from './forms/MessageBar.js';
|
|
52
53
|
export * from './choice/Check.js';
|
|
53
54
|
export * from './choice/DayStrip.js';
|
|
54
55
|
export * from './choice/Calendar.js';
|
package/dist/index.js
CHANGED
|
@@ -53,6 +53,7 @@ export * from './forms/FileBtn.js';
|
|
|
53
53
|
export * from './forms/AddRow.js';
|
|
54
54
|
export * from './forms/Pin.js';
|
|
55
55
|
export * from './forms/Composer.js';
|
|
56
|
+
export * from './forms/MessageBar.js';
|
|
56
57
|
export * from './choice/Check.js';
|
|
57
58
|
export * from './choice/DayStrip.js';
|
|
58
59
|
export * from './choice/Calendar.js';
|
|
@@ -9,7 +9,7 @@ export interface ScreenProps extends ComponentProps<'div'> {
|
|
|
9
9
|
as?: 'div' | 'main' | 'section';
|
|
10
10
|
/** TOP: a `TopBar` / `AppBar`, or `"lead"` — no bar, the content starts `--screen-lead` (15% of the screen) down */
|
|
11
11
|
top?: ReactNode | 'lead';
|
|
12
|
-
/** BOTTOM: an `ActionBar` (or a `FloatBar`) — a LAYER over the content's foot, as tall as its rows need.
|
|
12
|
+
/** BOTTOM: an `ActionBar` (or a `FloatBar`, or a chat's `MessageBar`) — a LAYER over the content's foot, as tall as its rows need.
|
|
13
13
|
* Never with a `Sheet` in the content: a sheet finishes on its own foot (warns once). */
|
|
14
14
|
bottom?: ReactNode;
|
|
15
15
|
/** `false` while the app does not yet know WHICH screen this is (signed in or not, a member with or without a request…):
|
package/dist/scaffold/Screen.js
CHANGED
|
@@ -21,7 +21,7 @@ export function Screen({ fill, palette, as = 'div', top, bottom, ready = true, c
|
|
|
21
21
|
/* the BOTTOM layer's height, published on the screen as --bottom-h (Lh 2026-09-23): the walk's pages end with that much room
|
|
22
22
|
more, so every last word scrolls up clear of the layer. Measured, because the layer is as tall as its rows and the text size. */
|
|
23
23
|
useEffect(() => {
|
|
24
|
-
const el = own.current, bar = el?.querySelector(':scope > .action-bar');
|
|
24
|
+
const el = own.current, bar = el?.querySelector(':scope > :is(.action-bar, .message-bar)');
|
|
25
25
|
if (!el || !bar) {
|
|
26
26
|
el?.style.removeProperty('--bottom-h');
|
|
27
27
|
return;
|
package/docs/reference.md
CHANGED
|
@@ -328,7 +328,7 @@ of `Screen`:
|
|
|
328
328
|
|---|---|---|
|
|
329
329
|
| **top** | `top` | `TopBar` · `AppBar` · `"lead"` (no bar: the content starts `--screen-lead`, 15% of the screen, down) |
|
|
330
330
|
| **content** | children | a `Step` (`Pages` · `Page` · `Page` + `Sheet`) · `Centre` · `SheetStack` … |
|
|
331
|
-
| **bottom** | `bottom` | `ActionBar` (rows: `controls` · the one `cta` row — the pager bar ← → or one wide button · a `ctaLink`) · `FloatBar` · nothing |
|
|
331
|
+
| **bottom** | `bottom` | `ActionBar` (rows: `controls` · the one `cta` row — the pager bar ← → or one wide button · a `ctaLink`) · `FloatBar` · `MessageBar` (a chat) · nothing |
|
|
332
332
|
|
|
333
333
|
```tsx
|
|
334
334
|
<Screen fill top="lead" bottom={<ActionBar variant="pager">…</ActionBar>}>
|
|
@@ -341,6 +341,13 @@ of `Screen`:
|
|
|
341
341
|
covers what is under it — on purpose, nothing is added to the content to make room. The keyboard lifts the layer (`--kb`).
|
|
342
342
|
- **The bar is INSIDE the screen** — `bottom`, never a sibling after `</Screen>`, never pinned with a hand-set `position`.
|
|
343
343
|
A `FloatBar` in `bottom` floats the same way.
|
|
344
|
+
- **A chat's bottom is its `MessageBar`** — the box the member types a message in, under a `Thread` of `Bubble`s in a
|
|
345
|
+
`Step` › `Page` (`<Screen fill top={…} bottom={<MessageBar…>}>`). lead (an extra action, an `IconBtn`) · the box · an
|
|
346
|
+
`IconBtn invert` send that is off while the box holds only blanks. The box starts one line tall and grows with the words up
|
|
347
|
+
to five lines (`--message-bar-input-max-h`), then scrolls. Controlled like an input (`value` + `onValueChange`, or
|
|
348
|
+
`defaultValue`); `onSend(words)` hands them to the app, then the bar asks for an empty box; the cursor stays in the box, so
|
|
349
|
+
the keyboard stays up. It is a layer like the `ActionBar`: measured into `--bottom-h`, lifted by `--kb`. It is not the
|
|
350
|
+
`Composer` (the one big write-in on a sheet) and not a sheet's form: a message is sent from where it is read.
|
|
344
351
|
- **A screen with a `Sheet` has no bottom.** The sheet finishes on its own `Foot`; `Screen` warns once when both
|
|
345
352
|
are there.
|
|
346
353
|
- **Templates** are `Screen`s with the three parts filled (`Walkthrough` = top `lead` · content `Pages` · bottom
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usableapp/cardds",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.144",
|
|
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).",
|