@dropby/vue 0.4.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.
@@ -0,0 +1,402 @@
1
+ import { t as PublicComponent } from "../chunks/public-component-A2rcQYAZ.js";
2
+ import { n as ChatAttachmentsToolkit, t as ChatAttachmentDraft } from "../chunks/chat-attachment-types-BG8VFQj5.js";
3
+ import { ExtractPublicPropTypes, MaybeRefOrGetter, PropType, VNode } from "vue";
4
+ import { AskField, AsksActions, AsyncResource, ChatActions, ChatHistoryLoadState, ChatThread as ChatThread$1, ChatThreadActions, ChatThreadsCollection, DropByError, DropById, FlagValue, Idea as Idea$1, IdeasActions, ListIdeasView, PagedCollection, PendingAsk, PendingAsksCollection } from "@dropby/browser";
5
+ declare const askProps: {
6
+ /** The ask to show. */
7
+ readonly ask: {
8
+ readonly type: PropType<PendingAsk>;
9
+ readonly required: true;
10
+ };
11
+ /** Passed to its `AskForm`. */
12
+ readonly fieldsPerStep: {
13
+ readonly type: NumberConstructor;
14
+ readonly default: undefined;
15
+ };
16
+ };
17
+ /** Props for `Ask`; other attributes go to its `div`. */
18
+ type AskProps = ExtractPublicPropTypes<typeof askProps>;
19
+ /** Slots of `Ask`. */
20
+ interface AskSlots {
21
+ /** Your own body, given the ask, in place of its title and form. */
22
+ default?: (state: {
23
+ ask: PendingAsk;
24
+ }) => VNode[];
25
+ }
26
+ /**
27
+ * One pending ask: its title and its `AskForm`, marked `data-pending`.
28
+ */
29
+ export declare const Ask: PublicComponent<AskProps, AskSlots>;
30
+ /** One field's answer: text, the chosen option ids, or a rating. */
31
+ type AskAnswerValue = string | string[] | number;
32
+ /** The answers given so far, by field id. */
33
+ type AskAnswers = Record<string, AskAnswerValue>;
34
+ /** What the `AskForm` default slot receives. */
35
+ interface AskFormState {
36
+ /** The ask being answered. */
37
+ ask: PendingAsk;
38
+ /** The fields on the current step. */
39
+ fields: AskField[];
40
+ /** The answers given so far. */
41
+ answers: AskAnswers;
42
+ /** Sets one field's answer, and clears its issue. */
43
+ setAnswer: (fieldId: string, value: AskAnswerValue) => void;
44
+ /** The current step, from 0. */
45
+ step: number;
46
+ /** How many steps there are. */
47
+ stepCount: number;
48
+ /** Whether this is the first step. */
49
+ isFirst: boolean;
50
+ /** Whether this is the last step. */
51
+ isLast: boolean;
52
+ /** Goes to the step before. */
53
+ back: () => void;
54
+ /** Goes to the next step when this one's answers are valid, or shows their issues. */
55
+ next: () => void;
56
+ /** Sends every answer when all are valid, or goes to the first step with an issue. */
57
+ submit: () => Promise<void>;
58
+ /** Dismisses the ask. */
59
+ dismiss: () => Promise<void>;
60
+ /** Whether a submit or dismissal is in flight. */
61
+ submitting: boolean;
62
+ /** Each field's issue, in copy for the user, by field id. */
63
+ issues: Record<string, string>;
64
+ /** Why the last submit or dismissal failed. */
65
+ error: DropByError | null;
66
+ }
67
+ declare const askFormProps: {
68
+ /** The ask to answer. */
69
+ readonly ask: {
70
+ readonly type: PropType<PendingAsk>;
71
+ readonly required: true;
72
+ };
73
+ /** How many fields a step shows: all by default, 1 for one at a time. */
74
+ readonly fieldsPerStep: {
75
+ readonly type: NumberConstructor;
76
+ readonly default: undefined;
77
+ };
78
+ };
79
+ /** Props for `AskForm`; other attributes go to its `form`. */
80
+ type AskFormProps = ExtractPublicPropTypes<typeof askFormProps>;
81
+ /** Slots of `AskForm`. */
82
+ interface AskFormSlots {
83
+ /** Your own form body, given the form's state, in place of the default. */
84
+ default?: (state: AskFormState) => VNode[];
85
+ }
86
+ /**
87
+ * The form to answer one ask: its fields, in steps when `fields-per-step` is
88
+ * set, then submit, and dismiss when the ask allows it. It checks each step's
89
+ * answers before moving on, and shows a failed submit or dismissal in plain
90
+ * copy.
91
+ */
92
+ export declare const AskForm: PublicComponent<AskFormProps, AskFormSlots>;
93
+ /** What the `ChatComposer` default slot receives. */
94
+ interface ChatComposerState {
95
+ /** The text being written. */
96
+ draft: string;
97
+ /** Changes the text. */
98
+ setDraft: (value: string) => void;
99
+ /**
100
+ * Sends the draft with any ready attachments, then clears both. Does nothing
101
+ * when the draft is empty, a send is in flight, or an upload is still in
102
+ * progress.
103
+ */
104
+ send: () => Promise<void>;
105
+ /** Whether a send is in flight. */
106
+ sending: boolean;
107
+ /** Why the last send failed; the draft is kept to send again. */
108
+ error: DropByError | null;
109
+ /** The attachments passed in, if any. */
110
+ attachments: ChatAttachmentsToolkit | undefined;
111
+ }
112
+ declare const chatComposerProps: {
113
+ /** The conversation to send to. */
114
+ readonly threadId: {
115
+ readonly type: PropType<DropById<"thr_">>;
116
+ readonly required: true;
117
+ };
118
+ /**
119
+ * Attachments from `useChatAttachments`, in
120
+ * `@dropby/vue/components/chat-attachments`. Omit for a text-only composer.
121
+ */
122
+ readonly attachments: {
123
+ readonly type: PropType<ChatAttachmentsToolkit>;
124
+ readonly default: undefined;
125
+ };
126
+ };
127
+ /** Props for `ChatComposer`; other attributes go to its `form`. */
128
+ type ChatComposerProps = ExtractPublicPropTypes<typeof chatComposerProps>;
129
+ /** Slots of `ChatComposer`. */
130
+ interface ChatComposerSlots {
131
+ /** Your own form body, given the draft and `send`, in place of the default. */
132
+ default?: (state: ChatComposerState) => VNode[];
133
+ }
134
+ /**
135
+ * A message box for one conversation. A message needs text, and sending is blocked
136
+ * while an upload is in progress; with `attachments`, it sends those that are
137
+ * ready. A failed send keeps the draft and shows plain copy; sending the same text
138
+ * and attachments again reuses the failed send's key, so a send whose answer was
139
+ * lost is not posted twice while this composer stays mounted.
140
+ */
141
+ export declare const ChatComposer: PublicComponent<ChatComposerProps, ChatComposerSlots>;
142
+ /** What the `ChatThread` default slot receives. */
143
+ interface ChatThreadState {
144
+ /** The load of older messages, once one started. */
145
+ olderMessages: ChatHistoryLoadState | undefined;
146
+ /** The load of the newest messages, once one started. */
147
+ latestMessages: ChatHistoryLoadState | undefined;
148
+ /** The conversation as loaded. */
149
+ thread: AsyncResource<ChatThread$1> | undefined;
150
+ /** The conversation's actions. */
151
+ actions: ChatThreadActions;
152
+ }
153
+ declare const chatThreadProps: {
154
+ /** The conversation to show. */
155
+ readonly id: {
156
+ readonly type: PropType<DropById<"thr_">>;
157
+ readonly required: true;
158
+ };
159
+ /** Do not open the conversation on mount; call `actions.open()` yourself. */
160
+ readonly manualLoad: {
161
+ readonly type: BooleanConstructor;
162
+ readonly default: false;
163
+ };
164
+ /**
165
+ * Marks replies seen once they are read on screen; true by default. Pass
166
+ * false to call `actions.markSeen` yourself.
167
+ */
168
+ readonly acknowledge: {
169
+ readonly type: BooleanConstructor;
170
+ readonly default: true;
171
+ };
172
+ };
173
+ /**
174
+ * Props for `ChatThread`; other attributes go to its `div`, or to your slot's root
175
+ * element when it has exactly one.
176
+ */
177
+ type ChatThreadProps = ExtractPublicPropTypes<typeof chatThreadProps>;
178
+ /** Slots of `ChatThread`. */
179
+ interface ChatThreadSlots {
180
+ /**
181
+ * Replaces the default body, composer included, given the conversation and
182
+ * its actions. A slot body is never watched for reading.
183
+ */
184
+ default?: (state: ChatThreadState) => VNode[];
185
+ }
186
+ /**
187
+ * One conversation: its messages, each with `data-author` and any attachments, in
188
+ * a live region, then a text-only composer. It opens the conversation on mount
189
+ * unless `manual-load`, and shows the load in `data-status`. When the thread or an
190
+ * element around it scrolls (`overflow-y: auto` or `scroll`), the default body
191
+ * follows new messages while the reader is at the end, or when the message is
192
+ * their own; it never scrolls the page. It marks replies seen once they are read
193
+ * on screen.
194
+ */
195
+ export declare const ChatThread: PublicComponent<ChatThreadProps, ChatThreadSlots>;
196
+ /** What the `ChatThreadList` default slot receives. */
197
+ interface ChatThreadListState {
198
+ /** The conversation list. */
199
+ threads: ChatThreadsCollection;
200
+ /** Chat's actions. */
201
+ actions: ChatActions;
202
+ }
203
+ declare const chatThreadListProps: {
204
+ /** Do not load the list on mount; call `actions.listThreads()` yourself. */
205
+ readonly manualLoad: {
206
+ readonly type: BooleanConstructor;
207
+ readonly default: false;
208
+ };
209
+ /** The conversation open now, marked `aria-current`; used only with `@select`. */
210
+ readonly selectedId: {
211
+ readonly type: PropType<DropById<"thr_"> | null>;
212
+ readonly default: null;
213
+ };
214
+ /** Bound by `@select`: makes each row a button that emits its conversation's id. */
215
+ readonly onSelect: {
216
+ readonly type: PropType<(threadId: DropById<"thr_">) => void>;
217
+ };
218
+ };
219
+ /**
220
+ * Props for `ChatThreadList`; other attributes go to its `ul`, or to your slot's
221
+ * root element when it has exactly one.
222
+ */
223
+ type ChatThreadListProps = ExtractPublicPropTypes<typeof chatThreadListProps>;
224
+ /** Slots of `ChatThreadList`. */
225
+ interface ChatThreadListSlots {
226
+ /** Your own list, given the conversations and chat's actions, in place of the default. */
227
+ default?: (state: ChatThreadListState) => VNode[];
228
+ }
229
+ /**
230
+ * The user's conversations, newest first, a page at a time. It starts with a
231
+ * refresh button and an unread filter (`aria-pressed`), marks rows with unread
232
+ * replies `data-unread`, loads on mount unless `manual-load`, shows the load in
233
+ * `data-status` and `data-empty`, and ends with a "show more conversations" item
234
+ * (`data-load-more`) while there are more, which also retries a page that failed.
235
+ */
236
+ export declare const ChatThreadList: PublicComponent<ChatThreadListProps, ChatThreadListSlots>;
237
+ declare const featureProps: {
238
+ /** The feature flag to read. */
239
+ readonly name: {
240
+ readonly type: StringConstructor;
241
+ readonly required: true;
242
+ };
243
+ /** The value that turns it on; without it, any truthy value does. */
244
+ readonly equals: {
245
+ readonly type: PropType<FlagValue>;
246
+ readonly default: undefined;
247
+ };
248
+ };
249
+ /** Props for `Feature`. */
250
+ type FeatureProps = ExtractPublicPropTypes<typeof featureProps>;
251
+ /** Slots of `Feature`. */
252
+ interface FeatureSlots {
253
+ /** What to render when the flag is on. */
254
+ default?: () => VNode[];
255
+ /** What to render when the flag is off, unset, or not yet read. */
256
+ fallback?: () => VNode[];
257
+ }
258
+ /**
259
+ * Renders its default slot when a feature flag is on: equal to `equals` when
260
+ * given, otherwise truthy. Renders the `fallback` slot otherwise, including until
261
+ * the session has loaded. It adds no markup of its own and takes no attributes.
262
+ */
263
+ export declare const Feature: PublicComponent<FeatureProps, FeatureSlots>;
264
+ declare const ideaProps: {
265
+ /** The idea to show. */
266
+ readonly idea: {
267
+ readonly type: PropType<Idea$1>;
268
+ readonly required: true;
269
+ };
270
+ };
271
+ /** Props for `Idea`; other attributes go to its `div`. */
272
+ type IdeaProps = ExtractPublicPropTypes<typeof ideaProps>;
273
+ /** Slots of `Idea`. */
274
+ interface IdeaSlots {
275
+ /** Your own body, given the idea, in place of the default. */
276
+ default?: (state: {
277
+ idea: Idea$1;
278
+ }) => VNode[];
279
+ }
280
+ /**
281
+ * One idea: its vote button, title and description, with `data-voted` when the
282
+ * user voted. In your own body, use `IdeaVoteButton` for voting.
283
+ */
284
+ export declare const Idea: PublicComponent<IdeaProps, IdeaSlots>;
285
+ /** What the `IdeaList` default slot receives. */
286
+ interface IdeaListState {
287
+ /** The ideas list. */
288
+ ideas: PagedCollection<Idea$1>;
289
+ /** The board's actions. */
290
+ actions: IdeasActions;
291
+ }
292
+ declare const ideaListProps: {
293
+ /**
294
+ * The user's ideas, or the public board; `owned` by default. Used only when the
295
+ * ideas store has not loaded yet; to switch later, call `actions.list({ view
296
+ * })`.
297
+ */
298
+ readonly view: {
299
+ readonly type: PropType<ListIdeasView>;
300
+ readonly default: undefined;
301
+ };
302
+ /** Do not load on mount; call `actions.list()` yourself. */
303
+ readonly manualLoad: {
304
+ readonly type: BooleanConstructor;
305
+ readonly default: false;
306
+ };
307
+ };
308
+ /**
309
+ * Props for `IdeaList`; other attributes go to its `ul`, or to your slot's root
310
+ * element when it has exactly one.
311
+ */
312
+ type IdeaListProps = ExtractPublicPropTypes<typeof ideaListProps>;
313
+ /** Slots of `IdeaList`. */
314
+ interface IdeaListSlots {
315
+ /** Your own list, given the ideas and the board's actions, in place of the default. */
316
+ default?: (state: IdeaListState) => VNode[];
317
+ }
318
+ /**
319
+ * Ideas, each an `Idea`, a page at a time: the board by votes, the user's ideas
320
+ * newest first. It loads on mount unless `manual-load`, shows the load in
321
+ * `data-status` and `data-empty`, and ends with a "show more ideas" item
322
+ * (`data-load-more`) while there are more.
323
+ */
324
+ export declare const IdeaList: PublicComponent<IdeaListProps, IdeaListSlots>;
325
+ /** What the `IdeaVoteButton` default slot receives: one idea's vote. */
326
+ interface IdeaVoteState {
327
+ /** The idea. */
328
+ idea: Idea$1;
329
+ /** Whether the user voted for it. */
330
+ voted: boolean;
331
+ /** Whether the user can vote on it. */
332
+ votable: boolean;
333
+ /** Whether a vote is in flight. */
334
+ voting: boolean;
335
+ /** Why the last vote failed. */
336
+ error: DropByError | null;
337
+ /** Adds the user's vote. */
338
+ vote: () => Promise<void>;
339
+ /** Takes the user's vote back. */
340
+ unvote: () => Promise<void>;
341
+ /** Votes, or takes the vote back. */
342
+ toggle: () => Promise<void>;
343
+ }
344
+ declare const ideaVoteButtonProps: {
345
+ /** The idea to vote on. */
346
+ readonly idea: {
347
+ readonly type: PropType<Idea$1>;
348
+ readonly required: true;
349
+ };
350
+ };
351
+ /** Props for `IdeaVoteButton`; other attributes go to its `button`. */
352
+ type IdeaVoteButtonProps = ExtractPublicPropTypes<typeof ideaVoteButtonProps>;
353
+ /** Slots of `IdeaVoteButton`. */
354
+ interface IdeaVoteButtonSlots {
355
+ /** Your own content, given the vote state, in place of the vote count. */
356
+ default?: (state: IdeaVoteState) => VNode[];
357
+ }
358
+ /**
359
+ * A button that votes for an idea, or takes the vote back. It shows the vote
360
+ * count, is disabled while a vote is in flight or when the user cannot vote,
361
+ * and exposes its state in `aria-pressed`, `aria-busy`, `data-voted` and
362
+ * `data-busy`. Your own `@click` runs first and can cancel the vote with
363
+ * `preventDefault()`; your own `disabled` wins over its own.
364
+ */
365
+ export declare const IdeaVoteButton: PublicComponent<IdeaVoteButtonProps, IdeaVoteButtonSlots>;
366
+ /** What the `PendingAsks` default slot receives. */
367
+ interface PendingAsksState {
368
+ /** The asks waiting for the user. */
369
+ asks: PendingAsksCollection;
370
+ /** The asks' actions. */
371
+ actions: AsksActions;
372
+ }
373
+ declare const pendingAsksProps: {
374
+ /** Passed to each ask's form. */
375
+ readonly fieldsPerStep: {
376
+ readonly type: NumberConstructor;
377
+ readonly default: undefined;
378
+ };
379
+ /** Do not load on mount; call `actions.listPending()` yourself. */
380
+ readonly manualLoad: {
381
+ readonly type: BooleanConstructor;
382
+ readonly default: false;
383
+ };
384
+ };
385
+ /**
386
+ * Props for `PendingAsks`; other attributes go to its `ul`, or to your slot's root
387
+ * element when it has exactly one.
388
+ */
389
+ type PendingAsksProps = ExtractPublicPropTypes<typeof pendingAsksProps>;
390
+ /** Slots of `PendingAsks`. */
391
+ interface PendingAsksSlots {
392
+ /** Your own list, given the asks and their actions, in place of the default. */
393
+ default?: (state: PendingAsksState) => VNode[];
394
+ }
395
+ /**
396
+ * The asks waiting for the user, each an `Ask`, a page at a time. It loads on
397
+ * mount unless `manual-load`, shows the load in `data-status` and `data-empty`,
398
+ * and ends with a "show more asks" item (`data-load-more`) while there are
399
+ * more.
400
+ */
401
+ export declare const PendingAsks: PublicComponent<PendingAsksProps, PendingAsksSlots>;
402
+ export type { AskAnswerValue, AskAnswers, AskFormProps, AskFormSlots, AskFormState, AskProps, AskSlots, ChatAttachmentDraft, ChatAttachmentsToolkit, ChatComposerProps, ChatComposerSlots, ChatComposerState, ChatThreadListProps, ChatThreadListSlots, ChatThreadListState, ChatThreadProps, ChatThreadSlots, ChatThreadState, FeatureProps, FeatureSlots, IdeaListProps, IdeaListSlots, IdeaListState, IdeaProps, IdeaSlots, IdeaVoteButtonProps, IdeaVoteButtonSlots, IdeaVoteState, PendingAsksProps, PendingAsksSlots, PendingAsksState };