@composable-os/pack-forms 0.1.0-beta.12 → 0.1.0-beta.14

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.
@@ -14,14 +14,14 @@ export declare function Question({ item, value, error, onChange, }: {
14
14
  value: DraftValue | undefined;
15
15
  error?: string;
16
16
  onChange: (value: DraftValue) => void;
17
- }): any;
17
+ }): import("react").JSX.Element;
18
18
  /** A form being filled: its questions, what to fix, the spam checks and the send. */
19
19
  export declare function FormFields({ form, filler, Turnstile, sendLabel, }: {
20
20
  form: OpenedForm;
21
21
  filler: Filler;
22
22
  Turnstile?: TurnstileWidget | undefined;
23
23
  sendLabel?: string;
24
- }): any;
24
+ }): import("react").JSX.Element;
25
25
  /**
26
26
  * A form by its address (`slug`), or by a personal link's token (`link`, read once from the page's
27
27
  * address with `takeLinkToken` and kept in memory). `via` says where it is: the business's website
@@ -34,7 +34,7 @@ export declare function FormBlock({ forms, slug, link, via, Turnstile, onSent, }
34
34
  via?: "site" | "app";
35
35
  Turnstile?: TurnstileWidget;
36
36
  onSent?: () => void;
37
- }): any;
37
+ }): import("react").JSX.Element;
38
38
  /**
39
39
  * A signed-in member's own personal link (or a child's they are a guardian of), opened from Needs
40
40
  * your attention by the link's id. Answered once; the item goes from Needs your attention once sent.
@@ -43,4 +43,4 @@ export declare function LinkedFormBlock({ forms, linkId, onSent, }: {
43
43
  forms: Pick<FormsHooks, "useLinkedForm" | "useAnswerLinked">;
44
44
  linkId: string;
45
45
  onSent?: () => void;
46
- }): any;
46
+ }): import("react").JSX.Element;
@@ -10,20 +10,20 @@ export declare function NativeQuestion({ item, value, error, onChange, }: {
10
10
  value: DraftValue | undefined;
11
11
  error?: string | undefined;
12
12
  onChange: (value: DraftValue) => void;
13
- }): any;
13
+ }): import("react").JSX.Element;
14
14
  /** A form being filled: its questions, what to fix, the spam check where asked, and the send. */
15
15
  export declare function NativeFormFields({ form, filler, Turnstile, }: {
16
16
  form: OpenedForm;
17
17
  filler: Filler;
18
18
  Turnstile?: NativeTurnstile | undefined;
19
- }): any;
19
+ }): import("react").JSX.Element;
20
20
  /** A form by its address, in the app. `Turnstile`: the app's widget, for a visitor's public form. */
21
21
  export declare function FormScreen({ forms, slug, Turnstile, onDone, }: {
22
22
  forms: Pick<FormsHooks, "useForm" | "useAnswer">;
23
23
  slug: string;
24
24
  Turnstile?: NativeTurnstile;
25
25
  onDone?: () => void;
26
- }): any;
26
+ }): import("react").JSX.Element;
27
27
  /**
28
28
  * A signed-in member's own personal link (or a child's they are a guardian of), opened from Needs
29
29
  * your attention by the link's id. Answered once; the item goes once sent.
@@ -32,4 +32,4 @@ export declare function LinkedFormScreen({ forms, linkId, onDone, }: {
32
32
  forms: Pick<FormsHooks, "useLinkedForm" | "useAnswerLinked">;
33
33
  linkId: string;
34
34
  onDone?: () => void;
35
- }): any;
35
+ }): import("react").JSX.Element;
@@ -208,7 +208,98 @@ type React = {
208
208
  * `const forms = createFormsHooks({ useQuery, useMutation, useState }, api)`. `api` is the
209
209
  * customer's generated client (signed in, or the public).
210
210
  */
