@htmlbricks/hb-messages-send 0.71.35 → 0.71.36
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/README.md +108 -19
- package/manifest.json +5 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,33 +1,122 @@
|
|
|
1
1
|
# hb-messages-send
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Category:** messaging · **Tags:** messaging, chat
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
`hb-messages-send` is a message composer for chat-style UIs. Users type in a textarea, optionally attach files, toggle tag chips, and send with the send control or **Enter** (**Shift+Enter** inserts a newline). When the message is sent, the element dispatches a **`sendMessage`** custom event whose `detail` carries the current text, your optional **`id`**, the selected tag ids, and the staged files.
|
|
8
|
+
|
|
9
|
+
The UI is built with **Bulma 1.x** inside the shadow root. **Bootstrap Icons** are loaded from jsDelivr in the component head for attach, send, tag, maximize, and file-type icons.
|
|
10
|
+
|
|
11
|
+
## Behavior
|
|
12
|
+
|
|
13
|
+
- **Text:** Bound to the composer. The send button stays disabled until there is non-empty text **or** at least one attached file.
|
|
14
|
+
- **Send:** Click the send button, or press **Enter** without **Shift**. An empty composer with no files logs a console warning and does not dispatch.
|
|
15
|
+
- **Expandable (`expandable`):** When enabled, the textarea grows with content up to an internal cap; when that cap is reached, a **maximize / minimize** control appears so users can expand the writing area (400px height while maximized).
|
|
16
|
+
- **Files (`files`):** If you pass a `files` configuration object, a paperclip control appears. **`mode: "single"`** keeps at most one file; **`mode: "multiple"`** allows many. Images get a thumbnail preview; other types show an icon by MIME type. Users can remove attachments before sending.
|
|
17
|
+
- **Tags (`tags`):** Optional chip buttons built from your definitions. Each tag must have an **`id`** (used in the event payload). **`icon`** is the Bootstrap Icons glyph name **without** the `bi-` prefix (the markup uses `bi bi-{icon}`). **`label`** is shown on the chip. **`color`** is optional; if omitted, the component picks a color for that chip.
|
|
18
|
+
|
|
19
|
+
## Styling (Bulma and CSS variables)
|
|
20
|
+
|
|
21
|
+
The component forwards Bulma’s light theme and CSS variables on `:host`. Prefer **`--bulma-*`** (and the component **`--tag-color`**) from the host page to match your site theme. See [Bulma CSS variables](https://bulma.io/documentation/features/css-variables/).
|
|
22
|
+
|
|
23
|
+
| Variable | Role |
|
|
24
|
+
|----------|------|
|
|
25
|
+
| `--bulma-primary` | Send button background. |
|
|
26
|
+
| `--bulma-primary-invert` | Icon color on the send button. |
|
|
27
|
+
| `--bulma-link` | Focus ring, file-attach accent, maximize control. |
|
|
28
|
+
| `--bulma-border` | Panel and file card borders. |
|
|
29
|
+
| `--bulma-text` | Default input and label color for readable text on the composer surface. |
|
|
30
|
+
| `--bulma-text-weak` | Muted text and disabled send state. |
|
|
31
|
+
| `--bulma-scheme-main` | Composer surface background. |
|
|
32
|
+
| `--bulma-scheme-main-bis` | File strip and toolbar background. |
|
|
33
|
+
| `--tag-color` | Accent for tag and file controls (per-tag overrides use inline `--tag-color` from each tag’s `color` or a fallback palette). |
|
|
34
|
+
|
|
35
|
+
### CSS parts
|
|
36
|
+
|
|
37
|
+
None.
|
|
38
|
+
|
|
39
|
+
### HTML slots
|
|
40
|
+
|
|
41
|
+
None.
|
|
42
|
+
|
|
43
|
+
## Custom element
|
|
44
|
+
|
|
45
|
+
`hb-messages-send`
|
|
46
|
+
|
|
47
|
+
## Attributes and properties (HTML consumers)
|
|
48
|
+
|
|
49
|
+
Web component **attributes** are strings. Use **`yes`** / **`no`** for booleans where noted (the implementation also treats the string **`true`** as enabled for **`expandable`**). Pass **objects and arrays as JSON strings** (e.g. `tags`, `files`).
|
|
50
|
+
|
|
51
|
+
| Name | Required | Description |
|
|
52
|
+
|------|----------|-------------|
|
|
53
|
+
| `id` | No | String echoed back on **`sendMessage`** so you can correlate the composer instance (e.g. thread or channel id). |
|
|
54
|
+
| `text` | No | Initial / current message text. |
|
|
55
|
+
| `expandable` | No | **`yes`** / **`no`** (or **`true`** / other) — taller minimum textarea, auto-grow, and maximize affordance when content hits the cap. |
|
|
56
|
+
| `tags` | No | JSON array of `{ id: string; label?: string; icon?: string; color?: string }`. **`id`** is required for selection; **`icon`** is a Bootstrap Icons name without the `bi-` prefix. |
|
|
57
|
+
| `files` | No | JSON object `{ "mode": "single" \| "multiple" }`. When set, the file attach control is shown and enforces single vs multi selection. |
|
|
58
|
+
|
|
59
|
+
The authoring **`Component`** type may list **`style`** for TypeScript wrappers; the inner UI is themed with **CSS variables** on `:host`, not that prop.
|
|
60
|
+
|
|
61
|
+
## Events
|
|
62
|
+
|
|
63
|
+
| Name | `detail` shape |
|
|
64
|
+
|------|----------------|
|
|
65
|
+
| `sendMessage` | **`text`:** `string` — composer text. **`id`:** `string` — value of the `id` prop. **`tags`:** `string[]` — ids of tags the user toggled on. **`files`:** array of staged items: each entry includes **`id`**, **`name`**, **`mimetype`**, **`fileSize`**, and **`content`** (`File` from the browser), matching what the composer staged before send. |
|
|
66
|
+
|
|
67
|
+
> **Note:** The repo’s `Events` typing may describe **`files`** as `File[]`. At runtime the event carries the internal staged objects above; use **`detail.files.map((f) => f.content)`** (or equivalent) when you need plain `File` instances.
|
|
68
|
+
|
|
69
|
+
## TypeScript (authoring / wrappers)
|
|
8
70
|
|
|
9
71
|
```typescript
|
|
10
72
|
export type Component = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
73
|
+
id?: string;
|
|
74
|
+
style?: string;
|
|
75
|
+
text?: string;
|
|
76
|
+
expandable?: boolean;
|
|
77
|
+
tags?: {
|
|
78
|
+
label?: string;
|
|
79
|
+
icon?: string;
|
|
80
|
+
id: string;
|
|
81
|
+
color?: string;
|
|
82
|
+
}[];
|
|
83
|
+
files?: {
|
|
84
|
+
mode: "single" | "multiple";
|
|
85
|
+
};
|
|
24
86
|
};
|
|
25
87
|
|
|
26
88
|
export type Events = {
|
|
27
|
-
|
|
89
|
+
sendMessage: { text?: string; id: string; tags: string[]; files: File[] };
|
|
28
90
|
};
|
|
29
91
|
```
|
|
30
92
|
|
|
31
|
-
|
|
93
|
+
## Examples
|
|
94
|
+
|
|
95
|
+
### Minimal
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<hb-messages-send expandable="yes"></hb-messages-send>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Tags, single file, and initial text
|
|
32
102
|
|
|
33
|
-
|
|
103
|
+
```html
|
|
104
|
+
<hb-messages-send
|
|
105
|
+
id="thread-42"
|
|
106
|
+
text="Reply here…"
|
|
107
|
+
expandable="yes"
|
|
108
|
+
tags='[{"id":"idea","label":"Idea","icon":"lightbulb"},{"id":"bug","label":"Bug","icon":"bug-fill"}]'
|
|
109
|
+
files='{"mode":"single"}'
|
|
110
|
+
></hb-messages-send>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Listen for sends (vanilla JS)
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
const el = document.querySelector("hb-messages-send");
|
|
117
|
+
el.addEventListener("sendMessage", (e) => {
|
|
118
|
+
const { text, id, tags, files } = e.detail;
|
|
119
|
+
const blobs = files.map((f) => f.content);
|
|
120
|
+
// Upload blobs, append to thread, clear composer via property if needed, etc.
|
|
121
|
+
});
|
|
122
|
+
```
|
package/manifest.json
CHANGED
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
"name": "--bulma-text",
|
|
191
191
|
"valueType": "color",
|
|
192
192
|
"defaultValue": "#363636",
|
|
193
|
-
"description": "
|
|
193
|
+
"description": "Controls the default composer input and label color so typed messages and helper copy remain readable on your chosen panel background."
|
|
194
194
|
},
|
|
195
195
|
{
|
|
196
196
|
"name": "--bulma-text-weak",
|
|
@@ -213,16 +213,11 @@
|
|
|
213
213
|
{
|
|
214
214
|
"name": "--tag-color",
|
|
215
215
|
"valueType": "color",
|
|
216
|
-
"defaultValue": "",
|
|
217
|
-
"description": "Per-tag and file-button border/fill (
|
|
216
|
+
"defaultValue": "#485fc7",
|
|
217
|
+
"description": "Per-tag and file-button border/fill (defaults from `--bulma-link` inline in markup)."
|
|
218
218
|
}
|
|
219
219
|
],
|
|
220
|
-
"parts": [
|
|
221
|
-
{
|
|
222
|
-
"name": "testpart",
|
|
223
|
-
"description": "test css part on 2 div tag"
|
|
224
|
-
}
|
|
225
|
-
]
|
|
220
|
+
"parts": []
|
|
226
221
|
},
|
|
227
222
|
"contributors": [],
|
|
228
223
|
"htmlSlots": [],
|
|
@@ -303,5 +298,5 @@
|
|
|
303
298
|
"size": {},
|
|
304
299
|
"iifePath": "main.iife.js",
|
|
305
300
|
"repoName": "@htmlbricks/hb-messages-send",
|
|
306
|
-
"version": "0.71.
|
|
301
|
+
"version": "0.71.36"
|
|
307
302
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlbricks/hb-messages-send",
|
|
3
|
-
"version": "0.71.
|
|
3
|
+
"version": "0.71.36",
|
|
4
4
|
"contributors": [],
|
|
5
5
|
"description": "Message composer with auto-growing textarea (optional `expandable` and maximize control), Enter-to-send, file attachments with previews (`files.mode` single or multiple), and optional `tags` as toggleable chips. Dispatches `sendMessage` with `text`, selected `tags`, and staged `files` when the user sends.",
|
|
6
6
|
"licenses": [
|