chat 4.13.0 → 4.13.2
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 +19 -31
- package/dist/{chunk-WKJEG4FE.js → chunk-THM4ACIE.js} +12 -4
- package/dist/chunk-THM4ACIE.js.map +1 -0
- package/dist/index.d.ts +409 -415
- package/dist/index.js +63 -29
- package/dist/index.js.map +1 -1
- package/dist/{jsx-runtime-COVsDskT.d.ts → jsx-runtime-Bdt1Dwzf.d.ts} +71 -71
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/docs/actions.mdx +98 -0
- package/docs/adapters/discord.mdx +217 -0
- package/docs/adapters/gchat.mdx +232 -0
- package/docs/adapters/github.mdx +225 -0
- package/docs/adapters/index.mdx +110 -0
- package/docs/adapters/linear.mdx +207 -0
- package/docs/adapters/meta.json +12 -0
- package/docs/adapters/slack.mdx +293 -0
- package/docs/adapters/teams.mdx +225 -0
- package/docs/api/cards.mdx +217 -0
- package/docs/api/channel.mdx +176 -0
- package/docs/api/chat.mdx +469 -0
- package/docs/api/index.mdx +29 -0
- package/docs/api/markdown.mdx +235 -0
- package/docs/api/message.mdx +163 -0
- package/docs/api/meta.json +14 -0
- package/docs/api/modals.mdx +222 -0
- package/docs/api/postable-message.mdx +166 -0
- package/docs/api/thread.mdx +186 -0
- package/docs/cards.mdx +213 -0
- package/docs/direct-messages.mdx +56 -0
- package/docs/emoji.mdx +77 -0
- package/docs/ephemeral-messages.mdx +77 -0
- package/docs/error-handling.mdx +147 -0
- package/docs/files.mdx +77 -0
- package/docs/getting-started.mdx +12 -0
- package/docs/guides/code-review-hono.mdx +248 -0
- package/docs/guides/discord-nuxt.mdx +237 -0
- package/docs/guides/meta.json +4 -0
- package/docs/guides/slack-nextjs.mdx +245 -0
- package/docs/index.mdx +92 -0
- package/docs/meta.json +20 -0
- package/docs/modals.mdx +208 -0
- package/docs/posting-messages.mdx +177 -0
- package/docs/slash-commands.mdx +110 -0
- package/docs/state/index.mdx +31 -0
- package/docs/state/ioredis.mdx +81 -0
- package/docs/state/memory.mdx +52 -0
- package/docs/state/meta.json +9 -0
- package/docs/state/redis.mdx +93 -0
- package/docs/streaming.mdx +99 -0
- package/docs/usage.mdx +338 -0
- package/package.json +10 -10
- package/dist/chunk-WKJEG4FE.js.map +0 -1
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Markdown
|
|
3
|
+
description: AST builder functions and utilities for programmatic message formatting.
|
|
4
|
+
type: reference
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
The SDK uses [mdast](https://github.com/syntax-tree/mdast) (Markdown AST) as the canonical format for message formatting. Each adapter converts the AST to the platform's native format.
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import {
|
|
11
|
+
root, paragraph, text, strong, emphasis, strikethrough,
|
|
12
|
+
inlineCode, codeBlock, link, blockquote,
|
|
13
|
+
parseMarkdown, stringifyMarkdown, toPlainText, walkAst,
|
|
14
|
+
} from "chat";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Node builders
|
|
18
|
+
|
|
19
|
+
### root
|
|
20
|
+
|
|
21
|
+
Root node — the required top-level wrapper for an AST.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
root([
|
|
25
|
+
paragraph([text("Hello, world!")]),
|
|
26
|
+
])
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
<TypeTable
|
|
30
|
+
type={{
|
|
31
|
+
children: {
|
|
32
|
+
description: 'Top-level content nodes (paragraphs, code blocks, blockquotes, lists).',
|
|
33
|
+
type: 'Content[]',
|
|
34
|
+
},
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
### paragraph
|
|
39
|
+
|
|
40
|
+
A paragraph block.
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
paragraph([text("Hello "), strong([text("world")])])
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### text
|
|
47
|
+
|
|
48
|
+
Plain text node.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
text("Hello, world!")
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### strong
|
|
55
|
+
|
|
56
|
+
**Bold** text.
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
strong([text("important")])
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### emphasis
|
|
63
|
+
|
|
64
|
+
_Italic_ text.
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
emphasis([text("emphasized")])
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### strikethrough
|
|
71
|
+
|
|
72
|
+
~~Strikethrough~~ text.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
strikethrough([text("removed")])
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### inlineCode
|
|
79
|
+
|
|
80
|
+
`Inline code` span.
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
inlineCode("const x = 1")
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### codeBlock
|
|
87
|
+
|
|
88
|
+
Fenced code block with optional language.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
codeBlock("const x = 1;", "typescript")
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
<TypeTable
|
|
95
|
+
type={{
|
|
96
|
+
value: {
|
|
97
|
+
description: 'Code content.',
|
|
98
|
+
type: 'string',
|
|
99
|
+
},
|
|
100
|
+
lang: {
|
|
101
|
+
description: 'Language identifier for syntax highlighting.',
|
|
102
|
+
type: 'string | undefined',
|
|
103
|
+
},
|
|
104
|
+
}}
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
### link
|
|
108
|
+
|
|
109
|
+
Hyperlink.
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
link("https://example.com", [text("click here")])
|
|
113
|
+
link("https://example.com", [text("click here")], "tooltip title")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
<TypeTable
|
|
117
|
+
type={{
|
|
118
|
+
url: {
|
|
119
|
+
description: 'Link URL.',
|
|
120
|
+
type: 'string',
|
|
121
|
+
},
|
|
122
|
+
children: {
|
|
123
|
+
description: 'Link text content.',
|
|
124
|
+
type: 'Content[]',
|
|
125
|
+
},
|
|
126
|
+
title: {
|
|
127
|
+
description: 'Optional tooltip text.',
|
|
128
|
+
type: 'string | undefined',
|
|
129
|
+
},
|
|
130
|
+
}}
|
|
131
|
+
/>
|
|
132
|
+
|
|
133
|
+
### blockquote
|
|
134
|
+
|
|
135
|
+
Block quotation.
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
blockquote([paragraph([text("Quoted text")])])
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Parsing and stringifying
|
|
142
|
+
|
|
143
|
+
### parseMarkdown
|
|
144
|
+
|
|
145
|
+
Parse a markdown string into an mdast AST.
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
const ast = parseMarkdown("**Hello** world");
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### stringifyMarkdown
|
|
152
|
+
|
|
153
|
+
Convert an mdast AST back to a markdown string.
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
const md = stringifyMarkdown(ast); // "**Hello** world"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### toPlainText
|
|
160
|
+
|
|
161
|
+
Strip all formatting and return plain text.
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
const plain = toPlainText(ast); // "Hello world"
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### markdownToPlainText
|
|
168
|
+
|
|
169
|
+
Shorthand for parsing markdown and extracting plain text.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
const plain = markdownToPlainText("**Hello** world"); // "Hello world"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## AST utilities
|
|
176
|
+
|
|
177
|
+
### walkAst
|
|
178
|
+
|
|
179
|
+
Transform an AST by visiting each node. Return a new value to replace the node, or `undefined` to keep it unchanged.
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
const transformed = walkAst(ast, (node) => {
|
|
183
|
+
if (isStrongNode(node)) {
|
|
184
|
+
return emphasis(getNodeChildren(node));
|
|
185
|
+
}
|
|
186
|
+
return undefined;
|
|
187
|
+
});
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Type guards
|
|
191
|
+
|
|
192
|
+
Functions for checking node types:
|
|
193
|
+
|
|
194
|
+
| Guard | Matches |
|
|
195
|
+
|-------|---------|
|
|
196
|
+
| `isTextNode(node)` | Plain text |
|
|
197
|
+
| `isParagraphNode(node)` | Paragraph |
|
|
198
|
+
| `isStrongNode(node)` | Bold |
|
|
199
|
+
| `isEmphasisNode(node)` | Italic |
|
|
200
|
+
| `isDeleteNode(node)` | Strikethrough |
|
|
201
|
+
| `isInlineCodeNode(node)` | Inline code |
|
|
202
|
+
| `isCodeNode(node)` | Code block |
|
|
203
|
+
| `isLinkNode(node)` | Link |
|
|
204
|
+
| `isBlockquoteNode(node)` | Blockquote |
|
|
205
|
+
| `isListNode(node)` | List |
|
|
206
|
+
| `isListItemNode(node)` | List item |
|
|
207
|
+
|
|
208
|
+
### getNodeChildren / getNodeValue
|
|
209
|
+
|
|
210
|
+
Safely access node properties without type narrowing.
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
const children = getNodeChildren(node); // Content[] | undefined
|
|
214
|
+
const value = getNodeValue(node); // string | undefined
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Platform formatting
|
|
218
|
+
|
|
219
|
+
The SDK uses mdast as the canonical format and each adapter converts it to the platform's native syntax. You write standard markdown and the SDK handles the translation — but it helps to know how each platform renders common formatting.
|
|
220
|
+
|
|
221
|
+
| Feature | Slack | Teams | Google Chat |
|
|
222
|
+
|---------|-------|-------|-------------|
|
|
223
|
+
| Bold | `*text*` | `**text**` | `*text*` |
|
|
224
|
+
| Italic | `_text_` | `_text_` | `_text_` |
|
|
225
|
+
| Strikethrough | `~text~` | `~~text~~` | `~text~` |
|
|
226
|
+
| Code | `` `code` `` | `` `code` `` | `` `code` `` |
|
|
227
|
+
| Code blocks | ```` ``` ```` | ```` ``` ```` | ```` ``` ```` |
|
|
228
|
+
| Links | `<url\|text>` | `[text](url)` | `[text](url)` |
|
|
229
|
+
| Lists | Supported | Supported | Supported |
|
|
230
|
+
| Blockquotes | `>` | `>` | Simulated with `>` prefix |
|
|
231
|
+
| Mentions | `<@USER>` | `<at>name</at>` | `<users/{id}>` |
|
|
232
|
+
|
|
233
|
+
<Callout type="info">
|
|
234
|
+
You don't need to worry about these differences when using the SDK — the AST builders and `parseMarkdown` handle conversion automatically. This table is useful if you're working with `raw` platform payloads or debugging formatting issues.
|
|
235
|
+
</Callout>
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Message
|
|
3
|
+
description: Normalized message format with text, AST, author, and metadata.
|
|
4
|
+
type: reference
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Incoming messages are normalized across all platforms into a consistent `Message` object.
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { Message } from "chat";
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Properties
|
|
14
|
+
|
|
15
|
+
<TypeTable
|
|
16
|
+
type={{
|
|
17
|
+
id: {
|
|
18
|
+
description: 'Platform-specific message ID.',
|
|
19
|
+
type: 'string',
|
|
20
|
+
},
|
|
21
|
+
threadId: {
|
|
22
|
+
description: 'Thread ID in adapter:channel:thread format.',
|
|
23
|
+
type: 'string',
|
|
24
|
+
},
|
|
25
|
+
text: {
|
|
26
|
+
description: 'Plain text content with all formatting stripped.',
|
|
27
|
+
type: 'string',
|
|
28
|
+
},
|
|
29
|
+
formatted: {
|
|
30
|
+
description: 'mdast AST representation — the canonical format for processing.',
|
|
31
|
+
type: 'Root',
|
|
32
|
+
},
|
|
33
|
+
raw: {
|
|
34
|
+
description: 'Original platform-specific payload (escape hatch).',
|
|
35
|
+
type: 'unknown',
|
|
36
|
+
},
|
|
37
|
+
author: {
|
|
38
|
+
description: 'Message author info.',
|
|
39
|
+
type: 'Author',
|
|
40
|
+
},
|
|
41
|
+
metadata: {
|
|
42
|
+
description: 'Timestamps and edit status.',
|
|
43
|
+
type: 'MessageMetadata',
|
|
44
|
+
},
|
|
45
|
+
attachments: {
|
|
46
|
+
description: 'File attachments.',
|
|
47
|
+
type: 'Attachment[]',
|
|
48
|
+
},
|
|
49
|
+
isMention: {
|
|
50
|
+
description: 'Whether the bot was @-mentioned in this message.',
|
|
51
|
+
type: 'boolean | undefined',
|
|
52
|
+
},
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
|
|
56
|
+
## Author
|
|
57
|
+
|
|
58
|
+
<TypeTable
|
|
59
|
+
type={{
|
|
60
|
+
userId: {
|
|
61
|
+
description: 'Platform-specific user ID.',
|
|
62
|
+
type: 'string',
|
|
63
|
+
},
|
|
64
|
+
userName: {
|
|
65
|
+
description: 'Username/handle for @-mentions.',
|
|
66
|
+
type: 'string',
|
|
67
|
+
},
|
|
68
|
+
fullName: {
|
|
69
|
+
description: 'Display name.',
|
|
70
|
+
type: 'string',
|
|
71
|
+
},
|
|
72
|
+
isBot: {
|
|
73
|
+
description: 'Whether the author is a bot.',
|
|
74
|
+
type: 'boolean | "unknown"',
|
|
75
|
+
},
|
|
76
|
+
isMe: {
|
|
77
|
+
description: 'Whether the author is this bot.',
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
},
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
82
|
+
|
|
83
|
+
### How `isMe` works
|
|
84
|
+
|
|
85
|
+
Each adapter detects whether a message came from the bot itself. The detection logic varies by platform:
|
|
86
|
+
|
|
87
|
+
| Platform | Detection method |
|
|
88
|
+
|----------|-----------------|
|
|
89
|
+
| Slack | Checks `event.user === botUserId` (primary), then `event.bot_id === botId` (for `bot_message` subtypes). Both IDs are fetched during initialization via `auth.test`. |
|
|
90
|
+
| Teams | Checks `activity.from.id === appId` (exact match), then checks if `activity.from.id` ends with `:{appId}` (handles `28:{appId}` format). |
|
|
91
|
+
| Google Chat | Checks `message.sender.name === botUserId`. The bot user ID is learned dynamically from message annotations when the bot is first @-mentioned. |
|
|
92
|
+
|
|
93
|
+
<Callout type="info">
|
|
94
|
+
All adapters return `false` if the bot ID isn't known yet. This is a safe default that prevents the bot from ignoring messages it should process.
|
|
95
|
+
</Callout>
|
|
96
|
+
|
|
97
|
+
## MessageMetadata
|
|
98
|
+
|
|
99
|
+
<TypeTable
|
|
100
|
+
type={{
|
|
101
|
+
dateSent: {
|
|
102
|
+
description: 'When the message was sent.',
|
|
103
|
+
type: 'Date',
|
|
104
|
+
},
|
|
105
|
+
edited: {
|
|
106
|
+
description: 'Whether the message has been edited.',
|
|
107
|
+
type: 'boolean',
|
|
108
|
+
},
|
|
109
|
+
editedAt: {
|
|
110
|
+
description: 'When the message was last edited.',
|
|
111
|
+
type: 'Date | undefined',
|
|
112
|
+
},
|
|
113
|
+
}}
|
|
114
|
+
/>
|
|
115
|
+
|
|
116
|
+
## Attachment
|
|
117
|
+
|
|
118
|
+
<TypeTable
|
|
119
|
+
type={{
|
|
120
|
+
type: {
|
|
121
|
+
description: 'Attachment type.',
|
|
122
|
+
type: '"image" | "file" | "video" | "audio"',
|
|
123
|
+
},
|
|
124
|
+
url: {
|
|
125
|
+
description: 'URL to the file.',
|
|
126
|
+
type: 'string | undefined',
|
|
127
|
+
},
|
|
128
|
+
data: {
|
|
129
|
+
description: 'Binary data (if already fetched).',
|
|
130
|
+
type: 'Buffer | Blob | undefined',
|
|
131
|
+
},
|
|
132
|
+
name: {
|
|
133
|
+
description: 'Filename.',
|
|
134
|
+
type: 'string | undefined',
|
|
135
|
+
},
|
|
136
|
+
mimeType: {
|
|
137
|
+
description: 'MIME type.',
|
|
138
|
+
type: 'string | undefined',
|
|
139
|
+
},
|
|
140
|
+
size: {
|
|
141
|
+
description: 'File size in bytes.',
|
|
142
|
+
type: 'number | undefined',
|
|
143
|
+
},
|
|
144
|
+
'fetchData()': {
|
|
145
|
+
description: 'Fetch the attachment data. Handles platform auth automatically.',
|
|
146
|
+
type: '() => Promise<Buffer> | undefined',
|
|
147
|
+
},
|
|
148
|
+
}}
|
|
149
|
+
/>
|
|
150
|
+
|
|
151
|
+
## Serialization
|
|
152
|
+
|
|
153
|
+
Messages can be serialized for workflow engines and external systems.
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
// Serialize
|
|
157
|
+
const json = message.toJSON();
|
|
158
|
+
|
|
159
|
+
// Deserialize
|
|
160
|
+
const restored = Message.fromJSON(json);
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The serialized format converts `Date` fields to ISO strings and omits non-serializable fields like `data` buffers and `fetchData` functions.
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Modals
|
|
3
|
+
description: Modal form components for collecting user input.
|
|
4
|
+
type: reference
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Modals display form dialogs that collect structured user input. Currently supported on Slack.
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { Modal, TextInput, Select, RadioSelect, SelectOption } from "chat";
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Modal
|
|
14
|
+
|
|
15
|
+
Top-level container for a form dialog. Open a modal from an `onAction` or `onSlashCommand` handler using `event.openModal()`.
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
bot.onAction("open-form", async (event) => {
|
|
19
|
+
await event.openModal(
|
|
20
|
+
Modal({
|
|
21
|
+
callbackId: "feedback",
|
|
22
|
+
title: "Submit Feedback",
|
|
23
|
+
submitLabel: "Send",
|
|
24
|
+
children: [
|
|
25
|
+
TextInput({ id: "comment", label: "Comment", multiline: true }),
|
|
26
|
+
],
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
<TypeTable
|
|
33
|
+
type={{
|
|
34
|
+
callbackId: {
|
|
35
|
+
description: 'Unique ID for routing to onModalSubmit/onModalClose handlers.',
|
|
36
|
+
type: 'string',
|
|
37
|
+
},
|
|
38
|
+
title: {
|
|
39
|
+
description: 'Modal title displayed in the header.',
|
|
40
|
+
type: 'string',
|
|
41
|
+
},
|
|
42
|
+
submitLabel: {
|
|
43
|
+
description: 'Label for the submit button.',
|
|
44
|
+
type: 'string',
|
|
45
|
+
default: '"Submit"',
|
|
46
|
+
},
|
|
47
|
+
closeLabel: {
|
|
48
|
+
description: 'Label for the close/cancel button.',
|
|
49
|
+
type: 'string',
|
|
50
|
+
default: '"Cancel"',
|
|
51
|
+
},
|
|
52
|
+
notifyOnClose: {
|
|
53
|
+
description: 'Whether to fire onModalClose when the user dismisses the modal.',
|
|
54
|
+
type: 'boolean',
|
|
55
|
+
default: 'false',
|
|
56
|
+
},
|
|
57
|
+
privateMetadata: {
|
|
58
|
+
description: 'Arbitrary string passed through the modal lifecycle (e.g., JSON context).',
|
|
59
|
+
type: 'string',
|
|
60
|
+
},
|
|
61
|
+
children: {
|
|
62
|
+
description: 'Form input elements.',
|
|
63
|
+
type: 'ModalChild[]',
|
|
64
|
+
},
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
|
|
68
|
+
## TextInput
|
|
69
|
+
|
|
70
|
+
A text input field.
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
TextInput({
|
|
74
|
+
id: "name",
|
|
75
|
+
label: "Your name",
|
|
76
|
+
placeholder: "Enter your name",
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
TextInput({
|
|
80
|
+
id: "description",
|
|
81
|
+
label: "Description",
|
|
82
|
+
multiline: true,
|
|
83
|
+
maxLength: 500,
|
|
84
|
+
optional: true,
|
|
85
|
+
})
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
<TypeTable
|
|
89
|
+
type={{
|
|
90
|
+
id: {
|
|
91
|
+
description: 'Input ID — used as the key in event.values.',
|
|
92
|
+
type: 'string',
|
|
93
|
+
},
|
|
94
|
+
label: {
|
|
95
|
+
description: 'Label displayed above the input.',
|
|
96
|
+
type: 'string',
|
|
97
|
+
},
|
|
98
|
+
placeholder: {
|
|
99
|
+
description: 'Placeholder text.',
|
|
100
|
+
type: 'string',
|
|
101
|
+
},
|
|
102
|
+
initialValue: {
|
|
103
|
+
description: 'Pre-filled value.',
|
|
104
|
+
type: 'string',
|
|
105
|
+
},
|
|
106
|
+
multiline: {
|
|
107
|
+
description: 'Render as a textarea.',
|
|
108
|
+
type: 'boolean',
|
|
109
|
+
default: 'false',
|
|
110
|
+
},
|
|
111
|
+
optional: {
|
|
112
|
+
description: 'Whether the field can be left empty.',
|
|
113
|
+
type: 'boolean',
|
|
114
|
+
default: 'false',
|
|
115
|
+
},
|
|
116
|
+
maxLength: {
|
|
117
|
+
description: 'Maximum character length.',
|
|
118
|
+
type: 'number',
|
|
119
|
+
},
|
|
120
|
+
}}
|
|
121
|
+
/>
|
|
122
|
+
|
|
123
|
+
## Select
|
|
124
|
+
|
|
125
|
+
Dropdown menu.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
Select({
|
|
129
|
+
id: "priority",
|
|
130
|
+
label: "Priority",
|
|
131
|
+
placeholder: "Select priority",
|
|
132
|
+
options: [
|
|
133
|
+
SelectOption({ label: "High", value: "high", description: "Urgent tasks" }),
|
|
134
|
+
SelectOption({ label: "Medium", value: "medium" }),
|
|
135
|
+
SelectOption({ label: "Low", value: "low" }),
|
|
136
|
+
],
|
|
137
|
+
})
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
<TypeTable
|
|
141
|
+
type={{
|
|
142
|
+
id: {
|
|
143
|
+
description: 'Input ID — used as the key in event.values.',
|
|
144
|
+
type: 'string',
|
|
145
|
+
},
|
|
146
|
+
label: {
|
|
147
|
+
description: 'Label displayed above the select.',
|
|
148
|
+
type: 'string',
|
|
149
|
+
},
|
|
150
|
+
placeholder: {
|
|
151
|
+
description: 'Placeholder text.',
|
|
152
|
+
type: 'string',
|
|
153
|
+
},
|
|
154
|
+
initialOption: {
|
|
155
|
+
description: 'Pre-selected option value.',
|
|
156
|
+
type: 'string',
|
|
157
|
+
},
|
|
158
|
+
optional: {
|
|
159
|
+
description: 'Whether the field can be left empty.',
|
|
160
|
+
type: 'boolean',
|
|
161
|
+
default: 'false',
|
|
162
|
+
},
|
|
163
|
+
options: {
|
|
164
|
+
description: 'Select options.',
|
|
165
|
+
type: 'SelectOptionElement[]',
|
|
166
|
+
},
|
|
167
|
+
}}
|
|
168
|
+
/>
|
|
169
|
+
|
|
170
|
+
## RadioSelect
|
|
171
|
+
|
|
172
|
+
Radio button group for mutually exclusive choices.
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
RadioSelect({
|
|
176
|
+
id: "status",
|
|
177
|
+
label: "Status",
|
|
178
|
+
options: [
|
|
179
|
+
SelectOption({ label: "Open", value: "open" }),
|
|
180
|
+
SelectOption({ label: "Closed", value: "closed" }),
|
|
181
|
+
],
|
|
182
|
+
})
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Same props as `Select` (except `placeholder`).
|
|
186
|
+
|
|
187
|
+
## SelectOption
|
|
188
|
+
|
|
189
|
+
An option used inside `Select` and `RadioSelect`.
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
SelectOption({ label: "High", value: "high", description: "Urgent tasks" })
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
<TypeTable
|
|
196
|
+
type={{
|
|
197
|
+
label: {
|
|
198
|
+
description: 'Display text.',
|
|
199
|
+
type: 'string',
|
|
200
|
+
},
|
|
201
|
+
value: {
|
|
202
|
+
description: 'Value sent in event.values when selected.',
|
|
203
|
+
type: 'string',
|
|
204
|
+
},
|
|
205
|
+
description: {
|
|
206
|
+
description: 'Optional description shown below the label.',
|
|
207
|
+
type: 'string',
|
|
208
|
+
},
|
|
209
|
+
}}
|
|
210
|
+
/>
|
|
211
|
+
|
|
212
|
+
## ModalChild types
|
|
213
|
+
|
|
214
|
+
The `children` array in `Modal` accepts these element types:
|
|
215
|
+
|
|
216
|
+
| Type | Created by |
|
|
217
|
+
|------|-----------|
|
|
218
|
+
| `TextInputElement` | `TextInput()` |
|
|
219
|
+
| `SelectElement` | `Select()` |
|
|
220
|
+
| `RadioSelectElement` | `RadioSelect()` |
|
|
221
|
+
| `TextElement` | `Text()` — static text content |
|
|
222
|
+
| `FieldsElement` | `Fields()` — key-value display |
|