211
- export declare function createFormsHooks<C extends ClientHolding>(react: React, client: C): any;
211
+ export declare function createFormsHooks<C extends ClientHolding>(react: React, client: C): import("@composable-os/client").HooksFor<{
212
+ /**
213
+ * A form as the caller may answer it now: by its address (`slug`), or by a personal link's
214
+ * token (`link`, which opening uses nothing of). Not found when it is not open to them.
215
+ */
216
+ useForm(which: {
217
+ slug: string;
218
+ } | {
219
+ link: string;
220
+ } | null): {
221
+ data: {
222
+ id: string;
223
+ version: number;
224
+ title: string | null;
225
+ questions: {
226
+ items: Record<string, unknown>[];
227
+ };
228
+ thanks: string | null;
229
+ anonymous: boolean;
230
+ turnstile: boolean;
231
+ shown: string | null;
232
+ } | undefined;
233
+ isPending: boolean;
234
+ error: unknown;
235
+ };
236
+ /** The form a signed-in member's own personal link is for (Needs your attention's `linkId`). */
237
+ useLinkedForm(linkId: string | null): {
238
+ data: {
239
+ id: string;
240
+ version: number;
241
+ title: string | null;
242
+ questions: {
243
+ items: Record<string, unknown>[];
244
+ };
245
+ thanks: string | null;
246
+ anonymous: boolean;
247
+ turnstile: boolean;
248
+ shown: string | null;
249
+ } | undefined;
250
+ isPending: boolean;
251
+ error: unknown;
252
+ };
253
+ /**
254
+ * Filling in a form `useForm` opened, and sending it: on the business's website (`site`) or
255
+ * its app (`app`), or by a personal link's token (`link`).
256
+ */
257
+ useAnswer(form: OpenedForm | undefined, way: {
258
+ via: Via;
259
+ link?: string | null;
260
+ }): {
261
+ draft: Readonly<Record<string, DraftValue>>;
262
+ /** The items to draw now, in order (headings and paragraphs among them). */
263
+ items: QuestionItem[];
264
+ /** What to fix, by question key. */
265
+ errors: Readonly<Record<string, string>>;
266
+ /** What the host (or the connection) said, for the form as a whole. */
267
+ problem: Refusal | null;
268
+ status: FillStatus;
269
+ /** The words to show once sent: the form's own thank-you, or a plain one. */
270
+ thanks: string;
271
+ set(key: string, value: DraftValue): void;
272
+ /**
273
+ * Checks the answers as the host will, then sends them. True when the host took them. A
274
+ * refusal stays on the screen (`problem`, `errors`), with the answers as typed.
275
+ */
276
+ send(checks?: SendChecks): Promise<boolean>;
277
+ };
278
+ /** Filling in and sending the form of a signed-in member's own personal link, by its id. */
279
+ useAnswerLinked(form: OpenedForm | undefined, linkId: string | null): {
280
+ draft: Readonly<Record<string, DraftValue>>;
281
+ /** The items to draw now, in order (headings and paragraphs among them). */
282
+ items: QuestionItem[];
283
+ /** What to fix, by question key. */
284
+ errors: Readonly<Record<string, string>>;
285
+ /** What the host (or the connection) said, for the form as a whole. */
286
+ problem: Refusal | null;
287
+ status: FillStatus;
288
+ /** The words to show once sent: the form's own thank-you, or a plain one. */
289
+ thanks: string;
290
+ set(key: string, value: DraftValue): void;
291
+ /**
292
+ * Checks the answers as the host will, then sends them. True when the host took them. A
293
+ * refusal stays on the screen (`problem`, `errors`), with the answers as typed.
294
+ */
295
+ send(checks?: SendChecks): Promise<boolean>;
296
+ };
297
+ }, {
298
+ readonly useForm: readonly ["x.forms.form"];
299
+ readonly useLinkedForm: readonly ["x.forms.linkedForm"];
300
+ readonly useAnswer: readonly ["x.forms.submit"];
301
+ readonly useAnswerLinked: readonly ["x.forms.submitLinked"];
302
+ }, import("@composable-os/client").OperationsOf<C>>;
212
303
  declare function allFormsHooks(react: React, api: FormsClient): {
213
304
  /**
214
305
  * A form as the caller may answer it now: by its address (`slug`), or by a personal link's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composable-os/pack-forms",
3
- "version": "0.1.0-beta.12",
3
+ "version": "0.1.0-beta.14",
4
4
  "license": "FSL-1.1-ALv2",
5
5
  "type": "module",
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "description": "Enquiry, sign-up, survey, feedback and staff forms the business builds and publishes, with every answer in one inbox, linked to the person who sent it."
37
37
  },
38
38
  "dependencies": {
39
- "@composable-os/client": "0.1.0-beta.12",
40
- "@composable-os/sdk": "0.1.0-beta.12"
39
+ "@composable-os/client": "0.1.0-beta.14",
40
+ "@composable-os/sdk": "0.1.0-beta.14"
41
41
  }
42
42
  }