@celobus/sdk 0.0.0-stage → 0.1.0
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/LICENSE +91 -0
- package/README.md +38 -2
- package/dist/access.d.ts +141 -0
- package/dist/access.js +232 -0
- package/dist/codec.d.ts +29 -0
- package/dist/codec.js +361 -0
- package/dist/cron.d.ts +2 -0
- package/dist/cron.js +113 -0
- package/dist/ctx.d.ts +644 -0
- package/dist/ctx.js +657 -0
- package/dist/db.d.ts +234 -0
- package/dist/db.js +495 -0
- package/dist/decimal.d.ts +39 -0
- package/dist/decimal.js +158 -0
- package/dist/declare.d.ts +311 -0
- package/dist/declare.js +78 -0
- package/dist/descriptor.d.ts +229 -0
- package/dist/descriptor.js +899 -0
- package/dist/errors.d.ts +65 -0
- package/dist/errors.js +114 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +34 -0
- package/dist/log.d.ts +39 -0
- package/dist/log.js +101 -0
- package/dist/names.d.ts +12 -0
- package/dist/names.js +41 -0
- package/dist/notify.d.ts +185 -0
- package/dist/notify.js +234 -0
- package/dist/platform.d.ts +61 -0
- package/dist/platform.js +47 -0
- package/dist/plugin.d.ts +43 -0
- package/dist/plugin.js +117 -0
- package/dist/query.d.ts +326 -0
- package/dist/query.js +794 -0
- package/dist/remote.d.ts +8 -0
- package/dist/remote.js +19 -0
- package/dist/schema.d.ts +487 -0
- package/dist/schema.js +405 -0
- package/dist/serve.d.ts +63 -0
- package/dist/serve.js +411 -0
- package/dist/sql.d.ts +13 -0
- package/dist/sql.js +33 -0
- package/dist/ui.d.ts +1867 -0
- package/dist/ui.js +3964 -0
- package/dist/viz-kinds.d.ts +12 -0
- package/dist/viz-kinds.js +14 -0
- package/package.json +33 -4
- package/proto/plugin.proto +994 -0
package/dist/ui.d.ts
ADDED
|
@@ -0,0 +1,1867 @@
|
|
|
1
|
+
import type { RoleLike } from "./ctx.js";
|
|
2
|
+
import type { EndpointDef } from "./declare.js";
|
|
3
|
+
import { EntityDef, FieldRef, MessageDef, type AnyField, type Infer, type IoType, type IoValue, type Shape, type ValueOf } from "./schema.js";
|
|
4
|
+
import { VIZ_KINDS } from "./viz-kinds.js";
|
|
5
|
+
/** The catalog revision these builders write (2: charts and figures, `ui.viz`, and dashboards, `ui.board`; 3: the app-like primitives). */
|
|
6
|
+
export declare const CATALOG = 3;
|
|
7
|
+
export type Tone = "neutral" | "ok" | "attention" | "danger";
|
|
8
|
+
export type Gap = "tight" | "normal" | "loose";
|
|
9
|
+
export type Size = "small" | "medium" | "large";
|
|
10
|
+
export type NoticeTone = Tone;
|
|
11
|
+
/** @internal What resolving needs from the plugin. */
|
|
12
|
+
export interface UiResolver {
|
|
13
|
+
/** The endpoint's name, or an error at `path` (and `""`) when it is not one of the plugin's. */
|
|
14
|
+
endpoint(def: EndpointDef<any, any>, path: string): string;
|
|
15
|
+
/** `<plugin>.<entity>` of one of the plugin's entities. */
|
|
16
|
+
entity(def: EntityDef<any>, path: string): string;
|
|
17
|
+
}
|
|
18
|
+
/** @internal A part of the document known only when the plugin resolves. */
|
|
19
|
+
export declare class Deferred {
|
|
20
|
+
readonly resolve: (r: UiResolver, path: string) => unknown;
|
|
21
|
+
constructor(resolve: (r: UiResolver, path: string) => unknown);
|
|
22
|
+
}
|
|
23
|
+
/** @internal Anything that becomes JSON in the document. */
|
|
24
|
+
export declare abstract class Built {
|
|
25
|
+
/** @internal */
|
|
26
|
+
abstract json(): unknown;
|
|
27
|
+
}
|
|
28
|
+
/** A catalog text: its key and its English (fallback) text, which goes into the document's `texts.en`. */
|
|
29
|
+
export declare class TextKey {
|
|
30
|
+
readonly key: string;
|
|
31
|
+
readonly en: string;
|
|
32
|
+
readonly args: Record<string, unknown>;
|
|
33
|
+
constructor(key: string, en: string, args?: Record<string, unknown>);
|
|
34
|
+
/** An argument of the text (`ui.text('orders.cancel', 'Cancel order {number}?').arg('number', r.get(order.f.number))`). */
|
|
35
|
+
arg<T>(name: string, v: ValueLike<T>): TextKey;
|
|
36
|
+
}
|
|
37
|
+
/** A value of type `T` from somewhere: a literal, a param, state, a query field, a row field, the caller, … */
|
|
38
|
+
export declare class Val<T> extends Built {
|
|
39
|
+
readonly v: unknown;
|
|
40
|
+
readonly __value: T;
|
|
41
|
+
constructor(/** @internal */ v: unknown);
|
|
42
|
+
/** @internal */
|
|
43
|
+
json(): unknown;
|
|
44
|
+
eq(other: ValueLike<T>): Cond;
|
|
45
|
+
ne(other: ValueLike<T>): Cond;
|
|
46
|
+
gt(other: ValueLike<T>): Cond;
|
|
47
|
+
lt(other: ValueLike<T>): Cond;
|
|
48
|
+
/** Absent, `""` or `[]`. */
|
|
49
|
+
empty(): Cond;
|
|
50
|
+
isIn(set: readonly T[]): Cond;
|
|
51
|
+
}
|
|
52
|
+
/** What may fill a slot of type `T`: a value of that type, a param or state of it, or a literal. */
|
|
53
|
+
export type ValueLike<T> = Val<T> | ParamRef<T> | StateRef<T> | T;
|
|
54
|
+
/** A presentation condition (never access control): `val.eq(..)`, `.and(..)`, `ui.not(..)`. */
|
|
55
|
+
export declare class Cond extends Built {
|
|
56
|
+
readonly c: unknown;
|
|
57
|
+
constructor(/** @internal */ c: unknown);
|
|
58
|
+
/** @internal */
|
|
59
|
+
json(): unknown;
|
|
60
|
+
and(other: Cond): Cond;
|
|
61
|
+
or(other: Cond): Cond;
|
|
62
|
+
}
|
|
63
|
+
/** A text: a literal, a catalog text (`ui.text(key, en)`), or a value shown as text. */
|
|
64
|
+
export type Txt = string | TextKey | Val<any> | ParamRef<any> | StateRef<any>;
|
|
65
|
+
/** Request (or key, or params) fields set to values: `{ id: r.get(order.f.id), reason: 'late' }`. */
|
|
66
|
+
export type ArgsOf<M> = {
|
|
67
|
+
[K in keyof M]?: ValueLike<NonNullable<M[K]>>;
|
|
68
|
+
};
|
|
69
|
+
interface ArgJson {
|
|
70
|
+
field: string;
|
|
71
|
+
value: unknown;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A topic: `const ORDERS = topic('orders', t.message('AllOrders', {}))`. Endpoints declare that they invalidate it
|
|
75
|
+
* (`.invalidates(ORDERS)`); queries follow it (`.follow(ORDERS)`, or one key: `.follow(ORDER.key({ id }))`).
|
|
76
|
+
*/
|
|
77
|
+
export declare class TopicDef<K> {
|
|
78
|
+
readonly name: string;
|
|
79
|
+
/** The key message (its fields name one record; none: the topic has one key). */
|
|
80
|
+
readonly keyMessage: MessageDef<any>;
|
|
81
|
+
readonly __key: (k: K) => K;
|
|
82
|
+
constructor(name: string,
|
|
83
|
+
/** The key message (its fields name one record; none: the topic has one key). */
|
|
84
|
+
keyMessage: MessageDef<any>);
|
|
85
|
+
/** The declaration with its defaults (no roles or scopes, invalidated by endpoint declarations). */
|
|
86
|
+
decl(): TopicDecl;
|
|
87
|
+
/** Members with any of these roles may follow it. */
|
|
88
|
+
roles(roles: readonly RoleLike[]): TopicDecl;
|
|
89
|
+
scopes(scopes: readonly string[]): TopicDecl;
|
|
90
|
+
/** The read endpoint that decides whether a member may follow one key (it takes the key's fields). */
|
|
91
|
+
authorize(endpoint: EndpointDef<any, any>): TopicDecl;
|
|
92
|
+
/** Invalidated by code (`ctx.invalidate`) rather than by endpoint declarations. */
|
|
93
|
+
manual(): TopicDecl;
|
|
94
|
+
describe(text: string): TopicDecl;
|
|
95
|
+
/** One key of the topic, for `.follow(..)`: `ORDER.key({ id })`. */
|
|
96
|
+
key(key: ArgsOf<K>): FollowKey;
|
|
97
|
+
/** An invalidation of the key whose field `key` is the response's field `from`: `ORDER.by(orderKey.f.id, order.f.id)`. */
|
|
98
|
+
by<T>(key: FieldRef<K, T>, from: FieldRef<any, T>): Invalidation;
|
|
99
|
+
}
|
|
100
|
+
/** Declares a topic and its key message. */
|
|
101
|
+
export declare function topic<S extends Shape>(name: string, key: MessageDef<S>): TopicDef<Infer<S>>;
|
|
102
|
+
/** A topic as the plugin declares it (`plugin({ topics: [ORDERS.roles([clerk])] })`). */
|
|
103
|
+
export declare class TopicDecl {
|
|
104
|
+
readonly topic: TopicDef<any>;
|
|
105
|
+
/** @internal */ readonly roleList: readonly RoleLike[];
|
|
106
|
+
/** @internal */ readonly scopeList: readonly string[];
|
|
107
|
+
/** @internal */ readonly authorizer: EndpointDef<any, any> | undefined;
|
|
108
|
+
/** @internal */ readonly isManual: boolean;
|
|
109
|
+
/** @internal */ readonly description: string;
|
|
110
|
+
constructor(topic: TopicDef<any>,
|
|
111
|
+
/** @internal */ roleList: readonly RoleLike[],
|
|
112
|
+
/** @internal */ scopeList: readonly string[],
|
|
113
|
+
/** @internal */ authorizer: EndpointDef<any, any> | undefined,
|
|
114
|
+
/** @internal */ isManual: boolean,
|
|
115
|
+
/** @internal */ description: string);
|
|
116
|
+
roles(roles: readonly RoleLike[]): TopicDecl;
|
|
117
|
+
scopes(scopes: readonly string[]): TopicDecl;
|
|
118
|
+
authorize(endpoint: EndpointDef<any, any>): TopicDecl;
|
|
119
|
+
manual(): TopicDecl;
|
|
120
|
+
describe(text: string): TopicDecl;
|
|
121
|
+
}
|
|
122
|
+
export type TopicLike = TopicDef<any> | TopicDecl;
|
|
123
|
+
/** @internal */
|
|
124
|
+
export declare function topicDecl(t: TopicLike): TopicDecl;
|
|
125
|
+
/** An endpoint's declared invalidation: a topic, and the key taken from the response. */
|
|
126
|
+
export declare class Invalidation {
|
|
127
|
+
readonly topic: string;
|
|
128
|
+
/** @internal [key field, response field] */ readonly key: readonly (readonly [string, string])[];
|
|
129
|
+
constructor(topic: string,
|
|
130
|
+
/** @internal [key field, response field] */ key: readonly (readonly [string, string])[]);
|
|
131
|
+
/** Another key field. */
|
|
132
|
+
and<K, T>(key: FieldRef<K, T>, from: FieldRef<any, T>): Invalidation;
|
|
133
|
+
}
|
|
134
|
+
export type InvalidationLike = TopicDef<any> | Invalidation;
|
|
135
|
+
/** @internal The descriptor's `invalidates` entry. */
|
|
136
|
+
export declare function invalidationJson(i: InvalidationLike): Record<string, unknown>;
|
|
137
|
+
/** A followed topic with a key value. */
|
|
138
|
+
export declare class FollowKey {
|
|
139
|
+
readonly topic: string;
|
|
140
|
+
/** @internal */ readonly key: readonly ArgJson[];
|
|
141
|
+
constructor(topic: string,
|
|
142
|
+
/** @internal */ key: readonly ArgJson[]);
|
|
143
|
+
}
|
|
144
|
+
export type FollowLike = TopicDef<any> | FollowKey;
|
|
145
|
+
interface QueryJson {
|
|
146
|
+
name: string;
|
|
147
|
+
endpoint: Deferred;
|
|
148
|
+
args: ArgJson[];
|
|
149
|
+
rows?: string;
|
|
150
|
+
paged: boolean;
|
|
151
|
+
feed?: {
|
|
152
|
+
after: string;
|
|
153
|
+
cursor: string;
|
|
154
|
+
key: string;
|
|
155
|
+
};
|
|
156
|
+
follow: {
|
|
157
|
+
topic: string;
|
|
158
|
+
key?: ArgJson[];
|
|
159
|
+
min_interval_ms?: number;
|
|
160
|
+
}[];
|
|
161
|
+
poll?: number;
|
|
162
|
+
max_age?: number;
|
|
163
|
+
when?: Cond;
|
|
164
|
+
older?: {
|
|
165
|
+
token: string;
|
|
166
|
+
arg: string;
|
|
167
|
+
};
|
|
168
|
+
debounce_ms?: number;
|
|
169
|
+
join?: {
|
|
170
|
+
as: string;
|
|
171
|
+
rows: string;
|
|
172
|
+
key: string;
|
|
173
|
+
by: string;
|
|
174
|
+
}[];
|
|
175
|
+
}
|
|
176
|
+
/** A query definition: `ui.call(listOrders, { status }).rows(listOrdersResponse.f.orders).paged().follow(ORDERS)`. */
|
|
177
|
+
export declare class QueryDef<Req, Resp, Row> {
|
|
178
|
+
readonly q: QueryJson;
|
|
179
|
+
readonly __types: (x: [Req, Resp, Row]) => void;
|
|
180
|
+
constructor(/** @internal */ q: QueryJson);
|
|
181
|
+
/** The repeated field tables, lists and charts iterate. */
|
|
182
|
+
rows<R>(f: FieldRef<Resp, R[]>): QueryDef<Req, Resp, R>;
|
|
183
|
+
/** `page_token`/`page_size` in the request, `next_page_token` in the response. */
|
|
184
|
+
paged(): QueryDef<Req, Resp, Row>;
|
|
185
|
+
/** Re-run on the topic's invalidations (any key, or one key: `ORDER.key({ id })`), at most every `minIntervalMs`. */
|
|
186
|
+
follow(t: FollowLike, minIntervalMs?: number): QueryDef<Req, Resp, Row>;
|
|
187
|
+
/** An append-only feed: `after` takes the last cursor, `cursor` gives it, rows are deduplicated by `key`. */
|
|
188
|
+
feed(after: FieldRef<Req, unknown>, cursor: FieldRef<Resp, unknown>, key: FieldRef<Row, unknown>): QueryDef<Req, Resp, Row>;
|
|
189
|
+
/** Re-run every `seconds` (at least 15). */
|
|
190
|
+
poll(seconds: number): QueryDef<Req, Resp, Row>;
|
|
191
|
+
/** The oldest the data may get while shown (seconds). */
|
|
192
|
+
maxAge(seconds: number): QueryDef<Req, Resp, Row>;
|
|
193
|
+
/** Runs only while `c` holds (a record panel reads once a row is selected). */
|
|
194
|
+
when(c: Cond): QueryDef<Req, Resp, Row>;
|
|
195
|
+
/**
|
|
196
|
+
* The page before the rows (catalog 3): the same endpoint and args read again with the request field `arg` set to
|
|
197
|
+
* the answer's `token`; a `stream` loads older pages with it.
|
|
198
|
+
*/
|
|
199
|
+
older<A, B>(token: FieldRef<Resp, A>, arg: FieldRef<Req, B>): QueryDef<Req, Resp, Row>;
|
|
200
|
+
/** Arguments that change wait this long (ms, at most 2000) before the read: a preview of what is typed (catalog 3). */
|
|
201
|
+
debounceMs(ms: number): QueryDef<Req, Resp, Row>;
|
|
202
|
+
/**
|
|
203
|
+
* A lookup the rows' templates read as `<via>.<field>` (catalog 3): each row gets the item of the response's
|
|
204
|
+
* repeated field `rows` whose `key` equals the row's `by`:
|
|
205
|
+
* `.join(who, channelView.f.people, face.f.id, msg.f.by)` with `const who = ui.via('who', msg, face)`.
|
|
206
|
+
*/
|
|
207
|
+
join<J, K>(via: Via<Row, J>, rows: FieldRef<Resp, J[]>, key: FieldRef<J, K>, by: FieldRef<Row, K>): QueryDef<Req, Resp, Row>;
|
|
208
|
+
}
|
|
209
|
+
/** A call of one of the plugin's read-only `ui` endpoints with its arguments. */
|
|
210
|
+
declare function call<I extends IoType, O extends IoType>(endpoint: EndpointDef<I, O>, a?: ArgsOf<IoValue<I>>): QueryDef<IoValue<I>, IoValue<O>, IoValue<O>>;
|
|
211
|
+
/** A declared query of a screen, an overlay or the document: read its fields, iterate its rows. */
|
|
212
|
+
export declare class Q<Resp, Row> {
|
|
213
|
+
readonly name: string;
|
|
214
|
+
readonly __types: (x: [Resp, Row]) => void;
|
|
215
|
+
constructor(name: string);
|
|
216
|
+
/** A field of the response (one record). */
|
|
217
|
+
field<T>(f: FieldRef<Resp, T>): Val<T>;
|
|
218
|
+
/** A nested field by path (`customer.name`). */
|
|
219
|
+
path<T = unknown>(path: string): Val<T>;
|
|
220
|
+
}
|
|
221
|
+
/** The current row of a table, list, chart or row menu. */
|
|
222
|
+
export declare class RowRef<R> {
|
|
223
|
+
readonly __row: (r: R) => R;
|
|
224
|
+
get<T>(f: FieldRef<R, T>): Val<T>;
|
|
225
|
+
/** A row value by path: a nested field (`ui.path(..)`) or a field of a query's join (`who.f(face.f.name)`). */
|
|
226
|
+
at<T>(p: RowPathLike<R, T>): Val<T>;
|
|
227
|
+
/** The row as a list item (`r.view(r.get(order.f.customer)).subtitle(..)`): a table's compact view, a search result. */
|
|
228
|
+
view(title: Txt): RowViewB<R>;
|
|
229
|
+
}
|
|
230
|
+
/** The values of the enclosing form. */
|
|
231
|
+
export declare class FormVals<Req> {
|
|
232
|
+
readonly __request: (r: Req) => Req;
|
|
233
|
+
get<T>(f: FieldRef<Req, T>): Val<T>;
|
|
234
|
+
}
|
|
235
|
+
/** A screen's key and its params message; `ui.screen(key, build)` builds it. */
|
|
236
|
+
export declare class ScreenKey<P> {
|
|
237
|
+
readonly id: string;
|
|
238
|
+
/** @internal */ readonly paramsMessage?: MessageDef<any> | undefined;
|
|
239
|
+
readonly __params: (p: P) => P;
|
|
240
|
+
constructor(id: string,
|
|
241
|
+
/** @internal */ paramsMessage?: MessageDef<any> | undefined);
|
|
242
|
+
}
|
|
243
|
+
/** An overlay's key and its params message. */
|
|
244
|
+
export declare class OverlayKey<P> {
|
|
245
|
+
readonly id: string;
|
|
246
|
+
/** @internal */ readonly paramsMessage?: MessageDef<any> | undefined;
|
|
247
|
+
readonly __params: (p: P) => P;
|
|
248
|
+
constructor(id: string,
|
|
249
|
+
/** @internal */ paramsMessage?: MessageDef<any> | undefined);
|
|
250
|
+
}
|
|
251
|
+
/** A screen or overlay param. */
|
|
252
|
+
export declare class ParamRef<T> {
|
|
253
|
+
readonly name: string;
|
|
254
|
+
/** @internal */ readonly field?: AnyField | undefined;
|
|
255
|
+
readonly __value: T;
|
|
256
|
+
constructor(name: string,
|
|
257
|
+
/** @internal */ field?: AnyField | undefined);
|
|
258
|
+
val(): Val<T>;
|
|
259
|
+
private input;
|
|
260
|
+
/** A select in a filter bar: the enum's values (or `.option(..)`); the label defaults to the param's name. */
|
|
261
|
+
select(label?: Txt): InputB;
|
|
262
|
+
/**
|
|
263
|
+
* A filter that takes several values: the enum's values (or `.option(..)`). The param is a string: the chosen
|
|
264
|
+
* values joined with commas, in the options' order (`unpaid,pending`); the endpoint splits it.
|
|
265
|
+
*/
|
|
266
|
+
choices(label?: Txt): InputB;
|
|
267
|
+
search(label?: Txt): InputB;
|
|
268
|
+
date(label?: Txt): InputB;
|
|
269
|
+
}
|
|
270
|
+
/** A state value of a screen or overlay. */
|
|
271
|
+
export declare class StateRef<T> {
|
|
272
|
+
readonly name: string;
|
|
273
|
+
readonly __value: T;
|
|
274
|
+
constructor(name: string);
|
|
275
|
+
val(): Val<T>;
|
|
276
|
+
}
|
|
277
|
+
/** A declared action (a chain of steps). */
|
|
278
|
+
export declare class ActionRef {
|
|
279
|
+
readonly name: string;
|
|
280
|
+
constructor(name: string);
|
|
281
|
+
}
|
|
282
|
+
/** What a screen's or overlay's builder function returns: its layout (or `s.layout(..)` sets it). */
|
|
283
|
+
export type BuildResult = Node | ScreenBuilder<any> | void;
|
|
284
|
+
export type ScreenBuild<P> = (s: ScreenBuilder<P>) => BuildResult;
|
|
285
|
+
/** The builder a screen's or overlay's function gets. */
|
|
286
|
+
export declare class ScreenBuilder<P> {
|
|
287
|
+
readonly __params: (p: P) => P;
|
|
288
|
+
/** @internal */ readonly params: Record<string, unknown>[];
|
|
289
|
+
/** @internal */ readonly states: Record<string, unknown>[];
|
|
290
|
+
/** @internal */ readonly queries: Record<string, unknown>[];
|
|
291
|
+
/** @internal */ readonly actions: Record<string, unknown>[];
|
|
292
|
+
/** @internal */ readonly overlays: OverlayDef<any>[];
|
|
293
|
+
/** @internal */ readonly headerNodes: Node[];
|
|
294
|
+
/** @internal */ titleText?: unknown;
|
|
295
|
+
/** @internal */ subtitleText?: unknown;
|
|
296
|
+
/** @internal */ kickerText?: unknown;
|
|
297
|
+
/** @internal */ sizeValue: Size;
|
|
298
|
+
/** @internal */ layoutNode?: Node;
|
|
299
|
+
private counter;
|
|
300
|
+
constructor(paramsMessage?: MessageDef<any>);
|
|
301
|
+
title(t: Txt): this;
|
|
302
|
+
subtitle(t: Txt): this;
|
|
303
|
+
/** A small line above an overlay's title (`COMMERCE · ORDERS`). */
|
|
304
|
+
kicker(t: Txt): this;
|
|
305
|
+
/** An overlay's size (default medium). */
|
|
306
|
+
size(size: Size): this;
|
|
307
|
+
/** A param of the params message (a filter, a record id). */
|
|
308
|
+
param<T>(f: FieldRef<P, T>): ParamRef<T>;
|
|
309
|
+
/**
|
|
310
|
+
* A param with a default: a screen opened without it behaves as if the link had the default (the queries get it,
|
|
311
|
+
* a `segmented` or a tab bound to it shows it selected), and the link stays without it. The param always has a
|
|
312
|
+
* value, so the handle is of the plain type even when the field is optional:
|
|
313
|
+
* `const range = s.paramOr(reportParams.f.range, '30')`.
|
|
314
|
+
*/
|
|
315
|
+
paramOr<T>(f: FieldRef<P, T>, initial: NoInfer<NonNullable<T>>): ParamRef<NonNullable<T>>;
|
|
316
|
+
/** State of a type (a `t.*` field) with its initial value. */
|
|
317
|
+
state<F extends AnyField>(name: string, type: F, initial?: ValueOf<F>): StateRef<ValueOf<F>>;
|
|
318
|
+
/**
|
|
319
|
+
* State that returns to its default when one of these params changes (catalog 3; a tab that starts over in another
|
|
320
|
+
* conversation): `s.stateReset('tab', t.text(), 'notes', [channel])`.
|
|
321
|
+
*/
|
|
322
|
+
stateReset<F extends AnyField>(name: string, type: F, initial: ValueOf<F>, params: readonly (ParamRef<any> | string)[]): StateRef<ValueOf<F>>;
|
|
323
|
+
query<Req, Resp, Row>(name: string, def: QueryDef<Req, Resp, Row>): Q<Resp, Row>;
|
|
324
|
+
/** A chain of steps run by a button, a menu item or a row open. */
|
|
325
|
+
action(name: string, build: (a: Chain) => unknown): ActionRef;
|
|
326
|
+
/** A chain that reads the row it is run on (`r.get(order.f.id)`). */
|
|
327
|
+
rowAction<R>(name: string, _rows: Q<any, R>, build: (a: Chain, r: RowRef<R>) => unknown): ActionRef;
|
|
328
|
+
private pushAction;
|
|
329
|
+
/** Buttons and menus in the header (a screen) or the footer (a dialog). */
|
|
330
|
+
header(nodes: readonly Node[]): this;
|
|
331
|
+
/** The same as `header`, as overlays name it. */
|
|
332
|
+
buttons(nodes: readonly Node[]): this;
|
|
333
|
+
/** An overlay this screen opens (`a.open(CANCEL, { id })`). */
|
|
334
|
+
overlay(o: OverlayDef<any>): this;
|
|
335
|
+
layout(node: Node): this;
|
|
336
|
+
/** A form filling `endpoint`'s request; its submit runs the chain `submit` builds (`a.callForm(endpoint, ..)`). */
|
|
337
|
+
form<I extends IoType, O extends IoType>(endpoint: EndpointDef<I, O>, build: (f: FormB<IoValue<I>>) => unknown, submitLabel: Txt, submit: (a: Chain, v: FormVals<IoValue<I>>) => unknown): N;
|
|
338
|
+
/** @internal */
|
|
339
|
+
finish(id: string, result: BuildResult): Node;
|
|
340
|
+
}
|
|
341
|
+
/** A screen: `/w/{slug}/p/{plugin}/s/{id}?{params}`. */
|
|
342
|
+
export declare class ScreenDef<P> extends ScreenKey<P> {
|
|
343
|
+
private readonly build;
|
|
344
|
+
constructor(id: string, paramsMessage: MessageDef<any> | undefined, build: ScreenBuild<P>);
|
|
345
|
+
/** @internal */
|
|
346
|
+
json(): Record<string, unknown>;
|
|
347
|
+
}
|
|
348
|
+
export type OverlayKind = "dialog" | "side_panel" | "sheet";
|
|
349
|
+
/** A dialog, side panel or sheet over a screen. */
|
|
350
|
+
export declare class OverlayDef<P> extends OverlayKey<P> {
|
|
351
|
+
readonly kind: OverlayKind;
|
|
352
|
+
private readonly build;
|
|
353
|
+
constructor(id: string, paramsMessage: MessageDef<any> | undefined, kind: OverlayKind, build: ScreenBuild<P>);
|
|
354
|
+
/** @internal */
|
|
355
|
+
json(): Record<string, unknown>;
|
|
356
|
+
}
|
|
357
|
+
declare function screenKey<S extends Shape>(id: string, params: MessageDef<S>): ScreenKey<Infer<S>>;
|
|
358
|
+
declare function screenKey(id: string): ScreenKey<{}>;
|
|
359
|
+
declare function overlayKey<S extends Shape>(id: string, params: MessageDef<S>): OverlayKey<Infer<S>>;
|
|
360
|
+
declare function overlayKey(id: string): OverlayKey<{}>;
|
|
361
|
+
declare function screen<P>(key: ScreenKey<P>, build: ScreenBuild<P>): ScreenDef<P>;
|
|
362
|
+
declare function screen<S extends Shape>(id: string, params: MessageDef<S>, build: ScreenBuild<Infer<S>>): ScreenDef<Infer<S>>;
|
|
363
|
+
declare function screen(id: string, build: ScreenBuild<{}>): ScreenDef<{}>;
|
|
364
|
+
/** A confirmation before the next steps: `ui.confirm('Archive it?')`, `ui.confirm.danger('Delete it?')`. */
|
|
365
|
+
export declare class ConfirmB {
|
|
366
|
+
/** @internal */ readonly c: Record<string, unknown>;
|
|
367
|
+
constructor(title: Txt);
|
|
368
|
+
text(t: Txt): this;
|
|
369
|
+
confirmLabel(t: Txt): this;
|
|
370
|
+
danger(): this;
|
|
371
|
+
/** The member types this value to confirm. */
|
|
372
|
+
typed<T>(v: ValueLike<T>): this;
|
|
373
|
+
cancelLabel(t: Txt): this;
|
|
374
|
+
/** What is affected, as a record line with an icon (`Order #1048 · Hartwell & Co · $2,480.00`). */
|
|
375
|
+
summary(icon: string, t: Txt): this;
|
|
376
|
+
}
|
|
377
|
+
/** A chain of steps: `a.confirm(..).call(..).toast(..).close()`; `onError` for the failure branch. */
|
|
378
|
+
export declare class Chain {
|
|
379
|
+
/** @internal */ readonly steps: Record<string, unknown>[];
|
|
380
|
+
/** @internal */ errorSteps: Record<string, unknown>[];
|
|
381
|
+
confirm(c: ConfirmB | Txt): this;
|
|
382
|
+
/** Calls a `ui` endpoint as the member. */
|
|
383
|
+
call<I extends IoType, O extends IoType>(endpoint: EndpointDef<I, O>, a?: ArgsOf<IoValue<I>>): this;
|
|
384
|
+
/** Calls with the enclosing form's values (and `a` over them). */
|
|
385
|
+
callForm<I extends IoType, O extends IoType>(endpoint: EndpointDef<I, O>, a?: ArgsOf<IoValue<I>>): this;
|
|
386
|
+
/** The last call shows a pending row in `rows` until a re-read returns it. */
|
|
387
|
+
pending(rows: Q<any, any>): this;
|
|
388
|
+
toast(t: Txt, tone?: Tone): this;
|
|
389
|
+
/** In `onError`: the failing call's own message. */
|
|
390
|
+
toastError(): this;
|
|
391
|
+
/** The last toast gets a second line. */
|
|
392
|
+
described(t: Txt): this;
|
|
393
|
+
/** The last toast gets a button running `action` (`Undo`). */
|
|
394
|
+
withButton(label: Txt, action: ActionRef): this;
|
|
395
|
+
open<P>(overlay: OverlayKey<P>, a?: ArgsOf<P>): this;
|
|
396
|
+
close(): this;
|
|
397
|
+
navigate<P>(screen: ScreenKey<P>, a?: ArgsOf<P>): this;
|
|
398
|
+
back(): this;
|
|
399
|
+
set<T>(state: StateRef<T>, v: NoInfer<ValueLike<T>>): this;
|
|
400
|
+
setParam<T>(param: ParamRef<T>, v: NoInfer<ValueLike<T>>): this;
|
|
401
|
+
/** Re-run these queries (none: every query of the screen). */
|
|
402
|
+
refresh(...queries: (Q<any, any> | string)[]): this;
|
|
403
|
+
openUrl(url: ValueLike<string>): this;
|
|
404
|
+
/** Puts the text into the composer of the item's stream (or the frame's primary composer), focused (catalog 3). */
|
|
405
|
+
draft(t: Txt): this;
|
|
406
|
+
/** Adds `@<name> ` to the composer and sends `key` as its `reply` while the mention stays (catalog 3). */
|
|
407
|
+
replyTo<K>(name: ValueLike<string>, key: Val<K>): this;
|
|
408
|
+
/** Scrolls the stream that holds an item with this key so the item is centred (catalog 3). */
|
|
409
|
+
scrollTo<K>(key: Val<K>): this;
|
|
410
|
+
/** Copies a value to the clipboard (catalog 3). */
|
|
411
|
+
copy<T>(v: ValueLike<T>): this;
|
|
412
|
+
/** Copies the screen's link with `#<key>` (catalog 3). */
|
|
413
|
+
copyLink<T>(key: ValueLike<T>): this;
|
|
414
|
+
/**
|
|
415
|
+
* Puts a row into the loaded rows of a query (by the stream's key) until the query's next answer (catalog 3):
|
|
416
|
+
* `a.call(postMessage, ..).merge(msgs, ui.result(posted.f.message))`.
|
|
417
|
+
*/
|
|
418
|
+
merge<R>(q: Q<any, R>, row: Val<R>): this;
|
|
419
|
+
/** The steps run when a step fails. */
|
|
420
|
+
onError(build: (e: Chain) => unknown): this;
|
|
421
|
+
}
|
|
422
|
+
/** A primitive with the common options: `.visible(cond)`, `.enabled(cond)`, `.fallback(node)`. */
|
|
423
|
+
export declare class Node extends Built {
|
|
424
|
+
/** @internal */ readonly kind: string;
|
|
425
|
+
/** @internal */ readonly body: Record<string, unknown>;
|
|
426
|
+
private visibleCond?;
|
|
427
|
+
private enabledCond?;
|
|
428
|
+
private fallbackNode?;
|
|
429
|
+
constructor(
|
|
430
|
+
/** @internal */ kind: string,
|
|
431
|
+
/** @internal */ body: Record<string, unknown>);
|
|
432
|
+
visible(c: Cond): this;
|
|
433
|
+
enabled(c: Cond): this;
|
|
434
|
+
/** What an older client draws instead (display primitives only). */
|
|
435
|
+
fallback(n: Node): this;
|
|
436
|
+
/** @internal */
|
|
437
|
+
json(): unknown;
|
|
438
|
+
}
|
|
439
|
+
/** A tone per value of an enum: `{ placed: 'attention', paid: 'ok' }`. */
|
|
440
|
+
export type Tones<T> = Partial<Record<Extract<T, string>, Tone>>;
|
|
441
|
+
/** The generic primitive; its options apply to the primitives that have them (as in the other SDKs). */
|
|
442
|
+
export declare class N extends Node {
|
|
443
|
+
private setFormat;
|
|
444
|
+
/** The gap of a stack or row. */
|
|
445
|
+
gap(gap: Gap): this;
|
|
446
|
+
/** A horizontal stack's children spread to both ends. */
|
|
447
|
+
between(): this;
|
|
448
|
+
/** A value at the end of a card's title line (a total; its format is the card's `.moneyIn(..)` and the like). */
|
|
449
|
+
trailing<T>(v: Val<T>): this;
|
|
450
|
+
/** Relative widths of columns (`[2, 1]`). */
|
|
451
|
+
ratios(r: readonly number[]): this;
|
|
452
|
+
/** A section's description. */
|
|
453
|
+
description(t: Txt): this;
|
|
454
|
+
/** Buttons in a section's head. */
|
|
455
|
+
actions(nodes: readonly Node[]): this;
|
|
456
|
+
/** A section's footer. */
|
|
457
|
+
footer(nodes: readonly Node[]): this;
|
|
458
|
+
/** The state (or param) that holds the selected tab. */
|
|
459
|
+
bind(to: StateRef<any> | ParamRef<any>): this;
|
|
460
|
+
/** A metric's change next to its value. */
|
|
461
|
+
delta<T>(v: Val<T>): this;
|
|
462
|
+
/** A metric's, meter's or progress' caption. */
|
|
463
|
+
caption(t: Txt): this;
|
|
464
|
+
/** A metric's caption tone and icon (`$33.9k overdue` in red with an alert icon). */
|
|
465
|
+
captionTone(tone: Tone, icon: string): this;
|
|
466
|
+
/** A card's or fields' title. */
|
|
467
|
+
titled(t: Txt): this;
|
|
468
|
+
/** At most this many avatars of an avatar stack (default 5). */
|
|
469
|
+
max(n: number): this;
|
|
470
|
+
moneyIn(code: string): this;
|
|
471
|
+
number(decimals?: number): this;
|
|
472
|
+
percent(decimals?: number): this;
|
|
473
|
+
date(): this;
|
|
474
|
+
datetime(): this;
|
|
475
|
+
relative(): this;
|
|
476
|
+
member(): this;
|
|
477
|
+
status(tones: Record<string, Tone>): this;
|
|
478
|
+
/** Counts up, live, from a moment in ms (`0:48`, `1:02:05`; catalog 3). */
|
|
479
|
+
elapsed(): this;
|
|
480
|
+
/** Counts down, live, to a moment in ms (`8 min`; catalog 3). */
|
|
481
|
+
countdown(): this;
|
|
482
|
+
/** A duration in ms (`1m 05s`; catalog 3). */
|
|
483
|
+
span(): this;
|
|
484
|
+
/**
|
|
485
|
+
* A split as an app-like screen: the viewport's height under the shell's header, each side scrolling itself (its
|
|
486
|
+
* first `stream` takes the free height), the detail an in-page side panel shown while its `visible` holds.
|
|
487
|
+
*/
|
|
488
|
+
fill(): this;
|
|
489
|
+
/** The split's panel width is dragged by its border: px from `min` to `max`, `initial` at first and on reset, the
|
|
490
|
+
* column keeping at least `keep`. */
|
|
491
|
+
resize(min: number, max: number, initial: number, keep?: number): this;
|
|
492
|
+
/** The bool state the detail's header's expand button toggles: true, the detail fills the screen. */
|
|
493
|
+
expand(state: StateRef<boolean>): this;
|
|
494
|
+
/**
|
|
495
|
+
* An icon button as a toggle (catalog 3): `pressed` says whether it is on; the icon and label given to
|
|
496
|
+
* `ui.iconButton` are the pressed ones, these the others. Its action reads `ui.form.pressed()`.
|
|
497
|
+
*/
|
|
498
|
+
toggle(pressed: ValueLike<boolean>, iconOff: string, labelOff: Txt): this;
|
|
499
|
+
private emphasis;
|
|
500
|
+
primary(): this;
|
|
501
|
+
ghost(): this;
|
|
502
|
+
danger(): this;
|
|
503
|
+
/** The action a button runs. */
|
|
504
|
+
run(action: ActionRef): this;
|
|
505
|
+
/** A button's, menu's or empty state's icon. */
|
|
506
|
+
icon(icon: string): this;
|
|
507
|
+
/** A notice's title, or a menu's label. */
|
|
508
|
+
title(t: Txt): this;
|
|
509
|
+
/** A notice's or an empty state's button. */
|
|
510
|
+
withAction(b: Node): this;
|
|
511
|
+
}
|
|
512
|
+
declare function stack(children: readonly Node[]): N;
|
|
513
|
+
/** `ui.row(children)`: children side by side (wrapping on a phone); `ui.row(field)`: a field of the current row. */
|
|
514
|
+
declare function row(children: readonly Node[]): N;
|
|
515
|
+
declare function row<T>(field: FieldRef<any, T>): Val<T>;
|
|
516
|
+
/** Columns that stack on a phone. */
|
|
517
|
+
declare function columns(children: readonly Node[]): N;
|
|
518
|
+
declare function section(title: Txt, children: readonly Node[]): N;
|
|
519
|
+
declare function card(children: readonly Node[]): N;
|
|
520
|
+
declare function divider(): N;
|
|
521
|
+
declare function split(list: Node, detail: Node): N;
|
|
522
|
+
/** One tab: its id, title and content. */
|
|
523
|
+
export declare class TabB extends Built {
|
|
524
|
+
readonly id: string;
|
|
525
|
+
private readonly title;
|
|
526
|
+
private readonly children;
|
|
527
|
+
private badgeValue?;
|
|
528
|
+
constructor(id: string, title: Txt, children: readonly Node[]);
|
|
529
|
+
badge<T>(v: Val<T>): this;
|
|
530
|
+
/** @internal */
|
|
531
|
+
json(): unknown;
|
|
532
|
+
}
|
|
533
|
+
declare function tab(id: string, title: Txt, children: readonly Node[]): TabB;
|
|
534
|
+
declare function tabs(list: readonly TabB[]): N;
|
|
535
|
+
/**
|
|
536
|
+
* A switch between a few options, bound to a state or to a param: a view switch,
|
|
537
|
+
* `ui.segmented(view, [['list', 'List'], ['board', 'Board']])`, or the range of a report, in the link,
|
|
538
|
+
* `ui.segmented(range, [['7', '7 days'], ['30', '30 days']])`. The options are values of the state's or the param's
|
|
539
|
+
* type; give a param a default (`s.paramOr(..)`) so the switch shows it on a link without the param.
|
|
540
|
+
*/
|
|
541
|
+
declare function segmented<T>(to: StateRef<T> | ParamRef<T>, options: readonly (readonly [NoInfer<NonNullable<T>>, Txt])[]): N;
|
|
542
|
+
declare function link<P>(text: Txt, screen: ScreenKey<P>, a?: ArgsOf<P>): N;
|
|
543
|
+
/** A table over a query's rows; columns and row values are handles of the row message. */
|
|
544
|
+
export declare class TableB<R> extends Node {
|
|
545
|
+
readonly __row: (r: R) => R;
|
|
546
|
+
private readonly columns;
|
|
547
|
+
private readonly rowActions;
|
|
548
|
+
private readonly rowTones;
|
|
549
|
+
constructor(query: string);
|
|
550
|
+
private column;
|
|
551
|
+
col<T>(f: FieldRef<R, T>, title: Txt): this;
|
|
552
|
+
/**
|
|
553
|
+
* A column that sorts the list by the request's string field `by`: a click on its head passes `asc`, the next
|
|
554
|
+
* `desc`, the third leaves the field out. One column sorts at a time.
|
|
555
|
+
*/
|
|
556
|
+
sortable<T>(f: FieldRef<R, T>, title: Txt, by: string): this;
|
|
557
|
+
mono<T>(f: FieldRef<R, T>, title: Txt): this;
|
|
558
|
+
number<T>(f: FieldRef<R, T>, title: Txt, decimals?: number): this;
|
|
559
|
+
/** A decimal amount in the currency of the row's field `currency`. */
|
|
560
|
+
money<T>(f: FieldRef<R, T>, title: Txt, currency: FieldRef<R, string>): this;
|
|
561
|
+
/** A decimal amount in a fixed currency (`USD`). */
|
|
562
|
+
moneyIn<T>(f: FieldRef<R, T>, title: Txt, code: string): this;
|
|
563
|
+
date<T>(f: FieldRef<R, T>, title: Txt): this;
|
|
564
|
+
datetime<T>(f: FieldRef<R, T>, title: Txt): this;
|
|
565
|
+
relative<T>(f: FieldRef<R, T>, title: Txt): this;
|
|
566
|
+
member<T>(f: FieldRef<R, T>, title: Txt): this;
|
|
567
|
+
avatar<T>(f: FieldRef<R, T>, title: Txt): this;
|
|
568
|
+
tags<T>(f: FieldRef<R, T>, title: Txt): this;
|
|
569
|
+
percent<T>(f: FieldRef<R, T>, title: Txt, decimals?: number): this;
|
|
570
|
+
bool<T>(f: FieldRef<R, T>, title: Txt): this;
|
|
571
|
+
/** An enum column drawn as a status with a tone per value. */
|
|
572
|
+
status<T>(f: FieldRef<R, T>, title: Txt, tones: Tones<T>): this;
|
|
573
|
+
/** The action run when a row is opened. */
|
|
574
|
+
open(action: ActionRef): this;
|
|
575
|
+
/** A button (or menu) on every row; a function gets the row (`r.get(order.f.status)`). */
|
|
576
|
+
rowButton(node: Node | ((r: RowRef<R>) => Node)): this;
|
|
577
|
+
/** The same as `rowButton`. */
|
|
578
|
+
rowAction(node: Node | ((r: RowRef<R>) => Node)): this;
|
|
579
|
+
/** Buttons, search and filters above the table. */
|
|
580
|
+
toolbar(nodes: readonly Node[]): this;
|
|
581
|
+
empty(t: Txt): this;
|
|
582
|
+
/** The selected row's key goes into this state. */
|
|
583
|
+
select<K>(state: StateRef<K>, key: FieldRef<R, K>): this;
|
|
584
|
+
/** The last column gets a second line from `f`. */
|
|
585
|
+
secondLine<T>(f: FieldRef<R, T>): this;
|
|
586
|
+
/** The last column gets an avatar: a picture URL from `f`, else the value's initials. */
|
|
587
|
+
withAvatar<T>(f: FieldRef<R, T>): this;
|
|
588
|
+
/** Rows can be checked; `state` holds the checked keys. */
|
|
589
|
+
checks<K>(state: StateRef<K[]>, key: FieldRef<R, K>): this;
|
|
590
|
+
/** How many rows there are in all (`Showing 1–10 of 1,248`). */
|
|
591
|
+
count<T>(v: Val<T>): this;
|
|
592
|
+
/** The line over the compact rows (`412 of 1,248 orders · newest first`); the count alone when absent. */
|
|
593
|
+
countLabel(t: Txt): this;
|
|
594
|
+
/** The row as a list item where a table does not fit (`(r) => r.view(r.get(order.f.customer)).subtitle(..)`). */
|
|
595
|
+
compact(view: (r: RowRef<R>) => RowViewB<R>): this;
|
|
596
|
+
/** The row whose key is in this param is drawn selected (a record panel next to the list). */
|
|
597
|
+
selectedBy(param: ParamRef<any>, key: FieldRef<R, string>): this;
|
|
598
|
+
/** A tone for rows that match (first match wins). */
|
|
599
|
+
rowTone(when: Cond | ((r: RowRef<R>) => Cond), tone: Tone): this;
|
|
600
|
+
}
|
|
601
|
+
declare function table<R>(q: Q<any, R>): TableB<R>;
|
|
602
|
+
/** A list over a query's rows: a title per row, optionally a subtitle, meta, avatar, status. */
|
|
603
|
+
export declare class ListB<R> extends Node {
|
|
604
|
+
readonly __row: (r: R) => R;
|
|
605
|
+
private readonly rowActions;
|
|
606
|
+
constructor(query: string, title: string);
|
|
607
|
+
subtitle<T>(f: FieldRef<R, T>): this;
|
|
608
|
+
meta<T>(f: FieldRef<R, T>): this;
|
|
609
|
+
/** Meta shown as a relative time ("5 min ago"). */
|
|
610
|
+
metaRelative<T>(f: FieldRef<R, T>): this;
|
|
611
|
+
avatar<T>(f: FieldRef<R, T>): this;
|
|
612
|
+
icon(icon: string): this;
|
|
613
|
+
/** A row field naming the row's icon. */
|
|
614
|
+
iconField<T>(f: FieldRef<R, T>): this;
|
|
615
|
+
/** A quiet text before the meta (`×2`). */
|
|
616
|
+
aside(t: Txt): this;
|
|
617
|
+
/** The meta is money in a currency. */
|
|
618
|
+
moneyIn(code: string): this;
|
|
619
|
+
status<T>(f: FieldRef<R, T>, tones: Tones<T>): this;
|
|
620
|
+
open(action: ActionRef): this;
|
|
621
|
+
rowButton(node: Node | ((r: RowRef<R>) => Node)): this;
|
|
622
|
+
empty(t: Txt): this;
|
|
623
|
+
/** A filter box over the rows' titles with this placeholder; it filters the loaded rows, no request (catalog 3). */
|
|
624
|
+
search(placeholder: Txt): this;
|
|
625
|
+
/** A green dot after the title while this field is true (catalog 3). */
|
|
626
|
+
online(f: FieldRef<R, boolean>): this;
|
|
627
|
+
/** On a phone, the first `n` rows (1 to 100), then `Show all` (catalog 3). */
|
|
628
|
+
limit(n: number): this;
|
|
629
|
+
/** On a phone, a label over the rows in a card (`People · 9`; catalog 3). */
|
|
630
|
+
groupLabel(t: Txt): this;
|
|
631
|
+
}
|
|
632
|
+
declare function list<R, T>(q: Q<any, R>, title: FieldRef<R, T>): ListB<R>;
|
|
633
|
+
/** One label/value pair of `ui.fields` (`ui.item('Total', order.field(..)).moneyIn('USD')`). */
|
|
634
|
+
export declare class ItemB extends Built {
|
|
635
|
+
private readonly label;
|
|
636
|
+
private readonly v;
|
|
637
|
+
private format?;
|
|
638
|
+
private target?;
|
|
639
|
+
private avatarValue?;
|
|
640
|
+
constructor(label: Txt, v: Val<any>);
|
|
641
|
+
private setFormat;
|
|
642
|
+
moneyIn(code: string): this;
|
|
643
|
+
number(decimals?: number): this;
|
|
644
|
+
percent(decimals?: number): this;
|
|
645
|
+
date(): this;
|
|
646
|
+
datetime(): this;
|
|
647
|
+
relative(): this;
|
|
648
|
+
member(): this;
|
|
649
|
+
bool(): this;
|
|
650
|
+
mono(): this;
|
|
651
|
+
status(tones: Record<string, Tone>): this;
|
|
652
|
+
/** The value links to a screen (a chip with an arrow). */
|
|
653
|
+
link<P>(screen: ScreenKey<P>, a?: ArgsOf<P>): this;
|
|
654
|
+
/** The value drawn as a chip with initials. */
|
|
655
|
+
chip(): this;
|
|
656
|
+
/** The chip's picture URL or initials. */
|
|
657
|
+
chipAvatar<T>(v: Val<T>): this;
|
|
658
|
+
/** @internal */
|
|
659
|
+
json(): unknown;
|
|
660
|
+
}
|
|
661
|
+
/** Label/value pairs of one record. */
|
|
662
|
+
declare function fields(items: readonly ItemB[]): N;
|
|
663
|
+
declare function item<T>(label: Txt, v: Val<T>): ItemB;
|
|
664
|
+
declare function metric<T>(title: Txt, v: Val<T>): N;
|
|
665
|
+
/**
|
|
666
|
+
* A chart over a query's rows: the first charts (catalog 1), kept for compatibility. New screens use `ui.viz`
|
|
667
|
+
* (`ui.viz.bar.column()`, `ui.viz.line.line()`, …), which has every kind of the charts catalogue.
|
|
668
|
+
*/
|
|
669
|
+
export declare class ChartB<R> extends Node {
|
|
670
|
+
readonly __row: (r: R) => R;
|
|
671
|
+
private readonly seriesList;
|
|
672
|
+
constructor(kind: "bar" | "line" | "area" | "pie", query: string, x: string);
|
|
673
|
+
series<T>(f: FieldRef<R, T>, label: Txt): this;
|
|
674
|
+
title(t: Txt): this;
|
|
675
|
+
moneyIn(code: string): this;
|
|
676
|
+
number(decimals?: number): this;
|
|
677
|
+
percent(decimals?: number): this;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* A dashboard (catalog revision 2): cards on one shared 12-column grid. The items flow left to right and wrap when a
|
|
681
|
+
* row is full; every row is as tall as its tallest card, and a narrower screen widens the cards.
|
|
682
|
+
*
|
|
683
|
+
* ui.board().quarter(revenue).quarter(orders).half(target).full(ui.heading('Sales')).span(8, line).third(donut)
|
|
684
|
+
*
|
|
685
|
+
* A chart is placed on the board itself (it draws its own card). A board is not put inside another board, and holds
|
|
686
|
+
* at most 60 items. An older client (catalog 1) draws the board's `.fallback(..)`.
|
|
687
|
+
*/
|
|
688
|
+
export declare class BoardB extends Node {
|
|
689
|
+
private readonly items;
|
|
690
|
+
constructor();
|
|
691
|
+
/** An item `columns` wide, of the grid's 12. */
|
|
692
|
+
span(columns: number, n: Node): this;
|
|
693
|
+
/** An item of the full width: a wide chart, a table, a heading between groups. */
|
|
694
|
+
full(n: Node): this;
|
|
695
|
+
/** An item of half the width (6 columns). */
|
|
696
|
+
half(n: Node): this;
|
|
697
|
+
/** An item of a third of the width (4 columns). */
|
|
698
|
+
third(n: Node): this;
|
|
699
|
+
/** An item of a quarter of the width (3 columns): a row of four metrics. */
|
|
700
|
+
quarter(n: Node): this;
|
|
701
|
+
}
|
|
702
|
+
declare function board(): BoardB;
|
|
703
|
+
/** A family of the charts catalogue (`line`, `bar`, `figure`, …). */
|
|
704
|
+
export type VizFamily = keyof typeof VIZ_KINDS;
|
|
705
|
+
/** A kind of a family (`VizKind<'bar'>` is `'bar' | 'column' | …`). */
|
|
706
|
+
export type VizKind<F extends VizFamily> = (typeof VIZ_KINDS)[F][number];
|
|
707
|
+
/** How a column's cells (or a pivot's labels) are read. */
|
|
708
|
+
export type VizAs = "number" | "text" | "date";
|
|
709
|
+
/** Where a `viz` option's data comes from (one key: `column`, `series`, `pivot`, `rows` or `value`). */
|
|
710
|
+
export type VizSource = Record<string, any>;
|
|
711
|
+
/**
|
|
712
|
+
* A chart or a figure of the charts catalogue (catalog revision 2): a kind of a family, its static options and the
|
|
713
|
+
* data bound into them from the screen's queries.
|
|
714
|
+
*
|
|
715
|
+
* ui.viz.line.line().title('Revenue').range('Last 30 days').option('fmt', 'money')
|
|
716
|
+
* .dates(sales, day.f.day).values(sales, day.f.total).open(ORDERS)
|
|
717
|
+
*
|
|
718
|
+
* The data methods add a bind each, in order; `.to(..)`, `.asText()`, `.asDate()` and `.textKeys(..)` change the
|
|
719
|
+
* bind just added. A chart draws its own card: place it on a `ui.board()`, in columns or in a stack, not next to
|
|
720
|
+
* other children of a card or a section. An older client (catalog 1) draws the node's `.fallback(..)`.
|
|
721
|
+
*/
|
|
722
|
+
export declare class VizB extends Node {
|
|
723
|
+
private readonly binds;
|
|
724
|
+
constructor(family: string, kind: string);
|
|
725
|
+
title(t: Txt): this;
|
|
726
|
+
/** The muted text at the right of the head (`Last 30 days`). */
|
|
727
|
+
range(t: Txt): this;
|
|
728
|
+
/** The height in px (16 to 1200); the kind's own height when not set. */
|
|
729
|
+
height(px: number): this;
|
|
730
|
+
/** A static option of the kind: `.option('fmt', 'money')`, `.option('bands', [50, 80])`. */
|
|
731
|
+
option(name: string, value: unknown): this;
|
|
732
|
+
/** Several static options at once: `.options({ fmt: 'money', curve: 'smooth' })`. */
|
|
733
|
+
options(options: Record<string, unknown>): this;
|
|
734
|
+
/** A bind written by hand (the typed methods below cover the sources). */
|
|
735
|
+
bind(to: string, from: VizSource): this;
|
|
736
|
+
private last;
|
|
737
|
+
/**
|
|
738
|
+
* A row field of every row, as an array in the option `to`. Numbers and numeric strings become numbers;
|
|
739
|
+
* `.asText()` keeps strings, `.asDate()` makes short date labels.
|
|
740
|
+
*/
|
|
741
|
+
column<R, T>(to: string, q: Q<any, R>, f: FieldRef<R, T>): this;
|
|
742
|
+
/** The `labels` (the x positions or the row names) from a row field, kept as text. */
|
|
743
|
+
labels<R, T>(q: Q<any, R>, f: FieldRef<R, T>): this;
|
|
744
|
+
/** The `labels` from a date or timestamp field, as short dates (`Nov 4`). */
|
|
745
|
+
dates<R, T>(q: Q<any, R>, f: FieldRef<R, T>): this;
|
|
746
|
+
/** The `values` (one series) from a row field. */
|
|
747
|
+
values<R, T>(q: Q<any, R>, f: FieldRef<R, T>): this;
|
|
748
|
+
/**
|
|
749
|
+
* One more series of the option `series`: the row field with its name in the legend. Calls one after another
|
|
750
|
+
* over the same query (also after `.series(..)`) make one bind.
|
|
751
|
+
*/
|
|
752
|
+
serie<R, T>(q: Q<any, R>, f: FieldRef<R, T>, label: Txt): this;
|
|
753
|
+
/** The option `series`, one series per row field: `.series(q, [[day.f.online, 'Online'], [day.f.retail, 'Retail']])`. */
|
|
754
|
+
series<R>(q: Q<any, R>, fields: readonly (readonly [FieldRef<R, any>, Txt])[]): this;
|
|
755
|
+
/**
|
|
756
|
+
* Long rows to wide: `labels` gets the distinct values of `x` in row order, the option `series` one series per
|
|
757
|
+
* distinct value of `series`, with `value` in its cells (`.asDate()` makes the labels short dates).
|
|
758
|
+
*/
|
|
759
|
+
pivot<R>(q: Q<any, R>, x: FieldRef<R, any>, series: FieldRef<R, any>, value: FieldRef<R, any>): this;
|
|
760
|
+
/**
|
|
761
|
+
* The option `rows`: an object per row with the keys given, each from a row field:
|
|
762
|
+
* `.rows(top, { name: product.f.title, value: product.f.revenue })`. Numeric strings become numbers except under
|
|
763
|
+
* the keys named by `.textKeys(..)`.
|
|
764
|
+
*/
|
|
765
|
+
rows<R>(q: Q<any, R>, map: Record<string, FieldRef<R, any>>): this;
|
|
766
|
+
/** The keys of the `rows` bind just added that stay text (a product named `2024` is not a number). */
|
|
767
|
+
textKeys(keys: readonly string[]): this;
|
|
768
|
+
/**
|
|
769
|
+
* One value in the option `to` (a name or a dotted path: `center.value`): a query's field
|
|
770
|
+
* (`summary.field(summaryResponse.f.revenue)`), a state, a param or a literal.
|
|
771
|
+
*/
|
|
772
|
+
value(to: string, v: ValueLike<unknown>): this;
|
|
773
|
+
/** Another option for the bind just added: `.rows(q, ..).to('parts')`, `.series(q, ..).to('groups')`. */
|
|
774
|
+
to(to: string): this;
|
|
775
|
+
private cast;
|
|
776
|
+
/** The `column` just added keeps its cells as text (the labels of a `pivot` too). */
|
|
777
|
+
asText(): this;
|
|
778
|
+
/** The `column` just added (or the labels of the `pivot`) holds ISO dates or datetimes: they become short labels. */
|
|
779
|
+
asDate(): this;
|
|
780
|
+
/**
|
|
781
|
+
* The state that receives what the member picks in the chart (a bar, a slice, a row): the picked value, or null
|
|
782
|
+
* when nothing is picked. Queries and conditions of the screen read it like any state.
|
|
783
|
+
*/
|
|
784
|
+
selectState(state: StateRef<any>): this;
|
|
785
|
+
/** The same, into a param of the screen (it is in the URL). */
|
|
786
|
+
selectParam(param: ParamRef<any>): this;
|
|
787
|
+
/** The screen the card's link leads to, with its params like `ui.link` (a literal, a param, a state): `.open(ORDERS, { status: 'paid' })`. */
|
|
788
|
+
open<P>(screen: ScreenKey<P>, a?: ArgsOf<P>): this;
|
|
789
|
+
}
|
|
790
|
+
/** A constructor per kind of the charts catalogue, by family. */
|
|
791
|
+
export type VizCatalogue = {
|
|
792
|
+
readonly [F in VizFamily]: {
|
|
793
|
+
readonly [K in VizKind<F>]: () => VizB;
|
|
794
|
+
};
|
|
795
|
+
};
|
|
796
|
+
/** A chart or figure by the names of its family and kind (a pair the catalogue has; `plugin check` says when not). */
|
|
797
|
+
declare function vizOf<F extends VizFamily>(family: F, kind: VizKind<F>): VizB;
|
|
798
|
+
declare function vizOf(family: string, kind: string): VizB;
|
|
799
|
+
/** A timeline over a query's rows: text, time and optionally the actor. */
|
|
800
|
+
export declare class TimelineB<R> extends Node {
|
|
801
|
+
readonly __row: (r: R) => R;
|
|
802
|
+
constructor(query: string, text: string, time: string);
|
|
803
|
+
actor<T>(f: FieldRef<R, T>): this;
|
|
804
|
+
/** The actor's picture URL (else initials). */
|
|
805
|
+
avatar<T>(f: FieldRef<R, T>): this;
|
|
806
|
+
/** A row field with an icon name for actors without a face. */
|
|
807
|
+
icon<T>(f: FieldRef<R, T>): this;
|
|
808
|
+
/** Times as `2 min`, `40 min`, `2 h`. */
|
|
809
|
+
shortTime(): this;
|
|
810
|
+
tone<T>(f: FieldRef<R, T>, tones: Tones<T>): this;
|
|
811
|
+
}
|
|
812
|
+
declare function timeline<R, A, B>(q: Q<any, R>, text: FieldRef<R, A>, time: FieldRef<R, B>): TimelineB<R>;
|
|
813
|
+
declare function status<T>(v: Val<T>, tones?: Tones<T>): N;
|
|
814
|
+
declare function tag(t: Txt): N;
|
|
815
|
+
declare function avatar<T>(v: Val<T>): N;
|
|
816
|
+
declare function avatarStack<T>(v: Val<T>): N;
|
|
817
|
+
declare function meter<A, B>(v: Val<A>, max: Val<B>): N;
|
|
818
|
+
/** A fraction 0..1. */
|
|
819
|
+
declare function progress<T>(v: Val<T>): N;
|
|
820
|
+
/** `ui.text(key, en)`: a catalog text; `ui.text(text)`: a body text primitive. */
|
|
821
|
+
declare function text(key: string, en: string, args?: Record<string, ValueLike<unknown>>): TextKey;
|
|
822
|
+
declare function text(t: Txt): N;
|
|
823
|
+
declare function heading(t: Txt): N;
|
|
824
|
+
declare function caption(t: Txt): N;
|
|
825
|
+
declare function mono(t: Txt): N;
|
|
826
|
+
declare function copyField<T>(label: Txt, v: Val<T>): N;
|
|
827
|
+
declare function empty(title: Txt, t?: Txt): N;
|
|
828
|
+
declare function notice(tone: NoticeTone, t: Txt): N;
|
|
829
|
+
/** A button running an action (`ui.button('Cancel', cancel)` or `ui.button('Cancel').run(cancel)`). */
|
|
830
|
+
declare function button(label: Txt, action?: ActionRef): N;
|
|
831
|
+
declare function iconButton(icon: string, label: Txt, action: ActionRef): N;
|
|
832
|
+
/** A menu item running an action. */
|
|
833
|
+
export declare class MenuItemB extends Built {
|
|
834
|
+
private readonly m;
|
|
835
|
+
constructor(label: Txt, action: ActionRef);
|
|
836
|
+
danger(): this;
|
|
837
|
+
icon(icon: string): this;
|
|
838
|
+
/** Shown only when the condition holds. */
|
|
839
|
+
when(c: Cond): this;
|
|
840
|
+
enabled(c: Cond): this;
|
|
841
|
+
/** Starts a new group with this title. */
|
|
842
|
+
section(t: Txt): this;
|
|
843
|
+
/** @internal */
|
|
844
|
+
json(): unknown;
|
|
845
|
+
}
|
|
846
|
+
declare function menuItem(label: Txt, action: ActionRef): MenuItemB;
|
|
847
|
+
declare function menu(items: readonly MenuItemB[]): N;
|
|
848
|
+
/** A form or filter input. */
|
|
849
|
+
export declare class InputB extends Built {
|
|
850
|
+
readonly i: Record<string, unknown>;
|
|
851
|
+
constructor(/** @internal */ i: Record<string, unknown>);
|
|
852
|
+
required(): this;
|
|
853
|
+
help(t: Txt): this;
|
|
854
|
+
placeholder(t: Txt): this;
|
|
855
|
+
initial<T>(v: Val<T>): this;
|
|
856
|
+
/** A literal option of a select, multi-select or radio cards. */
|
|
857
|
+
option(v: unknown, label: Txt): this;
|
|
858
|
+
/** `repeat`: rows at least / at most. */
|
|
859
|
+
items(min?: number, max?: number): this;
|
|
860
|
+
/** A filter chip's icon. */
|
|
861
|
+
icon(icon: string): this;
|
|
862
|
+
/** Shares its line with the next half input. */
|
|
863
|
+
half(): this;
|
|
864
|
+
/** A number with − and + buttons. */
|
|
865
|
+
stepper(): this;
|
|
866
|
+
/** `repeat`: a value at the end of each row from the i-th row of `q` (a line total from a quote). */
|
|
867
|
+
aside<R, V>(title: Txt, q: Q<any, R>, f: FieldRef<R, V>, moneyIn: string): this;
|
|
868
|
+
/** `repeat`: the add row's label. */
|
|
869
|
+
addLabel(t: Txt): this;
|
|
870
|
+
/** @internal */
|
|
871
|
+
json(): unknown;
|
|
872
|
+
}
|
|
873
|
+
/** Inputs that set params (a filter bar over a list screen). */
|
|
874
|
+
declare function filterBar(inputs: readonly InputB[]): N;
|
|
875
|
+
/** The inputs of a form over `Req`. */
|
|
876
|
+
export declare class FormB<Req> {
|
|
877
|
+
readonly __request: (r: Req) => Req;
|
|
878
|
+
/** @internal */ readonly sections: {
|
|
879
|
+
title?: unknown;
|
|
880
|
+
inputs: InputB[];
|
|
881
|
+
}[];
|
|
882
|
+
/** @internal */ cancelLabel?: unknown;
|
|
883
|
+
/** @internal */ phoneSubmitLabel?: unknown;
|
|
884
|
+
/** @internal */ summaryValue?: Record<string, unknown>;
|
|
885
|
+
/** @internal */ noteText?: unknown;
|
|
886
|
+
/** @internal */ alternateButton?: {
|
|
887
|
+
label: unknown;
|
|
888
|
+
chain: Chain;
|
|
889
|
+
};
|
|
890
|
+
/** @internal */ readonly notes: {
|
|
891
|
+
text: unknown;
|
|
892
|
+
visible?: Cond;
|
|
893
|
+
}[];
|
|
894
|
+
private input;
|
|
895
|
+
/** Starts a titled section. */
|
|
896
|
+
section(title: Txt): this;
|
|
897
|
+
cancel(label: Txt): this;
|
|
898
|
+
/** The submit button's label on a phone, where the form is a sheet (absent: the submit label). */
|
|
899
|
+
phoneSubmit(label: Txt): this;
|
|
900
|
+
text<T>(f: FieldRef<Req, T>, label: Txt): InputB;
|
|
901
|
+
textarea<T>(f: FieldRef<Req, T>, label: Txt): InputB;
|
|
902
|
+
number<T>(f: FieldRef<Req, T>, label: Txt): InputB;
|
|
903
|
+
money<T>(f: FieldRef<Req, T>, label: Txt): InputB;
|
|
904
|
+
date<T>(f: FieldRef<Req, T>, label: Txt): InputB;
|
|
905
|
+
datetime<T>(f: FieldRef<Req, T>, label: Txt): InputB;
|
|
906
|
+
checkbox(f: FieldRef<Req, boolean>, label: Txt): InputB;
|
|
907
|
+
switch(f: FieldRef<Req, boolean>, label: Txt): InputB;
|
|
908
|
+
member<T>(f: FieldRef<Req, T>, label: Txt): InputB;
|
|
909
|
+
upload<T>(f: FieldRef<Req, T>, label: Txt): InputB;
|
|
910
|
+
search<T>(f: FieldRef<Req, T>, label: Txt): InputB;
|
|
911
|
+
/** A select over an enum's values (or `.option(..)`). */
|
|
912
|
+
select<T>(f: FieldRef<Req, T>, label: Txt): InputB;
|
|
913
|
+
/** A multi-select over a repeated enum's values (or `.option(..)`). */
|
|
914
|
+
multiSelect<T>(f: FieldRef<Req, T>, label: Txt): InputB;
|
|
915
|
+
/** Radio cards over an enum's values. */
|
|
916
|
+
radio<T>(f: FieldRef<Req, T>, label: Txt): InputB;
|
|
917
|
+
/** A select whose options come from a query's rows. */
|
|
918
|
+
selectFrom<T, R, V, L>(f: FieldRef<Req, T>, label: Txt, q: Q<any, R>, v: FieldRef<R, V>, shown: FieldRef<R, L>): InputB;
|
|
919
|
+
/** Rows of a repeated message field (`Items`: product, quantity per row). */
|
|
920
|
+
repeat<T>(f: FieldRef<Req, T[]>, label: Txt, row: (r: RowForm<T>) => unknown): InputB;
|
|
921
|
+
/** A total under the inputs. */
|
|
922
|
+
summary<T>(title: Txt, caption: Txt | undefined, v: Val<T>, moneyIn: string): this;
|
|
923
|
+
/** A line next to the buttons. */
|
|
924
|
+
note(t: Txt): this;
|
|
925
|
+
/** A second button that sends the values another way (`Save draft`). */
|
|
926
|
+
alternate(label: Txt, build: (a: Chain) => unknown): this;
|
|
927
|
+
/**
|
|
928
|
+
* Chips over a directory (catalog 3): the rows of `q`, each chosen by `value` and drawn with `title`. The field gets
|
|
929
|
+
* the chosen values joined with `, `; `ui.pickedCount(f)`, `ui.pickedAgents(f)` and `ui.pickedFirst(f)` read the
|
|
930
|
+
* choice in conditions and texts, `ui.pickedQuery(f)` what is typed (in the `empty` text).
|
|
931
|
+
*/
|
|
932
|
+
pick<T, R, V, L>(f: FieldRef<Req, T>, label: Txt, q: Q<any, R>, value: FieldRef<R, V>, title: FieldRef<R, L>): PickB<R>;
|
|
933
|
+
/** A line under the inputs while `c` (over the form's values) holds (catalog 3). */
|
|
934
|
+
noteWhen(t: Txt, c: Cond): this;
|
|
935
|
+
}
|
|
936
|
+
/** A `pick` input: its directory's fields and texts (catalog 3). */
|
|
937
|
+
export declare class PickB<R> extends InputB {
|
|
938
|
+
readonly __row: (r: R) => R;
|
|
939
|
+
private pick;
|
|
940
|
+
avatar<T>(f: FieldRef<R, T>): this;
|
|
941
|
+
/** A bool field: the row is an agent (drawn with its tile; counted by `ui.pickedAgents`). */
|
|
942
|
+
agent(f: FieldRef<R, boolean>): this;
|
|
943
|
+
/** The agent tile: the glyph and the engine. */
|
|
944
|
+
tile<A, B>(icon: FieldRef<R, A>, engine: FieldRef<R, B>): this;
|
|
945
|
+
detail<T>(f: FieldRef<R, T>): this;
|
|
946
|
+
/** The rows are grouped by this field. */
|
|
947
|
+
section<T>(f: FieldRef<R, T>): this;
|
|
948
|
+
/** A list value of values not offered (the members already in). */
|
|
949
|
+
exclude<T>(v: ValueLike<T>): this;
|
|
950
|
+
/** The line when nothing matches the typed text, and when every row is chosen. */
|
|
951
|
+
empty(nothing: Txt, all: Txt): this;
|
|
952
|
+
}
|
|
953
|
+
/** The inputs of one row of a `repeat`. */
|
|
954
|
+
export declare class RowForm<T> {
|
|
955
|
+
readonly __row: (r: T) => T;
|
|
956
|
+
/** @internal */ readonly inputs: InputB[];
|
|
957
|
+
private push;
|
|
958
|
+
/** A select from a query's rows. */
|
|
959
|
+
selectFrom<V, R, A, L>(f: FieldRef<T, V>, label: Txt, q: Q<any, R>, value: FieldRef<R, A>, shown: FieldRef<R, L>): this;
|
|
960
|
+
/** A number with − and + buttons, starting at `initial`. */
|
|
961
|
+
stepper<V>(f: FieldRef<T, V>, label: Txt, initial: number): this;
|
|
962
|
+
}
|
|
963
|
+
/** A sidebar entry: a screen with its params, an optional icon and badge. */
|
|
964
|
+
export declare class EntryB extends Built {
|
|
965
|
+
private readonly screen;
|
|
966
|
+
private readonly title;
|
|
967
|
+
private readonly args;
|
|
968
|
+
private iconName?;
|
|
969
|
+
private badgeValue?;
|
|
970
|
+
private alertBadge;
|
|
971
|
+
/** @internal */ badgeQuery?: QueryJson;
|
|
972
|
+
constructor(screen: ScreenKey<any>, title: Txt, args: ArgJson[]);
|
|
973
|
+
icon(icon: string): this;
|
|
974
|
+
/** A count from a document-level query (`badge_<field>`), live through the topics it follows. */
|
|
975
|
+
badge<Req, Resp, Row, T>(def: QueryDef<Req, Resp, Row>, count: FieldRef<Resp, T>): this;
|
|
976
|
+
/** The badge asks for attention (a filled pill) instead of a quiet count. */
|
|
977
|
+
alert(): this;
|
|
978
|
+
/** @internal */ rowsJson?: Record<string, unknown>;
|
|
979
|
+
/** Rows: each row's icon field (`hash`, an agent's `bot`). */
|
|
980
|
+
rowIcon<R, T>(f: FieldRef<R, T>): this;
|
|
981
|
+
/** Rows: the unread count of each row (its label turns bold) and the viewer's mentions (an amber pill). */
|
|
982
|
+
unread<R, T, M>(unread: FieldRef<R, T>, mentions: FieldRef<R, M>): this;
|
|
983
|
+
/** Rows: how many show before "Show all" (1 to 20). */
|
|
984
|
+
limit(n: number): this;
|
|
985
|
+
/** Rows: an add row under them (`New channel`) that opens a document-level overlay. */
|
|
986
|
+
add<P>(title: Txt, overlay: OverlayKey<P>): this;
|
|
987
|
+
/** @internal */
|
|
988
|
+
json(): unknown;
|
|
989
|
+
}
|
|
990
|
+
declare function entry<P>(screen: ScreenKey<P>, title: Txt, a?: ArgsOf<P>): EntryB;
|
|
991
|
+
/** Entries from a query's rows (channels, direct messages): `ui.entryRows('Channels', def, channel.f.name, CHANNEL,
|
|
992
|
+
* { c: ui.rowValue(channel.f.id) })`, five shown before "Show all". */
|
|
993
|
+
declare function entryRows<Req, Resp, R, L, P>(title: Txt, def: QueryDef<Req, Resp, R>, label: FieldRef<R, L>, screen: ScreenKey<P>, a?: ArgsOf<P>): EntryB;
|
|
994
|
+
/** A sidebar group: `ui.nav('Orders', 'shopping-bag', [ui.entry(..)])`. */
|
|
995
|
+
export declare class NavB extends Built {
|
|
996
|
+
private readonly title;
|
|
997
|
+
private iconName?;
|
|
998
|
+
/** @internal */ readonly entries: EntryB[];
|
|
999
|
+
constructor(title: Txt, icon?: string, entries?: readonly EntryB[]);
|
|
1000
|
+
icon(icon: string): this;
|
|
1001
|
+
entry(e: EntryB): this;
|
|
1002
|
+
/** @internal */
|
|
1003
|
+
json(): unknown;
|
|
1004
|
+
}
|
|
1005
|
+
declare function nav(title: Txt, icon?: string, entries?: readonly EntryB[]): NavB;
|
|
1006
|
+
/** A command-palette entry. */
|
|
1007
|
+
export declare class CommandB extends Built {
|
|
1008
|
+
private readonly id;
|
|
1009
|
+
private readonly title;
|
|
1010
|
+
private readonly target;
|
|
1011
|
+
private iconName?;
|
|
1012
|
+
constructor(id: string, title: Txt, target: Record<string, unknown>);
|
|
1013
|
+
icon(icon: string): this;
|
|
1014
|
+
/** @internal */
|
|
1015
|
+
json(): unknown;
|
|
1016
|
+
}
|
|
1017
|
+
/** The builder a home widget's function gets: its queries are document-level (`home_<id>_<name>`). */
|
|
1018
|
+
export declare class WidgetBuilder {
|
|
1019
|
+
private readonly prefix;
|
|
1020
|
+
/** @internal */ readonly queries: QueryJson[];
|
|
1021
|
+
constructor(prefix: string);
|
|
1022
|
+
query<Req, Resp, Row>(name: string, def: QueryDef<Req, Resp, Row>): Q<Resp, Row>;
|
|
1023
|
+
}
|
|
1024
|
+
/** A workspace home widget. */
|
|
1025
|
+
export declare class HomeB {
|
|
1026
|
+
readonly id: string;
|
|
1027
|
+
private readonly title;
|
|
1028
|
+
private readonly build;
|
|
1029
|
+
private target?;
|
|
1030
|
+
constructor(id: string, title: Txt, build: (w: WidgetBuilder) => Node);
|
|
1031
|
+
/** The screen the widget opens. */
|
|
1032
|
+
opens<P>(screen: ScreenKey<P>, a?: ArgsOf<P>): this;
|
|
1033
|
+
/** @internal */
|
|
1034
|
+
json(): {
|
|
1035
|
+
widget: unknown;
|
|
1036
|
+
queries: QueryJson[];
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
declare function home(id: string, title: Txt, build: (w: WidgetBuilder) => Node): HomeB;
|
|
1040
|
+
export interface UiOptions {
|
|
1041
|
+
/** Sidebar groups; their entries' badge queries become document-level queries. */
|
|
1042
|
+
nav?: readonly NavB[];
|
|
1043
|
+
/** The screen the plugin opens on; it takes no required param (`E_UI_LANDING`). Without it, the client opens the
|
|
1044
|
+
* screen of the navigation's first entry that has one. */
|
|
1045
|
+
landing?: ScreenKey<any>;
|
|
1046
|
+
home?: readonly HomeB[];
|
|
1047
|
+
commands?: readonly CommandB[];
|
|
1048
|
+
screens?: readonly ScreenDef<any>[];
|
|
1049
|
+
/** Overlays opened from anywhere (a command, a nav "add" row). */
|
|
1050
|
+
overlays?: readonly OverlayDef<any>[];
|
|
1051
|
+
/** Records the command palette finds (`ui.search('Orders', findOrders, findRequest.f.text, findResponse.f.orders)`). */
|
|
1052
|
+
search?: readonly SearchB<any>[];
|
|
1053
|
+
/** Texts in other locales: `{ de: { 'nav.all': 'Alle Bestellungen' } }` (`en` comes from `ui.text(key, en)`). */
|
|
1054
|
+
texts?: Record<string, Record<string, string>>;
|
|
1055
|
+
}
|
|
1056
|
+
/** The plugin's UI, for `plugin({ ui })`. */
|
|
1057
|
+
export declare class UiDoc {
|
|
1058
|
+
/** @internal */ readonly tree: Record<string, unknown>;
|
|
1059
|
+
/** @internal */ readonly texts: Record<string, Record<string, string>>;
|
|
1060
|
+
constructor(
|
|
1061
|
+
/** @internal */ tree: Record<string, unknown>,
|
|
1062
|
+
/** @internal */ texts: Record<string, Record<string, string>>);
|
|
1063
|
+
}
|
|
1064
|
+
/** The plugin's UI: `ui.define({ nav, screens, commands, home, overlays })`. Screens are built here, in order. */
|
|
1065
|
+
declare function define(options: UiOptions): UiDoc;
|
|
1066
|
+
/** @internal The document as the descriptor carries it: deferred parts resolved, texts collected. */
|
|
1067
|
+
export declare function resolveUi(doc: UiDoc, r: UiResolver): Record<string, unknown>;
|
|
1068
|
+
/** A row as a list item: `r.view(r.get(order.f.customer)).subtitle(..).meta(..)` (a compact table row, a search result). */
|
|
1069
|
+
export declare class RowViewB<R> extends Built {
|
|
1070
|
+
readonly __row: (r: R) => R;
|
|
1071
|
+
private readonly v;
|
|
1072
|
+
constructor(title: Txt);
|
|
1073
|
+
subtitle(t: Txt): this;
|
|
1074
|
+
meta<T>(v: Val<T>): this;
|
|
1075
|
+
/** The meta is money in the row's currency field. */
|
|
1076
|
+
money<C>(currency: FieldRef<R, C>): this;
|
|
1077
|
+
avatar<T>(f: FieldRef<R, T>): this;
|
|
1078
|
+
icon(icon: string): this;
|
|
1079
|
+
status<T>(f: FieldRef<R, T>, tones: Tones<T>): this;
|
|
1080
|
+
/** @internal */
|
|
1081
|
+
json(): unknown;
|
|
1082
|
+
}
|
|
1083
|
+
/** A row as a list item; inside `compact`/`item` callbacks `r.view(..)` infers the row type. */
|
|
1084
|
+
declare function rowView<R>(title: Txt): RowViewB<R>;
|
|
1085
|
+
/** The head of a record: `ui.recordHeader(title).short(..).subtitle(..).tags([..]).actions([..]).menu([..])`. */
|
|
1086
|
+
export declare class RecordHeaderB extends Node {
|
|
1087
|
+
constructor(title: Txt);
|
|
1088
|
+
/** The top bar's title on a phone (`#1048`). */
|
|
1089
|
+
short(t: Txt): this;
|
|
1090
|
+
subtitle(t: Txt): this;
|
|
1091
|
+
/** The heading and the line under it on a phone. */
|
|
1092
|
+
compact(title: Txt, subtitle: Txt): this;
|
|
1093
|
+
/** Status chips next to the title. */
|
|
1094
|
+
tags(nodes: readonly Node[]): this;
|
|
1095
|
+
/** Buttons under the title. */
|
|
1096
|
+
actions(nodes: readonly Node[]): this;
|
|
1097
|
+
/** More actions (`…`). */
|
|
1098
|
+
menu(items: readonly MenuItemB[]): this;
|
|
1099
|
+
/** The action of the panel's expand button. */
|
|
1100
|
+
expand(action: ActionRef): this;
|
|
1101
|
+
/** The action of the panel's close button. */
|
|
1102
|
+
close(action: ActionRef): this;
|
|
1103
|
+
}
|
|
1104
|
+
declare function recordHeader(title: Txt): RecordHeaderB;
|
|
1105
|
+
/** An agent's run on a record: who, its state, its steps, Stop and a message box. */
|
|
1106
|
+
export declare class AgentRunB<Resp> extends Node {
|
|
1107
|
+
readonly __response: (r: Resp) => Resp;
|
|
1108
|
+
constructor(body: Record<string, unknown>);
|
|
1109
|
+
/** The line under the agent's name. */
|
|
1110
|
+
subtitle<T>(f: FieldRef<Resp, T>): this;
|
|
1111
|
+
/** A Stop button, shown while `when` holds. */
|
|
1112
|
+
stop(action: ActionRef, when: Cond): this;
|
|
1113
|
+
/** A message box; the action reads the text as `ui.formValue(..)` of the field `text`. */
|
|
1114
|
+
message(placeholder: Txt, action: ActionRef): this;
|
|
1115
|
+
/** What the run needs from the viewer, first and in amber: the request (a run field, empty when nothing is needed)
|
|
1116
|
+
* and one button; `due` is the deadline next to it (`by 11:30`). */
|
|
1117
|
+
needs<T, D>(text: FieldRef<Resp, T>, label: Txt, action: ActionRef, due?: FieldRef<Resp, D>): this;
|
|
1118
|
+
/** Opens the run's session page; the card then shows the current step instead of the step list. */
|
|
1119
|
+
open(label: Txt, action: ActionRef): this;
|
|
1120
|
+
/** The changes the run made to this record: `changes('Changes to this order', run.f.changes, change.f.text)`. */
|
|
1121
|
+
changes<C, T>(title: Txt, field: FieldRef<Resp, C[]>, text: FieldRef<C, T>): this;
|
|
1122
|
+
/** The agent's earlier sessions on this record: a run field with the line, hidden while empty, and its action. */
|
|
1123
|
+
earlier<T>(text: FieldRef<Resp, T>, action: ActionRef): this;
|
|
1124
|
+
/** The run's full log in a panel (catalog 3): the head, every step, the note. */
|
|
1125
|
+
log(): this;
|
|
1126
|
+
/** The agent's tile in the log's head: response fields with the glyph and the engine (catalog 3). */
|
|
1127
|
+
tile<A, B>(icon: FieldRef<Resp, A>, engine: FieldRef<Resp, B>): this;
|
|
1128
|
+
/** The status's label in the log's head (catalog 3). */
|
|
1129
|
+
statusLabel<T>(f: FieldRef<Resp, T>): this;
|
|
1130
|
+
/** The current step's label in the log's head (catalog 3). */
|
|
1131
|
+
stepLabel<T>(f: FieldRef<Resp, T>): this;
|
|
1132
|
+
/** How long the run has worked, in the log's head (catalog 3). */
|
|
1133
|
+
elapsed<T>(f: FieldRef<Resp, T>): this;
|
|
1134
|
+
/** The line under the steps while the run is not live (catalog 3). */
|
|
1135
|
+
note<T>(f: FieldRef<Resp, T>): this;
|
|
1136
|
+
/** While this holds the run is live (no note; catalog 3). */
|
|
1137
|
+
liveWhen(c: Cond): this;
|
|
1138
|
+
/** A step's detail line (a field of a step; catalog 3). */
|
|
1139
|
+
stepDetail<S, T>(f: FieldRef<S, T>): this;
|
|
1140
|
+
/** A step's time (catalog 3). */
|
|
1141
|
+
stepTime<S, T>(f: FieldRef<S, T>): this;
|
|
1142
|
+
/** A step's call, drawn as a process row's (catalog 3). */
|
|
1143
|
+
stepTool<S, T>(f: FieldRef<S, T>): this;
|
|
1144
|
+
/** A step's evidence (catalog 3). */
|
|
1145
|
+
stepEvidence<S, T>(f: FieldRef<S, T>): this;
|
|
1146
|
+
/** A step's lines (catalog 3). */
|
|
1147
|
+
stepLines<S, T>(f: FieldRef<S, T>): this;
|
|
1148
|
+
}
|
|
1149
|
+
/** `ui.agentRun(run, runResponse.f.agent, runResponse.f.status, tones, runResponse.f.steps, step.f.text, step.f.state)`. */
|
|
1150
|
+
declare function agentRun<Resp, A, E, S, B, C>(q: Q<Resp, any>, title: FieldRef<Resp, A>, status: FieldRef<Resp, E>, tones: Tones<E>, steps: FieldRef<Resp, S[]>, stepText: FieldRef<S, B>, stepState: FieldRef<S, C>): AgentRunB<Resp>;
|
|
1151
|
+
/** A conversation (a channel, a thread, a direct message): its messages oldest first, a card per message and a
|
|
1152
|
+
* message box. */
|
|
1153
|
+
export declare class ConversationB<R> extends Node {
|
|
1154
|
+
readonly __row: (r: R) => R;
|
|
1155
|
+
constructor(query: string, author: string, text: string, time: string);
|
|
1156
|
+
private cardBody;
|
|
1157
|
+
/** The author's picture URL (else their initials). */
|
|
1158
|
+
avatar<T>(f: FieldRef<R, T>): this;
|
|
1159
|
+
/** An icon name for authors without a face (an agent: `bot`). */
|
|
1160
|
+
icon<T>(f: FieldRef<R, T>): this;
|
|
1161
|
+
/** A small chip after the author (`AGENT`). */
|
|
1162
|
+
badge<T>(f: FieldRef<R, T>): this;
|
|
1163
|
+
/** A quiet line after the time (`via Commerce`). */
|
|
1164
|
+
via<T>(f: FieldRef<R, T>): this;
|
|
1165
|
+
/** A chip before the text (`To people`). */
|
|
1166
|
+
tag<T>(f: FieldRef<R, T>): this;
|
|
1167
|
+
/** The receipt under a message (`Applied · step 3`), toned by a field. */
|
|
1168
|
+
receipt<T, E>(text: FieldRef<R, T>, tone: FieldRef<R, E>, tones: Tones<E>): this;
|
|
1169
|
+
/** A card under the message, shown while its title is not empty, with its text. */
|
|
1170
|
+
card<A, B>(title: FieldRef<R, A>, text: FieldRef<R, B>): this;
|
|
1171
|
+
/** The card's band and its aside (`by 11:30`), toned by a field. */
|
|
1172
|
+
cardBand<A, B, E>(band: FieldRef<R, A>, aside: FieldRef<R, B>, tone: FieldRef<R, E>, tones: Tones<E>): this;
|
|
1173
|
+
/** The card's footer line (`14 replies · last 10:58`). */
|
|
1174
|
+
cardFooter<T>(f: FieldRef<R, T>): this;
|
|
1175
|
+
/** The card's button: its label is a row field (hidden while empty), the action runs on the row. */
|
|
1176
|
+
cardButton<T>(label: FieldRef<R, T>, action: ActionRef): this;
|
|
1177
|
+
/** The message box; its action reads `ui.formValue(..)` of the fields `text` and, with addressees, `to`. */
|
|
1178
|
+
composer(placeholder: Txt, action: ActionRef): this;
|
|
1179
|
+
/** An addressee of the message box; the first is the default. */
|
|
1180
|
+
to(value: string, label: Txt): this;
|
|
1181
|
+
empty(t: Txt): this;
|
|
1182
|
+
}
|
|
1183
|
+
/** `ui.conversation(messages, msg.f.author, msg.f.text, msg.f.at)`. */
|
|
1184
|
+
declare function conversation<R, A, B, C>(q: Q<any, R>, author: FieldRef<R, A>, text: FieldRef<R, B>, time: FieldRef<R, C>): ConversationB<R>;
|
|
1185
|
+
/** A messenger screen (`ui.chat(channel, send)`): the open thread, a run's log and the members as side panels and
|
|
1186
|
+
* the actions on messages.
|
|
1187
|
+
* @deprecated Catalog 3 deprecates `chat` (`W_UI_DEPRECATED`); build the screen from a `fill` split with a
|
|
1188
|
+
* `ui.header`, `ui.stream`s of posts, a `ui.strip` and a `ui.composer`. */
|
|
1189
|
+
export declare class ChatB extends Node {
|
|
1190
|
+
constructor(channel: string, send: string);
|
|
1191
|
+
private act;
|
|
1192
|
+
/** The open thread (`root`, `replies`) and the reply action (`{form: text, to, also}`). */
|
|
1193
|
+
thread(q: Q<any, any>, reply: ActionRef): this;
|
|
1194
|
+
/** An agent run's log (`steps`), with Stop and a note to the agent (`{form: text}`). */
|
|
1195
|
+
run(q: Q<any, any>, stop: ActionRef, tell: ActionRef): this;
|
|
1196
|
+
/** The members (`people`, `agents`) and the action that opens them. */
|
|
1197
|
+
members(q: Q<any, any>, open: ActionRef): this;
|
|
1198
|
+
/** Opens a message's thread, and closes the side panel. */
|
|
1199
|
+
openThread(open: ActionRef, close: ActionRef): this;
|
|
1200
|
+
/**
|
|
1201
|
+
* The open thread's Following bell: the action follows the thread (`{form: follow}` true) or stops following it
|
|
1202
|
+
* (false); the thread query reads `following`, whether the reader follows it.
|
|
1203
|
+
*/
|
|
1204
|
+
followThread(a: ActionRef): this;
|
|
1205
|
+
/** Opens a message's run log. */
|
|
1206
|
+
openRun(a: ActionRef): this;
|
|
1207
|
+
/** Approve, Decline and Undo on a message's approval. */
|
|
1208
|
+
approval(approve: ActionRef, decline: ActionRef, undo: ActionRef): this;
|
|
1209
|
+
/** A message card's button. */
|
|
1210
|
+
card(a: ActionRef): this;
|
|
1211
|
+
/** Reactions on a message (`{form: emoji}`). */
|
|
1212
|
+
react(a: ActionRef): this;
|
|
1213
|
+
/** The author's own changes to a message (edit `{form: text}`, delete), and pin or unpin it. */
|
|
1214
|
+
editing(edit: ActionRef, del: ActionRef, pin: ActionRef): this;
|
|
1215
|
+
/** Chooses an option of a message's decision (`{form: choice}`). */
|
|
1216
|
+
choose(a: ActionRef): this;
|
|
1217
|
+
/** The agent a direct message is with (`name`) and the action that pauses or resumes it. */
|
|
1218
|
+
about(q: Q<any, any>, pause: ActionRef): this;
|
|
1219
|
+
/** Whom a new message can go to (`people`, `agents`) and the action that starts it (`{form: to, text}`). */
|
|
1220
|
+
directory(q: Q<any, any>, start: ActionRef): this;
|
|
1221
|
+
}
|
|
1222
|
+
/** @deprecated Catalog 3 deprecates `chat`: a `fill` split with `ui.header`, `ui.stream`, `ui.strip` and `ui.composer`. */
|
|
1223
|
+
declare function chat(channel: Q<any, any>, send: ActionRef): ChatB;
|
|
1224
|
+
/** Records the command palette finds: `ui.search('Orders', findOrders, findRequest.f.text, findResponse.f.orders)`. */
|
|
1225
|
+
export declare class SearchB<R> extends Built {
|
|
1226
|
+
private readonly title;
|
|
1227
|
+
private readonly endpoint;
|
|
1228
|
+
private readonly text;
|
|
1229
|
+
private readonly rows;
|
|
1230
|
+
readonly __row: (r: R) => R;
|
|
1231
|
+
private itemView;
|
|
1232
|
+
private target;
|
|
1233
|
+
private readonly actions;
|
|
1234
|
+
constructor(title: Txt, endpoint: Deferred, text: string, rows: string);
|
|
1235
|
+
/** A result as a list item (`(r) => r.view(r.get(order.f.number)).subtitle(..)`). */
|
|
1236
|
+
item(view: (r: RowRef<R>) => RowViewB<R>): this;
|
|
1237
|
+
/** Where a result leads (`(r) => ({ id: r.get(order.f.id) })`). */
|
|
1238
|
+
open<P>(screen: ScreenKey<P>, a?: (r: RowRef<R>) => ArgsOf<P>): this;
|
|
1239
|
+
/** An action the palette offers on the top result: a document-level overlay with args from the result (`New order for {name}`). */
|
|
1240
|
+
action<P>(title: Txt, icon: string, overlay: OverlayKey<P>, a?: (r: RowRef<R>) => ArgsOf<P>): this;
|
|
1241
|
+
/** @internal */
|
|
1242
|
+
json(): unknown;
|
|
1243
|
+
}
|
|
1244
|
+
/** A source of records for the command palette: a read `ui` endpoint called with the typed text in `text`. */
|
|
1245
|
+
declare function search<I extends IoType, O extends IoType, R>(title: Txt, endpoint: EndpointDef<I, O>, text: FieldRef<IoValue<I>, string>, rows: FieldRef<IoValue<O>, R[]>): SearchB<R>;
|
|
1246
|
+
/** A card with a title line (`3 items · from catalog`); `.trailing(v).moneyIn(..)` adds a value at its end. */
|
|
1247
|
+
declare function titledCard(title: Txt, children: readonly Node[]): N;
|
|
1248
|
+
/** A small uppercase label over a group (`ACTIVITY`). */
|
|
1249
|
+
declare function label(t: Txt): N;
|
|
1250
|
+
/** A menu opened by a labelled button (`View`). */
|
|
1251
|
+
declare function menuButton(labelText: Txt, icon: string, items: readonly MenuItemB[]): N;
|
|
1252
|
+
/** The item type of a list, or the type itself: what a path continues into. */
|
|
1253
|
+
export type Elem<T> = T extends readonly (infer E)[] ? E : T;
|
|
1254
|
+
/**
|
|
1255
|
+
* A path into a row of `R` reading a `T`: a nested field (`ui.path(msg.f.thread, summary.f.count)` is
|
|
1256
|
+
* `thread.count`) or a field of a query's join (`who.f(face.f.name)` is `who.name`). Templates take it wherever they
|
|
1257
|
+
* take a field.
|
|
1258
|
+
*/
|
|
1259
|
+
export declare class PathOf<R, T> {
|
|
1260
|
+
readonly path: string;
|
|
1261
|
+
readonly __row: (r: R) => R;
|
|
1262
|
+
readonly __value: T;
|
|
1263
|
+
constructor(path: string);
|
|
1264
|
+
/** A field of the message this path leads to (or of its items). */
|
|
1265
|
+
dot<U>(f: FieldRef<Elem<T>, U>): PathOf<R, U>;
|
|
1266
|
+
}
|
|
1267
|
+
/** A field or a path of a row of `R`. */
|
|
1268
|
+
export type RowPathLike<R, T = any> = FieldRef<R, T> | PathOf<R, T>;
|
|
1269
|
+
/** A nested field of a row: `ui.path(msg.f.thread, summary.f.count)` (`thread.count`); `.dot(..)` goes deeper. */
|
|
1270
|
+
declare function path<R, T, U>(field: FieldRef<R, T>, next: FieldRef<Elem<T>, U>): PathOf<R, U>;
|
|
1271
|
+
/** A lookup of a query's rows (`QueryDef.join(..)`): the rows of `R` read the item of `J` as `<name>.<field>`. */
|
|
1272
|
+
export declare class Via<R, J> {
|
|
1273
|
+
readonly name: string;
|
|
1274
|
+
readonly __types: (x: [R, J]) => [R, J];
|
|
1275
|
+
constructor(name: string);
|
|
1276
|
+
/** A field of the looked-up item, as a path of the row. */
|
|
1277
|
+
f<T>(f: FieldRef<J, T>): PathOf<R, T>;
|
|
1278
|
+
}
|
|
1279
|
+
/** `ui.via('who', msg, face)`: the rows of `msg` read a `face` as `who.<field>` (or `ui.via<Msg, Face>('who')`). */
|
|
1280
|
+
declare function via<RS extends Shape, JS extends Shape>(name: string, row: MessageDef<RS>, item: MessageDef<JS>): Via<Infer<RS>, Infer<JS>>;
|
|
1281
|
+
declare function via<R, J>(name: string): Via<R, J>;
|
|
1282
|
+
/** A row value by path (a nested or joined field), for conditions and texts: `ui.rowAt(who.f(face.f.agent)).eq(true)`. */
|
|
1283
|
+
declare function rowAt<R, T>(p: RowPathLike<R, T>): Val<T>;
|
|
1284
|
+
/** Of a `pick` input: how many are chosen. */
|
|
1285
|
+
declare function pickedCount<T>(f: FieldRef<any, T>): Val<bigint>;
|
|
1286
|
+
/** Of a `pick` input: how many of the chosen are agents. */
|
|
1287
|
+
declare function pickedAgents<T>(f: FieldRef<any, T>): Val<bigint>;
|
|
1288
|
+
/** Of a `pick` input: the first word of the first chosen label. */
|
|
1289
|
+
declare function pickedFirst<T>(f: FieldRef<any, T>): Val<string>;
|
|
1290
|
+
/** Of a `pick` input: what is typed in its search (its `empty` text reads it: `Nobody matches “{q}”.`). */
|
|
1291
|
+
declare function pickedQuery<T>(f: FieldRef<any, T>): Val<string>;
|
|
1292
|
+
/** A piece of a header's subtitle: `ui.seg.text(..)`, `ui.seg.dotWaiting()`, `ui.seg.countdown(..).prefix('ends in ')`. */
|
|
1293
|
+
export declare class SegB extends Built {
|
|
1294
|
+
readonly s: Record<string, unknown>;
|
|
1295
|
+
constructor(/** @internal */ s: Record<string, unknown>);
|
|
1296
|
+
/** A text before the value, left out with it. */
|
|
1297
|
+
prefix(t: Txt): this;
|
|
1298
|
+
visible(c: Cond): this;
|
|
1299
|
+
/** @internal */
|
|
1300
|
+
json(): unknown;
|
|
1301
|
+
}
|
|
1302
|
+
/** A tab of a header: `ui.headerTab('pinned', 'Pinned').badge(q.field(view.f.pinnedCount))`. */
|
|
1303
|
+
export declare class HeaderTabB extends Built {
|
|
1304
|
+
private readonly t;
|
|
1305
|
+
constructor(id: string, title: Txt);
|
|
1306
|
+
/** ` · N` after the title while above 0. */
|
|
1307
|
+
badge<T>(v: Val<T>): this;
|
|
1308
|
+
/** Runs the action instead of selecting the tab. */
|
|
1309
|
+
action(a: ActionRef): this;
|
|
1310
|
+
/** @internal */
|
|
1311
|
+
json(): unknown;
|
|
1312
|
+
}
|
|
1313
|
+
declare function headerTab(id: string, title: Txt): HeaderTabB;
|
|
1314
|
+
/**
|
|
1315
|
+
* A head of a screen's column or of a side panel (catalog 3): a leading tile or faces, the title with a glyph, a
|
|
1316
|
+
* subtitle line of segments, a faces pill, text pills, icon buttons, a `…` menu, tabs, and the panel's expand and
|
|
1317
|
+
* close. On a phone a column's header is the shell's top bar; a panel's header is a back bar.
|
|
1318
|
+
*/
|
|
1319
|
+
export declare class HeaderB extends Node {
|
|
1320
|
+
private readonly buttonList;
|
|
1321
|
+
constructor(title: Txt);
|
|
1322
|
+
/** An icon name before the title. */
|
|
1323
|
+
titleIcon(v: ValueLike<string>): this;
|
|
1324
|
+
/** The icon the breadcrumb and the phone's top bar put before the screen's title. */
|
|
1325
|
+
crumbIcon(v: ValueLike<string>): this;
|
|
1326
|
+
/** An agent tile: the glyph and the engine (`claude`, `codex`, `pi`; empty: the ink cell). */
|
|
1327
|
+
leadingTile(icon: ValueLike<string>, engine: ValueLike<string>): this;
|
|
1328
|
+
/** A stack of faces (a list of `name`, `avatar`, `agent`, `icon`, `engine`). */
|
|
1329
|
+
leadingFaces<T>(v: Val<T>): this;
|
|
1330
|
+
/** The leading's size in px. */
|
|
1331
|
+
leadingSize(px: number): this;
|
|
1332
|
+
/** One line of segments joined with ` · `; a segment with an empty value is left out. */
|
|
1333
|
+
subtitle(segs: readonly SegB[]): this;
|
|
1334
|
+
/** The subtitle line is a button running this action. */
|
|
1335
|
+
subtitleAction(a: ActionRef): this;
|
|
1336
|
+
/** A muted text after the title (a panel's `# returns`). */
|
|
1337
|
+
context(t: Txt): this;
|
|
1338
|
+
/** A faces pill: the faces, the label (`9 members`), the action. */
|
|
1339
|
+
faces<T>(faces: Val<T>, label: Txt, a: ActionRef): this;
|
|
1340
|
+
/** The faces pill's accessible name (absent: `{label}: open`). Call it after `faces`. */
|
|
1341
|
+
facesAriaLabel(t: Txt): this;
|
|
1342
|
+
/** The faces pill is shown while `c` holds. */
|
|
1343
|
+
facesWhen(c: Cond): this;
|
|
1344
|
+
/** A text pill (at most 4). */
|
|
1345
|
+
button(label: Txt, a: ActionRef): this;
|
|
1346
|
+
/** The last pill is shown while `c` holds. */
|
|
1347
|
+
buttonWhen(c: Cond): this;
|
|
1348
|
+
/** `ui.iconButton` nodes (at most 4; a toggle bell). */
|
|
1349
|
+
icons(nodes: readonly Node[]): this;
|
|
1350
|
+
/** The `…` menu. */
|
|
1351
|
+
menu(items: readonly MenuItemB[]): this;
|
|
1352
|
+
/** The `…` button's and its menu's accessible label (absent: `More actions`). Call it after `menu`. */
|
|
1353
|
+
menuLabel(t: Txt): this;
|
|
1354
|
+
/** Tabs bound to a string state (or param) whose default is one of the ids. */
|
|
1355
|
+
tabs(bind: StateRef<string> | ParamRef<string>, items: readonly HeaderTabB[]): this;
|
|
1356
|
+
/** The tab bar's accessible label (absent: the title). Call it after `tabs`. */
|
|
1357
|
+
tabsLabel(t: Txt): this;
|
|
1358
|
+
/** The enclosing split's expand button (desktop). */
|
|
1359
|
+
expand(): this;
|
|
1360
|
+
/** The panel's close button (desktop) and back button (phone). */
|
|
1361
|
+
close(a: ActionRef): this;
|
|
1362
|
+
/** The phone back button's label. */
|
|
1363
|
+
back(t: Txt): this;
|
|
1364
|
+
private phone;
|
|
1365
|
+
/** The line under the phone's top-bar title. */
|
|
1366
|
+
phoneSub(t: Txt): this;
|
|
1367
|
+
/** Top-bar icon buttons on a phone: the actions of the header's icons or faces. */
|
|
1368
|
+
phoneIcons(actions: readonly ActionRef[]): this;
|
|
1369
|
+
/** The tabs first in the phone's `…` menu. */
|
|
1370
|
+
menuTabs(): this;
|
|
1371
|
+
}
|
|
1372
|
+
declare function header(title: Txt): HeaderB;
|
|
1373
|
+
/**
|
|
1374
|
+
* A live list of a query's rows (catalog 3), the newest at the bottom by default: older pages by the query's
|
|
1375
|
+
* `older`, day dividers, follow mode and jump to the latest, a `tail` query's rows merged after the rows by key, a
|
|
1376
|
+
* `head` row, an action when the newest row is seen, a post template per row:
|
|
1377
|
+
* `ui.stream(msgs).key(msg.f.id).post((p) => ..).days(msg.f.time)`.
|
|
1378
|
+
*/
|
|
1379
|
+
export declare class StreamB<R, Resp = any> extends Node {
|
|
1380
|
+
readonly __types: (x: [R, Resp]) => void;
|
|
1381
|
+
constructor(query: string);
|
|
1382
|
+
/** The row field that identifies an item (pages, the tail, `merge` and `scrollTo` go by it). */
|
|
1383
|
+
key<K>(f: FieldRef<R, K>): this;
|
|
1384
|
+
/** The template of a row. */
|
|
1385
|
+
post(build: (p: PostB<R>) => PostB<R>): this;
|
|
1386
|
+
/** A template built elsewhere (shared by two streams); the stream keeps it as it is now. */
|
|
1387
|
+
postWith(p: PostB<R>): this;
|
|
1388
|
+
/** Rows whose `field` equals `when` are one centred muted line: the author, the text, the time. */
|
|
1389
|
+
kindsLine<K>(field: FieldRef<R, K>, when: string, author: RowPathLike<R>, text: RowPathLike<R>, time: RowPathLike<R>): this;
|
|
1390
|
+
/**
|
|
1391
|
+
* Another query's rows (of the same row message) after the rows, by key: live items. A tail row gone from the next
|
|
1392
|
+
* tail answer stays until the main query has answered once more.
|
|
1393
|
+
*/
|
|
1394
|
+
tail(q: Q<any, R>): this;
|
|
1395
|
+
/** A row of the answer before the rows (drawn with the template, without its summary), and a rule under it. */
|
|
1396
|
+
head(row: FieldRef<Resp, R>, rule: Txt): this;
|
|
1397
|
+
/** A list read from the top (no follow mode). */
|
|
1398
|
+
anchorTop(): this;
|
|
1399
|
+
/** Older pages by a button only, with this label. */
|
|
1400
|
+
olderButton(label: Txt): this;
|
|
1401
|
+
/** The label of the button that loads older pages. */
|
|
1402
|
+
olderLabel(label: Txt): this;
|
|
1403
|
+
/** A divider before each day (`Today`, `Yesterday`, the date) of this field's moments. */
|
|
1404
|
+
days(f: RowPathLike<R>): this;
|
|
1405
|
+
/** A `New` divider after the item with this key. */
|
|
1406
|
+
unread<T>(key: ValueLike<T>): this;
|
|
1407
|
+
/** The jump button's text when nothing new came (`Assistant is working`). */
|
|
1408
|
+
jumpWorking(t: Txt): this;
|
|
1409
|
+
empty(t: Txt): this;
|
|
1410
|
+
/** A muted line above the first item on a phone. */
|
|
1411
|
+
phoneIntro(t: Txt): this;
|
|
1412
|
+
/** Runs the action with `{row: <the newest row>}` once the reader is at the end and the newest row changed. */
|
|
1413
|
+
onSeen(a: ActionRef): this;
|
|
1414
|
+
/** `onSeen` only while `c` holds (read in the newest row). */
|
|
1415
|
+
onSeenWhen(c: Cond): this;
|
|
1416
|
+
/** The name composers refer to (`ui.composer(send).forStream('messages')`). */
|
|
1417
|
+
id(id: string): this;
|
|
1418
|
+
/** The list's accessible name (`Messages`). */
|
|
1419
|
+
label(t: Txt): this;
|
|
1420
|
+
}
|
|
1421
|
+
declare function stream<Resp, R>(q: Q<Resp, R>): StreamB<R, Resp>;
|
|
1422
|
+
/**
|
|
1423
|
+
* The template of a stream's row (catalog 3): who wrote it and when, its text and recording, marks and lines under
|
|
1424
|
+
* it, a slot for a run of work, reactions, a summary of what follows from it, and what can be done with it. Every
|
|
1425
|
+
* field is a row field or a path (`who.f(face.f.name)`, `ui.path(..)`).
|
|
1426
|
+
*/
|
|
1427
|
+
export declare class PostB<R> extends Built {
|
|
1428
|
+
readonly p: Record<string, any>;
|
|
1429
|
+
readonly __row: (r: R) => R;
|
|
1430
|
+
constructor(/** @internal */ p?: Record<string, any>);
|
|
1431
|
+
/** A copy to change apart (a second stream's template without its summary). */
|
|
1432
|
+
clone(): PostB<R>;
|
|
1433
|
+
author(f: RowPathLike<R>): this;
|
|
1434
|
+
time(f: RowPathLike<R>): this;
|
|
1435
|
+
private avatarBody;
|
|
1436
|
+
/** The picture's URL (else the author's initials). */
|
|
1437
|
+
avatar(f: RowPathLike<R>): this;
|
|
1438
|
+
/** The agent tile: the glyph and the engine (drawn by default while `agent` is true or the glyph is not empty). */
|
|
1439
|
+
tile(icon: RowPathLike<R>, engine: RowPathLike<R>): this;
|
|
1440
|
+
/** The tile is drawn while `c` holds. */
|
|
1441
|
+
tileWhen(c: Cond): this;
|
|
1442
|
+
/** A tag after the name (`AGENT`) while `c` holds. */
|
|
1443
|
+
badge(t: Txt, c: Cond): this;
|
|
1444
|
+
/** A quiet line after the time (`via Commerce`). */
|
|
1445
|
+
source(f: RowPathLike<R>): this;
|
|
1446
|
+
/** The text as Markdown. */
|
|
1447
|
+
markdown(f: RowPathLike<R>): this;
|
|
1448
|
+
/** The text as plain text with `@[Name]` and `#[x]` chips (and the words lit while the recording plays). */
|
|
1449
|
+
plain(f: RowPathLike<R>): this;
|
|
1450
|
+
/** A bool field: the text is being written (a caret). */
|
|
1451
|
+
writing(f: RowPathLike<R, boolean>): this;
|
|
1452
|
+
/** A recording: its duration (s); `.audioMore(label, url, words)`. */
|
|
1453
|
+
audio(duration: RowPathLike<R>): this;
|
|
1454
|
+
/** The recording's label, URL (a data URL) and timed words (`word`, `start`, `end`). */
|
|
1455
|
+
audioMore(label: RowPathLike<R>, url: RowPathLike<R>, words: RowPathLike<R>): this;
|
|
1456
|
+
/** A bool field: `(edited)` after the text. */
|
|
1457
|
+
edited(f: RowPathLike<R, boolean>): this;
|
|
1458
|
+
/** A bool field: pinned; `mark` true draws `Pinned` above the head. */
|
|
1459
|
+
pinned(f: RowPathLike<R, boolean>, mark: ValueLike<boolean>): this;
|
|
1460
|
+
/** A bool field: the viewer's own row (no Reply to it). */
|
|
1461
|
+
mine(f: RowPathLike<R, boolean>): this;
|
|
1462
|
+
/** A line under the text; its tone by a field's value (`{ done: 'ok' }`). Drawn while the route's `to` is empty. */
|
|
1463
|
+
receipt(text: RowPathLike<R>, tone: RowPathLike<R>, tones: Record<string, Tone>): this;
|
|
1464
|
+
/** `→ <to> · <status>` with `why` as its tooltip; drawn while `to` is not empty. */
|
|
1465
|
+
route(to: RowPathLike<R>, status: RowPathLike<R>, why: RowPathLike<R>): this;
|
|
1466
|
+
/** A correction inline for 30 s after the moment `from` (ms), then in the menu: its label, the action. */
|
|
1467
|
+
correction(label: RowPathLike<R>, a: ActionRef, from: RowPathLike<R>): this;
|
|
1468
|
+
/** The correction's menu label, the words before it inline, its icon (`undo`, `arrow-right`). */
|
|
1469
|
+
correctionWords(menuLabel: RowPathLike<R>, lead: RowPathLike<R>, icon: RowPathLike<R>): this;
|
|
1470
|
+
/** How long the correction stays inline (ms, at most 120000). */
|
|
1471
|
+
correctionWindowMs(ms: number): this;
|
|
1472
|
+
/** Reaction chips: the repeated field, each one's emoji and count; a click runs `a` with `ui.form.emoji()`. */
|
|
1473
|
+
reactions<X, E, C>(field: RowPathLike<R, X[]>, emoji: FieldRef<X, E>, count: FieldRef<X, C>, a: ActionRef): this;
|
|
1474
|
+
/** The field of a reaction: the viewer's own (pressed). */
|
|
1475
|
+
reactionsMine<X>(f: FieldRef<X, boolean>): this;
|
|
1476
|
+
/** The emoji the hover's React offers (at most 8). */
|
|
1477
|
+
quick(emoji: readonly string[]): this;
|
|
1478
|
+
/** What follows from the item (replies): its count and the action that opens it. */
|
|
1479
|
+
summary(count: RowPathLike<R>, a: ActionRef): this;
|
|
1480
|
+
/** The summary's label (`{count} replies`). */
|
|
1481
|
+
summaryLabel(t: Txt): this;
|
|
1482
|
+
/** The summary's faces, last line, who works (since a moment in ms) and who waits. */
|
|
1483
|
+
summaryMore(faces: RowPathLike<R>, last: RowPathLike<R>, working: RowPathLike<R>, since: RowPathLike<R>, waiting: RowPathLike<R>): this;
|
|
1484
|
+
/** No summary (a pinned list's posts). */
|
|
1485
|
+
noSummary(): this;
|
|
1486
|
+
/** A run of work above the text: `at` is the field holding it; the block's fields are fields of what it holds. */
|
|
1487
|
+
process<T>(at: RowPathLike<R, T>, build: (w: ProcessB<Elem<T>>) => ProcessB<Elem<T>>): this;
|
|
1488
|
+
/** The rail on hover (desktop), in order. */
|
|
1489
|
+
hover(entries: readonly PostEntryB[]): this;
|
|
1490
|
+
/** The `…` menu, in order. */
|
|
1491
|
+
menu(entries: readonly PostEntryB[]): this;
|
|
1492
|
+
/** The phone's long-press sheet, in order. */
|
|
1493
|
+
sheet(entries: readonly PostEntryB[]): this;
|
|
1494
|
+
/** The inline editor of the text: `a` reads `ui.form.text()`; offered while `c` holds. */
|
|
1495
|
+
edit(a: ActionRef, c: Cond): this;
|
|
1496
|
+
/** While false: no rail, menu, sheet or inline correction. */
|
|
1497
|
+
actionsWhen(c: Cond): this;
|
|
1498
|
+
/** The identity card a mention, the lead or the name opens. */
|
|
1499
|
+
card<F>(c: CardB<F>): this;
|
|
1500
|
+
/** @internal */
|
|
1501
|
+
json(): unknown;
|
|
1502
|
+
}
|
|
1503
|
+
/** A post template to share between streams: `ui.post(msg)` (or `ui.post<Msg>()`). */
|
|
1504
|
+
declare function post<S extends Shape>(row: MessageDef<S>): PostB<Infer<S>>;
|
|
1505
|
+
declare function post<R>(): PostB<R>;
|
|
1506
|
+
/** An entry of a post's hover rail, menu or sheet: a built-in gesture (`ui.builtin.*`) or an action with its label. */
|
|
1507
|
+
export declare class PostEntryB extends Built {
|
|
1508
|
+
readonly e: Record<string, unknown>;
|
|
1509
|
+
constructor(/** @internal */ e: Record<string, unknown>);
|
|
1510
|
+
icon(icon: string): this;
|
|
1511
|
+
/** Drawn as a text button (the hover's `Ask agent`). */
|
|
1512
|
+
textStyle(): this;
|
|
1513
|
+
/** Drawn as an icon button (the label is its tooltip). */
|
|
1514
|
+
iconStyle(): this;
|
|
1515
|
+
danger(): this;
|
|
1516
|
+
visible(c: Cond): this;
|
|
1517
|
+
/** @internal */
|
|
1518
|
+
json(): unknown;
|
|
1519
|
+
}
|
|
1520
|
+
/** An entry running an action on the row: `ui.postEntry(openThread, 'Reply in thread').icon('message-square-text')`. */
|
|
1521
|
+
declare function postEntry(a: ActionRef, label: Txt): PostEntryB;
|
|
1522
|
+
/** An identity card: a name looked up (case-insensitively) in a query's rows. */
|
|
1523
|
+
export declare class CardB<F> extends Built {
|
|
1524
|
+
readonly __row: (r: F) => F;
|
|
1525
|
+
private readonly c;
|
|
1526
|
+
constructor(query: string, name: string);
|
|
1527
|
+
avatar<T>(f: FieldRef<F, T>): this;
|
|
1528
|
+
agent(f: FieldRef<F, boolean>): this;
|
|
1529
|
+
tile<A, B>(icon: FieldRef<F, A>, engine: FieldRef<F, B>): this;
|
|
1530
|
+
detail<T>(f: FieldRef<F, T>): this;
|
|
1531
|
+
/** The card's button: `a` reads `ui.form.to()`. */
|
|
1532
|
+
action(a: ActionRef): this;
|
|
1533
|
+
/** What the card says of a name not in the rows. */
|
|
1534
|
+
unknown(t: Txt): this;
|
|
1535
|
+
/** @internal */
|
|
1536
|
+
json(): unknown;
|
|
1537
|
+
}
|
|
1538
|
+
/** `ui.cardOf(people, face.f.name)`: the identity card over a query's rows. */
|
|
1539
|
+
declare function cardOf<F, T>(q: Q<any, F>, name: FieldRef<F, T>): CardB<F>;
|
|
1540
|
+
/**
|
|
1541
|
+
* A run of work (catalog 3): as a post's slot (`p.process(msg.f.work, (w) => w.state(work.f.state)..)`) or on its own
|
|
1542
|
+
* over a query's answer (`ui.process(runQ, (w) => ..)`). Live (`starting`, `working`), done, or ended (`stopped`,
|
|
1543
|
+
* `failed`, `timed_out`, `gone`); no block while `state` is empty. Its rows and calls have fixed field names.
|
|
1544
|
+
*/
|
|
1545
|
+
export declare class ProcessB<W> {
|
|
1546
|
+
private readonly at?;
|
|
1547
|
+
readonly __work: (w: W) => W;
|
|
1548
|
+
/** @internal */ readonly p: Record<string, unknown>;
|
|
1549
|
+
constructor(at?: string | undefined);
|
|
1550
|
+
private path;
|
|
1551
|
+
/** `starting`, `working`, `done`, `stopped`, `failed`, `timed_out`, `gone`; no block while empty. */
|
|
1552
|
+
state<T>(f: FieldRef<W, T>): this;
|
|
1553
|
+
label<T>(f: FieldRef<W, T>): this;
|
|
1554
|
+
meta<T>(f: FieldRef<W, T>): this;
|
|
1555
|
+
/** The moment (ms) the live block counts from. */
|
|
1556
|
+
started<T>(f: FieldRef<W, T>): this;
|
|
1557
|
+
/** The rows: `kind`, `title`, `detail`, `state`, `time`, `at`, `calls`, `tools`. */
|
|
1558
|
+
rows<T>(f: FieldRef<W, T>): this;
|
|
1559
|
+
/** The number of steps (`View N steps`). */
|
|
1560
|
+
steps<T>(f: FieldRef<W, T>): this;
|
|
1561
|
+
/** The text being written (with a caret). */
|
|
1562
|
+
saying<T>(f: FieldRef<W, T>): this;
|
|
1563
|
+
/** Retry on an ended block, with its label from a field, while `c` holds. */
|
|
1564
|
+
retry<T>(a: ActionRef, label: FieldRef<W, T>, c: Cond): this;
|
|
1565
|
+
/** `Open full log`. */
|
|
1566
|
+
log(a: ActionRef): this;
|
|
1567
|
+
/**
|
|
1568
|
+
* How a truncated call is read whole: `q` read once more with `a` and the request field `call` set to the call's
|
|
1569
|
+
* id; the answer's `field` replaces the call.
|
|
1570
|
+
*/
|
|
1571
|
+
fetchCall<Req, Resp, C, F>(q: Q<Resp, any>, call: FieldRef<Req, C>, field: FieldRef<Resp, F>, a?: ArgsOf<Req>): this;
|
|
1572
|
+
}
|
|
1573
|
+
/** A run of work on its own, over a query's answer: `ui.process(runQ, (w) => w.state(run.f.state).rows(run.f.rows))`. */
|
|
1574
|
+
declare function processNode<Resp, R>(q: Q<Resp, R>, build: (w: ProcessB<Resp>) => ProcessB<Resp>): N;
|
|
1575
|
+
/** A button of a strip's row: `ui.stripButton('Stop', stop).icon('square').stopStyle()`. */
|
|
1576
|
+
export declare class StripButtonB extends Built {
|
|
1577
|
+
private readonly s;
|
|
1578
|
+
constructor(label: Txt, a: ActionRef);
|
|
1579
|
+
icon(icon: string): this;
|
|
1580
|
+
/** The red-outlined Stop with the filled square. */
|
|
1581
|
+
stopStyle(): this;
|
|
1582
|
+
/** A muted text button. */
|
|
1583
|
+
textStyle(): this;
|
|
1584
|
+
visible(c: Cond): this;
|
|
1585
|
+
/** @internal */
|
|
1586
|
+
json(): unknown;
|
|
1587
|
+
}
|
|
1588
|
+
declare function stripButton(label: Txt, a: ActionRef): StripButtonB;
|
|
1589
|
+
/**
|
|
1590
|
+
* A pinned list of live items (catalog 3): a tile, the title, a dot (live, waiting), `Starting` or the time since
|
|
1591
|
+
* `since`, a sub line, a jump to the item's place in a stream and buttons; hidden while there are no rows.
|
|
1592
|
+
*/
|
|
1593
|
+
export declare class StripB<R> extends Node {
|
|
1594
|
+
readonly __row: (r: R) => R;
|
|
1595
|
+
private readonly buttonList;
|
|
1596
|
+
constructor(body: Record<string, unknown>);
|
|
1597
|
+
/** Above the items (`2 live runs`); none while empty. */
|
|
1598
|
+
label(t: Txt): this;
|
|
1599
|
+
tile<A, B>(icon: FieldRef<R, A>, engine: FieldRef<R, B>): this;
|
|
1600
|
+
/** Which values of the field are live, waiting and starting. */
|
|
1601
|
+
state<T>(f: FieldRef<R, T>, live: readonly string[], waiting?: readonly string[], starting?: readonly string[]): this;
|
|
1602
|
+
/** The moment (ms) an item counts from. */
|
|
1603
|
+
since<T>(f: FieldRef<R, T>): this;
|
|
1604
|
+
/** The moment (ms) a waiting item counts down to. */
|
|
1605
|
+
until<T>(f: FieldRef<R, T>): this;
|
|
1606
|
+
/** The line under the title. */
|
|
1607
|
+
subLine<T>(f: FieldRef<R, T>): this;
|
|
1608
|
+
/** After a waiting item's sub line, with `{left}` the countdown (`ends in {left}`). */
|
|
1609
|
+
countdownText(t: Txt): this;
|
|
1610
|
+
/** The tile and the title run it (row context). */
|
|
1611
|
+
open(a: ActionRef): this;
|
|
1612
|
+
/** The jump to the item's place in a stream: the key in `f`, the labels by state. */
|
|
1613
|
+
jump<T>(f: FieldRef<R, T>, label: Txt, labelWaiting: Txt): this;
|
|
1614
|
+
button(b: StripButtonB): this;
|
|
1615
|
+
ariaLabel(t: Txt): this;
|
|
1616
|
+
}
|
|
1617
|
+
/** A strip over a repeated field of a query's answer, each item keyed by `key` and titled by `title`. */
|
|
1618
|
+
declare function strip<Resp, R, K, T>(q: Q<Resp, any>, rows: FieldRef<Resp, R[]>, key: FieldRef<R, K>, title: FieldRef<R, T>): StripB<R>;
|
|
1619
|
+
/** A tool of a composer besides the mention. */
|
|
1620
|
+
export type ComposerTool = "add" | "emoji" | "attach";
|
|
1621
|
+
/** The mention picker's directory: `ui.mentions(people, face.f.name).tile(face.f.icon, face.f.engine)`. */
|
|
1622
|
+
export declare class MentionsB<F> extends Built {
|
|
1623
|
+
readonly __row: (r: F) => F;
|
|
1624
|
+
private readonly m;
|
|
1625
|
+
constructor(query: string, name: string);
|
|
1626
|
+
avatar<T>(f: FieldRef<F, T>): this;
|
|
1627
|
+
agent(f: FieldRef<F, boolean>): this;
|
|
1628
|
+
tile<A, B>(icon: FieldRef<F, A>, engine: FieldRef<F, B>): this;
|
|
1629
|
+
detail<T>(f: FieldRef<F, T>): this;
|
|
1630
|
+
/** The rows are grouped by this field on a desktop. */
|
|
1631
|
+
section<T>(f: FieldRef<F, T>): this;
|
|
1632
|
+
/** The picker's footer note. */
|
|
1633
|
+
note(t: Txt): this;
|
|
1634
|
+
/** @internal */
|
|
1635
|
+
json(): unknown;
|
|
1636
|
+
}
|
|
1637
|
+
declare function mentions<F, T>(q: Q<any, F>, name: FieldRef<F, T>): MentionsB<F>;
|
|
1638
|
+
/**
|
|
1639
|
+
* A message box (catalog 3): `ui.composer(send).forStream('messages').primary().mentions(..).reply()`. `send` reads
|
|
1640
|
+
* `ui.form.text()`, `ui.form.reply()`, the recording (`audio`, `duration`, `language`, `words`) and each option
|
|
1641
|
+
* (`ui.form.option('also')`).
|
|
1642
|
+
*/
|
|
1643
|
+
export declare class ComposerB extends Node {
|
|
1644
|
+
private readonly optionList;
|
|
1645
|
+
private readonly captionList;
|
|
1646
|
+
constructor(send: string);
|
|
1647
|
+
/** The `id` of the stream it belongs to (jumps to its end on send; `draft` and `replyTo` from its items). */
|
|
1648
|
+
forStream(id: string): this;
|
|
1649
|
+
placeholder(t: Txt): this;
|
|
1650
|
+
/** Owns ⌥ Space and the steps of rows outside a stream; one per frame. */
|
|
1651
|
+
primary(): this;
|
|
1652
|
+
/** The panel's box. */
|
|
1653
|
+
compact(): this;
|
|
1654
|
+
/** The tools besides the mention; none when empty. */
|
|
1655
|
+
tools(tools: readonly ComposerTool[]): this;
|
|
1656
|
+
mentions<F>(m: MentionsB<F>): this;
|
|
1657
|
+
/** `#word` becomes `#[word]` on send. */
|
|
1658
|
+
tags(): this;
|
|
1659
|
+
/** The Dictate button (shown when the workspace has a speech connection). */
|
|
1660
|
+
dictation(): this;
|
|
1661
|
+
/** Words for the recogniser besides the mentionable names. */
|
|
1662
|
+
vocabulary(t: Txt): this;
|
|
1663
|
+
/** Takes `replyTo`: `ui.form.reply()` is the key. */
|
|
1664
|
+
reply(): this;
|
|
1665
|
+
/** A checkbox under the box (`ui.form.option(name)`). */
|
|
1666
|
+
option(name: string, label: Txt): this;
|
|
1667
|
+
/** The last option is shown while `c` holds. */
|
|
1668
|
+
optionWhen(c: Cond): this;
|
|
1669
|
+
/** A caption line naming who will answer (`↳ …`); the first caption with a value is drawn. */
|
|
1670
|
+
captionRoute(t: Txt): this;
|
|
1671
|
+
/** A plain caption line. */
|
|
1672
|
+
captionDot(t: Txt): this;
|
|
1673
|
+
/** While `c` holds and the box is empty, Send is a labelled Stop running `a` (and Esc runs it). */
|
|
1674
|
+
stop(a: ActionRef, c: Cond): this;
|
|
1675
|
+
stopLabel(t: Txt): this;
|
|
1676
|
+
/** The Stop button's accessible name (absent: its label). Call it after `stop`. */
|
|
1677
|
+
stopAriaLabel(t: Txt): this;
|
|
1678
|
+
/** While `c` holds, the reason stands where the box would be. */
|
|
1679
|
+
readOnly(c: Cond, reason: Txt): this;
|
|
1680
|
+
/** The text is mirrored into this string state, for a query that reads what is typed. */
|
|
1681
|
+
draftState(s: StateRef<string>): this;
|
|
1682
|
+
}
|
|
1683
|
+
declare function composer(send: ActionRef): ComposerB;
|
|
1684
|
+
/** The UI builders. */
|
|
1685
|
+
export declare const ui: {
|
|
1686
|
+
define: typeof define;
|
|
1687
|
+
text: typeof text;
|
|
1688
|
+
lit: <T>(x: T) => Val<T>;
|
|
1689
|
+
row: typeof row;
|
|
1690
|
+
/** A field of the last call's result in the running chain. */
|
|
1691
|
+
result: <T>(f: FieldRef<any, T>) => Val<T>;
|
|
1692
|
+
/** The member looking at the screen. */
|
|
1693
|
+
callerId: () => Val<string>;
|
|
1694
|
+
callerName: () => Val<string>;
|
|
1695
|
+
/** In `onError`: what failed. */
|
|
1696
|
+
errorCode: () => Val<string>;
|
|
1697
|
+
errorMessage: () => Val<string>;
|
|
1698
|
+
errorOutcome: () => Val<"failed" | "unknown">;
|
|
1699
|
+
errorStep: () => Val<number>;
|
|
1700
|
+
/** No value: clears an optional param or state (`a.setParam(order, ui.none())`). */
|
|
1701
|
+
none: <T = never>() => Val<T>;
|
|
1702
|
+
/** A field of the current row, where no row handle is at hand (a list's aside text). */
|
|
1703
|
+
rowValue: <T>(f: FieldRef<any, T>) => Val<T>;
|
|
1704
|
+
/** The form's current values, for queries of the same overlay (a quote that reads them as they change). */
|
|
1705
|
+
formValue: <T>(f: FieldRef<any, T>) => Val<T>;
|
|
1706
|
+
not: (c: Cond) => Cond;
|
|
1707
|
+
call: typeof call;
|
|
1708
|
+
screenKey: typeof screenKey;
|
|
1709
|
+
overlayKey: typeof overlayKey;
|
|
1710
|
+
screen: typeof screen;
|
|
1711
|
+
dialog: {
|
|
1712
|
+
<P>(key: OverlayKey<P>, build: ScreenBuild<P>): OverlayDef<P>;
|
|
1713
|
+
<S extends Shape>(id: string, params: MessageDef<S>, build: ScreenBuild<Infer<S>>): OverlayDef<Infer<S>>;
|
|
1714
|
+
(id: string, build: ScreenBuild<{}>): OverlayDef<{}>;
|
|
1715
|
+
};
|
|
1716
|
+
sidePanel: {
|
|
1717
|
+
<P>(key: OverlayKey<P>, build: ScreenBuild<P>): OverlayDef<P>;
|
|
1718
|
+
<S extends Shape>(id: string, params: MessageDef<S>, build: ScreenBuild<Infer<S>>): OverlayDef<Infer<S>>;
|
|
1719
|
+
(id: string, build: ScreenBuild<{}>): OverlayDef<{}>;
|
|
1720
|
+
};
|
|
1721
|
+
sheet: {
|
|
1722
|
+
<P>(key: OverlayKey<P>, build: ScreenBuild<P>): OverlayDef<P>;
|
|
1723
|
+
<S extends Shape>(id: string, params: MessageDef<S>, build: ScreenBuild<Infer<S>>): OverlayDef<Infer<S>>;
|
|
1724
|
+
(id: string, build: ScreenBuild<{}>): OverlayDef<{}>;
|
|
1725
|
+
};
|
|
1726
|
+
confirm: ((title: Txt) => ConfirmB) & {
|
|
1727
|
+
danger: (title: Txt) => ConfirmB;
|
|
1728
|
+
};
|
|
1729
|
+
stack: typeof stack;
|
|
1730
|
+
columns: typeof columns;
|
|
1731
|
+
section: typeof section;
|
|
1732
|
+
card: typeof card;
|
|
1733
|
+
titledCard: typeof titledCard;
|
|
1734
|
+
tabs: typeof tabs;
|
|
1735
|
+
tab: typeof tab;
|
|
1736
|
+
divider: typeof divider;
|
|
1737
|
+
split: typeof split;
|
|
1738
|
+
board: typeof board;
|
|
1739
|
+
segmented: typeof segmented;
|
|
1740
|
+
link: typeof link;
|
|
1741
|
+
table: typeof table;
|
|
1742
|
+
list: typeof list;
|
|
1743
|
+
fields: typeof fields;
|
|
1744
|
+
item: typeof item;
|
|
1745
|
+
metric: typeof metric;
|
|
1746
|
+
barChart: <R, X>(q: Q<any, R>, x: FieldRef<R, X>) => ChartB<R>;
|
|
1747
|
+
lineChart: <R, X>(q: Q<any, R>, x: FieldRef<R, X>) => ChartB<R>;
|
|
1748
|
+
areaChart: <R, X>(q: Q<any, R>, x: FieldRef<R, X>) => ChartB<R>;
|
|
1749
|
+
pieChart: <R, X>(q: Q<any, R>, x: FieldRef<R, X>) => ChartB<R>;
|
|
1750
|
+
viz: typeof vizOf & VizCatalogue;
|
|
1751
|
+
timeline: typeof timeline;
|
|
1752
|
+
status: typeof status;
|
|
1753
|
+
tag: typeof tag;
|
|
1754
|
+
avatar: typeof avatar;
|
|
1755
|
+
avatarStack: typeof avatarStack;
|
|
1756
|
+
meter: typeof meter;
|
|
1757
|
+
progress: typeof progress;
|
|
1758
|
+
heading: typeof heading;
|
|
1759
|
+
caption: typeof caption;
|
|
1760
|
+
mono: typeof mono;
|
|
1761
|
+
copyField: typeof copyField;
|
|
1762
|
+
label: typeof label;
|
|
1763
|
+
empty: typeof empty;
|
|
1764
|
+
notice: typeof notice;
|
|
1765
|
+
recordHeader: typeof recordHeader;
|
|
1766
|
+
agentRun: typeof agentRun;
|
|
1767
|
+
conversation: typeof conversation;
|
|
1768
|
+
/** @deprecated Catalog 3 deprecates `chat` (`W_UI_DEPRECATED`): a `fill` split with `ui.header`, `ui.stream`,
|
|
1769
|
+
* `ui.strip` and `ui.composer`. */
|
|
1770
|
+
chat: typeof chat;
|
|
1771
|
+
rowView: typeof rowView;
|
|
1772
|
+
search: typeof search;
|
|
1773
|
+
filterBar: typeof filterBar;
|
|
1774
|
+
button: typeof button;
|
|
1775
|
+
iconButton: typeof iconButton;
|
|
1776
|
+
menu: typeof menu;
|
|
1777
|
+
menuButton: typeof menuButton;
|
|
1778
|
+
menuItem: typeof menuItem;
|
|
1779
|
+
via: typeof via;
|
|
1780
|
+
path: typeof path;
|
|
1781
|
+
rowAt: typeof rowAt;
|
|
1782
|
+
/** The values a composer, a post's actions and a toggle give their chain. */
|
|
1783
|
+
form: {
|
|
1784
|
+
/** The text typed (a composer, a post's inline edit). */
|
|
1785
|
+
text: () => Val<string>;
|
|
1786
|
+
/** The key of the item Reply was on (a composer with `.reply()`). */
|
|
1787
|
+
reply: () => Val<string>;
|
|
1788
|
+
/** A dictated recording: a data URL. */
|
|
1789
|
+
audio: () => Val<string>;
|
|
1790
|
+
/** The recording's duration. */
|
|
1791
|
+
duration: () => Val<string>;
|
|
1792
|
+
/** The recording's language. */
|
|
1793
|
+
language: () => Val<string>;
|
|
1794
|
+
/** The recording's timed words (JSON). */
|
|
1795
|
+
words: () => Val<string>;
|
|
1796
|
+
/** A composer's checkbox (`.option(name, label)`). */
|
|
1797
|
+
option: (name: string) => Val<boolean>;
|
|
1798
|
+
/** The emoji of a reaction. */
|
|
1799
|
+
emoji: () => Val<string>;
|
|
1800
|
+
/** The name an identity card's button is for. */
|
|
1801
|
+
to: () => Val<string>;
|
|
1802
|
+
/** A toggle's new state. */
|
|
1803
|
+
pressed: () => Val<boolean>;
|
|
1804
|
+
};
|
|
1805
|
+
pickedCount: typeof pickedCount;
|
|
1806
|
+
pickedAgents: typeof pickedAgents;
|
|
1807
|
+
pickedFirst: typeof pickedFirst;
|
|
1808
|
+
pickedQuery: typeof pickedQuery;
|
|
1809
|
+
header: typeof header;
|
|
1810
|
+
headerTab: typeof headerTab;
|
|
1811
|
+
seg: {
|
|
1812
|
+
/** A text; left out while its value is empty. */
|
|
1813
|
+
text: (t: Txt) => SegB;
|
|
1814
|
+
/** The amber dot of something at work. */
|
|
1815
|
+
dotLive: () => SegB;
|
|
1816
|
+
/** The hollow dot of something waiting. */
|
|
1817
|
+
dotWaiting: () => SegB;
|
|
1818
|
+
/** The line in the tone of something at work (amber), with no dot drawn. */
|
|
1819
|
+
toneLive: () => SegB;
|
|
1820
|
+
/** The line in the tone of something waiting, with no dot drawn. */
|
|
1821
|
+
toneWaiting: () => SegB;
|
|
1822
|
+
/** The time left until a moment in ms (left out while empty). */
|
|
1823
|
+
countdown: <T>(v: ValueLike<T>) => SegB;
|
|
1824
|
+
/** The time since a moment in ms. */
|
|
1825
|
+
elapsed: <T>(v: ValueLike<T>) => SegB;
|
|
1826
|
+
};
|
|
1827
|
+
stream: typeof stream;
|
|
1828
|
+
post: typeof post;
|
|
1829
|
+
postEntry: typeof postEntry;
|
|
1830
|
+
builtin: {
|
|
1831
|
+
/** The quick reactions (needs `reactions`). */
|
|
1832
|
+
react: () => PostEntryB;
|
|
1833
|
+
/** Reply to the author (needs a composer with `.reply()`). */
|
|
1834
|
+
reply: () => PostEntryB;
|
|
1835
|
+
copyText: () => PostEntryB;
|
|
1836
|
+
copyLink: () => PostEntryB;
|
|
1837
|
+
/** Play or pause the recording (needs `audio`). */
|
|
1838
|
+
play: () => PostEntryB;
|
|
1839
|
+
/** The inline editor (needs `edit`). */
|
|
1840
|
+
edit: () => PostEntryB;
|
|
1841
|
+
/** The correction after its inline window (needs `correction`). */
|
|
1842
|
+
correction: () => PostEntryB;
|
|
1843
|
+
/** The `…` button that opens the menu (the hover rail only). */
|
|
1844
|
+
more: () => PostEntryB;
|
|
1845
|
+
separator: () => PostEntryB;
|
|
1846
|
+
};
|
|
1847
|
+
cardOf: typeof cardOf;
|
|
1848
|
+
process: typeof processNode;
|
|
1849
|
+
strip: typeof strip;
|
|
1850
|
+
stripButton: typeof stripButton;
|
|
1851
|
+
composer: typeof composer;
|
|
1852
|
+
mentions: typeof mentions;
|
|
1853
|
+
nav: typeof nav;
|
|
1854
|
+
entry: typeof entry;
|
|
1855
|
+
entryRows: typeof entryRows;
|
|
1856
|
+
command: {
|
|
1857
|
+
/**
|
|
1858
|
+
* Navigates to a screen, with params like a link: `ui.command.navigate('week', 'Sales: last 7 days', REPORT,
|
|
1859
|
+
* { range: '7' })`. A command runs from anywhere, so its args are literals.
|
|
1860
|
+
*/
|
|
1861
|
+
navigate: <P>(id: string, title: Txt, screen: ScreenKey<P>, a?: ArgsOf<P>) => CommandB;
|
|
1862
|
+
/** Opens a document-level overlay (`ui.define({ overlays })`), with params (literals). */
|
|
1863
|
+
open: <P>(id: string, title: Txt, overlay: OverlayKey<P>, a?: ArgsOf<P>) => CommandB;
|
|
1864
|
+
};
|
|
1865
|
+
home: typeof home;
|
|
1866
|
+
};
|
|
1867
|
+
export {};
|